-
Notifications
You must be signed in to change notification settings - Fork 352
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Problem: nft module store is not initialized after upgrade #552
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,6 +26,7 @@ import ( | |
"github.com/cosmos/cosmos-sdk/server/api" | ||
"github.com/cosmos/cosmos-sdk/server/config" | ||
servertypes "github.com/cosmos/cosmos-sdk/server/types" | ||
storetypes "github.com/cosmos/cosmos-sdk/store/types" | ||
"github.com/cosmos/cosmos-sdk/testutil/testdata" | ||
sdk "github.com/cosmos/cosmos-sdk/types" | ||
"github.com/cosmos/cosmos-sdk/types/module" | ||
|
@@ -414,6 +415,27 @@ func New( | |
) | ||
app.SetEndBlocker(app.EndBlocker) | ||
|
||
planName := "v2.0.0" | ||
app.UpgradeKeeper.SetUpgradeHandler(planName, func(ctx sdk.Context, _ upgradetypes.Plan) { | ||
// https://github.com/crypto-org-chain/chain-main/blob/master/doc/architecture/adr-003.md | ||
}) | ||
|
||
upgradeInfo, err := app.UpgradeKeeper.ReadUpgradeInfoFromDisk() | ||
if err != nil { | ||
panic(err) | ||
} | ||
|
||
if upgradeInfo.Name == planName && !app.UpgradeKeeper.IsSkipHeight(upgradeInfo.Height) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. could add some explain for IsSkipHeight, There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. in latest planName is different from "2.0.0"? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. cosmos-sdk has a feature that you can skip upgrades in command line:
|
||
storeUpgrades := storetypes.StoreUpgrades{ | ||
Added: []string{nfttypes.StoreKey}, | ||
Renamed: []storetypes.StoreRename{}, | ||
Deleted: []string{}, | ||
} | ||
|
||
// configure store loader that checks if version == upgradeHeight and applies store upgrades | ||
app.SetStoreLoader(upgradetypes.UpgradeStoreLoader(upgradeInfo.Height, &storeUpgrades)) | ||
Comment on lines
+423
to
+436
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. should this just be called once / inside There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think the override only works before storage constructed, so it need to happen pretty early. while upgrade handler is called in abci event. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I get the example code from the godoc of upgrade module: https://pkg.go.dev/github.com/cosmos/[email protected]/x/upgrade#hdr-Performing_Upgrades There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. https://github.com/cosmos/cosmos-sdk/blob/master/x/upgrade/types/storeloader.go#L13 |
||
} | ||
|
||
if loadLatest { | ||
if err := app.LoadLatestVersion(); err != nil { | ||
tmos.Exit(err.Error()) | ||
|
@@ -433,10 +455,6 @@ func New( | |
app.ScopedIBCKeeper = scopedIBCKeeper | ||
app.ScopedTransferKeeper = scopedTransferKeeper | ||
|
||
app.UpgradeKeeper.SetUpgradeHandler("v2.0.0", func(ctx sdk.Context, _ upgradetypes.Plan) { | ||
// https://github.com/crypto-org-chain/chain-main/blob/master/doc/architecture/adr-003.md | ||
}) | ||
|
||
return app | ||
} | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can this fetched from other place?
because two places hard-coded
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the plan name only specified once here.