mirror of
https://github.com/fluencelabs/tendermint
synced 2025-06-11 12:21:20 +00:00
lite: comment out iavl code - TODO #1183
This commit is contained in:
@ -4,7 +4,6 @@ import (
|
|||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
|
|
||||||
"github.com/tendermint/go-wire/data"
|
"github.com/tendermint/go-wire/data"
|
||||||
"github.com/tendermint/iavl"
|
|
||||||
|
|
||||||
"github.com/tendermint/tendermint/lite"
|
"github.com/tendermint/tendermint/lite"
|
||||||
"github.com/tendermint/tendermint/lite/client"
|
"github.com/tendermint/tendermint/lite/client"
|
||||||
@ -13,6 +12,20 @@ import (
|
|||||||
ctypes "github.com/tendermint/tendermint/rpc/core/types"
|
ctypes "github.com/tendermint/tendermint/rpc/core/types"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// KeyProof represents a proof of existence or absence of a single key.
|
||||||
|
// Copied from iavl repo. TODO
|
||||||
|
type KeyProof interface {
|
||||||
|
// Verify verfies the proof is valid. To verify absence,
|
||||||
|
// the value should be nil.
|
||||||
|
Verify(key, value, root []byte) error
|
||||||
|
|
||||||
|
// Root returns the root hash of the proof.
|
||||||
|
Root() []byte
|
||||||
|
|
||||||
|
// Serialize itself
|
||||||
|
Bytes() []byte
|
||||||
|
}
|
||||||
|
|
||||||
// GetWithProof will query the key on the given node, and verify it has
|
// GetWithProof will query the key on the given node, and verify it has
|
||||||
// a valid proof, as defined by the certifier.
|
// a valid proof, as defined by the certifier.
|
||||||
//
|
//
|
||||||
@ -21,7 +34,7 @@ import (
|
|||||||
// If val is empty, proof should be KeyMissingProof
|
// If val is empty, proof should be KeyMissingProof
|
||||||
func GetWithProof(key []byte, reqHeight int64, node rpcclient.Client,
|
func GetWithProof(key []byte, reqHeight int64, node rpcclient.Client,
|
||||||
cert lite.Certifier) (
|
cert lite.Certifier) (
|
||||||
val data.Bytes, height int64, proof iavl.KeyProof, err error) {
|
val data.Bytes, height int64, proof KeyProof, err error) {
|
||||||
|
|
||||||
if reqHeight < 0 {
|
if reqHeight < 0 {
|
||||||
err = errors.Errorf("Height cannot be negative")
|
err = errors.Errorf("Height cannot be negative")
|
||||||
@ -41,7 +54,7 @@ func GetWithProof(key []byte, reqHeight int64, node rpcclient.Client,
|
|||||||
// GetWithProofOptions is useful if you want full access to the ABCIQueryOptions
|
// GetWithProofOptions is useful if you want full access to the ABCIQueryOptions
|
||||||
func GetWithProofOptions(path string, key []byte, opts rpcclient.ABCIQueryOptions,
|
func GetWithProofOptions(path string, key []byte, opts rpcclient.ABCIQueryOptions,
|
||||||
node rpcclient.Client, cert lite.Certifier) (
|
node rpcclient.Client, cert lite.Certifier) (
|
||||||
*ctypes.ResultABCIQuery, iavl.KeyProof, error) {
|
*ctypes.ResultABCIQuery, KeyProof, error) {
|
||||||
|
|
||||||
_resp, err := node.ABCIQueryWithOptions(path, key, opts)
|
_resp, err := node.ABCIQueryWithOptions(path, key, opts)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -67,6 +80,10 @@ func GetWithProofOptions(path string, key []byte, opts rpcclient.ABCIQueryOption
|
|||||||
return nil, nil, err
|
return nil, nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return &ctypes.ResultABCIQuery{Response: resp}, nil, nil
|
||||||
|
|
||||||
|
/* // TODO refactor so iavl stuff is not in tendermint core
|
||||||
|
// https://github.com/tendermint/tendermint/issues/1183
|
||||||
if len(resp.Value) > 0 {
|
if len(resp.Value) > 0 {
|
||||||
// The key was found, construct a proof of existence.
|
// The key was found, construct a proof of existence.
|
||||||
eproof, err := iavl.ReadKeyExistsProof(resp.Proof)
|
eproof, err := iavl.ReadKeyExistsProof(resp.Proof)
|
||||||
@ -94,6 +111,7 @@ func GetWithProofOptions(path string, key []byte, opts rpcclient.ABCIQueryOption
|
|||||||
return nil, nil, errors.Wrap(err, "Couldn't verify proof")
|
return nil, nil, errors.Wrap(err, "Couldn't verify proof")
|
||||||
}
|
}
|
||||||
return &ctypes.ResultABCIQuery{Response: resp}, aproof, ErrNoData()
|
return &ctypes.ResultABCIQuery{Response: resp}, aproof, ErrNoData()
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetCertifiedCommit gets the signed header for a given height
|
// GetCertifiedCommit gets the signed header for a given height
|
||||||
|
@ -9,7 +9,6 @@ import (
|
|||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
|
|
||||||
abci "github.com/tendermint/abci/types"
|
abci "github.com/tendermint/abci/types"
|
||||||
"github.com/tendermint/iavl"
|
|
||||||
|
|
||||||
"github.com/tendermint/tendermint/rpc/client"
|
"github.com/tendermint/tendermint/rpc/client"
|
||||||
rpctest "github.com/tendermint/tendermint/rpc/test"
|
rpctest "github.com/tendermint/tendermint/rpc/test"
|
||||||
@ -204,16 +203,8 @@ func TestAppCalls(t *testing.T) {
|
|||||||
// and we got a proof that works!
|
// and we got a proof that works!
|
||||||
_pres, err := c.ABCIQueryWithOptions("/key", k, client.ABCIQueryOptions{Trusted: false})
|
_pres, err := c.ABCIQueryWithOptions("/key", k, client.ABCIQueryOptions{Trusted: false})
|
||||||
pres := _pres.Response
|
pres := _pres.Response
|
||||||
if assert.Nil(err) && assert.True(pres.IsOK()) {
|
assert.Nil(err)
|
||||||
proof, err := iavl.ReadKeyExistsProof(pres.Proof)
|
assert.True(pres.IsOK())
|
||||||
if assert.Nil(err) {
|
|
||||||
key := pres.Key
|
|
||||||
value := pres.Value
|
|
||||||
assert.EqualValues(appHash, proof.RootHash)
|
|
||||||
valid := proof.Verify(key, value, appHash)
|
|
||||||
assert.Nil(valid)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user