Skip to content

Commit

Permalink
fix!: ConsumerModificationProposal is needed in Gaia upgrade handler (#…
Browse files Browse the repository at this point in the history
…2176)

ConsumerModificationProposal is needed in Gaia upgrade handler
  • Loading branch information
mpoke committed Aug 27, 2024
1 parent 19be098 commit 771be37
Showing 1 changed file with 52 additions and 2 deletions.
54 changes: 52 additions & 2 deletions x/ccv/provider/types/legacy_proposal.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,16 @@ import (

const (
ProposalTypeConsumerAddition = "ConsumerAddition"
ProposalTypeConsumerRemoval = "RemoveConsumer"
ProposalTypeConsumerModification = "UpdateConsumer"
ProposalTypeConsumerRemoval = "ConsumerRemoval"
ProposalTypeConsumerModification = "ConsumerModification"
ProposalTypeEquivocation = "Equivocation"
ProposalTypeChangeRewardDenoms = "ChangeRewardDenoms"
)

var (
_ govv1beta1.Content = &ConsumerAdditionProposal{}
_ govv1beta1.Content = &ConsumerRemovalProposal{}
_ govv1beta1.Content = &ConsumerModificationProposal{}
_ govv1beta1.Content = &ChangeRewardDenomsProposal{}
_ govv1beta1.Content = &EquivocationProposal{}
)
Expand Down Expand Up @@ -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.
Expand Down

0 comments on commit 771be37

Please sign in to comment.