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

Support eth_getProof JSON RPC method #251

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all 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
71 changes: 71 additions & 0 deletions IPs/RSKIP251.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
# Support eth_getProof JSON RPC method

|RSKIP |251 |
| :------------ |:-------------|
|**Title** |Support eth_getProof JSON RPC method |
|**Created** |30-06-2021 |
|**Author** |FJ |
|**Purpose** |Usa,Sec |
|**Layer** |Core |
|**Complexity** |1 |
|**Status** |Draft |

## Abstract

RSK implements a Unitrie data structure to store all the relevant blockchain state data, such as account balances and storage values. This data structure enables an easy verification of each stored value, using (also called Merkle proofs). Currently these proofs are only used inside blockchain nodes, but in order to allow verification of accounts outside the client, we need an additional method to deliver the proofs.

Combined with a stateRoot (which can be obtained from the blockheader), a Merkle proof enables the offline verification of any account or storage-value.

## Motivation

A method to provide Merkle proofs 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 phones running lightweight nodes.

The method could also be useful for layer 2 solutions.

## Specification

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)
Copy link
Collaborator

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?

- storage keys that we want to prove (if needed) (UNFORMATTED[])
Copy link
Collaborator

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 ?

Copy link
Collaborator

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 ?

- block number, block hash or an id (such as “earliest” or “latest”) (UNFORMATTED)|(TAG)

As response we’ll receive an Account object, composed by:

- 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)
Copy link
Contributor

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)

- accountProof (UNFORMATED[]): Array of rlp-serialized MerkleTree-Nodes, starting with the stateRoot-Node, following the path of the SHA3(address) as key.
Copy link
Contributor

Choose a reason for hiding this comment

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

minor typo unformated -> unformatted

- storageProof: Array of storage-entries as requested.
Copy link
Collaborator

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

- 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.
Copy link
Contributor

Choose a reason for hiding this comment

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

minor typo unformated -> unformatted


Each unitrie node should be serialized as described in the [RSKIP107](https://github.com/rsksmart/RSKIPs/blob/master/IPs/RSKIP107.md)
Copy link
Contributor

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?


### Address or storage non existent values
Copy link
Contributor

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


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.
Copy link
Contributor

Choose a reason for hiding this comment

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

  1. ausence -> absence?
  2. a non existent key will lead to different node .. I don't follow what different trie node means

Copy link
Collaborator

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
Copy link
Contributor

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


[1] EIP-1186 https://eips.ethereum.org/EIPS/eip-1186

[2] https://blog.rsk.co/noticia/towards-higher-onchain-scalability-with-the-unitrie/

[3] https://github.com/ethereum/EIPs/issues/1186

[4] https://github.com/rsksmart/RSKIPs/blob/master/IPs/RSKIP107.md

[5] https://github.com/rsksmart/rskj/issues/1493



### Copyright

Copyright and related rights waived via [CC0](https://creativecommons.org/publicdomain/zero/1.0/).