From 6f151acce688d37ac13a34057d9260321713b6e1 Mon Sep 17 00:00:00 2001 From: Levi Schoen Date: Mon, 4 Mar 2024 16:22:59 -0800 Subject: [PATCH] merge backported cosmos-sdk upgrade to iavl v1 to kava's v47 fork --- client/pruning/main.go | 4 +- go.mod | 41 ++-- go.sum | 103 +++++++--- store/cache/cache_test.go | 27 ++- store/iavl/store.go | 44 ++-- store/iavl/store_test.go | 53 +++-- store/iavl/tree.go | 42 ++-- store/iavl/tree_test.go | 10 +- store/prefix/store_test.go | 7 +- store/pruning/export_test.go | 3 - store/pruning/manager.go | 214 ++++++-------------- store/pruning/manager_test.go | 364 +++++++--------------------------- store/rootmulti/store.go | 46 +---- store/rootmulti/store_test.go | 38 +--- store/wrapper/ics23.go | 14 ++ store/wrapper/tmdb.go | 100 ++++++++++ 16 files changed, 460 insertions(+), 650 deletions(-) create mode 100644 store/wrapper/ics23.go create mode 100644 store/wrapper/tmdb.go diff --git a/client/pruning/main.go b/client/pruning/main.go index 247cd2c360c9..1359a4c1086a 100644 --- a/client/pruning/main.go +++ b/client/pruning/main.go @@ -106,7 +106,7 @@ Supported app-db-backend types include 'goleveldb', 'rocksdb', 'pebbledb'.`, } cmd.Printf("pruning heights start from %v, end at %v\n", pruningHeights[0], pruningHeights[len(pruningHeights)-1]) - if err = rootMultiStore.PruneStores(false, pruningHeights); err != nil { + if err = rootMultiStore.PruneStores(pruningHeights[len(pruningHeights)-1]); err != nil { return err } @@ -119,7 +119,7 @@ Supported app-db-backend types include 'goleveldb', 'rocksdb', 'pebbledb'.`, cmd.Flags().String(FlagAppDBBackend, "", "The type of database for application and snapshots databases") cmd.Flags().Uint64(server.FlagPruningKeepRecent, 0, "Number of recent heights to keep on disk (ignored if pruning is not 'custom')") cmd.Flags().Uint64(server.FlagPruningInterval, 10, - `Height interval at which pruned heights are removed from disk (ignored if pruning is not 'custom'), + `Height interval at which pruned heights are removed from disk (ignored if pruning is not 'custom'), this is not used by this command but kept for compatibility with the complete pruning options`) return cmd diff --git a/go.mod b/go.mod index 477b27f6f6ce..cece041d8951 100644 --- a/go.mod +++ b/go.mod @@ -1,4 +1,6 @@ -go 1.19 +go 1.21 + +toolchain go1.21.6 module github.com/cosmos/cosmos-sdk @@ -18,15 +20,17 @@ require ( github.com/cockroachdb/apd/v2 v2.0.2 github.com/cockroachdb/errors v1.10.0 github.com/cometbft/cometbft v0.37.4 - github.com/cometbft/cometbft-db v0.7.0 + github.com/cometbft/cometbft-db v0.9.1 github.com/confio/ics23/go v0.9.0 github.com/cosmos/btcutil v1.0.5 + github.com/cosmos/cosmos-db v1.0.0 github.com/cosmos/cosmos-proto v1.0.0-beta.3 github.com/cosmos/cosmos-sdk/db v1.0.0-beta.1.0.20220726092710-f848e4300a8a github.com/cosmos/go-bip39 v1.0.0 github.com/cosmos/gogogateway v1.2.0 github.com/cosmos/gogoproto v1.4.10 - github.com/cosmos/iavl v0.20.1 + github.com/cosmos/iavl v1.0.0 + github.com/cosmos/ics23/go v0.10.0 github.com/cosmos/ledger-cosmos-go v0.13.1 github.com/golang/mock v1.6.0 github.com/golang/protobuf v1.5.3 @@ -49,18 +53,19 @@ require ( github.com/prometheus/common v0.42.0 github.com/rakyll/statik v0.1.7 github.com/rs/zerolog v1.30.0 - github.com/spf13/cast v1.5.0 + github.com/spf13/cast v1.5.1 github.com/spf13/cobra v1.6.1 github.com/spf13/pflag v1.0.5 github.com/spf13/viper v1.14.0 github.com/stretchr/testify v1.8.4 github.com/tendermint/go-amino v0.16.0 + github.com/tendermint/tm-db v0.6.7 github.com/tidwall/btree v1.6.0 - golang.org/x/crypto v0.14.0 + golang.org/x/crypto v0.15.0 golang.org/x/exp v0.0.0-20230711153332-06a737ee72cb golang.org/x/sync v0.3.0 google.golang.org/genproto/googleapis/api v0.0.0-20231002182017-d307bd883b97 - google.golang.org/grpc v1.58.3 + google.golang.org/grpc v1.59.0 google.golang.org/protobuf v1.31.0 gotest.tools/v3 v3.5.0 pgregory.net/rapid v0.5.5 @@ -76,6 +81,7 @@ require ( filippo.io/edwards25519 v1.0.0 // indirect github.com/99designs/go-keychain v0.0.0-20191008050251-8e49817e8af4 // indirect github.com/ChainSafe/go-schnorrkel v1.0.0 // indirect + github.com/DataDog/zstd v1.5.2 // indirect github.com/aws/aws-sdk-go v1.44.203 // indirect github.com/beorn7/perks v1.0.1 // indirect github.com/bgentry/go-netrc v0.0.0-20140422174119-9fd32a8b3d3d // indirect @@ -84,8 +90,10 @@ require ( github.com/cespare/xxhash v1.1.0 // indirect github.com/cespare/xxhash/v2 v2.2.0 // indirect github.com/cockroachdb/logtags v0.0.0-20230118201751-21c54148d20b // indirect + github.com/cockroachdb/pebble v0.0.0-20230226194802-02d779ffbc46 // indirect github.com/cockroachdb/redact v1.1.5 // indirect github.com/coinbase/rosetta-sdk-go/types v1.0.0 // indirect + github.com/cosmos/gorocksdb v1.2.0 // indirect github.com/cosmos/rosetta-sdk-go v0.10.0 // indirect github.com/creachadair/taskgroup v0.3.2 // indirect github.com/danieljoos/wincred v1.1.2 // indirect @@ -97,6 +105,7 @@ require ( github.com/dgryski/go-farm v0.0.0-20200201041132-a6ae2369ad13 // indirect github.com/dustin/go-humanize v1.0.1 // indirect github.com/dvsekhvalnov/jose2go v1.5.0 // indirect + github.com/emicklei/dot v1.4.2 // indirect github.com/felixge/httpsnoop v1.0.2 // indirect github.com/fsnotify/fsnotify v1.6.0 // indirect github.com/getsentry/sentry-go v0.23.0 // indirect @@ -113,7 +122,7 @@ require ( github.com/google/go-cmp v0.5.9 // indirect github.com/google/orderedcode v0.0.1 // indirect github.com/google/s2a-go v0.1.4 // indirect - github.com/google/uuid v1.3.0 // indirect + github.com/google/uuid v1.3.1 // indirect github.com/googleapis/enterprise-certificate-proxy v0.2.4 // indirect github.com/googleapis/gax-go/v2 v2.12.0 // indirect github.com/gorilla/websocket v1.5.0 // indirect @@ -133,6 +142,7 @@ require ( github.com/kr/text v0.2.0 // indirect github.com/lib/pq v1.10.7 // indirect github.com/libp2p/go-buffer-pool v0.1.0 // indirect + github.com/linxGnu/grocksdb v1.8.6 // indirect github.com/mattn/go-colorable v0.1.13 // indirect github.com/matttproud/golang_protobuf_extensions v1.0.4 // indirect github.com/mimoo/StrobeGo v0.0.0-20210601165009-122bf33a46e0 // indirect @@ -142,7 +152,6 @@ require ( github.com/mitchellh/mapstructure v1.5.0 // indirect github.com/mtibben/percent v0.2.1 // indirect github.com/nxadm/tail v1.4.8 // indirect - github.com/onsi/gomega v1.20.0 // indirect github.com/pelletier/go-toml v1.9.5 // indirect github.com/pelletier/go-toml/v2 v2.0.7 // indirect github.com/petermattis/goid v0.0.0-20230317030725-371a4b8eda08 // indirect @@ -157,17 +166,16 @@ require ( github.com/spf13/jwalterweatherman v1.1.0 // indirect github.com/subosito/gotenv v1.4.1 // indirect github.com/syndtr/goleveldb v1.0.1-0.20220721030215-126854af5e6d // indirect - github.com/tecbot/gorocksdb v0.0.0-20191217155057-f0fad39f321c // indirect github.com/ulikunitz/xz v0.5.11 // indirect github.com/zondax/hid v0.9.2 // indirect github.com/zondax/ledger-go v0.14.3 // indirect - go.etcd.io/bbolt v1.3.7 // indirect + go.etcd.io/bbolt v1.3.8 // indirect go.opencensus.io v0.24.0 // indirect - golang.org/x/net v0.17.0 // indirect - golang.org/x/oauth2 v0.10.0 // indirect - golang.org/x/sys v0.13.0 // indirect - golang.org/x/term v0.13.0 // indirect - golang.org/x/text v0.13.0 // indirect + golang.org/x/net v0.18.0 // indirect + golang.org/x/oauth2 v0.11.0 // indirect + golang.org/x/sys v0.14.0 // indirect + golang.org/x/term v0.14.0 // indirect + golang.org/x/text v0.14.0 // indirect golang.org/x/xerrors v0.0.0-20220907171357-04be3eba64a2 // indirect google.golang.org/api v0.128.0 // indirect google.golang.org/appengine v1.6.7 // indirect @@ -182,6 +190,9 @@ require ( replace ( // use cosmos fork of keyring github.com/99designs/keyring => github.com/cosmos/keyring v1.2.0 + // Use cometbft fork of tendermint + github.com/cometbft/cometbft => github.com/kava-labs/cometbft v0.37.4-kava.1 + github.com/cometbft/cometbft-db => github.com/kava-labs/cometbft-db v0.9.1-kava.1 // dgrijalva/jwt-go is deprecated and doesn't receive security updates. // TODO: remove it: https://github.com/cosmos/cosmos-sdk/issues/13134 github.com/dgrijalva/jwt-go => github.com/golang-jwt/jwt/v4 v4.4.2 diff --git a/go.sum b/go.sum index 4715459f2963..88192445000a 100644 --- a/go.sum +++ b/go.sum @@ -207,14 +207,19 @@ filippo.io/edwards25519 v1.0.0/go.mod h1:N1IkdkCkiLB6tki+MYJoSx2JTY9NUlxZE7eHn5E github.com/99designs/go-keychain v0.0.0-20191008050251-8e49817e8af4 h1:/vQbFIOMbk2FiG/kXiLl8BRyzTWDw7gX/Hz7Dd5eDMs= github.com/99designs/go-keychain v0.0.0-20191008050251-8e49817e8af4/go.mod h1:hN7oaIRCjzsZ2dE+yG5k+rsdt3qcwykqK6HVGcKwsw4= github.com/Azure/go-ansiterm v0.0.0-20210617225240-d185dfc1b5a1 h1:UQHMgLO+TxOElx5B5HZ4hJQsoJ/PvUvKRhJHDQXO8P8= +github.com/Azure/go-ansiterm v0.0.0-20210617225240-d185dfc1b5a1/go.mod h1:xomTg63KZ2rFqZQzSB4Vz2SUXa1BpHTVz9L5PTmPC4E= 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= github.com/ChainSafe/go-schnorrkel v1.0.0 h1:3aDA67lAykLaG1y3AOjs88dMxC88PgUuHRrLeDnvGIM= github.com/ChainSafe/go-schnorrkel v1.0.0/go.mod h1:dpzHYVxLZcp8pjlV+O+UR8K0Hp/z7vcchBSbMBEhCw4= github.com/DataDog/datadog-go v3.2.0+incompatible/go.mod h1:LButxg5PwREeZtORoXG3tL4fMGNddJ+vMq1mwgfaqoQ= +github.com/DataDog/zstd v1.5.2 h1:vUG4lAyuPCXO0TLbXvPv7EB7cNK1QV/luu55UHLrrn8= +github.com/DataDog/zstd v1.5.2/go.mod h1:g4AWEaM3yOg3HYfnJ3YIawPnVdXJh9QME85blwSAmyw= github.com/Knetic/govaluate v3.0.1-0.20171022003610-9aa49832a739+incompatible/go.mod h1:r7JcOSlj0wfOMncg0iLm8Leh48TZaKVeNIfJntJ2wa0= github.com/Microsoft/go-winio v0.6.0 h1:slsWYD/zyx7lCXoZVlvQrj0hPTM1HI4+v1sIda2yDvg= +github.com/Microsoft/go-winio v0.6.0/go.mod h1:cTAf44im0RAYeL23bpB+fzCyDH2MJiz2BO69KH/soAE= github.com/Nvveen/Gotty v0.0.0-20120604004816-cd527374f1e5 h1:TngWCqHvy9oXAN6lEVMRuU21PR1EtLVZJmdB18Gu3Rw= +github.com/Nvveen/Gotty v0.0.0-20120604004816-cd527374f1e5/go.mod h1:lmUJ/7eu/Q8D7ML55dXQrVaamCz2vxCfdQBasLZfHKk= github.com/OneOfOne/xxhash v1.2.2 h1:KMrpdQIwFcEqXDklaen+P1axHaj9BSKzvpUUfnHldSE= github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU= github.com/Shopify/sarama v1.19.0/go.mod h1:FVkBWblsNy7DGZRfXLU0O9RCGt5g3g3yEuWXgklEdEo= @@ -222,6 +227,7 @@ github.com/Shopify/toxiproxy v2.1.4+incompatible/go.mod h1:OXgGpZ6Cli1/URJOF1DMx github.com/VividCortex/gohistogram v1.0.0 h1:6+hBz+qvs0JOrrNhhmR7lFxo5sINxBCGXrdtl/UvroE= github.com/VividCortex/gohistogram v1.0.0/go.mod h1:Pf5mBqqDxYaXu3hDrrU+w6nw50o/4+TcAqDqk/vUH7g= github.com/adlio/schema v1.3.3 h1:oBJn8I02PyTB466pZO1UZEn1TV5XLlifBSyMrmHl/1I= +github.com/adlio/schema v1.3.3/go.mod h1:1EsRssiv9/Ce2CMzq5DoL7RiMshhuigQxrR4DMV9fHg= github.com/afex/hystrix-go v0.0.0-20180502004556-fa1af6a1f4f5/go.mod h1:SkGFH1ia65gfNATL8TAiHDNxPzPdmEL5uirI2Uyuz6c= github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc= github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc= @@ -256,7 +262,9 @@ github.com/bgentry/speakeasy v0.1.1-0.20220910012023-760eaf8b6816/go.mod h1:+zsy github.com/btcsuite/btcd/btcec/v2 v2.3.2 h1:5n0X6hX0Zk+6omWcihdYvdAlGf2DfasC0GMf7DClJ3U= github.com/btcsuite/btcd/btcec/v2 v2.3.2/go.mod h1:zYzJ8etWJQIv1Ogk7OzpWjowwOdXY1W/17j2MW85J04= github.com/btcsuite/btcd/btcutil v1.1.2 h1:XLMbX8JQEiwMcYft2EGi8zPUkoa0abKIU6/BJSRsjzQ= +github.com/btcsuite/btcd/btcutil v1.1.2/go.mod h1:UR7dsSJzJUfMmFiiLlIrMq1lS9jh9EdCV7FStZSnpi0= github.com/btcsuite/btcd/chaincfg/chainhash v1.0.1 h1:q0rUy8C/TYNBQS1+CGKw68tLOFYSNEs0TFnxxnS9+4U= +github.com/btcsuite/btcd/chaincfg/chainhash v1.0.1/go.mod h1:7SFka0XMvUgj3hfZtydOrQY2mwhPclbT2snogU7SQQc= github.com/bufbuild/protocompile v0.4.0 h1:LbFKd2XowZvQ/kajzguUp2DC9UEIQhIq77fZZlaQsNA= github.com/bufbuild/protocompile v0.4.0/go.mod h1:3v93+mbWn/v3xzN+31nwkJfrEpAUwp+BagBSZWx+TP8= github.com/bytedance/sonic v1.5.0/go.mod h1:ED5hyg4y6t3/9Ku1R6dU/4KyJ48DZ4jPhfY1O2AihPM= @@ -303,22 +311,23 @@ github.com/cncf/xds/go v0.0.0-20211011173535-cb28da3451f1/go.mod h1:eXthEFrGJvWH github.com/cockroachdb/apd/v2 v2.0.2 h1:weh8u7Cneje73dDh+2tEVLUvyBc89iwepWCD8b8034E= github.com/cockroachdb/apd/v2 v2.0.2/go.mod h1:DDxRlzC2lo3/vSlmSoS7JkqbbrARPuFOGr0B9pvN3Gw= github.com/cockroachdb/datadriven v0.0.0-20190809214429-80d97fb3cbaa/go.mod h1:zn76sxSg3SzpJ0PPJaLDCu+Bu0Lg3sKTORVIj19EIF8= +github.com/cockroachdb/datadriven v1.0.2 h1:H9MtNqVoVhvd9nCBwOyDjUEdZCREqbIdCJD93PBm/jA= +github.com/cockroachdb/datadriven v1.0.2/go.mod h1:a9RdTaap04u637JoCzcUoIcDmvwSUtcUFtT/C3kJlTU= github.com/cockroachdb/errors v1.10.0 h1:lfxS8zZz1+OjtV4MtNWgboi/W5tyLEB6VQZBXN+0VUU= github.com/cockroachdb/errors v1.10.0/go.mod h1:lknhIsEVQ9Ss/qKDBQS/UqFSvPQjOwNq2qyKAxtHRqE= github.com/cockroachdb/logtags v0.0.0-20230118201751-21c54148d20b h1:r6VH0faHjZeQy818SGhaone5OnYfxFR/+AzdY3sf5aE= github.com/cockroachdb/logtags v0.0.0-20230118201751-21c54148d20b/go.mod h1:Vz9DsVWQQhf3vs21MhPMZpMGSht7O/2vFW2xusFUVOs= +github.com/cockroachdb/pebble v0.0.0-20230226194802-02d779ffbc46 h1:yMaoO76pV9knZ6bzEwzPSHnPSCTnrJohwkIQirmii70= +github.com/cockroachdb/pebble v0.0.0-20230226194802-02d779ffbc46/go.mod h1:9lRMC4XN3/BLPtIp6kAKwIaHu369NOf2rMucPzipz50= github.com/cockroachdb/redact v1.1.5 h1:u1PMllDkdFfPWaNGMyLD1+so+aq3uUItthCFqzwPJ30= github.com/cockroachdb/redact v1.1.5/go.mod h1:BVNblN9mBWFyMyqK1k3AAiSxhvhfK2oOZZ2lK+dpvRg= github.com/codahale/hdrhistogram v0.0.0-20161010025455-3a0bb77429bd/go.mod h1:sE/e/2PUdi/liOCUjSTXgM1o87ZssimdTWN964YiIeI= github.com/coinbase/rosetta-sdk-go/types v1.0.0 h1:jpVIwLcPoOeCR6o1tU+Xv7r5bMONNbHU7MuEHboiFuA= github.com/coinbase/rosetta-sdk-go/types v1.0.0/go.mod h1:eq7W2TMRH22GTW0N0beDnN931DW0/WOI1R2sdHNHG4c= -github.com/cometbft/cometbft v0.37.4 h1:xyvvEqlyfK8MgNIIKVJaMsuIp03wxOcFmVkT26+Ikpg= -github.com/cometbft/cometbft v0.37.4/go.mod h1:Cmg5Hp4sNpapm7j+x0xRyt2g0juQfmB752ous+pA0G8= -github.com/cometbft/cometbft-db v0.7.0 h1:uBjbrBx4QzU0zOEnU8KxoDl18dMNgDh+zZRUE0ucsbo= -github.com/cometbft/cometbft-db v0.7.0/go.mod h1:yiKJIm2WKrt6x8Cyxtq9YTEcIMPcEe4XPxhgX59Fzf0= github.com/confio/ics23/go v0.9.0 h1:cWs+wdbS2KRPZezoaaj+qBleXgUk5WOQFMP3CQFGTr4= github.com/confio/ics23/go v0.9.0/go.mod h1:4LPZ2NYqnYIVRklaozjNR1FScgDJ2s5Xrp+e/mYVRak= github.com/containerd/continuity v0.3.0 h1:nisirsYROK15TAMVukJOUyGJjz4BNQJBVsNvAXZJ/eg= +github.com/containerd/continuity v0.3.0/go.mod h1:wJEAIwKOm/pBZuBd0JmeTvnLquTB1Ag8espWhkykbPM= github.com/coreos/etcd v3.3.10+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc32PjwdhPthX9715RE= github.com/coreos/go-etcd v2.0.0+incompatible/go.mod h1:Jez6KQU2B/sWsbdaef3ED8NzMklzPG4d5KIOhIy30Tk= github.com/coreos/go-semver v0.2.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk= @@ -327,6 +336,8 @@ github.com/coreos/go-systemd/v22 v22.5.0/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSV github.com/coreos/pkg v0.0.0-20160727233714-3ac0863d7acf/go.mod h1:E3G3o1h8I7cfcXa63jLwjI0eiQQMgzzUDFVpN/nH/eA= github.com/cosmos/btcutil v1.0.5 h1:t+ZFcX77LpKtDBhjucvnOH8C2l2ioGsBNEQ3jef8xFk= github.com/cosmos/btcutil v1.0.5/go.mod h1:IyB7iuqZMJlthe2tkIFL33xPyzbFYP0XVdS8P5lUPis= +github.com/cosmos/cosmos-db v1.0.0 h1:EVcQZ+qYag7W6uorBKFPvX6gRjw6Uq2hIh4hCWjuQ0E= +github.com/cosmos/cosmos-db v1.0.0/go.mod h1:iBvi1TtqaedwLdcrZVYRSSCb6eSy61NLj4UNmdIgs0U= github.com/cosmos/cosmos-proto v1.0.0-beta.3 h1:VitvZ1lPORTVxkmF2fAp3IiA61xVwArQYKXTdEcpW6o= github.com/cosmos/cosmos-proto v1.0.0-beta.3/go.mod h1:t8IASdLaAq+bbHbjq4p960BvcTqtwuAxid3b/2rOD6I= github.com/cosmos/cosmos-sdk/db v1.0.0-beta.1.0.20220726092710-f848e4300a8a h1:2humuGPw3O5riJVFq/E2FRjF57UrO97W1qJcGVmK+6k= @@ -339,8 +350,12 @@ github.com/cosmos/gogogateway v1.2.0/go.mod h1:iQpLkGWxYcnCdz5iAdLcRBSw3h7NXeOkZ github.com/cosmos/gogoproto v1.4.2/go.mod h1:cLxOsn1ljAHSV527CHOtaIP91kK6cCrZETRBrkzItWU= github.com/cosmos/gogoproto v1.4.10 h1:QH/yT8X+c0F4ZDacDv3z+xE3WU1P1Z3wQoLMBRJoKuI= github.com/cosmos/gogoproto v1.4.10/go.mod h1:3aAZzeRWpAwr+SS/LLkICX2/kDFyaYVzckBDzygIxek= -github.com/cosmos/iavl v0.20.1 h1:rM1kqeG3/HBT85vsZdoSNsehciqUQPWrR4BYmqE2+zg= -github.com/cosmos/iavl v0.20.1/go.mod h1:WO7FyvaZJoH65+HFOsDir7xU9FWk2w9cHXNW1XHcl7A= +github.com/cosmos/gorocksdb v1.2.0 h1:d0l3jJG8M4hBouIZq0mDUHZ+zjOx044J3nGRskwTb4Y= +github.com/cosmos/gorocksdb v1.2.0/go.mod h1:aaKvKItm514hKfNJpUJXnnOWeBnk2GL4+Qw9NHizILw= +github.com/cosmos/iavl v1.0.0 h1:bw6t0Mv/mVCJvlMTOPHWLs5uUE3BRBfVWCRelOzl+so= +github.com/cosmos/iavl v1.0.0/go.mod h1:CmTGqMnRnucjxbjduneZXT+0vPgNElYvdefjX2q9tYc= +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/cosmos/keyring v1.2.0 h1:8C1lBP9xhImmIabyXW4c3vFjjLiBdGCmfLUfeZlV1Yo= github.com/cosmos/keyring v1.2.0/go.mod h1:fc+wB5KTk9wQ9sDx0kFXB3A0MaeGHM9AwRStKOQ5vOA= github.com/cosmos/ledger-cosmos-go v0.13.1 h1:12ac9+GwBb9BjP7X5ygpFk09Itwzjzfmg6A2CWFjoVs= @@ -360,6 +375,7 @@ github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSs 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/decred/dcrd/crypto/blake256 v1.0.0 h1:/8DMNYp9SGi5f0w7uCm6d6M4OU2rGFK09Y2A4Xv7EE0= +github.com/decred/dcrd/crypto/blake256 v1.0.0/go.mod h1:sQl2p6Y26YV+ZOcSTP6thNdn47hh8kt6rqSlvmrXFAc= github.com/decred/dcrd/dcrec/secp256k1/v4 v4.1.0 h1:HbphB4TFFXpv7MNrT52FGrrgVXF1owhMVTHFZIlnvd4= github.com/decred/dcrd/dcrec/secp256k1/v4 v4.1.0/go.mod h1:DZGJHZMqrU4JJqFAWUS2UO1+lbSKsdiOoYi9Zzey7Fc= github.com/desertbit/timer v0.0.0-20180107155436-c41aec40b27f h1:U5y3Y5UE0w7amNe7Z5G/twsBW0KEalRQXZzf8ufSh9I= @@ -373,7 +389,9 @@ github.com/dgryski/go-farm v0.0.0-20190423205320-6a90982ecee2/go.mod h1:SqUrOPUn github.com/dgryski/go-farm v0.0.0-20200201041132-a6ae2369ad13 h1:fAjc9m62+UWV/WAFKLNi6ZS0675eEUC9y3AlwSbQu1Y= github.com/dgryski/go-farm v0.0.0-20200201041132-a6ae2369ad13/go.mod h1:SqUrOPUnsFjfmXRMNPybcSiG0BgUW2AuFH8PAnS2iTw= github.com/docker/go-connections v0.4.0 h1:El9xVISelRB7BuFusrZozjnkIM5YnzCViNKohAFqRJQ= +github.com/docker/go-connections v0.4.0/go.mod h1:Gbd7IOopHjR8Iph03tsViu4nIes5XhDvyHbTtUxmeec= github.com/docker/go-units v0.5.0 h1:69rxXcBk27SvSaaxTtLh/8llcHD8vYHT7WSdRZ/jvr4= +github.com/docker/go-units v0.5.0/go.mod h1:fgPhTUdO+D/Jk86RDLlptpiXQzgHJF7gydDDbaIK4Dk= github.com/dustin/go-humanize v0.0.0-20171111073723-bb3d318650d4/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk= github.com/dustin/go-humanize v1.0.0/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk= github.com/dustin/go-humanize v1.0.1 h1:GzkhY7T5VNhEkwH0PVJgjz+fX1rhBrR7pRT3mDkpeCY= @@ -384,6 +402,8 @@ github.com/eapache/go-resiliency v1.1.0/go.mod h1:kFI+JgMyC7bLPUVY133qvEBtVayf5m github.com/eapache/go-xerial-snappy v0.0.0-20180814174437-776d5712da21/go.mod h1:+020luEh2TKB4/GOp8oxxtq0Daoen/Cii55CzbTV6DU= github.com/eapache/queue v1.1.0/go.mod h1:6eCeP0CKFpHLu8blIFXhExK/dRa7WDZfr6jVFPTqq+I= github.com/edsrzf/mmap-go v1.0.0/go.mod h1:YO35OhQPt3KJa3ryjFM5Bs14WD66h8eGKpfaBNrHW5M= +github.com/emicklei/dot v1.4.2 h1:UbK6gX4yvrpHKlxuUQicwoAis4zl8Dzwit9SnbBAXWw= +github.com/emicklei/dot v1.4.2/go.mod h1:DeV7GvQtIw4h2u73RKBkkFdvVAz0D9fzeJrgPW6gy/s= github.com/envoyproxy/go-control-plane v0.6.9/go.mod h1:SBwIajubJHhxtWwsL9s8ss4safvEdbitLhGGK48rN6g= github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= @@ -396,16 +416,21 @@ github.com/envoyproxy/go-control-plane v0.9.10-0.20210907150352-cf90f659a021/go. github.com/envoyproxy/go-control-plane v0.10.2-0.20220325020618-49ff273808a1/go.mod h1:KJwIaB5Mv44NWtYuAOFCVOjcI94vtpEz2JU/D2v6IjE= github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c= github.com/facebookgo/ensure v0.0.0-20200202191622-63f1cf65ac4c h1:8ISkoahWXwZR41ois5lSJBSVw4D0OV19Ht/JSTzvSv0= +github.com/facebookgo/ensure v0.0.0-20200202191622-63f1cf65ac4c/go.mod h1:Yg+htXGokKKdzcwhuNDwVvN+uBxDGXJ7G/VN1d8fa64= github.com/facebookgo/stack v0.0.0-20160209184415-751773369052 h1:JWuenKqqX8nojtoVVWjGfOF9635RETekkoH6Cc9SX0A= +github.com/facebookgo/stack v0.0.0-20160209184415-751773369052/go.mod h1:UbMTZqLaRiH3MsBH8va0n7s1pQYcu3uTb8G4tygF4Zg= github.com/facebookgo/subset v0.0.0-20200203212716-c811ad88dec4 h1:7HZCaLC5+BZpmbhCOZJ293Lz68O7PYrF2EzeiFMwCLk= +github.com/facebookgo/subset v0.0.0-20200203212716-c811ad88dec4/go.mod h1:5tD+neXqOorC30/tWg0LCSkrqj/AR6gu8yY8/fpw1q0= github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4= github.com/felixge/httpsnoop v1.0.1/go.mod h1:m8KPJKqk1gH5J9DgRY2ASl2lWCfGKXixSwevea8zH2U= github.com/felixge/httpsnoop v1.0.2 h1:+nS9g82KMXccJ/wp0zyRW9ZBHFETmMGtkk+2CTTrW4o= github.com/felixge/httpsnoop v1.0.2/go.mod h1:m8KPJKqk1gH5J9DgRY2ASl2lWCfGKXixSwevea8zH2U= github.com/fortytw2/leaktest v1.3.0 h1:u8491cBMTQ8ft8aeV+adlcytMZylmA5nnwwkRZjI8vw= +github.com/fortytw2/leaktest v1.3.0/go.mod h1:jDsjWgpAGjm2CA7WthBh/CdZYEPF31XHquHwclZch5g= github.com/franela/goblin v0.0.0-20200105215937-c9ffbefa60db/go.mod h1:7dvUGVsVBjqR7JHJk0brhHOZYGmfBYOrK0ZhYMEtBr4= github.com/franela/goreq v0.0.0-20171204163338-bcd34c9993f8/go.mod h1:ZhphrRTfi2rbfLwlschooIH4+wKKDR4Pdxhh+TRoA20= -github.com/frankban/quicktest v1.14.3 h1:FJKSZTDHjyhriyC81FLQ0LY93eSai0ZyR/ZIkd3ZUKE= +github.com/frankban/quicktest v1.14.4 h1:g2rn0vABPOOXmZUj+vbmUp0lPoXEMuhTpIluN0XL9UY= +github.com/frankban/quicktest v1.14.4/go.mod h1:4ptaffx2x8+WTWXmUCuVU6aPUX1/Mz7zb5vbUoiM6w0= github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ= github.com/fsnotify/fsnotify v1.6.0 h1:n+5WquG0fcWoWp6xPWfHdbskMCQaFnG6PfBrh1Ky4HY= @@ -418,6 +443,7 @@ github.com/gin-contrib/sse v0.1.0/go.mod h1:RHrZQHXnP2xjPF+u1gW/2HnVO7nvIa9PG3Gm github.com/gin-gonic/gin v1.9.0 h1:OjyFBKICoexlu99ctXNR2gg+c5pKrKMuyjgARg9qeY8= github.com/gin-gonic/gin v1.9.0/go.mod h1:W1Me9+hsUSyj3CePGrd1/QrKJMSJ1Tu/0hFEH89961k= github.com/go-errors/errors v1.4.2 h1:J6MZopCL4uSllY1OfXM374weqZFFItUbrImctkmUxIA= +github.com/go-errors/errors v1.4.2/go.mod h1:sIVyrIiJhuEF+Pj9Ebtd6P/rEYROXFi3BopGUQ5a5Og= github.com/go-gl/glfw v0.0.0-20190409004039-e6da0acd62b1/go.mod h1:vR7hzQXu2zJy9AVAgeJqvqgH9Q5CA+iKCZ2gyEVpxRU= github.com/go-gl/glfw/v3.3/glfw v0.0.0-20191125211704-12ad95a8df72/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8= github.com/go-gl/glfw/v3.3/glfw v0.0.0-20200222043503-6f7a984d4dc4/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8= @@ -537,6 +563,7 @@ github.com/google/martian/v3 v3.0.0/go.mod h1:y5Zk1BBys9G+gd6Jrk0W3cC1+ELVxBWuIG github.com/google/martian/v3 v3.1.0/go.mod h1:y5Zk1BBys9G+gd6Jrk0W3cC1+ELVxBWuIGO+w/tUAp0= github.com/google/martian/v3 v3.2.1/go.mod h1:oBOf6HBosgwRXnUGWUB05QECsc6uvmMiJ3+6W4l/CUk= github.com/google/martian/v3 v3.3.2 h1:IqNFLAmvJOgVlpdEBiQbDc2EwKW77amAycfTuWKdfvw= +github.com/google/martian/v3 v3.3.2/go.mod h1:oBOf6HBosgwRXnUGWUB05QECsc6uvmMiJ3+6W4l/CUk= github.com/google/orderedcode v0.0.1 h1:UzfcAexk9Vhv8+9pNOgRu41f16lHq725vPwnSeiG/Us= github.com/google/orderedcode v0.0.1/go.mod h1:iVyU4/qPKHY5h/wSd6rZZCDcLJNxiWO6dvsYES2Sb20= github.com/google/pprof v0.0.0-20181206194817-3ea8567a2e57/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc= @@ -559,8 +586,9 @@ github.com/google/s2a-go v0.1.4 h1:1kZ/sQM3srePvKs3tXAvQzo66XfcReoqFpIpIccE7Oc= github.com/google/s2a-go v0.1.4/go.mod h1:Ej+mSEMGRnqRzjc7VtF+jdBwYG5fuJfiZ8ELkjEwM0A= github.com/google/uuid v1.0.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= -github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I= github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/google/uuid v1.3.1 h1:KjJaJ9iWZ3jOFZIf1Lqf4laDRCasjl0BCmnEGxkdLb4= +github.com/google/uuid v1.3.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/googleapis/enterprise-certificate-proxy v0.0.0-20220520183353-fd19c99a87aa/go.mod h1:17drOmN3MwGY7t0e+Ei9b45FFGA3fBs3x36SsCg1hq8= github.com/googleapis/enterprise-certificate-proxy v0.1.0/go.mod h1:17drOmN3MwGY7t0e+Ei9b45FFGA3fBs3x36SsCg1hq8= github.com/googleapis/enterprise-certificate-proxy v0.2.0/go.mod h1:8C0jb7/mgJe/9KK8Lm7X9ctZC2t60YyIpYEI16jx0Qg= @@ -682,6 +710,10 @@ github.com/jstemmer/go-junit-report v0.9.1/go.mod h1:Brl9GWCQeLvo8nXZwPNNblvFj/X github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU= github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w= github.com/julienschmidt/httprouter v1.3.0/go.mod h1:JR6WtHb+2LUe8TCKY3cZOxFyyO8IZAc4RVcycCCAKdM= +github.com/kava-labs/cometbft v0.37.4-kava.1 h1:QRuyBieWdUBpe4pcXgzu1SdMH2lkTaqXr/JPIeqdiHE= +github.com/kava-labs/cometbft v0.37.4-kava.1/go.mod h1:Cmg5Hp4sNpapm7j+x0xRyt2g0juQfmB752ous+pA0G8= +github.com/kava-labs/cometbft-db v0.9.1-kava.1 h1:0KmSPdXYdRp6TsgKuMxRnMZCMEGC5ysIVjuJddYr4tw= +github.com/kava-labs/cometbft-db v0.9.1-kava.1/go.mod h1:iliyWaoV0mRwBJoizElCwwRA9Tf7jZJOURcRZF9m60U= github.com/kisielk/errcheck v1.1.0/go.mod h1:EZBBE59ingxPouuu3KfxchcWSUPOHkagtvWXihfKN4Q= github.com/kisielk/errcheck v1.2.0/go.mod h1:/BMXB+zMLi60iA8Vv6Ksmxu/1UDYcXs4uQLJ+jE2L00= github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8= @@ -715,6 +747,8 @@ github.com/libp2p/go-buffer-pool v0.1.0 h1:oK4mSFcQz7cTQIfqbe4MIj9gLW+mnanjyFtc6 github.com/libp2p/go-buffer-pool v0.1.0/go.mod h1:N+vh8gMqimBzdKkSMVuydVDq+UV5QTWy5HSiZacSbPg= github.com/lightstep/lightstep-tracer-common/golang/gogo v0.0.0-20190605223551-bc2310a04743/go.mod h1:qklhhLq1aX+mtWk9cPHPzaBjWImj5ULL6C7HFJtXQMM= github.com/lightstep/lightstep-tracer-go v0.18.1/go.mod h1:jlF1pusYV4pidLvZ+XD0UBX0ZE6WURAspgAczcDHrL4= +github.com/linxGnu/grocksdb v1.8.6 h1:O7I6SIGPrypf3f/gmrrLUBQDKfO8uOoYdWf4gLS06tc= +github.com/linxGnu/grocksdb v1.8.6/go.mod h1:xZCIb5Muw+nhbDK4Y5UJuOrin5MceOuiXkVUR7vp4WY= github.com/lyft/protoc-gen-validate v0.0.13/go.mod h1:XbGvPuh87YZc5TdIa2/I4pLk0QoUACkjt2znoq26NVQ= github.com/magiconair/properties v1.8.0/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ= github.com/magiconair/properties v1.8.6 h1:5ibWZ6iY0NctNGWo87LalDlEZ6R41TqbbDamhfG/Qzo= @@ -788,15 +822,19 @@ github.com/onsi/ginkgo v1.7.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+W github.com/onsi/ginkgo v1.12.1/go.mod h1:zj2OWP4+oCPe1qIXoGWkgMRwljMUYCdkwsT2108oapk= github.com/onsi/ginkgo v1.14.0/go.mod h1:iSB4RoI2tjJc9BBv4NKIKWKya62Rps+oPG/Lv9klQyY= github.com/onsi/ginkgo v1.16.4 h1:29JGrr5oVBm5ulCWet69zQkzWipVXIol6ygQUe/EzNc= +github.com/onsi/ginkgo v1.16.4/go.mod h1:dX+/inL/fNMqNlz0e9LfyB9TswhZpCVdJM/Z6Vvnwo0= github.com/onsi/gomega v1.4.3/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY= github.com/onsi/gomega v1.7.1/go.mod h1:XdKZgCCFLUoM/7CFJVPcG8C1xQ1AJ0vpAezJrB7JYyY= github.com/onsi/gomega v1.10.1/go.mod h1:iN09h71vgCQne3DLsj+A5owkum+a2tYe+TOCB1ybHNo= -github.com/onsi/gomega v1.20.0 h1:8W0cWlwFkflGPLltQvLRB7ZVD5HuP6ng320w2IS245Q= -github.com/onsi/gomega v1.20.0/go.mod h1:DtrZpjmvpn2mPm4YWQa0/ALMDj9v4YxLgojwPeREyVo= +github.com/onsi/gomega v1.26.0 h1:03cDLK28U6hWvCAns6NeydX3zIm4SF3ci69ulidS32Q= +github.com/onsi/gomega v1.26.0/go.mod h1:r+zV744Re+DiYCIPRlYOTxn0YkOLcAnW8k1xXdMPGhM= github.com/op/go-logging v0.0.0-20160315200505-970db520ece7/go.mod h1:HzydrMdWErDVzsI23lYNej1Htcns9BCg93Dk0bBINWk= github.com/opencontainers/go-digest v1.0.0 h1:apOUWs51W5PlhuyGyz9FCeeBIOUDA/6nW8Oi/yOhh5U= +github.com/opencontainers/go-digest v1.0.0/go.mod h1:0JzlMkj0TRzQZfJkVvzbP0HBR3IKzErnv2BNG4W4MAM= github.com/opencontainers/image-spec v1.1.0-rc2 h1:2zx/Stx4Wc5pIPDvIxHXvXtQFW/7XWJGmnM7r3wg034= +github.com/opencontainers/image-spec v1.1.0-rc2/go.mod h1:3OVijpioIKYWTqjiG0zfF6wvoJ4fAXGbjdZuI2NgsRQ= github.com/opencontainers/runc v1.1.3 h1:vIXrkId+0/J2Ymu2m7VjGvbSlAId9XNRPhn2p4b+d8w= +github.com/opencontainers/runc v1.1.3/go.mod h1:1J5XiS+vdZ3wCyZybsuxXZWGrgSr8fFJHLXuG2PsnNg= github.com/opentracing-contrib/go-observer v0.0.0-20170622124052-a52f23424492/go.mod h1:Ngi6UdF0k5OKD5t5wlmGhe/EDKPoUM3BXZSSfIuJbis= github.com/opentracing/basictracer-go v1.0.0/go.mod h1:QfBfYuafItcjQuMwinw9GhYKwFXS9KnPs5lxoYwgW74= github.com/opentracing/opentracing-go v1.0.2/go.mod h1:UkNAQd3GIcIGf0SeVgPpRdFStlNbqXla1AfSYxPUl2o= @@ -806,6 +844,7 @@ github.com/openzipkin/zipkin-go v0.1.6/go.mod h1:QgAqvLzwWbR/WpD4A3cGpPtJrZXNIiJ github.com/openzipkin/zipkin-go v0.2.1/go.mod h1:NaW6tEwdmWMaCDZzg8sh+IBNOxHMPnhQw8ySjnjRyN4= github.com/openzipkin/zipkin-go v0.2.2/go.mod h1:NaW6tEwdmWMaCDZzg8sh+IBNOxHMPnhQw8ySjnjRyN4= github.com/ory/dockertest v3.3.5+incompatible h1:iLLK6SQwIhcbrG783Dghaaa3WPzGc+4Emza6EbVUUGA= +github.com/ory/dockertest v3.3.5+incompatible/go.mod h1:1vX4m9wsvi00u5bseYwXaSnhNrne+V0E6LAcBILJdPs= github.com/pact-foundation/pact-go v1.0.4/go.mod h1:uExwJY4kCzNPcHRj+hCR/HBbOOIwwtUjcrb0b5/5kLM= github.com/pascaldekloe/goe v0.0.0-20180627143212-57f6aae5913c/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144TG7ZOy1lc= github.com/pascaldekloe/goe v0.1.0 h1:cBOtyMzM9HTpWjXfbbunk26uA6nG3a8n06Wieeh0MwY= @@ -824,6 +863,7 @@ github.com/petermattis/goid v0.0.0-20230317030725-371a4b8eda08/go.mod h1:pxMtw7c github.com/pierrec/lz4 v1.0.2-0.20190131084431-473cd7ce01a1/go.mod h1:3/3N9NVKO0jef7pBehbT1qWhCMrIgbYNnFAZCqQ5LRc= github.com/pierrec/lz4 v2.0.5+incompatible/go.mod h1:pdkljMzZIN41W+lC3N2tnIh5sFi+IEE17M5jbnwPHcY= github.com/pingcap/errors v0.11.4 h1:lFuQV/oaUMGcD2tqt+01ROSmJs75VG1ToEOkZIZ4nE4= +github.com/pingcap/errors v0.11.4/go.mod h1:Oi8TUi2kEtXXLMJk9l1cGmz20kV3TaQ0usTwv5KuLY8= github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e/go.mod h1:pJLUxLENpZxwdsKMEsNbx1VGcRFpLqf3715MtcvvzbA= github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= @@ -899,6 +939,7 @@ github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6Mwd github.com/sirupsen/logrus v1.6.0/go.mod h1:7uNnSEd1DgxDLC74fIahvMZmmYsHGZGEOFrfsX/uA88= github.com/sirupsen/logrus v1.7.0/go.mod h1:yWOB1SBYBC5VeMP7gHvWumXLIWorT60ONWic61uBYv0= github.com/sirupsen/logrus v1.9.0 h1:trlNQbNUG3OdDrDil03MCb1H2o9nJ1x4/5LYw7byDE0= +github.com/sirupsen/logrus v1.9.0/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ= github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc= github.com/smartystreets/goconvey v1.6.4/go.mod h1:syvi0/a8iFYH4r/RixwvyeAJjdLS9QV7WQ/tjFTllLA= github.com/soheilhy/cmux v0.1.4/go.mod h1:IM3LyeVVIOuxMH7sFAkER9+bJ4dT7Ms6E4xg4kGIyLM= @@ -910,8 +951,8 @@ github.com/spf13/afero v1.1.2/go.mod h1:j4pytiNVoe2o6bmDsKpLACNPDBIoEAkihy7loJ1B github.com/spf13/afero v1.9.2 h1:j49Hj62F0n+DaZ1dDCvhABaPNSGNkt32oRFxI33IEMw= github.com/spf13/afero v1.9.2/go.mod h1:iUV7ddyEEZPO5gA3zD4fJt6iStLlL+Lg4m2cihcDf8Y= github.com/spf13/cast v1.3.0/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE= -github.com/spf13/cast v1.5.0 h1:rj3WzYc11XZaIZMPKmwP96zkFEnnAmV8s6XbB2aY32w= -github.com/spf13/cast v1.5.0/go.mod h1:SpXXQ5YoyJw6s3/6cMTQuxvgRl3PCJiyaX9p6b155UU= +github.com/spf13/cast v1.5.1 h1:R+kOtfhWQE6TVQzY+4D7wJLBgkdVasCEFxSUBYBYIlA= +github.com/spf13/cast v1.5.1/go.mod h1:b9PdjNptOpzXr7Rq1q9gJML/2cdGQAo69NKzQ10KN48= github.com/spf13/cobra v0.0.3/go.mod h1:1l0Ry5zgKvJasoi3XT1TypsSe7PqH0Sj9dhYf7v3XqQ= github.com/spf13/cobra v0.0.5/go.mod h1:3K3wKZymM7VvHMDS9+Akkh4K60UwM26emMESw8tLCHU= github.com/spf13/cobra v1.6.1 h1:o94oiPyS4KD1mPy2fmcYYHHfCxLqYjJOhGsCHFZtEzA= @@ -949,10 +990,10 @@ github.com/subosito/gotenv v1.4.1 h1:jyEFiXpy21Wm81FBN71l9VoMMV8H8jG+qIK3GCpY6Qs github.com/subosito/gotenv v1.4.1/go.mod h1:ayKnFf/c6rvx/2iiLrJUk1e6plDbT3edrFNGqEflhK0= github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7 h1:epCh84lMvA70Z7CTTCmYQn2CKbY8j86K7/FAIr141uY= github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7/go.mod h1:q4W45IWZaF22tdD+VEXcAWRA037jwmWEB5VWYORlTpc= -github.com/tecbot/gorocksdb v0.0.0-20191217155057-f0fad39f321c h1:g+WoO5jjkqGAzHWCjJB1zZfXPIAaDpzXIEJ0eS6B5Ok= -github.com/tecbot/gorocksdb v0.0.0-20191217155057-f0fad39f321c/go.mod h1:ahpPrc7HpcfEWDQRZEmnXMzHY03mLDYMCxeDzy46i+8= github.com/tendermint/go-amino v0.16.0 h1:GyhmgQKvqF82e2oZeuMSp9JTN0N09emoSZlb2lyGa2E= github.com/tendermint/go-amino v0.16.0/go.mod h1:TQU0M1i/ImAo+tYpZi73AU3V/dKeCoMC9Sphe2ZwGME= +github.com/tendermint/tm-db v0.6.7 h1:fE00Cbl0jayAoqlExN6oyQJ7fR/ZtoVOmvPJ//+shu8= +github.com/tendermint/tm-db v0.6.7/go.mod h1:byQDzFkZV1syXr/ReXS808NxA2xvyuuVgXOJ/088L6I= github.com/tidwall/btree v1.6.0 h1:LDZfKfQIBHGHWSwckhXI0RPSXzlo+KYdjK7FWSqOzzg= github.com/tidwall/btree v1.6.0/go.mod h1:twD9XRA5jj9VUQGELzDO4HPQTNJsoWWfYEL+EUQ2cKY= github.com/tmc/grpc-websocket-proxy v0.0.0-20170815181823-89b8d40f7ca8/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U= @@ -980,8 +1021,8 @@ github.com/zondax/hid v0.9.2/go.mod h1:l5wttcP0jwtdLjqjMMWFVEE7d1zO0jvSPA9OPZxWp github.com/zondax/ledger-go v0.14.3 h1:wEpJt2CEcBJ428md/5MgSLsXLBos98sBOyxNmCjfUCw= github.com/zondax/ledger-go v0.14.3/go.mod h1:IKKaoxupuB43g4NxeQmbLXv7T9AlQyie1UpHb342ycI= go.etcd.io/bbolt v1.3.3/go.mod h1:IbVyRI1SCnLcuJnV2u8VeU0CEYM7e686BmAb1XKL+uU= -go.etcd.io/bbolt v1.3.7 h1:j+zJOnnEjF/kyHlDDgGnVL/AIqIJPq8UoB2GSNfkUfQ= -go.etcd.io/bbolt v1.3.7/go.mod h1:N9Mkw9X8x5fupy0IKsmuqVtoGDyxsaDlbk4Rd05IAQw= +go.etcd.io/bbolt v1.3.8 h1:xs88BrvEv273UsB79e0hcVrlUWmS0a8upikMFhSyAtA= +go.etcd.io/bbolt v1.3.8/go.mod h1:N9Mkw9X8x5fupy0IKsmuqVtoGDyxsaDlbk4Rd05IAQw= go.etcd.io/etcd v0.0.0-20191023171146-3cf2f69b5738/go.mod h1:dnLIgRNXwCJa5e+c6mIZCrds/GIG4ncV9HhK5PX7jPg= go.opencensus.io v0.20.1/go.mod h1:6WKK9ahsWS3RSO+PY9ZHZUfv2irvY6gN279GOPZjmmk= go.opencensus.io v0.20.2/go.mod h1:6WKK9ahsWS3RSO+PY9ZHZUfv2irvY6gN279GOPZjmmk= @@ -1021,8 +1062,8 @@ golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5y golang.org/x/crypto v0.0.0-20211108221036-ceb1ce70b4fa/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= golang.org/x/crypto v0.0.0-20220314234659-1baeb1ce4c0b/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= golang.org/x/crypto v0.5.0/go.mod h1:NK/OQwhpMQP3MwtdjgLlYHnH9ebylxKWv3e0fK+mkQU= -golang.org/x/crypto v0.14.0 h1:wBqGXzWJW6m1XrIKlAH0Hs1JJ7+9KBwnIO8v66Q9cHc= -golang.org/x/crypto v0.14.0/go.mod h1:MVFd36DqK4CsrnJYDkBA3VC4m2GkXAM0PvzMCn4JQf4= +golang.org/x/crypto v0.15.0 h1:frVn1TEaCEaZcn3Tmd7Y2b5KKPaZ+I32Q2OA3kYp5TA= +golang.org/x/crypto v0.15.0/go.mod h1:4ChreQoLWfG3xLDer1WdlH5NdlQ3+mwnQq1YTKY+72g= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8= @@ -1063,6 +1104,7 @@ golang.org/x/mod v0.4.1/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= golang.org/x/mod v0.11.0 h1:bUO06HqtnRcc/7l71XBe4WcqTZ+3AH1J59zWDDwLKgU= +golang.org/x/mod v0.11.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= @@ -1126,8 +1168,8 @@ golang.org/x/net v0.0.0-20221014081412-f15817d10f9b/go.mod h1:YDH+HFinaLZZlnHAfS golang.org/x/net v0.1.0/go.mod h1:Cx3nUiGt4eDBEyega/BKRp+/AlGL8hYe7U9odMt2Cco= golang.org/x/net v0.5.0/go.mod h1:DivGGAXEgPSlEBzxGzZI+ZLohi+xUj054jfeKui00ws= golang.org/x/net v0.7.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= -golang.org/x/net v0.17.0 h1:pVaXccu2ozPjCXewfr1S7xza/zcXTity9cCdXQYSjIM= -golang.org/x/net v0.17.0/go.mod h1:NxSsAGuq816PNPmqtQdLE42eU2Fs7NoRIZrHJAlaCOE= +golang.org/x/net v0.18.0 h1:mIYleuAkSbHh0tCv7RvjL3F6ZVbLjq4+R7zbOn3Kokg= +golang.org/x/net v0.18.0/go.mod h1:/czyP5RqHAH4odGYxBJ1qz0+CE5WZ+2j1YgoEo8F2jQ= 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= @@ -1153,8 +1195,8 @@ golang.org/x/oauth2 v0.0.0-20220822191816-0ebed06d0094/go.mod h1:h4gKUeWbJ4rQPri golang.org/x/oauth2 v0.0.0-20220909003341-f21342109be1/go.mod h1:h4gKUeWbJ4rQPri7E0u6Gs4e9Ri2zaLxzw5DI5XGrYg= golang.org/x/oauth2 v0.0.0-20221014153046-6fdb5e3db783/go.mod h1:h4gKUeWbJ4rQPri7E0u6Gs4e9Ri2zaLxzw5DI5XGrYg= golang.org/x/oauth2 v0.1.0/go.mod h1:G9FE4dLTsbXUu90h/Pf85g4w1D+SSAgR+q46nJZ8M4A= -golang.org/x/oauth2 v0.10.0 h1:zHCpF2Khkwy4mMB4bv0U37YtJdTGW8jI0glAApi0Kh8= -golang.org/x/oauth2 v0.10.0/go.mod h1:kTpgurOux7LqtuxjuyZa4Gj2gdezIt/jQtGnNFfypQI= +golang.org/x/oauth2 v0.11.0 h1:vPL4xzxBM4niKCW6g9whtaWVXTJf1U5e4aZxxFx/gbU= +golang.org/x/oauth2 v0.11.0/go.mod h1:LdF7O/8bLR/qWK9DrpXmbHLTouvRHK0SgJl0GmDBchk= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= @@ -1270,15 +1312,15 @@ golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.4.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.13.0 h1:Af8nKPmuFypiUBjVoU9V20FiaFXOcuZI21p0ycVYYGE= -golang.org/x/sys v0.13.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.14.0 h1:Vz7Qs629MkJkGyHxUlRHizWJRG2j8fbQKjELVSNhy7Q= +golang.org/x/sys v0.14.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= golang.org/x/term v0.1.0/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= golang.org/x/term v0.4.0/go.mod h1:9P2UbLfCdcvo3p/nzKvsmas4TnlujnuoV9hGgYzW1lQ= golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k= -golang.org/x/term v0.13.0 h1:bb+I9cTfFazGW51MZqBVmZy7+JEJMouUHTUSKVQLBek= -golang.org/x/term v0.13.0/go.mod h1:LTmsnFJwVN6bCy1rVCoS+qHT1HhALEFxKncY3WNNh4U= +golang.org/x/term v0.14.0 h1:LGK9IlZ8T9jvdy6cTdfKUCltatMFOehAQo9SRC46UQ8= +golang.org/x/term v0.14.0/go.mod h1:TySc+nGkYR6qt8km8wUhuFRTVSMIX3XPR58y2lC8vww= 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= golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= @@ -1292,8 +1334,8 @@ golang.org/x/text v0.3.8/go.mod h1:E6s5w1FMmriuDzIBO73fBruAKo1PCIq6d2Q6DHfQ8WQ= golang.org/x/text v0.4.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= golang.org/x/text v0.6.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= -golang.org/x/text v0.13.0 h1:ablQoSUd0tRdKxZewP80B+BaqeKJuVhuRxj/dkrun3k= -golang.org/x/text v0.13.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE= +golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ= +golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= golang.org/x/time v0.0.0-20180412165947-fbb02b2291d2/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= 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= @@ -1361,6 +1403,7 @@ golang.org/x/tools v0.1.4/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= golang.org/x/tools v0.1.5/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc= golang.org/x/tools v0.6.0 h1:BOw41kyTf3PuCW1pVQf8+Cyg8pMlkYB1oo9iJ6D/lKM= +golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= @@ -1585,8 +1628,8 @@ google.golang.org/grpc v1.48.0/go.mod h1:vN9eftEi1UMyUsIF80+uQXhHjbXYbm0uXoFCACu google.golang.org/grpc v1.49.0/go.mod h1:ZgQEeidpAuNRZ8iRrlBKXZQP1ghovWIVhdJRyCDK+GI= google.golang.org/grpc v1.50.0/go.mod h1:ZgQEeidpAuNRZ8iRrlBKXZQP1ghovWIVhdJRyCDK+GI= google.golang.org/grpc v1.50.1/go.mod h1:ZgQEeidpAuNRZ8iRrlBKXZQP1ghovWIVhdJRyCDK+GI= -google.golang.org/grpc v1.58.3 h1:BjnpXut1btbtgN/6sp+brB2Kbm2LjNXnidYujAVbSoQ= -google.golang.org/grpc v1.58.3/go.mod h1:tgX3ZQDlNJGU96V6yHh1T/JeoBQ2TXdr43YbYSsCJk0= +google.golang.org/grpc v1.59.0 h1:Z5Iec2pjwb+LEOqzpB2MR12/eKFhDPhuqW91O+4bwUk= +google.golang.org/grpc v1.59.0/go.mod h1:aUPDwccQo6OTjy7Hct4AfBPD1GptF4fyUjIkQ9YtF98= google.golang.org/grpc/cmd/protoc-gen-go-grpc v1.1.0/go.mod h1:6Kw0yEErY5E/yWrBtf03jp27GLLJujG4z/JK95pnjjw= google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8= google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0= diff --git a/store/cache/cache_test.go b/store/cache/cache_test.go index c9d4f1e8f7b9..790c8cd01abb 100644 --- a/store/cache/cache_test.go +++ b/store/cache/cache_test.go @@ -4,6 +4,7 @@ import ( "fmt" "testing" + "cosmossdk.io/log" dbm "github.com/cometbft/cometbft-db" "github.com/cosmos/iavl" "github.com/stretchr/testify/require" @@ -12,15 +13,15 @@ import ( "github.com/cosmos/cosmos-sdk/store/cachekv" iavlstore "github.com/cosmos/cosmos-sdk/store/iavl" "github.com/cosmos/cosmos-sdk/store/types" + "github.com/cosmos/cosmos-sdk/store/wrapper" ) func TestGetOrSetStoreCache(t *testing.T) { - db := dbm.NewMemDB() + db := wrapper.NewCosmosDB(dbm.NewMemDB()) mngr := cache.NewCommitKVStoreCacheManager(cache.DefaultCommitKVStoreCacheSize) sKey := types.NewKVStoreKey("test") - tree, err := iavl.NewMutableTree(db, 100, false) - require.NoError(t, err) + tree := iavl.NewMutableTree(db, 100, false, log.NewNopLogger()) store := iavlstore.UnsafeNewStore(tree) store2 := mngr.GetStoreCache(sKey, store) @@ -29,12 +30,11 @@ func TestGetOrSetStoreCache(t *testing.T) { } func TestUnwrap(t *testing.T) { - db := dbm.NewMemDB() + db := wrapper.NewCosmosDB(dbm.NewMemDB()) mngr := cache.NewCommitKVStoreCacheManager(cache.DefaultCommitKVStoreCacheSize) sKey := types.NewKVStoreKey("test") - tree, err := iavl.NewMutableTree(db, 100, false) - require.NoError(t, err) + tree := iavl.NewMutableTree(db, 100, false, log.NewNopLogger()) store := iavlstore.UnsafeNewStore(tree) _ = mngr.GetStoreCache(sKey, store) @@ -43,12 +43,11 @@ func TestUnwrap(t *testing.T) { } func TestStoreCache(t *testing.T) { - db := dbm.NewMemDB() + db := wrapper.NewCosmosDB(dbm.NewMemDB()) mngr := cache.NewCommitKVStoreCacheManager(cache.DefaultCommitKVStoreCacheSize) sKey := types.NewKVStoreKey("test") - tree, err := iavl.NewMutableTree(db, 100, false) - require.NoError(t, err) + tree := iavl.NewMutableTree(db, 100, false, log.NewNopLogger()) store := iavlstore.UnsafeNewStore(tree) kvStore := mngr.GetStoreCache(sKey, store) @@ -70,12 +69,11 @@ func TestStoreCache(t *testing.T) { } func TestReset(t *testing.T) { - db := dbm.NewMemDB() + db := wrapper.NewCosmosDB(dbm.NewMemDB()) mngr := cache.NewCommitKVStoreCacheManager(cache.DefaultCommitKVStoreCacheSize) sKey := types.NewKVStoreKey("test") - tree, err := iavl.NewMutableTree(db, 100, false) - require.NoError(t, err) + tree := iavl.NewMutableTree(db, 100, false, log.NewNopLogger()) store := iavlstore.UnsafeNewStore(tree) store2 := mngr.GetStoreCache(sKey, store) @@ -91,12 +89,11 @@ func TestReset(t *testing.T) { } func TestCacheWrap(t *testing.T) { - db := dbm.NewMemDB() + db := wrapper.NewCosmosDB(dbm.NewMemDB()) mngr := cache.NewCommitKVStoreCacheManager(cache.DefaultCommitKVStoreCacheSize) sKey := types.NewKVStoreKey("test") - tree, err := iavl.NewMutableTree(db, 100, false) - require.NoError(t, err) + tree := iavl.NewMutableTree(db, 100, false, log.NewNopLogger()) store := iavlstore.UnsafeNewStore(tree) cacheWrapper := mngr.GetStoreCache(sKey, store).CacheWrap() diff --git a/store/iavl/store.go b/store/iavl/store.go index 28e7f68df7d1..52c95cef1c80 100644 --- a/store/iavl/store.go +++ b/store/iavl/store.go @@ -6,6 +6,7 @@ import ( "io" "time" + clog "cosmossdk.io/log" dbm "github.com/cometbft/cometbft-db" abci "github.com/cometbft/cometbft/abci/types" "github.com/cometbft/cometbft/libs/log" @@ -17,6 +18,7 @@ import ( pruningtypes "github.com/cosmos/cosmos-sdk/store/pruning/types" "github.com/cosmos/cosmos-sdk/store/tracekv" "github.com/cosmos/cosmos-sdk/store/types" + "github.com/cosmos/cosmos-sdk/store/wrapper" "github.com/cosmos/cosmos-sdk/telemetry" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" "github.com/cosmos/cosmos-sdk/types/kv" @@ -52,10 +54,7 @@ func LoadStore(db dbm.DB, logger log.Logger, key types.StoreKey, id types.Commit // provided DB. An error is returned if the version fails to load, or if called with a positive // version on an empty tree. func LoadStoreWithInitialVersion(db dbm.DB, logger log.Logger, key types.StoreKey, id types.CommitID, lazyLoading bool, initialVersion uint64, cacheSize int, disableFastNode bool) (types.CommitKVStore, error) { - tree, err := iavl.NewMutableTreeWithOpts(db, cacheSize, &iavl.Options{InitialVersion: initialVersion}, disableFastNode) - if err != nil { - return nil, err - } + tree := iavl.NewMutableTree(wrapper.NewCosmosDB(db), cacheSize, disableFastNode, clog.NewNopLogger(), iavl.InitialVersionOption(initialVersion)) isUpgradeable, err := tree.IsUpgradeable() if err != nil { @@ -72,11 +71,7 @@ func LoadStoreWithInitialVersion(db dbm.DB, logger log.Logger, key types.StoreKe ) } - if lazyLoading { - _, err = tree.LazyLoadVersion(id.Version) - } else { - _, err = tree.LoadVersion(id.Version) - } + _, err = tree.LoadVersion(id.Version) if err != nil { return nil, err @@ -87,7 +82,7 @@ func LoadStoreWithInitialVersion(db dbm.DB, logger log.Logger, key types.StoreKe } return &Store{ - tree: tree, + tree: &mutableTree{tree}, logger: logger, }, nil } @@ -100,7 +95,7 @@ func LoadStoreWithInitialVersion(db dbm.DB, logger log.Logger, key types.StoreKe // passed into iavl.MutableTree func UnsafeNewStore(tree *iavl.MutableTree) *Store { return &Store{ - tree: tree, + tree: &mutableTree{tree}, } } @@ -142,10 +137,7 @@ func (st *Store) Commit() types.CommitID { // LastCommitID implements Committer. func (st *Store) LastCommitID() types.CommitID { - hash, err := st.tree.Hash() - if err != nil { - panic(err) - } + hash := st.tree.Hash() return types.CommitID{ Version: st.tree.Version(), @@ -228,22 +220,17 @@ func (st *Store) Delete(key []byte) { } } -// DeleteVersions deletes a series of versions from the MutableTree. An error +// DeleteVersionsTo deletes versions upto the given version from the MutableTree. An error // is returned if any single version is invalid or the delete fails. All writes // happen in a single batch with a single commit. -func (st *Store) DeleteVersions(versions ...int64) error { - return st.tree.DeleteVersions(versions...) +func (st *Store) DeleteVersionsTo(version int64) error { + return st.tree.DeleteVersionsTo(version) } // LoadVersionForOverwriting attempts to load a tree at a previously committed // version, or the latest version below it. Any versions greater than targetVersion will be deleted. func (st *Store) LoadVersionForOverwriting(targetVersion int64) (int64, error) { - return st.tree.LoadVersionForOverwriting(targetVersion) -} - -// LazyLoadVersionForOverwriting is the lazy version of LoadVersionForOverwriting. -func (st *Store) LazyLoadVersionForOverwriting(targetVersion int64) (int64, error) { - return st.tree.LazyLoadVersionForOverwriting(targetVersion) + return targetVersion, st.tree.LoadVersionForOverwriting(targetVersion) } // Implements types.KVStore. @@ -285,7 +272,7 @@ func (st *Store) Export(version int64) (*iavl.Exporter, error) { // Import imports an IAVL tree at the given version, returning an iavl.Importer for importing. func (st *Store) Import(version int64) (*iavl.Importer, error) { - tree, ok := st.tree.(*iavl.MutableTree) + tree, ok := st.tree.(*mutableTree) if !ok { return nil, errors.New("iavl import failed: unable to find mutable tree") } @@ -395,23 +382,24 @@ func (st *Store) Query(req abci.RequestQuery) (res abci.ResponseQuery) { func getProofFromTree(tree *iavl.MutableTree, key []byte, exists bool) *tmcrypto.ProofOps { var ( commitmentProof *ics23.CommitmentProof - err error ) if exists { // value was found - commitmentProof, err = tree.GetMembershipProof(key) + tempCommitmentProof, err := tree.GetMembershipProof(key) if err != nil { // sanity check: If value was found, membership proof must be creatable panic(fmt.Sprintf("unexpected value for empty proof: %s", err.Error())) } + commitmentProof = wrapper.ConvertCommitmentProof(tempCommitmentProof) } else { // value wasn't found - commitmentProof, err = tree.GetNonMembershipProof(key) + tempCommitmentProof, err := tree.GetNonMembershipProof(key) if err != nil { // sanity check: If value wasn't found, nonmembership proof must be creatable panic(fmt.Sprintf("unexpected error for nonexistence proof: %s", err.Error())) } + commitmentProof = wrapper.ConvertCommitmentProof(tempCommitmentProof) } op := types.NewIavlCommitmentOp(key, commitmentProof) diff --git a/store/iavl/store_test.go b/store/iavl/store_test.go index f73c86197c07..018b42bada0b 100644 --- a/store/iavl/store_test.go +++ b/store/iavl/store_test.go @@ -5,11 +5,13 @@ import ( "fmt" "testing" + "cosmossdk.io/log" "github.com/cosmos/cosmos-sdk/store/cachekv" + "github.com/cosmos/cosmos-sdk/store/wrapper" dbm "github.com/cometbft/cometbft-db" abci "github.com/cometbft/cometbft/abci/types" - "github.com/cometbft/cometbft/libs/log" + cmlog "github.com/cometbft/cometbft/libs/log" "github.com/cosmos/iavl" "github.com/stretchr/testify/require" @@ -34,8 +36,8 @@ func randBytes(numBytes int) []byte { // make a tree with data from above and save it func newAlohaTree(t *testing.T, db dbm.DB) (*iavl.MutableTree, types.CommitID) { - tree, err := iavl.NewMutableTree(db, cacheSize, false) - require.NoError(t, err) + dbt := wrapper.NewCosmosDB(db) + tree := iavl.NewMutableTree(dbt, cacheSize, false, log.NewNopLogger()) for k, v := range treeData { tree.Set([]byte(k), []byte(v)) @@ -100,17 +102,17 @@ func TestLoadStore(t *testing.T) { require.Equal(t, string(hcStore.Get([]byte("hello"))), "ciao") // Querying a new store at some previous non-pruned height H - newHStore, err := LoadStore(db, log.NewNopLogger(), types.NewKVStoreKey("test"), cIDH, false, DefaultIAVLCacheSize, false) + newHStore, err := LoadStore(db, cmlog.NewNopLogger(), types.NewKVStoreKey("test"), cIDH, false, DefaultIAVLCacheSize, false) require.NoError(t, err) require.Equal(t, string(newHStore.Get([]byte("hello"))), "hallo") // Querying a new store at some previous pruned height Hp - newHpStore, err := LoadStore(db, log.NewNopLogger(), types.NewKVStoreKey("test"), cIDHp, false, DefaultIAVLCacheSize, false) + newHpStore, err := LoadStore(db, cmlog.NewNopLogger(), types.NewKVStoreKey("test"), cIDHp, false, DefaultIAVLCacheSize, false) require.NoError(t, err) require.Equal(t, string(newHpStore.Get([]byte("hello"))), "hola") // Querying a new store at current height H - newHcStore, err := LoadStore(db, log.NewNopLogger(), types.NewKVStoreKey("test"), cIDHc, false, DefaultIAVLCacheSize, false) + newHcStore, err := LoadStore(db, cmlog.NewNopLogger(), types.NewKVStoreKey("test"), cIDHc, false, DefaultIAVLCacheSize, false) require.NoError(t, err) require.Equal(t, string(newHcStore.Get([]byte("hello"))), "ciao") } @@ -280,10 +282,8 @@ func TestIAVLIterator(t *testing.T) { } func TestIAVLReverseIterator(t *testing.T) { - db := dbm.NewMemDB() - - tree, err := iavl.NewMutableTree(db, cacheSize, false) - require.NoError(t, err) + db := wrapper.NewCosmosDB(dbm.NewMemDB()) + tree := iavl.NewMutableTree(db, cacheSize, false, log.NewNopLogger()) iavlStore := UnsafeNewStore(tree) @@ -314,9 +314,8 @@ func TestIAVLReverseIterator(t *testing.T) { } func TestIAVLPrefixIterator(t *testing.T) { - db := dbm.NewMemDB() - tree, err := iavl.NewMutableTree(db, cacheSize, false) - require.NoError(t, err) + db := wrapper.NewCosmosDB(dbm.NewMemDB()) + tree := iavl.NewMutableTree(db, cacheSize, false, log.NewNopLogger()) iavlStore := UnsafeNewStore(tree) @@ -378,9 +377,8 @@ func TestIAVLPrefixIterator(t *testing.T) { } func TestIAVLReversePrefixIterator(t *testing.T) { - db := dbm.NewMemDB() - tree, err := iavl.NewMutableTree(db, cacheSize, false) - require.NoError(t, err) + db := wrapper.NewCosmosDB(dbm.NewMemDB()) + tree := iavl.NewMutableTree(db, cacheSize, false, log.NewNopLogger()) iavlStore := UnsafeNewStore(tree) @@ -446,9 +444,8 @@ func nextVersion(iavl *Store) { } func TestIAVLNoPrune(t *testing.T) { - db := dbm.NewMemDB() - tree, err := iavl.NewMutableTree(db, cacheSize, false) - require.NoError(t, err) + db := wrapper.NewCosmosDB(dbm.NewMemDB()) + tree := iavl.NewMutableTree(db, cacheSize, false, log.NewNopLogger()) iavlStore := UnsafeNewStore(tree) nextVersion(iavlStore) @@ -465,9 +462,8 @@ func TestIAVLNoPrune(t *testing.T) { } func TestIAVLStoreQuery(t *testing.T) { - db := dbm.NewMemDB() - tree, err := iavl.NewMutableTree(db, cacheSize, false) - require.NoError(t, err) + db := wrapper.NewCosmosDB(dbm.NewMemDB()) + tree := iavl.NewMutableTree(db, cacheSize, false, log.NewNopLogger()) iavlStore := UnsafeNewStore(tree) @@ -568,10 +564,9 @@ func TestIAVLStoreQuery(t *testing.T) { func BenchmarkIAVLIteratorNext(b *testing.B) { b.ReportAllocs() - db := dbm.NewMemDB() + db := wrapper.NewCosmosDB(dbm.NewMemDB()) treeSize := 1000 - tree, err := iavl.NewMutableTree(db, cacheSize, false) - require.NoError(b, err) + tree := iavl.NewMutableTree(db, cacheSize, false, log.NewNopLogger()) for i := 0; i < treeSize; i++ { key := randBytes(4) @@ -604,8 +599,8 @@ func TestSetInitialVersion(t *testing.T) { { "works with a mutable tree", func(db *dbm.MemDB) *Store { - tree, err := iavl.NewMutableTree(db, cacheSize, false) - require.NoError(t, err) + dbt := wrapper.NewCosmosDB(db) + tree := iavl.NewMutableTree(dbt, cacheSize, false, log.NewNopLogger()) store := UnsafeNewStore(tree) return store @@ -614,8 +609,8 @@ func TestSetInitialVersion(t *testing.T) { { "throws error on immutable tree", func(db *dbm.MemDB) *Store { - tree, err := iavl.NewMutableTree(db, cacheSize, false) - require.NoError(t, err) + dbt := wrapper.NewCosmosDB(db) + tree := iavl.NewMutableTree(dbt, cacheSize, false, log.NewNopLogger()) store := UnsafeNewStore(tree) _, version, err := store.tree.SaveVersion() require.NoError(t, err) diff --git a/store/iavl/tree.go b/store/iavl/tree.go index 9719e3c7573e..7a33fa993f28 100644 --- a/store/iavl/tree.go +++ b/store/iavl/tree.go @@ -5,11 +5,13 @@ import ( "github.com/cosmos/cosmos-sdk/store/types" "github.com/cosmos/iavl" + + dbm "github.com/tendermint/tm-db" ) var ( _ Tree = (*immutableTree)(nil) - _ Tree = (*iavl.MutableTree)(nil) + _ Tree = (*mutableTree)(nil) ) type ( @@ -23,18 +25,18 @@ type ( Set(key, value []byte) (bool, error) Remove(key []byte) ([]byte, bool, error) SaveVersion() ([]byte, int64, error) - DeleteVersion(version int64) error - DeleteVersions(versions ...int64) error Version() int64 - Hash() ([]byte, error) + Hash() []byte + WorkingHash() []byte VersionExists(version int64) bool + DeleteVersionsTo(version int64) error GetVersioned(key []byte, version int64) ([]byte, error) GetImmutable(version int64) (*iavl.ImmutableTree, error) SetInitialVersion(version uint64) Iterator(start, end []byte, ascending bool) (types.Iterator, error) AvailableVersions() []int - LoadVersionForOverwriting(targetVersion int64) (int64, error) - LazyLoadVersionForOverwriting(targetVersion int64) (int64, error) + LoadVersionForOverwriting(targetVersion int64) error + TraverseStateChanges(startVersion, endVersion int64, fn func(version int64, changeSet *iavl.ChangeSet) error) error } // immutableTree is a simple wrapper around a reference to an iavl.ImmutableTree @@ -43,6 +45,10 @@ type ( immutableTree struct { *iavl.ImmutableTree } + + mutableTree struct { + *iavl.MutableTree + } ) func (it *immutableTree) Set(_, _ []byte) (bool, error) { @@ -57,12 +63,8 @@ func (it *immutableTree) SaveVersion() ([]byte, int64, error) { panic("cannot call 'SaveVersion' on an immutable IAVL tree") } -func (it *immutableTree) DeleteVersion(_ int64) error { - panic("cannot call 'DeleteVersion' on an immutable IAVL tree") -} - -func (it *immutableTree) DeleteVersions(_ ...int64) error { - panic("cannot call 'DeleteVersions' on an immutable IAVL tree") +func (it *immutableTree) DeleteVersionsTo(_ int64) error { + panic("cannot call 'DeleteVersionsTo' on an immutable IAVL tree") } func (it *immutableTree) SetInitialVersion(_ uint64) { @@ -93,10 +95,20 @@ func (it *immutableTree) AvailableVersions() []int { return []int{} } -func (it *immutableTree) LoadVersionForOverwriting(targetVersion int64) (int64, error) { +func (it *immutableTree) LoadVersionForOverwriting(targetVersion int64) error { panic("cannot call 'LoadVersionForOverwriting' on an immutable IAVL tree") } -func (it *immutableTree) LazyLoadVersionForOverwriting(targetVersion int64) (int64, error) { - panic("cannot call 'LazyLoadVersionForOverwriting' on an immutable IAVL tree") +func (it *immutableTree) WorkingHash() []byte { + panic("cannot call 'WorkingHash' on an immutable IAVL tree") +} + +func (it *immutableTree) Iterator(start, end []byte, ascending bool) (types.Iterator, error) { + iterator, err := it.ImmutableTree.Iterator(start, end, ascending) + return iterator.(dbm.Iterator), err +} + +func (mt *mutableTree) Iterator(start, end []byte, ascending bool) (types.Iterator, error) { + iterator, err := mt.MutableTree.Iterator(start, end, ascending) + return iterator.(dbm.Iterator), err } diff --git a/store/iavl/tree_test.go b/store/iavl/tree_test.go index 9abb7aa50de5..9d34a41ab977 100644 --- a/store/iavl/tree_test.go +++ b/store/iavl/tree_test.go @@ -3,19 +3,23 @@ package iavl import ( "testing" + "cosmossdk.io/log" + dbm "github.com/cometbft/cometbft-db" + "github.com/cosmos/cosmos-sdk/store/wrapper" "github.com/cosmos/iavl" "github.com/stretchr/testify/require" ) func TestImmutableTreePanics(t *testing.T) { t.Parallel() - immTree := iavl.NewImmutableTree(dbm.NewMemDB(), 100, false) + db := wrapper.NewCosmosDB(dbm.NewMemDB()) + immTree := iavl.NewImmutableTree(db, 100, false, log.NewNopLogger()) it := &immutableTree{immTree} require.Panics(t, func() { it.Set([]byte{}, []byte{}) }) require.Panics(t, func() { it.Remove([]byte{}) }) - require.Panics(t, func() { it.SaveVersion() }) // nolint:errcheck - require.Panics(t, func() { it.DeleteVersion(int64(1)) }) // nolint:errcheck + require.Panics(t, func() { it.SaveVersion() }) // nolint:errcheck + require.Panics(t, func() { it.DeleteVersionsTo(int64(1)) }) // nolint:errcheck val, err := it.GetVersioned(nil, 1) require.Error(t, err) diff --git a/store/prefix/store_test.go b/store/prefix/store_test.go index d7b655968814..7d9511910c88 100644 --- a/store/prefix/store_test.go +++ b/store/prefix/store_test.go @@ -4,7 +4,9 @@ import ( "crypto/rand" "testing" + "cosmossdk.io/log" "github.com/cosmos/cosmos-sdk/store/cachekv" + "github.com/cosmos/cosmos-sdk/store/wrapper" dbm "github.com/cometbft/cometbft-db" "github.com/stretchr/testify/require" @@ -89,9 +91,8 @@ func testPrefixStore(t *testing.T, baseStore types.KVStore, prefix []byte) { } func TestIAVLStorePrefix(t *testing.T) { - db := dbm.NewMemDB() - tree, err := tiavl.NewMutableTree(db, cacheSize, false) - require.NoError(t, err) + db := wrapper.NewCosmosDB(dbm.NewMemDB()) + tree := tiavl.NewMutableTree(db, cacheSize, false, log.NewNopLogger()) iavlStore := iavl.UnsafeNewStore(tree) testPrefixStore(t, iavlStore, []byte("test")) diff --git a/store/pruning/export_test.go b/store/pruning/export_test.go index 8c38778bf93d..676ff132ff98 100644 --- a/store/pruning/export_test.go +++ b/store/pruning/export_test.go @@ -1,11 +1,8 @@ package pruning var ( - PruneHeightsKey = pruneHeightsKey PruneSnapshotHeightsKey = pruneSnapshotHeightsKey Int64SliceToBytes = int64SliceToBytes - ListToBytes = listToBytes - LoadPruningHeights = loadPruningHeights LoadPruningSnapshotHeights = loadPruningSnapshotHeights ) diff --git a/store/pruning/manager.go b/store/pruning/manager.go index e159f909510a..adeb25eef208 100644 --- a/store/pruning/manager.go +++ b/store/pruning/manager.go @@ -1,9 +1,9 @@ package pruning import ( - "container/list" "encoding/binary" "fmt" + "sort" "sync" dbm "github.com/cometbft/cometbft-db" @@ -20,17 +20,13 @@ type Manager struct { logger log.Logger opts types.PruningOptions snapshotInterval uint64 - // Although pruneHeights happen in the same goroutine with the normal execution, - // we sync access to them to avoid soundness issues in the future if concurrency pattern changes. - pruneHeightsMx sync.Mutex - pruneHeights []int64 // Snapshots are taken in a separate goroutine from the regular execution // and can be delivered asynchrounously via HandleHeightSnapshot. // Therefore, we sync access to pruneSnapshotHeights with this mutex. - pruneSnapshotHeightsMx sync.Mutex + pruneSnapshotHeightsMx sync.RWMutex // These are the heights that are multiples of snapshotInterval and kept for state sync snapshots. // The heights are added to this list to be pruned when a snapshot is complete. - pruneSnapshotHeights *list.List + pruneSnapshotHeights []int64 } // NegativeHeightsError is returned when a negative height is provided to the manager. @@ -45,7 +41,6 @@ func (e *NegativeHeightsError) Error() string { } var ( - pruneHeightsKey = []byte("s/pruneheights") pruneSnapshotHeightsKey = []byte("s/prunesnapshotheights") ) @@ -58,8 +53,7 @@ func NewManager(db dbm.DB, logger log.Logger) *Manager { db: db, logger: logger, opts: types.NewPruningOptions(types.PruningNothing), - pruneHeights: []int64{}, - pruneSnapshotHeights: list.New(), + pruneSnapshotHeights: []int64{0}, } } @@ -73,89 +67,11 @@ func (m *Manager) GetOptions() types.PruningOptions { return m.opts } -// GetFlushAndResetPruningHeights returns all heights to be pruned during the next call to Prune(). -// It also flushes and resets the pruning heights. -func (m *Manager) GetFlushAndResetPruningHeights() ([]int64, error) { - if m.opts.GetPruningStrategy() == types.PruningNothing { - return []int64{}, nil - } - m.pruneHeightsMx.Lock() - defer m.pruneHeightsMx.Unlock() - - // flush the updates to disk so that it is not lost if crash happens. - if err := m.db.SetSync(pruneHeightsKey, int64SliceToBytes(m.pruneHeights)); err != nil { - return nil, err - } - - // Return a copy to prevent data races. - pruningHeights := make([]int64, len(m.pruneHeights)) - copy(pruningHeights, m.pruneHeights) - m.pruneHeights = m.pruneHeights[:0] - - return pruningHeights, nil -} - -// HandleHeight determines if previousHeight height needs to be kept for pruning at the right interval prescribed by -// the pruning strategy. Returns previousHeight, if it was kept to be pruned at the next call to Prune(), 0 otherwise. -// previousHeight must be greater than 0 for the handling to take effect since valid heights start at 1 and 0 represents -// the latest height. The latest height cannot be pruned. As a result, if previousHeight is less than or equal to 0, 0 is returned. -func (m *Manager) HandleHeight(previousHeight int64) int64 { - if m.opts.GetPruningStrategy() == types.PruningNothing || previousHeight <= 0 { - return 0 - } - - defer func() { - m.pruneHeightsMx.Lock() - defer m.pruneHeightsMx.Unlock() - - m.pruneSnapshotHeightsMx.Lock() - defer m.pruneSnapshotHeightsMx.Unlock() - - // move persisted snapshot heights to pruneHeights which - // represent the heights to be pruned at the next pruning interval. - var next *list.Element - for e := m.pruneSnapshotHeights.Front(); e != nil; e = next { - snHeight := e.Value.(int64) - if snHeight < previousHeight-int64(m.opts.KeepRecent) { - m.pruneHeights = append(m.pruneHeights, snHeight) - - // We must get next before removing to be able to continue iterating. - next = e.Next() - m.pruneSnapshotHeights.Remove(e) - } else { - next = e.Next() - } - } - - // flush the updates to disk so that they are not lost if crash happens. - if err := m.db.SetSync(pruneHeightsKey, int64SliceToBytes(m.pruneHeights)); err != nil { - panic(err) - } - }() - - if int64(m.opts.KeepRecent) < previousHeight { - pruneHeight := previousHeight - int64(m.opts.KeepRecent) - // We consider this height to be pruned iff: - // - // - snapshotInterval is zero as that means that all heights should be pruned. - // - snapshotInterval % (height - KeepRecent) != 0 as that means the height is not - // a 'snapshot' height. - if m.snapshotInterval == 0 || pruneHeight%int64(m.snapshotInterval) != 0 { - m.pruneHeightsMx.Lock() - defer m.pruneHeightsMx.Unlock() - - m.pruneHeights = append(m.pruneHeights, pruneHeight) - return pruneHeight - } - } - return 0 -} - -// HandleHeightSnapshot persists the snapshot height to be pruned at the next appropriate -// height defined by the pruning strategy. Flushes the update to disk and panics if the flush fails -// The input height must be greater than 0 and pruning strategy any but pruning nothing. -// If one of these conditions is not met, this function does nothing. -func (m *Manager) HandleHeightSnapshot(height int64) { +// HandleSnapshotHeight persists the snapshot height to be pruned at the next appropriate +// height defined by the pruning strategy. It flushes the update to disk and panics if the flush fails. +// The input height must be greater than 0, and the pruning strategy must not be set to pruning nothing. +// If either of these conditions is not met, this function does nothing. +func (m *Manager) HandleSnapshotHeight(height int64) { if m.opts.GetPruningStrategy() == types.PruningNothing || height <= 0 { return } @@ -163,11 +79,19 @@ func (m *Manager) HandleHeightSnapshot(height int64) { m.pruneSnapshotHeightsMx.Lock() defer m.pruneSnapshotHeightsMx.Unlock() - m.logger.Debug("HandleHeightSnapshot", "height", height) - m.pruneSnapshotHeights.PushBack(height) + m.logger.Debug("HandleSnapshotHeight", "height", height) + m.pruneSnapshotHeights = append(m.pruneSnapshotHeights, height) + sort.Slice(m.pruneSnapshotHeights, func(i, j int) bool { return m.pruneSnapshotHeights[i] < m.pruneSnapshotHeights[j] }) + k := 1 + for ; k < len(m.pruneSnapshotHeights); k++ { + if m.pruneSnapshotHeights[k] != m.pruneSnapshotHeights[k-1]+int64(m.snapshotInterval) { + break + } + } + m.pruneSnapshotHeights = m.pruneSnapshotHeights[k-1:] // flush the updates to disk so that they are not lost if crash happens. - if err := m.db.SetSync(pruneSnapshotHeightsKey, listToBytes(m.pruneSnapshotHeights)); err != nil { + if err := m.db.SetSync(pruneSnapshotHeightsKey, int64SliceToBytes(m.pruneSnapshotHeights)); err != nil { panic(err) } } @@ -177,83 +101,81 @@ func (m *Manager) SetSnapshotInterval(snapshotInterval uint64) { m.snapshotInterval = snapshotInterval } -// ShouldPruneAtHeight return true if the given height should be pruned, false otherwise -func (m *Manager) ShouldPruneAtHeight(height int64) bool { - return m.opts.Interval > 0 && m.opts.GetPruningStrategy() != types.PruningNothing && height%int64(m.opts.Interval) == 0 -} - -// LoadPruningHeights loads the pruning heights from the database as a crash recovery. -func (m *Manager) LoadPruningHeights(db dbm.DB) error { +// GetPruningHeight returns the height which can prune upto if it is able to prune at the given height. +func (m *Manager) GetPruningHeight(height int64) int64 { if m.opts.GetPruningStrategy() == types.PruningNothing { - return nil + return 0 } - loadedPruneHeights, err := loadPruningHeights(db) - if err != nil { - return err + if m.opts.Interval <= 0 { + return 0 } - if len(loadedPruneHeights) > 0 { - m.pruneHeightsMx.Lock() - defer m.pruneHeightsMx.Unlock() - m.pruneHeights = loadedPruneHeights + if height%int64(m.opts.Interval) != 0 || height <= int64(m.opts.KeepRecent) { + return 0 } - loadedPruneSnapshotHeights, err := loadPruningSnapshotHeights(db) - if err != nil { - return err + // Consider the snapshot height + pruneHeight := height - 1 - int64(m.opts.KeepRecent) // we should keep the current height at least + + m.pruneSnapshotHeightsMx.RLock() + defer m.pruneSnapshotHeightsMx.RUnlock() + + // snapshotInterval is zero, indicating that all heights can be pruned + if m.snapshotInterval <= 0 { + return pruneHeight } - if loadedPruneSnapshotHeights.Len() > 0 { - m.pruneSnapshotHeightsMx.Lock() - defer m.pruneSnapshotHeightsMx.Unlock() - m.pruneSnapshotHeights = loadedPruneSnapshotHeights + if len(m.pruneSnapshotHeights) == 0 { // the length should be greater than zero + return 0 } - return nil + // the snapshot `m.pruneSnapshotHeights[0]` is already operated, + // so we can prune upto `m.pruneSnapshotHeights[0] + int64(m.snapshotInterval) - 1` + snHeight := m.pruneSnapshotHeights[0] + int64(m.snapshotInterval) - 1 + if snHeight < pruneHeight { + return snHeight + } + return pruneHeight } -func loadPruningHeights(db dbm.DB) ([]int64, error) { - bz, err := db.Get(pruneHeightsKey) - if err != nil { - return nil, fmt.Errorf("failed to get pruned heights: %w", err) - } - if len(bz) == 0 { - return []int64{}, nil +// LoadSnapshotHeights loads the snapshot heights from the database as a crash recovery. +func (m *Manager) LoadSnapshotHeights(db dbm.DB) error { + if m.opts.GetPruningStrategy() == types.PruningNothing { + return nil } - prunedHeights := make([]int64, len(bz)/8) - i, offset := 0, 0 - for offset < len(bz) { - h := int64(binary.BigEndian.Uint64(bz[offset : offset+8])) - if h < 0 { - return []int64{}, &NegativeHeightsError{Height: h} - } + loadedPruneSnapshotHeights, err := loadPruningSnapshotHeights(db) + if err != nil { + return err + } - prunedHeights[i] = h - i++ - offset += 8 + if len(loadedPruneSnapshotHeights) > 0 { + m.pruneSnapshotHeightsMx.Lock() + defer m.pruneSnapshotHeightsMx.Unlock() + m.pruneSnapshotHeights = loadedPruneSnapshotHeights } - return prunedHeights, nil + return nil } -func loadPruningSnapshotHeights(db dbm.DB) (*list.List, error) { +func loadPruningSnapshotHeights(db dbm.DB) ([]int64, error) { bz, err := db.Get(pruneSnapshotHeightsKey) if err != nil { return nil, fmt.Errorf("failed to get post-snapshot pruned heights: %w", err) } - pruneSnapshotHeights := list.New() + if len(bz) == 0 { - return pruneSnapshotHeights, nil + return []int64{}, nil } + pruneSnapshotHeights := make([]int64, len(bz)/8) i, offset := 0, 0 for offset < len(bz) { h := int64(binary.BigEndian.Uint64(bz[offset : offset+8])) if h < 0 { return nil, &NegativeHeightsError{Height: h} } - pruneSnapshotHeights.PushBack(h) + pruneSnapshotHeights[i] = h i++ offset += 8 } @@ -270,13 +192,3 @@ func int64SliceToBytes(slice []int64) []byte { } return bz } - -func listToBytes(list *list.List) []byte { - bz := make([]byte, 0, list.Len()*8) - for e := list.Front(); e != nil; e = e.Next() { - buf := make([]byte, 8) - binary.BigEndian.PutUint64(buf, uint64(e.Value.(int64))) - bz = append(bz, buf...) - } - return bz -} diff --git a/store/pruning/manager_test.go b/store/pruning/manager_test.go index f7f71b9cfe4a..8618a762b504 100644 --- a/store/pruning/manager_test.go +++ b/store/pruning/manager_test.go @@ -1,7 +1,6 @@ package pruning_test import ( - "container/list" "errors" "fmt" "testing" @@ -22,9 +21,6 @@ func TestNewManager(t *testing.T) { manager := pruning.NewManager(db.NewMemDB(), log.NewNopLogger()) require.NotNil(t, manager) - heights, err := manager.GetFlushAndResetPruningHeights() - require.NoError(t, err) - require.NotNil(t, heights) require.Equal(t, types.PruningNothing, manager.GetOptions().GetPruningStrategy()) } @@ -79,12 +75,14 @@ func TestStrategies(t *testing.T) { }, } - manager := pruning.NewManager(db.NewMemDB(), log.NewNopLogger()) - - require.NotNil(t, manager) - for name, tc := range testcases { + tc := tc // Local copy to avoid shadowing. t.Run(name, func(t *testing.T) { + t.Parallel() + + manager := pruning.NewManager(db.NewMemDB(), log.NewNopLogger()) + require.NotNil(t, manager) + curStrategy := tc.strategy manager.SetSnapshotInterval(tc.snapshotInterval) @@ -110,86 +108,82 @@ func TestStrategies(t *testing.T) { require.Equal(t, tc.strategy, manager.GetOptions()) curKeepRecent := curStrategy.KeepRecent - curInterval := curStrategy.Interval + snHeight := int64(tc.snapshotInterval - 1) for curHeight := int64(0); curHeight < 110000; curHeight++ { - handleHeightActual := manager.HandleHeight(curHeight) - shouldPruneAtHeightActual := manager.ShouldPruneAtHeight(curHeight) + if tc.snapshotInterval != 0 { + if curHeight > int64(tc.snapshotInterval) && curHeight%int64(tc.snapshotInterval) == int64(tc.snapshotInterval)-1 { + manager.HandleSnapshotHeight(curHeight - int64(tc.snapshotInterval) + 1) + snHeight = curHeight + } + } - curPruningHeihts, err := manager.GetFlushAndResetPruningHeights() - require.Nil(t, err) + pruningHeightActual := manager.GetPruningHeight(curHeight) curHeightStr := fmt.Sprintf("height: %d", curHeight) switch curStrategy.GetPruningStrategy() { case types.PruningNothing: - require.Equal(t, int64(0), handleHeightActual, curHeightStr) - require.False(t, shouldPruneAtHeightActual, curHeightStr) - - heights, err := manager.GetFlushAndResetPruningHeights() - require.NoError(t, err) - require.Equal(t, 0, len(heights)) + require.Equal(t, int64(0), pruningHeightActual, curHeightStr) default: - if curHeight > int64(curKeepRecent) && (tc.snapshotInterval != 0 && (curHeight-int64(curKeepRecent))%int64(tc.snapshotInterval) != 0 || tc.snapshotInterval == 0) { - expectedHeight := curHeight - int64(curKeepRecent) - require.Equal(t, curHeight-int64(curKeepRecent), handleHeightActual, curHeightStr) - - require.Contains(t, curPruningHeihts, expectedHeight, curHeightStr) + if curHeight > int64(curKeepRecent) && curHeight%int64(curStrategy.Interval) == 0 { + pruningHeightExpected := curHeight - int64(curKeepRecent) - 1 + if tc.snapshotInterval > 0 && snHeight < pruningHeightExpected { + pruningHeightExpected = snHeight + } + require.Equal(t, pruningHeightExpected, pruningHeightActual, curHeightStr) } else { - require.Equal(t, int64(0), handleHeightActual, curHeightStr) - - heights, err := manager.GetFlushAndResetPruningHeights() - require.NoError(t, err) - require.Equal(t, 0, len(heights)) + require.Equal(t, int64(0), pruningHeightActual, curHeightStr) } - require.Equal(t, curHeight%int64(curInterval) == 0, shouldPruneAtHeightActual, curHeightStr) } - heights, err := manager.GetFlushAndResetPruningHeights() - require.NoError(t, err) - require.Equal(t, 0, len(heights)) } }) } } -func TestHandleHeight_Inputs(t *testing.T) { - var keepRecent int64 = int64(types.NewPruningOptions(types.PruningEverything).KeepRecent) +func TestPruningHeight_Inputs(t *testing.T) { + keepRecent := int64(types.NewPruningOptions(types.PruningEverything).KeepRecent) + interval := int64(types.NewPruningOptions(types.PruningEverything).Interval) testcases := map[string]struct { - height int64 - expectedResult int64 - strategy types.PruningStrategy - expectedHeights []int64 + height int64 + expectedResult int64 + strategy types.PruningStrategy }{ - "previousHeight is negative - prune everything - invalid previousHeight": { + "currentHeight is negative - prune everything - invalid currentHeight": { -1, 0, types.PruningEverything, - []int64{}, }, - "previousHeight is zero - prune everything - invalid previousHeight": { + "currentHeight is zero - prune everything - invalid currentHeight": { 0, 0, types.PruningEverything, - []int64{}, }, - "previousHeight is positive but within keep recent- prune everything - not kept": { + "currentHeight is positive but within keep recent- prune everything - not kept": { keepRecent, 0, types.PruningEverything, - []int64{}, }, - "previousHeight is positive and greater than keep recent - kept": { + "currentHeight is positive and equal to keep recent+1 - no kept": { keepRecent + 1, - keepRecent + 1 - keepRecent, + 0, + types.PruningEverything, + }, + "currentHeight is positive and greater than keep recent+1 but not multiple of interval - no kept": { + keepRecent + 2, + 0, + types.PruningEverything, + }, + "currentHeight is positive and greater than keep recent+1 and multiple of interval - kept": { + interval, + interval - keepRecent - 1, types.PruningEverything, - []int64{keepRecent + 1 - keepRecent}, }, "pruning nothing, previousHeight is positive and greater than keep recent - not kept": { keepRecent + 1, 0, types.PruningNothing, - []int64{}, }, } @@ -199,113 +193,8 @@ func TestHandleHeight_Inputs(t *testing.T) { require.NotNil(t, manager) manager.SetOptions(types.NewPruningOptions(tc.strategy)) - handleHeightActual := manager.HandleHeight(tc.height) - require.Equal(t, tc.expectedResult, handleHeightActual) - - actualHeights, err := manager.GetFlushAndResetPruningHeights() - require.NoError(t, err) - require.Equal(t, len(tc.expectedHeights), len(actualHeights)) - require.Equal(t, tc.expectedHeights, actualHeights) - }) - } -} - -func TestHandleHeight_FlushLoadFromDisk(t *testing.T) { - testcases := map[string]struct { - previousHeight int64 - keepRecent uint64 - snapshotInterval uint64 - movedSnapshotHeights []int64 - expectedHandleHeightResult int64 - expectedLoadPruningHeightsResult error - expectedLoadedHeights []int64 - }{ - "simple flush occurs": { - previousHeight: 11, - keepRecent: 10, - snapshotInterval: 0, - movedSnapshotHeights: []int64{}, - expectedHandleHeightResult: 11 - 10, - expectedLoadPruningHeightsResult: nil, - expectedLoadedHeights: []int64{11 - 10}, - }, - "previous height <= keep recent - no update and no flush": { - previousHeight: 9, - keepRecent: 10, - snapshotInterval: 0, - movedSnapshotHeights: []int64{}, - expectedHandleHeightResult: 0, - expectedLoadPruningHeightsResult: nil, - expectedLoadedHeights: []int64{}, - }, - "previous height alligns with snapshot interval - no update and no flush": { - previousHeight: 12, - keepRecent: 10, - snapshotInterval: 2, - movedSnapshotHeights: []int64{}, - expectedHandleHeightResult: 0, - expectedLoadPruningHeightsResult: nil, - expectedLoadedHeights: []int64{}, - }, - "previous height does not align with snapshot interval - flush": { - previousHeight: 12, - keepRecent: 10, - snapshotInterval: 3, - movedSnapshotHeights: []int64{}, - expectedHandleHeightResult: 2, - expectedLoadPruningHeightsResult: nil, - expectedLoadedHeights: []int64{2}, - }, - "moved snapshot heights - flushed": { - previousHeight: 32, - keepRecent: 10, - snapshotInterval: 5, - movedSnapshotHeights: []int64{15, 20, 25}, - expectedHandleHeightResult: 22, - expectedLoadPruningHeightsResult: nil, - expectedLoadedHeights: []int64{15, 20, 22}, - }, - "previous height alligns with snapshot interval - no update but flush snapshot heights": { - previousHeight: 30, - keepRecent: 10, - snapshotInterval: 5, - movedSnapshotHeights: []int64{15, 20, 25}, - expectedHandleHeightResult: 0, - expectedLoadPruningHeightsResult: nil, - expectedLoadedHeights: []int64{15}, - }, - } - - for name, tc := range testcases { - t.Run(name, func(t *testing.T) { - // Setup - db := db.NewMemDB() - manager := pruning.NewManager(db, log.NewNopLogger()) - require.NotNil(t, manager) - - manager.SetSnapshotInterval(tc.snapshotInterval) - manager.SetOptions(types.NewCustomPruningOptions(uint64(tc.keepRecent), uint64(10))) - - for _, snapshotHeight := range tc.movedSnapshotHeights { - manager.HandleHeightSnapshot(snapshotHeight) - } - - // Test HandleHeight and flush - handleHeightActual := manager.HandleHeight(tc.previousHeight) - require.Equal(t, tc.expectedHandleHeightResult, handleHeightActual) - - loadedPruneHeights, err := pruning.LoadPruningHeights(db) - require.NoError(t, err) - require.Equal(t, len(loadedPruneHeights), len(loadedPruneHeights)) - - // Test load back - err = manager.LoadPruningHeights(db) - require.NoError(t, err) - - heights, err := manager.GetFlushAndResetPruningHeights() - require.NoError(t, err) - require.Equal(t, len(tc.expectedLoadedHeights), len(heights)) - require.ElementsMatch(t, tc.expectedLoadedHeights, heights) + pruningHeightActual := manager.GetPruningHeight(tc.height) + require.Equal(t, tc.expectedResult, pruningHeightActual) }) } } @@ -328,11 +217,11 @@ func TestHandleHeight_DbErr_Panic(t *testing.T) { } }() - manager.HandleHeight(10) + manager.HandleSnapshotHeight(10) } -func TestHandleHeightSnapshot_FlushLoadFromDisk(t *testing.T) { - loadedHeightsMirror := []int64{} +func TestHandleSnapshotHeight_LoadFromDisk(t *testing.T) { + snapshotInterval := uint64(10) // Setup db := db.NewMemDB() @@ -341,96 +230,29 @@ func TestHandleHeightSnapshot_FlushLoadFromDisk(t *testing.T) { manager.SetOptions(types.NewPruningOptions(types.PruningEverything)) + manager.SetSnapshotInterval(snapshotInterval) + + expected := 0 + for snapshotHeight := int64(-1); snapshotHeight < 100; snapshotHeight++ { - // Test flush - manager.HandleHeightSnapshot(snapshotHeight) + snapshotHeightStr := fmt.Sprintf("snaphost height: %d", snapshotHeight) + if snapshotHeight > int64(snapshotInterval) && snapshotHeight%int64(snapshotInterval) == 1 { - // Post test - if snapshotHeight > 0 { - loadedHeightsMirror = append(loadedHeightsMirror, snapshotHeight) + // Test flush + manager.HandleSnapshotHeight(snapshotHeight - 1) + expected = 1 } - loadedSnapshotHeights, err := pruning.LoadPruningSnapshotHeights(db) require.NoError(t, err) - require.Equal(t, len(loadedHeightsMirror), loadedSnapshotHeights.Len()) + require.Equal(t, expected, len(loadedSnapshotHeights), snapshotHeightStr) // Test load back - err = manager.LoadPruningHeights(db) + err = manager.LoadSnapshotHeights(db) require.NoError(t, err) loadedSnapshotHeights, err = pruning.LoadPruningSnapshotHeights(db) require.NoError(t, err) - require.Equal(t, len(loadedHeightsMirror), loadedSnapshotHeights.Len()) - } -} - -func TestHandleHeightSnapshot_DbErr_Panic(t *testing.T) { - ctrl := gomock.NewController(t) - - // Setup - dbMock := mock.NewMockDB(ctrl) - - dbMock.EXPECT().SetSync(gomock.Any(), gomock.Any()).Return(errors.New(dbErr)).Times(1) - - manager := pruning.NewManager(dbMock, log.NewNopLogger()) - manager.SetOptions(types.NewPruningOptions(types.PruningEverything)) - require.NotNil(t, manager) - - defer func() { - if r := recover(); r == nil { - t.Fail() - } - }() - - manager.HandleHeightSnapshot(10) -} - -func TestFlushLoad(t *testing.T) { - db := db.NewMemDB() - manager := pruning.NewManager(db, log.NewNopLogger()) - require.NotNil(t, manager) - - curStrategy := types.NewCustomPruningOptions(100, 15) - - snapshotInterval := uint64(10) - manager.SetSnapshotInterval(snapshotInterval) - - manager.SetOptions(curStrategy) - require.Equal(t, curStrategy, manager.GetOptions()) - - keepRecent := curStrategy.KeepRecent - - heightsToPruneMirror := make([]int64, 0) - - for curHeight := int64(0); curHeight < 1000; curHeight++ { - handleHeightActual := manager.HandleHeight(curHeight) - - curHeightStr := fmt.Sprintf("height: %d", curHeight) - - if curHeight > int64(keepRecent) && (snapshotInterval != 0 && (curHeight-int64(keepRecent))%int64(snapshotInterval) != 0 || snapshotInterval == 0) { - expectedHandleHeight := curHeight - int64(keepRecent) - require.Equal(t, expectedHandleHeight, handleHeightActual, curHeightStr) - heightsToPruneMirror = append(heightsToPruneMirror, expectedHandleHeight) - } else { - require.Equal(t, int64(0), handleHeightActual, curHeightStr) - } - - if manager.ShouldPruneAtHeight(curHeight) && curHeight > int64(keepRecent) { - actualHeights, err := manager.GetFlushAndResetPruningHeights() - require.NoError(t, err) - require.Equal(t, len(heightsToPruneMirror), len(actualHeights)) - require.Equal(t, heightsToPruneMirror, actualHeights) - - err = manager.LoadPruningHeights(db) - require.NoError(t, err) - - actualHeights, err = manager.GetFlushAndResetPruningHeights() - require.NoError(t, err) - require.Equal(t, len(heightsToPruneMirror), len(actualHeights)) - require.Equal(t, heightsToPruneMirror, actualHeights) - - heightsToPruneMirror = make([]int64, 0) - } + require.Equal(t, expected, len(loadedSnapshotHeights), snapshotHeightStr) } } @@ -445,43 +267,18 @@ func TestLoadPruningHeights(t *testing.T) { manager.SetOptions(types.NewPruningOptions(types.PruningDefault)) testcases := map[string]struct { - flushedPruningHeights []int64 - getFlushedPruningSnapshotHeights func() *list.List + getFlushedPruningSnapshotHeights func() []int64 expectedResult error }{ - "negative pruningHeight - error": { - flushedPruningHeights: []int64{10, 0, -1}, - expectedResult: &pruning.NegativeHeightsError{Height: -1}, - }, "negative snapshotPruningHeight - error": { - getFlushedPruningSnapshotHeights: func() *list.List { - l := list.New() - l.PushBack(int64(5)) - l.PushBack(int64(-2)) - l.PushBack(int64(3)) - return l + getFlushedPruningSnapshotHeights: func() []int64 { + return []int64{5, -2, 3} }, expectedResult: &pruning.NegativeHeightsError{Height: -2}, }, - "both have negative - pruningHeight error": { - flushedPruningHeights: []int64{10, 0, -1}, - getFlushedPruningSnapshotHeights: func() *list.List { - l := list.New() - l.PushBack(int64(5)) - l.PushBack(int64(-2)) - l.PushBack(int64(3)) - return l - }, - expectedResult: &pruning.NegativeHeightsError{Height: -1}, - }, - "both non-negative - success": { - flushedPruningHeights: []int64{10, 0, 3}, - getFlushedPruningSnapshotHeights: func() *list.List { - l := list.New() - l.PushBack(int64(5)) - l.PushBack(int64(0)) - l.PushBack(int64(3)) - return l + "non-negative - success": { + getFlushedPruningSnapshotHeights: func() []int64 { + return []int64{5, 0, 3} }, }, } @@ -489,44 +286,23 @@ func TestLoadPruningHeights(t *testing.T) { for name, tc := range testcases { t.Run(name, func(t *testing.T) { db := db.NewMemDB() - if tc.flushedPruningHeights != nil { - err = db.Set(pruning.PruneHeightsKey, pruning.Int64SliceToBytes(tc.flushedPruningHeights)) - require.NoError(t, err) - } if tc.getFlushedPruningSnapshotHeights != nil { - err = db.Set(pruning.PruneSnapshotHeightsKey, pruning.ListToBytes(tc.getFlushedPruningSnapshotHeights())) + err = db.Set(pruning.PruneSnapshotHeightsKey, pruning.Int64SliceToBytes(tc.getFlushedPruningSnapshotHeights())) require.NoError(t, err) } - err = manager.LoadPruningHeights(db) + err = manager.LoadSnapshotHeights(db) require.Equal(t, tc.expectedResult, err) }) } } -func TestLoadPruningHeights_PruneNothing(t *testing.T) { +func TestLoadSnapshotHeights_PruneNothing(t *testing.T) { manager := pruning.NewManager(db.NewMemDB(), log.NewNopLogger()) require.NotNil(t, manager) manager.SetOptions(types.NewPruningOptions(types.PruningNothing)) - require.Nil(t, manager.LoadPruningHeights(db.NewMemDB())) -} - -func TestGetFlushAndResetPruningHeights_DbErr_Panic(t *testing.T) { - ctrl := gomock.NewController(t) - - // Setup - dbMock := mock.NewMockDB(ctrl) - - dbMock.EXPECT().SetSync(gomock.Any(), gomock.Any()).Return(errors.New(dbErr)).Times(1) - - manager := pruning.NewManager(dbMock, log.NewNopLogger()) - manager.SetOptions(types.NewPruningOptions(types.PruningEverything)) - require.NotNil(t, manager) - - heights, err := manager.GetFlushAndResetPruningHeights() - require.Error(t, err) - require.Nil(t, heights) + require.Nil(t, manager.LoadSnapshotHeights(db.NewMemDB())) } diff --git a/store/rootmulti/store.go b/store/rootmulti/store.go index bebd6cd1af9a..d93351d7526e 100644 --- a/store/rootmulti/store.go +++ b/store/rootmulti/store.go @@ -288,7 +288,7 @@ func (rs *Store) loadVersion(ver int64, upgrades *types.StoreUpgrades) error { rs.stores = newStores // load any pruned heights we missed from disk to be pruned on the next run - if err := rs.pruningManager.LoadPruningHeights(rs.db); err != nil { + if err := rs.pruningManager.LoadSnapshotHeights(rs.db); err != nil { return err } @@ -339,7 +339,7 @@ func moveKVStoreData(oldDB types.KVStore, newDB types.KVStore) error { // If other strategy, this height is persisted until it is // less than - KeepRecent and % Interval == 0 func (rs *Store) PruneSnapshotHeight(height int64) { - rs.pruningManager.HandleHeightSnapshot(height) + rs.pruningManager.HandleSnapshotHeight(height) } // SetInterBlockCache sets the Store's internal inter-block (persistent) cache. @@ -594,38 +594,19 @@ func (rs *Store) GetKVStore(key types.StoreKey) types.KVStore { } func (rs *Store) handlePruning(version int64) error { - rs.pruningManager.HandleHeight(version - 1) // we should never prune the current version. - if !rs.pruningManager.ShouldPruneAtHeight(version) { - return nil - } - rs.logger.Info("prune start", "height", version) + pruneHeight := rs.pruningManager.GetPruningHeight(version) defer rs.logger.Info("prune end", "height", version) - return rs.PruneStores(true, nil) + return rs.PruneStores(pruneHeight) } -// PruneStores prunes the specific heights of the multi store. -// If clearPruningManager is true, the pruning manager will return the pruning heights, -// and they are appended to the pruningHeights to be pruned. -func (rs *Store) PruneStores(clearPruningManager bool, pruningHeights []int64) (err error) { - if clearPruningManager { - heights, err := rs.pruningManager.GetFlushAndResetPruningHeights() - if err != nil { - return err - } - - if len(heights) == 0 { - rs.logger.Debug("no heights to be pruned from pruning manager") - } - - pruningHeights = append(pruningHeights, heights...) - } - - if len(pruningHeights) == 0 { - rs.logger.Debug("no heights need to be pruned") +// PruneStores prunes all history up to the specific height of the multi store. +func (rs *Store) PruneStores(pruningHeight int64) (err error) { + if pruningHeight <= 0 { + rs.logger.Debug("pruning skipped, height is less than or equal to 0") return nil } - rs.logger.Debug("pruning store", "heights", pruningHeights) + rs.logger.Debug("pruning store", "height", pruningHeight) for key, store := range rs.stores { rs.logger.Debug("pruning store", "key", key) // Also log store.name (a private variable)? @@ -638,7 +619,7 @@ func (rs *Store) PruneStores(clearPruningManager bool, pruningHeights []int64) ( store = rs.GetCommitKVStore(key) - err := store.(*iavl.Store).DeleteVersions(pruningHeights...) + err := store.(*iavl.Store).DeleteVersionsTo(pruningHeight) if err == nil { continue } @@ -1022,12 +1003,7 @@ func (rs *Store) RollbackToVersion(target int64) error { // If the store is wrapped with an inter-block cache, we must first unwrap // it to get the underlying IAVL store. store = rs.GetCommitKVStore(key) - var err error - if rs.lazyLoading { - _, err = store.(*iavl.Store).LazyLoadVersionForOverwriting(target) - } else { - _, err = store.(*iavl.Store).LoadVersionForOverwriting(target) - } + _, err := store.(*iavl.Store).LoadVersionForOverwriting(target) if err != nil { return err } diff --git a/store/rootmulti/store_test.go b/store/rootmulti/store_test.go index 41ee371b2b00..242a3ce5464e 100644 --- a/store/rootmulti/store_test.go +++ b/store/rootmulti/store_test.go @@ -562,12 +562,8 @@ func TestMultiStore_Pruning_SameHeightsTwice(t *testing.T) { err := ms.LoadVersion(numVersions - 1) require.NoError(t, err) - // Ensure already pruned heights were loaded - heights, err := ms.pruningManager.GetFlushAndResetPruningHeights() - require.NoError(t, err) - require.Equal(t, expectedHeights, heights) - - require.NoError(t, ms.pruningManager.LoadPruningHeights(db)) + // Ensure already pruned snapshot heights were loaded + require.NoError(t, ms.pruningManager.LoadSnapshotHeights(db)) // Test pruning the same heights again lastCommitInfo = ms.Commit() @@ -581,7 +577,6 @@ func TestMultiStore_Pruning_SameHeightsTwice(t *testing.T) { func TestMultiStore_PruningRestart(t *testing.T) { db := dbm.NewMemDB() ms := newMultiStoreWithMounts(db, pruningtypes.NewCustomPruningOptions(2, 11)) - ms.SetSnapshotInterval(3) require.NoError(t, ms.LoadLatestVersion()) // Commit enough to build up heights to prune, where on the next block we should @@ -590,37 +585,26 @@ func TestMultiStore_PruningRestart(t *testing.T) { ms.Commit() } - pruneHeights := []int64{1, 2, 4, 5, 7} - - // ensure we've persisted the current batch of heights to prune to the store's DB - err := ms.pruningManager.LoadPruningHeights(ms.db) - require.NoError(t, err) - - actualHeightsToPrune, err := ms.pruningManager.GetFlushAndResetPruningHeights() - require.NoError(t, err) - require.Equal(t, len(pruneHeights), len(actualHeightsToPrune)) - require.Equal(t, pruneHeights, actualHeightsToPrune) + actualHeightToPrune := ms.pruningManager.GetPruningHeight(ms.LatestVersion()) + require.Equal(t, int64(0), actualHeightToPrune) // "restart" ms = newMultiStoreWithMounts(db, pruningtypes.NewCustomPruningOptions(2, 11)) - ms.SetSnapshotInterval(3) - err = ms.LoadLatestVersion() + err := ms.LoadLatestVersion() require.NoError(t, err) - actualHeightsToPrune, err = ms.pruningManager.GetFlushAndResetPruningHeights() - require.NoError(t, err) - require.Equal(t, pruneHeights, actualHeightsToPrune) + actualHeightToPrune = ms.pruningManager.GetPruningHeight(ms.LatestVersion()) + require.Equal(t, int64(0), actualHeightToPrune) // commit one more block and ensure the heights have been pruned ms.Commit() - actualHeightsToPrune, err = ms.pruningManager.GetFlushAndResetPruningHeights() - require.NoError(t, err) - require.Empty(t, actualHeightsToPrune) + actualHeightToPrune = ms.pruningManager.GetPruningHeight(ms.LatestVersion()) + require.Equal(t, int64(8), actualHeightToPrune) - for _, v := range pruneHeights { + for v := int64(1); v <= actualHeightToPrune; v++ { _, err := ms.CacheMultiStoreWithVersion(v) - require.NoError(t, err, "expected error when loading height: %d", v) + require.Error(t, err, "expected error when loading height: %d", v) } } diff --git a/store/wrapper/ics23.go b/store/wrapper/ics23.go new file mode 100644 index 000000000000..760982d365d2 --- /dev/null +++ b/store/wrapper/ics23.go @@ -0,0 +1,14 @@ +package wrapper + +import ( + ics23 "github.com/confio/ics23/go" + cics23 "github.com/cosmos/ics23/go" + "github.com/golang/protobuf/proto" +) + +func ConvertCommitmentProof(proof *cics23.CommitmentProof) *ics23.CommitmentProof { + msg, _ := proto.Marshal(proof) + var newProof ics23.CommitmentProof + proto.Unmarshal(msg, &newProof) + return &newProof +} diff --git a/store/wrapper/tmdb.go b/store/wrapper/tmdb.go new file mode 100644 index 000000000000..ac1711d1f895 --- /dev/null +++ b/store/wrapper/tmdb.go @@ -0,0 +1,100 @@ +package wrapper + +import ( + tdbm "github.com/cometbft/cometbft-db" + cdbm "github.com/cosmos/cosmos-db" +) + +type DBWrapper struct { + db tdbm.DB +} + +func NewCosmosDB(db tdbm.DB) cdbm.DB { + return &DBWrapper{db: db} +} + +func (db *DBWrapper) Get(key []byte) ([]byte, error) { + return db.db.Get(key) +} + +func (db *DBWrapper) Has(key []byte) (bool, error) { + return db.db.Has(key) +} + +func (db *DBWrapper) Set(key []byte, value []byte) error { + return db.db.Set(key, value) +} + +func (db *DBWrapper) SetSync(key []byte, value []byte) error { + return db.db.SetSync(key, value) +} + +func (db *DBWrapper) Delete(key []byte) error { + return db.db.Delete(key) +} + +func (db *DBWrapper) DeleteSync(key []byte) error { + return db.db.DeleteSync(key) +} + +func (db *DBWrapper) Iterator(start, end []byte) (cdbm.Iterator, error) { + it, err := db.db.Iterator(start, end) + return it.(cdbm.Iterator), err +} + +func (db *DBWrapper) ReverseIterator(start, end []byte) (cdbm.Iterator, error) { + it, err := db.db.ReverseIterator(start, end) + return it.(cdbm.Iterator), err +} + +func (db *DBWrapper) NewBatch() cdbm.Batch { + return NewCosmosBatch(db.db.NewBatch()) +} + +func (db *DBWrapper) NewBatchWithSize(size int) cdbm.Batch { + return NewCosmosBatch(db.db.NewBatch()) +} + +func (db *DBWrapper) Print() error { + return db.db.Print() +} + +func (db *DBWrapper) Stats() map[string]string { + return db.db.Stats() +} + +func (db *DBWrapper) Close() error { + return db.db.Close() +} + +type BatchWrapper struct { + batch tdbm.Batch +} + +func NewCosmosBatch(batch tdbm.Batch) cdbm.Batch { + return &BatchWrapper{batch: batch} +} + +func (b *BatchWrapper) Set(key, value []byte) error { + return b.batch.Set(key, value) +} + +func (b *BatchWrapper) Delete(key []byte) error { + return b.batch.Delete(key) +} + +func (b *BatchWrapper) Write() error { + return b.batch.Write() +} + +func (b *BatchWrapper) WriteSync() error { + return b.batch.WriteSync() +} + +func (b *BatchWrapper) Close() error { + return b.batch.Close() +} + +func (b *BatchWrapper) GetByteSize() (int, error) { + return 0, nil +}