From 90f083c1067fde5101c526b172894928ed64a0ec Mon Sep 17 00:00:00 2001 From: yihuang Date: Mon, 11 Mar 2024 17:32:23 +0800 Subject: [PATCH] Problem: versiondb memstore fix not included (#1341) * Problem: memiavl/versiondb new tagged version not used * changelog --- CHANGELOG.md | 1 + app/app.go | 34 +++++++++++++++++----------------- app/versiondb.go | 6 ++---- app/versiondb_placeholder.go | 4 +--- go.mod | 7 +++---- go.sum | 12 ++++++------ gomod2nix.toml | 11 +++++------ 7 files changed, 35 insertions(+), 40 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e982fa9104..095eb37644 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,7 @@ - [#1298](https://github.com/crypto-org-chain/cronos/pull/1298) Update cosmos-sdk to latest `v0.46.x`. - [#1307](https://github.com/crypto-org-chain/cronos/pull/1307) Include fasten memiavl restore and versiondb version mismatch related fixes from submodules. +- [#1341](https://github.com/crypto-org-chain/cronos/pull/1341) Include versiondb memstore fix. *Jan 05, 2024* diff --git a/app/app.go b/app/app.go index 7640a8ea7a..90bc65fd0d 100644 --- a/app/app.go +++ b/app/app.go @@ -372,23 +372,6 @@ func New( keys, memKeys, tkeys := StoreKeys(experimental) - // load state streaming if enabled - if _, _, err := streaming.LoadStreamingServices(bApp, appOpts, appCodec, keys); err != nil { - fmt.Printf("failed to load state streaming: %s", err) - os.Exit(1) - } - - // wire up the versiondb's `StreamingService` and `MultiStore`. - streamers := cast.ToStringSlice(appOpts.Get("store.streamers")) - var qms sdk.MultiStore - if slices.Contains(streamers, "versiondb") { - var err error - qms, err = setupVersionDB(homePath, bApp, keys, tkeys, memKeys) - if err != nil { - panic(err) - } - } - app := &App{ BaseApp: bApp, cdc: cdc, @@ -754,6 +737,23 @@ func New( app.MountTransientStores(tkeys) app.MountMemoryStores(memKeys) + // load state streaming if enabled + if _, _, err := streaming.LoadStreamingServices(app.BaseApp, appOpts, appCodec, keys); err != nil { + fmt.Printf("failed to load state streaming: %s", err) + os.Exit(1) + } + + // wire up the versiondb's `StreamingService` and `MultiStore`. + streamers := cast.ToStringSlice(appOpts.Get("store.streamers")) + var qms sdk.MultiStore + if slices.Contains(streamers, "versiondb") { + var err error + qms, err = app.setupVersionDB(homePath, keys, tkeys, memKeys) + if err != nil { + panic(err) + } + } + // initialize BaseApp app.SetInitChainer(app.InitChainer) app.SetBeginBlocker(app.BeginBlocker) diff --git a/app/versiondb.go b/app/versiondb.go index 752d17942c..10b0ad76ad 100644 --- a/app/versiondb.go +++ b/app/versiondb.go @@ -7,16 +7,14 @@ import ( "os" "path/filepath" - "github.com/cosmos/cosmos-sdk/baseapp" storetypes "github.com/cosmos/cosmos-sdk/store/types" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/crypto-org-chain/cronos/versiondb" "github.com/crypto-org-chain/cronos/versiondb/tsrocksdb" ) -func setupVersionDB( +func (app *App) setupVersionDB( homePath string, - app *baseapp.BaseApp, keys map[string]*storetypes.KVStoreKey, tkeys map[string]*storetypes.TransientStoreKey, memKeys map[string]*storetypes.MemoryStoreKey, @@ -39,7 +37,7 @@ func setupVersionDB( service := versiondb.NewStreamingService(versionDB, exposeStoreKeys) app.SetStreamingService(service) - verDB := versiondb.NewMultiStore(versionDB, exposeStoreKeys) + verDB := versiondb.NewMultiStore(app.CommitMultiStore(), versionDB, exposeStoreKeys) verDB.MountTransientStores(tkeys) verDB.MountMemoryStores(memKeys) diff --git a/app/versiondb_placeholder.go b/app/versiondb_placeholder.go index 1c46fec500..1225c8e864 100644 --- a/app/versiondb_placeholder.go +++ b/app/versiondb_placeholder.go @@ -6,14 +6,12 @@ package app import ( "errors" - "github.com/cosmos/cosmos-sdk/baseapp" storetypes "github.com/cosmos/cosmos-sdk/store/types" sdk "github.com/cosmos/cosmos-sdk/types" ) -func setupVersionDB( +func (app *App) setupVersionDB( homePath string, - app *baseapp.BaseApp, keys map[string]*storetypes.KVStoreKey, tkeys map[string]*storetypes.TransientStoreKey, memKeys map[string]*storetypes.MemoryStoreKey, diff --git a/go.mod b/go.mod index 427612e06b..008a2fe86a 100644 --- a/go.mod +++ b/go.mod @@ -8,8 +8,8 @@ require ( github.com/armon/go-metrics v0.4.1 github.com/cosmos/cosmos-sdk v0.46.15-0.20231107150241-7799bba7bc88 github.com/cosmos/ibc-go/v5 v5.2.1 - github.com/crypto-org-chain/cronos/store v0.0.0-20240130060137-c12016e4052e - github.com/crypto-org-chain/cronos/versiondb v0.0.0-20240130060137-c12016e4052e + github.com/crypto-org-chain/cronos/store v0.0.6 + github.com/crypto-org-chain/cronos/versiondb v0.0.6 github.com/ethereum/go-ethereum v1.10.26 github.com/evmos/ethermint v0.0.0-00010101000000-000000000000 github.com/gogo/protobuf v1.3.3 @@ -77,7 +77,7 @@ require ( github.com/cosmos/iavl v0.19.6 // indirect github.com/cosmos/ledger-cosmos-go v0.12.4 // indirect github.com/creachadair/taskgroup v0.3.2 // indirect - github.com/crypto-org-chain/cronos/memiavl v0.0.4 // indirect + github.com/crypto-org-chain/cronos/memiavl v0.0.6 // indirect github.com/danieljoos/wincred v1.1.2 // indirect github.com/davecgh/go-spew v1.1.1 // indirect github.com/deckarep/golang-set v1.8.0 // indirect @@ -219,7 +219,6 @@ replace ( // the version used by cockroach v22.2.7 release github.com/cockroachdb/pebble => github.com/cockroachdb/pebble v0.0.0-20230206180212-744ea7cc8f90 github.com/cometbft/cometbft-db => github.com/crypto-org-chain/cometbft-db v0.0.0-20231011055109-57922ac52a63 - github.com/crypto-org-chain/cronos/memiavl => github.com/crypto-org-chain/cronos/memiavl v0.0.0-20240130060137-c12016e4052e // dgrijalva/jwt-go is deprecated and doesn't receive security updates. // TODO: remove it: https://github.com/cosmos/cosmos-sdk/issues/13134 github.com/dgrijalva/jwt-go => github.com/golang-jwt/jwt/v4 v4.4.2 diff --git a/go.sum b/go.sum index 2476a68de7..23f7884355 100644 --- a/go.sum +++ b/go.sum @@ -1262,12 +1262,12 @@ github.com/creack/pty v1.1.11/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ github.com/cristalhq/acmd v0.8.1/go.mod h1:LG5oa43pE/BbxtfMoImHCQN++0Su7dzipdgBjMCBVDQ= github.com/crypto-org-chain/cometbft-db v0.0.0-20231011055109-57922ac52a63 h1:R1QJ9a3XdYMSKo+1RdFifxb/g3lNypC52L/rpYrWoKo= github.com/crypto-org-chain/cometbft-db v0.0.0-20231011055109-57922ac52a63/go.mod h1:rocwIfnS+kA060x64gkSIRvWB9StSppIkJuo5MWzL24= -github.com/crypto-org-chain/cronos/memiavl v0.0.0-20240130060137-c12016e4052e h1:i/5RUn3u17PoPPm40mA30Pd89E+xCRVOvtogbQFE8Qo= -github.com/crypto-org-chain/cronos/memiavl v0.0.0-20240130060137-c12016e4052e/go.mod h1:sPIAu3w4KkWWTlN92GyLaB/qeMdszSYd6fF3r+p0C+A= -github.com/crypto-org-chain/cronos/store v0.0.0-20240130060137-c12016e4052e h1:xH57WcZkh3wxRbKQwK7WVnKOQSinNKVjWNCFHOxTVaY= -github.com/crypto-org-chain/cronos/store v0.0.0-20240130060137-c12016e4052e/go.mod h1:KC9cV7VK8BNIJySzztw2nWSqPqVGcffsumMl3sORPCM= -github.com/crypto-org-chain/cronos/versiondb v0.0.0-20240130060137-c12016e4052e h1:9tr6e1b+XB4dkmyAF2fzGJokbosiOXJPQFUUa/R2odU= -github.com/crypto-org-chain/cronos/versiondb v0.0.0-20240130060137-c12016e4052e/go.mod h1:i9e8vrU54C/JvSM+rX/jUidFRBcyXZ8FgNX+EvrasQc= +github.com/crypto-org-chain/cronos/memiavl v0.0.6 h1:rEJ906TnPO/qDit2FX+makXtLKHryGdA9uh573qi8LY= +github.com/crypto-org-chain/cronos/memiavl v0.0.6/go.mod h1:sPIAu3w4KkWWTlN92GyLaB/qeMdszSYd6fF3r+p0C+A= +github.com/crypto-org-chain/cronos/store v0.0.6 h1:kil/XuXmm2N2+VjsxscC9H9PTPUcOqRjnJp4SgciKd0= +github.com/crypto-org-chain/cronos/store v0.0.6/go.mod h1:MTFIcuiiLuU15blCkCoUI94Xa1JH2L1qVJQvanUwawo= +github.com/crypto-org-chain/cronos/versiondb v0.0.6 h1:G6FHrDa9G7aX900bePmBFOJgrEQzMsEw+rtqNaRqJU8= +github.com/crypto-org-chain/cronos/versiondb v0.0.6/go.mod h1:wziy3/1v8iGxiAKmiOoCt1XR/SQJKl9t9yHwpA9IQic= github.com/crypto-org-chain/ethermint v0.20.11-cronos.0.20231220064956-a85daedc6ffc h1:1sdpqaZTdUJtq8N35yVVOhYT/5SzQnA/jI7UYAWXsjw= github.com/crypto-org-chain/ethermint v0.20.11-cronos.0.20231220064956-a85daedc6ffc/go.mod h1:EDjmywAw/EMpMufJA2Q+E9pNHAB00Dt5siQanMOZC88= github.com/crypto-org-chain/go-ethereum v1.10.19-deepcopy-jumptable h1:VQLW0R8t9DcC/HvQZO1i0mIWjJfAezhI8lLUCholP0M= diff --git a/gomod2nix.toml b/gomod2nix.toml index 9919c33a59..06d9844dbd 100644 --- a/gomod2nix.toml +++ b/gomod2nix.toml @@ -152,15 +152,14 @@ schema = 3 version = "v0.3.2" hash = "sha256-Y261IO/d9xjV0UScqHvo31broxvnKn4IQQC9Mu6jNkE=" [mod."github.com/crypto-org-chain/cronos/memiavl"] - version = "v0.0.0-20240130060137-c12016e4052e" + version = "v0.0.6" hash = "sha256-4chV7TmG5Kw4Nac1s0kAcBk5UtyucP5HU5flijas3eg=" - replaced = "github.com/crypto-org-chain/cronos/memiavl" [mod."github.com/crypto-org-chain/cronos/store"] - version = "v0.0.0-20240130060137-c12016e4052e" - hash = "sha256-Kuv0nCgbnzrNPaQkSCCKmVNr/AcNhM9cCpW5e1DdyhM=" + version = "v0.0.6" + hash = "sha256-LTHz5StEJ3OibyUYYabeRAOLUYa2AN3LlOjx+WFruWI=" [mod."github.com/crypto-org-chain/cronos/versiondb"] - version = "v0.0.0-20240130060137-c12016e4052e" - hash = "sha256-qI16polu5o09nG0v2WYRThv7bXoEG3HlBgzhy9FBnXo=" + version = "v0.0.6" + hash = "sha256-hucr41fmGGzCta2izU62cv/iJNafAEFnWG7MRAXoi4s=" [mod."github.com/danieljoos/wincred"] version = "v1.1.2" hash = "sha256-Nnklfg12vmWCOhELGyoRqEF4w4srp0WbPwreaChYLKs="