-
Notifications
You must be signed in to change notification settings - Fork 122
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat!: ics parameter migration (#1408)
* Added MsgUpdateParams * added handlers MsgUpdateParams and migration for legacy parameter updates * Changed to store service * Revert "Changed to store service" This reverts commit e47868f. * use module's store instead of x/param parameter space * Added migration + tests * Addressed review comments * Addressed comments
- Loading branch information
Showing
27 changed files
with
1,525 additions
and
326 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,111 @@ | ||
package keeper | ||
|
||
import ( | ||
"time" | ||
|
||
sdk "github.com/cosmos/cosmos-sdk/types" | ||
paramtypes "github.com/cosmos/cosmos-sdk/x/params/types" | ||
|
||
ccvtypes "github.com/cosmos/interchain-security/v3/x/ccv/types" | ||
) | ||
|
||
// Legacy: used for migration only! | ||
// GetConsumerParamsLegacy returns the params for the consumer ccv module from x/param subspace | ||
// which will be deprecated soon | ||
func (k Keeper) GetConsumerParamsLegacy(ctx sdk.Context, paramSpace paramtypes.Subspace) ccvtypes.Params { | ||
return ccvtypes.NewParams( | ||
getEnabled(ctx, paramSpace), | ||
getBlocksPerDistributionTransmission(ctx, paramSpace), | ||
getDistributionTransmissionChannel(ctx, paramSpace), | ||
getProviderFeePoolAddrStr(ctx, paramSpace), | ||
getCCVTimeoutPeriod(ctx, paramSpace), | ||
getTransferTimeoutPeriod(ctx, paramSpace), | ||
getConsumerRedistributionFrac(ctx, paramSpace), | ||
getHistoricalEntries(ctx, paramSpace), | ||
getUnbondingPeriod(ctx, paramSpace), | ||
getSoftOptOutThreshold(ctx, paramSpace), | ||
getRewardDenoms(ctx, paramSpace), | ||
getProviderRewardDenoms(ctx, paramSpace), | ||
) | ||
} | ||
|
||
// getEnabled returns the enabled flag for the consumer module | ||
func getEnabled(ctx sdk.Context, paramStore paramtypes.Subspace) bool { | ||
var enabled bool | ||
paramStore.Get(ctx, ccvtypes.KeyEnabled, &enabled) | ||
return enabled | ||
} | ||
|
||
func getBlocksPerDistributionTransmission(ctx sdk.Context, paramStore paramtypes.Subspace) int64 { | ||
var bpdt int64 | ||
paramStore.Get(ctx, ccvtypes.KeyBlocksPerDistributionTransmission, &bpdt) | ||
return bpdt | ||
} | ||
|
||
func getDistributionTransmissionChannel(ctx sdk.Context, paramStore paramtypes.Subspace) string { | ||
var s string | ||
paramStore.Get(ctx, ccvtypes.KeyDistributionTransmissionChannel, &s) | ||
return s | ||
} | ||
|
||
func getProviderFeePoolAddrStr(ctx sdk.Context, paramStore paramtypes.Subspace) string { | ||
var s string | ||
paramStore.Get(ctx, ccvtypes.KeyProviderFeePoolAddrStr, &s) | ||
return s | ||
} | ||
|
||
// getCCVTimeoutPeriod returns the timeout period for sent ccv related ibc packets | ||
func getCCVTimeoutPeriod(ctx sdk.Context, paramStore paramtypes.Subspace) time.Duration { | ||
var p time.Duration | ||
paramStore.Get(ctx, ccvtypes.KeyCCVTimeoutPeriod, &p) | ||
return p | ||
} | ||
|
||
// getTransferTimeoutPeriod returns the timeout period for sent transfer related ibc packets | ||
func getTransferTimeoutPeriod(ctx sdk.Context, paramStore paramtypes.Subspace) time.Duration { | ||
var p time.Duration | ||
paramStore.Get(ctx, ccvtypes.KeyTransferTimeoutPeriod, &p) | ||
return p | ||
} | ||
|
||
// getConsumerRedistributionFrac returns the fraction of tokens allocated to the consumer redistribution | ||
// address during distribution events. The fraction is a string representing a | ||
// decimal number. For example "0.75" would represent 75%. | ||
func getConsumerRedistributionFrac(ctx sdk.Context, paramStore paramtypes.Subspace) string { | ||
var str string | ||
paramStore.Get(ctx, ccvtypes.KeyConsumerRedistributionFrac, &str) | ||
return str | ||
} | ||
|
||
// getHistoricalEntries returns the number of historical info entries to persist in store | ||
func getHistoricalEntries(ctx sdk.Context, paramStore paramtypes.Subspace) int64 { | ||
var n int64 | ||
paramStore.Get(ctx, ccvtypes.KeyHistoricalEntries, &n) | ||
return n | ||
} | ||
|
||
func getUnbondingPeriod(ctx sdk.Context, paramStore paramtypes.Subspace) time.Duration { | ||
var period time.Duration | ||
paramStore.Get(ctx, ccvtypes.KeyConsumerUnbondingPeriod, &period) | ||
return period | ||
} | ||
|
||
// getSoftOptOutThreshold returns the percentage of validators at the bottom of the set | ||
// that can opt out of running the consumer chain | ||
func getSoftOptOutThreshold(ctx sdk.Context, paramStore paramtypes.Subspace) string { | ||
var str string | ||
paramStore.Get(ctx, ccvtypes.KeySoftOptOutThreshold, &str) | ||
return str | ||
} | ||
|
||
func getRewardDenoms(ctx sdk.Context, paramStore paramtypes.Subspace) []string { | ||
var denoms []string | ||
paramStore.Get(ctx, ccvtypes.KeyRewardDenoms, &denoms) | ||
return denoms | ||
} | ||
|
||
func getProviderRewardDenoms(ctx sdk.Context, paramStore paramtypes.Subspace) []string { | ||
var denoms []string | ||
paramStore.Get(ctx, ccvtypes.KeyProviderRewardDenoms, &denoms) | ||
return denoms | ||
} |
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
Oops, something went wrong.