-
Notifications
You must be signed in to change notification settings - Fork 28
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
Support eth_getProof JSON RPC method #251
base: master
Are you sure you want to change the base?
Conversation
@SergioDemianLerner It'd be interesting to know your thoughts about this RSKIP, specially the verifications for non existing accounts (or storage keys). To me it seems more clear to return empty lists for any of those scenarios
|
also I still need to add some tests cases and code to the spec |
IPs/RSKIP251.md
Outdated
|
||
RSK implements a Unitrie data structure to store all the relevant blockchain data, such as account states and storage values, this particular data structure enables an easy verification of each stored value, just by getting a merkle proof. Currently these proofs are only useful for blockchain nodes, but in order to allow verification of accounts outside the client, we need an additional function delivering us the required proof. | ||
|
||
Combined with a stateRoot (from the blockheader) it enables offline verification of any account or storage-value. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- This sentence should be part of the above paragraph.. the "it" in "it enables" refers to the function mentioned above
- ... enables "offline verification" .. what does "offline" mean?
- Even though it is mentioned in title (and motivation), it is good to explicitly say this is a RPC method in the abstract
IPs/RSKIP251.md
Outdated
|
||
## Motivation | ||
|
||
Offering these function through the RPC-Interface would enable applications to store and send proofs to devices which are not directly connected to the p2p-network and still are able to verify the data. This could be used for mobile applications, which are currently only using a remote client. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
typo these function -> this function
.. there are some other minor typos, we can clean them up later :)
IPs/RSKIP251.md
Outdated
|
||
Offering these function through the RPC-Interface would enable applications to store and send proofs to devices which are not directly connected to the p2p-network and still are able to verify the data. This could be used for mobile applications, which are currently only using a remote client. | ||
|
||
Also it might be useful for L2 solutions. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
move to above paragraph
- balance (QUANTITY) | ||
- codeHash (UNFORMATTED): SHA3 of the code associated to the specifica account (for EOA just retrieve SHA3(EMPTY_BYTE_ARRAY)) | ||
- nonce (QUANTITY) | ||
- storageHash (UNFORMATTED): hash of the code of the account. For a EOA it will return "0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470" == SHA3(EMPTY_BYTE_ARRAY) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hash of "code" -> hash of "value" in storage node/ cell (for the given the storage key)
- codeHash (UNFORMATTED): SHA3 of the code associated to the specifica account (for EOA just retrieve SHA3(EMPTY_BYTE_ARRAY)) | ||
- nonce (QUANTITY) | ||
- storageHash (UNFORMATTED): hash of the code of the account. For a EOA it will return "0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470" == SHA3(EMPTY_BYTE_ARRAY) | ||
- accountProof (UNFORMATED[]): Array of rlp-serialized MerkleTree-Nodes, starting with the stateRoot-Node, following the path of the SHA3(address) as key. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
minor typo unformated -> unformatted
- Storage-entry: | ||
- Key (UNFORMATTED): Requested storage key | ||
- Value (QUANTITY): Value contained for that key | ||
- Proof (UNFORMATED[]): Array of rlp-serialized MerkleTree-Nodes, starting with the storageHash-Node, following the path of the SHA3(key) as path. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
minor typo unformated -> unformatted
- Value (QUANTITY): Value contained for that key | ||
- Proof (UNFORMATED[]): Array of rlp-serialized MerkleTree-Nodes, starting with the storageHash-Node, following the path of the SHA3(key) as path. | ||
|
||
Each unitrie node should be serialized as described in the [RSKIP107](https://github.com/rsksmart/RSKIPs/blob/master/IPs/RSKIP107.md) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
how/why is the serialization relevant for the RPC method?
|
||
Each unitrie node should be serialized as described in the [RSKIP107](https://github.com/rsksmart/RSKIPs/blob/master/IPs/RSKIP107.md) | ||
|
||
### Address or storage non existent values |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please change the order, start with Non existent .. e.g. Non existent addresses or storage values
|
||
### Address or storage non existent values | ||
|
||
If a non-existent address or key from storage is requested, we’ll need to provide enough information to verify that ausence from the outside world. For example, a non existing key will lead to a different node. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- ausence -> absence?
- a non existent key will lead to different node .. I don't follow what different trie node means
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
unclear meaning of this paragraph.
Do you want to receive a proof of non-membership ?
|
||
Note that this is not the same as requesting with wrong parameters, if those params are invalid, we just need to respond as a failed request. | ||
|
||
## References |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These references numbers should be marked in the text where they are cited. For example, it would be nice to cite [1] in the abstract when talking about Merkle proofs for state data
Hey Fede, we can approve the PR, but we will merge it only after Sergio has some time to review it, since you marked him specifically :) |
The method eth_getProof() is added to the RPC interface. The method returns the account and storage-values of the specified account including the Merkle-proof. | ||
|
||
Params | ||
- address (UNFORMATTED) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
which is the name of the field?
|
||
Params | ||
- address (UNFORMATTED) | ||
- storage keys that we want to prove (if needed) (UNFORMATTED[]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same here. This field should have a name, right ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is address specified but starageKeys is omitted ? Are both optional ?
- nonce (QUANTITY) | ||
- storageHash (UNFORMATTED): hash of the code of the account. For a EOA it will return "0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470" == SHA3(EMPTY_BYTE_ARRAY) | ||
- accountProof (UNFORMATED[]): Array of rlp-serialized MerkleTree-Nodes, starting with the stateRoot-Node, following the path of the SHA3(address) as key. | ||
- storageProof: Array of storage-entries as requested. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this proof given for the account or for the storage keys given as arguments? It's unclear
|
||
### Address or storage non existent values | ||
|
||
If a non-existent address or key from storage is requested, we’ll need to provide enough information to verify that ausence from the outside world. For example, a non existing key will lead to a different node. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
unclear meaning of this paragraph.
Do you want to receive a proof of non-membership ?
@fedejinich this PR has stagnated for a long time. When you get the chance, please update it to address some of the major comments, so we can merge the PR. Further discussions can then happen on the RSK research forum. |
Introducing a new JSON RPC method to retrieve merkle proofs from the JSON RPC layer. Useful for state verifications