From 59e29925ac26547ed77bc890e9ee14baf80dcc55 Mon Sep 17 00:00:00 2001 From: Julien Robert Date: Thu, 25 Jul 2024 14:39:05 +0200 Subject: [PATCH] refactor: minimal logger interface (#964) --- basic_test.go | 7 ++-- benchmarks/bench_test.go | 3 +- benchmarks/cosmos-exim/main.go | 8 ++-- cmd/go.mod | 12 +++--- cmd/go.sum | 32 +++++++------- db/README.md | 2 +- diff_test.go | 5 +-- export_test.go | 13 +++--- go.mod | 7 ++-- go.sum | 36 +++++++--------- immutable_tree.go | 5 +-- import_test.go | 31 +++++++------- iterator_test.go | 17 ++++---- logger.go | 34 +++++++++++++++ migrate_test.go | 17 ++++---- mutable_tree.go | 5 +-- mutable_tree_test.go | 55 ++++++++++++------------ nodedb.go | 5 +-- nodedb_test.go | 35 ++++++++-------- proof_iavl_test.go | 3 +- proof_ics23_test.go | 3 +- testutils_test.go | 5 +-- tree_random_test.go | 3 +- tree_test.go | 77 +++++++++++++++++----------------- 24 files changed, 214 insertions(+), 206 deletions(-) create mode 100644 logger.go diff --git a/basic_test.go b/basic_test.go index 395a1c238..1d3e09074 100644 --- a/basic_test.go +++ b/basic_test.go @@ -7,7 +7,6 @@ import ( "sort" "testing" - "cosmossdk.io/core/log" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" @@ -442,14 +441,14 @@ func TestPersistence(t *testing.T) { } // Construct some tree and save it - t1 := NewMutableTree(db, 0, false, log.NewNopLogger()) + t1 := NewMutableTree(db, 0, false, NewNopLogger()) for key, value := range records { t1.Set([]byte(key), []byte(value)) } t1.SaveVersion() // Load a tree - t2 := NewMutableTree(db, 0, false, log.NewNopLogger()) + t2 := NewMutableTree(db, 0, false, NewNopLogger()) t2.Load() for key, value := range records { t2value, err := t2.Get([]byte(key)) @@ -497,7 +496,7 @@ func TestProof(t *testing.T) { func TestTreeProof(t *testing.T) { db := dbm.NewMemDB() - tree := NewMutableTree(db, 100, false, log.NewNopLogger()) + tree := NewMutableTree(db, 100, false, NewNopLogger()) hash := tree.Hash() assert.Equal(t, "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", hex.EncodeToString(hash)) diff --git a/benchmarks/bench_test.go b/benchmarks/bench_test.go index 137cb7dd3..f87f23926 100644 --- a/benchmarks/bench_test.go +++ b/benchmarks/bench_test.go @@ -8,7 +8,6 @@ import ( "runtime" "testing" - "cosmossdk.io/core/log" corestore "cosmossdk.io/core/store" "github.com/stretchr/testify/require" @@ -27,7 +26,7 @@ func randBytes(length int) []byte { } func prepareTree(b *testing.B, db dbm.DB, size, keyLen, dataLen int) (*iavl.MutableTree, [][]byte) { - t := iavl.NewMutableTree(db, size, false, log.NewNopLogger()) + t := iavl.NewMutableTree(db, size, false, iavl.NewNopLogger()) keys := make([][]byte, size) for i := 0; i < size; i++ { diff --git a/benchmarks/cosmos-exim/main.go b/benchmarks/cosmos-exim/main.go index d74f3b96a..34ba70266 100644 --- a/benchmarks/cosmos-exim/main.go +++ b/benchmarks/cosmos-exim/main.go @@ -5,8 +5,6 @@ import ( "os" "time" - "cosmossdk.io/core/log" - "github.com/cosmos/iavl" idbm "github.com/cosmos/iavl/db" ) @@ -92,7 +90,7 @@ func runExport(dbPath string) (int64, map[string][]*iavl.ExportNode, error) { if err != nil { return 0, nil, err } - tree := iavl.NewMutableTree(idbm.NewPrefixDB(ldb, []byte("s/k:main/")), 0, false, log.NewNopLogger()) + tree := iavl.NewMutableTree(idbm.NewPrefixDB(ldb, []byte("s/k:main/")), 0, false, iavl.NewNopLogger()) version, err := tree.LoadVersion(0) if err != nil { return 0, nil, err @@ -104,7 +102,7 @@ func runExport(dbPath string) (int64, map[string][]*iavl.ExportNode, error) { totalStats := Stats{} for _, name := range stores { db := idbm.NewPrefixDB(ldb, []byte("s/k:"+name+"/")) - tree := iavl.NewMutableTree(db, 0, false, log.NewNopLogger()) + tree := iavl.NewMutableTree(db, 0, false, iavl.NewNopLogger()) stats := Stats{} export := make([]*iavl.ExportNode, 0, 100000) @@ -169,7 +167,7 @@ func runImport(version int64, exports map[string][]*iavl.ExportNode) error { if err != nil { return err } - newTree := iavl.NewMutableTree(newDB, 0, false, log.NewNopLogger()) + newTree := iavl.NewMutableTree(newDB, 0, false, iavl.NewNopLogger()) importer, err := newTree.Import(version) if err != nil { return err diff --git a/cmd/go.mod b/cmd/go.mod index fc19712d2..460a98c18 100644 --- a/cmd/go.mod +++ b/cmd/go.mod @@ -3,8 +3,8 @@ module github.com/cosmos/iavl/cmd go 1.21 require ( - cosmossdk.io/core v0.12.1-0.20240514205955-97c9bbb0341b - cosmossdk.io/log v1.3.2-0.20240514205955-97c9bbb0341b + cosmossdk.io/core v0.12.1-0.20240725072823-6a2d039e1212 + cosmossdk.io/log v1.3.1 github.com/cosmos/cosmos-db v1.0.2 github.com/cosmos/iavl v1.2.0 ) @@ -18,7 +18,7 @@ require ( github.com/cockroachdb/pebble v1.1.0 // indirect github.com/cockroachdb/redact v1.1.5 // indirect github.com/cockroachdb/tokenbucket v0.0.0-20230807174530-cc333fc44b06 // indirect - github.com/cosmos/gogoproto v1.4.12 // indirect + github.com/cosmos/gogoproto v1.5.0 // indirect github.com/cosmos/ics23/go v0.10.0 // indirect github.com/emicklei/dot v1.6.2 // indirect github.com/getsentry/sentry-go v0.18.0 // indirect @@ -45,9 +45,9 @@ require ( github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7 // indirect golang.org/x/crypto v0.23.0 // indirect golang.org/x/exp v0.0.0-20231006140011-7918f672742d // indirect - golang.org/x/sys v0.20.0 // indirect - golang.org/x/text v0.15.0 // indirect - google.golang.org/protobuf v1.34.1 // indirect + golang.org/x/sys v0.22.0 // indirect + golang.org/x/text v0.16.0 // indirect + google.golang.org/protobuf v1.34.2 // indirect ) replace github.com/cosmos/iavl => ../. diff --git a/cmd/go.sum b/cmd/go.sum index 981302bd8..b8dd2a037 100644 --- a/cmd/go.sum +++ b/cmd/go.sum @@ -30,10 +30,10 @@ cloud.google.com/go/storage v1.5.0/go.mod h1:tpKbwo567HUNpVclU5sGELwQWBDZ8gh0Zeo cloud.google.com/go/storage v1.6.0/go.mod h1:N7U0C8pVQ/+NIKOBQyamJIeKQKkZ+mxpohlUTyfDhBk= cloud.google.com/go/storage v1.8.0/go.mod h1:Wv1Oy7z6Yz3DshWRJFhqM/UCfaWIRTdp0RXyy7KQOVs= cloud.google.com/go/storage v1.10.0/go.mod h1:FLPqc6j+Ki4BU591ie1oL6qBQGu2Bl/tZ9ullr3+Kg0= -cosmossdk.io/core v0.12.1-0.20240514205955-97c9bbb0341b h1:QudoITEtzaPNGltOQSyMbVopBQ2Z28h717nwLhlj6JU= -cosmossdk.io/core v0.12.1-0.20240514205955-97c9bbb0341b/go.mod h1:jJ3gjbqJyHPrTjn2Ad6wjb7Oz90G1ZjDg0JyBii41QE= -cosmossdk.io/log v1.3.2-0.20240514205955-97c9bbb0341b h1:twjCK9N+p+6wEdJ33KRTXgCicmbJGoj47AEOFS0/qsg= -cosmossdk.io/log v1.3.2-0.20240514205955-97c9bbb0341b/go.mod h1:FcxhbFGkwLGFr3NsnSLsfrxjpCdQQ7ow3GaYaw5Zb70= +cosmossdk.io/core v0.12.1-0.20240725072823-6a2d039e1212 h1:yLjl2aq6XMa5Zb1aKfwNHn1U+fFmmAtZyWKNWm/yVH8= +cosmossdk.io/core v0.12.1-0.20240725072823-6a2d039e1212/go.mod h1:sLzMwAW9HW+Nm3GltUVHDRSRZbcXLy9+2AYgi2bwt/s= +cosmossdk.io/log v1.3.1 h1:UZx8nWIkfbbNEWusZqzAx3ZGvu54TZacWib3EzUYmGI= +cosmossdk.io/log v1.3.1/go.mod h1:2/dIomt8mKdk6vl3OWJcPk2be3pGOS8OQaLUM/3/tCM= dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo= @@ -73,8 +73,8 @@ github.com/cockroachdb/tokenbucket v0.0.0-20230807174530-cc333fc44b06/go.mod h1: github.com/coreos/go-systemd/v22 v22.5.0/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc= github.com/cosmos/cosmos-db v1.0.2 h1:hwMjozuY1OlJs/uh6vddqnk9j7VamLv+0DBlbEXbAKs= github.com/cosmos/cosmos-db v1.0.2/go.mod h1:Z8IXcFJ9PqKK6BIsVOB3QXtkKoqUOp1vRvPT39kOXEA= -github.com/cosmos/gogoproto v1.4.12 h1:vB6Lbe/rtnYGjQuFxkPiPYiCybqFT8QvLipDZP8JpFE= -github.com/cosmos/gogoproto v1.4.12/go.mod h1:LnZob1bXRdUoqMMtwYlcR3wjiElmlC+FkjaZRv1/eLY= +github.com/cosmos/gogoproto v1.5.0 h1:SDVwzEqZDDBoslaeZg+dGE55hdzHfgUA40pEanMh52o= +github.com/cosmos/gogoproto v1.5.0/go.mod h1:iUM31aofn3ymidYG6bUR5ZFrk+Om8p5s754eMUcyp8I= github.com/cosmos/ics23/go v0.10.0 h1:iXqLLgp2Lp+EdpIuwXTYIQU+AiHj9mOC2X9ab++bZDM= github.com/cosmos/ics23/go v0.10.0/go.mod h1:ZfJSmng/TBNTBkFemHHHj5YY7VAU/MBU980F4VU1NG0= github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= @@ -362,8 +362,8 @@ golang.org/x/net v0.0.0-20200813134508-3edf25e44fcc/go.mod h1:/O7V0waA8r7cgGh81R golang.org/x/net v0.0.0-20200822124328-c89045814202/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= golang.org/x/net v0.0.0-20210525063256-abc453219eb5/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= -golang.org/x/net v0.24.0 h1:1PcaxkF854Fu3+lvBIx5SYn9wRlBzzcnHZSiaFFAb0w= -golang.org/x/net v0.24.0/go.mod h1:2Q7sJY5mzlzWjKtYUEXSlBWCdyaioyXzRB2RtU8KVE8= +golang.org/x/net v0.27.0 h1:5K3Njcw06/l2y9vpGCSdcxWOYHOUk3dVNGDXN+FvAys= +golang.org/x/net v0.27.0/go.mod h1:dDi0PyhWNoiUOrAS8uXv/vnScO4wnHQO4mj9fn/RytE= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= @@ -380,8 +380,8 @@ golang.org/x/sync v0.0.0-20200317015054-43a5402ce75a/go.mod h1:RxMgew5VJxzue5/jJ golang.org/x/sync v0.0.0-20200625203802-6e8e738ad208/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20201207232520-09787c993a3a/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4 h1:uVc8UZUe6tr40fFVnUP5Oj+veunVezqYl9z7DYw9xzw= -golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.7.0 h1:YsImfSBoP9QPYL0xyKJPq0gcaJdG3rInoqxTWbfQu9M= +golang.org/x/sync v0.7.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= @@ -428,8 +428,8 @@ golang.org/x/sys v0.0.0-20220114195835-da31bd327af9/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.20.0 h1:Od9JTbYCk261bKm4M/mw7AklTlFYIa0bIp9BgSm1S8Y= -golang.org/x/sys v0.20.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/sys v0.22.0 h1:RI27ohtqKCnwULzJLqkv897zojh5/DwS/ENaMzUOaWI= +golang.org/x/sys v0.22.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= @@ -437,8 +437,8 @@ golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3 golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= -golang.org/x/text v0.15.0 h1:h1V/4gjBv8v9cjcR6+AR5+/cIYK5N/WAgiv4xlsEtAk= -golang.org/x/text v0.15.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= +golang.org/x/text v0.16.0 h1:a94ExnEXNtEwYLGJSIUxnWoxoRz/ZcCsV63ROupILh4= +golang.org/x/text v0.16.0/go.mod h1:GhwF1Be+LQoKShO3cGOHzqOgRrGaYc9AvblQOmPVHnI= golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= @@ -563,8 +563,8 @@ google.golang.org/protobuf v1.24.0/go.mod h1:r/3tXBNzIEhYS9I1OUVjXDlt8tc493IdKGj google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c= google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= -google.golang.org/protobuf v1.34.1 h1:9ddQBjfCyZPOHPUiPxpYESBLc+T8P3E+Vo4IbKZgFWg= -google.golang.org/protobuf v1.34.1/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos= +google.golang.org/protobuf v1.34.2 h1:6xV6lTsCfpGD21XK49h7MhtcApnLqkfYgPcdHftf6hg= +google.golang.org/protobuf v1.34.2/go.mod h1:qYOHts0dSfpeUzUFpOMr/WGzszTmLH+DiWniOlNbLDw= gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= diff --git a/db/README.md b/db/README.md index d9418d2fd..0f010dc40 100644 --- a/db/README.md +++ b/db/README.md @@ -23,6 +23,6 @@ func main() { panic(err) } - tree := iavl.NewMutableTree(idbm.NewWrapper(dbm.NewPrefixDB(levelDB, []byte("s/k:main/"))), 0, false, log.NewNopLogger()) + tree := iavl.NewMutableTree(idbm.NewWrapper(dbm.NewPrefixDB(levelDB, []byte("s/k:main/"))), 0, false, NewNopLogger()) } ``` diff --git a/diff_test.go b/diff_test.go index cf54716c7..44f72a12b 100644 --- a/diff_test.go +++ b/diff_test.go @@ -8,7 +8,6 @@ import ( "sort" "testing" - "cosmossdk.io/core/log" "github.com/stretchr/testify/require" dbm "github.com/cosmos/iavl/db" @@ -21,7 +20,7 @@ func TestDiffRoundTrip(t *testing.T) { // apply changeSets to tree db := dbm.NewMemDB() - tree := NewMutableTree(db, 0, true, log.NewNopLogger()) + tree := NewMutableTree(db, 0, true, NewNopLogger()) for i := range changeSets { v, err := tree.SaveChangeSet(changeSets[i]) require.NoError(t, err) @@ -30,7 +29,7 @@ func TestDiffRoundTrip(t *testing.T) { // extract change sets from db var extractChangeSets []*ChangeSet - tree2 := NewImmutableTree(db, 0, true, log.NewNopLogger()) + tree2 := NewImmutableTree(db, 0, true, NewNopLogger()) err := tree2.TraverseStateChanges(0, math.MaxInt64, func(_ int64, changeSet *ChangeSet) error { extractChangeSets = append(extractChangeSets, changeSet) return nil diff --git a/export_test.go b/export_test.go index 41f988302..9772e2ed1 100644 --- a/export_test.go +++ b/export_test.go @@ -5,7 +5,6 @@ import ( "math/rand" "testing" - "cosmossdk.io/core/log" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" @@ -15,7 +14,7 @@ import ( // setupExportTreeBasic sets up a basic tree with a handful of // create/update/delete operations over a few versions. func setupExportTreeBasic(t require.TestingT) *ImmutableTree { - tree := NewMutableTree(dbm.NewMemDB(), 0, false, log.NewNopLogger()) + tree := NewMutableTree(dbm.NewMemDB(), 0, false, NewNopLogger()) _, err := tree.Set([]byte("x"), []byte{255}) require.NoError(t, err) @@ -74,7 +73,7 @@ func setupExportTreeRandom(t *testing.T) *ImmutableTree { ) r := rand.New(rand.NewSource(randSeed)) - tree := NewMutableTree(dbm.NewMemDB(), 0, false, log.NewNopLogger()) + tree := NewMutableTree(dbm.NewMemDB(), 0, false, NewNopLogger()) var version int64 keys := make([][]byte, 0, versionOps) @@ -134,7 +133,7 @@ func setupExportTreeSized(t require.TestingT, treeSize int) *ImmutableTree { ) r := rand.New(rand.NewSource(randSeed)) - tree := NewMutableTree(dbm.NewMemDB(), 0, false, log.NewNopLogger()) + tree := NewMutableTree(dbm.NewMemDB(), 0, false, NewNopLogger()) for i := 0; i < treeSize; i++ { key := make([]byte, keySize) @@ -228,7 +227,7 @@ func TestExporterCompress(t *testing.T) { func TestExporter_Import(t *testing.T) { testcases := map[string]*ImmutableTree{ - "empty tree": NewImmutableTree(dbm.NewMemDB(), 0, false, log.NewNopLogger()), + "empty tree": NewImmutableTree(dbm.NewMemDB(), 0, false, NewNopLogger()), "basic tree": setupExportTreeBasic(t), } if !testing.Short() { @@ -255,7 +254,7 @@ func TestExporter_Import(t *testing.T) { exporter = NewCompressExporter(innerExporter) } - newTree := NewMutableTree(dbm.NewMemDB(), 0, false, log.NewNopLogger()) + newTree := NewMutableTree(dbm.NewMemDB(), 0, false, NewNopLogger()) innerImporter, err := newTree.Import(tree.Version()) require.NoError(t, err) defer innerImporter.Close() @@ -323,7 +322,7 @@ func TestExporter_Close(t *testing.T) { } func TestExporter_DeleteVersionErrors(t *testing.T) { - tree := NewMutableTree(dbm.NewMemDB(), 0, false, log.NewNopLogger()) + tree := NewMutableTree(dbm.NewMemDB(), 0, false, NewNopLogger()) _, err := tree.Set([]byte("a"), []byte{1}) require.NoError(t, err) diff --git a/go.mod b/go.mod index 2c7a5c0c7..13529117f 100644 --- a/go.mod +++ b/go.mod @@ -3,7 +3,7 @@ module github.com/cosmos/iavl go 1.21 require ( - cosmossdk.io/core v0.12.1-0.20240514205955-97c9bbb0341b + cosmossdk.io/core v0.12.1-0.20240725072823-6a2d039e1212 github.com/cosmos/ics23/go v0.10.0 github.com/emicklei/dot v1.6.2 github.com/gogo/protobuf v1.3.2 @@ -14,17 +14,16 @@ require ( ) require ( - github.com/cosmos/gogoproto v1.4.12 // indirect + github.com/cosmos/gogoproto v1.5.0 // indirect github.com/davecgh/go-spew v1.1.1 // indirect github.com/fsnotify/fsnotify v1.5.4 // indirect github.com/golang/snappy v0.0.4 // indirect github.com/google/go-cmp v0.6.0 // indirect - github.com/kr/text v0.2.0 // indirect github.com/onsi/gomega v1.26.0 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect golang.org/x/crypto v0.23.0 // indirect golang.org/x/exp v0.0.0-20231006140011-7918f672742d // indirect - google.golang.org/protobuf v1.34.1 // indirect + google.golang.org/protobuf v1.34.2 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect ) diff --git a/go.sum b/go.sum index 8a4fd72da..3d1601bcd 100644 --- a/go.sum +++ b/go.sum @@ -1,10 +1,9 @@ -cosmossdk.io/core v0.12.1-0.20240514205955-97c9bbb0341b h1:QudoITEtzaPNGltOQSyMbVopBQ2Z28h717nwLhlj6JU= -cosmossdk.io/core v0.12.1-0.20240514205955-97c9bbb0341b/go.mod h1:jJ3gjbqJyHPrTjn2Ad6wjb7Oz90G1ZjDg0JyBii41QE= -github.com/cosmos/gogoproto v1.4.12 h1:vB6Lbe/rtnYGjQuFxkPiPYiCybqFT8QvLipDZP8JpFE= -github.com/cosmos/gogoproto v1.4.12/go.mod h1:LnZob1bXRdUoqMMtwYlcR3wjiElmlC+FkjaZRv1/eLY= +cosmossdk.io/core v0.12.1-0.20240725072823-6a2d039e1212 h1:yLjl2aq6XMa5Zb1aKfwNHn1U+fFmmAtZyWKNWm/yVH8= +cosmossdk.io/core v0.12.1-0.20240725072823-6a2d039e1212/go.mod h1:sLzMwAW9HW+Nm3GltUVHDRSRZbcXLy9+2AYgi2bwt/s= +github.com/cosmos/gogoproto v1.5.0 h1:SDVwzEqZDDBoslaeZg+dGE55hdzHfgUA40pEanMh52o= +github.com/cosmos/gogoproto v1.5.0/go.mod h1:iUM31aofn3ymidYG6bUR5ZFrk+Om8p5s754eMUcyp8I= github.com/cosmos/ics23/go v0.10.0 h1:iXqLLgp2Lp+EdpIuwXTYIQU+AiHj9mOC2X9ab++bZDM= github.com/cosmos/ics23/go v0.10.0/go.mod h1:ZfJSmng/TBNTBkFemHHHj5YY7VAU/MBU980F4VU1NG0= -github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/emicklei/dot v1.6.2 h1:08GN+DD79cy/tzN6uLCT84+2Wk9u+wvqP+Hkx/dIR8A= @@ -24,6 +23,8 @@ github.com/golang/protobuf v1.4.0-rc.2/go.mod h1:LlEzMj4AhA7rCAGe4KMBDvJI+AwstrU github.com/golang/protobuf v1.4.0-rc.4.0.20200313231945-b860323f09d0/go.mod h1:WU3c8KckQ9AFe+yFwt9sWVRKCVIyN9cPHBJSNnbL67w= github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvqG2KuDX0= github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= +github.com/golang/protobuf v1.5.3 h1:KhyjKVUg7Usr/dYsdSqoFveMYd5ko72D+zANwlG1mmg= +github.com/golang/protobuf v1.5.3/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= github.com/golang/snappy v0.0.4 h1:yAGX7huGHXlcLOEtBnF4w7FQwA26wojNCwOYAEhLjQM= github.com/golang/snappy v0.0.4/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= github.com/google/btree v1.1.2 h1:xf4v41cLI2Z6FxbKm+8Bu+m8ifhj15JuZ9sa0jZCMUU= @@ -36,10 +37,6 @@ github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeN github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8= github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= -github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= -github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk= -github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= -github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= github.com/nxadm/tail v1.4.4 h1:DQuhQpB1tVlglWS2hLQ5OV6B5r8aGxSrPc5Qo6uTN78= github.com/nxadm/tail v1.4.4/go.mod h1:kenIhsEOeOJmVchQTgglprH7qJGnHDVpk1VPCcaMI8A= github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= @@ -52,8 +49,6 @@ github.com/onsi/gomega v1.26.0 h1:03cDLK28U6hWvCAns6NeydX3zIm4SF3ci69ulidS32Q= github.com/onsi/gomega v1.26.0/go.mod h1:r+zV744Re+DiYCIPRlYOTxn0YkOLcAnW8k1xXdMPGhM= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= -github.com/rogpeppe/go-internal v1.11.0 h1:cWPaGQEPrBb5/AsnsZesgZZ9yb1OQ+GOISoDNXVBh4M= -github.com/rogpeppe/go-internal v1.11.0/go.mod h1:ddIwULY96R17DhadqLgMfk9H9tvdUzkipdSkR5nkCZA= github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg= github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7 h1:epCh84lMvA70Z7CTTCmYQn2CKbY8j86K7/FAIr141uY= @@ -79,8 +74,8 @@ golang.org/x/net v0.0.0-20200520004742-59133d7f0dd7/go.mod h1:qpuaurCH72eLCgpAm/ golang.org/x/net v0.0.0-20200813134508-3edf25e44fcc/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM= -golang.org/x/net v0.24.0 h1:1PcaxkF854Fu3+lvBIx5SYn9wRlBzzcnHZSiaFFAb0w= -golang.org/x/net v0.24.0/go.mod h1:2Q7sJY5mzlzWjKtYUEXSlBWCdyaioyXzRB2RtU8KVE8= +golang.org/x/net v0.27.0 h1:5K3Njcw06/l2y9vpGCSdcxWOYHOUk3dVNGDXN+FvAys= +golang.org/x/net v0.27.0/go.mod h1:dDi0PyhWNoiUOrAS8uXv/vnScO4wnHQO4mj9fn/RytE= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= @@ -100,14 +95,14 @@ golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220412211240-33da011f77ad/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.20.0 h1:Od9JTbYCk261bKm4M/mw7AklTlFYIa0bIp9BgSm1S8Y= -golang.org/x/sys v0.20.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/sys v0.22.0 h1:RI27ohtqKCnwULzJLqkv897zojh5/DwS/ENaMzUOaWI= +golang.org/x/sys v0.22.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= -golang.org/x/text v0.15.0 h1:h1V/4gjBv8v9cjcR6+AR5+/cIYK5N/WAgiv4xlsEtAk= -golang.org/x/text v0.15.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= +golang.org/x/text v0.16.0 h1:a94ExnEXNtEwYLGJSIUxnWoxoRz/ZcCsV63ROupILh4= +golang.org/x/text v0.16.0/go.mod h1:GhwF1Be+LQoKShO3cGOHzqOgRrGaYc9AvblQOmPVHnI= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= @@ -123,11 +118,10 @@ google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQ google.golang.org/protobuf v1.20.1-0.20200309200217-e05f789c0967/go.mod h1:A+miEFZTKqfCUM6K7xSMQL9OKL/b6hQv+e19PK+JZNE= google.golang.org/protobuf v1.21.0/go.mod h1:47Nbq4nVaFHyn7ilMalzfO3qCViNmqZ2kzikPIcrTAo= google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= -google.golang.org/protobuf v1.34.1 h1:9ddQBjfCyZPOHPUiPxpYESBLc+T8P3E+Vo4IbKZgFWg= -google.golang.org/protobuf v1.34.1/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos= +google.golang.org/protobuf v1.34.2 h1:6xV6lTsCfpGD21XK49h7MhtcApnLqkfYgPcdHftf6hg= +google.golang.org/protobuf v1.34.2/go.mod h1:qYOHts0dSfpeUzUFpOMr/WGzszTmLH+DiWniOlNbLDw= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= -gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q= gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys= gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 h1:uRGJdciOHaEIrze2W8Q3AKkepLTh2hOroT7a+7czfdQ= gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw= diff --git a/immutable_tree.go b/immutable_tree.go index 240cc913f..c800bd804 100644 --- a/immutable_tree.go +++ b/immutable_tree.go @@ -4,7 +4,6 @@ import ( "fmt" "strings" - "cosmossdk.io/core/log" corestore "cosmossdk.io/core/store" dbm "github.com/cosmos/iavl/db" @@ -17,7 +16,7 @@ import ( // Returned key/value byte slices must not be modified, since they may point to data located inside // IAVL which would also be modified. type ImmutableTree struct { - logger log.Logger + logger Logger root *Node ndb *nodeDB @@ -26,7 +25,7 @@ type ImmutableTree struct { } // NewImmutableTree creates both in-memory and persistent instances -func NewImmutableTree(db dbm.DB, cacheSize int, skipFastStorageUpgrade bool, lg log.Logger, options ...Option) *ImmutableTree { +func NewImmutableTree(db dbm.DB, cacheSize int, skipFastStorageUpgrade bool, lg Logger, options ...Option) *ImmutableTree { opts := DefaultOptions() for _, opt := range options { opt(&opts) diff --git a/import_test.go b/import_test.go index aec9406a9..9f4d49aee 100644 --- a/import_test.go +++ b/import_test.go @@ -3,7 +3,6 @@ package iavl import ( "testing" - "cosmossdk.io/core/log" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" @@ -11,7 +10,7 @@ import ( ) func ExampleImporter() { - tree := NewMutableTree(dbm.NewMemDB(), 0, false, log.NewNopLogger()) + tree := NewMutableTree(dbm.NewMemDB(), 0, false, NewNopLogger()) _, err := tree.Set([]byte("a"), []byte{1}) if err != nil { @@ -52,7 +51,7 @@ func ExampleImporter() { exported = append(exported, node) } - newTree := NewMutableTree(dbm.NewMemDB(), 0, false, log.NewNopLogger()) + newTree := NewMutableTree(dbm.NewMemDB(), 0, false, NewNopLogger()) importer, err := newTree.Import(version) if err != nil { panic(err) @@ -71,13 +70,13 @@ func ExampleImporter() { } func TestImporter_NegativeVersion(t *testing.T) { - tree := NewMutableTree(dbm.NewMemDB(), 0, false, log.NewNopLogger()) + tree := NewMutableTree(dbm.NewMemDB(), 0, false, NewNopLogger()) _, err := tree.Import(-1) require.Error(t, err) } func TestImporter_NotEmpty(t *testing.T) { - tree := NewMutableTree(dbm.NewMemDB(), 0, false, log.NewNopLogger()) + tree := NewMutableTree(dbm.NewMemDB(), 0, false, NewNopLogger()) _, err := tree.Set([]byte("a"), []byte{1}) require.NoError(t, err) _, _, err = tree.SaveVersion() @@ -90,13 +89,13 @@ func TestImporter_NotEmpty(t *testing.T) { func TestImporter_NotEmptyDatabase(t *testing.T) { db := dbm.NewMemDB() - tree := NewMutableTree(db, 0, false, log.NewNopLogger()) + tree := NewMutableTree(db, 0, false, NewNopLogger()) _, err := tree.Set([]byte("a"), []byte{1}) require.NoError(t, err) _, _, err = tree.SaveVersion() require.NoError(t, err) - tree = NewMutableTree(db, 0, false, log.NewNopLogger()) + tree = NewMutableTree(db, 0, false, NewNopLogger()) _, err = tree.Load() require.NoError(t, err) @@ -105,7 +104,7 @@ func TestImporter_NotEmptyDatabase(t *testing.T) { } func TestImporter_NotEmptyUnsaved(t *testing.T) { - tree := NewMutableTree(dbm.NewMemDB(), 0, false, log.NewNopLogger()) + tree := NewMutableTree(dbm.NewMemDB(), 0, false, NewNopLogger()) _, err := tree.Set([]byte("a"), []byte{1}) require.NoError(t, err) @@ -132,7 +131,7 @@ func TestImporter_Add(t *testing.T) { for desc, tc := range testcases { tc := tc // appease scopelint t.Run(desc, func(t *testing.T) { - tree := NewMutableTree(dbm.NewMemDB(), 0, false, log.NewNopLogger()) + tree := NewMutableTree(dbm.NewMemDB(), 0, false, NewNopLogger()) importer, err := tree.Import(1) require.NoError(t, err) defer importer.Close() @@ -151,7 +150,7 @@ func TestImporter_Add(t *testing.T) { } func TestImporter_Add_Closed(t *testing.T) { - tree := NewMutableTree(dbm.NewMemDB(), 0, false, log.NewNopLogger()) + tree := NewMutableTree(dbm.NewMemDB(), 0, false, NewNopLogger()) importer, err := tree.Import(1) require.NoError(t, err) @@ -162,7 +161,7 @@ func TestImporter_Add_Closed(t *testing.T) { } func TestImporter_Close(t *testing.T) { - tree := NewMutableTree(dbm.NewMemDB(), 0, false, log.NewNopLogger()) + tree := NewMutableTree(dbm.NewMemDB(), 0, false, NewNopLogger()) importer, err := tree.Import(1) require.NoError(t, err) @@ -178,7 +177,7 @@ func TestImporter_Close(t *testing.T) { } func TestImporter_Commit(t *testing.T) { - tree := NewMutableTree(dbm.NewMemDB(), 0, false, log.NewNopLogger()) + tree := NewMutableTree(dbm.NewMemDB(), 0, false, NewNopLogger()) importer, err := tree.Import(1) require.NoError(t, err) @@ -193,7 +192,7 @@ func TestImporter_Commit(t *testing.T) { } func TestImporter_Commit_ForwardVersion(t *testing.T) { - tree := NewMutableTree(dbm.NewMemDB(), 0, false, log.NewNopLogger()) + tree := NewMutableTree(dbm.NewMemDB(), 0, false, NewNopLogger()) importer, err := tree.Import(2) require.NoError(t, err) @@ -208,7 +207,7 @@ func TestImporter_Commit_ForwardVersion(t *testing.T) { } func TestImporter_Commit_Closed(t *testing.T) { - tree := NewMutableTree(dbm.NewMemDB(), 0, false, log.NewNopLogger()) + tree := NewMutableTree(dbm.NewMemDB(), 0, false, NewNopLogger()) importer, err := tree.Import(1) require.NoError(t, err) @@ -222,7 +221,7 @@ func TestImporter_Commit_Closed(t *testing.T) { } func TestImporter_Commit_Empty(t *testing.T) { - tree := NewMutableTree(dbm.NewMemDB(), 0, false, log.NewNopLogger()) + tree := NewMutableTree(dbm.NewMemDB(), 0, false, NewNopLogger()) importer, err := tree.Import(3) require.NoError(t, err) defer importer.Close() @@ -259,7 +258,7 @@ func benchmarkImport(b *testing.B, nodes int) { b.StartTimer() for n := 0; n < b.N; n++ { - newTree := NewMutableTree(dbm.NewMemDB(), 0, false, log.NewNopLogger()) + newTree := NewMutableTree(dbm.NewMemDB(), 0, false, NewNopLogger()) importer, err := newTree.Import(tree.Version()) require.NoError(b, err) for _, item := range exported { diff --git a/iterator_test.go b/iterator_test.go index f9a1855ea..c4b03f2e5 100644 --- a/iterator_test.go +++ b/iterator_test.go @@ -6,7 +6,6 @@ import ( "sync" "testing" - log "cosmossdk.io/core/log" corestore "cosmossdk.io/core/store" "github.com/stretchr/testify/require" @@ -59,14 +58,14 @@ func TestUnsavedFastIterator_NewIterator_NilAdditions_Failure(t *testing.T) { } t.Run("Nil additions given", func(t *testing.T) { - tree := NewMutableTree(dbm.NewMemDB(), 0, false, log.NewNopLogger()) + tree := NewMutableTree(dbm.NewMemDB(), 0, false, NewNopLogger()) itr := NewUnsavedFastIterator(start, end, ascending, tree.ndb, nil, tree.unsavedFastNodeRemovals) performTest(t, itr) require.ErrorIs(t, errUnsavedFastIteratorNilAdditionsGiven, itr.Error()) }) t.Run("Nil removals given", func(t *testing.T) { - tree := NewMutableTree(dbm.NewMemDB(), 0, false, log.NewNopLogger()) + tree := NewMutableTree(dbm.NewMemDB(), 0, false, NewNopLogger()) itr := NewUnsavedFastIterator(start, end, ascending, tree.ndb, tree.unsavedFastNodeAdditions, nil) performTest(t, itr) require.ErrorIs(t, errUnsavedFastIteratorNilRemovalsGiven, itr.Error()) @@ -79,7 +78,7 @@ func TestUnsavedFastIterator_NewIterator_NilAdditions_Failure(t *testing.T) { }) t.Run("Additions and removals are nil", func(t *testing.T) { - tree := NewMutableTree(dbm.NewMemDB(), 0, false, log.NewNopLogger()) + tree := NewMutableTree(dbm.NewMemDB(), 0, false, NewNopLogger()) itr := NewUnsavedFastIterator(start, end, ascending, tree.ndb, nil, nil) performTest(t, itr) require.ErrorIs(t, errUnsavedFastIteratorNilAdditionsGiven, itr.Error()) @@ -248,7 +247,7 @@ func iteratorSuccessTest(t *testing.T, config *iteratorTestConfig) { } func setupIteratorAndMirror(t *testing.T, config *iteratorTestConfig) (corestore.Iterator, [][]string) { - tree := NewMutableTree(dbm.NewMemDB(), 0, false, log.NewNopLogger()) + tree := NewMutableTree(dbm.NewMemDB(), 0, false, NewNopLogger()) mirror := setupMirrorForIterator(t, config, tree) _, _, err := tree.SaveVersion() @@ -264,7 +263,7 @@ func setupIteratorAndMirror(t *testing.T, config *iteratorTestConfig) (corestore } func setupFastIteratorAndMirror(t *testing.T, config *iteratorTestConfig) (corestore.Iterator, [][]string) { - tree := NewMutableTree(dbm.NewMemDB(), 0, false, log.NewNopLogger()) + tree := NewMutableTree(dbm.NewMemDB(), 0, false, NewNopLogger()) mirror := setupMirrorForIterator(t, config, tree) _, _, err := tree.SaveVersion() @@ -275,7 +274,7 @@ func setupFastIteratorAndMirror(t *testing.T, config *iteratorTestConfig) (cores } func setupUnsavedFastIterator(t *testing.T, config *iteratorTestConfig) (corestore.Iterator, [][]string) { - tree := NewMutableTree(dbm.NewMemDB(), 0, false, log.NewNopLogger()) + tree := NewMutableTree(dbm.NewMemDB(), 0, false, NewNopLogger()) // For unsaved fast iterator, we would like to test the state where // there are saved fast nodes as well as some unsaved additions and removals. @@ -365,11 +364,11 @@ func TestNodeIterator_Success(t *testing.T) { } func TestNodeIterator_WithEmptyRoot(t *testing.T) { - itr, err := NewNodeIterator(nil, newNodeDB(dbm.NewMemDB(), 0, DefaultOptions(), log.NewNopLogger())) + itr, err := NewNodeIterator(nil, newNodeDB(dbm.NewMemDB(), 0, DefaultOptions(), NewNopLogger())) require.NoError(t, err) require.False(t, itr.Valid()) - itr, err = NewNodeIterator([]byte{}, newNodeDB(dbm.NewMemDB(), 0, DefaultOptions(), log.NewNopLogger())) + itr, err = NewNodeIterator([]byte{}, newNodeDB(dbm.NewMemDB(), 0, DefaultOptions(), NewNopLogger())) require.NoError(t, err) require.False(t, itr.Valid()) } diff --git a/logger.go b/logger.go new file mode 100644 index 000000000..2a66a7752 --- /dev/null +++ b/logger.go @@ -0,0 +1,34 @@ +package iavl + +// Logger defines basic logger that IAVL expects. +// It is a subset of the cosmossdk.io/core/log.Logger interface. +// cosmossdk.io/log/log.Logger implements this interface. +type Logger interface { + // Info takes a message and a set of key/value pairs and logs with level INFO. + // The key of the tuple must be a string. + Info(msg string, keyVals ...any) + + // Warn takes a message and a set of key/value pairs and logs with level WARN. + // The key of the tuple must be a string. + Warn(msg string, keyVals ...any) + + // Error takes a message and a set of key/value pairs and logs with level ERR. + // The key of the tuple must be a string. + Error(msg string, keyVals ...any) + + // Debug takes a message and a set of key/value pairs and logs with level DEBUG. + // The key of the tuple must be a string. + Debug(msg string, keyVals ...any) +} + +// NewNopLogger returns a new logger that does nothing. +func NewNopLogger() Logger { + return &noopLogger{} +} + +type noopLogger struct{} + +func (l *noopLogger) Info(string, ...any) {} +func (l *noopLogger) Warn(string, ...any) {} +func (l *noopLogger) Error(string, ...any) {} +func (l *noopLogger) Debug(string, ...any) {} diff --git a/migrate_test.go b/migrate_test.go index 51f511f94..3ace1ab15 100644 --- a/migrate_test.go +++ b/migrate_test.go @@ -10,7 +10,6 @@ import ( "testing" "time" - "cosmossdk.io/core/log" "github.com/stretchr/testify/require" dbm "github.com/cosmos/iavl/db" @@ -65,7 +64,7 @@ func TestLazySet(t *testing.T) { } }() - tree := NewMutableTree(db, 1000, false, log.NewNopLogger()) + tree := NewMutableTree(db, 1000, false, NewNopLogger()) // Load the latest legacy version _, err = tree.LoadVersion(int64(legacyVersion)) @@ -83,7 +82,7 @@ func TestLazySet(t *testing.T) { require.NoError(t, err) } - tree = NewMutableTree(db, 1000, false, log.NewNopLogger()) + tree = NewMutableTree(db, 1000, false, NewNopLogger()) // Verify that the latest legacy version can still be loaded _, err = tree.LoadVersion(int64(legacyVersion)) @@ -108,7 +107,7 @@ func TestLegacyReferenceNode(t *testing.T) { } }() - tree := NewMutableTree(db, 1000, false, log.NewNopLogger()) + tree := NewMutableTree(db, 1000, false, NewNopLogger()) // Load the latest legacy version _, err = tree.LoadVersion(int64(legacyVersion)) @@ -122,7 +121,7 @@ func TestLegacyReferenceNode(t *testing.T) { require.NoError(t, err) // Load the previous version - newTree := NewMutableTree(db, 1000, false, log.NewNopLogger()) + newTree := NewMutableTree(db, 1000, false, NewNopLogger()) _, err = newTree.LoadVersion(version - 1) require.NoError(t, err) // Check if the reference node is refactored @@ -148,7 +147,7 @@ func TestDeleteVersions(t *testing.T) { } }() - tree := NewMutableTree(db, 1000, false, log.NewNopLogger()) + tree := NewMutableTree(db, 1000, false, NewNopLogger()) // Load the latest legacy version _, err = tree.LoadVersion(int64(legacyVersion)) @@ -228,7 +227,7 @@ func TestPruning(t *testing.T) { }() // Load the latest version - tree := NewMutableTree(db, 1000, false, log.NewNopLogger()) + tree := NewMutableTree(db, 1000, false, NewNopLogger()) _, err = tree.Load() require.NoError(t, err) @@ -268,7 +267,7 @@ func TestPruning(t *testing.T) { time.Sleep(500 * time.Millisecond) } // Reload the tree - tree = NewMutableTree(db, 0, false, log.NewNopLogger()) + tree = NewMutableTree(db, 0, false, NewNopLogger()) versions := tree.AvailableVersions() require.Equal(t, versions[0], int(toVersion)+legacyVersion+1) for _, v := range versions { @@ -315,7 +314,7 @@ func TestRandomSet(t *testing.T) { } }() - tree := NewMutableTree(db, 10000, false, log.NewNopLogger()) + tree := NewMutableTree(db, 10000, false, NewNopLogger()) // Load the latest legacy version _, err = tree.LoadVersion(int64(legacyVersion)) diff --git a/mutable_tree.go b/mutable_tree.go index 350e39b93..1497fc074 100644 --- a/mutable_tree.go +++ b/mutable_tree.go @@ -7,7 +7,6 @@ import ( "sort" "sync" - log "cosmossdk.io/core/log" corestore "cosmossdk.io/core/store" dbm "github.com/cosmos/iavl/db" @@ -34,7 +33,7 @@ type Option func(*Options) // // The inner ImmutableTree should not be used directly by callers. type MutableTree struct { - logger log.Logger + logger Logger *ImmutableTree // The current, working tree. lastSaved *ImmutableTree // The most recently saved tree. @@ -47,7 +46,7 @@ type MutableTree struct { } // NewMutableTree returns a new tree with the specified optional options. -func NewMutableTree(db dbm.DB, cacheSize int, skipFastStorageUpgrade bool, lg log.Logger, options ...Option) *MutableTree { +func NewMutableTree(db dbm.DB, cacheSize int, skipFastStorageUpgrade bool, lg Logger, options ...Option) *MutableTree { opts := DefaultOptions() for _, opt := range options { opt(&opts) diff --git a/mutable_tree_test.go b/mutable_tree_test.go index 1f28c572d..9d8aca5cc 100644 --- a/mutable_tree_test.go +++ b/mutable_tree_test.go @@ -10,7 +10,6 @@ import ( "sync" "testing" - "cosmossdk.io/core/log" "github.com/cosmos/iavl/fastnode" "github.com/cosmos/iavl/internal/encoding" @@ -35,7 +34,7 @@ var ( func setupMutableTree(skipFastStorageUpgrade bool) *MutableTree { memDB := dbm.NewMemDB() - tree := NewMutableTree(memDB, 0, skipFastStorageUpgrade, log.NewNopLogger()) + tree := NewMutableTree(memDB, 0, skipFastStorageUpgrade, NewNopLogger()) return tree } @@ -257,7 +256,7 @@ func TestMutableTree_LoadVersion_Empty(t *testing.T) { func TestMutableTree_InitialVersion(t *testing.T) { memDB := dbm.NewMemDB() - tree := NewMutableTree(memDB, 0, false, log.NewNopLogger(), InitialVersionOption(9)) + tree := NewMutableTree(memDB, 0, false, NewNopLogger(), InitialVersionOption(9)) _, err := tree.Set([]byte("a"), []byte{0x01}) require.NoError(t, err) @@ -272,18 +271,18 @@ func TestMutableTree_InitialVersion(t *testing.T) { assert.EqualValues(t, 10, version) // Reloading the tree with the same initial version is fine - tree = NewMutableTree(memDB, 0, false, log.NewNopLogger(), InitialVersionOption(9)) + tree = NewMutableTree(memDB, 0, false, NewNopLogger(), InitialVersionOption(9)) version, err = tree.Load() require.NoError(t, err) assert.EqualValues(t, 10, version) // Reloading the tree with an initial version beyond the lowest should error - tree = NewMutableTree(memDB, 0, false, log.NewNopLogger(), InitialVersionOption(10)) + tree = NewMutableTree(memDB, 0, false, NewNopLogger(), InitialVersionOption(10)) _, err = tree.Load() require.Error(t, err) // Reloading the tree with a lower initial version is fine, and new versions can be produced - tree = NewMutableTree(memDB, 0, false, log.NewNopLogger(), InitialVersionOption(3)) + tree = NewMutableTree(memDB, 0, false, NewNopLogger(), InitialVersionOption(3)) version, err = tree.Load() require.NoError(t, err) assert.EqualValues(t, 10, version) @@ -308,7 +307,7 @@ func TestMutableTree_SetInitialVersion(t *testing.T) { func BenchmarkMutableTree_Set(b *testing.B) { db := dbm.NewMemDB() - t := NewMutableTree(db, 100000, false, log.NewNopLogger()) + t := NewMutableTree(db, 100000, false, NewNopLogger()) for i := 0; i < 1000000; i++ { _, err := t.Set(iavlrand.RandBytes(10), []byte{}) require.NoError(b, err) @@ -326,7 +325,7 @@ func BenchmarkMutableTree_Set(b *testing.B) { func prepareTree(t *testing.T) *MutableTree { mdb := dbm.NewMemDB() - tree := NewMutableTree(mdb, 1000, false, log.NewNopLogger()) + tree := NewMutableTree(mdb, 1000, false, NewNopLogger()) for i := 0; i < 100; i++ { _, err := tree.Set([]byte{byte(i)}, []byte("a")) require.NoError(t, err) @@ -342,7 +341,7 @@ func prepareTree(t *testing.T) *MutableTree { require.True(t, ver == 2) require.NoError(t, err) - newTree := NewMutableTree(mdb, 1000, false, log.NewNopLogger()) + newTree := NewMutableTree(mdb, 1000, false, NewNopLogger()) return newTree } @@ -401,16 +400,16 @@ func TestMutableTree_DeleteVersion(t *testing.T) { func TestMutableTree_LazyLoadVersionWithEmptyTree(t *testing.T) { mdb := dbm.NewMemDB() - tree := NewMutableTree(mdb, 1000, false, log.NewNopLogger()) + tree := NewMutableTree(mdb, 1000, false, NewNopLogger()) _, v1, err := tree.SaveVersion() require.NoError(t, err) - newTree1 := NewMutableTree(mdb, 1000, false, log.NewNopLogger()) + newTree1 := NewMutableTree(mdb, 1000, false, NewNopLogger()) v2, err := newTree1.LoadVersion(1) require.NoError(t, err) require.True(t, v1 == v2) - newTree2 := NewMutableTree(mdb, 1000, false, log.NewNopLogger()) + newTree2 := NewMutableTree(mdb, 1000, false, NewNopLogger()) v2, err = newTree1.LoadVersion(1) require.NoError(t, err) require.True(t, v1 == v2) @@ -420,7 +419,7 @@ func TestMutableTree_LazyLoadVersionWithEmptyTree(t *testing.T) { func TestMutableTree_SetSimple(t *testing.T) { mdb := dbm.NewMemDB() - tree := NewMutableTree(mdb, 0, false, log.NewNopLogger()) + tree := NewMutableTree(mdb, 0, false, NewNopLogger()) const testKey1 = "a" const testVal1 = "test" @@ -591,7 +590,7 @@ func TestMutableTree_SetRemoveSet(t *testing.T) { func TestMutableTree_FastNodeIntegration(t *testing.T) { mdb := dbm.NewMemDB() - tree := NewMutableTree(mdb, 1000, false, log.NewNopLogger()) + tree := NewMutableTree(mdb, 1000, false, NewNopLogger()) const key1 = "a" const key2 = "b" @@ -655,7 +654,7 @@ func TestMutableTree_FastNodeIntegration(t *testing.T) { require.Equal(t, len(unsavedNodeRemovals), 0) // Load - t2 := NewMutableTree(mdb, 0, false, log.NewNopLogger()) + t2 := NewMutableTree(mdb, 0, false, NewNopLogger()) _, err = t2.Load() require.NoError(t, err) @@ -722,7 +721,7 @@ func TestIterator_MutableTree_Invalid(t *testing.T) { func TestUpgradeStorageToFast_LatestVersion_Success(t *testing.T) { // Setup db := dbm.NewMemDB() - tree := NewMutableTree(db, 1000, false, log.NewNopLogger()) + tree := NewMutableTree(db, 1000, false, NewNopLogger()) // Default version when storage key does not exist in the db isFastCacheEnabled, err := tree.IsFastCacheEnabled() @@ -752,7 +751,7 @@ func TestUpgradeStorageToFast_LatestVersion_Success(t *testing.T) { func TestUpgradeStorageToFast_AlreadyUpgraded_Success(t *testing.T) { // Setup db := dbm.NewMemDB() - tree := NewMutableTree(db, 1000, false, log.NewNopLogger()) + tree := NewMutableTree(db, 1000, false, NewNopLogger()) // Default version when storage key does not exist in the db isFastCacheEnabled, err := tree.IsFastCacheEnabled() @@ -802,7 +801,7 @@ func TestUpgradeStorageToFast_DbErrorConstructor_Failure(t *testing.T) { dbMock.EXPECT().NewBatchWithSize(gomock.Any()).Return(nil).Times(1) dbMock.EXPECT().ReverseIterator(gomock.Any(), gomock.Any()).Return(rIterMock, nil).Times(1) - tree := NewMutableTree(dbMock, 0, false, log.NewNopLogger()) + tree := NewMutableTree(dbMock, 0, false, NewNopLogger()) require.NotNil(t, tree) isFastCacheEnabled, err := tree.IsFastCacheEnabled() @@ -837,7 +836,7 @@ func TestUpgradeStorageToFast_DbErrorEnableFastStorage_Failure(t *testing.T) { batchMock.EXPECT().Set(gomock.Any(), gomock.Any()).Return(expectedError).Times(1) batchMock.EXPECT().GetByteSize().Return(100, nil).Times(1) - tree := NewMutableTree(dbMock, 0, false, log.NewNopLogger()) + tree := NewMutableTree(dbMock, 0, false, NewNopLogger()) require.NotNil(t, tree) isFastCacheEnabled, err := tree.IsFastCacheEnabled() @@ -877,7 +876,7 @@ func TestFastStorageReUpgradeProtection_NoForceUpgrade_Success(t *testing.T) { dbMock.EXPECT().NewBatchWithSize(gomock.Any()).Return(batchMock).Times(1) dbMock.EXPECT().ReverseIterator(gomock.Any(), gomock.Any()).Return(rIterMock, nil).Times(1) // called to get latest version - tree := NewMutableTree(dbMock, 0, false, log.NewNopLogger()) + tree := NewMutableTree(dbMock, 0, false, NewNopLogger()) require.NotNil(t, tree) // Pretend that we called Load and have the latest state in the tree @@ -971,7 +970,7 @@ func TestFastStorageReUpgradeProtection_ForceUpgradeFirstTime_NoForceSecondTime_ iterMock.EXPECT().Valid().Return(false).Times(1) iterMock.EXPECT().Close().Return(nil).Times(1) - tree := NewMutableTree(dbMock, 0, false, log.NewNopLogger()) + tree := NewMutableTree(dbMock, 0, false, NewNopLogger()) require.NotNil(t, tree) // Pretend that we called Load and have the latest state in the tree @@ -1021,7 +1020,7 @@ func TestUpgradeStorageToFast_Integration_Upgraded_FastIterator_Success(t *testi require.False(t, isUpgradeable) require.NoError(t, err) - sut := NewMutableTree(tree.ndb.db, 1000, false, log.NewNopLogger()) + sut := NewMutableTree(tree.ndb.db, 1000, false, NewNopLogger()) isFastCacheEnabled, err = sut.IsFastCacheEnabled() require.NoError(t, err) @@ -1088,7 +1087,7 @@ func TestUpgradeStorageToFast_Integration_Upgraded_GetFast_Success(t *testing.T) require.False(t, isUpgradeable) require.NoError(t, err) - sut := NewMutableTree(tree.ndb.db, 1000, false, log.NewNopLogger()) + sut := NewMutableTree(tree.ndb.db, 1000, false, NewNopLogger()) isFastCacheEnabled, err = sut.IsFastCacheEnabled() require.NoError(t, err) @@ -1221,7 +1220,7 @@ func TestUpgradeStorageToFast_Delete_Stale_Success(t *testing.T) { func setupTreeAndMirror(t *testing.T, numEntries int, skipFastStorageUpgrade bool) (*MutableTree, [][]string) { db := dbm.NewMemDB() - tree := NewMutableTree(db, 0, skipFastStorageUpgrade, log.NewNopLogger()) + tree := NewMutableTree(db, 0, skipFastStorageUpgrade, NewNopLogger()) keyPrefix, valPrefix := "key", "val" @@ -1269,7 +1268,7 @@ func TestNoFastStorageUpgrade_Integration_SaveVersion_Load_Get_Success(t *testin require.False(t, isUpgradeable) require.NoError(t, err) - sut := NewMutableTree(tree.ndb.db, 1000, true, log.NewNopLogger()) + sut := NewMutableTree(tree.ndb.db, 1000, true, NewNopLogger()) isFastCacheEnabled, err = sut.IsFastCacheEnabled() require.NoError(t, err) @@ -1356,7 +1355,7 @@ func TestNoFastStorageUpgrade_Integration_SaveVersion_Load_Iterate_Success(t *te require.False(t, isUpgradeable) require.NoError(t, err) - sut := NewMutableTree(tree.ndb.db, 1000, true, log.NewNopLogger()) + sut := NewMutableTree(tree.ndb.db, 1000, true, NewNopLogger()) isFastCacheEnabled, err = sut.IsFastCacheEnabled() require.NoError(t, err) @@ -1415,7 +1414,7 @@ func TestMutableTree_InitialVersion_FirstVersion(t *testing.T) { db := dbm.NewMemDB() initialVersion := int64(1000) - tree := NewMutableTree(db, 0, true, log.NewNopLogger(), InitialVersionOption(uint64(initialVersion))) + tree := NewMutableTree(db, 0, true, NewNopLogger(), InitialVersionOption(uint64(initialVersion))) _, err := tree.Set([]byte("hello"), []byte("world")) require.NoError(t, err) @@ -1444,7 +1443,7 @@ func TestMutableTree_InitialVersion_FirstVersion(t *testing.T) { func TestMutableTreeClose(t *testing.T) { db := dbm.NewMemDB() - tree := NewMutableTree(db, 0, true, log.NewNopLogger()) + tree := NewMutableTree(db, 0, true, NewNopLogger()) _, err := tree.Set([]byte("hello"), []byte("world")) require.NoError(t, err) diff --git a/nodedb.go b/nodedb.go index f3c1f06c3..a71708b31 100644 --- a/nodedb.go +++ b/nodedb.go @@ -12,7 +12,6 @@ import ( "sync" "time" - "cosmossdk.io/core/log" corestore "cosmossdk.io/core/store" "github.com/cosmos/iavl/cache" @@ -77,7 +76,7 @@ var ( var errInvalidFastStorageVersion = fmt.Errorf("fast storage version must be in the format %s", fastStorageVersionDelimiter) type nodeDB struct { - logger log.Logger + logger Logger mtx sync.Mutex // Read/write lock. db dbm.DB // Persistent node storage. @@ -92,7 +91,7 @@ type nodeDB struct { fastNodeCache cache.Cache // Cache for nodes in the fast index that represents only key-value pairs at the latest version. } -func newNodeDB(db dbm.DB, cacheSize int, opts Options, lg log.Logger) *nodeDB { +func newNodeDB(db dbm.DB, cacheSize int, opts Options, lg Logger) *nodeDB { storeVersion, err := db.Get(metadataKeyFormat.Key([]byte(storageVersionKey))) if err != nil || storeVersion == nil { diff --git a/nodedb_test.go b/nodedb_test.go index a9af51b63..be8314241 100644 --- a/nodedb_test.go +++ b/nodedb_test.go @@ -7,7 +7,6 @@ import ( "testing" "time" - log "cosmossdk.io/core/log" "github.com/golang/mock/gomock" "github.com/stretchr/testify/require" @@ -51,7 +50,7 @@ func TestNewNoDbStorage_StorageVersionInDb_Success(t *testing.T) { dbMock.EXPECT().Get(gomock.Any()).Return([]byte(expectedVersion), nil).Times(1) dbMock.EXPECT().NewBatchWithSize(gomock.Any()).Return(nil).Times(1) - ndb := newNodeDB(dbMock, 0, DefaultOptions(), log.NewNopLogger()) + ndb := newNodeDB(dbMock, 0, DefaultOptions(), NewNopLogger()) require.Equal(t, expectedVersion, ndb.storageVersion) } @@ -63,7 +62,7 @@ func TestNewNoDbStorage_ErrorInConstructor_DefaultSet(t *testing.T) { dbMock.EXPECT().Get(gomock.Any()).Return(nil, errors.New("some db error")).Times(1) dbMock.EXPECT().NewBatchWithSize(gomock.Any()).Return(nil).Times(1) - ndb := newNodeDB(dbMock, 0, DefaultOptions(), log.NewNopLogger()) + ndb := newNodeDB(dbMock, 0, DefaultOptions(), NewNopLogger()) require.Equal(t, expectedVersion, ndb.getStorageVersion()) } @@ -76,7 +75,7 @@ func TestNewNoDbStorage_DoesNotExist_DefaultSet(t *testing.T) { dbMock.EXPECT().Get(gomock.Any()).Return(nil, nil).Times(1) dbMock.EXPECT().NewBatchWithSize(gomock.Any()).Return(nil).Times(1) - ndb := newNodeDB(dbMock, 0, DefaultOptions(), log.NewNopLogger()) + ndb := newNodeDB(dbMock, 0, DefaultOptions(), NewNopLogger()) require.Equal(t, expectedVersion, ndb.getStorageVersion()) } @@ -85,7 +84,7 @@ func TestSetStorageVersion_Success(t *testing.T) { db := dbm.NewMemDB() - ndb := newNodeDB(db, 0, DefaultOptions(), log.NewNopLogger()) + ndb := newNodeDB(db, 0, DefaultOptions(), NewNopLogger()) require.Equal(t, defaultStorageVersionValue, ndb.getStorageVersion()) latestVersion, err := ndb.getLatestVersion() @@ -113,7 +112,7 @@ func TestSetStorageVersion_DBFailure_OldKept(t *testing.T) { batchMock.EXPECT().GetByteSize().Return(100, nil).Times(1) batchMock.EXPECT().Set(metadataKeyFormat.Key([]byte(storageVersionKey)), []byte(fastStorageVersionValue+fastStorageVersionDelimiter+strconv.Itoa(expectedFastCacheVersion))).Return(errors.New(expectedErrorMsg)).Times(1) - ndb := newNodeDB(dbMock, 0, DefaultOptions(), log.NewNopLogger()) + ndb := newNodeDB(dbMock, 0, DefaultOptions(), NewNopLogger()) require.Equal(t, defaultStorageVersionValue, ndb.getStorageVersion()) err := ndb.SetFastStorageVersionToBatch(int64(expectedFastCacheVersion)) @@ -134,7 +133,7 @@ func TestSetStorageVersion_InvalidVersionFailure_OldKept(t *testing.T) { dbMock.EXPECT().Get(gomock.Any()).Return([]byte(invalidStorageVersion), nil).Times(1) dbMock.EXPECT().NewBatchWithSize(gomock.Any()).Return(batchMock).Times(1) - ndb := newNodeDB(dbMock, 0, DefaultOptions(), log.NewNopLogger()) + ndb := newNodeDB(dbMock, 0, DefaultOptions(), NewNopLogger()) require.Equal(t, invalidStorageVersion, ndb.getStorageVersion()) err := ndb.SetFastStorageVersionToBatch(0) @@ -145,7 +144,7 @@ func TestSetStorageVersion_InvalidVersionFailure_OldKept(t *testing.T) { func TestSetStorageVersion_FastVersionFirst_VersionAppended(t *testing.T) { db := dbm.NewMemDB() - ndb := newNodeDB(db, 0, DefaultOptions(), log.NewNopLogger()) + ndb := newNodeDB(db, 0, DefaultOptions(), NewNopLogger()) ndb.storageVersion = fastStorageVersionValue ndb.latestVersion = 100 @@ -156,7 +155,7 @@ func TestSetStorageVersion_FastVersionFirst_VersionAppended(t *testing.T) { func TestSetStorageVersion_FastVersionSecond_VersionAppended(t *testing.T) { db := dbm.NewMemDB() - ndb := newNodeDB(db, 0, DefaultOptions(), log.NewNopLogger()) + ndb := newNodeDB(db, 0, DefaultOptions(), NewNopLogger()) ndb.latestVersion = 100 storageVersionBytes := []byte(fastStorageVersionValue) @@ -170,7 +169,7 @@ func TestSetStorageVersion_FastVersionSecond_VersionAppended(t *testing.T) { func TestSetStorageVersion_SameVersionTwice(t *testing.T) { db := dbm.NewMemDB() - ndb := newNodeDB(db, 0, DefaultOptions(), log.NewNopLogger()) + ndb := newNodeDB(db, 0, DefaultOptions(), NewNopLogger()) ndb.latestVersion = 100 storageVersionBytes := []byte(fastStorageVersionValue) @@ -190,7 +189,7 @@ func TestSetStorageVersion_SameVersionTwice(t *testing.T) { // Test case where version is incorrect and has some extra garbage at the end func TestShouldForceFastStorageUpdate_DefaultVersion_True(t *testing.T) { db := dbm.NewMemDB() - ndb := newNodeDB(db, 0, DefaultOptions(), log.NewNopLogger()) + ndb := newNodeDB(db, 0, DefaultOptions(), NewNopLogger()) ndb.storageVersion = defaultStorageVersionValue ndb.latestVersion = 100 @@ -201,7 +200,7 @@ func TestShouldForceFastStorageUpdate_DefaultVersion_True(t *testing.T) { func TestShouldForceFastStorageUpdate_FastVersion_Greater_True(t *testing.T) { db := dbm.NewMemDB() - ndb := newNodeDB(db, 0, DefaultOptions(), log.NewNopLogger()) + ndb := newNodeDB(db, 0, DefaultOptions(), NewNopLogger()) ndb.latestVersion = 100 ndb.storageVersion = fastStorageVersionValue + fastStorageVersionDelimiter + strconv.Itoa(int(ndb.latestVersion+1)) @@ -212,7 +211,7 @@ func TestShouldForceFastStorageUpdate_FastVersion_Greater_True(t *testing.T) { func TestShouldForceFastStorageUpdate_FastVersion_Smaller_True(t *testing.T) { db := dbm.NewMemDB() - ndb := newNodeDB(db, 0, DefaultOptions(), log.NewNopLogger()) + ndb := newNodeDB(db, 0, DefaultOptions(), NewNopLogger()) ndb.latestVersion = 100 ndb.storageVersion = fastStorageVersionValue + fastStorageVersionDelimiter + strconv.Itoa(int(ndb.latestVersion-1)) @@ -223,7 +222,7 @@ func TestShouldForceFastStorageUpdate_FastVersion_Smaller_True(t *testing.T) { func TestShouldForceFastStorageUpdate_FastVersion_Match_False(t *testing.T) { db := dbm.NewMemDB() - ndb := newNodeDB(db, 0, DefaultOptions(), log.NewNopLogger()) + ndb := newNodeDB(db, 0, DefaultOptions(), NewNopLogger()) ndb.latestVersion = 100 ndb.storageVersion = fastStorageVersionValue + fastStorageVersionDelimiter + strconv.Itoa(int(ndb.latestVersion)) @@ -234,7 +233,7 @@ func TestShouldForceFastStorageUpdate_FastVersion_Match_False(t *testing.T) { func TestIsFastStorageEnabled_True(t *testing.T) { db := dbm.NewMemDB() - ndb := newNodeDB(db, 0, DefaultOptions(), log.NewNopLogger()) + ndb := newNodeDB(db, 0, DefaultOptions(), NewNopLogger()) ndb.latestVersion = 100 ndb.storageVersion = fastStorageVersionValue + fastStorageVersionDelimiter + strconv.Itoa(int(ndb.latestVersion)) @@ -243,7 +242,7 @@ func TestIsFastStorageEnabled_True(t *testing.T) { func TestIsFastStorageEnabled_False(t *testing.T) { db := dbm.NewMemDB() - ndb := newNodeDB(db, 0, DefaultOptions(), log.NewNopLogger()) + ndb := newNodeDB(db, 0, DefaultOptions(), NewNopLogger()) ndb.latestVersion = 100 ndb.storageVersion = defaultStorageVersionValue @@ -380,7 +379,7 @@ func TestNodeDB_traverseOrphans(t *testing.T) { func makeAndPopulateMutableTree(tb testing.TB) *MutableTree { memDB := dbm.NewMemDB() - tree := NewMutableTree(memDB, 0, false, log.NewNopLogger(), InitialVersionOption(9)) + tree := NewMutableTree(memDB, 0, false, NewNopLogger(), InitialVersionOption(9)) for i := 0; i < 1e4; i++ { buf := make([]byte, 0, (i/255)+1) @@ -399,7 +398,7 @@ func TestDeleteVersionsFromNoDeadlock(t *testing.T) { db := dbm.NewMemDB() - ndb := newNodeDB(db, 0, DefaultOptions(), log.NewNopLogger()) + ndb := newNodeDB(db, 0, DefaultOptions(), NewNopLogger()) require.Equal(t, defaultStorageVersionValue, ndb.getStorageVersion()) err := ndb.SetFastStorageVersionToBatch(ndb.latestVersion) diff --git a/proof_iavl_test.go b/proof_iavl_test.go index ea95fffb5..42ace0f41 100644 --- a/proof_iavl_test.go +++ b/proof_iavl_test.go @@ -4,14 +4,13 @@ import ( "fmt" "testing" - log "cosmossdk.io/core/log" "github.com/stretchr/testify/require" dbm "github.com/cosmos/iavl/db" ) func TestProofOp(t *testing.T) { - tree := NewMutableTree(dbm.NewMemDB(), 0, false, log.NewNopLogger()) + tree := NewMutableTree(dbm.NewMemDB(), 0, false, NewNopLogger()) keys := []byte{0x0a, 0x11, 0x2e, 0x32, 0x50, 0x72, 0x99, 0xa1, 0xe4, 0xf7} // 10 total. for _, ikey := range keys { key := []byte{ikey} diff --git a/proof_ics23_test.go b/proof_ics23_test.go index b9e017725..fc56d17cd 100644 --- a/proof_ics23_test.go +++ b/proof_ics23_test.go @@ -7,7 +7,6 @@ import ( "sort" "testing" - log "cosmossdk.io/core/log" ics23 "github.com/cosmos/ics23/go" "github.com/stretchr/testify/require" @@ -204,7 +203,7 @@ func GetNonKey(allkeys [][]byte, loc Where) []byte { // BuildTree creates random key/values and stores in tree // returns a list of all keys in sorted order func BuildTree(size int, cacheSize int) (itree *MutableTree, keys [][]byte, err error) { - tree := NewMutableTree(dbm.NewMemDB(), cacheSize, false, log.NewNopLogger()) + tree := NewMutableTree(dbm.NewMemDB(), cacheSize, false, NewNopLogger()) // insert lots of info and store the bytes keys = make([][]byte, size) diff --git a/testutils_test.go b/testutils_test.go index f150873f3..62e8ca36a 100644 --- a/testutils_test.go +++ b/testutils_test.go @@ -9,7 +9,6 @@ import ( "sort" "testing" - log "cosmossdk.io/core/log" corestore "cosmossdk.io/core/store" "github.com/stretchr/testify/require" @@ -44,7 +43,7 @@ func b2i(bz []byte) int { // Construct a MutableTree func getTestTree(cacheSize int) *MutableTree { - return NewMutableTree(dbm.NewMemDB(), cacheSize, false, log.NewNopLogger()) + return NewMutableTree(dbm.NewMemDB(), cacheSize, false, NewNopLogger()) } // Convenience for a new node @@ -322,7 +321,7 @@ func benchmarkImmutableAvlTreeWithDB(b *testing.B, db dbm.DB) { b.StopTimer() - t := NewMutableTree(db, 100000, false, log.NewNopLogger()) + t := NewMutableTree(db, 100000, false, NewNopLogger()) value := []byte{} for i := 0; i < 1000000; i++ { diff --git a/tree_random_test.go b/tree_random_test.go index 7e2c6905a..00f069523 100644 --- a/tree_random_test.go +++ b/tree_random_test.go @@ -10,7 +10,6 @@ import ( "strings" "testing" - "cosmossdk.io/core/log" "github.com/stretchr/testify/require" dbm "github.com/cosmos/iavl/db" @@ -80,7 +79,7 @@ func testRandomOperations(t *testing.T, randSeed int64) { if !(r.Float64() < cacheChance) { cacheSize = 0 } - tree = NewMutableTree(levelDB, cacheSize, false, log.NewNopLogger(), SyncOption(sync)) + tree = NewMutableTree(levelDB, cacheSize, false, NewNopLogger(), SyncOption(sync)) version, err = tree.Load() require.NoError(t, err) t.Logf("Loaded version %v (sync=%v cache=%v)", version, sync, cacheSize) diff --git a/tree_test.go b/tree_test.go index 28c5bfcb1..3fec9237b 100644 --- a/tree_test.go +++ b/tree_test.go @@ -12,7 +12,6 @@ import ( "strconv" "testing" - "cosmossdk.io/core/log" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" @@ -54,7 +53,7 @@ func TestVersionedRandomTree(t *testing.T) { d, closeDB := getTestDB() defer closeDB() - tree := NewMutableTree(d, 100, false, log.NewNopLogger()) + tree := NewMutableTree(d, 100, false, NewNopLogger()) versions := 50 keysPerVersion := 30 @@ -130,7 +129,7 @@ func TestTreeHash(t *testing.T) { require.Len(t, expectHashes, versions, "must have expected hashes for all versions") r := rand.New(rand.NewSource(randSeed)) - tree := NewMutableTree(dbm.NewMemDB(), 0, false, log.NewNopLogger()) + tree := NewMutableTree(dbm.NewMemDB(), 0, false, NewNopLogger()) keys := make([][]byte, 0, versionOps) for i := 0; i < versions; i++ { @@ -180,7 +179,7 @@ func TestVersionedRandomTreeSmallKeys(t *testing.T) { d, closeDB := getTestDB() defer closeDB() - tree := NewMutableTree(d, 100, false, log.NewNopLogger()) + tree := NewMutableTree(d, 100, false, NewNopLogger()) singleVersionTree := getTestTree(0) versions := 20 keysPerVersion := 50 @@ -228,7 +227,7 @@ func TestVersionedRandomTreeSmallKeysRandomDeletes(t *testing.T) { d, closeDB := getTestDB() defer closeDB() - tree := NewMutableTree(d, 100, false, log.NewNopLogger()) + tree := NewMutableTree(d, 100, false, NewNopLogger()) singleVersionTree := getTestTree(0) versions := 30 keysPerVersion := 50 @@ -319,7 +318,7 @@ func TestVersionedEmptyTree(t *testing.T) { d, closeDB := getTestDB() defer closeDB() - tree := NewMutableTree(d, 0, false, log.NewNopLogger()) + tree := NewMutableTree(d, 0, false, NewNopLogger()) hash, v, err := tree.SaveVersion() require.NoError(err) @@ -359,7 +358,7 @@ func TestVersionedEmptyTree(t *testing.T) { tree.Set([]byte("k"), []byte("v")) // Now reload the tree. - tree = NewMutableTree(d, 0, false, log.NewNopLogger()) + tree = NewMutableTree(d, 0, false, NewNopLogger()) tree.Load() require.False(tree.VersionExists(1)) @@ -375,7 +374,7 @@ func TestVersionedTree(t *testing.T) { d, closeDB := getTestDB() defer closeDB() - tree := NewMutableTree(d, 0, false, log.NewNopLogger()) + tree := NewMutableTree(d, 0, false, NewNopLogger()) // We start with empty database. require.Equal(0, tree.ndb.size()) @@ -425,7 +424,7 @@ func TestVersionedTree(t *testing.T) { // Recreate a new tree and load it, to make sure it works in this // scenario. - tree = NewMutableTree(d, 100, false, log.NewNopLogger()) + tree = NewMutableTree(d, 100, false, NewNopLogger()) _, err = tree.Load() require.NoError(err) @@ -478,7 +477,7 @@ func TestVersionedTree(t *testing.T) { require.EqualValues(hash3, hash4) require.NotNil(hash4) - tree = NewMutableTree(d, 100, false, log.NewNopLogger()) + tree = NewMutableTree(d, 100, false, NewNopLogger()) _, err = tree.Load() require.NoError(err) @@ -593,7 +592,7 @@ func TestVersionedTreeVersionDeletingEfficiency(t *testing.T) { d, closeDB := getTestDB() defer closeDB() - tree := NewMutableTree(d, 0, false, log.NewNopLogger()) + tree := NewMutableTree(d, 0, false, NewNopLogger()) tree.Set([]byte("key0"), []byte("val0")) tree.Set([]byte("key1"), []byte("val0")) @@ -685,7 +684,7 @@ func TestVersionedTreeSpecialCase(t *testing.T) { d, closeDB := getTestDB() defer closeDB() - tree := NewMutableTree(d, 0, false, log.NewNopLogger()) + tree := NewMutableTree(d, 0, false, NewNopLogger()) tree.Set([]byte("key1"), []byte("val0")) tree.Set([]byte("key2"), []byte("val0")) @@ -709,7 +708,7 @@ func TestVersionedTreeSpecialCase2(t *testing.T) { require := require.New(t) d := dbm.NewMemDB() - tree := NewMutableTree(d, 100, false, log.NewNopLogger()) + tree := NewMutableTree(d, 100, false, NewNopLogger()) tree.Set([]byte("key1"), []byte("val0")) tree.Set([]byte("key2"), []byte("val0")) @@ -722,7 +721,7 @@ func TestVersionedTreeSpecialCase2(t *testing.T) { tree.Set([]byte("key2"), []byte("val2")) tree.SaveVersion() - tree = NewMutableTree(d, 100, false, log.NewNopLogger()) + tree = NewMutableTree(d, 100, false, NewNopLogger()) _, err := tree.Load() require.NoError(err) @@ -766,7 +765,7 @@ func TestVersionedTreeSpecialCase3(t *testing.T) { func TestVersionedTreeSaveAndLoad(t *testing.T) { require := require.New(t) d := dbm.NewMemDB() - tree := NewMutableTree(d, 0, false, log.NewNopLogger()) + tree := NewMutableTree(d, 0, false, NewNopLogger()) // Loading with an empty root is a no-op. tree.Load() @@ -790,7 +789,7 @@ func TestVersionedTreeSaveAndLoad(t *testing.T) { require.Equal(int64(6), tree.Version()) // Reload the tree, to test that roots and orphans are properly loaded. - ntree := NewMutableTree(d, 0, false, log.NewNopLogger()) + ntree := NewMutableTree(d, 0, false, NewNopLogger()) ntree.Load() require.False(ntree.IsEmpty()) @@ -907,7 +906,7 @@ func TestVersionedCheckpointsSpecialCase3(_ *testing.T) { } func TestVersionedCheckpointsSpecialCase4(t *testing.T) { - tree := NewMutableTree(dbm.NewMemDB(), 0, false, log.NewNopLogger()) + tree := NewMutableTree(dbm.NewMemDB(), 0, false, NewNopLogger()) tree.Set([]byte("U"), []byte("XamDUtiJ")) tree.Set([]byte("A"), []byte("UkZBuYIU")) @@ -1026,7 +1025,7 @@ func TestVersionedCheckpointsSpecialCase7(_ *testing.T) { func TestVersionedTreeEfficiency(t *testing.T) { require := require.New(t) - tree := NewMutableTree(dbm.NewMemDB(), 0, false, log.NewNopLogger()) + tree := NewMutableTree(dbm.NewMemDB(), 0, false, NewNopLogger()) versions := 20 keysPerVersion := 100 keysAddedPerVersion := map[int]int{} @@ -1154,7 +1153,7 @@ func TestOrphans(t *testing.T) { // Then randomly delete versions other than the first and last until only those two remain // Any remaining orphan nodes should either have fromVersion == firstVersion || toVersion == lastVersion require := require.New(t) - tree := NewMutableTree(dbm.NewMemDB(), 100, false, log.NewNopLogger()) + tree := NewMutableTree(dbm.NewMemDB(), 100, false, NewNopLogger()) NUMVERSIONS := 100 NUMUPDATES := 100 @@ -1305,7 +1304,7 @@ func TestOverwrite(t *testing.T) { require := require.New(t) mdb := dbm.NewMemDB() - tree := NewMutableTree(mdb, 0, false, log.NewNopLogger()) + tree := NewMutableTree(mdb, 0, false, NewNopLogger()) // Set one kv pair and save version 1 tree.Set([]byte("key1"), []byte("value1")) @@ -1318,7 +1317,7 @@ func TestOverwrite(t *testing.T) { require.NoError(err, "SaveVersion should not fail") // Reload tree at version 1 - tree = NewMutableTree(mdb, 0, false, log.NewNopLogger()) + tree = NewMutableTree(mdb, 0, false, NewNopLogger()) _, err = tree.LoadVersion(int64(1)) require.NoError(err, "LoadVersion should not fail") @@ -1337,7 +1336,7 @@ func TestOverwriteEmpty(t *testing.T) { require := require.New(t) mdb := dbm.NewMemDB() - tree := NewMutableTree(mdb, 0, false, log.NewNopLogger()) + tree := NewMutableTree(mdb, 0, false, NewNopLogger()) // Save empty version 1 _, _, err := tree.SaveVersion() @@ -1371,7 +1370,7 @@ func TestLoadVersionForOverwriting(t *testing.T) { require := require.New(t) mdb := dbm.NewMemDB() - tree := NewMutableTree(mdb, 0, false, log.NewNopLogger()) + tree := NewMutableTree(mdb, 0, false, NewNopLogger()) maxLength := 100 for count := 1; count <= maxLength; count++ { @@ -1382,10 +1381,10 @@ func TestLoadVersionForOverwriting(t *testing.T) { require.NoError(err, "SaveVersion should not fail") } - tree = NewMutableTree(mdb, 0, false, log.NewNopLogger()) + tree = NewMutableTree(mdb, 0, false, NewNopLogger()) require.Error(tree.LoadVersionForOverwriting(int64(maxLength * 2))) - tree = NewMutableTree(mdb, 0, false, log.NewNopLogger()) + tree = NewMutableTree(mdb, 0, false, NewNopLogger()) err := tree.LoadVersionForOverwriting(int64(maxLength / 2)) require.NoError(err, "LoadVersion should not fail") @@ -1408,7 +1407,7 @@ func TestLoadVersionForOverwriting(t *testing.T) { require.NoError(err, "SaveVersion should not fail, overwrite was allowed") // Reload tree at version 50, the latest tree version is 52 - tree = NewMutableTree(mdb, 0, false, log.NewNopLogger()) + tree = NewMutableTree(mdb, 0, false, NewNopLogger()) _, err = tree.LoadVersion(int64(maxLength / 2)) require.NoError(err, "LoadVersion should not fail") @@ -1444,7 +1443,7 @@ func BenchmarkTreeLoadAndDelete(b *testing.B) { defer d.Close() defer os.RemoveAll("./bench.db") - tree := NewMutableTree(d, 0, false, log.NewNopLogger()) + tree := NewMutableTree(d, 0, false, NewNopLogger()) for v := 1; v < numVersions; v++ { for i := 0; i < numKeysPerVersion; i++ { tree.Set([]byte(iavlrand.RandStr(16)), iavlrand.RandBytes(32)) @@ -1455,7 +1454,7 @@ func BenchmarkTreeLoadAndDelete(b *testing.B) { b.Run("LoadAndDelete", func(b *testing.B) { for n := 0; n < b.N; n++ { b.StopTimer() - tree = NewMutableTree(d, 0, false, log.NewNopLogger()) + tree = NewMutableTree(d, 0, false, NewNopLogger()) require.NoError(b, err) runtime.GC() b.StartTimer() @@ -1479,7 +1478,7 @@ func BenchmarkTreeLoadAndDelete(b *testing.B) { func TestLoadVersionForOverwritingCase2(t *testing.T) { require := require.New(t) - tree := NewMutableTree(dbm.NewMemDB(), 0, false, log.NewNopLogger()) + tree := NewMutableTree(dbm.NewMemDB(), 0, false, NewNopLogger()) for i := byte(0); i < 20; i++ { tree.Set([]byte{i}, []byte{i}) @@ -1541,7 +1540,7 @@ func TestLoadVersionForOverwritingCase2(t *testing.T) { func TestLoadVersionForOverwritingCase3(t *testing.T) { require := require.New(t) - tree := NewMutableTree(dbm.NewMemDB(), 0, false, log.NewNopLogger()) + tree := NewMutableTree(dbm.NewMemDB(), 0, false, NewNopLogger()) for i := byte(0); i < 20; i++ { tree.Set([]byte{i}, []byte{i}) @@ -1670,7 +1669,7 @@ func Benchmark_GetWithIndex(b *testing.B) { const numKeyVals = 100000 - t := NewMutableTree(db, numKeyVals, false, log.NewNopLogger()) + t := NewMutableTree(db, numKeyVals, false, NewNopLogger()) keys := make([][]byte, 0, numKeyVals) @@ -1720,7 +1719,7 @@ func Benchmark_GetByIndex(b *testing.B) { const numKeyVals = 100000 - t := NewMutableTree(db, numKeyVals, false, log.NewNopLogger()) + t := NewMutableTree(db, numKeyVals, false, NewNopLogger()) for i := 0; i < numKeyVals; i++ { key := iavlrand.RandBytes(10) @@ -1793,7 +1792,7 @@ func TestNodeCacheStatisic(t *testing.T) { t.Run(name, func(_ *testing.T) { stat := &Statistics{} db := dbm.NewMemDB() - mt := NewMutableTree(db, tc.cacheSize, false, log.NewNopLogger(), StatOption(stat)) + mt := NewMutableTree(db, tc.cacheSize, false, NewNopLogger(), StatOption(stat)) for i := 0; i < numKeyVals; i++ { key := []byte(strconv.Itoa(i)) @@ -1823,7 +1822,7 @@ func TestEmptyVersionDelete(t *testing.T) { db := dbm.NewMemDB() defer db.Close() - tree := NewMutableTree(db, 0, false, log.NewNopLogger()) + tree := NewMutableTree(db, 0, false, NewNopLogger()) _, err := tree.Set([]byte("key1"), []byte("value1")) require.NoError(t, err) @@ -1837,7 +1836,7 @@ func TestEmptyVersionDelete(t *testing.T) { require.NoError(t, tree.DeleteVersionsTo(5)) // Load the tree from disk. - tree = NewMutableTree(db, 0, false, log.NewNopLogger()) + tree = NewMutableTree(db, 0, false, NewNopLogger()) v, err := tree.Load() require.NoError(t, err) require.Equal(t, int64(toVersion), v) @@ -1853,7 +1852,7 @@ func TestReferenceRoot(t *testing.T) { db := dbm.NewMemDB() defer db.Close() - tree := NewMutableTree(db, 0, false, log.NewNopLogger()) + tree := NewMutableTree(db, 0, false, NewNopLogger()) _, err := tree.Set([]byte("key1"), []byte("value1")) require.NoError(t, err) @@ -1872,7 +1871,7 @@ func TestReferenceRoot(t *testing.T) { require.NoError(t, err) // Load the tree from disk. - tree = NewMutableTree(db, 0, false, log.NewNopLogger()) + tree = NewMutableTree(db, 0, false, NewNopLogger()) _, err = tree.Load() require.NoError(t, err) require.Equal(t, int64(2), tree.Version()) @@ -1886,7 +1885,7 @@ func TestWorkingHashWithInitialVersion(t *testing.T) { defer db.Close() initialVersion := int64(100) - tree := NewMutableTree(db, 0, false, log.NewNopLogger()) + tree := NewMutableTree(db, 0, false, NewNopLogger()) tree.SetInitialVersion(uint64(initialVersion)) v := tree.WorkingVersion() @@ -1903,7 +1902,7 @@ func TestWorkingHashWithInitialVersion(t *testing.T) { db = dbm.NewMemDB() // without WorkingHash - tree = NewMutableTree(db, 0, false, log.NewNopLogger(), InitialVersionOption(uint64(initialVersion))) + tree = NewMutableTree(db, 0, false, NewNopLogger(), InitialVersionOption(uint64(initialVersion))) _, err = tree.Set([]byte("key1"), []byte("value1")) require.NoError(t, err)