Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat!: Add support for priority validators #2101

Merged
merged 41 commits into from
Oct 25, 2024
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
536243a
Start adding priority validators
p-offtermatt Jul 26, 2024
7b7612e
Add new priority_validator field
p-offtermatt Jul 26, 2024
c3df006
Resolve conflicts with main
kirdatatjana Oct 7, 2024
f96fb22
Added priority list to the PowerShapingParameters
kirdatatjana Oct 15, 2024
e41bd64
Add documentation for priority list
kirdatatjana Oct 16, 2024
5893cd3
Add priority list in local-testnet.sh
kirdatatjana Oct 16, 2024
09beb73
Update .changelog/unreleased/features/provider/xxxx-priority-validato…
kirdatatjana Oct 16, 2024
d442765
Update x/ccv/provider/keeper/power_shaping.go
kirdatatjana Oct 16, 2024
e6b17ef
Update x/ccv/provider/keeper/power_shaping_test.go
kirdatatjana Oct 16, 2024
4083463
Update x/ccv/provider/keeper/power_shaping_test.go
kirdatatjana Oct 16, 2024
508aa1c
Update .changelog/unreleased/api-breaking/provider/xxxx-priority-vali…
kirdatatjana Oct 16, 2024
da41d15
Fix typo in provider.proto
kirdatatjana Oct 16, 2024
a7572eb
Merge branch 'ph/priority-validators' of https://github.com/cosmos/in…
kirdatatjana Oct 16, 2024
165ef87
Remove unnecessary priority list from test in steps_permissionless_ic…
kirdatatjana Oct 16, 2024
d5cb420
Remove comment from grpc_query.go
kirdatatjana Oct 16, 2024
b6788e6
Add e2e test for priority list
kirdatatjana Oct 16, 2024
1c19591
Improved e2e test
kirdatatjana Oct 17, 2024
b36e28f
Merge branch 'main' into ph/priority-validators
kirdatatjana Oct 17, 2024
171246d
Merge branch 'main' into ph/priority-validators
kirdatatjana Oct 17, 2024
ae2c771
Fixed some issues
kirdatatjana Oct 21, 2024
e40a8c6
Refactored code logic
kirdatatjana Oct 21, 2024
e878390
Refactored code logic
kirdatatjana Oct 22, 2024
837a078
Renamed files
kirdatatjana Oct 22, 2024
04e9c57
Removed priority list from migrations.go
kirdatatjana Oct 22, 2024
f866876
Fixed bug for priority list
kirdatatjana Oct 23, 2024
21d8ff7
Added priority list to e2e nightly tests
kirdatatjana Oct 23, 2024
abd2773
Update tx.go
kirdatatjana Oct 23, 2024
2c83503
Refactored TestCapValidatorSet
kirdatatjana Oct 23, 2024
a78038f
Merge branch 'ph/priority-validators' of https://github.com/cosmos/in…
kirdatatjana Oct 23, 2024
5ef9ff2
Small fixes
kirdatatjana Oct 24, 2024
ba04ab8
Small fixes
kirdatatjana Oct 24, 2024
d5d043b
Fix PartitionBasedOnPriorityList function
kirdatatjana Oct 24, 2024
31e8001
Update contrib/local-testnet.sh
kirdatatjana Oct 25, 2024
cc84d75
Moved 2101-introduce-priority-validators.md into state-breaking
kirdatatjana Oct 25, 2024
6336f9d
Merge branch 'ph/priority-validators' of https://github.com/cosmos/in…
kirdatatjana Oct 25, 2024
adc3a0e
Fixed TestGetConsumerChain
kirdatatjana Oct 25, 2024
94eba83
Added test case in TestCapValidatorSet
kirdatatjana Oct 25, 2024
a49866c
Revert changes made by the merge
kirdatatjana Oct 25, 2024
0b38ed4
Removed changes from ADRs that were already implemented
kirdatatjana Oct 25, 2024
a1d974d
Added a comment in CapValidatorSet function
kirdatatjana Oct 25, 2024
9f4d771
Removed unnecessary imports
kirdatatjana Oct 25, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
- Allow consumer chains to specify a list of priority validators that are included in the validator set before other validators are considered
kirdatatjana marked this conversation as resolved.
Show resolved Hide resolved
([\#xxxx](https://github.com/cosmos/interchain-security/pull/xxxx))
kirdatatjana marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
- Allow consumer chains to specify a list of priority validators that are included in the validator set before other validators are considered
([\#xxxx](https://github.com/cosmos/interchain-security/pull/xxxx))
kirdatatjana marked this conversation as resolved.
Show resolved Hide resolved
7 changes: 6 additions & 1 deletion proto/interchain_security/ccv/provider/v1/provider.proto
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ message ConsumerAdditionProposal {
bytes binary_hash = 6;
// spawn time is the time on the provider chain at which the consumer chain
// genesis is finalized and all validators will be responsible for starting
// their consumer chain validator node.
// their consumer chain validator nodeConsumerAd.
kirdatatjana marked this conversation as resolved.
Show resolved Hide resolved
google.protobuf.Timestamp spawn_time = 7
[ (gogoproto.stdtime) = true, (gogoproto.nullable) = false ];

Expand Down Expand Up @@ -489,6 +489,11 @@ message PowerShapingParameters {
uint64 min_stake = 6;
// Corresponds to whether inactive validators are allowed to validate the consumer chain.
bool allow_inactive_vals = 7;
// Corresponds to a list of provider consensus addresses of validators that should have PRIORITY to validate on the consumer chain,
// meaning as long as they are eligible/opted in to validate on the consumer chain, the validator set will be
// filled with these validators first, and other validators will be added to the validator set only if there are
// not enough eligible priority validators.
repeated string prioritylist = 8;
}

// ConsumerIds contains consumer ids of chains
Expand Down
5 changes: 5 additions & 0 deletions proto/interchain_security/ccv/provider/v1/query.proto
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,11 @@ message Chain {
string consumer_id = 13;
// the reward denoms allowlisted by this consumer chain
AllowlistedRewardDenoms allowlisted_reward_denoms = 14;
// Corresponds to a list of provider consensus addresses of validators that should have PRIORITY to validate on the consumer chain,
// meaning as long as they are eligible/opted in to validate on the consumer chain, the validator set will be
// filled with these validators first, and other validators will be added to the validator set only if there are
// not enough eligible priority validators.
repeated string prioritylist = 15;
}

message QueryValidatorConsumerAddrRequest {
Expand Down
9 changes: 9 additions & 0 deletions tests/e2e/actions.go
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,7 @@ type PowerShapingParameters struct {
Denylist []string
MinStake uint64
AllowInactiveVals bool
Prioritylist []string
}

func (tr Chain) updateConsumerChain(action UpdateConsumerChainAction, verbose bool) {
Expand Down Expand Up @@ -320,6 +321,7 @@ func (tr Chain) updateConsumerChain(action UpdateConsumerChainAction, verbose bo
Denylist: action.PowerShapingParams.Denylist,
MinStake: action.PowerShapingParams.MinStake,
AllowInactiveVals: action.PowerShapingParams.AllowInactiveVals,
Prioritylist: action.PowerShapingParams.Prioritylist,
}

consumerId := tr.testConfig.chainConfigs[action.ConsumerChain].ConsumerId
Expand Down Expand Up @@ -376,6 +378,7 @@ func (tr Chain) createConsumerChain(action CreateConsumerChainAction, verbose bo
Denylist: action.PowerShapingParams.Denylist,
MinStake: action.PowerShapingParams.MinStake,
AllowInactiveVals: action.PowerShapingParams.AllowInactiveVals,
Prioritylist: action.PowerShapingParams.Prioritylist,
}

metadata := types.ConsumerMetadata{
Expand Down Expand Up @@ -463,6 +466,7 @@ type SubmitConsumerAdditionProposalAction struct {
Denylist []string
MinStake uint64
AllowInactiveVals bool
Prioritylist []string
}

func (tr Chain) UpdateConsumer(providerChain ChainID, validator ValidatorID, update types.MsgUpdateConsumer, verbose bool) {
Expand Down Expand Up @@ -657,6 +661,7 @@ func (tr Chain) submitConsumerAdditionProposal(
Denylist: action.Denylist,
MinStake: action.MinStake,
AllowInactiveVals: action.AllowInactiveVals,
Prioritylist: action.Prioritylist,
}
update.PowerShapingParameters = &powerShapingParameters
tr.UpdateConsumer(action.Chain, action.From, *update, verbose)
Expand Down Expand Up @@ -757,6 +762,7 @@ func (tr Chain) submitConsumerAdditionLegacyProposal(
Denylist: action.Denylist,
MinStake: action.MinStake,
AllowInactiveVals: action.AllowInactiveVals,
Prioritylist: action.Prioritylist,
}

bz, err := json.Marshal(prop)
Expand Down Expand Up @@ -937,6 +943,7 @@ type SubmitConsumerModificationProposalAction struct {
AllowInactiveVals bool
MinStake uint64
NewOwner string
Prioritylist []string
}

func (tr Chain) submitConsumerModificationProposal(
Expand All @@ -962,6 +969,7 @@ func (tr Chain) submitConsumerModificationProposal(
ValidatorSetCap: action.ValidatorSetCap,
Allowlist: action.Allowlist,
Denylist: action.Denylist,
Prioritylist: action.Prioritylist,
},
}

Expand Down Expand Up @@ -1019,6 +1027,7 @@ func (tr Chain) submitConsumerModificationLegacyProposal(
ValidatorSetCap: action.ValidatorSetCap,
Allowlist: action.Allowlist,
Denylist: action.Denylist,
Prioritylist: action.Prioritylist,
}

bz, err := json.Marshal(prop)
Expand Down
7 changes: 4 additions & 3 deletions tests/e2e/steps_permissionless_ics.go
Original file line number Diff line number Diff line change
Expand Up @@ -142,9 +142,10 @@ func stepsPermissionlessICS() []Step {
SpawnTime: 0,
},
PowerShapingParams: &PowerShapingParameters{
TopN: 0,
Allowlist: []string{getDefaultValidators()[ValidatorID("carol")].ValconsAddress},
Denylist: []string{getDefaultValidators()[ValidatorID("bob")].ValconsAddress},
TopN: 0,
Allowlist: []string{getDefaultValidators()[ValidatorID("carol")].ValconsAddress},
Denylist: []string{getDefaultValidators()[ValidatorID("bob")].ValconsAddress},
Prioritylist: []string{getDefaultValidators()[ValidatorID("carol")].ValconsAddress},
kirdatatjana marked this conversation as resolved.
Show resolved Hide resolved
},
},
State: State{},
Expand Down
1 change: 1 addition & 0 deletions testutil/keeper/unit_test_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,7 @@ func GetTestPowerShapingParameters() providertypes.PowerShapingParameters {
Denylist: nil,
MinStake: 0,
AllowInactiveVals: false,
Prioritylist: nil,
}
}

Expand Down
6 changes: 4 additions & 2 deletions x/ccv/provider/client/cli/tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,8 @@ where create_consumer.json has the following structure:
"allowlist": [],
"denylist": [],
"min_stake": "0",
"allow_inactive_vals": false
"allow_inactive_vals": false,
"prioritylist": []
},
"allowlisted_reward_denoms": {
"denoms": ["ibc/...", "ibc/..."]
Expand Down Expand Up @@ -352,7 +353,8 @@ where update_consumer.json has the following structure:
"allowlist": [],
"denylist": [],
"min_stake": "0",
"allow_inactive_vals": false
"allow_inactive_vals": false,
"prioritylist": []
},
"allowlisted_reward_denoms": {
"denoms": ["ibc/...", "ibc/..."]
Expand Down
2 changes: 2 additions & 0 deletions x/ccv/provider/client/legacy_proposals.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ type ConsumerAdditionProposalJSON struct {
Denylist []string `json:"denylist"`
MinStake uint64 `json:"min_stake"`
AllowInactiveVals bool `json:"allow_inactive_vals"`
Prioritylist []string `json:"prioritylist"`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do not update legacy proposals as we no longer need them. Actually, why do we even have this file?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Priority list is now removed from legacy_proposals.go.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@MSalopek do you know why do we still need this file? cc @bermuell

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My mistake, the priority list is needed in legacy proposal for e2e test.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we still legacy props on our e2e tests? Can we get rid of these? Not something we need to do in this PR though.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't remove them because you'll break governance on gaia. They have to exist so old Txs can be displayed and handled properly. Otherwise you will not be able to fetch an old block or check an old gov proposal because the gov type is missing.

Please don't remove it.

}

type ConsumerAdditionProposalReq struct {
Expand Down Expand Up @@ -176,6 +177,7 @@ type ConsumerModificationProposalJSON struct {
Denylist []string `json:"denylist"`
MinStake uint64 `json:"min_stake"`
AllowInactiveVals bool `json:"allow_inactive_vals"`
Prioritylist []string `json:"prioritylist"`
kirdatatjana marked this conversation as resolved.
Show resolved Hide resolved

Deposit string `json:"deposit"`
}
Expand Down
1 change: 1 addition & 0 deletions x/ccv/provider/keeper/consumer_lifecycle.go
Original file line number Diff line number Diff line change
Expand Up @@ -486,6 +486,7 @@ func (k Keeper) DeleteConsumerChain(ctx sdk.Context, consumerId string) (err err
k.DeleteDenylist(ctx, consumerId)
k.DeleteAllOptedIn(ctx, consumerId)
k.DeleteConsumerValSet(ctx, consumerId)
k.DeletePrioritylist(ctx, consumerId)

k.DeleteConsumerRemovalTime(ctx, consumerId)

Expand Down
5 changes: 5 additions & 0 deletions x/ccv/provider/keeper/consumer_lifecycle_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -222,34 +222,39 @@ func TestBeginBlockLaunchConsumers(t *testing.T) {
ValidatorSetCap: 0,
Allowlist: []string{},
Denylist: []string{},
Prioritylist: []string{},
},
{
Top_N: 50,
ValidatorsPowerCap: 0,
ValidatorSetCap: 0,
Allowlist: []string{},
Denylist: []string{},
Prioritylist: []string{},
},
{
Top_N: 50,
ValidatorsPowerCap: 0,
ValidatorSetCap: 0,
Allowlist: []string{},
Denylist: []string{},
Prioritylist: []string{},
},
{
Top_N: 0,
ValidatorsPowerCap: 0,
ValidatorSetCap: 0,
Allowlist: []string{},
Denylist: []string{},
Prioritylist: []string{},
},
{
Top_N: 0,
ValidatorsPowerCap: 0,
ValidatorSetCap: 0,
Allowlist: []string{},
Denylist: []string{},
Prioritylist: []string{},
},
}

Expand Down
7 changes: 7 additions & 0 deletions x/ccv/provider/keeper/grpc_query.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,12 @@ func (k Keeper) GetConsumerChain(ctx sdk.Context, consumerId string) (types.Chai
strDenylist[i] = addr.String()
}

prioritylist := k.GetPriorityList(ctx, consumerId)
strPrioritylist := make([]string, len(prioritylist))
for i, addr := range prioritylist {
strPrioritylist[i] = addr.String()
}

metadata, err := k.GetConsumerMetadata(ctx, consumerId)
if err != nil {
return types.Chain{}, fmt.Errorf("cannot find metadata (%s): %s", consumerId, err.Error())
Expand All @@ -139,6 +145,7 @@ func (k Keeper) GetConsumerChain(ctx sdk.Context, consumerId string) (types.Chai
MinStake: powerShapingParameters.MinStake,
ConsumerId: consumerId,
AllowlistedRewardDenoms: &types.AllowlistedRewardDenoms{Denoms: allowlistedRewardDenoms},
Prioritylist: strPrioritylist, //strPrioritylist, Should I retrieve from somewhere => where do I retrieve it from? Basically where does priority list come from and where is it stored
kirdatatjana marked this conversation as resolved.
Show resolved Hide resolved
}, nil
}

Expand Down
17 changes: 16 additions & 1 deletion x/ccv/provider/keeper/grpc_query_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -447,7 +447,12 @@ func TestGetConsumerChain(t *testing.T) {
{types.NewProviderConsAddress([]byte("providerAddr6"))},
{},
}

prioritylists := [][]types.ProviderConsAddress{
{},
{types.NewProviderConsAddress([]byte("providerAddr1")), types.NewProviderConsAddress([]byte("providerAddr2"))},
{types.NewProviderConsAddress([]byte("providerAddr3"))},
{},
}
allowInactiveVals := []bool{true, false, true, false}

minStakes := []math.Int{
Expand Down Expand Up @@ -486,6 +491,9 @@ func TestGetConsumerChain(t *testing.T) {
for _, addr := range denylists[i] {
pk.SetDenylist(ctx, consumerID, addr)
}
for _, addr := range prioritylists[i] {
pk.SetPrioritylist(ctx, consumerID, addr)
}
strAllowlist := make([]string, len(allowlists[i]))
for j, addr := range allowlists[i] {
strAllowlist[j] = addr.String()
Expand All @@ -496,6 +504,11 @@ func TestGetConsumerChain(t *testing.T) {
strDenylist[j] = addr.String()
}

strPrioritylist := make([]string, len(prioritylists[i]))
for j, addr := range allowlists[i] {
kirdatatjana marked this conversation as resolved.
Show resolved Hide resolved
strPrioritylist[j] = addr.String()
}

metadataLists = append(metadataLists, types.ConsumerMetadata{Name: chainIDs[i]})
pk.SetConsumerMetadata(ctx, consumerID, metadataLists[i])

Expand All @@ -520,6 +533,7 @@ func TestGetConsumerChain(t *testing.T) {
MinStake: minStakes[i].Uint64(),
ConsumerId: consumerIDs[i],
AllowlistedRewardDenoms: allowlistedRewardDenoms[i],
Prioritylist: strPrioritylist,
})
}

Expand Down Expand Up @@ -666,6 +680,7 @@ func TestQueryConsumerChains(t *testing.T) {
Metadata: metadata,
ConsumerId: consumerId,
AllowlistedRewardDenoms: &types.AllowlistedRewardDenoms{Denoms: []string{}},
Prioritylist: []string{},
}
consumerIds[i] = consumerId
consumers[i] = &c
Expand Down
Loading
Loading