Skip to content
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

add denom traces migration #656

Merged
merged 1 commit into from
Aug 27, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions .drone.yml
Original file line number Diff line number Diff line change
Expand Up @@ -75,12 +75,12 @@ steps:
password:
from_secret: docker_password
tags:
- v7-alpha
- v7-rc
when:
event:
- push
branch:
- ica-testing
- add-denom-traces-migration
- name: docker_release
image: plugins/docker:18
settings:
Expand Down Expand Up @@ -341,7 +341,7 @@ steps:
- ./scripts/ci/upgrade/proposal.sh
- name: stargaze-upgraded
pull: true
image: publicawesome/stargaze:v7-alpha
image: publicawesome/stargaze:v7-rc
commands:
- ./scripts/ci/upgrade/run-upgrade.sh
environment:
Expand Down Expand Up @@ -396,6 +396,6 @@ depends_on:
- ibc-integration-test
---
kind: signature
hmac: 0b778bfb2eaa3b852127d6a595c16dcd3aa9697d7e6cc50d172deccf8eb4b9ab
hmac: 83236df0cf43bf7972a6a9c949af5d1c0b01791cb081b0f03d2d6e2d6ddc40cc

...
25 changes: 25 additions & 0 deletions app/upgrades.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,16 @@ import (
icacontrollertypes "github.com/cosmos/ibc-go/v3/modules/apps/27-interchain-accounts/controller/types"
icahosttypes "github.com/cosmos/ibc-go/v3/modules/apps/27-interchain-accounts/host/types"
icatypes "github.com/cosmos/ibc-go/v3/modules/apps/27-interchain-accounts/types"
ibctransfertypes "github.com/cosmos/ibc-go/v3/modules/apps/transfer/types"
)

// next upgrade name
const upgradeName = "v7"

func equalTraces(dtA, dtB ibctransfertypes.DenomTrace) bool {
return dtA.BaseDenom == dtB.BaseDenom && dtA.Path == dtB.Path
}

// RegisterUpgradeHandlers returns upgrade handlers
func (app *App) RegisterUpgradeHandlers(cfg module.Configurator) {
app.UpgradeKeeper.SetUpgradeHandler(upgradeName, func(ctx sdk.Context, plan upgradetypes.Plan, fromVM module.VersionMap) (module.VersionMap, error) {
Expand Down Expand Up @@ -51,6 +56,26 @@ func (app *App) RegisterUpgradeHandlers(cfg module.Configurator) {
}
// initialize ICS27 module
icamodule.InitModule(ctx, controllerParams, hostParams)

// fix denom traces
// list of traces that must replace the old traces in store
var newTraces []ibctransfertypes.DenomTrace
app.TransferKeeper.IterateDenomTraces(ctx,
func(dt ibctransfertypes.DenomTrace) bool {
// check if the new way of splitting FullDenom
// into Trace and BaseDenom passes validation and
// is the same as the current DenomTrace.
// If it isn't then store the new DenomTrace in the list of new traces.
newTrace := ibctransfertypes.ParseDenomTrace(dt.GetFullDenomPath())
if err := newTrace.Validate(); err == nil && !equalTraces(newTrace, dt) {
newTraces = append(newTraces, newTrace)
}
return false
})
// replace the outdated traces with the new trace information
for _, nt := range newTraces {
app.TransferKeeper.SetDenomTrace(ctx, nt)
}
return app.mm.RunMigrations(ctx, cfg, fromVM)
})

Expand Down