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

store: add proof to ViewState response #7593

Merged
merged 14 commits into from
Sep 9, 2022

Conversation

blasrodri
Copy link
Contributor

@blasrodri blasrodri commented Sep 9, 2022

Introduce visited_nodes to TrieIterator which records raw bytes of all
the nodes the iterator visits. Those are then returned as proof in
response to ViewState request. Since the exact nodes the iterator
visited are included in the proof, it is therefore possible to verify
all the values returned in the state.

At the moment the proof is always included.

Fixes: #2076

@blasrodri blasrodri requested a review from a team as a code owner September 9, 2022 07:13
@blasrodri blasrodri changed the title Mpt proof rework Trie (non)-membership proofs v2 Sep 9, 2022
@blasrodri
Copy link
Contributor Author

@mina86 I think I've broken something when merging master. Can you take a look?

@mina86 mina86 requested review from mina86 and removed request for mm-near September 9, 2022 11:08
core/store/src/trie/mod.rs Outdated Show resolved Hide resolved
core/store/src/trie/iterator.rs Outdated Show resolved Hide resolved
@mina86
Copy link
Contributor

mina86 commented Sep 9, 2022

cutting one element (the last) element to the proof works (!)

Yes, that’s expected. Previously iterator would fetch an unnecessary node which ended up included in the proof. With the seek_prefix change this no longer happens and the proof is one node shorter.

@mina86 mina86 changed the title Trie (non)-membership proofs v2 store: add proof to ViewState response Sep 9, 2022
Copy link
Contributor

@mina86 mina86 left a comment

Choose a reason for hiding this comment

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

Great, thanks!

Sorry it took so long, but it turned out to be more convoluted than it appeared at first sight. Especially since it is part of public API and we had the whole borsh red herring at the beginning. But we’re finally here! \o/

@near-bulldozer near-bulldozer bot merged commit faa1811 into near:master Sep 9, 2022
@blasrodri
Copy link
Contributor Author

Great, thanks!

Sorry it took so long, but it turned out to be more convoluted than it appeared at first sight. Especially since it is part of public API and we had the whole borsh red herring at the beginning. But we’re finally here! \o/

I'm going to cry! Thanks for your support @mina86

nikurt pushed a commit that referenced this pull request Nov 9, 2022
Introduce visited_nodes to TrieIterator which records raw bytes of all
the nodes the iterator visits.  Those are then returned as proof in
response to ViewState request.  Since the exact nodes the iterator
visited are included in the proof, it is therefore possible to verify
all the values returned in the state.

At the moment the proof is always included.

Fixes: #2076
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Contract state should provide proofs from state root
3 participants