-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
implement get proof rpc endpoint #13291
base: main
Are you sure you want to change the base?
Conversation
a19d2f9
to
91ff2b0
Compare
fee4a79
to
c76029b
Compare
c76029b
to
c3f515d
Compare
Add unit tests + remove printlns. @awskii will give a more meaningful review tho. this is not my domain |
0433019
to
3b4808f
Compare
a2c6086
to
970d2c1
Compare
9337a4b
to
b3bc88c
Compare
// | ||
// If the trie does not contain a value for key, the returned proof contains all | ||
// nodes of the longest existing prefix of the key (at least the root node), ending | ||
// with the node that proves the absence of the key. | ||
func (t *Trie) Prove(key []byte, fromLevel int, storage bool) ([][]byte, error) { | ||
func (t *Trie) Prove(key []byte, fromLevel int, storage bool) ([][]byte, []byte, error) { |
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.
Not necessary to rely on Prove
to get the storage value as it can easily be retrieved via stateReader.
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.
Yeah, I'm not sure so we can directly access value here, why not returning it. We wouldn't need stateReader
and would have a ready value 🤔
Isn't this one easier?
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.
As we discussed, I's suggest not returning the value bytes since we don't want the function to do more than it should. If you need the value either use a StateReader, or write another function to traverse the trie and get the value. I did this on my branch:
func (t *Trie) GetAccountNode(key []byte) (value *AccountNode, gotValue bool) {
hex := keybytesToHex(key)
return t.getAccount(t.RootNode, hex, 0)
}
c26e569
to
650dc19
Compare
650dc19
to
89a473b
Compare
a9663ca
to
786cbc8
Compare
// shouldn't happen, but check anyway | ||
return nil, fmt.Errorf("block number is in the future latest=%d requested=%d", latestBlock, blockNr) | ||
} | ||
return api.getProof(ctx, address, storageKeys, rpc.BlockNumberOrHashWithNumber(rpc.BlockNumber(latestBlock)), api.db, api.logger) |
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.
why not to pass already opened RoTx?
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.
Can I use only one and the same of RoTx
everywhere ? 🤔
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.
786cbc8
to
ee64763
Compare
ee64763
to
064242e
Compare
06f3e13
to
d044cdb
Compare
#13201