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

Define eth_account #329

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions src/eth/state.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -84,3 +84,18 @@
name: Account
schema:
$ref: '#/components/schemas/AccountProof'
- name: eth_getAccount
summary: Returns the account at given address, or 'null' if the account does not exist in the state.
params:
- name: Address
required: true
schema:
$ref: '#/components/schemas/address'
- name: Block
required: false
schema:
$ref: '#/components/schemas/BlockNumberOrTag'
result:
name: Account
schema:
lightclient marked this conversation as resolved.
Show resolved Hide resolved
$ref: '#/components/schemas/Account'
21 changes: 21 additions & 0 deletions src/schemas/state.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -54,3 +54,24 @@ StorageProof:
type: array
items:
$ref: '#/components/schemas/bytes'
Account:
title: Account
type: object
required:
Copy link

Choose a reason for hiding this comment

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

Propose including the blockHash this was resolved from to the return value to support the case that a tag was the block param passed in. If the EL is providing the account state as of the "latest" block, the caller likely has no idea what block that is. This api is not in the engine API so we can't assume the caller is aware of current chain state.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Myeah, that makes sense... but IMO it doesn't belong in the Account object, but rather as a metadata along with the account.
so maybe something like this?

{
    "blockHash": "0x...", 
    "stateRoot":  "...", 
    "account": { ... }
}

Copy link

Choose a reason for hiding this comment

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

yeah, much better. agreed.

Copy link
Member

Choose a reason for hiding this comment

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

I think we already have this issue with all the other state reading methods, such as eth_getBalance, eth_getTransactionCount, etc. I think it is better to retain consistency with the other methods and in the future possible move them all to this format above.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, I agree with @lightclient

- root
holiman marked this conversation as resolved.
Show resolved Hide resolved
- balance
- nonce
- codeHash
properties:
root:
holiman marked this conversation as resolved.
Show resolved Hide resolved
title: storage root
$ref: '#/components/schemas/hash32'
balance:
title: balance
$ref: '#/components/schemas/uint256'
codeHash:
title: codeHash
$ref: '#/components/schemas/hash32'
nonce:
title: nonce
$ref: '#/components/schemas/uint64'
6 changes: 6 additions & 0 deletions tests/eth_getAccount/get-account.io
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
>> {"jsonrpc":"2.0","id":9,"method":"eth_getAccount","params":["0x000000000000000000000000000000000000dead","latest"]}
<< {"jsonrpc":"2.0","id":9,"result": null}
>> {"jsonrpc":"2.0","id":10,"method":"eth_getAccount","params":["0xaa00000000000000000000000000000000000000","latest"]}
<< {"jsonrpc":"2.0","id":10,"result": { "codeHash": "0xce92c756baff35fa740c3557c1a971fd24d2d35b7c8e067880d50cd86bb0bc99", "root": "0x8afc95b7d18a226944b9c2070b6bda1c3a36afcc3730429d47579c94b9fe5850", "balance": "0x1", "nonce": "0x1"}}
holiman marked this conversation as resolved.
Show resolved Hide resolved
>> {"jsonrpc":"2.0","id":11,"method":"eth_getAccount","params":["0xaa00000000000000000000000000000000000000","0xffff"]}
<< {"jsonrpc":"2.0","id":11,"error":{"code":-32000,"message":"header not found"}}