diff --git a/client/pruning/main.go b/client/pruning/main.go index 1359a4c1086a..247cd2c360c9 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(pruningHeights[len(pruningHeights)-1]); err != nil { + if err = rootMultiStore.PruneStores(false, pruningHeights); 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 22eb8500ee25..6fddc5ad636c 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,4 @@ -go 1.21 - -toolchain go1.21.6 +go 1.19 module github.com/cosmos/cosmos-sdk @@ -20,17 +18,15 @@ 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.9.1 + github.com/cometbft/cometbft-db v0.7.0 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.4 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 v1.0.0 - github.com/cosmos/ics23/go v0.10.0 + github.com/cosmos/iavl v0.20.1 github.com/cosmos/ledger-cosmos-go v0.13.1 github.com/golang/mock v1.6.0 github.com/golang/protobuf v1.5.3 @@ -53,7 +49,7 @@ require ( github.com/prometheus/common v0.42.0 github.com/rakyll/statik v0.1.7 github.com/rs/zerolog v1.32.0 - github.com/spf13/cast v1.5.1 + github.com/spf13/cast v1.5.0 github.com/spf13/cobra v1.6.1 github.com/spf13/pflag v1.0.5 github.com/spf13/viper v1.14.0 @@ -80,7 +76,6 @@ 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 @@ -89,7 +84,6 @@ 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/rosetta-sdk-go v0.10.0 // indirect @@ -103,7 +97,6 @@ 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.6.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 @@ -142,7 +135,6 @@ 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 @@ -152,6 +144,7 @@ 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 @@ -166,10 +159,11 @@ 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.8 // indirect + go.etcd.io/bbolt v1.3.7 // indirect go.opencensus.io v0.24.0 // indirect go.opentelemetry.io/otel v1.19.0 // indirect go.opentelemetry.io/otel/metric v1.19.0 // indirect @@ -192,9 +186,6 @@ 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 @@ -210,6 +201,8 @@ replace ( ) retract ( + // Incorrectly used IAVL v1 in IAVL v0 branch + v0.47.10-kava.2 // revert fix https://github.com/cosmos/cosmos-sdk/pull/16331 v0.46.12 // subject to a bug in the group module and gov module migration diff --git a/go.sum b/go.sum index 94be73b8973e..be7392fc6aad 100644 --- a/go.sum +++ b/go.sum @@ -206,18 +206,13 @@ 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/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= @@ -225,7 +220,6 @@ 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= @@ -260,9 +254,7 @@ 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= @@ -309,23 +301,22 @@ 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= @@ -334,8 +325,6 @@ 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.4 h1:aEL7tU/rLOmxZQ9z4i7mzxcLbSCY48OdY7lIWTLG7oU= github.com/cosmos/cosmos-proto v1.0.0-beta.4/go.mod h1:oeB+FyVzG3XrQJbJng0EnV8Vljfk9XvTIpGILNU/9Co= github.com/cosmos/cosmos-sdk/db v1.0.0-beta.1.0.20220726092710-f848e4300a8a h1:2humuGPw3O5riJVFq/E2FRjF57UrO97W1qJcGVmK+6k= @@ -348,10 +337,8 @@ 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 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/iavl v0.20.1 h1:rM1kqeG3/HBT85vsZdoSNsehciqUQPWrR4BYmqE2+zg= +github.com/cosmos/iavl v0.20.1/go.mod h1:WO7FyvaZJoH65+HFOsDir7xU9FWk2w9cHXNW1XHcl7A= 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= @@ -371,7 +358,6 @@ 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= @@ -385,9 +371,7 @@ 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= @@ -398,8 +382,6 @@ 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= @@ -411,16 +393,17 @@ github.com/envoyproxy/go-control-plane v0.9.9-0.20210512163311-63b5d3c536b0/go.m github.com/envoyproxy/go-control-plane v0.9.10-0.20210907150352-cf90f659a021/go.mod h1:AFq3mo9L8Lqqiid3OhADV3RfLJnjiw63cSpi+fDTRC0= 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/stack v0.0.0-20160209184415-751773369052 h1:JWuenKqqX8nojtoVVWjGfOF9635RETekkoH6Cc9SX0A= +github.com/facebookgo/subset v0.0.0-20200203212716-c811ad88dec4 h1:7HZCaLC5+BZpmbhCOZJ293Lz68O7PYrF2EzeiFMwCLk= 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.4 h1:g2rn0vABPOOXmZUj+vbmUp0lPoXEMuhTpIluN0XL9UY= -github.com/frankban/quicktest v1.14.4/go.mod h1:4ptaffx2x8+WTWXmUCuVU6aPUX1/Mz7zb5vbUoiM6w0= +github.com/frankban/quicktest v1.14.3 h1:FJKSZTDHjyhriyC81FLQ0LY93eSai0ZyR/ZIkd3ZUKE= 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= @@ -433,7 +416,6 @@ 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-kit/kit v0.8.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as= github.com/go-kit/kit v0.9.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as= github.com/go-kit/kit v0.10.0/go.mod h1:xUsJbQ/Fp4kEt7AFgCuvyX4a71u8h9jB8tj/ORgOZ7o= @@ -556,7 +538,6 @@ 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= @@ -703,10 +684,6 @@ 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= @@ -740,8 +717,6 @@ 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= @@ -814,19 +789,15 @@ 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.26.0 h1:03cDLK28U6hWvCAns6NeydX3zIm4SF3ci69ulidS32Q= -github.com/onsi/gomega v1.26.0/go.mod h1:r+zV744Re+DiYCIPRlYOTxn0YkOLcAnW8k1xXdMPGhM= +github.com/onsi/gomega v1.20.0 h1:8W0cWlwFkflGPLltQvLRB7ZVD5HuP6ng320w2IS245Q= +github.com/onsi/gomega v1.20.0/go.mod h1:DtrZpjmvpn2mPm4YWQa0/ALMDj9v4YxLgojwPeREyVo= 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= @@ -836,7 +807,6 @@ 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= @@ -855,7 +825,6 @@ 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= @@ -931,7 +900,6 @@ 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= @@ -943,8 +911,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.1 h1:R+kOtfhWQE6TVQzY+4D7wJLBgkdVasCEFxSUBYBYIlA= -github.com/spf13/cast v1.5.1/go.mod h1:b9PdjNptOpzXr7Rq1q9gJML/2cdGQAo69NKzQ10KN48= +github.com/spf13/cast v1.5.0 h1:rj3WzYc11XZaIZMPKmwP96zkFEnnAmV8s6XbB2aY32w= +github.com/spf13/cast v1.5.0/go.mod h1:SpXXQ5YoyJw6s3/6cMTQuxvgRl3PCJiyaX9p6b155UU= 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= @@ -982,6 +950,8 @@ 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/tidwall/btree v1.6.0 h1:LDZfKfQIBHGHWSwckhXI0RPSXzlo+KYdjK7FWSqOzzg= @@ -1011,8 +981,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.8 h1:xs88BrvEv273UsB79e0hcVrlUWmS0a8upikMFhSyAtA= -go.etcd.io/bbolt v1.3.8/go.mod h1:N9Mkw9X8x5fupy0IKsmuqVtoGDyxsaDlbk4Rd05IAQw= +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/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= @@ -1030,7 +1000,6 @@ go.opentelemetry.io/otel v1.19.0/go.mod h1:i0QyjOq3UPoTzff0PJB2N66fb4S0+rSbSB15/ go.opentelemetry.io/otel/metric v1.19.0 h1:aTzpGtV0ar9wlV4Sna9sdJyII5jTVJEvKETPiOKwvpE= go.opentelemetry.io/otel/metric v1.19.0/go.mod h1:L5rUsV9kM1IxCj1MmSdS+JQAcVm319EUrDVLrt7jqt8= go.opentelemetry.io/otel/sdk v1.19.0 h1:6USY6zH+L8uMH8L3t1enZPR3WFEmSTADlqldyHtJi3o= -go.opentelemetry.io/otel/sdk v1.19.0/go.mod h1:NedEbbS4w3C6zElbLdPJKOpJQOrGUJ+GfzpjUvI0v1A= go.opentelemetry.io/otel/trace v1.19.0 h1:DFVQmlVbfVeOuBRrwdtaehRrWiL1JoVs9CPIQ1Dzxpg= go.opentelemetry.io/otel/trace v1.19.0/go.mod h1:mfaSyvGyEJEI0nyV2I4qhNQnbBOUUmYZpYojqMnX2vo= go.opentelemetry.io/proto/otlp v0.7.0/go.mod h1:PqfVotwruBrMGOCsRd/89rSnXhoiJIqeYNgFYFoEGnI= @@ -1379,7 +1348,6 @@ 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.2.0/go.mod h1:y4OqIKeOV/fWJetJ8bXPU1sEVniLMIyDAZWeHdV+NTA= 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= diff --git a/store/cache/cache_test.go b/store/cache/cache_test.go index 790c8cd01abb..c9d4f1e8f7b9 100644 --- a/store/cache/cache_test.go +++ b/store/cache/cache_test.go @@ -4,7 +4,6 @@ import ( "fmt" "testing" - "cosmossdk.io/log" dbm "github.com/cometbft/cometbft-db" "github.com/cosmos/iavl" "github.com/stretchr/testify/require" @@ -13,15 +12,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 := wrapper.NewCosmosDB(dbm.NewMemDB()) + db := dbm.NewMemDB() mngr := cache.NewCommitKVStoreCacheManager(cache.DefaultCommitKVStoreCacheSize) sKey := types.NewKVStoreKey("test") - tree := iavl.NewMutableTree(db, 100, false, log.NewNopLogger()) + tree, err := iavl.NewMutableTree(db, 100, false) + require.NoError(t, err) store := iavlstore.UnsafeNewStore(tree) store2 := mngr.GetStoreCache(sKey, store) @@ -30,11 +29,12 @@ func TestGetOrSetStoreCache(t *testing.T) { } func TestUnwrap(t *testing.T) { - db := wrapper.NewCosmosDB(dbm.NewMemDB()) + db := dbm.NewMemDB() mngr := cache.NewCommitKVStoreCacheManager(cache.DefaultCommitKVStoreCacheSize) sKey := types.NewKVStoreKey("test") - tree := iavl.NewMutableTree(db, 100, false, log.NewNopLogger()) + tree, err := iavl.NewMutableTree(db, 100, false) + require.NoError(t, err) store := iavlstore.UnsafeNewStore(tree) _ = mngr.GetStoreCache(sKey, store) @@ -43,11 +43,12 @@ func TestUnwrap(t *testing.T) { } func TestStoreCache(t *testing.T) { - db := wrapper.NewCosmosDB(dbm.NewMemDB()) + db := dbm.NewMemDB() mngr := cache.NewCommitKVStoreCacheManager(cache.DefaultCommitKVStoreCacheSize) sKey := types.NewKVStoreKey("test") - tree := iavl.NewMutableTree(db, 100, false, log.NewNopLogger()) + tree, err := iavl.NewMutableTree(db, 100, false) + require.NoError(t, err) store := iavlstore.UnsafeNewStore(tree) kvStore := mngr.GetStoreCache(sKey, store) @@ -69,11 +70,12 @@ func TestStoreCache(t *testing.T) { } func TestReset(t *testing.T) { - db := wrapper.NewCosmosDB(dbm.NewMemDB()) + db := dbm.NewMemDB() mngr := cache.NewCommitKVStoreCacheManager(cache.DefaultCommitKVStoreCacheSize) sKey := types.NewKVStoreKey("test") - tree := iavl.NewMutableTree(db, 100, false, log.NewNopLogger()) + tree, err := iavl.NewMutableTree(db, 100, false) + require.NoError(t, err) store := iavlstore.UnsafeNewStore(tree) store2 := mngr.GetStoreCache(sKey, store) @@ -89,11 +91,12 @@ func TestReset(t *testing.T) { } func TestCacheWrap(t *testing.T) { - db := wrapper.NewCosmosDB(dbm.NewMemDB()) + db := dbm.NewMemDB() mngr := cache.NewCommitKVStoreCacheManager(cache.DefaultCommitKVStoreCacheSize) sKey := types.NewKVStoreKey("test") - tree := iavl.NewMutableTree(db, 100, false, log.NewNopLogger()) + tree, err := iavl.NewMutableTree(db, 100, false) + require.NoError(t, err) store := iavlstore.UnsafeNewStore(tree) cacheWrapper := mngr.GetStoreCache(sKey, store).CacheWrap() diff --git a/store/iavl/store.go b/store/iavl/store.go index 52c95cef1c80..28e7f68df7d1 100644 --- a/store/iavl/store.go +++ b/store/iavl/store.go @@ -6,7 +6,6 @@ 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" @@ -18,7 +17,6 @@ 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" @@ -54,7 +52,10 @@ 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 := iavl.NewMutableTree(wrapper.NewCosmosDB(db), cacheSize, disableFastNode, clog.NewNopLogger(), iavl.InitialVersionOption(initialVersion)) + tree, err := iavl.NewMutableTreeWithOpts(db, cacheSize, &iavl.Options{InitialVersion: initialVersion}, disableFastNode) + if err != nil { + return nil, err + } isUpgradeable, err := tree.IsUpgradeable() if err != nil { @@ -71,7 +72,11 @@ func LoadStoreWithInitialVersion(db dbm.DB, logger log.Logger, key types.StoreKe ) } - _, err = tree.LoadVersion(id.Version) + if lazyLoading { + _, err = tree.LazyLoadVersion(id.Version) + } else { + _, err = tree.LoadVersion(id.Version) + } if err != nil { return nil, err @@ -82,7 +87,7 @@ func LoadStoreWithInitialVersion(db dbm.DB, logger log.Logger, key types.StoreKe } return &Store{ - tree: &mutableTree{tree}, + tree: tree, logger: logger, }, nil } @@ -95,7 +100,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: &mutableTree{tree}, + tree: tree, } } @@ -137,7 +142,10 @@ func (st *Store) Commit() types.CommitID { // LastCommitID implements Committer. func (st *Store) LastCommitID() types.CommitID { - hash := st.tree.Hash() + hash, err := st.tree.Hash() + if err != nil { + panic(err) + } return types.CommitID{ Version: st.tree.Version(), @@ -220,17 +228,22 @@ func (st *Store) Delete(key []byte) { } } -// DeleteVersionsTo deletes versions upto the given version from the MutableTree. An error +// DeleteVersions deletes a series of versions 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) DeleteVersionsTo(version int64) error { - return st.tree.DeleteVersionsTo(version) +func (st *Store) DeleteVersions(versions ...int64) error { + return st.tree.DeleteVersions(versions...) } // 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 targetVersion, st.tree.LoadVersionForOverwriting(targetVersion) + 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) } // Implements types.KVStore. @@ -272,7 +285,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.(*mutableTree) + tree, ok := st.tree.(*iavl.MutableTree) if !ok { return nil, errors.New("iavl import failed: unable to find mutable tree") } @@ -382,24 +395,23 @@ 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 - tempCommitmentProof, err := tree.GetMembershipProof(key) + commitmentProof, 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 - tempCommitmentProof, err := tree.GetNonMembershipProof(key) + commitmentProof, 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 018b42bada0b..f73c86197c07 100644 --- a/store/iavl/store_test.go +++ b/store/iavl/store_test.go @@ -5,13 +5,11 @@ 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" - cmlog "github.com/cometbft/cometbft/libs/log" + "github.com/cometbft/cometbft/libs/log" "github.com/cosmos/iavl" "github.com/stretchr/testify/require" @@ -36,8 +34,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) { - dbt := wrapper.NewCosmosDB(db) - tree := iavl.NewMutableTree(dbt, cacheSize, false, log.NewNopLogger()) + tree, err := iavl.NewMutableTree(db, cacheSize, false) + require.NoError(t, err) for k, v := range treeData { tree.Set([]byte(k), []byte(v)) @@ -102,17 +100,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, cmlog.NewNopLogger(), types.NewKVStoreKey("test"), cIDH, false, DefaultIAVLCacheSize, false) + newHStore, err := LoadStore(db, log.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, cmlog.NewNopLogger(), types.NewKVStoreKey("test"), cIDHp, false, DefaultIAVLCacheSize, false) + newHpStore, err := LoadStore(db, log.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, cmlog.NewNopLogger(), types.NewKVStoreKey("test"), cIDHc, false, DefaultIAVLCacheSize, false) + newHcStore, err := LoadStore(db, log.NewNopLogger(), types.NewKVStoreKey("test"), cIDHc, false, DefaultIAVLCacheSize, false) require.NoError(t, err) require.Equal(t, string(newHcStore.Get([]byte("hello"))), "ciao") } @@ -282,8 +280,10 @@ func TestIAVLIterator(t *testing.T) { } func TestIAVLReverseIterator(t *testing.T) { - db := wrapper.NewCosmosDB(dbm.NewMemDB()) - tree := iavl.NewMutableTree(db, cacheSize, false, log.NewNopLogger()) + db := dbm.NewMemDB() + + tree, err := iavl.NewMutableTree(db, cacheSize, false) + require.NoError(t, err) iavlStore := UnsafeNewStore(tree) @@ -314,8 +314,9 @@ func TestIAVLReverseIterator(t *testing.T) { } func TestIAVLPrefixIterator(t *testing.T) { - db := wrapper.NewCosmosDB(dbm.NewMemDB()) - tree := iavl.NewMutableTree(db, cacheSize, false, log.NewNopLogger()) + db := dbm.NewMemDB() + tree, err := iavl.NewMutableTree(db, cacheSize, false) + require.NoError(t, err) iavlStore := UnsafeNewStore(tree) @@ -377,8 +378,9 @@ func TestIAVLPrefixIterator(t *testing.T) { } func TestIAVLReversePrefixIterator(t *testing.T) { - db := wrapper.NewCosmosDB(dbm.NewMemDB()) - tree := iavl.NewMutableTree(db, cacheSize, false, log.NewNopLogger()) + db := dbm.NewMemDB() + tree, err := iavl.NewMutableTree(db, cacheSize, false) + require.NoError(t, err) iavlStore := UnsafeNewStore(tree) @@ -444,8 +446,9 @@ func nextVersion(iavl *Store) { } func TestIAVLNoPrune(t *testing.T) { - db := wrapper.NewCosmosDB(dbm.NewMemDB()) - tree := iavl.NewMutableTree(db, cacheSize, false, log.NewNopLogger()) + db := dbm.NewMemDB() + tree, err := iavl.NewMutableTree(db, cacheSize, false) + require.NoError(t, err) iavlStore := UnsafeNewStore(tree) nextVersion(iavlStore) @@ -462,8 +465,9 @@ func TestIAVLNoPrune(t *testing.T) { } func TestIAVLStoreQuery(t *testing.T) { - db := wrapper.NewCosmosDB(dbm.NewMemDB()) - tree := iavl.NewMutableTree(db, cacheSize, false, log.NewNopLogger()) + db := dbm.NewMemDB() + tree, err := iavl.NewMutableTree(db, cacheSize, false) + require.NoError(t, err) iavlStore := UnsafeNewStore(tree) @@ -564,9 +568,10 @@ func TestIAVLStoreQuery(t *testing.T) { func BenchmarkIAVLIteratorNext(b *testing.B) { b.ReportAllocs() - db := wrapper.NewCosmosDB(dbm.NewMemDB()) + db := dbm.NewMemDB() treeSize := 1000 - tree := iavl.NewMutableTree(db, cacheSize, false, log.NewNopLogger()) + tree, err := iavl.NewMutableTree(db, cacheSize, false) + require.NoError(b, err) for i := 0; i < treeSize; i++ { key := randBytes(4) @@ -599,8 +604,8 @@ func TestSetInitialVersion(t *testing.T) { { "works with a mutable tree", func(db *dbm.MemDB) *Store { - dbt := wrapper.NewCosmosDB(db) - tree := iavl.NewMutableTree(dbt, cacheSize, false, log.NewNopLogger()) + tree, err := iavl.NewMutableTree(db, cacheSize, false) + require.NoError(t, err) store := UnsafeNewStore(tree) return store @@ -609,8 +614,8 @@ func TestSetInitialVersion(t *testing.T) { { "throws error on immutable tree", func(db *dbm.MemDB) *Store { - dbt := wrapper.NewCosmosDB(db) - tree := iavl.NewMutableTree(dbt, cacheSize, false, log.NewNopLogger()) + tree, err := iavl.NewMutableTree(db, cacheSize, false) + require.NoError(t, err) 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 0d65b10de865..9719e3c7573e 100644 --- a/store/iavl/tree.go +++ b/store/iavl/tree.go @@ -5,13 +5,11 @@ import ( "github.com/cosmos/cosmos-sdk/store/types" "github.com/cosmos/iavl" - - dbm "github.com/cometbft/cometbft-db" ) var ( _ Tree = (*immutableTree)(nil) - _ Tree = (*mutableTree)(nil) + _ Tree = (*iavl.MutableTree)(nil) ) type ( @@ -25,18 +23,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 - WorkingHash() []byte + Hash() ([]byte, error) 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) error - TraverseStateChanges(startVersion, endVersion int64, fn func(version int64, changeSet *iavl.ChangeSet) error) error + LoadVersionForOverwriting(targetVersion int64) (int64, error) + LazyLoadVersionForOverwriting(targetVersion int64) (int64, error) } // immutableTree is a simple wrapper around a reference to an iavl.ImmutableTree @@ -45,10 +43,6 @@ type ( immutableTree struct { *iavl.ImmutableTree } - - mutableTree struct { - *iavl.MutableTree - } ) func (it *immutableTree) Set(_, _ []byte) (bool, error) { @@ -63,8 +57,12 @@ func (it *immutableTree) SaveVersion() ([]byte, int64, error) { panic("cannot call 'SaveVersion' on an immutable IAVL tree") } -func (it *immutableTree) DeleteVersionsTo(_ int64) error { - panic("cannot call 'DeleteVersionsTo' 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) SetInitialVersion(_ uint64) { @@ -95,20 +93,10 @@ func (it *immutableTree) AvailableVersions() []int { return []int{} } -func (it *immutableTree) LoadVersionForOverwriting(targetVersion int64) error { +func (it *immutableTree) LoadVersionForOverwriting(targetVersion int64) (int64, error) { panic("cannot call 'LoadVersionForOverwriting' 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 +func (it *immutableTree) LazyLoadVersionForOverwriting(targetVersion int64) (int64, error) { + panic("cannot call 'LazyLoadVersionForOverwriting' on an immutable IAVL tree") } diff --git a/store/iavl/tree_test.go b/store/iavl/tree_test.go index 9d34a41ab977..9abb7aa50de5 100644 --- a/store/iavl/tree_test.go +++ b/store/iavl/tree_test.go @@ -3,23 +3,19 @@ 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() - db := wrapper.NewCosmosDB(dbm.NewMemDB()) - immTree := iavl.NewImmutableTree(db, 100, false, log.NewNopLogger()) + immTree := iavl.NewImmutableTree(dbm.NewMemDB(), 100, false) 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.DeleteVersionsTo(int64(1)) }) // nolint:errcheck + require.Panics(t, func() { it.SaveVersion() }) // nolint:errcheck + require.Panics(t, func() { it.DeleteVersion(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 7d9511910c88..d7b655968814 100644 --- a/store/prefix/store_test.go +++ b/store/prefix/store_test.go @@ -4,9 +4,7 @@ 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" @@ -91,8 +89,9 @@ func testPrefixStore(t *testing.T, baseStore types.KVStore, prefix []byte) { } func TestIAVLStorePrefix(t *testing.T) { - db := wrapper.NewCosmosDB(dbm.NewMemDB()) - tree := tiavl.NewMutableTree(db, cacheSize, false, log.NewNopLogger()) + db := dbm.NewMemDB() + tree, err := tiavl.NewMutableTree(db, cacheSize, false) + require.NoError(t, err) iavlStore := iavl.UnsafeNewStore(tree) testPrefixStore(t, iavlStore, []byte("test")) diff --git a/store/pruning/export_test.go b/store/pruning/export_test.go index 676ff132ff98..8c38778bf93d 100644 --- a/store/pruning/export_test.go +++ b/store/pruning/export_test.go @@ -1,8 +1,11 @@ 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 adeb25eef208..e159f909510a 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,13 +20,17 @@ 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.RWMutex + pruneSnapshotHeightsMx sync.Mutex // 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 []int64 + pruneSnapshotHeights *list.List } // NegativeHeightsError is returned when a negative height is provided to the manager. @@ -41,6 +45,7 @@ func (e *NegativeHeightsError) Error() string { } var ( + pruneHeightsKey = []byte("s/pruneheights") pruneSnapshotHeightsKey = []byte("s/prunesnapshotheights") ) @@ -53,7 +58,8 @@ func NewManager(db dbm.DB, logger log.Logger) *Manager { db: db, logger: logger, opts: types.NewPruningOptions(types.PruningNothing), - pruneSnapshotHeights: []int64{0}, + pruneHeights: []int64{}, + pruneSnapshotHeights: list.New(), } } @@ -67,89 +73,137 @@ func (m *Manager) GetOptions() types.PruningOptions { return m.opts } -// 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 +// 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() - m.pruneSnapshotHeightsMx.Lock() - defer m.pruneSnapshotHeightsMx.Unlock() - - 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 - } + // 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 } - 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, int64SliceToBytes(m.pruneSnapshotHeights)); err != nil { - panic(err) - } -} + // Return a copy to prevent data races. + pruningHeights := make([]int64, len(m.pruneHeights)) + copy(pruningHeights, m.pruneHeights) + m.pruneHeights = m.pruneHeights[:0] -// SetSnapshotInterval sets the interval at which the snapshots are taken. -func (m *Manager) SetSnapshotInterval(snapshotInterval uint64) { - m.snapshotInterval = snapshotInterval + return pruningHeights, nil } -// 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 0 - } - if m.opts.Interval <= 0 { +// 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 } - if height%int64(m.opts.Interval) != 0 || height <= int64(m.opts.KeepRecent) { - return 0 - } + defer func() { + m.pruneHeightsMx.Lock() + defer m.pruneHeightsMx.Unlock() - // Consider the snapshot height - pruneHeight := height - 1 - int64(m.opts.KeepRecent) // we should keep the current height at least + m.pruneSnapshotHeightsMx.Lock() + defer m.pruneSnapshotHeightsMx.Unlock() - m.pruneSnapshotHeightsMx.RLock() - defer m.pruneSnapshotHeightsMx.RUnlock() + // 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() + } + } - // snapshotInterval is zero, indicating that all heights can be pruned - if m.snapshotInterval <= 0 { - return pruneHeight + // 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 +} - if len(m.pruneSnapshotHeights) == 0 { // the length should be greater than zero - 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) { + if m.opts.GetPruningStrategy() == types.PruningNothing || height <= 0 { + return } - // 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 + m.pruneSnapshotHeightsMx.Lock() + defer m.pruneSnapshotHeightsMx.Unlock() + + m.logger.Debug("HandleHeightSnapshot", "height", height) + m.pruneSnapshotHeights.PushBack(height) + + // 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 { + panic(err) } - return pruneHeight } -// LoadSnapshotHeights loads the snapshot heights from the database as a crash recovery. -func (m *Manager) LoadSnapshotHeights(db dbm.DB) error { +// SetSnapshotInterval sets the interval at which the snapshots are taken. +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 { if m.opts.GetPruningStrategy() == types.PruningNothing { return nil } + loadedPruneHeights, err := loadPruningHeights(db) + if err != nil { + return err + } + + if len(loadedPruneHeights) > 0 { + m.pruneHeightsMx.Lock() + defer m.pruneHeightsMx.Unlock() + m.pruneHeights = loadedPruneHeights + } loadedPruneSnapshotHeights, err := loadPruningSnapshotHeights(db) if err != nil { return err } - if len(loadedPruneSnapshotHeights) > 0 { + if loadedPruneSnapshotHeights.Len() > 0 { m.pruneSnapshotHeightsMx.Lock() defer m.pruneSnapshotHeightsMx.Unlock() m.pruneSnapshotHeights = loadedPruneSnapshotHeights @@ -158,24 +212,48 @@ func (m *Manager) LoadSnapshotHeights(db dbm.DB) error { return nil } -func loadPruningSnapshotHeights(db dbm.DB) ([]int64, error) { +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 + } + + 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} + } + + prunedHeights[i] = h + i++ + offset += 8 + } + + return prunedHeights, nil +} + +func loadPruningSnapshotHeights(db dbm.DB) (*list.List, 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 []int64{}, nil + return pruneSnapshotHeights, 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[i] = h + pruneSnapshotHeights.PushBack(h) i++ offset += 8 } @@ -192,3 +270,13 @@ 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 8618a762b504..f7f71b9cfe4a 100644 --- a/store/pruning/manager_test.go +++ b/store/pruning/manager_test.go @@ -1,6 +1,7 @@ package pruning_test import ( + "container/list" "errors" "fmt" "testing" @@ -21,6 +22,9 @@ 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()) } @@ -75,14 +79,12 @@ func TestStrategies(t *testing.T) { }, } - 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()) - manager := pruning.NewManager(db.NewMemDB(), log.NewNopLogger()) - require.NotNil(t, manager) + require.NotNil(t, manager) + for name, tc := range testcases { + t.Run(name, func(t *testing.T) { curStrategy := tc.strategy manager.SetSnapshotInterval(tc.snapshotInterval) @@ -108,82 +110,86 @@ func TestStrategies(t *testing.T) { require.Equal(t, tc.strategy, manager.GetOptions()) curKeepRecent := curStrategy.KeepRecent - snHeight := int64(tc.snapshotInterval - 1) + curInterval := curStrategy.Interval for curHeight := int64(0); curHeight < 110000; 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 - } - } + handleHeightActual := manager.HandleHeight(curHeight) + shouldPruneAtHeightActual := manager.ShouldPruneAtHeight(curHeight) - pruningHeightActual := manager.GetPruningHeight(curHeight) + curPruningHeihts, err := manager.GetFlushAndResetPruningHeights() + require.Nil(t, err) curHeightStr := fmt.Sprintf("height: %d", curHeight) switch curStrategy.GetPruningStrategy() { case types.PruningNothing: - require.Equal(t, int64(0), pruningHeightActual, curHeightStr) + 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)) default: - 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) + 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) } else { - require.Equal(t, int64(0), pruningHeightActual, curHeightStr) + require.Equal(t, int64(0), handleHeightActual, curHeightStr) + + heights, err := manager.GetFlushAndResetPruningHeights() + require.NoError(t, err) + require.Equal(t, 0, len(heights)) } + require.Equal(t, curHeight%int64(curInterval) == 0, shouldPruneAtHeightActual, curHeightStr) } + heights, err := manager.GetFlushAndResetPruningHeights() + require.NoError(t, err) + require.Equal(t, 0, len(heights)) } }) } } -func TestPruningHeight_Inputs(t *testing.T) { - keepRecent := int64(types.NewPruningOptions(types.PruningEverything).KeepRecent) - interval := int64(types.NewPruningOptions(types.PruningEverything).Interval) +func TestHandleHeight_Inputs(t *testing.T) { + var keepRecent int64 = int64(types.NewPruningOptions(types.PruningEverything).KeepRecent) testcases := map[string]struct { - height int64 - expectedResult int64 - strategy types.PruningStrategy + height int64 + expectedResult int64 + strategy types.PruningStrategy + expectedHeights []int64 }{ - "currentHeight is negative - prune everything - invalid currentHeight": { + "previousHeight is negative - prune everything - invalid previousHeight": { -1, 0, types.PruningEverything, + []int64{}, }, - "currentHeight is zero - prune everything - invalid currentHeight": { + "previousHeight is zero - prune everything - invalid previousHeight": { 0, 0, types.PruningEverything, + []int64{}, }, - "currentHeight is positive but within keep recent- prune everything - not kept": { + "previousHeight is positive but within keep recent- prune everything - not kept": { keepRecent, 0, types.PruningEverything, + []int64{}, }, - "currentHeight is positive and equal to keep recent+1 - no kept": { + "previousHeight is positive and greater than keep recent - kept": { keepRecent + 1, - 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, + keepRecent + 1 - keepRecent, types.PruningEverything, + []int64{keepRecent + 1 - keepRecent}, }, "pruning nothing, previousHeight is positive and greater than keep recent - not kept": { keepRecent + 1, 0, types.PruningNothing, + []int64{}, }, } @@ -193,8 +199,113 @@ func TestPruningHeight_Inputs(t *testing.T) { require.NotNil(t, manager) manager.SetOptions(types.NewPruningOptions(tc.strategy)) - pruningHeightActual := manager.GetPruningHeight(tc.height) - require.Equal(t, tc.expectedResult, pruningHeightActual) + 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) }) } } @@ -217,11 +328,11 @@ func TestHandleHeight_DbErr_Panic(t *testing.T) { } }() - manager.HandleSnapshotHeight(10) + manager.HandleHeight(10) } -func TestHandleSnapshotHeight_LoadFromDisk(t *testing.T) { - snapshotInterval := uint64(10) +func TestHandleHeightSnapshot_FlushLoadFromDisk(t *testing.T) { + loadedHeightsMirror := []int64{} // Setup db := db.NewMemDB() @@ -230,29 +341,96 @@ func TestHandleSnapshotHeight_LoadFromDisk(t *testing.T) { manager.SetOptions(types.NewPruningOptions(types.PruningEverything)) - manager.SetSnapshotInterval(snapshotInterval) - - expected := 0 - for snapshotHeight := int64(-1); snapshotHeight < 100; snapshotHeight++ { - snapshotHeightStr := fmt.Sprintf("snaphost height: %d", snapshotHeight) - if snapshotHeight > int64(snapshotInterval) && snapshotHeight%int64(snapshotInterval) == 1 { + // Test flush + manager.HandleHeightSnapshot(snapshotHeight) - // Test flush - manager.HandleSnapshotHeight(snapshotHeight - 1) - expected = 1 + // Post test + if snapshotHeight > 0 { + loadedHeightsMirror = append(loadedHeightsMirror, snapshotHeight) } + loadedSnapshotHeights, err := pruning.LoadPruningSnapshotHeights(db) require.NoError(t, err) - require.Equal(t, expected, len(loadedSnapshotHeights), snapshotHeightStr) + require.Equal(t, len(loadedHeightsMirror), loadedSnapshotHeights.Len()) // Test load back - err = manager.LoadSnapshotHeights(db) + err = manager.LoadPruningHeights(db) require.NoError(t, err) loadedSnapshotHeights, err = pruning.LoadPruningSnapshotHeights(db) require.NoError(t, err) - require.Equal(t, expected, len(loadedSnapshotHeights), snapshotHeightStr) + 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) + } } } @@ -267,18 +445,43 @@ func TestLoadPruningHeights(t *testing.T) { manager.SetOptions(types.NewPruningOptions(types.PruningDefault)) testcases := map[string]struct { - getFlushedPruningSnapshotHeights func() []int64 + flushedPruningHeights []int64 + getFlushedPruningSnapshotHeights func() *list.List expectedResult error }{ + "negative pruningHeight - error": { + flushedPruningHeights: []int64{10, 0, -1}, + expectedResult: &pruning.NegativeHeightsError{Height: -1}, + }, "negative snapshotPruningHeight - error": { - getFlushedPruningSnapshotHeights: func() []int64 { - return []int64{5, -2, 3} + 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: -2}, }, - "non-negative - success": { - getFlushedPruningSnapshotHeights: func() []int64 { - return []int64{5, 0, 3} + "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 }, }, } @@ -286,23 +489,44 @@ 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.Int64SliceToBytes(tc.getFlushedPruningSnapshotHeights())) + err = db.Set(pruning.PruneSnapshotHeightsKey, pruning.ListToBytes(tc.getFlushedPruningSnapshotHeights())) require.NoError(t, err) } - err = manager.LoadSnapshotHeights(db) + err = manager.LoadPruningHeights(db) require.Equal(t, tc.expectedResult, err) }) } } -func TestLoadSnapshotHeights_PruneNothing(t *testing.T) { +func TestLoadPruningHeights_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.LoadSnapshotHeights(db.NewMemDB())) + 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) } diff --git a/store/rootmulti/store.go b/store/rootmulti/store.go index d93351d7526e..bebd6cd1af9a 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.LoadSnapshotHeights(rs.db); err != nil { + if err := rs.pruningManager.LoadPruningHeights(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.HandleSnapshotHeight(height) + rs.pruningManager.HandleHeightSnapshot(height) } // SetInterBlockCache sets the Store's internal inter-block (persistent) cache. @@ -594,19 +594,38 @@ func (rs *Store) GetKVStore(key types.StoreKey) types.KVStore { } func (rs *Store) handlePruning(version int64) error { - pruneHeight := rs.pruningManager.GetPruningHeight(version) + 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) defer rs.logger.Info("prune end", "height", version) - return rs.PruneStores(pruneHeight) + return rs.PruneStores(true, nil) } -// 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") +// 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") return nil } - rs.logger.Debug("pruning store", "height", pruningHeight) + rs.logger.Debug("pruning store", "heights", pruningHeights) for key, store := range rs.stores { rs.logger.Debug("pruning store", "key", key) // Also log store.name (a private variable)? @@ -619,7 +638,7 @@ func (rs *Store) PruneStores(pruningHeight int64) (err error) { store = rs.GetCommitKVStore(key) - err := store.(*iavl.Store).DeleteVersionsTo(pruningHeight) + err := store.(*iavl.Store).DeleteVersions(pruningHeights...) if err == nil { continue } @@ -1003,7 +1022,12 @@ 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) - _, err := store.(*iavl.Store).LoadVersionForOverwriting(target) + var err error + if rs.lazyLoading { + _, err = store.(*iavl.Store).LazyLoadVersionForOverwriting(target) + } else { + _, 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 242a3ce5464e..41ee371b2b00 100644 --- a/store/rootmulti/store_test.go +++ b/store/rootmulti/store_test.go @@ -562,8 +562,12 @@ func TestMultiStore_Pruning_SameHeightsTwice(t *testing.T) { err := ms.LoadVersion(numVersions - 1) require.NoError(t, err) - // Ensure already pruned snapshot heights were loaded - require.NoError(t, ms.pruningManager.LoadSnapshotHeights(db)) + // 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)) // Test pruning the same heights again lastCommitInfo = ms.Commit() @@ -577,6 +581,7 @@ 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 @@ -585,26 +590,37 @@ func TestMultiStore_PruningRestart(t *testing.T) { ms.Commit() } - actualHeightToPrune := ms.pruningManager.GetPruningHeight(ms.LatestVersion()) - require.Equal(t, int64(0), actualHeightToPrune) + 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) // "restart" ms = newMultiStoreWithMounts(db, pruningtypes.NewCustomPruningOptions(2, 11)) - err := ms.LoadLatestVersion() + ms.SetSnapshotInterval(3) + err = ms.LoadLatestVersion() require.NoError(t, err) - actualHeightToPrune = ms.pruningManager.GetPruningHeight(ms.LatestVersion()) - require.Equal(t, int64(0), actualHeightToPrune) + actualHeightsToPrune, err = ms.pruningManager.GetFlushAndResetPruningHeights() + require.NoError(t, err) + require.Equal(t, pruneHeights, actualHeightsToPrune) // commit one more block and ensure the heights have been pruned ms.Commit() - actualHeightToPrune = ms.pruningManager.GetPruningHeight(ms.LatestVersion()) - require.Equal(t, int64(8), actualHeightToPrune) + actualHeightsToPrune, err = ms.pruningManager.GetFlushAndResetPruningHeights() + require.NoError(t, err) + require.Empty(t, actualHeightsToPrune) - for v := int64(1); v <= actualHeightToPrune; v++ { + for _, v := range pruneHeights { _, err := ms.CacheMultiStoreWithVersion(v) - require.Error(t, err, "expected error when loading height: %d", v) + require.NoError(t, err, "expected error when loading height: %d", v) } } diff --git a/store/wrapper/ics23.go b/store/wrapper/ics23.go deleted file mode 100644 index 760982d365d2..000000000000 --- a/store/wrapper/ics23.go +++ /dev/null @@ -1,14 +0,0 @@ -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 deleted file mode 100644 index ac1711d1f895..000000000000 --- a/store/wrapper/tmdb.go +++ /dev/null @@ -1,100 +0,0 @@ -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 -}