Skip to content

Commit

Permalink
Prov: Create the MigrateParamsProv bank keeper method. (#604)
Browse files Browse the repository at this point in the history
* Update bank migrations to allow us to merge the SDK's v4 with our v4.

* Add changelog entry.

* Put the migratios back to what the SDK has since those changes don't actually matter anymore.

* Change the changelog entry to better reflect what's done.
  • Loading branch information
SpicyLemon authored Mar 27, 2024
1 parent 4fd3097 commit 28a10ac
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ Ref: https://keepachangelog.com/en/1.0.0/
### Improvements

* [#595](https://github.com/provenance-io/cosmos-sdk/pull/595) Provenance: Create SimulateFromSeedProv which is the same as SimulateFromSeed but also returns the simulation's end block time which is needed for some sims tests.
* [#604](https://github.com/provenance-io/cosmos-sdk/pull/604) Provenance: Create bankkeeper.MigrateParamsProv so we can finish the v3-v4 bank module migration.

### Bug Fixes

Expand Down
32 changes: 32 additions & 0 deletions x/bank/keeper/keeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import (
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
"github.com/cosmos/cosmos-sdk/types/query"
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
"github.com/cosmos/cosmos-sdk/x/bank/exported"
"github.com/cosmos/cosmos-sdk/x/bank/types"
)

Expand Down Expand Up @@ -476,3 +477,34 @@ func (k BaseViewKeeper) IterateTotalSupply(ctx context.Context, cb func(sdk.Coin
panic(err)
}
}

// MigrateParamsProv migrates the bank params from the params module into the bank state.
//
// It is specifically needed by the Provenance Blockchain in one of its upgrades.
// The SDK does this as part of the migration from v3 to v4 (Migrate3to4).
// But Provenance is already on its own v4, so that migration won't be run.
// The only difference between Provenance's v4 and the SDK's v4 is the movement of the params into the bank state.
//
// This function will be called in one of Provenance's upgrades in order to make our v4 the same as the SDK's v4.
// Once that upgrade is done, this function won't be needed anymore, and should be deleted.
func (k BaseKeeper) MigrateParamsProv(goCtx context.Context, legacySubspace exported.Subspace) error {
// This is basically a copy of migrations.v4.MigrateStore, but I didn't want to import that package to call it directly.
ctx := sdk.UnwrapSDKContext(goCtx)
var currParams types.Params
legacySubspace.GetParamSet(ctx, &currParams)

// SendEnabled is migrated to the x/bank module store, so delete from the params
currParams = types.NewParams(currParams.DefaultSendEnabled)

if err := currParams.Validate(); err != nil {
return err
}

bz, err := k.cdc.Marshal(&currParams)
if err != nil {
return err
}

st := k.storeService.OpenKVStore(ctx)
return st.Set(types.ParamsKey, bz)
}

0 comments on commit 28a10ac

Please sign in to comment.