diff --git a/Makefile b/Makefile index f7a0fcb2edb4..d5be191b11b4 100644 --- a/Makefile +++ b/Makefile @@ -505,13 +505,17 @@ localnet-debug: localnet-stop localnet-build-dlv localnet-build-nodes .PHONY: localnet-start localnet-stop localnet-debug localnet-build-env localnet-build-dlv localnet-build-nodes -test-system: build-v53 build +build-system-test-current: build + mkdir -p ./tests/systemtests/binaries/ + cp $(BUILDDIR)/simd ./tests/systemtests/binaries/ + +test-system: build-v53 build-system-test-current mkdir -p ./tests/systemtests/binaries/ cp $(BUILDDIR)/simd ./tests/systemtests/binaries/ mkdir -p ./tests/systemtests/binaries/v0.53 mv $(BUILDDIR)/simdv53 ./tests/systemtests/binaries/v0.53/simd $(MAKE) -C tests/systemtests test -.PHONY: test-system +.PHONY: test-system build-system-test-current # build-v53 checks out the v0.53.x branch, builds the binary, and renames it to simdv53. build-v53: diff --git a/baseapp/setup_memiavl.go b/baseapp/setup_memiavl.go new file mode 100644 index 000000000000..4e91fcccd570 --- /dev/null +++ b/baseapp/setup_memiavl.go @@ -0,0 +1,65 @@ +package baseapp + +import ( + "path/filepath" + + "cosmossdk.io/store/cronos/rootmulti" + + "github.com/crypto-org-chain/cronos/memiavl" + + "github.com/spf13/cast" + + servertypes "github.com/cosmos/cosmos-sdk/server/types" + sdk "github.com/cosmos/cosmos-sdk/types" +) + +const ( + FlagMemIAVL = "memiavl.enable" + FlagAsyncCommitBuffer = "memiavl.async-commit-buffer" + FlagZeroCopy = "memiavl.zero-copy" + FlagSnapshotKeepRecent = "memiavl.snapshot-keep-recent" + FlagSnapshotInterval = "memiavl.snapshot-interval" + FlagCacheSize = "memiavl.cache-size" + FlagSnapshotWriterLimit = "memiavl.snapshot-writer-limit" +) + +// SetupMemIAVL insert the memiavl setter in front of baseapp options, so that +// the default rootmulti store is replaced by memiavl store, +func SetupMemIAVL( + homePath string, + appOpts servertypes.AppOptions, + sdk46Compact bool, + supportExportNonSnapshotVersion bool, + cacheSize int, +) func(*BaseApp) { + opts := memiavl.Options{ + AsyncCommitBuffer: cast.ToInt(appOpts.Get(FlagAsyncCommitBuffer)), + ZeroCopy: cast.ToBool(appOpts.Get(FlagZeroCopy)), + SnapshotKeepRecent: cast.ToUint32(appOpts.Get(FlagSnapshotKeepRecent)), + SnapshotInterval: cast.ToUint32(appOpts.Get(FlagSnapshotInterval)), + CacheSize: cacheSize, + SnapshotWriterLimit: cast.ToInt(appOpts.Get(FlagSnapshotWriterLimit)), + } + + if opts.ZeroCopy { + // it's unsafe to cache zero-copied byte slices without copying them + sdk.SetAddrCacheEnabled(false) + } + + // cms must be overridden before the other options, because they may use the cms, + // make sure the cms aren't be overridden by the other options later on. + return setMemIAVL(homePath, opts, sdk46Compact, supportExportNonSnapshotVersion) +} + +func setMemIAVL(homePath string, opts memiavl.Options, sdk46Compact, supportExportNonSnapshotVersion bool) func(*BaseApp) { + return func(bapp *BaseApp) { + logger := bapp.Logger() + // trigger state-sync snapshot creation by memiavl + opts.TriggerStateSyncExport = func(height int64) { + go bapp.SnapshotManager().SnapshotIfApplicable(height) + } + cms := rootmulti.NewStore(filepath.Join(homePath, "data", "memiavl.db"), logger, sdk46Compact, supportExportNonSnapshotVersion) + cms.SetMemIAVLOptions(opts) + bapp.SetCMS(cms) + } +} diff --git a/go.mod b/go.mod index f9e2e10b8a05..e9b60b5bcedb 100644 --- a/go.mod +++ b/go.mod @@ -27,6 +27,7 @@ require ( github.com/cosmos/gogogateway v1.2.0 github.com/cosmos/gogoproto v1.7.0 github.com/cosmos/ledger-cosmos-go v0.15.0 + github.com/crypto-org-chain/cronos/memiavl v0.1.0 github.com/decred/dcrd/dcrec/secp256k1/v4 v4.4.0 github.com/golang/protobuf v1.5.4 github.com/google/go-cmp v0.7.0 @@ -84,6 +85,7 @@ require ( github.com/GoogleCloudPlatform/opentelemetry-operations-go/detectors/gcp v1.27.0 // indirect github.com/GoogleCloudPlatform/opentelemetry-operations-go/exporter/metric v0.48.1 // indirect github.com/GoogleCloudPlatform/opentelemetry-operations-go/internal/resourcemapping v0.48.1 // indirect + github.com/alitto/pond v1.8.3 // indirect github.com/aws/aws-sdk-go v1.44.122 // indirect github.com/beorn7/perks v1.0.1 // indirect github.com/bgentry/go-netrc v0.0.0-20140422174119-9fd32a8b3d3d // indirect @@ -151,6 +153,7 @@ require ( github.com/klauspost/cpuid/v2 v2.2.10 // indirect github.com/kr/pretty v0.3.1 // indirect github.com/kr/text v0.2.0 // indirect + github.com/ledgerwatch/erigon-lib v0.0.0-20230210071639-db0e7ed11263 // indirect github.com/lib/pq v1.10.9 // indirect github.com/linxGnu/grocksdb v1.10.1 // indirect github.com/lmittmann/tint v1.0.7 // indirect @@ -181,9 +184,15 @@ require ( github.com/subosito/gotenv v1.6.0 // indirect github.com/supranational/blst v0.3.14 // indirect github.com/syndtr/goleveldb v1.0.1-0.20220721030215-126854af5e6d // indirect - github.com/tidwall/btree v1.7.0 // indirect + github.com/tidwall/btree v1.8.0 // indirect + github.com/tidwall/gjson v1.10.2 // indirect + github.com/tidwall/match v1.1.1 // indirect + github.com/tidwall/pretty v1.2.0 // indirect + github.com/tidwall/tinylru v1.1.0 // indirect + github.com/tidwall/wal v1.1.7 // indirect github.com/twitchyliquid64/golang-asm v0.15.1 // indirect github.com/ulikunitz/xz v0.5.10 // indirect + github.com/zbiljic/go-filelock v0.0.0-20170914061330-1dbf7103ab7d // indirect github.com/zeebo/errs v1.4.0 // indirect github.com/zondax/hid v0.9.2 // indirect github.com/zondax/ledger-go v1.0.0 // indirect @@ -218,6 +227,7 @@ require ( // Here are the short-lived replace from the Cosmos SDK // Replace here are pending PRs, or version to be tagged +replace cosmossdk.io/store => ./store // Below are the long-lived replace of the Cosmos SDK replace ( diff --git a/go.sum b/go.sum index 27023b1c93d9..4a28fc4a681d 100644 --- a/go.sum +++ b/go.sum @@ -630,8 +630,6 @@ cosmossdk.io/math v1.5.3 h1:WH6tu6Z3AUCeHbeOSHg2mt9rnoiUWVWaQ2t6Gkll96U= cosmossdk.io/math v1.5.3/go.mod h1:uqcZv7vexnhMFJF+6zh9EWdm/+Ylyln34IvPnBauPCQ= cosmossdk.io/schema v1.1.0 h1:mmpuz3dzouCoyjjcMcA/xHBEmMChN+EHh8EHxHRHhzE= cosmossdk.io/schema v1.1.0/go.mod h1:Gb7pqO+tpR+jLW5qDcNOSv0KtppYs7881kfzakguhhI= -cosmossdk.io/store v1.10.0-rc.2 h1:7ze2UoheVTVMK4ElHtoRhYv8nlUImj34e4yp1yy1bgE= -cosmossdk.io/store v1.10.0-rc.2/go.mod h1:3p1IV4EGsULFfeyAcfj7/DBcDsy8d3VlYIEJnhhbP3U= cosmossdk.io/x/tx v1.2.0-rc.1 h1:AartiA6eiTD9KHmnlj3uG3H8FjyjI0qNkmvmU+p6cJ8= cosmossdk.io/x/tx v1.2.0-rc.1/go.mod h1:UzpMTUmQEFfz+m0E+lhzFIiEhtZCHjScU/NC652DBHI= dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU= @@ -679,6 +677,8 @@ github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751/go.mod h1:LOuy github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0= github.com/alecthomas/units v0.0.0-20190717042225-c3de453c63f4/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0= github.com/alecthomas/units v0.0.0-20190924025748-f65c72e2690d/go.mod h1:rBZYJk541a8SKzHPHnH3zbiI+7dagKZ0cgpgrD7Fyho= +github.com/alitto/pond v1.8.3 h1:ydIqygCLVPqIX/USe5EaV/aSRXTRXDEI9JwuDdu+/xs= +github.com/alitto/pond v1.8.3/go.mod h1:CmvIIGd5jKLasGI3D87qDkQxjzChdKMmnXMg3fG6M6Q= github.com/andybalholm/brotli v1.0.4/go.mod h1:fO7iG3H7G2nSZ7m0zPUDn85XEX2GTukHGRSepvi9Eig= github.com/antihax/optional v1.0.0/go.mod h1:uupD/76wgC+ih3iEmQUL+0Ugr19nfwCT1kdvxnR2qWY= github.com/apache/arrow/go/v10 v10.0.1/go.mod h1:YvhnlEePVnBS4+0z3fhPfUy7W1Ikj0Ih0vcRo/gZ1M0= @@ -826,6 +826,8 @@ github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d/go.mod h1:ma github.com/cpuguy83/go-md2man/v2 v2.0.6/go.mod h1:oOW0eioCTA6cOiMLiUPZOpcVxMig6NIQQ7OS05n1F4g= github.com/creack/pty v1.1.7/go.mod h1:lj5s0c3V2DBrqTV7llrYr5NG6My20zk30Fl46Y7DoTY= github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= +github.com/crypto-org-chain/cronos/memiavl v0.1.0 h1:bHjD9mdra/SoByljilIgIkm2Tavkswy4qT6SLvVzDic= +github.com/crypto-org-chain/cronos/memiavl v0.1.0/go.mod h1:IyRvgFKOQPC/Qdx543PGl6WgeDOU+hWdv+xLz3stotc= github.com/danieljoos/wincred v1.1.2 h1:QLdCxFs1/Yl4zduvBdcHB8goaYk9RARS2SgLLRuAyr0= github.com/danieljoos/wincred v1.1.2/go.mod h1:GijpziifJoIBfYh+S7BbkdUTU4LfM+QnGqR5Vl2tAx0= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= @@ -1259,6 +1261,8 @@ github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc= github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw= +github.com/ledgerwatch/erigon-lib v0.0.0-20230210071639-db0e7ed11263 h1:LGEzZvf33Y1NhuP5+jI/ni9l1TFS6oYPDilgy74NusM= +github.com/ledgerwatch/erigon-lib v0.0.0-20230210071639-db0e7ed11263/go.mod h1:OXgMDuUo2lZ3NpH29ZvMYbk+LxFd5ffDl2Z2mGMuY/I= github.com/leodido/go-urn v1.2.4 h1:XlAE/cm/ms7TE/VMVoduSpNBoyc2dOxHs5MZSwAN63Q= github.com/leodido/go-urn v1.2.4/go.mod h1:7ZrI8mTSeBSHl/UaRyKQW1qZeMgak41ANeCNaVckg+4= github.com/lib/pq v1.10.9 h1:YXG7RB+JIjhP29X+OtkiDnYaXQwpS4JEWq7dtCCRUEw= @@ -1534,8 +1538,18 @@ github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7 h1:epCh84lMvA70 github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7/go.mod h1:q4W45IWZaF22tdD+VEXcAWRA037jwmWEB5VWYORlTpc= 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.7.0 h1:L1fkJH/AuEh5zBnnBbmTwQ5Lt+bRJ5A8EWecslvo9iI= -github.com/tidwall/btree v1.7.0/go.mod h1:twD9XRA5jj9VUQGELzDO4HPQTNJsoWWfYEL+EUQ2cKY= +github.com/tidwall/btree v1.8.0 h1:kHHy8hSBauQUe0KPHMFLOt0olAj1nDnkHPJhr8+HFkM= +github.com/tidwall/btree v1.8.0/go.mod h1:jBbTdUWhSZClZWoDg54VnvV7/54modSOzDN7VXftj1A= +github.com/tidwall/gjson v1.10.2 h1:APbLGOM0rrEkd8WBw9C24nllro4ajFuJu0Sc9hRz8Bo= +github.com/tidwall/gjson v1.10.2/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk= +github.com/tidwall/match v1.1.1 h1:+Ho715JplO36QYgwN9PGYNhgZvoUSc9X2c80KVTi+GA= +github.com/tidwall/match v1.1.1/go.mod h1:eRSPERbgtNPcGhD8UCthc6PmLEQXEWd3PRB5JTxsfmM= +github.com/tidwall/pretty v1.2.0 h1:RWIZEg2iJ8/g6fDDYzMpobmaoGh5OLl4AXtGUGPcqCs= +github.com/tidwall/pretty v1.2.0/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhsoaGGjNU= +github.com/tidwall/tinylru v1.1.0 h1:XY6IUfzVTU9rpwdhKUF6nQdChgCdGjkMfLzbWyiau6I= +github.com/tidwall/tinylru v1.1.0/go.mod h1:3+bX+TJ2baOLMWTnlyNWHh4QMnFyARg2TLTQ6OFbzw8= +github.com/tidwall/wal v1.1.7 h1:emc1TRjIVsdKKSnpwGBAcsAGg0767SvUk8+ygx7Bb+4= +github.com/tidwall/wal v1.1.7/go.mod h1:r6lR1j27W9EPalgHiB7zLJDYu3mzW5BQP5KrzBpYY/E= github.com/tmc/grpc-websocket-proxy v0.0.0-20170815181823-89b8d40f7ca8/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U= github.com/tv42/httpunix v0.0.0-20150427012821-b75d8614f926/go.mod h1:9ESjWnEqriFuLhtthL60Sar/7RFoluCcXsuvEwTV5KM= github.com/twitchyliquid64/golang-asm v0.15.1 h1:SU5vSMR7hnwNxj24w34ZyCi/FmDZTkS4MhqMhdFk5YI= @@ -1554,6 +1568,8 @@ github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9dec github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= github.com/yuin/goldmark v1.4.1/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= +github.com/zbiljic/go-filelock v0.0.0-20170914061330-1dbf7103ab7d h1:XQyeLr7N9iY9mi+TGgsBFkj54+j3fdoo8e2u6zrGP5A= +github.com/zbiljic/go-filelock v0.0.0-20170914061330-1dbf7103ab7d/go.mod h1:hoMeDjlNXTNqVwrCk8YDyaBS2g5vFfEX2ezMi4vb6CY= github.com/zeebo/assert v1.3.0/go.mod h1:Pq9JiuJQpG8JLJdtkwrJESF0Foym2/D9XMU5ciN/wJ0= github.com/zeebo/errs v1.4.0 h1:XNdoD/RRMKP7HD0UhJnIzUy74ISdGGxURlYG8HSWSfM= github.com/zeebo/errs v1.4.0/go.mod h1:sgbWHsvVuTPHcqJJGQ1WhI5KbWlHYz+2+2C/LSEtCw4= diff --git a/server/util.go b/server/util.go index b3100dd63b34..ff0194023aac 100644 --- a/server/util.go +++ b/server/util.go @@ -25,6 +25,7 @@ import ( "golang.org/x/sync/errgroup" "cosmossdk.io/log" + "cosmossdk.io/store" "cosmossdk.io/store/snapshots" snapshottypes "cosmossdk.io/store/snapshots/types" @@ -582,6 +583,14 @@ func DefaultBaseappOptions(appOpts types.AppOptions) []func(*baseapp.BaseApp) { defaultMempool, baseapp.SetChainID(chainID), baseapp.SetQueryGasLimit(cast.ToUint64(appOpts.Get(FlagQueryGasLimit))), + // TODO for testing purposes we always enable memiavl, but we need this to be a config param in the future + baseapp.SetupMemIAVL( + homeDir, + appOpts, + false, + false, + 50000, + ), } } diff --git a/simapp/go.mod b/simapp/go.mod index d0bfae1dc6a7..ca809a3b7130 100644 --- a/simapp/go.mod +++ b/simapp/go.mod @@ -47,6 +47,7 @@ require ( github.com/GoogleCloudPlatform/opentelemetry-operations-go/detectors/gcp v1.27.0 // indirect github.com/GoogleCloudPlatform/opentelemetry-operations-go/exporter/metric v0.51.0 // indirect github.com/GoogleCloudPlatform/opentelemetry-operations-go/internal/resourcemapping v0.51.0 // indirect + github.com/alitto/pond v1.8.3 // indirect github.com/aws/aws-sdk-go v1.44.224 // indirect github.com/beorn7/perks v1.0.1 // indirect github.com/bgentry/go-netrc v0.0.0-20140422174119-9fd32a8b3d3d // indirect @@ -76,6 +77,7 @@ require ( github.com/cosmos/ledger-cosmos-go v0.15.0 // indirect github.com/creachadair/atomicfile v0.3.8 // indirect github.com/creachadair/tomledit v0.0.28 // indirect + github.com/crypto-org-chain/cronos/memiavl v0.1.0 // indirect github.com/danieljoos/wincred v1.1.2 // indirect github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect github.com/decred/dcrd/dcrec/secp256k1/v4 v4.4.0 // indirect @@ -138,6 +140,7 @@ require ( github.com/klauspost/cpuid/v2 v2.2.10 // indirect github.com/kr/pretty v0.3.1 // indirect github.com/kr/text v0.2.0 // indirect + github.com/ledgerwatch/erigon-lib v0.0.0-20230210071639-db0e7ed11263 // indirect github.com/lib/pq v1.10.9 // indirect github.com/linxGnu/grocksdb v1.10.1 // indirect github.com/lmittmann/tint v1.0.7 // indirect @@ -174,9 +177,15 @@ require ( github.com/supranational/blst v0.3.14 // indirect github.com/syndtr/goleveldb v1.0.1-0.20220721030215-126854af5e6d // indirect github.com/tendermint/go-amino v0.16.0 // indirect - github.com/tidwall/btree v1.7.0 // indirect + github.com/tidwall/btree v1.8.0 // indirect + github.com/tidwall/gjson v1.10.2 // indirect + github.com/tidwall/match v1.1.1 // indirect + github.com/tidwall/pretty v1.2.0 // indirect + github.com/tidwall/tinylru v1.1.0 // indirect + github.com/tidwall/wal v1.1.7 // indirect github.com/twitchyliquid64/golang-asm v0.15.1 // indirect github.com/ulikunitz/xz v0.5.11 // indirect + github.com/zbiljic/go-filelock v0.0.0-20170914061330-1dbf7103ab7d // indirect github.com/zeebo/errs v1.4.0 // indirect github.com/zondax/hid v0.9.2 // indirect github.com/zondax/ledger-go v1.0.0 // indirect @@ -217,9 +226,8 @@ require ( // Here are the short-lived replace from the SimApp // Replace here are pending PRs, or version to be tagged -// replace ( -// -// ) +// +replace cosmossdk.io/store => ../store // Below are the long-lived replace of the SimApp replace ( diff --git a/simapp/go.sum b/simapp/go.sum index 649b65986b6d..04f9a1e5f36d 100644 --- a/simapp/go.sum +++ b/simapp/go.sum @@ -632,8 +632,6 @@ cosmossdk.io/math v1.5.3 h1:WH6tu6Z3AUCeHbeOSHg2mt9rnoiUWVWaQ2t6Gkll96U= cosmossdk.io/math v1.5.3/go.mod h1:uqcZv7vexnhMFJF+6zh9EWdm/+Ylyln34IvPnBauPCQ= cosmossdk.io/schema v1.1.0 h1:mmpuz3dzouCoyjjcMcA/xHBEmMChN+EHh8EHxHRHhzE= cosmossdk.io/schema v1.1.0/go.mod h1:Gb7pqO+tpR+jLW5qDcNOSv0KtppYs7881kfzakguhhI= -cosmossdk.io/store v1.10.0-rc.2 h1:7ze2UoheVTVMK4ElHtoRhYv8nlUImj34e4yp1yy1bgE= -cosmossdk.io/store v1.10.0-rc.2/go.mod h1:3p1IV4EGsULFfeyAcfj7/DBcDsy8d3VlYIEJnhhbP3U= cosmossdk.io/tools/confix v0.2.0-rc.4 h1:m+rE4N7sUHxwcEJE9pSm1O8HfdUmTSI3l90lQBF4cQY= cosmossdk.io/tools/confix v0.2.0-rc.4/go.mod h1:ANAmjE5X02R492sFxO1WWST47HNgYt7ltSltKI1wJWk= cosmossdk.io/x/tx v1.2.0-rc.1 h1:AartiA6eiTD9KHmnlj3uG3H8FjyjI0qNkmvmU+p6cJ8= @@ -683,6 +681,8 @@ github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751/go.mod h1:LOuy github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0= github.com/alecthomas/units v0.0.0-20190717042225-c3de453c63f4/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0= github.com/alecthomas/units v0.0.0-20190924025748-f65c72e2690d/go.mod h1:rBZYJk541a8SKzHPHnH3zbiI+7dagKZ0cgpgrD7Fyho= +github.com/alitto/pond v1.8.3 h1:ydIqygCLVPqIX/USe5EaV/aSRXTRXDEI9JwuDdu+/xs= +github.com/alitto/pond v1.8.3/go.mod h1:CmvIIGd5jKLasGI3D87qDkQxjzChdKMmnXMg3fG6M6Q= github.com/andybalholm/brotli v1.0.4/go.mod h1:fO7iG3H7G2nSZ7m0zPUDn85XEX2GTukHGRSepvi9Eig= github.com/antihax/optional v1.0.0/go.mod h1:uupD/76wgC+ih3iEmQUL+0Ugr19nfwCT1kdvxnR2qWY= github.com/apache/arrow/go/v10 v10.0.1/go.mod h1:YvhnlEePVnBS4+0z3fhPfUy7W1Ikj0Ih0vcRo/gZ1M0= @@ -837,6 +837,8 @@ github.com/creachadair/tomledit v0.0.28 h1:aQJVwcNTzx4SZ/tSbkyGE69w4YQ6Gn+xhHHKt github.com/creachadair/tomledit v0.0.28/go.mod h1:pqb2HRQi0lMu6MBiUmTk/0XQ+SmPtq2QbUrG+eiLP5w= github.com/creack/pty v1.1.7/go.mod h1:lj5s0c3V2DBrqTV7llrYr5NG6My20zk30Fl46Y7DoTY= github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= +github.com/crypto-org-chain/cronos/memiavl v0.1.0 h1:bHjD9mdra/SoByljilIgIkm2Tavkswy4qT6SLvVzDic= +github.com/crypto-org-chain/cronos/memiavl v0.1.0/go.mod h1:IyRvgFKOQPC/Qdx543PGl6WgeDOU+hWdv+xLz3stotc= github.com/danieljoos/wincred v1.1.2 h1:QLdCxFs1/Yl4zduvBdcHB8goaYk9RARS2SgLLRuAyr0= github.com/danieljoos/wincred v1.1.2/go.mod h1:GijpziifJoIBfYh+S7BbkdUTU4LfM+QnGqR5Vl2tAx0= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= @@ -1267,6 +1269,8 @@ github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc= github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw= +github.com/ledgerwatch/erigon-lib v0.0.0-20230210071639-db0e7ed11263 h1:LGEzZvf33Y1NhuP5+jI/ni9l1TFS6oYPDilgy74NusM= +github.com/ledgerwatch/erigon-lib v0.0.0-20230210071639-db0e7ed11263/go.mod h1:OXgMDuUo2lZ3NpH29ZvMYbk+LxFd5ffDl2Z2mGMuY/I= github.com/leodido/go-urn v1.2.4 h1:XlAE/cm/ms7TE/VMVoduSpNBoyc2dOxHs5MZSwAN63Q= github.com/leodido/go-urn v1.2.4/go.mod h1:7ZrI8mTSeBSHl/UaRyKQW1qZeMgak41ANeCNaVckg+4= github.com/lib/pq v1.10.9 h1:YXG7RB+JIjhP29X+OtkiDnYaXQwpS4JEWq7dtCCRUEw= @@ -1542,8 +1546,18 @@ github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7 h1:epCh84lMvA70 github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7/go.mod h1:q4W45IWZaF22tdD+VEXcAWRA037jwmWEB5VWYORlTpc= 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.7.0 h1:L1fkJH/AuEh5zBnnBbmTwQ5Lt+bRJ5A8EWecslvo9iI= -github.com/tidwall/btree v1.7.0/go.mod h1:twD9XRA5jj9VUQGELzDO4HPQTNJsoWWfYEL+EUQ2cKY= +github.com/tidwall/btree v1.8.0 h1:kHHy8hSBauQUe0KPHMFLOt0olAj1nDnkHPJhr8+HFkM= +github.com/tidwall/btree v1.8.0/go.mod h1:jBbTdUWhSZClZWoDg54VnvV7/54modSOzDN7VXftj1A= +github.com/tidwall/gjson v1.10.2 h1:APbLGOM0rrEkd8WBw9C24nllro4ajFuJu0Sc9hRz8Bo= +github.com/tidwall/gjson v1.10.2/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk= +github.com/tidwall/match v1.1.1 h1:+Ho715JplO36QYgwN9PGYNhgZvoUSc9X2c80KVTi+GA= +github.com/tidwall/match v1.1.1/go.mod h1:eRSPERbgtNPcGhD8UCthc6PmLEQXEWd3PRB5JTxsfmM= +github.com/tidwall/pretty v1.2.0 h1:RWIZEg2iJ8/g6fDDYzMpobmaoGh5OLl4AXtGUGPcqCs= +github.com/tidwall/pretty v1.2.0/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhsoaGGjNU= +github.com/tidwall/tinylru v1.1.0 h1:XY6IUfzVTU9rpwdhKUF6nQdChgCdGjkMfLzbWyiau6I= +github.com/tidwall/tinylru v1.1.0/go.mod h1:3+bX+TJ2baOLMWTnlyNWHh4QMnFyARg2TLTQ6OFbzw8= +github.com/tidwall/wal v1.1.7 h1:emc1TRjIVsdKKSnpwGBAcsAGg0767SvUk8+ygx7Bb+4= +github.com/tidwall/wal v1.1.7/go.mod h1:r6lR1j27W9EPalgHiB7zLJDYu3mzW5BQP5KrzBpYY/E= github.com/tmc/grpc-websocket-proxy v0.0.0-20170815181823-89b8d40f7ca8/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U= github.com/tv42/httpunix v0.0.0-20150427012821-b75d8614f926/go.mod h1:9ESjWnEqriFuLhtthL60Sar/7RFoluCcXsuvEwTV5KM= github.com/twitchyliquid64/golang-asm v0.15.1 h1:SU5vSMR7hnwNxj24w34ZyCi/FmDZTkS4MhqMhdFk5YI= @@ -1563,6 +1577,8 @@ github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9dec github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= github.com/yuin/goldmark v1.4.1/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= +github.com/zbiljic/go-filelock v0.0.0-20170914061330-1dbf7103ab7d h1:XQyeLr7N9iY9mi+TGgsBFkj54+j3fdoo8e2u6zrGP5A= +github.com/zbiljic/go-filelock v0.0.0-20170914061330-1dbf7103ab7d/go.mod h1:hoMeDjlNXTNqVwrCk8YDyaBS2g5vFfEX2ezMi4vb6CY= github.com/zeebo/assert v1.3.0/go.mod h1:Pq9JiuJQpG8JLJdtkwrJESF0Foym2/D9XMU5ciN/wJ0= github.com/zeebo/errs v1.4.0 h1:XNdoD/RRMKP7HD0UhJnIzUy74ISdGGxURlYG8HSWSfM= github.com/zeebo/errs v1.4.0/go.mod h1:sgbWHsvVuTPHcqJJGQ1WhI5KbWlHYz+2+2C/LSEtCw4= diff --git a/store/cronos/cachemulti/store.go b/store/cronos/cachemulti/store.go new file mode 100644 index 000000000000..57912c53f417 --- /dev/null +++ b/store/cronos/cachemulti/store.go @@ -0,0 +1,37 @@ +package cachemulti + +import ( + "io" + + "cosmossdk.io/store/cachemulti" + "cosmossdk.io/store/types" +) + +var NoopCloser io.Closer = CloserFunc(func() error { return nil }) + +type CloserFunc func() error + +func (fn CloserFunc) Close() error { + return fn() +} + +// Store wraps sdk's cachemulti.Store to add io.Closer interface +type Store struct { + cachemulti.Store + io.Closer +} + +func NewStore( + stores map[types.StoreKey]types.CacheWrapper, + traceWriter io.Writer, traceContext types.TraceContext, + closer io.Closer, +) Store { + if closer == nil { + closer = NoopCloser + } + store := cachemulti.NewStore(nil, stores, nil, traceWriter, traceContext) + return Store{ + Store: store, + Closer: closer, + } +} diff --git a/store/cronos/config/config.go b/store/cronos/config/config.go new file mode 100644 index 000000000000..03f4c8ce49e1 --- /dev/null +++ b/store/cronos/config/config.go @@ -0,0 +1,32 @@ +package config + +import "github.com/crypto-org-chain/cronos/memiavl" + +const DefaultCacheSize = 1000 + +type MemIAVLConfig struct { + // Enable defines if the memiavl should be enabled. + Enable bool `mapstructure:"enable"` + // ZeroCopy defines if the memiavl should return slices pointing to mmap-ed buffers directly (zero-copy), + // the zero-copied slices must not be retained beyond current block's execution. + // the sdk address cache will be disabled if zero-copy is enabled. + ZeroCopy bool `mapstructure:"zero-copy"` + // AsyncCommitBuffer defines the size of asynchronous commit queue, this greatly improve block catching-up + // performance, -1 means synchronous commit. + AsyncCommitBuffer int `mapstructure:"async-commit-buffer"` + // SnapshotKeepRecent defines what many old snapshots (excluding the latest one) to keep after new snapshots are + // taken, defaults to 1 to make sure ibc relayers work. + SnapshotKeepRecent uint32 `mapstructure:"snapshot-keep-recent"` + // SnapshotInterval defines the block interval the memiavl snapshot is taken, default to 1000. + SnapshotInterval uint32 `mapstructure:"snapshot-interval"` + // CacheSize defines the size of the cache for each memiavl store. + CacheSize int `mapstructure:"cache-size"` +} + +func DefaultMemIAVLConfig() MemIAVLConfig { + return MemIAVLConfig{ + CacheSize: DefaultCacheSize, + SnapshotInterval: memiavl.DefaultSnapshotInterval, + SnapshotKeepRecent: 1, + } +} diff --git a/store/cronos/config/toml.go b/store/cronos/config/toml.go new file mode 100644 index 000000000000..2848e226dc1c --- /dev/null +++ b/store/cronos/config/toml.go @@ -0,0 +1,32 @@ +package config + +// DefaultConfigTemplate defines the configuration template for the memiavl configuration +const DefaultConfigTemplate = ` +############################################################################### +### MemIAVL Configuration ### +############################################################################### + +[memiavl] + +# Enable defines if the memiavl should be enabled. +enable = {{ .MemIAVL.Enable }} + +# ZeroCopy defines if the memiavl should return slices pointing to mmap-ed buffers directly (zero-copy), +# the zero-copied slices must not be retained beyond current block's execution. +# the sdk address cache will be disabled if zero-copy is enabled. +zero-copy = {{ .MemIAVL.ZeroCopy }} + +# AsyncCommitBuffer defines the size of asynchronous commit queue, this greatly improve block catching-up +# performance, -1 means synchronous commit. +async-commit-buffer = {{ .MemIAVL.AsyncCommitBuffer }} + +# SnapshotKeepRecent defines what many old snapshots (excluding the latest one) to keep after new snapshots are +# taken, defaults to 1 to make sure ibc relayers work. +snapshot-keep-recent = {{ .MemIAVL.SnapshotKeepRecent }} + +# SnapshotInterval defines the block interval the memiavl snapshot is taken, default to 1000. +snapshot-interval = {{ .MemIAVL.SnapshotInterval }} + +# CacheSize defines the size of the cache for each memiavl store, default to 1000. +cache-size = {{ .MemIAVL.CacheSize }} +` diff --git a/store/cronos/memiavlstore/store.go b/store/cronos/memiavlstore/store.go new file mode 100644 index 000000000000..fb8461bdf584 --- /dev/null +++ b/store/cronos/memiavlstore/store.go @@ -0,0 +1,215 @@ +package memiavlstore + +import ( + "fmt" + "io" + + cmtprotocrypto "github.com/cometbft/cometbft/api/cometbft/crypto/v1" + ics23 "github.com/cosmos/ics23/go" + "github.com/crypto-org-chain/cronos/memiavl" + + "cosmossdk.io/errors" + "cosmossdk.io/log" + "cosmossdk.io/store/cachekv" + pruningtypes "cosmossdk.io/store/pruning/types" + "cosmossdk.io/store/tracekv" + "cosmossdk.io/store/types" +) + +var ( + _ types.KVStore = (*Store)(nil) + _ types.CommitStore = (*Store)(nil) + _ types.CommitKVStore = (*Store)(nil) + _ types.Queryable = (*Store)(nil) +) + +var () + +// Store Implements types.KVStore and CommitKVStore. +type Store struct { + tree *memiavl.Tree + logger log.Logger + + changeSet memiavl.ChangeSet +} + +func New(tree *memiavl.Tree, logger log.Logger) *Store { + return &Store{tree: tree, logger: logger} +} + +func (st *Store) SetTree(tree *memiavl.Tree) { + st.tree = tree +} + +func (st *Store) Commit() types.CommitID { + panic("memiavl store is not supposed to be committed alone") +} + +func (st *Store) LastCommitID() types.CommitID { + hash := st.tree.RootHash() + return types.CommitID{ + Version: st.tree.Version(), + Hash: hash, + } +} + +// SetPruning panics as pruning options should be provided at initialization +// since IAVl accepts pruning options directly. +func (st *Store) SetPruning(_ pruningtypes.PruningOptions) { + panic("cannot set pruning options on an initialized IAVL store") +} + +// GetPruning panics as pruning options should be provided at initialization +// since IAVl accepts pruning options directly. +func (st *Store) GetPruning() pruningtypes.PruningOptions { + panic("cannot get pruning options on an initialized IAVL store") +} + +// GetStoreType Implements Store. +func (st *Store) GetStoreType() types.StoreType { + return types.StoreTypeIAVL +} + +func (st *Store) CacheWrap() types.CacheWrap { + return cachekv.NewStore(st) +} + +// CacheWrapWithTrace implements the Store interface. +func (st *Store) CacheWrapWithTrace(w io.Writer, tc types.TraceContext) types.CacheWrap { + return cachekv.NewStore(tracekv.NewStore(st, w, tc)) +} + +// Set Implements types.KVStore. +// we assume Set is only called in `Commit`, so the written state is only visible after commit. +func (st *Store) Set(key, value []byte) { + st.changeSet.Pairs = append(st.changeSet.Pairs, &memiavl.KVPair{ + Key: key, Value: value, + }) +} + +// Get Implements types.KVStore. +func (st *Store) Get(key []byte) []byte { + return st.tree.Get(key) +} + +// Has Implements types.KVStore. +func (st *Store) Has(key []byte) bool { + return st.tree.Has(key) +} + +// Delete Implements types.KVStore. +// we assume Delete is only called in `Commit`, so the written state is only visible after commit. +func (st *Store) Delete(key []byte) { + st.changeSet.Pairs = append(st.changeSet.Pairs, &memiavl.KVPair{ + Key: key, Delete: true, + }) +} + +func (st *Store) Iterator(start, end []byte) types.Iterator { + return st.tree.Iterator(start, end, true) +} + +func (st *Store) ReverseIterator(start, end []byte) types.Iterator { + return st.tree.Iterator(start, end, false) +} + +// SetInitialVersion sets the initial version of the IAVL tree. It is used when +// starting a new chain at an arbitrary height. +// implements interface StoreWithInitialVersion +func (st *Store) SetInitialVersion(version int64) { + panic("memiavl store's SetInitialVersion is not supposed to be called directly") +} + +// PopChangeSet returns the change set and clear it +func (st *Store) PopChangeSet() memiavl.ChangeSet { + cs := st.changeSet + st.changeSet = memiavl.ChangeSet{} + return cs +} + +func (st *Store) Query(req *types.RequestQuery) (res *types.ResponseQuery, err error) { + if len(req.Data) == 0 { + return nil, errors.Wrap(types.ErrTxDecode, "query cannot be zero length") + } + + if req.Height > 0 && req.Height != st.tree.Version() { + return nil, errors.Wrap(types.ErrInvalidHeight, "invalid height") + } + + res = &types.ResponseQuery{ + Height: st.tree.Version(), + } + + switch req.Path { + case "/key": // get by key + res.Key = req.Data // data holds the key bytes + res.Value = st.tree.Get(res.Key) + + if !req.Prove { + break + } + + // get proof from tree and convert to merkle.Proof before adding to result + res.ProofOps = getProofFromTree(st.tree, req.Data, res.Value != nil) + case "/subspace": + pairs := memiavl.Pairs{ + Pairs: make([]memiavl.Pair, 0), + } + + subspace := req.Data + res.Key = subspace + + iterator := types.KVStorePrefixIterator(st, subspace) + for ; iterator.Valid(); iterator.Next() { + pairs.Pairs = append(pairs.Pairs, memiavl.Pair{Key: iterator.Key(), Value: iterator.Value()}) + } + err := iterator.Close() + if err != nil { + return nil, errors.Wrapf(err, "failed to close iterator") + } + + bz, err := pairs.Marshal() + if err != nil { + return nil, errors.Wrapf(err, "failed to marshal KV pairs") + } + + res.Value = bz + default: + return nil, errors.Wrapf(types.ErrUnknownRequest, "unexpected query path: %v", req.Path) + } + + return res, nil +} + +func (st *Store) WorkingHash() []byte { + return st.tree.RootHash() +} + +// Takes a MutableTree, a key, and a flag for creating existence or absence proof and returns the +// appropriate merkle.Proof. Since this must be called after querying for the value, this function should never error +// Thus, it will panic on error rather than returning it +func getProofFromTree(tree *memiavl.Tree, key []byte, exists bool) *cmtprotocrypto.ProofOps { + var ( + commitmentProof *ics23.CommitmentProof + err error + ) + + if exists { + // value was found + 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())) + } + } else { + // value wasn't found + 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())) + } + } + + op := types.NewIavlCommitmentOp(key, commitmentProof) + return &cmtprotocrypto.ProofOps{Ops: []cmtprotocrypto.ProofOp{op.ProofOp()}} +} diff --git a/store/cronos/rootmulti/import.go b/store/cronos/rootmulti/import.go new file mode 100644 index 000000000000..45e0f97c0792 --- /dev/null +++ b/store/cronos/rootmulti/import.go @@ -0,0 +1,92 @@ +package rootmulti + +import ( + "errors" + "fmt" + "io" + "math" + + protoio "github.com/cosmos/gogoproto/io" + "github.com/crypto-org-chain/cronos/memiavl" + + cosmoserrors "cosmossdk.io/errors" + "cosmossdk.io/store/snapshots/types" + storetypes "cosmossdk.io/store/types" +) + +// Restore Implements interface Snapshotter +func (rs *Store) Restore( + height uint64, format uint32, protoReader protoio.Reader, +) (types.SnapshotItem, error) { + if rs.db != nil { + if err := rs.db.Close(); err != nil { + return types.SnapshotItem{}, fmt.Errorf("failed to close db: %w", err) + } + rs.db = nil + } + + item, err := rs.restore(height, format, protoReader) + if err != nil { + return types.SnapshotItem{}, err + } + + return item, rs.LoadLatestVersion() +} + +func (rs *Store) restore( + height uint64, format uint32, protoReader protoio.Reader, +) (types.SnapshotItem, error) { + importer, err := memiavl.NewMultiTreeImporter(rs.dir, height) + if err != nil { + return types.SnapshotItem{}, err + } + defer importer.Close() + + var snapshotItem types.SnapshotItem +loop: + for { + snapshotItem = types.SnapshotItem{} + err := protoReader.ReadMsg(&snapshotItem) + if errors.Is(err, io.EOF) { + break + } else if err != nil { + return types.SnapshotItem{}, cosmoserrors.Wrap(err, "invalid protobuf message") + } + + switch item := snapshotItem.Item.(type) { + case *types.SnapshotItem_Store: + if err := importer.AddTree(item.Store.Name); err != nil { + return types.SnapshotItem{}, err + } + case *types.SnapshotItem_IAVL: + if item.IAVL.Height > math.MaxInt8 { + return types.SnapshotItem{}, cosmoserrors.Wrapf(storetypes.ErrLogic, "node height %v cannot exceed %v", + item.IAVL.Height, math.MaxInt8) + } + node := &memiavl.ExportNode{ + Key: item.IAVL.Key, + Value: item.IAVL.Value, + Height: int8(item.IAVL.Height), + Version: item.IAVL.Version, + } + // Protobuf does not differentiate between []byte{} as nil, but fortunately IAVL does + // not allow nil keys nor nil values for leaf nodes, so we can always set them to empty. + if node.Key == nil { + node.Key = []byte{} + } + if node.Height == 0 && node.Value == nil { + node.Value = []byte{} + } + importer.AddNode(node) + default: + // unknown element, could be an extension + break loop + } + } + + if err := importer.Finalize(); err != nil { + return types.SnapshotItem{}, err + } + + return snapshotItem, nil +} diff --git a/store/cronos/rootmulti/objstore.go b/store/cronos/rootmulti/objstore.go new file mode 100644 index 000000000000..6840d0de79a4 --- /dev/null +++ b/store/cronos/rootmulti/objstore.go @@ -0,0 +1,34 @@ +//go:build objstore +// +build objstore + +package rootmulti + +import ( + "fmt" + + "github.com/crypto-org-chain/cronos/memiavl" + + "cosmossdk.io/store/transient" + "cosmossdk.io/store/types" +) + +// GetObjKVStore Implements interface MultiStore +func (rs *Store) GetObjKVStore(key types.StoreKey) types.ObjKVStore { + s, ok := rs.stores[key].(types.ObjKVStore) + if !ok { + panic(fmt.Sprintf("store with key %v is not ObjKVStore", key)) + } + return s +} + +func (rs *Store) loadExtraStore(db *memiavl.DB, key types.StoreKey, params storeParams) (types.CommitStore, error) { + if params.typ == types.StoreTypeObject { + if _, ok := key.(*types.ObjectStoreKey); !ok { + return nil, fmt.Errorf("unexpected key type for a ObjectStoreKey; got: %s, %T", key.String(), key) + } + + return transient.NewObjStore(), nil + } + + panic(fmt.Sprintf("unrecognized store type %v", params.typ)) +} diff --git a/store/cronos/rootmulti/objstore_placeholder.go b/store/cronos/rootmulti/objstore_placeholder.go new file mode 100644 index 000000000000..ce3d57cf5b4e --- /dev/null +++ b/store/cronos/rootmulti/objstore_placeholder.go @@ -0,0 +1,15 @@ +//go:build !objstore +// +build !objstore + +package rootmulti + +import ( + "fmt" + + "cosmossdk.io/store/types" + "github.com/crypto-org-chain/cronos/memiavl" +) + +func (rs *Store) loadExtraStore(db *memiavl.DB, key types.StoreKey, params storeParams) (types.CommitStore, error) { + panic(fmt.Sprintf("unrecognized store type %v", params.typ)) +} diff --git a/store/cronos/rootmulti/snapshot.go b/store/cronos/rootmulti/snapshot.go new file mode 100644 index 000000000000..25f82089fd9d --- /dev/null +++ b/store/cronos/rootmulti/snapshot.go @@ -0,0 +1,70 @@ +package rootmulti + +import ( + "errors" + "fmt" + "math" + + protoio "github.com/cosmos/gogoproto/io" + "github.com/crypto-org-chain/cronos/memiavl" + + "cosmossdk.io/store/snapshots/types" +) + +// Snapshot Implements interface Snapshotter +func (rs *Store) Snapshot(height uint64, protoWriter protoio.Writer) (returnErr error) { + if height > math.MaxUint32 { + return fmt.Errorf("height overflows uint32: %d", height) + } + version := uint32(height) + + exporter, err := memiavl.NewMultiTreeExporter(rs.dir, version, rs.supportExportNonSnapshotVersion) + if err != nil { + return err + } + + defer func() { + returnErr = errors.Join(returnErr, exporter.Close()) + }() + + for { + item, err := exporter.Next() + if err != nil { + if errors.Is(err, memiavl.ErrorExportDone) { + break + } + + return err + } + + switch item := item.(type) { + case *memiavl.ExportNode: + if err := protoWriter.WriteMsg(&types.SnapshotItem{ + Item: &types.SnapshotItem_IAVL{ + IAVL: &types.SnapshotIAVLItem{ + Key: item.Key, + Value: item.Value, + Height: int32(item.Height), + Version: item.Version, + }, + }, + }); err != nil { + return err + } + case string: + if err := protoWriter.WriteMsg(&types.SnapshotItem{ + Item: &types.SnapshotItem_Store{ + Store: &types.SnapshotStoreItem{ + Name: item, + }, + }, + }); err != nil { + return err + } + default: + return fmt.Errorf("unknown item type %T", item) + } + } + + return nil +} diff --git a/store/cronos/rootmulti/store.go b/store/cronos/rootmulti/store.go new file mode 100644 index 000000000000..e4a8ce3d1ca3 --- /dev/null +++ b/store/cronos/rootmulti/store.go @@ -0,0 +1,665 @@ +package rootmulti + +import ( + "fmt" + "io" + "math" + "sort" + "strings" + + "cosmossdk.io/store/cronos/cachemulti" + "cosmossdk.io/store/cronos/memiavlstore" + dbm "github.com/cosmos/cosmos-db" + "github.com/crypto-org-chain/cronos/memiavl" + + "cosmossdk.io/errors" + "cosmossdk.io/log" + "cosmossdk.io/store/listenkv" + "cosmossdk.io/store/mem" + "cosmossdk.io/store/metrics" + pruningtypes "cosmossdk.io/store/pruning/types" + "cosmossdk.io/store/rootmulti" + "cosmossdk.io/store/transient" + "cosmossdk.io/store/types" +) + +const CommitInfoFileName = "commit_infos" + +var ( + _ types.CommitMultiStore = (*Store)(nil) + _ types.Queryable = (*Store)(nil) +) + +type Store struct { + dir string + db *memiavl.DB + logger log.Logger + + // to keep it comptaible with cosmos-sdk 0.46, merge the memstores into commit info + lastCommitInfo *types.CommitInfo + + storesParams map[types.StoreKey]storeParams + keysByName map[string]types.StoreKey + stores map[types.StoreKey]types.CommitStore + listeners map[types.StoreKey]*types.MemoryListener + + opts memiavl.Options + + // sdk46Compact defines if the root hash is compatible with cosmos-sdk 0.46 and before. + sdk46Compact bool + // it's more efficient to export snapshot versions, we can filter out the non-snapshot versions + supportExportNonSnapshotVersion bool +} + +func NewStore(dir string, logger log.Logger, sdk46Compact, supportExportNonSnapshotVersion bool) *Store { + return &Store{ + dir: dir, + logger: logger, + sdk46Compact: sdk46Compact, + supportExportNonSnapshotVersion: supportExportNonSnapshotVersion, + + storesParams: make(map[types.StoreKey]storeParams), + keysByName: make(map[string]types.StoreKey), + stores: make(map[types.StoreKey]types.CommitStore), + listeners: make(map[types.StoreKey]*types.MemoryListener), + } +} + +// flush writes all the pending change sets to memiavl tree. +func (rs *Store) flush() error { + var changeSets []*memiavl.NamedChangeSet + for key := range rs.stores { + // it'll unwrap the inter-block cache + store := rs.GetCommitStore(key) + if memiavlStore, ok := store.(*memiavlstore.Store); ok { + cs := memiavlStore.PopChangeSet() + if len(cs.Pairs) > 0 { + changeSets = append(changeSets, &memiavl.NamedChangeSet{ + Name: key.Name(), + Changeset: cs, + }) + } + } + } + sort.SliceStable(changeSets, func(i, j int) bool { + return changeSets[i].Name < changeSets[j].Name + }) + + return rs.db.ApplyChangeSets(changeSets) +} + +// WorkingHash returns the app hash of the working tree, +// +// Implements interface Committer. +func (rs *Store) WorkingHash() []byte { + if err := rs.flush(); err != nil { + panic(err) + } + commitInfo := convertCommitInfo(rs.db.WorkingCommitInfo()) + if rs.sdk46Compact { + commitInfo = amendCommitInfo(commitInfo, rs.storesParams) + } + return commitInfo.Hash() +} + +// Commit Implements interface Committer +func (rs *Store) Commit() types.CommitID { + if err := rs.flush(); err != nil { + panic(err) + } + + for _, store := range rs.stores { + if store.GetStoreType() != types.StoreTypeIAVL { + _ = store.Commit() + } + } + + _, err := rs.db.Commit() + if err != nil { + panic(err) + } + + // the underlying memiavl tree might be reloaded, update the tree. + for key := range rs.stores { + store := rs.stores[key] + if store.GetStoreType() == types.StoreTypeIAVL { + store.(*memiavlstore.Store).SetTree(rs.db.TreeByName(key.Name())) + } + } + + rs.lastCommitInfo = convertCommitInfo(rs.db.LastCommitInfo()) + if rs.sdk46Compact { + rs.lastCommitInfo = amendCommitInfo(rs.lastCommitInfo, rs.storesParams) + } + return rs.lastCommitInfo.CommitID() +} + +func (rs *Store) Close() error { + return rs.db.Close() +} + +// LastCommitID Implements interface Committer +func (rs *Store) LastCommitID() types.CommitID { + if rs.lastCommitInfo == nil { + v, err := memiavl.GetLatestVersion(rs.dir) + if err != nil { + panic(fmt.Errorf("failed to get latest version: %w", err)) + } + return types.CommitID{Version: v} + } + + return rs.lastCommitInfo.CommitID() +} + +// SetPruning Implements interface Committer +func (rs *Store) SetPruning(pruningtypes.PruningOptions) { +} + +// SetMetrics sets the metrics gatherer for the store package +func (rs *Store) SetMetrics(metrics metrics.StoreMetrics) { +} + +// GetPruning Implements interface Committer +func (rs *Store) GetPruning() pruningtypes.PruningOptions { + return pruningtypes.NewPruningOptions(pruningtypes.PruningDefault) +} + +// GetStoreType Implements interface Store +func (rs *Store) GetStoreType() types.StoreType { + return types.StoreTypeMulti +} + +// CacheWrap Implements interface CacheWrapper +func (rs *Store) CacheWrap() types.CacheWrap { + return rs.CacheMultiStore().(types.CacheWrap) +} + +// CacheWrapWithTrace Implements interface CacheWrapper +func (rs *Store) CacheWrapWithTrace(_ io.Writer, _ types.TraceContext) types.CacheWrap { + return rs.CacheWrap() +} + +// CacheMultiStore Implements interface MultiStore +func (rs *Store) CacheMultiStore() types.CacheMultiStore { + stores := make(map[types.StoreKey]types.CacheWrapper) + for k, v := range rs.stores { + store := types.CacheWrapper(v) + if kv, ok := store.(types.KVStore); ok { + // Wire the listenkv.Store to allow listeners to observe the writes from the cache store, + // set same listeners on cache store will observe duplicated writes. + if rs.ListeningEnabled(k) { + store = listenkv.NewStore(kv, k, rs.listeners[k]) + } + } + stores[k] = store + } + return cachemulti.NewStore(stores, nil, nil, nil) +} + +// CacheMultiStoreWithVersion Implements interface MultiStore +// used to createQueryContext, abci_query or grpc query service. +func (rs *Store) CacheMultiStoreWithVersion(version int64) (types.CacheMultiStore, error) { + if version == 0 || (rs.lastCommitInfo != nil && version == rs.lastCommitInfo.Version) { + return rs.CacheMultiStore(), nil + } + opts := rs.opts + opts.TargetVersion = uint32(version) + opts.ReadOnly = true + db, err := memiavl.Load(rs.dir, opts) + if err != nil { + return nil, err + } + + stores := make(map[types.StoreKey]types.CacheWrapper) + + // add the transient/mem stores registered in current app. + for k, store := range rs.stores { + if store.GetStoreType() != types.StoreTypeIAVL { + stores[k] = store + } + } + + // add all the iavl stores at the target version. + for _, tree := range db.Trees() { + stores[rs.keysByName[tree.Name]] = memiavlstore.New(tree.Tree, rs.logger) + } + + return cachemulti.NewStore(stores, nil, nil, nil), nil +} + +// GetStore Implements interface MultiStore +func (rs *Store) GetStore(key types.StoreKey) types.Store { + s, ok := rs.stores[key] + if !ok { + panic(fmt.Sprintf("store does not exist for key: %s", key.Name())) + } + return s +} + +// GetKVStore Implements interface MultiStore +func (rs *Store) GetKVStore(key types.StoreKey) types.KVStore { + s, ok := rs.GetStore(key).(types.KVStore) + if !ok { + panic(fmt.Sprintf("store with key %v is not KVStore", key)) + } + return s +} + +// TracingEnabled Implements interface MultiStore +func (rs *Store) TracingEnabled() bool { + return false +} + +// SetTracer Implements interface MultiStore +func (rs *Store) SetTracer(w io.Writer) types.MultiStore { + return nil +} + +// SetTracingContext Implements interface MultiStore +func (rs *Store) SetTracingContext(types.TraceContext) types.MultiStore { + return nil +} + +// LatestVersion Implements interface MultiStore +func (rs *Store) LatestVersion() int64 { + return rs.db.Version() +} + +// PruneSnapshotHeight Implements interface Snapshotter +// not needed, memiavl manage its own snapshot/pruning strategy +func (rs *Store) PruneSnapshotHeight(height int64) { +} + +// SetSnapshotInterval Implements interface Snapshotter +// not needed, memiavl manage its own snapshot/pruning strategy +func (rs *Store) SetSnapshotInterval(snapshotInterval uint64) { +} + +// MountStoreWithDB Implements interface CommitMultiStore +func (rs *Store) MountStoreWithDB(key types.StoreKey, typ types.StoreType, _ dbm.DB) { + if key == nil { + panic("MountIAVLStore() key cannot be nil") + } + if _, ok := rs.storesParams[key]; ok { + panic(fmt.Sprintf("store duplicate store key %v", key)) + } + if _, ok := rs.keysByName[key.Name()]; ok { + panic(fmt.Sprintf("store duplicate store key name %v", key)) + } + rs.storesParams[key] = newStoreParams(key, typ) + rs.keysByName[key.Name()] = key +} + +// GetCommitStore Implements interface CommitMultiStore +func (rs *Store) GetCommitStore(key types.StoreKey) types.CommitStore { + return rs.stores[key] +} + +// GetCommitKVStore Implements interface CommitMultiStore +func (rs *Store) GetCommitKVStore(key types.StoreKey) types.CommitKVStore { + store, ok := rs.GetCommitStore(key).(types.CommitKVStore) + if !ok { + panic(fmt.Sprintf("store with key %v is not CommitKVStore", key)) + } + + return store +} + +// LoadLatestVersion Implements interface CommitMultiStore +// used by normal node startup. +func (rs *Store) LoadLatestVersion() error { + return rs.LoadVersionAndUpgrade(0, nil) +} + +// LoadLatestVersionAndUpgrade Implements interface CommitMultiStore +func (rs *Store) LoadLatestVersionAndUpgrade(upgrades *types.StoreUpgrades) error { + return rs.LoadVersionAndUpgrade(0, upgrades) +} + +// LoadVersionAndUpgrade Implements interface CommitMultiStore +// used by node startup with UpgradeStoreLoader +func (rs *Store) LoadVersionAndUpgrade(version int64, upgrades *types.StoreUpgrades) error { + if version > math.MaxUint32 { + return fmt.Errorf("version overflows uint32: %d", version) + } + + storesKeys := make([]types.StoreKey, 0, len(rs.storesParams)) + for key := range rs.storesParams { + storesKeys = append(storesKeys, key) + } + // deterministic iteration order for upgrades + sort.Slice(storesKeys, func(i, j int) bool { + return storesKeys[i].Name() < storesKeys[j].Name() + }) + + initialStores := make([]string, 0, len(storesKeys)) + for _, key := range storesKeys { + if rs.storesParams[key].typ == types.StoreTypeIAVL { + initialStores = append(initialStores, key.Name()) + } + } + + opts := rs.opts + opts.CreateIfMissing = true + opts.InitialStores = initialStores + opts.TargetVersion = uint32(version) + db, err := memiavl.Load(rs.dir, opts) + if err != nil { + return errors.Wrapf(err, "fail to load memiavl at %s", rs.dir) + } + + var treeUpgrades []*memiavl.TreeNameUpgrade + if upgrades != nil { + for _, name := range upgrades.Deleted { + treeUpgrades = append(treeUpgrades, &memiavl.TreeNameUpgrade{Name: name, Delete: true}) + } + for _, name := range upgrades.Added { + treeUpgrades = append(treeUpgrades, &memiavl.TreeNameUpgrade{Name: name}) + } + for _, rename := range upgrades.Renamed { + treeUpgrades = append(treeUpgrades, &memiavl.TreeNameUpgrade{Name: rename.NewKey, RenameFrom: rename.OldKey}) + } + } + + if len(treeUpgrades) > 0 { + if err := db.ApplyUpgrades(treeUpgrades); err != nil { + return err + } + } + + newStores := make(map[types.StoreKey]types.CommitStore, len(storesKeys)) + for _, key := range storesKeys { + newStores[key], err = rs.loadCommitStoreFromParams(db, key, rs.storesParams[key]) + if err != nil { + return err + } + } + + rs.db = db + rs.stores = newStores + // to keep the root hash compatible with cosmos-sdk 0.46 + if db.Version() != 0 { + rs.lastCommitInfo = convertCommitInfo(db.LastCommitInfo()) + if rs.sdk46Compact { + rs.lastCommitInfo = amendCommitInfo(rs.lastCommitInfo, rs.storesParams) + } + } else { + rs.lastCommitInfo = &types.CommitInfo{} + } + + return nil +} + +func (rs *Store) loadCommitStoreFromParams(db *memiavl.DB, key types.StoreKey, params storeParams) (types.CommitStore, error) { + switch params.typ { + case types.StoreTypeMulti: + panic("recursive MultiStores not yet supported") + case types.StoreTypeIAVL: + tree := db.TreeByName(key.Name()) + if tree == nil { + return nil, fmt.Errorf("new store is not added in upgrades: %s", key.Name()) + } + return types.CommitStore(memiavlstore.New(tree, rs.logger)), nil + case types.StoreTypeDB: + panic("recursive MultiStores not yet supported") + case types.StoreTypeTransient: + if _, ok := key.(*types.TransientStoreKey); !ok { + return nil, fmt.Errorf("unexpected key type for a TransientStoreKey; got: %s, %T", key.String(), key) + } + + return transient.NewStore(), nil + + case types.StoreTypeMemory: + if _, ok := key.(*types.MemoryStoreKey); !ok { + return nil, fmt.Errorf("unexpected key type for a MemoryStoreKey; got: %s", key.String()) + } + + return mem.NewStore(), nil + + default: + return rs.loadExtraStore(db, key, params) + } +} + +// LoadVersion Implements interface CommitMultiStore +// used by export cmd +func (rs *Store) LoadVersion(ver int64) error { + return rs.LoadVersionAndUpgrade(ver, nil) +} + +// SetInterBlockCache is a noop here because memiavl do caching on it's own, which works well with zero-copy. +func (rs *Store) SetInterBlockCache(c types.MultiStorePersistentCache) {} + +// SetInitialVersion Implements interface CommitMultiStore +// used by InitChain when the initial height is bigger than 1 +func (rs *Store) SetInitialVersion(version int64) error { + return rs.db.SetInitialVersion(version) +} + +// SetIAVLCacheSize Implements interface CommitMultiStore +func (rs *Store) SetIAVLCacheSize(size int) { +} + +// SetIAVLDisableFastNode Implements interface CommitMultiStore +func (rs *Store) SetIAVLDisableFastNode(disable bool) { +} + +// SetIAVLSyncPruning Implements interface CommitMultiStore +func (rs *Store) SetIAVLSyncPruning(syncPruning bool) { +} + +// SetLazyLoading Implements interface CommitMultiStore +func (rs *Store) SetLazyLoading(lazyLoading bool) { +} + +func (rs *Store) SetMemIAVLOptions(opts memiavl.Options) { + if opts.Logger == nil { + opts.Logger = memiavl.Logger(rs.logger.With("module", "memiavl")) + } + rs.opts = opts +} + +// RollbackToVersion delete the versions after `target` and update the latest version. +// it should only be called in standalone cli commands. +func (rs *Store) RollbackToVersion(target int64) error { + if target <= 0 { + return fmt.Errorf("invalid rollback height target: %d", target) + } + + if target > math.MaxUint32 { + return fmt.Errorf("rollback height target %d exceeds max uint32", target) + } + + if rs.db != nil { + if err := rs.db.Close(); err != nil { + return err + } + } + + opts := rs.opts + opts.TargetVersion = uint32(target) + opts.LoadForOverwriting = true + + var err error + rs.db, err = memiavl.Load(rs.dir, opts) + + return err +} + +// ListeningEnabled Implements interface CommitMultiStore +func (rs *Store) ListeningEnabled(key types.StoreKey) bool { + if ls, ok := rs.listeners[key]; ok { + return ls != nil + } + return false +} + +// AddListeners Implements interface CommitMultiStore +func (rs *Store) AddListeners(keys []types.StoreKey) { + for i := range keys { + listener := rs.listeners[keys[i]] + if listener == nil { + rs.listeners[keys[i]] = types.NewMemoryListener() + } + } +} + +// PopStateCache returns the accumulated state change messages from the CommitMultiStore +// Calling PopStateCache destroys only the currently accumulated state in each listener +// not the state in the store itself. This is a mutating and destructive operation. +// This method has been synchronized. +func (rs *Store) PopStateCache() []*types.StoreKVPair { + var cache []*types.StoreKVPair + for key := range rs.listeners { + ls := rs.listeners[key] + if ls != nil { + cache = append(cache, ls.PopStateCache()...) + } + } + sort.SliceStable(cache, func(i, j int) bool { + return cache[i].StoreKey < cache[j].StoreKey + }) + return cache +} + +// GetStoreByName performs a lookup of a StoreKey given a store name typically +// provided in a path. The StoreKey is then used to perform a lookup and return +// a Store. If the Store is wrapped in an inter-block cache, it will be unwrapped +// prior to being returned. If the StoreKey does not exist, nil is returned. +func (rs *Store) GetStoreByName(name string) types.Store { + key := rs.keysByName[name] + if key == nil { + return nil + } + + return rs.GetCommitStore(key) +} + +// Query Implements interface Queryable +func (rs *Store) Query(req *types.RequestQuery) (*types.ResponseQuery, error) { + version := req.Height + if version == 0 { + version = rs.db.Version() + } + + // If the request's height is the latest height we've committed, then utilize + // the store's lastCommitInfo as this commit info may not be flushed to disk. + // Otherwise, we query for the commit info from disk. + db := rs.db + if version != rs.lastCommitInfo.Version { + var err error + db, err = memiavl.Load(rs.dir, memiavl.Options{TargetVersion: uint32(version), ReadOnly: true}) + if err != nil { + return nil, err + } + defer db.Close() + } + + path := req.Path + storeName, subpath, err := parsePath(path) + if err != nil { + return nil, err + } + + store := types.Queryable(memiavlstore.New(db.TreeByName(storeName), rs.logger)) + + // trim the path and make the query + req.Path = subpath + res, err := store.Query(req) + if err != nil { + return nil, err + } + + if !req.Prove || !rootmulti.RequireProof(subpath) { + return res, nil + } + + if res.ProofOps == nil || len(res.ProofOps.Ops) == 0 { + return nil, errors.Wrap(types.ErrInvalidRequest, "proof is unexpectedly empty; ensure height has not been pruned") + } + + commitInfo := convertCommitInfo(db.LastCommitInfo()) + if rs.sdk46Compact { + commitInfo = amendCommitInfo(commitInfo, rs.storesParams) + } + + // Restore origin path and append proof op. + res.ProofOps.Ops = append(res.ProofOps.Ops, commitInfo.ProofOp(storeName)) + + return res, nil +} + +// parsePath expects a format like /[/] +// Must start with /, subpath may be empty +// Returns error if it doesn't start with / +func parsePath(path string) (storeName, subpath string, err error) { + if !strings.HasPrefix(path, "/") { + return storeName, subpath, errors.Wrapf(types.ErrUnknownRequest, "invalid path: %s", path) + } + + paths := strings.SplitN(path[1:], "/", 2) + storeName = paths[0] + + if len(paths) == 2 { + subpath = "/" + paths[1] + } + + return storeName, subpath, nil +} + +type storeParams struct { + key types.StoreKey + typ types.StoreType +} + +func newStoreParams(key types.StoreKey, typ types.StoreType) storeParams { + return storeParams{ + key: key, + typ: typ, + } +} + +func mergeStoreInfos(commitInfo *types.CommitInfo, storeInfos []types.StoreInfo) *types.CommitInfo { + infos := make([]types.StoreInfo, 0, len(commitInfo.StoreInfos)+len(storeInfos)) + infos = append(infos, commitInfo.StoreInfos...) + infos = append(infos, storeInfos...) + sort.SliceStable(infos, func(i, j int) bool { + return infos[i].Name < infos[j].Name + }) + return &types.CommitInfo{ + Version: commitInfo.Version, + StoreInfos: infos, + } +} + +// amendCommitInfo add mem stores commit infos to keep it compatible with cosmos-sdk 0.46 +func amendCommitInfo(commitInfo *types.CommitInfo, storeParams map[types.StoreKey]storeParams) *types.CommitInfo { + var extraStoreInfos []types.StoreInfo + for key := range storeParams { + typ := storeParams[key].typ + if typ != types.StoreTypeIAVL && typ != types.StoreTypeTransient { + extraStoreInfos = append(extraStoreInfos, types.StoreInfo{ + Name: key.Name(), + CommitId: types.CommitID{}, + }) + } + } + return mergeStoreInfos(commitInfo, extraStoreInfos) +} + +func convertCommitInfo(commitInfo *memiavl.CommitInfo) *types.CommitInfo { + storeInfos := make([]types.StoreInfo, len(commitInfo.StoreInfos)) + for i, storeInfo := range commitInfo.StoreInfos { + storeInfos[i] = types.StoreInfo{ + Name: storeInfo.Name, + CommitId: types.CommitID{ + Version: storeInfo.CommitId.Version, + Hash: storeInfo.CommitId.Hash, + }, + } + } + return &types.CommitInfo{ + Version: commitInfo.Version, + StoreInfos: storeInfos, + } +} diff --git a/store/cronos/rootmulti/store_test.go b/store/cronos/rootmulti/store_test.go new file mode 100644 index 000000000000..2880aeb9ac96 --- /dev/null +++ b/store/cronos/rootmulti/store_test.go @@ -0,0 +1,15 @@ +package rootmulti + +import ( + "testing" + + "github.com/stretchr/testify/require" + + "cosmossdk.io/log" + "cosmossdk.io/store/types" +) + +func TestLastCommitID(t *testing.T) { + store := NewStore(t.TempDir(), log.NewNopLogger(), false, false) + require.Equal(t, types.CommitID{}, store.LastCommitID()) +} diff --git a/store/go.mod b/store/go.mod index bb9e4fc8d289..e48366c8db82 100644 --- a/store/go.mod +++ b/store/go.mod @@ -13,6 +13,7 @@ require ( github.com/cosmos/gogoproto v1.7.0 github.com/cosmos/iavl v1.2.6 github.com/cosmos/ics23/go v0.11.0 + github.com/crypto-org-chain/cronos/memiavl v0.1.0 github.com/hashicorp/go-hclog v1.6.3 github.com/hashicorp/go-metrics v0.5.4 github.com/hashicorp/go-plugin v1.6.3 @@ -25,6 +26,17 @@ require ( gotest.tools/v3 v3.5.2 ) +require ( + github.com/alitto/pond v1.8.3 // indirect + github.com/ledgerwatch/erigon-lib v0.0.0-20230210071639-db0e7ed11263 // indirect + github.com/tidwall/gjson v1.10.2 // indirect + github.com/tidwall/match v1.1.1 // indirect + github.com/tidwall/pretty v1.2.0 // indirect + github.com/tidwall/tinylru v1.1.0 // indirect + github.com/tidwall/wal v1.1.7 // indirect + github.com/zbiljic/go-filelock v0.0.0-20170914061330-1dbf7103ab7d // indirect +) + require ( github.com/DataDog/zstd v1.5.7 // indirect github.com/beorn7/perks v1.0.1 // indirect diff --git a/store/go.sum b/store/go.sum index b5eef93da794..a23bf52b45ec 100644 --- a/store/go.sum +++ b/store/go.sum @@ -13,6 +13,8 @@ github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751/go.mod h1:LOuy github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0= github.com/alecthomas/units v0.0.0-20190717042225-c3de453c63f4/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0= github.com/alecthomas/units v0.0.0-20190924025748-f65c72e2690d/go.mod h1:rBZYJk541a8SKzHPHnH3zbiI+7dagKZ0cgpgrD7Fyho= +github.com/alitto/pond v1.8.3 h1:ydIqygCLVPqIX/USe5EaV/aSRXTRXDEI9JwuDdu+/xs= +github.com/alitto/pond v1.8.3/go.mod h1:CmvIIGd5jKLasGI3D87qDkQxjzChdKMmnXMg3fG6M6Q= github.com/armon/go-metrics v0.4.1/go.mod h1:E6amYzXo6aW1tqzoZGT755KkbgrJsSdpwZ+3JqfkOG4= github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q= github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8= @@ -66,6 +68,8 @@ github.com/cosmos/iavl v1.2.6/go.mod h1:GiM43q0pB+uG53mLxLDzimxM9l/5N9UuSY3/D0hu github.com/cosmos/ics23/go v0.11.0 h1:jk5skjT0TqX5e5QJbEnwXIS2yI2vnmLOgpQPeM5RtnU= github.com/cosmos/ics23/go v0.11.0/go.mod h1:A8OjxPE67hHST4Icw94hOxxFEJMBG031xIGF/JHNIY0= github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= +github.com/crypto-org-chain/cronos/memiavl v0.1.0 h1:bHjD9mdra/SoByljilIgIkm2Tavkswy4qT6SLvVzDic= +github.com/crypto-org-chain/cronos/memiavl v0.1.0/go.mod h1:IyRvgFKOQPC/Qdx543PGl6WgeDOU+hWdv+xLz3stotc= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc h1:U9qPSI2PIWSS1VwoXQT9A3Wy9MM3WgvqSxFWenqJduM= @@ -182,6 +186,8 @@ github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= +github.com/ledgerwatch/erigon-lib v0.0.0-20230210071639-db0e7ed11263 h1:LGEzZvf33Y1NhuP5+jI/ni9l1TFS6oYPDilgy74NusM= +github.com/ledgerwatch/erigon-lib v0.0.0-20230210071639-db0e7ed11263/go.mod h1:OXgMDuUo2lZ3NpH29ZvMYbk+LxFd5ffDl2Z2mGMuY/I= github.com/linxGnu/grocksdb v1.10.1 h1:YX6gUcKvSC3d0s9DaqgbU+CRkZHzlELgHu1Z/kmtslg= github.com/linxGnu/grocksdb v1.10.1/go.mod h1:C3CNe9UYc9hlEM2pC82AqiGS3LRW537u9LFV4wIZuHk= github.com/mattn/go-colorable v0.1.9/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc= @@ -292,11 +298,23 @@ github.com/syndtr/goleveldb v1.0.1-0.20220721030215-126854af5e6d h1:vfofYNRScrDd github.com/syndtr/goleveldb v1.0.1-0.20220721030215-126854af5e6d/go.mod h1:RRCYJbIwD5jmqPI9XoAFR0OcDxqUctll6zUj/+B4S48= github.com/tidwall/btree v1.8.0 h1:kHHy8hSBauQUe0KPHMFLOt0olAj1nDnkHPJhr8+HFkM= github.com/tidwall/btree v1.8.0/go.mod h1:jBbTdUWhSZClZWoDg54VnvV7/54modSOzDN7VXftj1A= +github.com/tidwall/gjson v1.10.2 h1:APbLGOM0rrEkd8WBw9C24nllro4ajFuJu0Sc9hRz8Bo= +github.com/tidwall/gjson v1.10.2/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk= +github.com/tidwall/match v1.1.1 h1:+Ho715JplO36QYgwN9PGYNhgZvoUSc9X2c80KVTi+GA= +github.com/tidwall/match v1.1.1/go.mod h1:eRSPERbgtNPcGhD8UCthc6PmLEQXEWd3PRB5JTxsfmM= +github.com/tidwall/pretty v1.2.0 h1:RWIZEg2iJ8/g6fDDYzMpobmaoGh5OLl4AXtGUGPcqCs= +github.com/tidwall/pretty v1.2.0/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhsoaGGjNU= +github.com/tidwall/tinylru v1.1.0 h1:XY6IUfzVTU9rpwdhKUF6nQdChgCdGjkMfLzbWyiau6I= +github.com/tidwall/tinylru v1.1.0/go.mod h1:3+bX+TJ2baOLMWTnlyNWHh4QMnFyARg2TLTQ6OFbzw8= +github.com/tidwall/wal v1.1.7 h1:emc1TRjIVsdKKSnpwGBAcsAGg0767SvUk8+ygx7Bb+4= +github.com/tidwall/wal v1.1.7/go.mod h1:r6lR1j27W9EPalgHiB7zLJDYu3mzW5BQP5KrzBpYY/E= github.com/tv42/httpunix v0.0.0-20150427012821-b75d8614f926/go.mod h1:9ESjWnEqriFuLhtthL60Sar/7RFoluCcXsuvEwTV5KM= github.com/twitchyliquid64/golang-asm v0.15.1 h1:SU5vSMR7hnwNxj24w34ZyCi/FmDZTkS4MhqMhdFk5YI= github.com/twitchyliquid64/golang-asm v0.15.1/go.mod h1:a1lVb/DtPvCB8fslRZhAngC2+aY1QWCk3Cedj/Gdt08= github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= +github.com/zbiljic/go-filelock v0.0.0-20170914061330-1dbf7103ab7d h1:XQyeLr7N9iY9mi+TGgsBFkj54+j3fdoo8e2u6zrGP5A= +github.com/zbiljic/go-filelock v0.0.0-20170914061330-1dbf7103ab7d/go.mod h1:hoMeDjlNXTNqVwrCk8YDyaBS2g5vFfEX2ezMi4vb6CY= go.opentelemetry.io/auto/sdk v1.1.0 h1:cH53jehLUN6UFLY71z+NDOiNJqDdPRaXzTel0sJySYA= go.opentelemetry.io/auto/sdk v1.1.0/go.mod h1:3wSPjt5PWp2RhlCcmmOial7AvC4DQqZb7a7wCow3W8A= go.opentelemetry.io/otel v1.36.0 h1:UumtzIklRBY6cI/lllNZlALOF5nNIzJVb16APdvgTXg= diff --git a/store/types/errors.go b/store/types/errors.go index db86a3cc6558..3b57665f2141 100644 --- a/store/types/errors.go +++ b/store/types/errors.go @@ -25,4 +25,6 @@ var ( // ErrInvalidRequest defines an ABCI typed error where the request contains // invalid data. ErrInvalidRequest = errors.Register(StoreCodespace, 7, "invalid request") + + ErrInvalidHeight = errors.New(StoreCodespace, 8, "invalid height") ) diff --git a/tests/go.mod b/tests/go.mod index ee61de6ade4c..20291da0646a 100644 --- a/tests/go.mod +++ b/tests/go.mod @@ -50,6 +50,7 @@ require ( github.com/GoogleCloudPlatform/opentelemetry-operations-go/detectors/gcp v1.28.0 // indirect github.com/GoogleCloudPlatform/opentelemetry-operations-go/exporter/metric v0.52.0 // indirect github.com/GoogleCloudPlatform/opentelemetry-operations-go/internal/resourcemapping v0.52.0 // indirect + github.com/alitto/pond v1.8.3 // indirect github.com/aws/aws-sdk-go v1.44.224 // indirect github.com/beorn7/perks v1.0.1 // indirect github.com/bgentry/go-netrc v0.0.0-20140422174119-9fd32a8b3d3d // indirect @@ -75,6 +76,7 @@ require ( github.com/cosmos/iavl v1.2.6 // indirect github.com/cosmos/ics23/go v0.11.0 // indirect github.com/cosmos/ledger-cosmos-go v0.15.0 // indirect + github.com/crypto-org-chain/cronos/memiavl v0.1.0 // indirect github.com/danieljoos/wincred v1.2.2 // indirect github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect github.com/decred/dcrd/dcrec/secp256k1/v4 v4.4.0 // indirect @@ -137,6 +139,7 @@ require ( github.com/klauspost/cpuid/v2 v2.2.10 // indirect github.com/kr/pretty v0.3.1 // indirect github.com/kr/text v0.2.0 // indirect + github.com/ledgerwatch/erigon-lib v0.0.0-20230210071639-db0e7ed11263 // indirect github.com/lib/pq v1.10.9 // indirect github.com/linxGnu/grocksdb v1.10.1 // indirect github.com/lmittmann/tint v1.0.7 // indirect @@ -174,9 +177,15 @@ require ( github.com/subosito/gotenv v1.6.0 // indirect github.com/supranational/blst v0.3.14 // indirect github.com/syndtr/goleveldb v1.0.1-0.20220721030215-126854af5e6d // indirect - github.com/tidwall/btree v1.7.0 // indirect + github.com/tidwall/btree v1.8.0 // indirect + github.com/tidwall/gjson v1.10.2 // indirect + github.com/tidwall/match v1.1.1 // indirect + github.com/tidwall/pretty v1.2.0 // indirect + github.com/tidwall/tinylru v1.1.0 // indirect + github.com/tidwall/wal v1.1.7 // indirect github.com/twitchyliquid64/golang-asm v0.15.1 // indirect github.com/ulikunitz/xz v0.5.11 // indirect + github.com/zbiljic/go-filelock v0.0.0-20170914061330-1dbf7103ab7d // indirect github.com/zeebo/errs v1.4.0 // indirect github.com/zondax/hid v0.9.2 // indirect github.com/zondax/ledger-go v1.0.0 // indirect @@ -213,9 +222,7 @@ require ( // Here are the short-lived replace from the SimApp // Replace here are pending PRs, or version to be tagged -// replace ( -// -// ) +replace cosmossdk.io/store => ../store // Below are the long-lived replace for tests. replace ( diff --git a/tests/go.sum b/tests/go.sum index d072ce93b52a..33e82b4490eb 100644 --- a/tests/go.sum +++ b/tests/go.sum @@ -632,8 +632,6 @@ cosmossdk.io/math v1.5.3 h1:WH6tu6Z3AUCeHbeOSHg2mt9rnoiUWVWaQ2t6Gkll96U= cosmossdk.io/math v1.5.3/go.mod h1:uqcZv7vexnhMFJF+6zh9EWdm/+Ylyln34IvPnBauPCQ= cosmossdk.io/schema v1.1.0 h1:mmpuz3dzouCoyjjcMcA/xHBEmMChN+EHh8EHxHRHhzE= cosmossdk.io/schema v1.1.0/go.mod h1:Gb7pqO+tpR+jLW5qDcNOSv0KtppYs7881kfzakguhhI= -cosmossdk.io/store v1.10.0-rc.2 h1:7ze2UoheVTVMK4ElHtoRhYv8nlUImj34e4yp1yy1bgE= -cosmossdk.io/store v1.10.0-rc.2/go.mod h1:3p1IV4EGsULFfeyAcfj7/DBcDsy8d3VlYIEJnhhbP3U= cosmossdk.io/x/tx v1.2.0-rc.1 h1:AartiA6eiTD9KHmnlj3uG3H8FjyjI0qNkmvmU+p6cJ8= cosmossdk.io/x/tx v1.2.0-rc.1/go.mod h1:UzpMTUmQEFfz+m0E+lhzFIiEhtZCHjScU/NC652DBHI= dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU= @@ -681,6 +679,8 @@ github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751/go.mod h1:LOuy github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0= github.com/alecthomas/units v0.0.0-20190717042225-c3de453c63f4/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0= github.com/alecthomas/units v0.0.0-20190924025748-f65c72e2690d/go.mod h1:rBZYJk541a8SKzHPHnH3zbiI+7dagKZ0cgpgrD7Fyho= +github.com/alitto/pond v1.8.3 h1:ydIqygCLVPqIX/USe5EaV/aSRXTRXDEI9JwuDdu+/xs= +github.com/alitto/pond v1.8.3/go.mod h1:CmvIIGd5jKLasGI3D87qDkQxjzChdKMmnXMg3fG6M6Q= github.com/andybalholm/brotli v1.0.4/go.mod h1:fO7iG3H7G2nSZ7m0zPUDn85XEX2GTukHGRSepvi9Eig= github.com/antihax/optional v1.0.0/go.mod h1:uupD/76wgC+ih3iEmQUL+0Ugr19nfwCT1kdvxnR2qWY= github.com/apache/arrow/go/v10 v10.0.1/go.mod h1:YvhnlEePVnBS4+0z3fhPfUy7W1Ikj0Ih0vcRo/gZ1M0= @@ -829,6 +829,8 @@ github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d/go.mod h1:ma github.com/cpuguy83/go-md2man/v2 v2.0.6/go.mod h1:oOW0eioCTA6cOiMLiUPZOpcVxMig6NIQQ7OS05n1F4g= github.com/creack/pty v1.1.7/go.mod h1:lj5s0c3V2DBrqTV7llrYr5NG6My20zk30Fl46Y7DoTY= github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= +github.com/crypto-org-chain/cronos/memiavl v0.1.0 h1:bHjD9mdra/SoByljilIgIkm2Tavkswy4qT6SLvVzDic= +github.com/crypto-org-chain/cronos/memiavl v0.1.0/go.mod h1:IyRvgFKOQPC/Qdx543PGl6WgeDOU+hWdv+xLz3stotc= github.com/danieljoos/wincred v1.2.2 h1:774zMFJrqaeYCK2W57BgAem/MLi6mtSE47MB6BOJ0i0= github.com/danieljoos/wincred v1.2.2/go.mod h1:w7w4Utbrz8lqeMbDAK0lkNJUv5sAOkFi7nd/ogr0Uh8= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= @@ -1262,6 +1264,8 @@ github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc= github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw= +github.com/ledgerwatch/erigon-lib v0.0.0-20230210071639-db0e7ed11263 h1:LGEzZvf33Y1NhuP5+jI/ni9l1TFS6oYPDilgy74NusM= +github.com/ledgerwatch/erigon-lib v0.0.0-20230210071639-db0e7ed11263/go.mod h1:OXgMDuUo2lZ3NpH29ZvMYbk+LxFd5ffDl2Z2mGMuY/I= github.com/leodido/go-urn v1.2.4 h1:XlAE/cm/ms7TE/VMVoduSpNBoyc2dOxHs5MZSwAN63Q= github.com/leodido/go-urn v1.2.4/go.mod h1:7ZrI8mTSeBSHl/UaRyKQW1qZeMgak41ANeCNaVckg+4= github.com/lib/pq v1.10.9 h1:YXG7RB+JIjhP29X+OtkiDnYaXQwpS4JEWq7dtCCRUEw= @@ -1540,8 +1544,18 @@ github.com/syndtr/goleveldb v1.0.1-0.20220721030215-126854af5e6d h1:vfofYNRScrDd github.com/syndtr/goleveldb v1.0.1-0.20220721030215-126854af5e6d/go.mod h1:RRCYJbIwD5jmqPI9XoAFR0OcDxqUctll6zUj/+B4S48= 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.7.0 h1:L1fkJH/AuEh5zBnnBbmTwQ5Lt+bRJ5A8EWecslvo9iI= -github.com/tidwall/btree v1.7.0/go.mod h1:twD9XRA5jj9VUQGELzDO4HPQTNJsoWWfYEL+EUQ2cKY= +github.com/tidwall/btree v1.8.0 h1:kHHy8hSBauQUe0KPHMFLOt0olAj1nDnkHPJhr8+HFkM= +github.com/tidwall/btree v1.8.0/go.mod h1:jBbTdUWhSZClZWoDg54VnvV7/54modSOzDN7VXftj1A= +github.com/tidwall/gjson v1.10.2 h1:APbLGOM0rrEkd8WBw9C24nllro4ajFuJu0Sc9hRz8Bo= +github.com/tidwall/gjson v1.10.2/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk= +github.com/tidwall/match v1.1.1 h1:+Ho715JplO36QYgwN9PGYNhgZvoUSc9X2c80KVTi+GA= +github.com/tidwall/match v1.1.1/go.mod h1:eRSPERbgtNPcGhD8UCthc6PmLEQXEWd3PRB5JTxsfmM= +github.com/tidwall/pretty v1.2.0 h1:RWIZEg2iJ8/g6fDDYzMpobmaoGh5OLl4AXtGUGPcqCs= +github.com/tidwall/pretty v1.2.0/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhsoaGGjNU= +github.com/tidwall/tinylru v1.1.0 h1:XY6IUfzVTU9rpwdhKUF6nQdChgCdGjkMfLzbWyiau6I= +github.com/tidwall/tinylru v1.1.0/go.mod h1:3+bX+TJ2baOLMWTnlyNWHh4QMnFyARg2TLTQ6OFbzw8= +github.com/tidwall/wal v1.1.7 h1:emc1TRjIVsdKKSnpwGBAcsAGg0767SvUk8+ygx7Bb+4= +github.com/tidwall/wal v1.1.7/go.mod h1:r6lR1j27W9EPalgHiB7zLJDYu3mzW5BQP5KrzBpYY/E= github.com/tmc/grpc-websocket-proxy v0.0.0-20170815181823-89b8d40f7ca8/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U= github.com/tv42/httpunix v0.0.0-20150427012821-b75d8614f926/go.mod h1:9ESjWnEqriFuLhtthL60Sar/7RFoluCcXsuvEwTV5KM= github.com/twitchyliquid64/golang-asm v0.15.1 h1:SU5vSMR7hnwNxj24w34ZyCi/FmDZTkS4MhqMhdFk5YI= @@ -1561,6 +1575,8 @@ github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9dec github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= github.com/yuin/goldmark v1.4.1/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= +github.com/zbiljic/go-filelock v0.0.0-20170914061330-1dbf7103ab7d h1:XQyeLr7N9iY9mi+TGgsBFkj54+j3fdoo8e2u6zrGP5A= +github.com/zbiljic/go-filelock v0.0.0-20170914061330-1dbf7103ab7d/go.mod h1:hoMeDjlNXTNqVwrCk8YDyaBS2g5vFfEX2ezMi4vb6CY= github.com/zeebo/assert v1.3.0/go.mod h1:Pq9JiuJQpG8JLJdtkwrJESF0Foym2/D9XMU5ciN/wJ0= github.com/zeebo/errs v1.4.0 h1:XNdoD/RRMKP7HD0UhJnIzUy74ISdGGxURlYG8HSWSfM= github.com/zeebo/errs v1.4.0/go.mod h1:sgbWHsvVuTPHcqJJGQ1WhI5KbWlHYz+2+2C/LSEtCw4= diff --git a/tests/systemtests/go.mod b/tests/systemtests/go.mod index dfc1a447c36e..65b563e018c1 100644 --- a/tests/systemtests/go.mod +++ b/tests/systemtests/go.mod @@ -2,6 +2,9 @@ module cosmossdk.io/tests/systemtests go 1.23.5 +// temporary replace +replace cosmossdk.io/store => ../../store + replace ( // always use latest versions in tests cosmossdk.io/systemtests => ../../systemtests @@ -32,6 +35,7 @@ require ( github.com/99designs/keyring v1.2.2 // indirect github.com/DataDog/datadog-go v3.2.0+incompatible // indirect github.com/DataDog/zstd v1.5.7 // indirect + github.com/alitto/pond v1.8.3 // indirect github.com/beorn7/perks v1.0.1 // indirect github.com/bgentry/speakeasy v0.2.0 // indirect github.com/bytedance/sonic v1.14.0 // indirect @@ -58,6 +62,7 @@ require ( github.com/cosmos/ics23/go v0.11.0 // indirect github.com/cosmos/ledger-cosmos-go v0.15.0 // indirect github.com/creachadair/tomledit v0.0.28 // indirect + github.com/crypto-org-chain/cronos/memiavl v0.1.0 // indirect github.com/danieljoos/wincred v1.2.2 // indirect github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect github.com/decred/dcrd/dcrec/secp256k1/v4 v4.4.0 // indirect @@ -109,6 +114,7 @@ require ( github.com/klauspost/cpuid/v2 v2.2.10 // indirect github.com/kr/pretty v0.3.1 // indirect github.com/kr/text v0.2.0 // indirect + github.com/ledgerwatch/erigon-lib v0.0.0-20230210071639-db0e7ed11263 // indirect github.com/lib/pq v1.10.9 // indirect github.com/linxGnu/grocksdb v1.10.1 // indirect github.com/lmittmann/tint v1.0.7 // indirect @@ -143,10 +149,13 @@ require ( github.com/supranational/blst v0.3.14 // indirect github.com/syndtr/goleveldb v1.0.1-0.20220721030215-126854af5e6d // indirect github.com/tendermint/go-amino v0.16.0 // indirect - github.com/tidwall/btree v1.7.0 // indirect + github.com/tidwall/btree v1.8.0 // indirect github.com/tidwall/match v1.1.1 // indirect github.com/tidwall/pretty v1.2.0 // indirect + github.com/tidwall/tinylru v1.1.0 // indirect + github.com/tidwall/wal v1.1.7 // indirect github.com/twitchyliquid64/golang-asm v0.15.1 // indirect + github.com/zbiljic/go-filelock v0.0.0-20170914061330-1dbf7103ab7d // indirect github.com/zondax/hid v0.9.2 // indirect github.com/zondax/ledger-go v1.0.0 // indirect go.etcd.io/bbolt v1.4.0 // indirect diff --git a/tests/systemtests/go.sum b/tests/systemtests/go.sum index 69d90e3ba785..719a9c49811c 100644 --- a/tests/systemtests/go.sum +++ b/tests/systemtests/go.sum @@ -16,8 +16,6 @@ cosmossdk.io/math v1.5.3 h1:WH6tu6Z3AUCeHbeOSHg2mt9rnoiUWVWaQ2t6Gkll96U= cosmossdk.io/math v1.5.3/go.mod h1:uqcZv7vexnhMFJF+6zh9EWdm/+Ylyln34IvPnBauPCQ= cosmossdk.io/schema v1.1.0 h1:mmpuz3dzouCoyjjcMcA/xHBEmMChN+EHh8EHxHRHhzE= cosmossdk.io/schema v1.1.0/go.mod h1:Gb7pqO+tpR+jLW5qDcNOSv0KtppYs7881kfzakguhhI= -cosmossdk.io/store v1.10.0-rc.2 h1:7ze2UoheVTVMK4ElHtoRhYv8nlUImj34e4yp1yy1bgE= -cosmossdk.io/store v1.10.0-rc.2/go.mod h1:3p1IV4EGsULFfeyAcfj7/DBcDsy8d3VlYIEJnhhbP3U= cosmossdk.io/x/tx v1.2.0-rc.1 h1:AartiA6eiTD9KHmnlj3uG3H8FjyjI0qNkmvmU+p6cJ8= cosmossdk.io/x/tx v1.2.0-rc.1/go.mod h1:UzpMTUmQEFfz+m0E+lhzFIiEhtZCHjScU/NC652DBHI= dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU= @@ -51,6 +49,8 @@ github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751/go.mod h1:LOuy github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0= github.com/alecthomas/units v0.0.0-20190717042225-c3de453c63f4/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0= github.com/alecthomas/units v0.0.0-20190924025748-f65c72e2690d/go.mod h1:rBZYJk541a8SKzHPHnH3zbiI+7dagKZ0cgpgrD7Fyho= +github.com/alitto/pond v1.8.3 h1:ydIqygCLVPqIX/USe5EaV/aSRXTRXDEI9JwuDdu+/xs= +github.com/alitto/pond v1.8.3/go.mod h1:CmvIIGd5jKLasGI3D87qDkQxjzChdKMmnXMg3fG6M6Q= github.com/antihax/optional v1.0.0/go.mod h1:uupD/76wgC+ih3iEmQUL+0Ugr19nfwCT1kdvxnR2qWY= github.com/apache/thrift v0.12.0/go.mod h1:cp2SuWMxlEZw2r+iP2GNCdIi4C1qmUzdZFSVb+bacwQ= github.com/apache/thrift v0.13.0/go.mod h1:cp2SuWMxlEZw2r+iP2GNCdIi4C1qmUzdZFSVb+bacwQ= @@ -167,6 +167,8 @@ github.com/creachadair/tomledit v0.0.28 h1:aQJVwcNTzx4SZ/tSbkyGE69w4YQ6Gn+xhHHKt github.com/creachadair/tomledit v0.0.28/go.mod h1:pqb2HRQi0lMu6MBiUmTk/0XQ+SmPtq2QbUrG+eiLP5w= github.com/creack/pty v1.1.7/go.mod h1:lj5s0c3V2DBrqTV7llrYr5NG6My20zk30Fl46Y7DoTY= github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= +github.com/crypto-org-chain/cronos/memiavl v0.1.0 h1:bHjD9mdra/SoByljilIgIkm2Tavkswy4qT6SLvVzDic= +github.com/crypto-org-chain/cronos/memiavl v0.1.0/go.mod h1:IyRvgFKOQPC/Qdx543PGl6WgeDOU+hWdv+xLz3stotc= github.com/danieljoos/wincred v1.2.2 h1:774zMFJrqaeYCK2W57BgAem/MLi6mtSE47MB6BOJ0i0= github.com/danieljoos/wincred v1.2.2/go.mod h1:w7w4Utbrz8lqeMbDAK0lkNJUv5sAOkFi7nd/ogr0Uh8= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= @@ -458,6 +460,8 @@ github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc= github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw= +github.com/ledgerwatch/erigon-lib v0.0.0-20230210071639-db0e7ed11263 h1:LGEzZvf33Y1NhuP5+jI/ni9l1TFS6oYPDilgy74NusM= +github.com/ledgerwatch/erigon-lib v0.0.0-20230210071639-db0e7ed11263/go.mod h1:OXgMDuUo2lZ3NpH29ZvMYbk+LxFd5ffDl2Z2mGMuY/I= github.com/leodido/go-urn v1.2.0 h1:hpXL4XnriNwQ/ABnpepYM/1vCLWNDfUNts8dX3xTG6Y= github.com/leodido/go-urn v1.2.0/go.mod h1:+8+nEpDfqqsY+g338gtMEUOtuK+4dEMhiQEgxpxOKII= github.com/lib/pq v1.10.9 h1:YXG7RB+JIjhP29X+OtkiDnYaXQwpS4JEWq7dtCCRUEw= @@ -703,8 +707,9 @@ github.com/syndtr/goleveldb v1.0.1-0.20220721030215-126854af5e6d h1:vfofYNRScrDd github.com/syndtr/goleveldb v1.0.1-0.20220721030215-126854af5e6d/go.mod h1:RRCYJbIwD5jmqPI9XoAFR0OcDxqUctll6zUj/+B4S48= 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.7.0 h1:L1fkJH/AuEh5zBnnBbmTwQ5Lt+bRJ5A8EWecslvo9iI= -github.com/tidwall/btree v1.7.0/go.mod h1:twD9XRA5jj9VUQGELzDO4HPQTNJsoWWfYEL+EUQ2cKY= +github.com/tidwall/btree v1.8.0 h1:kHHy8hSBauQUe0KPHMFLOt0olAj1nDnkHPJhr8+HFkM= +github.com/tidwall/btree v1.8.0/go.mod h1:jBbTdUWhSZClZWoDg54VnvV7/54modSOzDN7VXftj1A= +github.com/tidwall/gjson v1.10.2/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk= github.com/tidwall/gjson v1.14.2/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk= github.com/tidwall/gjson v1.18.0 h1:FIDeeyB800efLX89e5a8Y0BNH+LOngJyGrIWxG2FKQY= github.com/tidwall/gjson v1.18.0/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk= @@ -714,6 +719,10 @@ github.com/tidwall/pretty v1.2.0 h1:RWIZEg2iJ8/g6fDDYzMpobmaoGh5OLl4AXtGUGPcqCs= github.com/tidwall/pretty v1.2.0/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhsoaGGjNU= github.com/tidwall/sjson v1.2.5 h1:kLy8mja+1c9jlljvWTlSazM7cKDRfJuR/bOJhcY5NcY= github.com/tidwall/sjson v1.2.5/go.mod h1:Fvgq9kS/6ociJEDnK0Fk1cpYF4FIW6ZF7LAe+6jwd28= +github.com/tidwall/tinylru v1.1.0 h1:XY6IUfzVTU9rpwdhKUF6nQdChgCdGjkMfLzbWyiau6I= +github.com/tidwall/tinylru v1.1.0/go.mod h1:3+bX+TJ2baOLMWTnlyNWHh4QMnFyARg2TLTQ6OFbzw8= +github.com/tidwall/wal v1.1.7 h1:emc1TRjIVsdKKSnpwGBAcsAGg0767SvUk8+ygx7Bb+4= +github.com/tidwall/wal v1.1.7/go.mod h1:r6lR1j27W9EPalgHiB7zLJDYu3mzW5BQP5KrzBpYY/E= github.com/tmc/grpc-websocket-proxy v0.0.0-20170815181823-89b8d40f7ca8/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U= github.com/tv42/httpunix v0.0.0-20150427012821-b75d8614f926/go.mod h1:9ESjWnEqriFuLhtthL60Sar/7RFoluCcXsuvEwTV5KM= github.com/twitchyliquid64/golang-asm v0.15.1 h1:SU5vSMR7hnwNxj24w34ZyCi/FmDZTkS4MhqMhdFk5YI= @@ -727,6 +736,8 @@ github.com/urfave/cli v1.22.1/go.mod h1:Gos4lmkARVdJ6EkW0WaNv/tZAAMe9V7XWyB60NtX github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2/go.mod h1:UETIi67q53MR2AWcXfiuqkDkRtnGDLqkBTpCHuJHxtU= github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= +github.com/zbiljic/go-filelock v0.0.0-20170914061330-1dbf7103ab7d h1:XQyeLr7N9iY9mi+TGgsBFkj54+j3fdoo8e2u6zrGP5A= +github.com/zbiljic/go-filelock v0.0.0-20170914061330-1dbf7103ab7d/go.mod h1:hoMeDjlNXTNqVwrCk8YDyaBS2g5vFfEX2ezMi4vb6CY= github.com/zondax/hid v0.9.2 h1:WCJFnEDMiqGF64nlZz28E9qLVZ0KSJ7xpc5DLEyma2U= github.com/zondax/hid v0.9.2/go.mod h1:l5wttcP0jwtdLjqjMMWFVEE7d1zO0jvSPA9OPZxWpEM= github.com/zondax/ledger-go v1.0.0 h1:BvNoksIyRqyQTW78rIZP9A44WwAminKiomQa7jXp9EI=