You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Unclear is what exactly these ProofOp types are and what they mean.
Digging in deeper, we can see the iavl_value_proof defines one operation to represent the entire range proof for one value:
typeIAVLValueOpstruct {
// Encoded in ProofOp.Key.key []byte// To encode in ProofOp.Data.Proof*RangeProof`json:"proof"`
}
...func (opIAVLValueOp) ProofOp() merkle.ProofOp {
bz:=cdc.MustMarshalBinaryLengthPrefixed(op)
return merkle.ProofOp{
Type: ProofOpIAVLValue,
Key: op.key,
Data: bz,
}
}
With the actual range proof, being an iavl-specific internal structure, encoded with go-amino. I cannot see this code actually called, however.
In an attempt to see this in practice, I will look at the canonical abci app, cosmos-sdk.
This may work fine if both client and server are golang and importing the iavl codebase, but I see trouble with handling these not-well-defined proofs in eg. a javascript client.
Final conclusion from this deep-dive in cosmos code:
Raw proof structures are available in tendermint/iavl
There is a "standard format" to encode them
This "standard format" currently stores enormous opaque blobs that cannot be parse in another language
We should define a simpler RangeProof -> merkle.ProofOp[] mapping that can be defined in terms of simpler primitives (concat, sha256, etc)
The case of one item is collapsed into a subset of range proof. Let us define a simple-to-parse struct for the one-key-present case, then the one-key-missing case, then the larger range proof, then secondary index proofs.... Each one can be it's own issue and should be well defined to be able to validate from non-go code without access to any custom libraries
The text was updated successfully, but these errors were encountered:
We should aim for as much compatibility with cosmos-sdk/tendermint as possible in the proof format, as it would allow us to one day also implement a compatible ibc module. It seems like there is some progress recently on defining a canonical merkle proof format that we can adopt internally (or maybe get for "free" from iavl implementation).
we want to use a format compatible with tendermint, and ideally cosmos-sdk, to make it easier to support ibc.
Starting from tendermint rpc... let's track down the proof format...
Rpc call returns the abciQuery object (as json)
func ABCIQuery(ctx *rpctypes.Context, path string, data cmn.HexBytes, height int64, prove bool) (*ctypes.ResultABCIQuery, error)
Abci definition
merkle.Proof format
Unclear is what exactly these ProofOp types are and what they mean.
Digging in deeper, we can see the iavl_value_proof defines one operation to represent the entire range proof for one value:
With the actual range proof, being an iavl-specific internal structure, encoded with go-amino. I cannot see this code actually called, however.
In an attempt to see this in practice, I will look at the canonical abci app, cosmos-sdk.
Look at their BaseApp.Query entry point.
Which will route the query to the data store if the prefix is "/store"
It seems that rootmulti.Store is the default
app.cms
implementation, with the actual Query functionWhich takes the QueryResult of a substore, and appends a special "multistore proof op":
And finally, we dig into the Query method of the Iavl sub-store, and see the proof formation:
So, basically, we just call MutableTree.GetVersionedWithProof and then serialize the returned RangeProof into a custom format.
This may work fine if both client and server are golang and importing the iavl codebase, but I see trouble with handling these not-well-defined proofs in eg. a javascript client.
Final conclusion from this deep-dive in cosmos code:
The text was updated successfully, but these errors were encountered: