-
Notifications
You must be signed in to change notification settings - Fork 94
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 consumer module #237
Merged
Merged
Add consumer module #237
Changes from 2 commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
0a8843b
add consumer
GNaD13 4a1fd29
add param space
GNaD13 85489b9
param subspace
GNaD13 d2db1a3
add test
GNaD13 524c943
remove log
GNaD13 0e7644b
nit
GNaD13 ab47f77
remove slashing hooks
GNaD13 58e41c9
add upgrade handler
GNaD13 acc2273
bump v6
GNaD13 1483386
pfm
GNaD13 3d784dd
nit
GNaD13 fa25302
add v6
GNaD13 745aac0
nit
GNaD13 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,111 @@ | ||
package ante | ||
|
||
import ( | ||
banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" | ||
distrtypes "github.com/cosmos/cosmos-sdk/x/distribution/types" | ||
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" | ||
govv1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1" | ||
govv1beta1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1" | ||
"github.com/cosmos/cosmos-sdk/x/params/types/proposal" | ||
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" | ||
ibctransfertypes "github.com/cosmos/ibc-go/v7/modules/apps/transfer/types" | ||
|
||
icahosttypes "github.com/cosmos/ibc-go/v7/modules/apps/27-interchain-accounts/host/types" | ||
|
||
upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types" | ||
|
||
ccvconsumertypes "github.com/cosmos/interchain-security/v3/x/ccv/consumer/types" | ||
ccvgov "github.com/cosmos/interchain-security/v3/x/ccv/democracy/governance" | ||
) | ||
|
||
var WhiteListModule = map[string]struct{}{ | ||
"/cosmos.gov.v1.MsgUpdateParams": {}, | ||
"/cosmos.bank.v1beta1.MsgUpdateParams": {}, | ||
"/cosmos.staking.v1beta1.MsgUpdateParams": {}, | ||
"/cosmos.distribution.v1beta1.MsgUpdateParams": {}, | ||
"/cosmos.mint.v1beta1.MsgUpdateParams": {}, | ||
"/cosmos.upgrade.v1beta1.MsgSoftwareUpgrade": {}, | ||
"/cosmos.upgrade.v1beta1.MsgCancelUpgrade": {}, | ||
"/centauri.transfermiddleware.v1beta1.MsgAddParachainIBCTokenInfo": {}, | ||
"/centauri.transfermiddleware.v1beta1.MsgRemoveParachainIBCTokenInfo": {}, | ||
"/centauri.transfermiddleware.v1beta1.MsgAddRlyAddress": {}, | ||
} | ||
|
||
func IsModuleWhiteList(typeUrl string) bool { | ||
_, found := WhiteListModule[typeUrl] | ||
return found | ||
} | ||
|
||
func IsProposalWhitelisted(content govv1beta1.Content) bool { | ||
switch c := content.(type) { | ||
case *proposal.ParameterChangeProposal: | ||
return isParamChangeWhitelisted(getParamChangesMapFromArray(c.Changes)) | ||
case *upgradetypes.SoftwareUpgradeProposal, //nolint:staticcheck | ||
*upgradetypes.CancelSoftwareUpgradeProposal: //nolint:staticcheck | ||
return true | ||
|
||
default: | ||
return false | ||
} | ||
} | ||
|
||
func getParamChangesMapFromArray(paramChanges []proposal.ParamChange) map[ccvgov.ParamChangeKey]struct{} { | ||
res := map[ccvgov.ParamChangeKey]struct{}{} | ||
for _, paramChange := range paramChanges { | ||
key := ccvgov.ParamChangeKey{ | ||
MsgType: paramChange.Subspace, | ||
Key: paramChange.Key, | ||
} | ||
|
||
res[key] = struct{}{} | ||
} | ||
|
||
return res | ||
} | ||
|
||
func isParamChangeWhitelisted(paramChanges map[ccvgov.ParamChangeKey]struct{}) bool { | ||
for paramChangeKey := range paramChanges { | ||
_, found := WhitelistedParams[paramChangeKey] | ||
if !found { | ||
return false | ||
} | ||
} | ||
return true | ||
} | ||
|
||
var WhitelistedParams = map[ccvgov.ParamChangeKey]struct{}{ | ||
//bank | ||
{MsgType: banktypes.ModuleName, Key: string(banktypes.KeySendEnabled)}: {}, | ||
{MsgType: banktypes.ModuleName, Key: string(banktypes.KeyDefaultSendEnabled)}: {}, | ||
//governance | ||
{MsgType: govtypes.ModuleName, Key: string(govv1.ParamStoreKeyDepositParams)}: {}, //min_deposit, max_deposit_period | ||
{MsgType: govtypes.ModuleName, Key: string(govv1.ParamStoreKeyVotingParams)}: {}, //voting_period | ||
{MsgType: govtypes.ModuleName, Key: string(govv1.ParamStoreKeyTallyParams)}: {}, //quorum,threshold,veto_threshold | ||
//staking | ||
{MsgType: stakingtypes.ModuleName, Key: string(stakingtypes.KeyUnbondingTime)}: {}, | ||
{MsgType: stakingtypes.ModuleName, Key: string(stakingtypes.KeyMaxValidators)}: {}, | ||
{MsgType: stakingtypes.ModuleName, Key: string(stakingtypes.KeyMaxEntries)}: {}, | ||
{MsgType: stakingtypes.ModuleName, Key: string(stakingtypes.KeyHistoricalEntries)}: {}, | ||
{MsgType: stakingtypes.ModuleName, Key: string(stakingtypes.KeyBondDenom)}: {}, | ||
{MsgType: stakingtypes.ModuleName, Key: string(stakingtypes.KeyMinCommissionRate)}: {}, | ||
//ccv consumer | ||
{MsgType: ccvconsumertypes.ModuleName, Key: string(ccvconsumertypes.KeyRewardDenoms)}: {}, | ||
{MsgType: ccvconsumertypes.ModuleName, Key: string(ccvconsumertypes.KeyEnabled)}: {}, | ||
{MsgType: ccvconsumertypes.ModuleName, Key: string(ccvconsumertypes.KeyBlocksPerDistributionTransmission)}: {}, | ||
{MsgType: ccvconsumertypes.ModuleName, Key: string(ccvconsumertypes.KeyDistributionTransmissionChannel)}: {}, | ||
{MsgType: ccvconsumertypes.ModuleName, Key: string(ccvconsumertypes.KeyProviderFeePoolAddrStr)}: {}, | ||
{MsgType: ccvconsumertypes.ModuleName, Key: string(ccvconsumertypes.KeyTransferTimeoutPeriod)}: {}, | ||
{MsgType: ccvconsumertypes.ModuleName, Key: string(ccvconsumertypes.KeyConsumerRedistributionFrac)}: {}, | ||
{MsgType: ccvconsumertypes.ModuleName, Key: string(ccvconsumertypes.KeyHistoricalEntries)}: {}, | ||
{MsgType: ccvconsumertypes.ModuleName, Key: string(ccvconsumertypes.KeyConsumerUnbondingPeriod)}: {}, | ||
{MsgType: ccvconsumertypes.ModuleName, Key: string(ccvconsumertypes.KeySoftOptOutThreshold)}: {}, | ||
{MsgType: ccvconsumertypes.ModuleName, Key: string(ccvconsumertypes.KeyProviderRewardDenoms)}: {}, | ||
//distribution | ||
{MsgType: distrtypes.ModuleName, Key: string(distrtypes.ParamStoreKeyCommunityTax)}: {}, | ||
{MsgType: distrtypes.ModuleName, Key: string(distrtypes.ParamStoreKeyWithdrawAddrEnabled)}: {}, | ||
//ibc transfer | ||
{MsgType: ibctransfertypes.ModuleName, Key: string(ibctransfertypes.KeySendEnabled)}: {}, | ||
//ica | ||
{MsgType: icahosttypes.SubModuleName, Key: string(icahosttypes.KeyHostEnabled)}: {}, | ||
{MsgType: icahosttypes.SubModuleName, Key: string(icahosttypes.KeyAllowMessages)}: {}, | ||
} |
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.
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.
Check warning
Code scanning / CodeQL
Iteration over map