Conversation
mossid
left a comment
There was a problem hiding this comment.
Few modifications requested, LGTM.
crypto/merkle/proof.go
Outdated
| // Extension of ProofOp (defined in merkle.proto) | ||
|
|
||
| func (po ProofOp) Bytes() []byte { | ||
| bz, err := amino.MarshalBinary(po) |
There was a problem hiding this comment.
Also, we maybe don't need this function if ProofOpis a member of abci.ResponseQuery because proto will handle marshaling.
| if !bytes.Equal(root, args[0]) { | ||
| return cmn.NewError("Calculated root hash is invalid: expected %+v but %+v", root, args[0]) | ||
| } | ||
| return nil |
There was a problem hiding this comment.
We have to check len(keys) == 0 before returning nil
crypto/merkle/proof.go
Outdated
| } | ||
| } | ||
|
|
||
| func (prt *ProofRuntime) RegisterAminoOpDecoder(typ string, opType reflect.Type) { |
There was a problem hiding this comment.
Maybe better to have generator function instead of reflect.Type?
There was a problem hiding this comment.
I think this is fine, esp for something called AminoOpDecoder.
| computedHash := computeHashFromAunts(index, total, leafHash, sp.Aunts) | ||
| return computedHash != nil && bytes.Equal(computedHash, rootHash) | ||
| // Verify that the SimpleProof proves the root hash. | ||
| func (sp *SimpleProof) Verify(rootHash []byte, index int, total int, leafHash []byte) error { |
There was a problem hiding this comment.
Can we exclude index int, total int, leafHash []byte from the argument list? The fields are exported, the user can check it manually when they need to. Or we can make a new method like Validate to check the fields' validity.
There was a problem hiding this comment.
I think we can exclude index/total, but we should leave rootHash and leafHash. The other two we can expose GetIndex() and GetTotal(). We should add a comment that the user should check these if they need to verify this info.
Codecov Report
@@ Coverage Diff @@
## jae/literefactor4 #1912 +/- ##
=====================================================
- Coverage 61.24% 60.06% -1.19%
=====================================================
Files 191 162 -29
Lines 15421 13527 -1894
=====================================================
- Hits 9445 8125 -1320
+ Misses 5128 4649 -479
+ Partials 848 753 -95
|
| version = "~0.10.1" | ||
|
|
||
| [[constraint]] | ||
| name = "github.com/tendermint/iavl" |
There was a problem hiding this comment.
Talked to bucky recently and figured we'll move it into tendermint/tendermint because it's useful to have them for the abci/example/kvstore app.
There was a problem hiding this comment.
Truth is that it will still be much more convenient to have it in the SDK as that is where it is primarily used and thus putting it there will maximally reduce developer overhead when changes need to be made. So I'd still advocate for putting it in the SDK and not requiring it in Tendermint if possible
| type State struct { | ||
| db dbm.DB | ||
| db dbm.DB | ||
| tree *iavl.VersionedTree |
crypto/merkle/proof_key_path_test.go
Outdated
| var path KeyPath | ||
| keys := make([][]byte, 10) | ||
|
|
||
| for d := 0; d < 20; d++ { |
liamsi
left a comment
There was a problem hiding this comment.
1st pass while going through the changes. Will follow up with a more detailed review shortly.
| bytes key = 6; | ||
| bytes value = 7; | ||
| bytes proof = 8; | ||
| merkle.Proof proof = 8; |
There was a problem hiding this comment.
Note: This will be breaking.
| protoc --gogo_out=. -I $GOPATH/src/ -I . -I $GOPATH/src/github.com/gogo/protobuf/protobuf merkle.proto | ||
| echo "--> adding nolint declarations to protobuf generated files" | ||
| awk '/package merkle/ { print "//nolint: gas"; print; next }1' merkle.pb.go > merkle.pb.go.new | ||
| mv merkle.pb.go.new merkle.pb.go |
There was a problem hiding this comment.
Nit: proto files often are compiled using a gen.go file. See here for example: https://github.com/google/trillian/blob/e856bae55959e54d2e480790d7c881aced7a4b5c/gen.go#L15-L24
Not sure if this works with gogoproto though.
|
|
||
| func RegisterWire(cdc *amino.Codec) { | ||
| // Nothing to do. | ||
| } |
There was a problem hiding this comment.
As far as I see, this file's only intention is to provide a global variable which does not hold any state. Should we remove RegisterWire and Seal the codec instead?
|
|
||
| NOTE: Punycode will never be supported here, because not all values can be | ||
| decoded. For example, no string decodes to the string "xn--blah" in | ||
| Punycode. |
There was a problem hiding this comment.
Maybe I should continue reading first but if it is unsupported / disallowed, it would be great to have a test-case showing what happens if punycode is used.
| // ProofOp gets converted to an instance of ProofOperator: | ||
|
|
||
| type ProofOperator interface { | ||
| Run([][]byte) ([][]byte, error) |
There was a problem hiding this comment.
As someone not involved in the reasoning / design of these changes, it is unclear what Run will do (and what it will return) in this context.
| // (which will result in a proof being returned). | ||
| var DefaultABCIQueryOptions = ABCIQueryOptions{Height: 0, Trusted: false} | ||
| // DefaultABCIQueryOptions are latest height (0) and prove false. | ||
| var DefaultABCIQueryOptions = ABCIQueryOptions{Height: 0, Prove: false} |
There was a problem hiding this comment.
Wouldn't the equivalent of Trusted: false be Prove: true instead?
|
Also linking #2052 as both PRs have |
|
@mossid I'll submit a PR to resolve above merge conflicts (I'm not if I can push here directly). I'll do so without changing above base branch @mossid: I think the easiest way to unblock yourself on the outdated protofiles / merge conflicts would be to cherrypick the latest two commits from: https://github.com/tendermint/tendermint/compare/jae/literefactor4...Liamsi:jae/generalmerkle?expand=1 These changes resolve the merge conflicts, regenerate all relevant protos. They also contain some changes to gogoproto params (and consequential changes). Let me know if this works for you. |
|
|
||
| for i, op := range poz { | ||
| key := op.GetKey() | ||
| if len(key) != 0 { |
There was a problem hiding this comment.
Can we add the code for checking the length of the remaining keys for preventing panic if the keypath is too short?
|
Closing for #2298 |
Related:
cosmos/iavl#84edit(@liamsi): cosmos/iavl#85