Skip to content

Commit

Permalink
minor
Browse files Browse the repository at this point in the history
  • Loading branch information
vuong177 committed Apr 22, 2023
1 parent 591f182 commit f824f84
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 32 deletions.
6 changes: 3 additions & 3 deletions x/ccv/democracy/governance/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ func (am AppModule) EndBlock(ctx sdk.Context, request abci.RequestEndBlock) []ab
}

func deleteForbiddenProposal(ctx sdk.Context, am AppModule, proposal v1.Proposal) {
if am.isProposalWhitelisted(proposal.Content) {
if am.isProposalWhitelisted(proposal.Messages) {
return
}
// delete the votes related to the proposal calling Tally
Expand All @@ -78,7 +78,7 @@ func deleteForbiddenProposal(ctx sdk.Context, am AppModule, proposal v1.Proposal
logger := am.keeper.Logger(ctx)
logger.Info(
"proposal is not whitelisted; deleted",
"proposal", proposal.ProposalId,
"proposal", proposal.Id,
"title", proposal.GetTitle(),
"total_deposit", proposal.TotalDeposit.String())
"total_deposit", proposal.TotalDeposit)
}
6 changes: 3 additions & 3 deletions x/ccv/provider/proposal_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,16 @@ package provider
import (
sdk "github.com/cosmos/cosmos-sdk/types"
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types"
"github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1"
"github.com/cosmos/interchain-security/x/ccv/provider/keeper"
"github.com/cosmos/interchain-security/x/ccv/provider/types"
)

// NewProviderProposalHandler defines the handler for consumer addition,
// consumer removal and equivocation proposals.
// Passed proposals are executed during EndBlock.
func NewProviderProposalHandler(k keeper.Keeper) govtypes.Handler {
return func(ctx sdk.Context, content govtypes.Content) error {
func NewProviderProposalHandler(k keeper.Keeper) v1beta1.Handler {
return func(ctx sdk.Context, content v1beta1.Content) error {
switch c := content.(type) {
case *types.ConsumerAdditionProposal:
return k.HandleConsumerAdditionProposal(ctx, c)
Expand Down
4 changes: 2 additions & 2 deletions x/ccv/provider/proposal_handler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ import (
sdk "github.com/cosmos/cosmos-sdk/types"
distributiontypes "github.com/cosmos/cosmos-sdk/x/distribution/types"
evidencetypes "github.com/cosmos/cosmos-sdk/x/evidence/types"
"github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1"
"github.com/golang/mock/gomock"
"github.com/stretchr/testify/require"

clienttypes "github.com/cosmos/ibc-go/v7/modules/core/02-client/types"

govtypes "github.com/cosmos/cosmos-sdk/x/gov/types"
testkeeper "github.com/cosmos/interchain-security/testutil/keeper"
"github.com/cosmos/interchain-security/x/ccv/provider"
providertypes "github.com/cosmos/interchain-security/x/ccv/provider/types"
Expand All @@ -28,7 +28,7 @@ func TestProviderProposalHandler(t *testing.T) {

testCases := []struct {
name string
content govtypes.Content
content v1beta1.Content
blockTime time.Time
expValidConsumerAddition bool
expValidConsumerRemoval bool
Expand Down
8 changes: 4 additions & 4 deletions x/ccv/provider/types/codec.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
codectypes "github.com/cosmos/cosmos-sdk/codec/types"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/msgservice"
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types"
"github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1"
)

// RegisterLegacyAminoCodec registers the necessary x/ibc transfer interfaces and concrete types
Expand All @@ -16,19 +16,19 @@ func RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) {
// RegisterInterfaces registers the provider proposal structs to the interface registry
func RegisterInterfaces(registry codectypes.InterfaceRegistry) {
registry.RegisterImplementations(
(*govtypes.Content)(nil),
(*v1beta1.Content)(nil),
&ConsumerAdditionProposal{},
)
registry.RegisterImplementations(
(*govtypes.Content)(nil),
(*v1beta1.Content)(nil),
&ConsumerRemovalProposal{},
)
registry.RegisterImplementations(
(*sdk.Msg)(nil),
&MsgAssignConsumerKey{},
)
registry.RegisterImplementations(
(*govtypes.Content)(nil),
(*v1beta1.Content)(nil),
&EquivocationProposal{},
)
msgservice.RegisterMsgServiceDesc(registry, &_Msg_serviceDesc)
Expand Down
29 changes: 13 additions & 16 deletions x/ccv/provider/types/genesis_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ func TestValidateGenesisState(t *testing.T) {
nil,
nil,
types.NewParams(ibctmtypes.NewClientState("", ibctmtypes.DefaultTrustLevel, 0, 0,
time.Second*40, clienttypes.Height{}, commitmenttypes.GetSDKSpecs(), []string{"ibc", "upgradedIBCState"}, true, false),
time.Second*40, clienttypes.Height{}, commitmenttypes.GetSDKSpecs(), []string{"ibc", "upgradedIBCState"}),
types.DefaultTrustingPeriodFraction, time.Hour, time.Hour, 30*time.Minute, time.Hour, "0.1", 400),
nil,
nil,
Expand All @@ -92,7 +92,7 @@ func TestValidateGenesisState(t *testing.T) {
nil,
nil,
types.NewParams(ibctmtypes.NewClientState("", ibctmtypes.DefaultTrustLevel, 0, 0,
time.Second*40, clienttypes.Height{}, commitmenttypes.GetSDKSpecs(), []string{"ibc", "upgradedIBCState"}, true, false),
time.Second*40, clienttypes.Height{}, commitmenttypes.GetSDKSpecs(), []string{"ibc", "upgradedIBCState"}),
types.DefaultTrustingPeriodFraction, time.Hour, time.Hour, 30*time.Minute, time.Hour, "0.1", 400),
nil,
nil,
Expand All @@ -111,7 +111,7 @@ func TestValidateGenesisState(t *testing.T) {
nil,
nil,
types.NewParams(ibctmtypes.NewClientState("", ibctmtypes.DefaultTrustLevel, 0, 0,
time.Second*40, clienttypes.Height{}, commitmenttypes.GetSDKSpecs(), []string{"ibc", "upgradedIBCState"}, true, false),
time.Second*40, clienttypes.Height{}, commitmenttypes.GetSDKSpecs(), []string{"ibc", "upgradedIBCState"}),
types.DefaultTrustingPeriodFraction, time.Hour, time.Hour, 30*time.Minute, time.Hour, "0.1", 400),
nil,
nil,
Expand All @@ -130,7 +130,7 @@ func TestValidateGenesisState(t *testing.T) {
nil,
nil,
types.NewParams(ibctmtypes.NewClientState("", ibctmtypes.DefaultTrustLevel, 0, 0,
time.Second*40, clienttypes.Height{}, commitmenttypes.GetSDKSpecs(), []string{"ibc", "upgradedIBCState"}, true, false),
time.Second*40, clienttypes.Height{}, commitmenttypes.GetSDKSpecs(), []string{"ibc", "upgradedIBCState"}),
types.DefaultTrustingPeriodFraction, time.Hour, time.Hour, 30*time.Minute, time.Hour, "0.1", 400),
nil,
nil,
Expand All @@ -149,7 +149,7 @@ func TestValidateGenesisState(t *testing.T) {
nil,
nil,
types.NewParams(ibctmtypes.NewClientState("", ibctmtypes.DefaultTrustLevel, 0, 0,
0, clienttypes.Height{}, nil, []string{"ibc", "upgradedIBCState"}, true, false),
0, clienttypes.Height{}, nil, []string{"ibc", "upgradedIBCState"}),
types.DefaultTrustingPeriodFraction,
ccv.DefaultCCVTimeoutPeriod,
types.DefaultInitTimeoutPeriod,
Expand All @@ -174,7 +174,7 @@ func TestValidateGenesisState(t *testing.T) {
nil,
nil,
types.NewParams(ibctmtypes.NewClientState("", ibctmtypes.DefaultTrustLevel, 0, 0,
time.Second*40, clienttypes.Height{}, commitmenttypes.GetSDKSpecs(), []string{"ibc", "upgradedIBCState"}, true, false),
time.Second*40, clienttypes.Height{}, commitmenttypes.GetSDKSpecs(), []string{"ibc", "upgradedIBCState"}),
"0.0", // 0 trusting period fraction here
ccv.DefaultCCVTimeoutPeriod,
types.DefaultInitTimeoutPeriod,
Expand All @@ -199,7 +199,7 @@ func TestValidateGenesisState(t *testing.T) {
nil,
nil,
types.NewParams(ibctmtypes.NewClientState("", ibctmtypes.DefaultTrustLevel, 0, 0,
time.Second*40, clienttypes.Height{}, commitmenttypes.GetSDKSpecs(), []string{"ibc", "upgradedIBCState"}, true, false),
time.Second*40, clienttypes.Height{}, commitmenttypes.GetSDKSpecs(), []string{"ibc", "upgradedIBCState"}),
types.DefaultTrustingPeriodFraction,
0, // 0 ccv timeout here
types.DefaultInitTimeoutPeriod,
Expand All @@ -224,7 +224,7 @@ func TestValidateGenesisState(t *testing.T) {
nil,
nil,
types.NewParams(ibctmtypes.NewClientState("", ibctmtypes.DefaultTrustLevel, 0, 0,
time.Second*40, clienttypes.Height{}, commitmenttypes.GetSDKSpecs(), []string{"ibc", "upgradedIBCState"}, true, false),
time.Second*40, clienttypes.Height{}, commitmenttypes.GetSDKSpecs(), []string{"ibc", "upgradedIBCState"}),
types.DefaultTrustingPeriodFraction,
ccv.DefaultCCVTimeoutPeriod,
0, // 0 init timeout here
Expand All @@ -249,7 +249,7 @@ func TestValidateGenesisState(t *testing.T) {
nil,
nil,
types.NewParams(ibctmtypes.NewClientState("", ibctmtypes.DefaultTrustLevel, 0, 0,
time.Second*40, clienttypes.Height{}, commitmenttypes.GetSDKSpecs(), []string{"ibc", "upgradedIBCState"}, true, false),
time.Second*40, clienttypes.Height{}, commitmenttypes.GetSDKSpecs(), []string{"ibc", "upgradedIBCState"}),
types.DefaultTrustingPeriodFraction,
ccv.DefaultCCVTimeoutPeriod,
types.DefaultInitTimeoutPeriod,
Expand All @@ -274,7 +274,7 @@ func TestValidateGenesisState(t *testing.T) {
nil,
nil,
types.NewParams(ibctmtypes.NewClientState("", ibctmtypes.DefaultTrustLevel, 0, 0,
time.Second*40, clienttypes.Height{}, commitmenttypes.GetSDKSpecs(), []string{"ibc", "upgradedIBCState"}, true, false),
time.Second*40, clienttypes.Height{}, commitmenttypes.GetSDKSpecs(), []string{"ibc", "upgradedIBCState"}),
types.DefaultTrustingPeriodFraction,
ccv.DefaultCCVTimeoutPeriod,
types.DefaultInitTimeoutPeriod,
Expand All @@ -299,7 +299,7 @@ func TestValidateGenesisState(t *testing.T) {
nil,
nil,
types.NewParams(ibctmtypes.NewClientState("", ibctmtypes.DefaultTrustLevel, 0, 0,
time.Second*40, clienttypes.Height{}, commitmenttypes.GetSDKSpecs(), []string{"ibc", "upgradedIBCState"}, true, false),
time.Second*40, clienttypes.Height{}, commitmenttypes.GetSDKSpecs(), []string{"ibc", "upgradedIBCState"}),
types.DefaultTrustingPeriodFraction,
ccv.DefaultCCVTimeoutPeriod,
types.DefaultInitTimeoutPeriod,
Expand All @@ -324,7 +324,7 @@ func TestValidateGenesisState(t *testing.T) {
nil,
nil,
types.NewParams(ibctmtypes.NewClientState("", ibctmtypes.DefaultTrustLevel, 0, 0,
time.Second*40, clienttypes.Height{}, commitmenttypes.GetSDKSpecs(), []string{"ibc", "upgradedIBCState"}, true, false),
time.Second*40, clienttypes.Height{}, commitmenttypes.GetSDKSpecs(), []string{"ibc", "upgradedIBCState"}),
types.DefaultTrustingPeriodFraction,
ccv.DefaultCCVTimeoutPeriod,
types.DefaultInitTimeoutPeriod,
Expand Down Expand Up @@ -678,10 +678,7 @@ func getInitialConsumerGenesis(t *testing.T, chainID string) consumertypes.Genes
time.Duration(1),
clienttypes.Height{RevisionNumber: clienttypes.ParseChainID(chainID), RevisionHeight: 1},
commitmenttypes.GetSDKSpecs(),
[]string{"upgrade", "upgradedIBCState"},
true,
true,
)
[]string{"upgrade", "upgradedIBCState"})
consensusState := ibctmtypes.NewConsensusState(time.Now(), commitmenttypes.NewMerkleRoot([]byte("apphash")), valHash)

params := consumertypes.DefaultParams()
Expand Down
2 changes: 1 addition & 1 deletion x/ccv/provider/types/params_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ func TestValidateParams(t *testing.T) {
time.Second*40, clienttypes.Height{}, commitmenttypes.GetSDKSpecs(), []string{"ibc", "upgradedIBCState"}),
"0.33", time.Hour, time.Hour, time.Hour, 30*time.Minute, "0.1", 100), true},
{"custom invalid params", types.NewParams(ibctmtypes.NewClientState("", ibctmtypes.DefaultTrustLevel, 0, 0,
0, clienttypes.Height{}, nil, []string{"ibc", "upgradedIBCState"}, true, false),
0, clienttypes.Height{}, nil, []string{"ibc", "upgradedIBCState"}),
"0.33", time.Hour, time.Hour, time.Hour, 30*time.Minute, "0.1", 100), false},
{"blank client", types.NewParams(&ibctmtypes.ClientState{},
"0.33", time.Hour, time.Hour, time.Hour, 30*time.Minute, "0.1", 100), false},
Expand Down
5 changes: 2 additions & 3 deletions x/ccv/provider/types/proposal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import (

"github.com/cosmos/cosmos-sdk/codec"
codectypes "github.com/cosmos/cosmos-sdk/codec/types"
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types"
"github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1"

clienttypes "github.com/cosmos/ibc-go/v7/modules/core/02-client/types"
Expand Down Expand Up @@ -219,7 +218,7 @@ func TestMarshalConsumerAdditionProposal(t *testing.T) {
// create codec
ir := codectypes.NewInterfaceRegistry()
types.RegisterInterfaces(ir)
govtypes.RegisterInterfaces(ir)
v1beta1.RegisterInterfaces(ir)
clienttypes.RegisterInterfaces(ir)
ibctmtypes.RegisterInterfaces(ir)
cdc := codec.NewProtoCodec(ir)
Expand Down Expand Up @@ -281,7 +280,7 @@ func TestConsumerAdditionProposalString(t *testing.T) {
func TestEquivocationProposalValidateBasic(t *testing.T) {
tests := []struct {
name string
proposal govtypes.Content
proposal v1beta1.Content
expectedError string
}{
{
Expand Down

0 comments on commit f824f84

Please sign in to comment.