-
Notifications
You must be signed in to change notification settings - Fork 134
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: v2 migrations #975
Merged
Merged
feat: v2 migrations #975
Changes from all commits
Commits
Show all changes
25 commits
Select commit
Hold shift + click to select a range
1c5cf77
v2 imports
shaspitz f7b0e31
Squashed commit of the following:
shaspitz ed43d0b
rm old code
shaspitz 0b4e6b7
go.mod restore
shaspitz 70bb621
better naming of hardcodes
shaspitz 1861340
consumer boilerplate
shaspitz 96b6fef
comments
shaspitz 1abfc6a
Merge branch 'main' into shawn/v2-migrations-hardcoded
shaspitz 39b8a6f
migrate consumer genesis states
shaspitz e9b71fd
test and cleans
shaspitz 57e82a8
lint
shaspitz 75f86f3
Merge branch 'main' into shawn/v2-migrations-hardcoded
shaspitz 1e87457
migration and partial test
shaspitz 7db29b6
cleans
shaspitz e380bbb
finish test
shaspitz baa747b
comments and doc
shaspitz 7ddb7e3
Update migration_test.go
shaspitz d858a33
Merge branch 'main' into shawn/v2-migrations-hardcoded
shaspitz add0973
Update CHANGELOG.md
shaspitz 2d10e22
Merge branch 'main' into shawn/v2-migrations-hardcoded
shaspitz ac41852
expand in changelog
shaspitz a135c28
increment consensus ver
shaspitz 8498fc0
set key table on construction
shaspitz d60b342
rm semver migration funcs
shaspitz a235a1a
comment explaining consensus version
shaspitz File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
package keeper | ||
|
||
import ( | ||
"time" | ||
|
||
sdk "github.com/cosmos/cosmos-sdk/types" | ||
paramtypes "github.com/cosmos/cosmos-sdk/x/params/types" | ||
consumertypes "github.com/cosmos/interchain-security/v2/x/ccv/consumer/types" | ||
ccvtypes "github.com/cosmos/interchain-security/v2/x/ccv/types" | ||
) | ||
|
||
// Migrator is a struct for handling in-place store migrations. | ||
type Migrator struct { | ||
ccvConsumerKeeper Keeper | ||
ccvConsumerParamSpace paramtypes.Subspace | ||
} | ||
|
||
// NewMigrator returns a new Migrator. | ||
func NewMigrator(ccvConsumerKeeper Keeper, ccvConsumerParamSpace paramtypes.Subspace) Migrator { | ||
return Migrator{ccvConsumerKeeper: ccvConsumerKeeper, ccvConsumerParamSpace: ccvConsumerParamSpace} | ||
} | ||
|
||
// Note: If migrating from v1.2.0-multiden to v2.0.0, there are no migrations required. | ||
// This is due to the fact that the former version includes both of: | ||
// - https://github.com/cosmos/interchain-security/commit/54e9852d3c89a2513cd0170a56c6eec894fc878d | ||
// - https://github.com/cosmos/interchain-security/pull/833 | ||
// both of which handle the introduction of new params. | ||
|
||
// Migratev1Tov2 migrates a consumer from v1.0.0 to v2.0.0. | ||
func (m Migrator) Migratev1Tov2(ctx sdk.Context) error { | ||
// Migrate params | ||
MigrateParamsv1Tov2(ctx, m.ccvConsumerParamSpace) | ||
|
||
return nil | ||
} | ||
|
||
// MigrateParamsv1Tov2 migrates the consumer CCV module params from v1.0.0 to v2.0.0, | ||
// setting default values for new params. | ||
func MigrateParamsv1Tov2(ctx sdk.Context, paramsSubspace paramtypes.Subspace) { | ||
// Get old params | ||
var enabled bool | ||
paramsSubspace.Get(ctx, consumertypes.KeyEnabled, &enabled) | ||
var blocksPerDistributionTransmission int64 | ||
paramsSubspace.Get(ctx, consumertypes.KeyBlocksPerDistributionTransmission, &blocksPerDistributionTransmission) | ||
var distributionTransmissionChannel string | ||
paramsSubspace.Get(ctx, consumertypes.KeyDistributionTransmissionChannel, &distributionTransmissionChannel) | ||
var providerFeePoolAddrStr string | ||
paramsSubspace.Get(ctx, consumertypes.KeyProviderFeePoolAddrStr, &providerFeePoolAddrStr) | ||
var ccvTimeoutPeriod time.Duration | ||
paramsSubspace.Get(ctx, ccvtypes.KeyCCVTimeoutPeriod, &ccvTimeoutPeriod) | ||
var transferTimeoutPeriod time.Duration | ||
paramsSubspace.Get(ctx, consumertypes.KeyTransferTimeoutPeriod, &transferTimeoutPeriod) | ||
var consumerRedistributionFrac string | ||
paramsSubspace.Get(ctx, consumertypes.KeyConsumerRedistributionFrac, &consumerRedistributionFrac) | ||
var historicalEntries int64 | ||
paramsSubspace.Get(ctx, consumertypes.KeyHistoricalEntries, &historicalEntries) | ||
var unbondingPeriod time.Duration | ||
paramsSubspace.Get(ctx, consumertypes.KeyConsumerUnbondingPeriod, &unbondingPeriod) | ||
|
||
// Recycle old params, set new params to default values | ||
defaultParams := consumertypes.DefaultParams() | ||
newParams := consumertypes.NewParams( | ||
enabled, | ||
blocksPerDistributionTransmission, | ||
distributionTransmissionChannel, | ||
providerFeePoolAddrStr, | ||
ccvTimeoutPeriod, | ||
transferTimeoutPeriod, | ||
consumerRedistributionFrac, | ||
historicalEntries, | ||
unbondingPeriod, | ||
defaultParams.SoftOptOutThreshold, | ||
defaultParams.RewardDenoms, | ||
defaultParams.ProviderRewardDenoms, | ||
) | ||
|
||
// Persist new params | ||
paramsSubspace.SetParamSet(ctx, &newParams) | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
we now have to pass in param subspace to the app module constructor so the subspace can be used for migrations