Skip to content
This repository has been archived by the owner on Nov 6, 2020. It is now read-only.

[light/jsonrpc] Provide the actual account for eth_coinbase RPC and unify error handeling for light and full client #9383

Merged
merged 6 commits into from
Sep 5, 2018

Conversation

niklasad1
Copy link
Collaborator

The previous implementation always provided the zero address on
eth_coinbase RPCs.
Now instead, the actual address is returned on
success and an error when no accounts are found!

Note, this behavior is different from the full client where we return the zero address if no accounts are found!

Manual tests

Account exists

$  curl --data '{"method":"eth_coinbase","params":[],"id":1,"jsonrpc":"2.0"}' -H "Content-Type: application/json" -X POST localhost:8545
{"jsonrpc":"2.0","result":"0x006e87b3369ab27991cbc8461641db4e7435e139","id":1}

Account doesn't exist

curl --data '{"method":"eth_coinbase","params":[],"id":1,"jsonrpc":"2.0"}' -H "Content-Type: application/json" -X POST localhost:8545
{"jsonrpc":"2.0","error":{"code":-32023,"message":"No accounts were found","data":"\"\""},"id":1}

@niklasad1 niklasad1 added A0-pleasereview 🤓 Pull request needs code review. B0-patchthis M4-core ⛓ Core client code / Rust. M6-rpcapi 📣 RPC API. labels Aug 20, 2018
@5chdn 5chdn added this to the 2.1 milestone Aug 23, 2018
@5chdn 5chdn mentioned this pull request Aug 23, 2018
28 tasks
@sorpaas
Copy link
Collaborator

sorpaas commented Aug 28, 2018

@niklasad1 Do you think it would be a good idea to align full client and light client behavior? Change light client to return zero address when not found, or change full client to return error when not found?

@niklasad1
Copy link
Collaborator Author

niklasad1 commented Aug 28, 2018

@sorpaas

Yeah, I think we should align the behavior in the full and light client but I don't like the behavior of returning the zero address to indicate errors. So, I would want to return errors in both clients however it might make the RPC futures a bit harder to code!

@sorpaas
Copy link
Collaborator

sorpaas commented Aug 28, 2018

We've already modified eth_getLogs similarly (return errors when parameters are not found). So I think just changing full node's behavior may be fine if we state it clearly in changelogs.

cc @5chdn @tomusdrw

@sorpaas sorpaas added the B7-releasenotes 📜 Changes should be mentioned in the release notes of the next minor version release. label Aug 28, 2018
@tomusdrw
Copy link
Collaborator

Yeah, we should have both methods aligned. I'm ok to include that in the relnotes, "the RPC spec" doesn't really describe error conditions at all (I guess that's the reason we didn't return many errors in the past), so there is much room for improvement here.

I'm ok with returning an error, but we should also document all the error conditions in wiki in some nice readable and consistent format.

@@ -252,7 +252,15 @@ impl<T: LightChainClient + 'static> Eth for EthClient<T> {
}

fn author(&self) -> Result<RpcH160> {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just for my education: what is the reason for rpc-specific hashtypes like RpcH160?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Historical reasons - hash types were not JSON-serializable in the past, I think currently we could get rid of the wrappers and just use the regular types

@niklasad1 niklasad1 force-pushed the light/provide-account-eth_coinbase branch from 45dc28b to cda2a76 Compare August 28, 2018 16:12
@niklasad1 niklasad1 changed the title [light/jsonrpc] Provide the actual account for eth_coinbase RPC [light/jsonrpc] Provide the actual account for eth_coinbase RPC and unify error handeling for light and full client Aug 30, 2018
@niklasad1 niklasad1 force-pushed the light/provide-account-eth_coinbase branch from cda2a76 to 0150a2f Compare August 30, 2018 08:58
@5chdn 5chdn mentioned this pull request Aug 31, 2018
8 tasks
The previous implementation always provided the `zero address` on
`eth_coinbase` RPC. Now, instead the actual address is returned on
success or an error when no account(s) is found!
In the full-client return an error when no account is found instead of
returning the `zero address`
@niklasad1 niklasad1 force-pushed the light/provide-account-eth_coinbase branch from 0150a2f to bc05784 Compare September 1, 2018 15:23
Copy link
Contributor

@cheme cheme left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good.

@ordian ordian added A8-looksgood 🦄 Pull request is reviewed well. and removed A0-pleasereview 🤓 Pull request needs code review. labels Sep 5, 2018
@cheme cheme merged commit dca88ff into master Sep 5, 2018
@ordian ordian deleted the light/provide-account-eth_coinbase branch September 5, 2018 17:21
5chdn pushed a commit that referenced this pull request Sep 6, 2018
… unify error handeling for light and full client (#9383)

* Provide the actual `account` for eth_coinbase

The previous implementation always provided the `zero address` on
`eth_coinbase` RPC. Now, instead the actual address is returned on
success or an error when no account(s) is found!

* full client `eth_coinbase` return err

In the full-client return an error when no account is found instead of
returning the `zero address`

* Remove needless blocks on single import

* Remove needless `static` lifetime on const

* Fix `rpc_eth_author` test
5chdn added a commit that referenced this pull request Sep 10, 2018
* parity-version: bump beta to 2.0.4

* [light/jsonrpc] Provide the actual account for `eth_coinbase` RPC and unify error handeling for light and full client (#9383)

* Provide the actual `account` for eth_coinbase

The previous implementation always provided the `zero address` on
`eth_coinbase` RPC. Now, instead the actual address is returned on
success or an error when no account(s) is found!

* full client `eth_coinbase` return err

In the full-client return an error when no account is found instead of
returning the `zero address`

* Remove needless blocks on single import

* Remove needless `static` lifetime on const

* Fix `rpc_eth_author` test

* parity: print correct keys path on startup (#9501)

* aura: don't report skipped primaries when empty steps are enabled (#9435)

* Only check warp syncing for eth_getWorks (#9484)

* Only check warp syncing for eth_getWorks

* Use SyncStatus::is_snapshot_syncing

* Fix Snapshot restoration failure on Windows (#9491)

* Close Blooms DB files before DB restoration

* PR Grumbles I

* PR Grumble

* Grumble
phahulin added a commit to poanetwork/eth-net-intelligence-api that referenced this pull request Nov 9, 2018
Newer versions of parity don't return zero address in `eth_coinbase` when no accounts exist (openethereum/parity-ethereum#9383). It prevents netstats agent from obtaining correct node version info.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
A8-looksgood 🦄 Pull request is reviewed well. B7-releasenotes 📜 Changes should be mentioned in the release notes of the next minor version release. M4-core ⛓ Core client code / Rust. M6-rpcapi 📣 RPC API.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants