Skip to content

Commit

Permalink
fix!: Fix opt-in assignment (#1732)
Browse files Browse the repository at this point in the history
* Make the same validator assigning the same key a noop instead of an error

* Adjust test

* Update tests

* Fix newline warning

* Regenerate traces

* Add key assignment change to changelog

* Add info log for same key same validator assignments

* Add changelog entry to api-breaking

* Update x/ccv/provider/handler_test.go

Co-authored-by: insumity <[email protected]>

* Add more comments to test and return right validator

---------

Co-authored-by: insumity <[email protected]>
  • Loading branch information
p-offtermatt and insumity committed Apr 2, 2024
1 parent bfe10df commit 26f3c82
Show file tree
Hide file tree
Showing 15 changed files with 302 additions and 54 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
- Assigning a key that is already assigned by the same validator will now be a no-op instead of throwing an error.
([\#1732](https://github.com/cosmos/interchain-security/pull/1732))
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
- Assigning a key that is already assigned by the same validator will now be a no-op instead of throwing an error.
([\#1732](https://github.com/cosmos/interchain-security/pull/1732))
4 changes: 2 additions & 2 deletions tests/e2e/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -430,13 +430,13 @@ TEST RESULTS
}
}
if len(passedTests) > 0 {
report += fmt.Sprintln("\n\nPASSED TESTS:\n")
report += fmt.Sprintln("\n\nPASSED TESTS:")
for _, t := range passedTests {
report += t.Report()
}
}
if len(remainingTests) > 0 {
report += fmt.Sprintln("\n\nREMAINING TESTS:\n")
report += fmt.Sprintln("\n\nREMAINING TESTS:")
for _, t := range remainingTests {
report += t.Report()
}
Expand Down
12 changes: 0 additions & 12 deletions tests/e2e/steps_compatibility.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,18 +85,6 @@ func compstepsStartConsumerChain(consumerName string, proposalIndex, chainIndex
},
},
},
{
// op should fail - key already assigned by the same validator
Action: AssignConsumerPubKeyAction{
Chain: ChainID(consumerName),
Validator: ValidatorID("carol"),
ConsumerPubkey: getDefaultValidators()[ValidatorID("carol")].ConsumerValPubKey,
ReconfigureNode: false,
ExpectError: true,
ExpectedError: "a validator has assigned the consumer key already: consumer key is already in use by a validator",
},
State: State{},
},
{
// op should fail - key already assigned by another validator
Action: AssignConsumerPubKeyAction{
Expand Down
16 changes: 12 additions & 4 deletions tests/e2e/steps_start_chains.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,16 +82,24 @@ func stepsStartConsumerChain(consumerName string, proposalIndex, chainIndex uint
},
},
{
// op should fail - key already assigned by the same validator
// op should be a noop - key already assigned, but by the same validator
Action: AssignConsumerPubKeyAction{
Chain: ChainID(consumerName),
Validator: ValidatorID("carol"),
ConsumerPubkey: getDefaultValidators()[ValidatorID("carol")].ConsumerValPubKey,
ReconfigureNode: false,
ExpectError: true,
ExpectedError: "a validator has assigned the consumer key already: consumer key is already in use by a validator",
ExpectError: false,
},
State: State{
ChainID(consumerName): ChainState{
AssignedKeys: &map[ValidatorID]string{
ValidatorID("carol"): getDefaultValidators()[ValidatorID("carol")].ConsumerValconsAddressOnProvider,
},
ProviderKeys: &map[ValidatorID]string{
ValidatorID("carol"): getDefaultValidators()[ValidatorID("carol")].ValconsAddress,
},
},
},
State: State{},
},
{
// op should fail - key already assigned by another validator
Expand Down
26 changes: 23 additions & 3 deletions tests/e2e/tracehandler_testdata/consumer-double-sign.json
Original file line number Diff line number Diff line change
Expand Up @@ -134,10 +134,30 @@
"Validator": "carol",
"ConsumerPubkey": "{\"@type\":\"/cosmos.crypto.ed25519.PubKey\",\"key\":\"Ui5Gf1+mtWUdH8u3xlmzdKID+F3PK0sfXZ73GZ6q6is=\"}",
"ReconfigureNode": false,
"ExpectError": true,
"ExpectedError": "a validator has assigned the consumer key already: consumer key is already in use by a validator"
"ExpectError": false,
"ExpectedError": ""
},
"State": {}
"State": {
"consu": {
"ValBalances": null,
"ProposedConsumerChains": null,
"ValPowers": null,
"StakedTokens": null,
"Params": null,
"Rewards": null,
"ConsumerChains": null,
"AssignedKeys": {
"carol": "cosmosvalcons1kswr5sq599365kcjmhgufevfps9njf43e4lwdk"
},
"ProviderKeys": {
"carol": "cosmosvalcons1ezyrq65s3gshhx5585w6mpusq3xsj3ayzf4uv6"
},
"ConsumerPendingPacketQueueSize": null,
"RegisteredConsumerRewardDenoms": null,
"ClientsFrozenHeights": null,
"Proposals": null
}
}
},
{
"ActionType": "main.AssignConsumerPubKeyAction",
Expand Down
26 changes: 23 additions & 3 deletions tests/e2e/tracehandler_testdata/democracy.json
Original file line number Diff line number Diff line change
Expand Up @@ -134,10 +134,30 @@
"Validator": "carol",
"ConsumerPubkey": "{\"@type\":\"/cosmos.crypto.ed25519.PubKey\",\"key\":\"Ui5Gf1+mtWUdH8u3xlmzdKID+F3PK0sfXZ73GZ6q6is=\"}",
"ReconfigureNode": false,
"ExpectError": true,
"ExpectedError": "a validator has assigned the consumer key already: consumer key is already in use by a validator"
"ExpectError": false,
"ExpectedError": ""
},
"State": {}
"State": {
"democ": {
"ValBalances": null,
"ProposedConsumerChains": null,
"ValPowers": null,
"StakedTokens": null,
"Params": null,
"Rewards": null,
"ConsumerChains": null,
"AssignedKeys": {
"carol": "cosmosvalcons1kswr5sq599365kcjmhgufevfps9njf43e4lwdk"
},
"ProviderKeys": {
"carol": "cosmosvalcons1ezyrq65s3gshhx5585w6mpusq3xsj3ayzf4uv6"
},
"ConsumerPendingPacketQueueSize": null,
"RegisteredConsumerRewardDenoms": null,
"ClientsFrozenHeights": null,
"Proposals": null
}
}
},
{
"ActionType": "main.AssignConsumerPubKeyAction",
Expand Down
26 changes: 23 additions & 3 deletions tests/e2e/tracehandler_testdata/democracyRewardsSteps.json
Original file line number Diff line number Diff line change
Expand Up @@ -134,10 +134,30 @@
"Validator": "carol",
"ConsumerPubkey": "{\"@type\":\"/cosmos.crypto.ed25519.PubKey\",\"key\":\"Ui5Gf1+mtWUdH8u3xlmzdKID+F3PK0sfXZ73GZ6q6is=\"}",
"ReconfigureNode": false,
"ExpectError": true,
"ExpectedError": "a validator has assigned the consumer key already: consumer key is already in use by a validator"
"ExpectError": false,
"ExpectedError": ""
},
"State": {}
"State": {
"democ": {
"ValBalances": null,
"ProposedConsumerChains": null,
"ValPowers": null,
"StakedTokens": null,
"Params": null,
"Rewards": null,
"ConsumerChains": null,
"AssignedKeys": {
"carol": "cosmosvalcons1kswr5sq599365kcjmhgufevfps9njf43e4lwdk"
},
"ProviderKeys": {
"carol": "cosmosvalcons1ezyrq65s3gshhx5585w6mpusq3xsj3ayzf4uv6"
},
"ConsumerPendingPacketQueueSize": null,
"RegisteredConsumerRewardDenoms": null,
"ClientsFrozenHeights": null,
"Proposals": null
}
}
},
{
"ActionType": "main.AssignConsumerPubKeyAction",
Expand Down
26 changes: 23 additions & 3 deletions tests/e2e/tracehandler_testdata/happyPath.json
Original file line number Diff line number Diff line change
Expand Up @@ -134,10 +134,30 @@
"Validator": "carol",
"ConsumerPubkey": "{\"@type\":\"/cosmos.crypto.ed25519.PubKey\",\"key\":\"Ui5Gf1+mtWUdH8u3xlmzdKID+F3PK0sfXZ73GZ6q6is=\"}",
"ReconfigureNode": false,
"ExpectError": true,
"ExpectedError": "a validator has assigned the consumer key already: consumer key is already in use by a validator"
"ExpectError": false,
"ExpectedError": ""
},
"State": {}
"State": {
"consu": {
"ValBalances": null,
"ProposedConsumerChains": null,
"ValPowers": null,
"StakedTokens": null,
"Params": null,
"Rewards": null,
"ConsumerChains": null,
"AssignedKeys": {
"carol": "cosmosvalcons1kswr5sq599365kcjmhgufevfps9njf43e4lwdk"
},
"ProviderKeys": {
"carol": "cosmosvalcons1ezyrq65s3gshhx5585w6mpusq3xsj3ayzf4uv6"
},
"ConsumerPendingPacketQueueSize": null,
"RegisteredConsumerRewardDenoms": null,
"ClientsFrozenHeights": null,
"Proposals": null
}
}
},
{
"ActionType": "main.AssignConsumerPubKeyAction",
Expand Down
52 changes: 46 additions & 6 deletions tests/e2e/tracehandler_testdata/multipleConsumers.json
Original file line number Diff line number Diff line change
Expand Up @@ -134,10 +134,30 @@
"Validator": "carol",
"ConsumerPubkey": "{\"@type\":\"/cosmos.crypto.ed25519.PubKey\",\"key\":\"Ui5Gf1+mtWUdH8u3xlmzdKID+F3PK0sfXZ73GZ6q6is=\"}",
"ReconfigureNode": false,
"ExpectError": true,
"ExpectedError": "a validator has assigned the consumer key already: consumer key is already in use by a validator"
"ExpectError": false,
"ExpectedError": ""
},
"State": {}
"State": {
"consu": {
"ValBalances": null,
"ProposedConsumerChains": null,
"ValPowers": null,
"StakedTokens": null,
"Params": null,
"Rewards": null,
"ConsumerChains": null,
"AssignedKeys": {
"carol": "cosmosvalcons1kswr5sq599365kcjmhgufevfps9njf43e4lwdk"
},
"ProviderKeys": {
"carol": "cosmosvalcons1ezyrq65s3gshhx5585w6mpusq3xsj3ayzf4uv6"
},
"ConsumerPendingPacketQueueSize": null,
"RegisteredConsumerRewardDenoms": null,
"ClientsFrozenHeights": null,
"Proposals": null
}
}
},
{
"ActionType": "main.AssignConsumerPubKeyAction",
Expand Down Expand Up @@ -399,10 +419,30 @@
"Validator": "carol",
"ConsumerPubkey": "{\"@type\":\"/cosmos.crypto.ed25519.PubKey\",\"key\":\"Ui5Gf1+mtWUdH8u3xlmzdKID+F3PK0sfXZ73GZ6q6is=\"}",
"ReconfigureNode": false,
"ExpectError": true,
"ExpectedError": "a validator has assigned the consumer key already: consumer key is already in use by a validator"
"ExpectError": false,
"ExpectedError": ""
},
"State": {}
"State": {
"densu": {
"ValBalances": null,
"ProposedConsumerChains": null,
"ValPowers": null,
"StakedTokens": null,
"Params": null,
"Rewards": null,
"ConsumerChains": null,
"AssignedKeys": {
"carol": "cosmosvalcons1kswr5sq599365kcjmhgufevfps9njf43e4lwdk"
},
"ProviderKeys": {
"carol": "cosmosvalcons1ezyrq65s3gshhx5585w6mpusq3xsj3ayzf4uv6"
},
"ConsumerPendingPacketQueueSize": null,
"RegisteredConsumerRewardDenoms": null,
"ClientsFrozenHeights": null,
"Proposals": null
}
}
},
{
"ActionType": "main.AssignConsumerPubKeyAction",
Expand Down
26 changes: 23 additions & 3 deletions tests/e2e/tracehandler_testdata/shorthappy.json
Original file line number Diff line number Diff line change
Expand Up @@ -134,10 +134,30 @@
"Validator": "carol",
"ConsumerPubkey": "{\"@type\":\"/cosmos.crypto.ed25519.PubKey\",\"key\":\"Ui5Gf1+mtWUdH8u3xlmzdKID+F3PK0sfXZ73GZ6q6is=\"}",
"ReconfigureNode": false,
"ExpectError": true,
"ExpectedError": "a validator has assigned the consumer key already: consumer key is already in use by a validator"
"ExpectError": false,
"ExpectedError": ""
},
"State": {}
"State": {
"consu": {
"ValBalances": null,
"ProposedConsumerChains": null,
"ValPowers": null,
"StakedTokens": null,
"Params": null,
"Rewards": null,
"ConsumerChains": null,
"AssignedKeys": {
"carol": "cosmosvalcons1kswr5sq599365kcjmhgufevfps9njf43e4lwdk"
},
"ProviderKeys": {
"carol": "cosmosvalcons1ezyrq65s3gshhx5585w6mpusq3xsj3ayzf4uv6"
},
"ConsumerPendingPacketQueueSize": null,
"RegisteredConsumerRewardDenoms": null,
"ClientsFrozenHeights": null,
"Proposals": null
}
}
},
{
"ActionType": "main.AssignConsumerPubKeyAction",
Expand Down
26 changes: 23 additions & 3 deletions tests/e2e/tracehandler_testdata/slashThrottle.json
Original file line number Diff line number Diff line change
Expand Up @@ -134,10 +134,30 @@
"Validator": "carol",
"ConsumerPubkey": "{\"@type\":\"/cosmos.crypto.ed25519.PubKey\",\"key\":\"Ui5Gf1+mtWUdH8u3xlmzdKID+F3PK0sfXZ73GZ6q6is=\"}",
"ReconfigureNode": false,
"ExpectError": true,
"ExpectedError": "a validator has assigned the consumer key already: consumer key is already in use by a validator"
"ExpectError": false,
"ExpectedError": ""
},
"State": {}
"State": {
"consu": {
"ValBalances": null,
"ProposedConsumerChains": null,
"ValPowers": null,
"StakedTokens": null,
"Params": null,
"Rewards": null,
"ConsumerChains": null,
"AssignedKeys": {
"carol": "cosmosvalcons1kswr5sq599365kcjmhgufevfps9njf43e4lwdk"
},
"ProviderKeys": {
"carol": "cosmosvalcons1ezyrq65s3gshhx5585w6mpusq3xsj3ayzf4uv6"
},
"ConsumerPendingPacketQueueSize": null,
"RegisteredConsumerRewardDenoms": null,
"ClientsFrozenHeights": null,
"Proposals": null
}
}
},
{
"ActionType": "main.AssignConsumerPubKeyAction",
Expand Down
Loading

0 comments on commit 26f3c82

Please sign in to comment.