Moved merkleeyes->iavl and updated references
This commit is contained in:
parent
b869a999c3
commit
2951763660
13
app/store.go
13
app/store.go
|
@ -10,7 +10,7 @@ import (
|
|||
"github.com/pkg/errors"
|
||||
abci "github.com/tendermint/abci/types"
|
||||
"github.com/tendermint/go-wire"
|
||||
"github.com/tendermint/merkleeyes/iavl"
|
||||
"github.com/tendermint/iavl"
|
||||
cmn "github.com/tendermint/tmlibs/common"
|
||||
dbm "github.com/tendermint/tmlibs/db"
|
||||
"github.com/tendermint/tmlibs/log"
|
||||
|
@ -180,18 +180,13 @@ func (s *Store) Query(reqQuery abci.RequestQuery) (resQuery abci.ResponseQuery)
|
|||
key := reqQuery.Data // Data holds the key bytes
|
||||
resQuery.Key = key
|
||||
if reqQuery.Prove {
|
||||
value, proofExists, proofNotExists, err := tree.GetWithProof(key)
|
||||
value, proof, err := tree.GetWithProof(key)
|
||||
if err != nil {
|
||||
resQuery.Log = err.Error()
|
||||
break
|
||||
}
|
||||
|
||||
if value != nil {
|
||||
resQuery.Value = value
|
||||
resQuery.Proof = wire.BinaryBytes(proofExists)
|
||||
} else {
|
||||
resQuery.Proof = wire.BinaryBytes(proofNotExists)
|
||||
}
|
||||
resQuery.Value = value
|
||||
resQuery.Proof = proof.Bytes()
|
||||
} else {
|
||||
value := tree.Get(key)
|
||||
resQuery.Value = value
|
||||
|
|
|
@ -10,8 +10,8 @@ import (
|
|||
|
||||
wire "github.com/tendermint/go-wire"
|
||||
"github.com/tendermint/go-wire/data"
|
||||
"github.com/tendermint/iavl"
|
||||
"github.com/tendermint/light-client/proofs"
|
||||
"github.com/tendermint/merkleeyes/iavl"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/client"
|
||||
"github.com/cosmos/cosmos-sdk/client/commands"
|
||||
|
@ -50,20 +50,18 @@ func Get(key []byte, prove bool) (data.Bytes, uint64, error) {
|
|||
resp, err := node.ABCIQuery("/key", key, false)
|
||||
return data.Bytes(resp.Value), resp.Height, err
|
||||
}
|
||||
val, h, _, _, err := GetWithProof(key)
|
||||
val, h, _, err := GetWithProof(key)
|
||||
return val, h, err
|
||||
}
|
||||
|
||||
// GetWithProof returns the values stored under a given key at the named
|
||||
// height as in Get. Additionally, it will return a validated merkle
|
||||
// proof for the key-value pair if it exists, and all checks pass.
|
||||
func GetWithProof(key []byte) (data.Bytes, uint64,
|
||||
*iavl.KeyExistsProof, *iavl.KeyNotExistsProof, error) {
|
||||
|
||||
func GetWithProof(key []byte) (data.Bytes, uint64, iavl.KeyProof, error) {
|
||||
node := commands.GetNode()
|
||||
cert, err := commands.GetCertifier()
|
||||
if err != nil {
|
||||
return nil, 0, nil, nil, err
|
||||
return nil, 0, nil, err
|
||||
}
|
||||
return client.GetWithProof(key, node, cert)
|
||||
}
|
||||
|
|
|
@ -59,7 +59,7 @@ var validatorsCmd = &cobra.Command{
|
|||
|
||||
func runValidators(cmd *cobra.Command, args []string) error {
|
||||
c := commands.GetNode()
|
||||
validators, err := c.Validators()
|
||||
validators, err := c.Validators(nil)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
|
@ -27,7 +27,7 @@ func runBlock(cmd *cobra.Command, args []string) error {
|
|||
}
|
||||
|
||||
h := viper.GetInt(FlagHeight)
|
||||
block, err := c.Block(h)
|
||||
block, err := c.Block(&h)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -47,7 +47,7 @@ func runCommit(cmd *cobra.Command, args []string) error {
|
|||
}
|
||||
|
||||
h := viper.GetInt(FlagHeight)
|
||||
commit, err := c.Commit(h)
|
||||
commit, err := c.Commit(&h)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
|
@ -3,11 +3,10 @@ package client
|
|||
import (
|
||||
"github.com/pkg/errors"
|
||||
|
||||
wire "github.com/tendermint/go-wire"
|
||||
"github.com/tendermint/go-wire/data"
|
||||
"github.com/tendermint/iavl"
|
||||
lc "github.com/tendermint/light-client"
|
||||
"github.com/tendermint/light-client/certifiers"
|
||||
"github.com/tendermint/merkleeyes/iavl"
|
||||
|
||||
"github.com/tendermint/tendermint/rpc/client"
|
||||
)
|
||||
|
@ -16,11 +15,10 @@ import (
|
|||
// a valid proof, as defined by the certifier.
|
||||
//
|
||||
// If there is any error in checking, returns an error.
|
||||
// If val is non-empty, eproof will be non-nil
|
||||
// If val is empty, neproof will be non-nil
|
||||
// If val is non-empty, proof should be KeyExistsProof
|
||||
// If val is empty, proof should be KeyMissingProof
|
||||
func GetWithProof(key []byte, node client.Client, cert certifiers.Certifier) (
|
||||
val data.Bytes, height uint64, eproof *iavl.KeyExistsProof,
|
||||
neproof *iavl.KeyNotExistsProof, err error) {
|
||||
val data.Bytes, height uint64, proof iavl.KeyProof, err error) {
|
||||
|
||||
resp, err := node.ABCIQuery("/key", key, true)
|
||||
if err != nil {
|
||||
|
@ -48,8 +46,8 @@ func GetWithProof(key []byte, node client.Client, cert certifiers.Certifier) (
|
|||
|
||||
if len(resp.Value) > 0 {
|
||||
// The key was found, construct a proof of existence.
|
||||
eproof = new(iavl.KeyExistsProof)
|
||||
err = wire.ReadBinaryBytes(resp.Proof, &eproof)
|
||||
var eproof *iavl.KeyExistsProof
|
||||
eproof, err = iavl.ReadKeyExistsProof(resp.Proof)
|
||||
if err != nil {
|
||||
err = errors.Wrap(err, "Error reading proof")
|
||||
return
|
||||
|
@ -62,22 +60,24 @@ func GetWithProof(key []byte, node client.Client, cert certifiers.Certifier) (
|
|||
return
|
||||
}
|
||||
val = data.Bytes(resp.Value)
|
||||
proof = eproof
|
||||
} else {
|
||||
// The key wasn't found, construct a proof of non-existence.
|
||||
neproof = new(iavl.KeyNotExistsProof)
|
||||
err = wire.ReadBinaryBytes(resp.Proof, &neproof)
|
||||
var aproof *iavl.KeyAbsentProof
|
||||
aproof, err = iavl.ReadKeyAbsentProof(resp.Proof)
|
||||
if err != nil {
|
||||
err = errors.Wrap(err, "Error reading proof")
|
||||
return
|
||||
}
|
||||
|
||||
// Validate the proof against the certified header to ensure data integrity.
|
||||
err = neproof.Verify(resp.Key, check.Header.AppHash)
|
||||
err = proof.Verify(resp.Key, nil, check.Header.AppHash)
|
||||
if err != nil {
|
||||
err = errors.Wrap(err, "Couldn't verify proof")
|
||||
return
|
||||
}
|
||||
err = lc.ErrNoData()
|
||||
proof = aproof
|
||||
}
|
||||
|
||||
height = resp.Height
|
||||
|
@ -93,7 +93,7 @@ func GetCertifiedCheckpoint(h int, node client.Client,
|
|||
// Validators and will fail on querying tendermint for non-current height.
|
||||
// When this is supported, we should use it instead...
|
||||
client.WaitForHeight(node, h, nil)
|
||||
commit, err := node.Commit(h)
|
||||
commit, err := node.Commit(&h)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
hash: 8c26e55d658fbe1b9c7951833528b63613549a61149ca7e78e6de2d96f81f372
|
||||
updated: 2017-09-06T13:54:19.419666453+02:00
|
||||
hash: ba9b44c722e57f103b8b6b861aabaeb37ad59c706160b6281817945f95dfbc1e
|
||||
updated: 2017-09-06T17:08:51.118191348+02:00
|
||||
imports:
|
||||
- name: github.com/bgentry/speakeasy
|
||||
version: 4aabc24848ce5fd31929f7d1e4ea74d3709c14cd
|
||||
|
@ -136,6 +136,8 @@ imports:
|
|||
subpackages:
|
||||
- data
|
||||
- data/base58
|
||||
- name: github.com/tendermint/iavl
|
||||
version: a3ec7707c4eacabd33b7c510df364bfce1eb33e6
|
||||
- name: github.com/tendermint/light-client
|
||||
version: ac2e4bf47b31aaf5d3d336691ac786ec751bfc32
|
||||
subpackages:
|
||||
|
@ -146,7 +148,6 @@ imports:
|
|||
- name: github.com/tendermint/merkleeyes
|
||||
version: 2f6e5d31e7a35045d8d0a5895cb1fec33dd4d32b
|
||||
subpackages:
|
||||
- client
|
||||
- iavl
|
||||
- name: github.com/tendermint/tendermint
|
||||
version: aa78fc14b5824725f8a14dd2c2ad727a9ab89cc3
|
||||
|
|
|
@ -28,11 +28,8 @@ import:
|
|||
- certifiers
|
||||
- certifiers/client
|
||||
- certifiers/files
|
||||
- package: github.com/tendermint/merkleeyes
|
||||
- package: github.com/tendermint/iavl
|
||||
version: develop
|
||||
subpackages:
|
||||
- client
|
||||
- iavl
|
||||
- package: github.com/tendermint/tendermint
|
||||
version: develop
|
||||
subpackages:
|
||||
|
|
|
@ -197,7 +197,7 @@ func packetQueryCmd(cmd *cobra.Command, args []string) error {
|
|||
}
|
||||
|
||||
// output queue, create a post packet
|
||||
bs, height, proof, _, err := query.GetWithProof(key)
|
||||
bs, height, proof, err := query.GetWithProof(key)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
|
@ -3,8 +3,8 @@ package ibc
|
|||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/tendermint/iavl"
|
||||
"github.com/tendermint/light-client/certifiers"
|
||||
"github.com/tendermint/merkleeyes/iavl"
|
||||
"github.com/tendermint/tmlibs/log"
|
||||
|
||||
sdk "github.com/cosmos/cosmos-sdk"
|
||||
|
@ -59,7 +59,7 @@ func genEmptySeed(keys certifiers.ValKeys, chain string, h int,
|
|||
func makePostPacket(tree *iavl.IAVLTree, packet Packet, fromID string, fromHeight int) PostPacketTx {
|
||||
key := []byte(fmt.Sprintf("some-long-prefix-%06d", packet.Sequence))
|
||||
tree.Set(key, packet.Bytes())
|
||||
_, proof, _, err := tree.GetWithProof(key)
|
||||
_, proof, err := tree.GetWithProof(key)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
|
|
@ -2,8 +2,8 @@ package ibc
|
|||
|
||||
import (
|
||||
"github.com/tendermint/go-wire/data"
|
||||
"github.com/tendermint/iavl"
|
||||
"github.com/tendermint/light-client/certifiers"
|
||||
"github.com/tendermint/merkleeyes/iavl"
|
||||
|
||||
sdk "github.com/cosmos/cosmos-sdk"
|
||||
)
|
||||
|
@ -86,7 +86,7 @@ func (u UpdateChainTx) Wrap() sdk.Tx {
|
|||
// If must have the special `AllowIBC` permission from the app
|
||||
// that can send this packet (so only coins can request SendTx packet)
|
||||
type CreatePacketTx struct {
|
||||
DestChain string `json:"dest_chain"`
|
||||
DestChain string `json:"dest_chain"`
|
||||
Permissions sdk.Actors `json:"permissions"`
|
||||
Tx sdk.Tx `json:"tx"`
|
||||
}
|
||||
|
@ -115,9 +115,9 @@ type PostPacketTx struct {
|
|||
// The block height in which Packet was committed, to check Proof
|
||||
FromChainHeight uint64 `json:"src_height"`
|
||||
// this proof must match the header and the packet.Bytes()
|
||||
Proof *iavl.KeyExistsProof `json:"proof"`
|
||||
Key data.Bytes `json:"key"`
|
||||
Packet Packet `json:"packet"`
|
||||
Proof iavl.KeyProof `json:"proof"`
|
||||
Key data.Bytes `json:"key"`
|
||||
Packet Packet `json:"packet"`
|
||||
}
|
||||
|
||||
// ValidateBasic makes sure this is consistent - used to satisfy TxInner
|
||||
|
|
|
@ -14,7 +14,7 @@ package commands
|
|||
// // "github.com/tendermint/tmlibs/log"
|
||||
|
||||
// "github.com/tendermint/go-wire"
|
||||
// "github.com/tendermint/merkleeyes/iavl"
|
||||
// "github.com/tendermint/iavl"
|
||||
// cmn "github.com/tendermint/tmlibs/common"
|
||||
|
||||
// "github.com/cosmos/cosmos-sdk/plugins/ibc"
|
||||
|
|
|
@ -7,7 +7,7 @@ import (
|
|||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
"github.com/tendermint/merkleeyes/iavl"
|
||||
"github.com/tendermint/iavl"
|
||||
"github.com/tendermint/tmlibs/log"
|
||||
|
||||
sdk "github.com/cosmos/cosmos-sdk"
|
||||
|
|
|
@ -3,7 +3,7 @@ package state
|
|||
import (
|
||||
"math/rand"
|
||||
|
||||
"github.com/tendermint/merkleeyes/iavl"
|
||||
"github.com/tendermint/iavl"
|
||||
)
|
||||
|
||||
// store nonce as it's own type so no one can even try to fake it
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
package state
|
||||
|
||||
import "github.com/tendermint/merkleeyes/iavl"
|
||||
import "github.com/tendermint/iavl"
|
||||
|
||||
// State represents the app states, separating the commited state (for queries)
|
||||
// from the working state (for CheckTx and AppendTx)
|
||||
|
|
|
@ -6,7 +6,7 @@ import (
|
|||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
"github.com/tendermint/merkleeyes/iavl"
|
||||
"github.com/tendermint/iavl"
|
||||
)
|
||||
|
||||
type keyVal struct {
|
||||
|
|
|
@ -6,7 +6,7 @@ import (
|
|||
|
||||
"github.com/stretchr/testify/assert"
|
||||
|
||||
"github.com/tendermint/merkleeyes/iavl"
|
||||
"github.com/tendermint/iavl"
|
||||
dbm "github.com/tendermint/tmlibs/db"
|
||||
)
|
||||
|
||||
|
|
Loading…
Reference in New Issue