Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update IAVL dependency for v0.10.0 #1952

Merged
merged 7 commits into from
Sep 6, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions Gopkg.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Gopkg.toml
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@

[[override]]
name = "github.com/tendermint/iavl"
version = "=v0.9.2"
version = "=v0.10.0"

[[override]]
name = "github.com/tendermint/tendermint"
Expand Down
1 change: 1 addition & 0 deletions PENDING.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ IMPROVEMENTS
* [tools] Make get_vendor_deps deletes `.vendor-new` directories, in case scratch files are present.
* [cli] \#1632 Add integration tests to ensure `basecoind init && basecoind` start sequences run successfully for both `democoin` and `basecoin` examples.
* [store] Speedup IAVL iteration, and consequently everything that requires IAVL iteration. [#2143](https://github.com/cosmos/cosmos-sdk/issues/2143)
* [store] \#1952 Update IAVL dependency to v0.10.0
* [simulation] Make timestamps randomized [#2153](https://github.com/cosmos/cosmos-sdk/pull/2153)

* Tendermint
Expand Down
1 change: 1 addition & 0 deletions baseapp/baseapp.go
Original file line number Diff line number Diff line change
Expand Up @@ -345,6 +345,7 @@ func handleQueryStore(app *BaseApp, path []string, req abci.RequestQuery) (res a
return queryable.Query(req)
}

// nolint: unparam
func handleQueryP2P(app *BaseApp, path []string, req abci.RequestQuery) (res abci.ResponseQuery) {
// "/p2p" prefix for p2p queries
if len(path) >= 4 {
Expand Down
4 changes: 2 additions & 2 deletions baseapp/baseapp_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -626,12 +626,12 @@ func TestSimulateTx(t *testing.T) {
// simulate a message, check gas reported
result := app.Simulate(tx)
require.True(t, result.IsOK(), result.Log)
require.Equal(t, int64(gasConsumed), result.GasUsed)
require.Equal(t, gasConsumed, result.GasUsed)

// simulate again, same result
result = app.Simulate(tx)
require.True(t, result.IsOK(), result.Log)
require.Equal(t, int64(gasConsumed), result.GasUsed)
require.Equal(t, gasConsumed, result.GasUsed)

// simulate by calling Query with encoded tx
txBytes, err := codec.MarshalBinary(tx)
Expand Down
4 changes: 3 additions & 1 deletion client/context/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,15 @@ import (

"github.com/pkg/errors"

"strings"

"github.com/cosmos/cosmos-sdk/store"
"github.com/cosmos/cosmos-sdk/wire"
abci "github.com/tendermint/tendermint/abci/types"
cmn "github.com/tendermint/tendermint/libs/common"
tmliteProxy "github.com/tendermint/tendermint/lite/proxy"
rpcclient "github.com/tendermint/tendermint/rpc/client"
ctypes "github.com/tendermint/tendermint/rpc/core/types"
"strings"
)

// GetNode returns an RPC client. If the context's client is not defined, an
Expand Down Expand Up @@ -323,6 +324,7 @@ func (ctx CLIContext) query(path string, key cmn.HexBytes) (res []byte, err erro
}

// verifyProof perform response proof verification
// nolint: unparam
func (ctx CLIContext) verifyProof(path string, resp abci.ResponseQuery) error {

if ctx.Certifier == nil {
Expand Down
3 changes: 3 additions & 0 deletions cmd/cosmos-sdk-cli/cmd/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ func resolveProjectPath(remoteProjectPath string) string {
return gopath + string(os.PathSeparator) + "src" + string(os.PathSeparator) + remoteProjectPath
}

// nolint: unparam, errcheck
func copyBasecoinTemplate(projectName string, projectPath string, remoteProjectPath string) {
basecoinProjectPath := resolveProjectPath(remoteBasecoinPath)
filepath.Walk(basecoinProjectPath, func(path string, f os.FileInfo, err error) error {
Expand Down Expand Up @@ -88,6 +89,7 @@ func copyBasecoinTemplate(projectName string, projectPath string, remoteProjectP
})
}

// nolint: errcheck
func createGopkg(projectPath string) {
// Create gopkg.toml file
dependencies := map[string]string{
Expand All @@ -111,6 +113,7 @@ func createGopkg(projectPath string) {
ioutil.WriteFile(projectPath+"/Gopkg.toml", []byte(contents), os.ModePerm)
}

// nolint: errcheck
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lets make a follow-up issue to handle the nolints?

func createMakefile(projectPath string) {
// Create makefile
// TODO: Should we use tools/ directory as in Cosmos-SDK to get tools for linting etc.
Expand Down
3 changes: 3 additions & 0 deletions examples/democoin/x/assoc/validator_set.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ func GetAssocKey(base sdk.ValAddress, assoc sdk.ValAddress) []byte {
}

// Associate associates new address with validator address
// nolint: unparam
func (valset ValidatorSet) Associate(ctx sdk.Context, base sdk.ValAddress, assoc sdk.ValAddress) bool {
if len(base) != valset.addrLen || len(assoc) != valset.addrLen {
return false
Expand All @@ -76,6 +77,7 @@ func (valset ValidatorSet) Associate(ctx sdk.Context, base sdk.ValAddress, assoc
}

// Dissociate removes association between addresses
// nolint: unparam
func (valset ValidatorSet) Dissociate(ctx sdk.Context, base sdk.ValAddress, assoc sdk.ValAddress) bool {
if len(base) != valset.addrLen || len(assoc) != valset.addrLen {
return false
Expand All @@ -90,6 +92,7 @@ func (valset ValidatorSet) Dissociate(ctx sdk.Context, base sdk.ValAddress, asso
}

// Associations returns all associated addresses with a validator
// nolint: unparam
func (valset ValidatorSet) Associations(ctx sdk.Context, base sdk.ValAddress) (res []sdk.ValAddress) {
res = make([]sdk.ValAddress, valset.maxAssoc)
iter := sdk.KVStorePrefixIterator(valset.store, GetAssocPrefix(base))
Expand Down
1 change: 1 addition & 0 deletions server/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -344,6 +344,7 @@ func readOrCreatePrivValidator(tmConfig *cfg.Config) crypto.PubKey {

// writeGenesisFile creates and writes the genesis configuration to disk. An
// error is returned if building or writing the configuration to file fails.
// nolint: unparam
func writeGenesisFile(cdc *wire.Codec, genesisFile, chainID string, validators []tmtypes.GenesisValidator, appState json.RawMessage) error {
genDoc := tmtypes.GenesisDoc{
ChainID: chainID,
Expand Down
1 change: 1 addition & 0 deletions server/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ func startStandAlone(ctx *Context, appCreator AppCreator) error {
return nil
}

// nolint: unparam
func startInProcess(ctx *Context, appCreator AppCreator) (*node.Node, error) {
cfg := ctx.Config
home := cfg.RootDir
Expand Down
17 changes: 9 additions & 8 deletions store/iavlstore.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ const (

// load the iavl store
func LoadIAVLStore(db dbm.DB, id CommitID, pruning sdk.PruningStrategy) (CommitStore, error) {
tree := iavl.NewVersionedTree(db, defaultIAVLCacheSize)
tree := iavl.NewMutableTree(db, defaultIAVLCacheSize)
_, err := tree.LoadVersion(id.Version)
if err != nil {
return nil, err
Expand All @@ -40,7 +40,7 @@ var _ Queryable = (*iavlStore)(nil)
type iavlStore struct {

// The underlying tree.
tree *iavl.VersionedTree
tree *iavl.MutableTree

// How many old versions we hold onto.
// A value of 0 means keep no recent states.
Expand All @@ -56,7 +56,8 @@ type iavlStore struct {
}

// CONTRACT: tree should be fully loaded.
func newIAVLStore(tree *iavl.VersionedTree, numRecent int64, storeEvery int64) *iavlStore {
// nolint: unparam
func newIAVLStore(tree *iavl.MutableTree, numRecent int64, storeEvery int64) *iavlStore {
st := &iavlStore{
tree: tree,
numRecent: numRecent,
Expand Down Expand Up @@ -167,16 +168,16 @@ func (st *iavlStore) Gas(meter GasMeter, config GasConfig) KVStore {

// Implements KVStore.
func (st *iavlStore) Iterator(start, end []byte) Iterator {
return newIAVLIterator(st.tree.Tree(), start, end, true)
return newIAVLIterator(st.tree.ImmutableTree, start, end, true)
}

// Implements KVStore.
func (st *iavlStore) ReverseIterator(start, end []byte) Iterator {
return newIAVLIterator(st.tree.Tree(), start, end, false)
return newIAVLIterator(st.tree.ImmutableTree, start, end, false)
}

// Handle gatest the latest height, if height is 0
func getHeight(tree *iavl.VersionedTree, req abci.RequestQuery) int64 {
func getHeight(tree *iavl.MutableTree, req abci.RequestQuery) int64 {
height := req.Height
if height == 0 {
latest := tree.Version64()
Expand Down Expand Up @@ -255,7 +256,7 @@ func (st *iavlStore) Query(req abci.RequestQuery) (res abci.ResponseQuery) {
// Implements Iterator.
type iavlIterator struct {
// Underlying store
tree *iavl.Tree
tree *iavl.ImmutableTree

// Domain
start, end []byte
Expand Down Expand Up @@ -286,7 +287,7 @@ var _ Iterator = (*iavlIterator)(nil)
// newIAVLIterator will create a new iavlIterator.
// CONTRACT: Caller must release the iavlIterator, as each one creates a new
// goroutine.
func newIAVLIterator(tree *iavl.Tree, start, end []byte, ascending bool) *iavlIterator {
func newIAVLIterator(tree *iavl.ImmutableTree, start, end []byte, ascending bool) *iavlIterator {
iter := &iavlIterator{
tree: tree,
start: cp(start),
Expand Down
14 changes: 7 additions & 7 deletions store/iavlstore_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ var (
)

// make a tree and save it
func newTree(t *testing.T, db dbm.DB) (*iavl.VersionedTree, CommitID) {
tree := iavl.NewVersionedTree(db, cacheSize)
func newTree(t *testing.T, db dbm.DB) (*iavl.MutableTree, CommitID) {
tree := iavl.NewMutableTree(db, cacheSize)
for k, v := range treeData {
tree.Set([]byte(k), []byte(v))
}
Expand Down Expand Up @@ -325,7 +325,7 @@ type pruneState struct {

func testPruning(t *testing.T, numRecent int64, storeEvery int64, states []pruneState) {
db := dbm.NewMemDB()
tree := iavl.NewVersionedTree(db, cacheSize)
tree := iavl.NewMutableTree(db, cacheSize)
iavlStore := newIAVLStore(tree, numRecent, storeEvery)
for step, state := range states {
for _, ver := range state.stored {
Expand All @@ -344,7 +344,7 @@ func testPruning(t *testing.T, numRecent int64, storeEvery int64, states []prune

func TestIAVLNoPrune(t *testing.T) {
db := dbm.NewMemDB()
tree := iavl.NewVersionedTree(db, cacheSize)
tree := iavl.NewMutableTree(db, cacheSize)
iavlStore := newIAVLStore(tree, numRecent, int64(1))
nextVersion(iavlStore)
for i := 1; i < 100; i++ {
Expand All @@ -359,7 +359,7 @@ func TestIAVLNoPrune(t *testing.T) {

func TestIAVLPruneEverything(t *testing.T) {
db := dbm.NewMemDB()
tree := iavl.NewVersionedTree(db, cacheSize)
tree := iavl.NewMutableTree(db, cacheSize)
iavlStore := newIAVLStore(tree, int64(0), int64(0))
nextVersion(iavlStore)
for i := 1; i < 100; i++ {
Expand All @@ -377,7 +377,7 @@ func TestIAVLPruneEverything(t *testing.T) {

func TestIAVLStoreQuery(t *testing.T) {
db := dbm.NewMemDB()
tree := iavl.NewVersionedTree(db, cacheSize)
tree := iavl.NewMutableTree(db, cacheSize)
iavlStore := newIAVLStore(tree, numRecent, storeEvery)

k1, v1 := []byte("key1"), []byte("val1")
Expand Down Expand Up @@ -468,7 +468,7 @@ func TestIAVLStoreQuery(t *testing.T) {
func BenchmarkIAVLIteratorNext(b *testing.B) {
db := dbm.NewMemDB()
treeSize := 1000
tree := iavl.NewVersionedTree(db, cacheSize)
tree := iavl.NewMutableTree(db, cacheSize)
for i := 0; i < treeSize; i++ {
key := cmn.RandBytes(4)
value := cmn.RandBytes(50)
Expand Down
8 changes: 5 additions & 3 deletions store/multistoreproof_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@ package store

import (
"encoding/hex"
"testing"

"github.com/stretchr/testify/assert"
"github.com/tendermint/iavl"
cmn "github.com/tendermint/tendermint/libs/common"
"testing"
"github.com/tendermint/tendermint/libs/db"
)

func TestVerifyMultiStoreCommitInfo(t *testing.T) {
Expand Down Expand Up @@ -91,7 +93,7 @@ func TestVerifyMultiStoreCommitInfo(t *testing.T) {
}

func TestVerifyRangeProof(t *testing.T) {
tree := iavl.NewTree(nil, 0)
tree := iavl.NewMutableTree(db.NewMemDB(), 0)

rand := cmn.NewRand()
rand.Seed(0) // for determinism
Expand All @@ -100,7 +102,7 @@ func TestVerifyRangeProof(t *testing.T) {
tree.Set(key, []byte(rand.Str(8)))
}

root := tree.Hash()
root := tree.WorkingHash()

key := []byte{0x32}
val, proof, err := tree.GetWithProof(key)
Expand Down
2 changes: 1 addition & 1 deletion store/prefixstore_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ func testPrefixStore(t *testing.T, baseStore KVStore, prefix []byte) {

func TestIAVLStorePrefix(t *testing.T) {
db := dbm.NewMemDB()
tree := iavl.NewVersionedTree(db, cacheSize)
tree := iavl.NewMutableTree(db, cacheSize)
iavlStore := newIAVLStore(tree, numRecent, storeEvery)

testPrefixStore(t, iavlStore, []byte("test"))
Expand Down
1 change: 1 addition & 0 deletions store/tracekvstore.go
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,7 @@ func (tkv *TraceKVStore) CacheWrapWithTrace(_ io.Writer, _ TraceContext) CacheWr

// writeOperation writes a KVStore operation to the underlying io.Writer as
// JSON-encoded data where the key/value pair is base64 encoded.
// nolint: errcheck
func writeOperation(w io.Writer, op operation, tc TraceContext, key, value []byte) {
traceOp := traceOperation{
Operation: op,
Expand Down
8 changes: 4 additions & 4 deletions store/tracekvstore_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -156,8 +156,8 @@ func TestTestTraceKVStoreIterator(t *testing.T) {
iterator := store.Iterator(nil, nil)

s, e := iterator.Domain()
require.Equal(t, []uint8([]byte(nil)), s)
require.Equal(t, []uint8([]byte(nil)), e)
require.Equal(t, []byte(nil), s)
require.Equal(t, []byte(nil), e)

testCases := []struct {
expectedKey []byte
Expand Down Expand Up @@ -212,8 +212,8 @@ func TestTestTraceKVStoreReverseIterator(t *testing.T) {
iterator := store.ReverseIterator(nil, nil)

s, e := iterator.Domain()
require.Equal(t, []uint8([]byte(nil)), s)
require.Equal(t, []uint8([]byte(nil)), e)
require.Equal(t, []byte(nil), s)
require.Equal(t, []byte(nil), e)

testCases := []struct {
expectedKey []byte
Expand Down
1 change: 1 addition & 0 deletions tests/gobash.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (

// ExecuteT executes the command, pipes any input to STDIN and return STDOUT,
// logging STDOUT/STDERR to t.
// nolint: errcheck
func ExecuteT(t *testing.T, cmd, input string) (out string) {
t.Log("Running", cmn.Cyan(cmd))

Expand Down
3 changes: 3 additions & 0 deletions types/account.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ func (aa AccAddress) String() string {
}

// Format implements the fmt.Formatter interface.
// nolint: errcheck
func (aa AccAddress) Format(s fmt.State, verb rune) {
switch verb {
case 's':
Expand Down Expand Up @@ -247,6 +248,7 @@ func (va ValAddress) String() string {
}

// Format implements the fmt.Formatter interface.
// nolint: errcheck
func (va ValAddress) Format(s fmt.State, verb rune) {
switch verb {
case 's':
Expand Down Expand Up @@ -361,6 +363,7 @@ func (ca ConsAddress) String() string {
}

// Format implements the fmt.Formatter interface.
// nolint: errcheck
func (ca ConsAddress) Format(s fmt.State, verb rune) {
switch verb {
case 's':
Expand Down
1 change: 1 addition & 0 deletions types/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ type Context struct {
}

// create a new context
// nolint: unparam
func NewContext(ms MultiStore, header abci.Header, isCheckTx bool, logger log.Logger) Context {
c := Context{
Context: context.Background(),
Expand Down
1 change: 1 addition & 0 deletions types/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,7 @@ func (err *sdkError) WithDefaultCodespace(cs CodespaceType) Error {
}

// Implements ABCIError.
// nolint: errcheck
func (err *sdkError) TraceSDK(format string, args ...interface{}) Error {
err.Trace(1, format, args...)
return err
Expand Down
Loading