Fix general merkle keypath to start w/ last op's key#2733
Merged
Conversation
Codecov Report
@@ Coverage Diff @@
## develop #2733 +/- ##
==========================================
Coverage ? 62.32%
==========================================
Files ? 211
Lines ? 17055
Branches ? 0
==========================================
Hits ? 10630
Misses ? 5552
Partials ? 873
|
melekes
reviewed
Oct 31, 2018
| if len(key) != 0 { | ||
| if !bytes.Equal(keys[0], key) { | ||
| return cmn.NewError("Key mismatch on operation #%d: expected %+v but %+v", i, []byte(keys[0]), []byte(key)) | ||
| lastKey := keys[len(keys)-1] |
Contributor
There was a problem hiding this comment.
should we check that len(keys) > 0 especially when we're modifying them later keys = keys[:len(keys)-1]
Contributor
There was a problem hiding this comment.
KeyPathToKeys ensures that the keys aren't empty, unless there's an error
Contributor
ebuchman
approved these changes
Oct 31, 2018
| if len(key) != 0 { | ||
| if !bytes.Equal(keys[0], key) { | ||
| return cmn.NewError("Key mismatch on operation #%d: expected %+v but %+v", i, []byte(keys[0]), []byte(key)) | ||
| lastKey := keys[len(keys)-1] |
Contributor
There was a problem hiding this comment.
KeyPathToKeys ensures that the keys aren't empty, unless there's an error
| op3 := NewDominoOp("", "INPUT3", "INPUT4") | ||
| op4 := NewDominoOp("KEY4", "INPUT4", "OUTPUT4") | ||
|
|
||
| // Good |
Contributor
There was a problem hiding this comment.
would make a good table driven test
Contributor
|
Oh nvm, we haven't even written the keypath spec ... |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
General Merkle ProofOperator was iterating over the keys in the wrong order. The keypath should start with the last operation to run (e.g. the top-level root hash operation), not end with it.
NOTE: This is related to https://github.com/cosmos/cosmos-sdk/pull/2633/files