Skip to content

Commit

Permalink
feat: bump cosmos-sdk - expedite proposals support (#1970)
Browse files Browse the repository at this point in the history
* deps: bump cosmos-sdk-lsm

* tests: add expedited props changes

* tests: update e2e configs

* provider update gov hooks interface
  • Loading branch information
MSalopek authored Jun 20, 2024
1 parent ec6ea32 commit 1c6d11f
Show file tree
Hide file tree
Showing 9 changed files with 29 additions and 16 deletions.
4 changes: 2 additions & 2 deletions app/consumer-democracy/ante/forbidden_proposals_ante_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -187,11 +187,11 @@ func newLegacyParamChangeProposalMsg(changes []proposal.ParamChange) *govv1.MsgS
if err != nil {
return nil
}
msg, _ := govv1.NewMsgSubmitProposal([]sdk.Msg{msgContent}, sdk.NewCoins(), sdk.AccAddress{}.String(), "", "", "")
msg, _ := govv1.NewMsgSubmitProposal([]sdk.Msg{msgContent}, sdk.NewCoins(), sdk.AccAddress{}.String(), "", "", "", false)
return msg
}

func newParamChangeProposalMsg(msgs []sdk.Msg) *govv1.MsgSubmitProposal {
msg, _ := govv1.NewMsgSubmitProposal(msgs, sdk.NewCoins(), sdk.AccAddress{}.String(), "", "", "")
msg, _ := govv1.NewMsgSubmitProposal(msgs, sdk.NewCoins(), sdk.AccAddress{}.String(), "", "", "", false)
return msg
}
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ require (
cosmossdk.io/math v1.3.0
github.com/cometbft/cometbft v0.37.6
github.com/cometbft/cometbft-db v0.11.0
github.com/cosmos/cosmos-sdk v0.47.12
github.com/cosmos/cosmos-sdk v0.47.16-ics-lsm
github.com/cosmos/gogoproto v1.4.10
github.com/cosmos/ibc-go/v7 v7.6.0
github.com/cosmos/ics23/go v0.10.0
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -335,8 +335,8 @@ github.com/cosmos/btcutil v1.0.5 h1:t+ZFcX77LpKtDBhjucvnOH8C2l2ioGsBNEQ3jef8xFk=
github.com/cosmos/btcutil v1.0.5/go.mod h1:IyB7iuqZMJlthe2tkIFL33xPyzbFYP0XVdS8P5lUPis=
github.com/cosmos/cosmos-proto v1.0.0-beta.5 h1:eNcayDLpip+zVLRLYafhzLvQlSmyab+RC5W7ZfmxJLA=
github.com/cosmos/cosmos-proto v1.0.0-beta.5/go.mod h1:hQGLpiIUloJBMdQMMWb/4wRApmI9hjHH05nefC0Ojec=
github.com/cosmos/cosmos-sdk v0.47.12 h1:KOZHAVWrcilHywBN/FabBaXbDFMzoFmtdX0hqy5Ory8=
github.com/cosmos/cosmos-sdk v0.47.12/go.mod h1:ADjORYzUQqQv/FxDi0H0K5gW/rAk1CiDR3ZKsExfJV0=
github.com/cosmos/cosmos-sdk v0.47.16-ics-lsm h1:+mlfnZ4Cs8HMw9xy7Epjv56avptYSTsX3TVlUDX3Qcs=
github.com/cosmos/cosmos-sdk v0.47.16-ics-lsm/go.mod h1:uzvMwHXmuRDSOaF8ec9HickjLHJcItWBREdkaDHcPiE=
github.com/cosmos/go-bip39 v0.0.0-20180819234021-555e2067c45d/go.mod h1:tSxLoYXyBmiFeKpvmq4dzayMdCjCnu8uqmCysIGBT2Y=
github.com/cosmos/go-bip39 v1.0.0 h1:pcomnQdrdH22njcAatO0yWojsUnCO3y2tNoV1cb6hHY=
github.com/cosmos/go-bip39 v1.0.0/go.mod h1:RNJv0H/pOIVgxw6KS7QeX2a0Uo0aKUlfhZ4xuwvCdJw=
Expand Down
6 changes: 6 additions & 0 deletions tests/e2e/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -373,6 +373,7 @@ func SlashThrottleTestConfig() TestConfig {
IpPrefix: "7.7.7",
VotingWaitTime: 20,
GenesisChanges: ".app_state.gov.params.voting_period = \"20s\" | " +
".app_state.gov.params.expedited_voting_period = \"10s\" | " +
// Custom slashing parameters for testing validator downtime functionality
// See https://docs.cosmos.network/main/modules/slashing/04_begin_block.html#uptime-tracking
".app_state.slashing.params.signed_blocks_window = \"10\" | " +
Expand Down Expand Up @@ -521,6 +522,7 @@ func DefaultTestConfig() TestConfig {
IpPrefix: "7.7.7",
VotingWaitTime: 20,
GenesisChanges: ".app_state.gov.params.voting_period = \"20s\" | " +
".app_state.gov.params.expedited_voting_period = \"10s\" | " +
// Custom slashing parameters for testing validator downtime functionality
// See https://docs.cosmos.network/main/modules/slashing/04_begin_block.html#uptime-tracking
".app_state.slashing.params.signed_blocks_window = \"10\" | " +
Expand Down Expand Up @@ -642,6 +644,8 @@ func MultiConsumerTestConfig() TestConfig {
IpPrefix: "7.7.7",
VotingWaitTime: 20,
GenesisChanges: ".app_state.gov.params.voting_period = \"30s\" | " +
".app_state.gov.params.expedited_voting_period = \"10s\" | " +

// Custom slashing parameters for testing validator downtime functionality
// See https://docs.cosmos.network/main/modules/slashing/04_begin_block.html#uptime-tracking
".app_state.slashing.params.signed_blocks_window = \"10\" | " +
Expand Down Expand Up @@ -701,6 +705,8 @@ func ChangeoverTestConfig() TestConfig {
IpPrefix: "7.7.7",
VotingWaitTime: 20,
GenesisChanges: ".app_state.gov.params.voting_period = \"20s\" | " +
".app_state.gov.params.expedited_voting_period = \"10s\" | " +

// Custom slashing parameters for testing validator downtime functionality
// See https://docs.cosmos.network/main/modules/slashing/04_begin_block.html#uptime-tracking
".app_state.slashing.params.signed_blocks_window = \"10\" | " +
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/democracy.go
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ func (s *ConsumerDemocracyTestSuite) TestDemocracyGovernanceWhitelisting() {
func submitProposalWithDepositAndVote(govKeeper testutil.TestGovKeeper, ctx sdk.Context, msgs []sdk.Msg,
accounts []ibctesting.SenderAccount, proposer sdk.AccAddress, depositAmount sdk.Coins,
) error {
proposal, err := govKeeper.SubmitProposal(ctx, msgs, "", "title", "summary", proposer)
proposal, err := govKeeper.SubmitProposal(ctx, msgs, "", "title", "summary", proposer, false)
if err != nil {
return err
}
Expand Down
2 changes: 1 addition & 1 deletion testutil/integration/interfaces.go
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ type TestMintKeeper interface {
type TestGovKeeper interface {
GetParams(ctx sdk.Context) govv1.Params
SetParams(ctx sdk.Context, params govv1.Params) error
SubmitProposal(ctx sdk.Context, messages []sdk.Msg, metadata, title, summary string, proposer sdk.AccAddress) (govv1.Proposal, error)
SubmitProposal(ctx sdk.Context, messages []sdk.Msg, metadata, title, summary string, proposer sdk.AccAddress, expedited bool) (govv1.Proposal, error)
AddDeposit(ctx sdk.Context, proposalID uint64, depositorAddr sdk.AccAddress, depositAmount sdk.Coins) (bool, error)
AddVote(ctx sdk.Context, proposalID uint64, voterAddr sdk.AccAddress, options govv1.WeightedVoteOptions, metadata string) error
}
8 changes: 4 additions & 4 deletions x/ccv/provider/client/proposal_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ Where proposal.json contains:
return err
}

msg, err := govv1.NewMsgSubmitProposal([]sdk.Msg{msgContent}, deposit, from.String(), "", content.GetTitle(), proposal.Summary)
msg, err := govv1.NewMsgSubmitProposal([]sdk.Msg{msgContent}, deposit, from.String(), "", content.GetTitle(), proposal.Summary, false)
if err != nil {
return err
}
Expand Down Expand Up @@ -163,7 +163,7 @@ Where proposal.json contains:
return err
}

msg, err := govv1.NewMsgSubmitProposal([]sdk.Msg{msgContent}, deposit, from.String(), "", content.GetTitle(), proposal.Summary)
msg, err := govv1.NewMsgSubmitProposal([]sdk.Msg{msgContent}, deposit, from.String(), "", content.GetTitle(), proposal.Summary, false)
if err != nil {
return err
}
Expand Down Expand Up @@ -227,7 +227,7 @@ Where proposal.json contains:
return err
}

msg, err := govv1.NewMsgSubmitProposal([]sdk.Msg{msgContent}, deposit, from.String(), "", content.GetTitle(), proposal.Summary)
msg, err := govv1.NewMsgSubmitProposal([]sdk.Msg{msgContent}, deposit, from.String(), "", content.GetTitle(), proposal.Summary, false)
if err != nil {
return err
}
Expand Down Expand Up @@ -284,7 +284,7 @@ func SubmitChangeRewardDenomsProposalTxCmd() *cobra.Command {
return err
}

msg, err := govv1.NewMsgSubmitProposal([]sdk.Msg{msgContent}, deposit, from.String(), "", content.GetTitle(), proposal.Summary)
msg, err := govv1.NewMsgSubmitProposal([]sdk.Msg{msgContent}, deposit, from.String(), "", content.GetTitle(), proposal.Summary, false)
if err != nil {
return err
}
Expand Down
15 changes: 10 additions & 5 deletions x/ccv/provider/keeper/hooks.go
Original file line number Diff line number Diff line change
Expand Up @@ -213,29 +213,34 @@ func (h Hooks) BeforeDelegationRemoved(_ sdk.Context, _ sdk.AccAddress, _ sdk.Va
// AfterProposalSubmission - call hook if registered
// After a consumerAddition proposal submission, a record is created
// that maps the proposal ID to the consumer chain ID.
func (h Hooks) AfterProposalSubmission(ctx sdk.Context, proposalID uint64) {
func (h Hooks) AfterProposalSubmission(ctx sdk.Context, proposalID uint64) error {
if p, ok := h.GetConsumerAdditionLegacyPropFromProp(ctx, proposalID); ok {
h.k.SetProposedConsumerChain(ctx, p.ChainId, proposalID)
}
return nil
}

// AfterProposalVotingPeriodEnded - call hook if registered
// After proposal voting ends, the consumer chainID in store is deleted.
// When a consumerAddition proposal passes, the consumer chainID is available in providerKeeper.GetAllPendingConsumerAdditionProps
// or providerKeeper.GetAllConsumerChains(ctx).
func (h Hooks) AfterProposalVotingPeriodEnded(ctx sdk.Context, proposalID uint64) {
func (h Hooks) AfterProposalVotingPeriodEnded(ctx sdk.Context, proposalID uint64) error {
if _, ok := h.GetConsumerAdditionLegacyPropFromProp(ctx, proposalID); ok {
h.k.DeleteProposedConsumerChainInStore(ctx, proposalID)
}
return nil
}

func (h Hooks) AfterProposalDeposit(ctx sdk.Context, proposalID uint64, depositorAddr sdk.AccAddress) {
func (h Hooks) AfterProposalDeposit(ctx sdk.Context, proposalID uint64, depositorAddr sdk.AccAddress) error {
return nil
}

func (h Hooks) AfterProposalVote(ctx sdk.Context, proposalID uint64, voterAddr sdk.AccAddress) {
func (h Hooks) AfterProposalVote(ctx sdk.Context, proposalID uint64, voterAddr sdk.AccAddress) error {
return nil
}

func (h Hooks) AfterProposalFailedMinDeposit(ctx sdk.Context, proposalID uint64) {
func (h Hooks) AfterProposalFailedMinDeposit(ctx sdk.Context, proposalID uint64) error {
return nil
}

// GetConsumerAdditionLegacyPropFromProp extracts a consumer addition legacy proposal from
Expand Down
2 changes: 2 additions & 0 deletions x/ccv/provider/keeper/hooks_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ func TestAfterPropSubmissionAndVotingPeriodEnded(t *testing.T) {
"",
"",
sdk.AccAddress(acct.SDKValOpAddress()),
false,
)
require.NoError(t, err)

Expand Down Expand Up @@ -202,6 +203,7 @@ func TestGetConsumerAdditionLegacyPropFromProp(t *testing.T) {
"",
"",
sdk.AccAddress(acct.SDKValOpAddress()),
false,
)
require.NoError(t, err)
}
Expand Down

0 comments on commit 1c6d11f

Please sign in to comment.