From 771be378b7b7cb5d8746971cc01c932f5f2a5e63 Mon Sep 17 00:00:00 2001 From: Marius Poke Date: Tue, 27 Aug 2024 20:39:33 +0200 Subject: [PATCH] fix!: ConsumerModificationProposal is needed in Gaia upgrade handler (#2176) ConsumerModificationProposal is needed in Gaia upgrade handler --- x/ccv/provider/types/legacy_proposal.go | 54 ++++++++++++++++++++++++- 1 file changed, 52 insertions(+), 2 deletions(-) diff --git a/x/ccv/provider/types/legacy_proposal.go b/x/ccv/provider/types/legacy_proposal.go index f29f3b6c07..3124cc3d87 100644 --- a/x/ccv/provider/types/legacy_proposal.go +++ b/x/ccv/provider/types/legacy_proposal.go @@ -20,8 +20,8 @@ import ( const ( ProposalTypeConsumerAddition = "ConsumerAddition" - ProposalTypeConsumerRemoval = "RemoveConsumer" - ProposalTypeConsumerModification = "UpdateConsumer" + ProposalTypeConsumerRemoval = "ConsumerRemoval" + ProposalTypeConsumerModification = "ConsumerModification" ProposalTypeEquivocation = "Equivocation" ProposalTypeChangeRewardDenoms = "ChangeRewardDenoms" ) @@ -29,6 +29,7 @@ const ( var ( _ govv1beta1.Content = &ConsumerAdditionProposal{} _ govv1beta1.Content = &ConsumerRemovalProposal{} + _ govv1beta1.Content = &ConsumerModificationProposal{} _ govv1beta1.Content = &ChangeRewardDenomsProposal{} _ govv1beta1.Content = &EquivocationProposal{} ) @@ -239,6 +240,55 @@ func (sccp *ConsumerRemovalProposal) ValidateBasic() error { return nil } +// NewConsumerModificationProposal creates a new consumer modification proposal. +func NewConsumerModificationProposal(title, description, chainID string, + topN uint32, + validatorsPowerCap uint32, + validatorSetCap uint32, + allowlist []string, + denylist []string, + minStake uint64, + allowInactiveVals bool, +) govv1beta1.Content { + return &ConsumerModificationProposal{ + Title: title, + Description: description, + ChainId: chainID, + Top_N: topN, + ValidatorsPowerCap: validatorsPowerCap, + ValidatorSetCap: validatorSetCap, + Allowlist: allowlist, + Denylist: denylist, + MinStake: minStake, + AllowInactiveVals: allowInactiveVals, + } +} + +// ProposalRoute returns the routing key of a consumer modification proposal. +func (cccp *ConsumerModificationProposal) ProposalRoute() string { return RouterKey } + +// ProposalType returns the type of the consumer modification proposal. +func (cccp *ConsumerModificationProposal) ProposalType() string { + return ProposalTypeConsumerModification +} + +// ValidateBasic runs basic stateless validity checks +func (cccp *ConsumerModificationProposal) ValidateBasic() error { + if err := govv1beta1.ValidateAbstract(cccp); err != nil { + return err + } + + if strings.TrimSpace(cccp.ChainId) == "" { + return errorsmod.Wrap(ErrInvalidConsumerModificationProposal, "consumer chain id must not be blank") + } + + err := ValidatePSSFeatures(cccp.Top_N, cccp.ValidatorsPowerCap) + if err != nil { + return errorsmod.Wrapf(ErrInvalidConsumerModificationProposal, "invalid PSS features: %s", err.Error()) + } + return nil +} + // NewEquivocationProposal creates a new equivocation proposal. // [DEPRECATED]: do not use because equivocations can be submitted // and verified automatically on the provider.