-
Notifications
You must be signed in to change notification settings - Fork 115
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
Implementation of Nimbus eth_getProof RPC Endpoint. #1960
Conversation
nimbus/db/distinct_tries.nim
Outdated
@@ -1,5 +1,5 @@ | |||
# Nimbus | |||
# Copyright (c) 2023 Status Research & Development GmbH | |||
# Copyright (c) 2024 Status Research & Development GmbH |
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 the correct way to update the copyright notice? Or should it be 2023-2024?
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.
2023-2024
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.
Thanks, I'll update in that case.
rootHash | ||
rootHash, | ||
getAccountProof, | ||
getStorageProof |
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.
Exporting the new proof procs to be used with the ReadOnlyStateDB type.
|
||
# This implementation of getBranch on the CoreDbPhkRef type is a temporary solution | ||
# which can be removed once we get an equivient proc defined on the CoreDbPhkRef type | ||
# in the db layer. |
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 code was copied from the HexaryTrie library in order to implement getBranch on the CoreDbPhkRef type.
@@ -249,6 +253,29 @@ proc isDeadAccount*(db: AccountStateDB, address: EthAddress): bool = | |||
else: | |||
result = true | |||
|
|||
proc removeEmptyRlpNode(branch: var seq[MptNodeRlpBytes]) = | |||
if branch.len() == 1 and branch[0] == emptyRlp: | |||
branch.del(0) |
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.
The getBranch code returns a single node with a value of emptyRlp (zero encoded as rlp) if the trie state is empty. We remove this because this isn't a valid proof and causes the proof verification to fail. Also Geth returns an empty list in this case so we do the same.
ProofResponse( | ||
address: w3Addr(address), | ||
accountProof: seq[RlpEncodedBytes](accountProof), | ||
storageProof: storage) |
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.
We return zero values (default values) for the account if the account doesn't exist, including the codeHash and storageHash.
looks good to me |
Great. Planning to merge it after I update the copyright notices. |
This PR includes changes to implement the eth_getProof RPC endpoint implemented as follows:
Here is the link to the spec: https://eips.ethereum.org/EIPS/eip-1186. Note that the spec is in the 'Stagnant' state so it was never moved to final.