-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
Use simple merkle proof for commit info #6323
Use simple merkle proof for commit info #6323
Conversation
Codecov Report
@@ Coverage Diff @@
## master #6323 +/- ##
==========================================
- Coverage 55.71% 55.69% -0.03%
==========================================
Files 448 448
Lines 26978 26941 -37
==========================================
- Hits 15032 15005 -27
+ Misses 10869 10862 -7
+ Partials 1077 1074 -3 |
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.
Some comments for the reviewers
"github.com/tendermint/iavl" | ||
"github.com/tendermint/tendermint/crypto/merkle" | ||
) | ||
|
||
// MultiStoreProof defines a collection of store proofs in a multi-store |
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.
Note to review: This was for handling the serialized StoreInfos[]
as a proof, which is now removed in favor of a merkle commitment (which scales much better for dozens or more of substores)
func (si storeInfo) Hash() []byte { | ||
// Doesn't write Name, since SimpleHashFromMap() will | ||
// include them via the keys. | ||
bz := si.Core.CommitID.Hash |
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 storeInfo
contains a name and a commitment (hash and version).
This method is not really used to "hash" it in a normal means, but rather pull out the hash that was already inside of it.
In effect, to make a chained proof op work, you would have to take the root hash from the iavlstore and then hash it before feeding it as a value to the merkle simple proof, which makes no sense. We want the simple proof to commit directly to the root hash of the sub stores (not a hash of a hash of a hash... - we are not bitcoin mining).
If anyone intends to use this as a real hashing op (which it never was used as), it must contain the name as well before feeding it to the hasher. In such a case we could rename this to eg. Commitment
, which we would use to feed into commitInfo.Hash()
and commitInfo.ProofOp()
.
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.
Yes, believe this was why the hashing in TM had to be removed. This approach works better. Could you please put the cruz of this comment in the godoc. Namely that this does not actually hash the storeInfo, rather it returns the embedded store hash
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.
Yes, I can definitely add it to the GoDoc. I can also rename the function to make it more explicit that we are not trying to implement the Hasher
interface but just access the substore hash.
Actually I can do both (rename an explain the purpose of the function). Any preferences for names?
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.
Quick doc request, otherwise lgtm 👍
func (si storeInfo) Hash() []byte { | ||
// Doesn't write Name, since SimpleHashFromMap() will | ||
// include them via the keys. | ||
bz := si.Core.CommitID.Hash |
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.
Yes, believe this was why the hashing in TM had to be removed. This approach works better. Could you please put the cruz of this comment in the godoc. Namely that this does not actually hash the storeInfo, rather it returns the embedded store hash
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.
utACK
Nice. |
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.
ACK
Great work @ethanfrey -- please merge latest |
403d922
to
e37e82b
Compare
Thanks for the quick reply everyone 😄 I just rebased on top of latest master, waiting for the CI to do it's magic |
How does automerge work? I rebased and passed all CI tests, but now it says: "Merging is blocked. The base branch restricts merging to authorized users". Looks like someone with write access will have to do so manually. |
Description
Pulling out one part of the logic from #6178 and simplifying the changes
One step towards #5842
Currently we serialize the entire
commitInfo
in the root multistore proofs. This is not even a merkle proof, just all data. Before we can move to ics23 proofs, we need to use merkle proofs that can be transformed to that format (it is just an encoding, not the logic).As discussed a few times with @cwgoes and now @AdityaSripal we use
merkle.SimpleProofsFromMap
to produce the commitment of the root multi store. This can later be converted into ics23 format, but this is a valid, testable step that can be merged to master and is an improvement over current state.closes: #XXXX
Before we can merge this PR, please make sure that all the following items have been
checked off. If any of the checklist items are not applicable, please leave them but
write a little note why.
For contributor use:
docs/
) or specification (x/<module>/spec/
)godoc
comments.Unreleased
section inCHANGELOG.md
Files changed
in the Github PR explorer