Skip to content

Commit

Permalink
fix!: change UX in key assignment (#1998)
Browse files Browse the repository at this point in the history
* init

* added nit changes

* added CHANGELOGs

* fixed E2E tests error message

* brought one more test from #1732

* fixed logging

* fixed event key

* fixed CHANGELOGs

* rebase
  • Loading branch information
insumity committed Jul 18, 2024
1 parent 360a0b0 commit fde751e
Show file tree
Hide file tree
Showing 15 changed files with 96 additions and 247 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
- Change the UX in key assignment by returning an error if a validator tries to
reuse the same consumer key.
([\#1998](https://github.com/cosmos/interchain-security/pull/1998))
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
- Change the UX in key assignment by returning an error if a validator tries to
reuse the same consumer key.
([\#1998](https://github.com/cosmos/interchain-security/pull/1998))
12 changes: 12 additions & 0 deletions tests/e2e/steps_compatibility.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,18 @@ 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
18 changes: 5 additions & 13 deletions tests/e2e/steps_start_chains.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,24 +86,16 @@ func stepsStartConsumerChain(consumerName string, proposalIndex, chainIndex uint
},
},
{
// op should be a noop - key already assigned, but by the same validator
// 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: 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,
},
},
ExpectError: true,
ExpectedError: "a validator has or had assigned this consumer key already",
},
State: State{},
},
{
// op should fail - key already assigned by another validator
Expand All @@ -114,7 +106,7 @@ func stepsStartConsumerChain(consumerName string, proposalIndex, chainIndex uint
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",
ExpectedError: "a validator has or had assigned this consumer key already",
},
State: State{
ChainID(consumerName): ChainState{
Expand Down
30 changes: 4 additions & 26 deletions tests/e2e/tracehandler_testdata/consumer-double-sign.json
Original file line number Diff line number Diff line change
Expand Up @@ -145,32 +145,10 @@
"Validator": "carol",
"ConsumerPubkey": "{\"@type\":\"/cosmos.crypto.ed25519.PubKey\",\"key\":\"Ui5Gf1+mtWUdH8u3xlmzdKID+F3PK0sfXZ73GZ6q6is=\"}",
"ReconfigureNode": false,
"ExpectError": false,
"ExpectedError": ""
"ExpectError": true,
"ExpectedError": "a validator has or had assigned this consumer key already"
},
"State": {
"consu": {
"ValBalances": null,
"ProposedConsumerChains": null,
"ValPowers": null,
"StakedTokens": null,
"IBCTransferParams": null,
"Params": null,
"Rewards": null,
"ConsumerChains": null,
"AssignedKeys": {
"carol": "cosmosvalcons1kswr5sq599365kcjmhgufevfps9njf43e4lwdk"
},
"ProviderKeys": {
"carol": "cosmosvalcons1ezyrq65s3gshhx5585w6mpusq3xsj3ayzf4uv6"
},
"ConsumerPendingPacketQueueSize": null,
"RegisteredConsumerRewardDenoms": null,
"ClientsFrozenHeights": null,
"HasToValidate": null,
"Proposals": null
}
}
"State": {}
},
{
"ActionType": "main.AssignConsumerPubKeyAction",
Expand All @@ -180,7 +158,7 @@
"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"
"ExpectedError": "a validator has or had assigned this consumer key already"
},
"State": {
"consu": {
Expand Down
30 changes: 4 additions & 26 deletions tests/e2e/tracehandler_testdata/democracy.json
Original file line number Diff line number Diff line change
Expand Up @@ -145,32 +145,10 @@
"Validator": "carol",
"ConsumerPubkey": "{\"@type\":\"/cosmos.crypto.ed25519.PubKey\",\"key\":\"Ui5Gf1+mtWUdH8u3xlmzdKID+F3PK0sfXZ73GZ6q6is=\"}",
"ReconfigureNode": false,
"ExpectError": false,
"ExpectedError": ""
"ExpectError": true,
"ExpectedError": "a validator has or had assigned this consumer key already"
},
"State": {
"democ": {
"ValBalances": null,
"ProposedConsumerChains": null,
"ValPowers": null,
"StakedTokens": null,
"IBCTransferParams": null,
"Params": null,
"Rewards": null,
"ConsumerChains": null,
"AssignedKeys": {
"carol": "cosmosvalcons1kswr5sq599365kcjmhgufevfps9njf43e4lwdk"
},
"ProviderKeys": {
"carol": "cosmosvalcons1ezyrq65s3gshhx5585w6mpusq3xsj3ayzf4uv6"
},
"ConsumerPendingPacketQueueSize": null,
"RegisteredConsumerRewardDenoms": null,
"ClientsFrozenHeights": null,
"HasToValidate": null,
"Proposals": null
}
}
"State": {}
},
{
"ActionType": "main.AssignConsumerPubKeyAction",
Expand All @@ -180,7 +158,7 @@
"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"
"ExpectedError": "a validator has or had assigned this consumer key already"
},
"State": {
"democ": {
Expand Down
30 changes: 4 additions & 26 deletions tests/e2e/tracehandler_testdata/democracyRewardsSteps.json
Original file line number Diff line number Diff line change
Expand Up @@ -145,32 +145,10 @@
"Validator": "carol",
"ConsumerPubkey": "{\"@type\":\"/cosmos.crypto.ed25519.PubKey\",\"key\":\"Ui5Gf1+mtWUdH8u3xlmzdKID+F3PK0sfXZ73GZ6q6is=\"}",
"ReconfigureNode": false,
"ExpectError": false,
"ExpectedError": ""
"ExpectError": true,
"ExpectedError": "a validator has or had assigned this consumer key already"
},
"State": {
"democ": {
"ValBalances": null,
"ProposedConsumerChains": null,
"ValPowers": null,
"StakedTokens": null,
"IBCTransferParams": null,
"Params": null,
"Rewards": null,
"ConsumerChains": null,
"AssignedKeys": {
"carol": "cosmosvalcons1kswr5sq599365kcjmhgufevfps9njf43e4lwdk"
},
"ProviderKeys": {
"carol": "cosmosvalcons1ezyrq65s3gshhx5585w6mpusq3xsj3ayzf4uv6"
},
"ConsumerPendingPacketQueueSize": null,
"RegisteredConsumerRewardDenoms": null,
"ClientsFrozenHeights": null,
"HasToValidate": null,
"Proposals": null
}
}
"State": {}
},
{
"ActionType": "main.AssignConsumerPubKeyAction",
Expand All @@ -180,7 +158,7 @@
"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"
"ExpectedError": "a validator has or had assigned this consumer key already"
},
"State": {
"democ": {
Expand Down
30 changes: 4 additions & 26 deletions tests/e2e/tracehandler_testdata/happyPath.json
Original file line number Diff line number Diff line change
Expand Up @@ -145,32 +145,10 @@
"Validator": "carol",
"ConsumerPubkey": "{\"@type\":\"/cosmos.crypto.ed25519.PubKey\",\"key\":\"Ui5Gf1+mtWUdH8u3xlmzdKID+F3PK0sfXZ73GZ6q6is=\"}",
"ReconfigureNode": false,
"ExpectError": false,
"ExpectedError": ""
"ExpectError": true,
"ExpectedError": "a validator has or had assigned this consumer key already"
},
"State": {
"consu": {
"ValBalances": null,
"ProposedConsumerChains": null,
"ValPowers": null,
"StakedTokens": null,
"IBCTransferParams": null,
"Params": null,
"Rewards": null,
"ConsumerChains": null,
"AssignedKeys": {
"carol": "cosmosvalcons1kswr5sq599365kcjmhgufevfps9njf43e4lwdk"
},
"ProviderKeys": {
"carol": "cosmosvalcons1ezyrq65s3gshhx5585w6mpusq3xsj3ayzf4uv6"
},
"ConsumerPendingPacketQueueSize": null,
"RegisteredConsumerRewardDenoms": null,
"ClientsFrozenHeights": null,
"HasToValidate": null,
"Proposals": null
}
}
"State": {}
},
{
"ActionType": "main.AssignConsumerPubKeyAction",
Expand All @@ -180,7 +158,7 @@
"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"
"ExpectedError": "a validator has or had assigned this consumer key already"
},
"State": {
"consu": {
Expand Down
60 changes: 8 additions & 52 deletions tests/e2e/tracehandler_testdata/multipleConsumers.json
Original file line number Diff line number Diff line change
Expand Up @@ -145,32 +145,10 @@
"Validator": "carol",
"ConsumerPubkey": "{\"@type\":\"/cosmos.crypto.ed25519.PubKey\",\"key\":\"Ui5Gf1+mtWUdH8u3xlmzdKID+F3PK0sfXZ73GZ6q6is=\"}",
"ReconfigureNode": false,
"ExpectError": false,
"ExpectedError": ""
"ExpectError": true,
"ExpectedError": "a validator has or had assigned this consumer key already"
},
"State": {
"consu": {
"ValBalances": null,
"ProposedConsumerChains": null,
"ValPowers": null,
"StakedTokens": null,
"IBCTransferParams": null,
"Params": null,
"Rewards": null,
"ConsumerChains": null,
"AssignedKeys": {
"carol": "cosmosvalcons1kswr5sq599365kcjmhgufevfps9njf43e4lwdk"
},
"ProviderKeys": {
"carol": "cosmosvalcons1ezyrq65s3gshhx5585w6mpusq3xsj3ayzf4uv6"
},
"ConsumerPendingPacketQueueSize": null,
"RegisteredConsumerRewardDenoms": null,
"ClientsFrozenHeights": null,
"HasToValidate": null,
"Proposals": null
}
}
"State": {}
},
{
"ActionType": "main.AssignConsumerPubKeyAction",
Expand All @@ -180,7 +158,7 @@
"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"
"ExpectedError": "a validator has or had assigned this consumer key already"
},
"State": {
"consu": {
Expand Down Expand Up @@ -449,32 +427,10 @@
"Validator": "carol",
"ConsumerPubkey": "{\"@type\":\"/cosmos.crypto.ed25519.PubKey\",\"key\":\"Ui5Gf1+mtWUdH8u3xlmzdKID+F3PK0sfXZ73GZ6q6is=\"}",
"ReconfigureNode": false,
"ExpectError": false,
"ExpectedError": ""
"ExpectError": true,
"ExpectedError": "a validator has or had assigned this consumer key already"
},
"State": {
"densu": {
"ValBalances": null,
"ProposedConsumerChains": null,
"ValPowers": null,
"StakedTokens": null,
"IBCTransferParams": null,
"Params": null,
"Rewards": null,
"ConsumerChains": null,
"AssignedKeys": {
"carol": "cosmosvalcons1kswr5sq599365kcjmhgufevfps9njf43e4lwdk"
},
"ProviderKeys": {
"carol": "cosmosvalcons1ezyrq65s3gshhx5585w6mpusq3xsj3ayzf4uv6"
},
"ConsumerPendingPacketQueueSize": null,
"RegisteredConsumerRewardDenoms": null,
"ClientsFrozenHeights": null,
"HasToValidate": null,
"Proposals": null
}
}
"State": {}
},
{
"ActionType": "main.AssignConsumerPubKeyAction",
Expand All @@ -484,7 +440,7 @@
"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"
"ExpectedError": "a validator has or had assigned this consumer key already"
},
"State": {
"densu": {
Expand Down
30 changes: 4 additions & 26 deletions tests/e2e/tracehandler_testdata/shorthappy.json
Original file line number Diff line number Diff line change
Expand Up @@ -145,32 +145,10 @@
"Validator": "carol",
"ConsumerPubkey": "{\"@type\":\"/cosmos.crypto.ed25519.PubKey\",\"key\":\"Ui5Gf1+mtWUdH8u3xlmzdKID+F3PK0sfXZ73GZ6q6is=\"}",
"ReconfigureNode": false,
"ExpectError": false,
"ExpectedError": ""
"ExpectError": true,
"ExpectedError": "a validator has or had assigned this consumer key already"
},
"State": {
"consu": {
"ValBalances": null,
"ProposedConsumerChains": null,
"ValPowers": null,
"StakedTokens": null,
"IBCTransferParams": null,
"Params": null,
"Rewards": null,
"ConsumerChains": null,
"AssignedKeys": {
"carol": "cosmosvalcons1kswr5sq599365kcjmhgufevfps9njf43e4lwdk"
},
"ProviderKeys": {
"carol": "cosmosvalcons1ezyrq65s3gshhx5585w6mpusq3xsj3ayzf4uv6"
},
"ConsumerPendingPacketQueueSize": null,
"RegisteredConsumerRewardDenoms": null,
"ClientsFrozenHeights": null,
"HasToValidate": null,
"Proposals": null
}
}
"State": {}
},
{
"ActionType": "main.AssignConsumerPubKeyAction",
Expand All @@ -180,7 +158,7 @@
"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"
"ExpectedError": "a validator has or had assigned this consumer key already"
},
"State": {
"consu": {
Expand Down
Loading

0 comments on commit fde751e

Please sign in to comment.