Skip to content

Commit

Permalink
Handle minStake and maxRank in Msgs
Browse files Browse the repository at this point in the history
  • Loading branch information
p-offtermatt committed Jul 16, 2024
1 parent 44ff049 commit 2eb8dda
Show file tree
Hide file tree
Showing 6 changed files with 276 additions and 109 deletions.
8 changes: 8 additions & 0 deletions proto/interchain_security/ccv/provider/v1/tx.proto
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,10 @@ message MsgConsumerAddition {
repeated string denylist = 17;
// signer address
string authority = 18 [(cosmos_proto.scalar) = "cosmos.AddressString"];
// Corresponds to the minimal amount of (provider chain) stake required to validate on the consumer chain.
int64 min_stake = 19;
// Corresponds to the maximal rank in the provider chain validator set that a validator can have to validate on the consumer chain.
int32 max_rank = 20;
}

// MsgConsumerAdditionResponse defines response type for MsgConsumerAddition messages
Expand Down Expand Up @@ -320,6 +324,10 @@ message MsgConsumerModification {
repeated string denylist = 8;
// signer address
string authority = 9 [(cosmos_proto.scalar) = "cosmos.AddressString"];
// Corresponds to the minimal amount of (provider chain) stake required to validate on the consumer chain.
int64 min_stake = 10;
// Corresponds to the maximal rank in the provider chain validator set that a validator can have to validate on the consumer chain.
int32 max_rank = 11;
}

message MsgConsumerModificationResponse {}
2 changes: 2 additions & 0 deletions x/ccv/provider/keeper/legacy_proposal.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,8 @@ func (k Keeper) HandleLegacyConsumerModificationProposal(ctx sdk.Context, p *typ
k.SetTopN(ctx, p.ChainId, p.Top_N)
k.SetValidatorsPowerCap(ctx, p.ChainId, p.ValidatorsPowerCap)
k.SetValidatorSetCap(ctx, p.ChainId, p.ValidatorSetCap)
k.SetMinStake(ctx, p.ChainId, p.MinStake)
k.SetMaxValidatorRank(ctx, p.ChainId, p.MaxRank)

k.DeleteAllowlist(ctx, p.ChainId)
for _, address := range p.Allowlist {
Expand Down
4 changes: 2 additions & 2 deletions x/ccv/provider/keeper/legacy_proposal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -294,8 +294,8 @@ func TestHandleConsumerModificationProposal(t *testing.T) {
expectedValidatorSetCap := uint32(20)
expectedAllowlistedValidator := "cosmosvalcons1wpex7anfv3jhystyv3eq20r35a"
expectedDenylistedValidator := "cosmosvalcons1nx7n5uh0ztxsynn4sje6eyq2ud6rc6klc96w39"
expectedMinStake := 0
expectedMaxValidatorRank := 20
expectedMinStake := int64(0)
expectedMaxValidatorRank := int32(20)
proposal := providertypes.NewConsumerModificationProposal("title", "description", chainID,
expectedTopN,
expectedValidatorsPowerCap,
Expand Down
2 changes: 2 additions & 0 deletions x/ccv/provider/keeper/proposal.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,8 @@ func (k Keeper) HandleConsumerModificationProposal(ctx sdk.Context, proposal *ty
ValidatorSetCap: proposal.ValidatorSetCap,
Allowlist: proposal.Allowlist,
Denylist: proposal.Denylist,
MinStake: proposal.MinStake,
MaxRank: proposal.MaxRank,
}

return k.HandleLegacyConsumerModificationProposal(ctx, &p)
Expand Down
4 changes: 4 additions & 0 deletions x/ccv/provider/keeper/proposal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -930,6 +930,10 @@ func TestBeginBlockInit(t *testing.T) {

valAddr, _ := sdk.ValAddressFromBech32(validator.GetOperator())
mocks.MockStakingKeeper.EXPECT().GetLastValidatorPower(gomock.Any(), valAddr).Return(int64(1), nil).AnyTimes()

// for each validator, expect a call to GetValidatorByConsAddr with its consensus address
mocks.MockStakingKeeper.EXPECT().GetValidatorByConsAddr(gomock.Any(), consAddr).Return(validator, nil).AnyTimes()

providerKeeper.SetOptedIn(ctx, pendingProps[4].ChainId, providertypes.NewProviderConsAddress(consAddr))

providerKeeper.BeginBlockInit(ctx)
Expand Down
Loading

0 comments on commit 2eb8dda

Please sign in to comment.