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

feat: increment consensus ver and register migration #1295

Merged
merged 4 commits into from
Sep 19, 2023
Merged
Show file tree
Hide file tree
Changes from 2 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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ Note:

Changes:

* (feat) [#1295](https://github.com/cosmos/interchain-security/pull/1295) increment consumer consensus version and register consumer packet migration.
* (fix!) [#1262](https://github.com/cosmos/interchain-security/pull/1262) Remove incorrect address validation on `ProviderFeePoolAddrStr` param.
* (feature!) [#1244](https://github.com/cosmos/interchain-security/pull/1244) Update the default consumer unbonding period to 2 weeks.
* (fix!) [#1244](https://github.com/cosmos/interchain-security/pull/1244) Validate token transfer messages before calling `Transfer()`.
Expand Down
8 changes: 4 additions & 4 deletions x/ccv/consumer/keeper/migration.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,19 +25,18 @@ func NewMigrator(ccvConsumerKeeper Keeper, ccvConsumerParamSpace paramtypes.Subs
// https://github.com/cosmos/interchain-security/pull/1037
//
// Note an equivalent migration is not required for providers.
func (k Keeper) MigrateConsumerPacketData(ctx sdk.Context) {
func (k Keeper) MigrateConsumerPacketData(ctx sdk.Context) error {
// deserialize packet data from old format
var depreciatedType ccvtypes.ConsumerPacketDataList
store := ctx.KVStore(k.storeKey)
bz := store.Get([]byte{consumertypes.PendingDataPacketsBytePrefix})
if bz == nil {
ctx.Logger().Info("no pending data packets to migrate")
return
return nil
}
err := depreciatedType.Unmarshal(bz)
if err != nil {
// An error here would indicate something is very wrong
panic(fmt.Errorf("failed to unmarshal pending data packets: %w", err))
return fmt.Errorf("failed to unmarshal pending data packets: %w", err)
}

// Delete old data
Expand All @@ -48,6 +47,7 @@ func (k Keeper) MigrateConsumerPacketData(ctx sdk.Context) {
for _, data := range depreciatedType.List {
k.AppendPendingPacket(ctx, data.Type, data.Data)
}
return nil
}

// TODO: the following hackyness could be removed if we're able to reference older versions of ICS.
Expand Down
10 changes: 4 additions & 6 deletions x/ccv/consumer/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,9 @@ func (AppModule) RegisterInvariants(ir sdk.InvariantRegistry) {
// RegisterServices registers module services.
func (am AppModule) RegisterServices(cfg module.Configurator) {
consumertypes.RegisterQueryServer(cfg.QueryServer(), am.keeper)
cfg.RegisterMigration(consumertypes.ModuleName,
1, // from version 1
am.keeper.MigrateConsumerPacketData)
shaspitz marked this conversation as resolved.
Show resolved Hide resolved
}

// InitGenesis performs genesis initialization for the consumer module. It returns
Expand All @@ -126,12 +129,7 @@ func (am AppModule) ExportGenesis(ctx sdk.Context, cdc codec.JSONCodec) json.Raw

// ConsensusVersion implements AppModule/ConsensusVersion.
func (AppModule) ConsensusVersion() uint64 {
// Note that v1.0.0 consumers should technically be on a different consensus version
// than v1.2.0-multiden and v2.0.0. However, Neutron was the first consumer to launch
// in prod, and they've started on v1.2.0-multiden (which has a ConsensusVersion of 1).
//
// v1.2.0-multiden and v2.0.0 are consensus compatible, so they need return the same ConsensusVersion of 1.
return 1
return 2
}

// BeginBlock implements the AppModule interface
Expand Down
Loading