Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: getAccount #10402

Merged
merged 3 commits into from
Aug 21, 2024
Merged

fix: getAccount #10402

merged 3 commits into from
Aug 21, 2024

Conversation

greged93
Copy link
Contributor

After checking out the implementation of the endpoint by Geth and Nethermind, I believe we should be returning an None value if the account if not found in the state.

Example:

curl https://docs-demo.quiknode.pro/ \                                                                                                                                                                                                                                    130 ↵
  --header 'Content-Type: application/json' \
  --data '{
      "method": "eth_getAccount",
      "params":["0x8D97689C9818892B700e27F316cc3E41e17fBebf", "latest"],
      "id": 1,
      "jsonrpc": "2.0"
}'

Returns null.

Copy link
Collaborator

@mattsse mattsse left a comment

Choose a reason for hiding this comment

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

nice, smol nits

let nonce = account.nonce;
let code_hash = account.bytecode_hash.unwrap_or(KECCAK_EMPTY);
let account = state.basic_account(address).map_err(Self::Error::from_eth_err)?;
if let Some(account) = account {
Copy link
Collaborator

Choose a reason for hiding this comment

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

styl nit:

let use let Some() else {return Ok(None)} here to get rid of the scope


let account = eth_api.get_account(address, Default::default()).await.unwrap();
let expected_account =
alloy_consensus::Account { code_hash: KECCAK_EMPTY, ..Default::default() };
Copy link
Collaborator

Choose a reason for hiding this comment

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

I believe this is available from the reth-rpc-types crate so we don't need the alloy-consensus dep here

Copy link
Collaborator

Choose a reason for hiding this comment

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

this test case can also be added as an additional call here

EthApiClient::accounts(client).await.unwrap();

crates/rpc/rpc-eth-api/src/helpers/state.rs Outdated Show resolved Hide resolved
@mattsse mattsse added this pull request to the merge queue Aug 21, 2024
@mattsse mattsse added C-bug An unexpected or incorrect behavior A-rpc Related to the RPC implementation labels Aug 21, 2024
Merged via the queue into paradigmxyz:main with commit 1f5fb90 Aug 21, 2024
34 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-rpc Related to the RPC implementation C-bug An unexpected or incorrect behavior
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants