From 84955b9ddf08ed25e08814641c909fd84dc135da Mon Sep 17 00:00:00 2001 From: Simon Noetzlin Date: Wed, 15 Nov 2023 17:28:09 +0100 Subject: [PATCH] feat: update misbehaviour handling using IBC-Go 7 (#1401) * nit fix * improve doc * super picky nit * fix!: drop nil votes in misbehaviour handling (#1404) * update CHANGELOG for final release * save * update test to extract byzantine validators * improve testing * nits * nits * Update tests/integration/misbehaviour.go Co-authored-by: insumity * Update testutil/crypto/evidence.go Co-authored-by: insumity * update util func * doc * check misb client ID * Update x/ccv/provider/keeper/misbehaviour.go Co-authored-by: insumity * nits --------- Co-authored-by: insumity * fix comments * update changelog * Update x/ccv/provider/keeper/misbehaviour.go Co-authored-by: insumity * improve tests * lint * udpate traces * silly bug --------- Co-authored-by: insumity --- ...ic-verification-of-equivocation-feature.md | 3 + ...ic-verification-of-equivocation-feature.md | 3 + .../consumer-double-sign.json | 39 +- .../consumer-misbehaviour.json | 39 +- .../e2e/tracehandler_testdata/democracy.json | 3 - .../democracyRewardsSteps.json | 3 - .../e2e/tracehandler_testdata/happyPath.json | 369 ------------------ .../e2e/tracehandler_testdata/shorthappy.json | 369 ------------------ .../tracehandler_testdata/slashThrottle.json | 2 + tests/integration/misbehaviour.go | 137 ++++--- x/ccv/provider/keeper/misbehaviour.go | 33 +- 11 files changed, 131 insertions(+), 869 deletions(-) create mode 100644 .changelog/unreleased/features/provider/1340-add-cryptographic-verification-of-equivocation-feature.md create mode 100644 .changelog/unreleased/state-breaking/provider/1340-add-cryptographic-verification-of-equivocation-feature.md diff --git a/.changelog/unreleased/features/provider/1340-add-cryptographic-verification-of-equivocation-feature.md b/.changelog/unreleased/features/provider/1340-add-cryptographic-verification-of-equivocation-feature.md new file mode 100644 index 0000000000..e34b5fff28 --- /dev/null +++ b/.changelog/unreleased/features/provider/1340-add-cryptographic-verification-of-equivocation-feature.md @@ -0,0 +1,3 @@ +- Add the cryptographic verification of equivocation feature to the provider + (cf. ADR-005 & ADR-013). ([\#1340](https://github.com/cosmos/interchain- + security/pull/1340)) \ No newline at end of file diff --git a/.changelog/unreleased/state-breaking/provider/1340-add-cryptographic-verification-of-equivocation-feature.md b/.changelog/unreleased/state-breaking/provider/1340-add-cryptographic-verification-of-equivocation-feature.md new file mode 100644 index 0000000000..e34b5fff28 --- /dev/null +++ b/.changelog/unreleased/state-breaking/provider/1340-add-cryptographic-verification-of-equivocation-feature.md @@ -0,0 +1,3 @@ +- Add the cryptographic verification of equivocation feature to the provider + (cf. ADR-005 & ADR-013). ([\#1340](https://github.com/cosmos/interchain- + security/pull/1340)) \ No newline at end of file diff --git a/tests/e2e/tracehandler_testdata/consumer-double-sign.json b/tests/e2e/tracehandler_testdata/consumer-double-sign.json index d1a7ae065f..d6d1fc7086 100644 --- a/tests/e2e/tracehandler_testdata/consumer-double-sign.json +++ b/tests/e2e/tracehandler_testdata/consumer-double-sign.json @@ -37,8 +37,7 @@ "ConsumerChains": null, "AssignedKeys": null, "ProviderKeys": null, - "ConsumerChainQueueSizes": null, - "GlobalSlashQueueSize": null, + "ConsumerPendingPacketQueueSize": null, "RegisteredConsumerRewardDenoms": null, "ClientsFrozenHeights": null, "Proposals": null @@ -72,8 +71,7 @@ "ConsumerChains": null, "AssignedKeys": null, "ProviderKeys": null, - "ConsumerChainQueueSizes": null, - "GlobalSlashQueueSize": null, + "ConsumerPendingPacketQueueSize": null, "RegisteredConsumerRewardDenoms": null, "ClientsFrozenHeights": null, "Proposals": { @@ -117,8 +115,7 @@ "ProviderKeys": { "carol": "cosmosvalcons1ezyrq65s3gshhx5585w6mpusq3xsj3ayzf4uv6" }, - "ConsumerChainQueueSizes": null, - "GlobalSlashQueueSize": null, + "ConsumerPendingPacketQueueSize": null, "RegisteredConsumerRewardDenoms": null, "ClientsFrozenHeights": null, "Proposals": null @@ -162,8 +159,7 @@ "ProviderKeys": { "carol": "cosmosvalcons1ezyrq65s3gshhx5585w6mpusq3xsj3ayzf4uv6" }, - "ConsumerChainQueueSizes": null, - "GlobalSlashQueueSize": null, + "ConsumerPendingPacketQueueSize": null, "RegisteredConsumerRewardDenoms": null, "ClientsFrozenHeights": null, "Proposals": null @@ -199,8 +195,7 @@ "ConsumerChains": null, "AssignedKeys": null, "ProviderKeys": null, - "ConsumerChainQueueSizes": null, - "GlobalSlashQueueSize": null, + "ConsumerPendingPacketQueueSize": null, "RegisteredConsumerRewardDenoms": null, "ClientsFrozenHeights": null, "Proposals": { @@ -258,8 +253,7 @@ "ConsumerChains": null, "AssignedKeys": null, "ProviderKeys": null, - "ConsumerChainQueueSizes": null, - "GlobalSlashQueueSize": null, + "ConsumerPendingPacketQueueSize": null, "RegisteredConsumerRewardDenoms": null, "ClientsFrozenHeights": null, "Proposals": null @@ -277,8 +271,7 @@ "ConsumerChains": null, "AssignedKeys": null, "ProviderKeys": null, - "ConsumerChainQueueSizes": null, - "GlobalSlashQueueSize": null, + "ConsumerPendingPacketQueueSize": null, "RegisteredConsumerRewardDenoms": null, "ClientsFrozenHeights": null, "Proposals": null @@ -328,8 +321,7 @@ "ConsumerChains": null, "AssignedKeys": null, "ProviderKeys": null, - "ConsumerChainQueueSizes": null, - "GlobalSlashQueueSize": null, + "ConsumerPendingPacketQueueSize": null, "RegisteredConsumerRewardDenoms": null, "ClientsFrozenHeights": null, "Proposals": null @@ -351,8 +343,7 @@ "ConsumerChains": null, "AssignedKeys": null, "ProviderKeys": null, - "ConsumerChainQueueSizes": null, - "GlobalSlashQueueSize": null, + "ConsumerPendingPacketQueueSize": null, "RegisteredConsumerRewardDenoms": null, "ClientsFrozenHeights": null, "Proposals": null @@ -378,8 +369,7 @@ "ConsumerChains": null, "AssignedKeys": null, "ProviderKeys": null, - "ConsumerChainQueueSizes": null, - "GlobalSlashQueueSize": null, + "ConsumerPendingPacketQueueSize": null, "RegisteredConsumerRewardDenoms": null, "ClientsFrozenHeights": null, "Proposals": null @@ -401,8 +391,7 @@ "ConsumerChains": null, "AssignedKeys": null, "ProviderKeys": null, - "ConsumerChainQueueSizes": null, - "GlobalSlashQueueSize": null, + "ConsumerPendingPacketQueueSize": null, "RegisteredConsumerRewardDenoms": null, "ClientsFrozenHeights": null, "Proposals": null @@ -431,8 +420,7 @@ "ConsumerChains": null, "AssignedKeys": null, "ProviderKeys": null, - "ConsumerChainQueueSizes": null, - "GlobalSlashQueueSize": null, + "ConsumerPendingPacketQueueSize": null, "RegisteredConsumerRewardDenoms": null, "ClientsFrozenHeights": null, "Proposals": null @@ -454,8 +442,7 @@ "ConsumerChains": null, "AssignedKeys": null, "ProviderKeys": null, - "ConsumerChainQueueSizes": null, - "GlobalSlashQueueSize": null, + "ConsumerPendingPacketQueueSize": null, "RegisteredConsumerRewardDenoms": null, "ClientsFrozenHeights": null, "Proposals": null diff --git a/tests/e2e/tracehandler_testdata/consumer-misbehaviour.json b/tests/e2e/tracehandler_testdata/consumer-misbehaviour.json index 717761327d..028637934f 100644 --- a/tests/e2e/tracehandler_testdata/consumer-misbehaviour.json +++ b/tests/e2e/tracehandler_testdata/consumer-misbehaviour.json @@ -31,8 +31,7 @@ "ConsumerChains": null, "AssignedKeys": null, "ProviderKeys": null, - "ConsumerChainQueueSizes": null, - "GlobalSlashQueueSize": null, + "ConsumerPendingPacketQueueSize": null, "RegisteredConsumerRewardDenoms": null, "ClientsFrozenHeights": null, "Proposals": null @@ -66,8 +65,7 @@ "ConsumerChains": null, "AssignedKeys": null, "ProviderKeys": null, - "ConsumerChainQueueSizes": null, - "GlobalSlashQueueSize": null, + "ConsumerPendingPacketQueueSize": null, "RegisteredConsumerRewardDenoms": null, "ClientsFrozenHeights": null, "Proposals": { @@ -111,8 +109,7 @@ "ProviderKeys": { "alice": "cosmosvalcons1qmq08eruchr5sf5s3rwz7djpr5a25f7xw4mceq" }, - "ConsumerChainQueueSizes": null, - "GlobalSlashQueueSize": null, + "ConsumerPendingPacketQueueSize": null, "RegisteredConsumerRewardDenoms": null, "ClientsFrozenHeights": null, "Proposals": null @@ -146,8 +143,7 @@ "ConsumerChains": null, "AssignedKeys": null, "ProviderKeys": null, - "ConsumerChainQueueSizes": null, - "GlobalSlashQueueSize": null, + "ConsumerPendingPacketQueueSize": null, "RegisteredConsumerRewardDenoms": null, "ClientsFrozenHeights": null, "Proposals": { @@ -193,8 +189,7 @@ "ConsumerChains": null, "AssignedKeys": null, "ProviderKeys": null, - "ConsumerChainQueueSizes": null, - "GlobalSlashQueueSize": null, + "ConsumerPendingPacketQueueSize": null, "RegisteredConsumerRewardDenoms": null, "ClientsFrozenHeights": null, "Proposals": null @@ -211,8 +206,7 @@ "ConsumerChains": null, "AssignedKeys": null, "ProviderKeys": null, - "ConsumerChainQueueSizes": null, - "GlobalSlashQueueSize": null, + "ConsumerPendingPacketQueueSize": null, "RegisteredConsumerRewardDenoms": null, "ClientsFrozenHeights": null, "Proposals": null @@ -263,8 +257,7 @@ "ConsumerChains": null, "AssignedKeys": null, "ProviderKeys": null, - "ConsumerChainQueueSizes": null, - "GlobalSlashQueueSize": null, + "ConsumerPendingPacketQueueSize": null, "RegisteredConsumerRewardDenoms": null, "ClientsFrozenHeights": null, "Proposals": null @@ -281,8 +274,7 @@ "ConsumerChains": null, "AssignedKeys": null, "ProviderKeys": null, - "ConsumerChainQueueSizes": null, - "GlobalSlashQueueSize": null, + "ConsumerPendingPacketQueueSize": null, "RegisteredConsumerRewardDenoms": null, "ClientsFrozenHeights": null, "Proposals": null @@ -310,8 +302,7 @@ "ConsumerChains": null, "AssignedKeys": null, "ProviderKeys": null, - "ConsumerChainQueueSizes": null, - "GlobalSlashQueueSize": null, + "ConsumerPendingPacketQueueSize": null, "RegisteredConsumerRewardDenoms": null, "ClientsFrozenHeights": null, "Proposals": null @@ -351,8 +342,7 @@ "ConsumerChains": null, "AssignedKeys": null, "ProviderKeys": null, - "ConsumerChainQueueSizes": null, - "GlobalSlashQueueSize": null, + "ConsumerPendingPacketQueueSize": null, "RegisteredConsumerRewardDenoms": null, "ClientsFrozenHeights": null, "Proposals": null @@ -372,8 +362,7 @@ "ConsumerChains": null, "AssignedKeys": null, "ProviderKeys": null, - "ConsumerChainQueueSizes": null, - "GlobalSlashQueueSize": null, + "ConsumerPendingPacketQueueSize": null, "RegisteredConsumerRewardDenoms": null, "ClientsFrozenHeights": null, "Proposals": null @@ -401,8 +390,7 @@ "ConsumerChains": null, "AssignedKeys": null, "ProviderKeys": null, - "ConsumerChainQueueSizes": null, - "GlobalSlashQueueSize": null, + "ConsumerPendingPacketQueueSize": null, "RegisteredConsumerRewardDenoms": null, "ClientsFrozenHeights": null, "Proposals": null @@ -422,8 +410,7 @@ "ConsumerChains": null, "AssignedKeys": null, "ProviderKeys": null, - "ConsumerChainQueueSizes": null, - "GlobalSlashQueueSize": null, + "ConsumerPendingPacketQueueSize": null, "RegisteredConsumerRewardDenoms": null, "ClientsFrozenHeights": { "07-tendermint-0": { diff --git a/tests/e2e/tracehandler_testdata/democracy.json b/tests/e2e/tracehandler_testdata/democracy.json index 729dd35005..3a9ab84a96 100644 --- a/tests/e2e/tracehandler_testdata/democracy.json +++ b/tests/e2e/tracehandler_testdata/democracy.json @@ -610,10 +610,7 @@ "ProviderKeys": null, "ConsumerPendingPacketQueueSize": null, "RegisteredConsumerRewardDenoms": null, -<<<<<<< HEAD "ClientsFrozenHeights": null, -======= ->>>>>>> main "Proposals": { "1": { "RawProposal": { diff --git a/tests/e2e/tracehandler_testdata/democracyRewardsSteps.json b/tests/e2e/tracehandler_testdata/democracyRewardsSteps.json index c9e36b15b6..74df5293b9 100644 --- a/tests/e2e/tracehandler_testdata/democracyRewardsSteps.json +++ b/tests/e2e/tracehandler_testdata/democracyRewardsSteps.json @@ -610,10 +610,7 @@ "ProviderKeys": null, "ConsumerPendingPacketQueueSize": null, "RegisteredConsumerRewardDenoms": null, -<<<<<<< HEAD "ClientsFrozenHeights": null, -======= ->>>>>>> main "Proposals": { "1": { "RawProposal": { diff --git a/tests/e2e/tracehandler_testdata/happyPath.json b/tests/e2e/tracehandler_testdata/happyPath.json index ee62446065..7c26f5c274 100644 --- a/tests/e2e/tracehandler_testdata/happyPath.json +++ b/tests/e2e/tracehandler_testdata/happyPath.json @@ -1358,69 +1358,6 @@ } }, { -<<<<<<< HEAD -======= - "ActionType": "main.submitEquivocationProposalAction", - "Action": { - "Chain": "consu", - "Height": 10, - "Time": "2023-10-04T12:14:14.883367+02:00", - "Power": 500, - "Validator": "bob", - "Deposit": 10000001, - "From": "bob" - }, - "State": { - "consu": { - "ValBalances": null, - "ValPowers": { - "alice": 509, - "bob": 500, - "carol": 495 - }, - "StakedTokens": null, - "Params": null, - "Rewards": null, - "ConsumerChains": null, - "AssignedKeys": null, - "ProviderKeys": null, - "ConsumerPendingPacketQueueSize": null, - "RegisteredConsumerRewardDenoms": null, - "Proposals": null - }, - "provi": { - "ValBalances": { - "bob": 9500000000 - }, - "ValPowers": { - "alice": 509, - "bob": 500, - "carol": 495 - }, - "StakedTokens": null, - "Params": null, - "Rewards": null, - "ConsumerChains": null, - "AssignedKeys": null, - "ProviderKeys": null, - "ConsumerPendingPacketQueueSize": null, - "RegisteredConsumerRewardDenoms": null, - "Proposals": { - "2": { - "RawProposal": { - "Title": "", - "Description": "", - "Deposit": 0, - "Status": "" - }, - "Type": "main.TextProposal" - } - } - } - } - }, - { ->>>>>>> main "ActionType": "main.doublesignSlashAction", "Action": { "Validator": "carol", @@ -1507,313 +1444,7 @@ "ProviderKeys": null, "ConsumerPendingPacketQueueSize": null, "RegisteredConsumerRewardDenoms": null, -<<<<<<< HEAD "ClientsFrozenHeights": null, -======= - "Proposals": null - } - } - }, - { - "ActionType": "main.doublesignSlashAction", - "Action": { - "Validator": "bob", - "Chain": "consu" - }, - "State": { - "consu": { - "ValBalances": null, - "ValPowers": { - "alice": 509, - "bob": 500, - "carol": 0 - }, - "StakedTokens": null, - "Params": null, - "Rewards": null, - "ConsumerChains": null, - "AssignedKeys": null, - "ProviderKeys": null, - "ConsumerPendingPacketQueueSize": null, - "RegisteredConsumerRewardDenoms": null, - "Proposals": null - }, - "provi": { - "ValBalances": null, - "ValPowers": { - "alice": 509, - "bob": 500, - "carol": 0 - }, - "StakedTokens": null, - "Params": null, - "Rewards": null, - "ConsumerChains": null, - "AssignedKeys": null, - "ProviderKeys": null, - "ConsumerPendingPacketQueueSize": null, - "RegisteredConsumerRewardDenoms": null, - "Proposals": null - } - } - }, - { - "ActionType": "main.relayPacketsAction", - "Action": { - "ChainA": "provi", - "ChainB": "consu", - "Port": "provider", - "Channel": 0 - }, - "State": { - "consu": { - "ValBalances": null, - "ValPowers": { - "alice": 509, - "bob": 500, - "carol": 0 - }, - "StakedTokens": null, - "Params": null, - "Rewards": null, - "ConsumerChains": null, - "AssignedKeys": null, - "ProviderKeys": null, - "ConsumerPendingPacketQueueSize": null, - "RegisteredConsumerRewardDenoms": null, - "Proposals": null - }, - "provi": { - "ValBalances": null, - "ValPowers": { - "alice": 509, - "bob": 500, - "carol": 0 - }, - "StakedTokens": null, - "Params": null, - "Rewards": null, - "ConsumerChains": null, - "AssignedKeys": null, - "ProviderKeys": null, - "ConsumerPendingPacketQueueSize": null, - "RegisteredConsumerRewardDenoms": null, - "Proposals": null - } - } - }, - { - "ActionType": "main.relayPacketsAction", - "Action": { - "ChainA": "provi", - "ChainB": "consu", - "Port": "provider", - "Channel": 0 - }, - "State": { - "consu": { - "ValBalances": null, - "ValPowers": { - "alice": 509, - "bob": 500, - "carol": 0 - }, - "StakedTokens": null, - "Params": null, - "Rewards": null, - "ConsumerChains": null, - "AssignedKeys": null, - "ProviderKeys": null, - "ConsumerPendingPacketQueueSize": null, - "RegisteredConsumerRewardDenoms": null, - "Proposals": null - }, - "provi": { - "ValBalances": null, - "ValPowers": { - "alice": 509, - "bob": 500, - "carol": 0 - }, - "StakedTokens": null, - "Params": null, - "Rewards": null, - "ConsumerChains": null, - "AssignedKeys": null, - "ProviderKeys": null, - "ConsumerPendingPacketQueueSize": null, - "RegisteredConsumerRewardDenoms": null, - "Proposals": null - } - } - }, - { - "ActionType": "main.submitEquivocationProposalAction", - "Action": { - "Chain": "consu", - "Height": 10, - "Time": "2023-10-04T12:14:14.88337+02:00", - "Power": 500, - "Validator": "bob", - "Deposit": 10000001, - "From": "bob" - }, - "State": { - "consu": { - "ValBalances": null, - "ValPowers": { - "alice": 509, - "bob": 500, - "carol": 0 - }, - "StakedTokens": null, - "Params": null, - "Rewards": null, - "ConsumerChains": null, - "AssignedKeys": null, - "ProviderKeys": null, - "ConsumerPendingPacketQueueSize": null, - "RegisteredConsumerRewardDenoms": null, - "Proposals": null - }, - "provi": { - "ValBalances": { - "bob": 9489999999 - }, - "ValPowers": { - "alice": 509, - "bob": 500, - "carol": 0 - }, - "StakedTokens": null, - "Params": null, - "Rewards": null, - "ConsumerChains": null, - "AssignedKeys": null, - "ProviderKeys": null, - "ConsumerPendingPacketQueueSize": null, - "RegisteredConsumerRewardDenoms": null, - "Proposals": { - "2": { - "RawProposal": { - "Height": 10, - "Power": 500, - "ConsensusAddress": "cosmosvalcons1nx7n5uh0ztxsynn4sje6eyq2ud6rc6klc96w39", - "Deposit": 10000001, - "Status": "PROPOSAL_STATUS_VOTING_PERIOD" - }, - "Type": "main.EquivocationProposal" - } - } - } - } - }, - { - "ActionType": "main.voteGovProposalAction", - "Action": { - "Chain": "provi", - "From": [ - "alice", - "bob", - "carol" - ], - "Vote": [ - "yes", - "yes", - "yes" - ], - "PropNumber": 2 - }, - "State": { - "consu": { - "ValBalances": null, - "ValPowers": { - "alice": 509, - "bob": 500, - "carol": 0 - }, - "StakedTokens": null, - "Params": null, - "Rewards": null, - "ConsumerChains": null, - "AssignedKeys": null, - "ProviderKeys": null, - "ConsumerPendingPacketQueueSize": null, - "RegisteredConsumerRewardDenoms": null, - "Proposals": null - }, - "provi": { - "ValBalances": null, - "ValPowers": { - "alice": 509, - "bob": 0, - "carol": 0 - }, - "StakedTokens": null, - "Params": null, - "Rewards": null, - "ConsumerChains": null, - "AssignedKeys": null, - "ProviderKeys": null, - "ConsumerPendingPacketQueueSize": null, - "RegisteredConsumerRewardDenoms": null, - "Proposals": { - "2": { - "RawProposal": { - "Height": 10, - "Power": 500, - "ConsensusAddress": "cosmosvalcons1nx7n5uh0ztxsynn4sje6eyq2ud6rc6klc96w39", - "Deposit": 10000001, - "Status": "PROPOSAL_STATUS_PASSED" - }, - "Type": "main.EquivocationProposal" - } - } - } - } - }, - { - "ActionType": "main.relayPacketsAction", - "Action": { - "ChainA": "provi", - "ChainB": "consu", - "Port": "provider", - "Channel": 0 - }, - "State": { - "consu": { - "ValBalances": null, - "ValPowers": { - "alice": 509, - "bob": 0, - "carol": 0 - }, - "StakedTokens": null, - "Params": null, - "Rewards": null, - "ConsumerChains": null, - "AssignedKeys": null, - "ProviderKeys": null, - "ConsumerPendingPacketQueueSize": null, - "RegisteredConsumerRewardDenoms": null, - "Proposals": null - }, - "provi": { - "ValBalances": null, - "ValPowers": { - "alice": 509, - "bob": 0, - "carol": 0 - }, - "StakedTokens": null, - "Params": null, - "Rewards": null, - "ConsumerChains": null, - "AssignedKeys": null, - "ProviderKeys": null, - "ConsumerPendingPacketQueueSize": null, - "RegisteredConsumerRewardDenoms": null, ->>>>>>> main "Proposals": null } } diff --git a/tests/e2e/tracehandler_testdata/shorthappy.json b/tests/e2e/tracehandler_testdata/shorthappy.json index a9dc42e18c..85e96aeed1 100644 --- a/tests/e2e/tracehandler_testdata/shorthappy.json +++ b/tests/e2e/tracehandler_testdata/shorthappy.json @@ -929,69 +929,6 @@ } }, { -<<<<<<< HEAD -======= - "ActionType": "main.submitEquivocationProposalAction", - "Action": { - "Chain": "consu", - "Height": 10, - "Time": "2023-10-04T12:14:14.883385+02:00", - "Power": 500, - "Validator": "bob", - "Deposit": 10000001, - "From": "bob" - }, - "State": { - "consu": { - "ValBalances": null, - "ValPowers": { - "alice": 509, - "bob": 500, - "carol": 495 - }, - "StakedTokens": null, - "Params": null, - "Rewards": null, - "ConsumerChains": null, - "AssignedKeys": null, - "ProviderKeys": null, - "ConsumerPendingPacketQueueSize": null, - "RegisteredConsumerRewardDenoms": null, - "Proposals": null - }, - "provi": { - "ValBalances": { - "bob": 9500000000 - }, - "ValPowers": { - "alice": 509, - "bob": 500, - "carol": 495 - }, - "StakedTokens": null, - "Params": null, - "Rewards": null, - "ConsumerChains": null, - "AssignedKeys": null, - "ProviderKeys": null, - "ConsumerPendingPacketQueueSize": null, - "RegisteredConsumerRewardDenoms": null, - "Proposals": { - "2": { - "RawProposal": { - "Title": "", - "Description": "", - "Deposit": 0, - "Status": "" - }, - "Type": "main.TextProposal" - } - } - } - } - }, - { ->>>>>>> main "ActionType": "main.doublesignSlashAction", "Action": { "Validator": "carol", @@ -1078,313 +1015,7 @@ "ProviderKeys": null, "ConsumerPendingPacketQueueSize": null, "RegisteredConsumerRewardDenoms": null, -<<<<<<< HEAD "ClientsFrozenHeights": null, -======= - "Proposals": null - } - } - }, - { - "ActionType": "main.doublesignSlashAction", - "Action": { - "Validator": "bob", - "Chain": "consu" - }, - "State": { - "consu": { - "ValBalances": null, - "ValPowers": { - "alice": 509, - "bob": 500, - "carol": 0 - }, - "StakedTokens": null, - "Params": null, - "Rewards": null, - "ConsumerChains": null, - "AssignedKeys": null, - "ProviderKeys": null, - "ConsumerPendingPacketQueueSize": null, - "RegisteredConsumerRewardDenoms": null, - "Proposals": null - }, - "provi": { - "ValBalances": null, - "ValPowers": { - "alice": 509, - "bob": 500, - "carol": 0 - }, - "StakedTokens": null, - "Params": null, - "Rewards": null, - "ConsumerChains": null, - "AssignedKeys": null, - "ProviderKeys": null, - "ConsumerPendingPacketQueueSize": null, - "RegisteredConsumerRewardDenoms": null, - "Proposals": null - } - } - }, - { - "ActionType": "main.relayPacketsAction", - "Action": { - "ChainA": "provi", - "ChainB": "consu", - "Port": "provider", - "Channel": 0 - }, - "State": { - "consu": { - "ValBalances": null, - "ValPowers": { - "alice": 509, - "bob": 500, - "carol": 0 - }, - "StakedTokens": null, - "Params": null, - "Rewards": null, - "ConsumerChains": null, - "AssignedKeys": null, - "ProviderKeys": null, - "ConsumerPendingPacketQueueSize": null, - "RegisteredConsumerRewardDenoms": null, - "Proposals": null - }, - "provi": { - "ValBalances": null, - "ValPowers": { - "alice": 509, - "bob": 500, - "carol": 0 - }, - "StakedTokens": null, - "Params": null, - "Rewards": null, - "ConsumerChains": null, - "AssignedKeys": null, - "ProviderKeys": null, - "ConsumerPendingPacketQueueSize": null, - "RegisteredConsumerRewardDenoms": null, - "Proposals": null - } - } - }, - { - "ActionType": "main.relayPacketsAction", - "Action": { - "ChainA": "provi", - "ChainB": "consu", - "Port": "provider", - "Channel": 0 - }, - "State": { - "consu": { - "ValBalances": null, - "ValPowers": { - "alice": 509, - "bob": 500, - "carol": 0 - }, - "StakedTokens": null, - "Params": null, - "Rewards": null, - "ConsumerChains": null, - "AssignedKeys": null, - "ProviderKeys": null, - "ConsumerPendingPacketQueueSize": null, - "RegisteredConsumerRewardDenoms": null, - "Proposals": null - }, - "provi": { - "ValBalances": null, - "ValPowers": { - "alice": 509, - "bob": 500, - "carol": 0 - }, - "StakedTokens": null, - "Params": null, - "Rewards": null, - "ConsumerChains": null, - "AssignedKeys": null, - "ProviderKeys": null, - "ConsumerPendingPacketQueueSize": null, - "RegisteredConsumerRewardDenoms": null, - "Proposals": null - } - } - }, - { - "ActionType": "main.submitEquivocationProposalAction", - "Action": { - "Chain": "consu", - "Height": 10, - "Time": "2023-10-04T12:14:14.883388+02:00", - "Power": 500, - "Validator": "bob", - "Deposit": 10000001, - "From": "bob" - }, - "State": { - "consu": { - "ValBalances": null, - "ValPowers": { - "alice": 509, - "bob": 500, - "carol": 0 - }, - "StakedTokens": null, - "Params": null, - "Rewards": null, - "ConsumerChains": null, - "AssignedKeys": null, - "ProviderKeys": null, - "ConsumerPendingPacketQueueSize": null, - "RegisteredConsumerRewardDenoms": null, - "Proposals": null - }, - "provi": { - "ValBalances": { - "bob": 9489999999 - }, - "ValPowers": { - "alice": 509, - "bob": 500, - "carol": 0 - }, - "StakedTokens": null, - "Params": null, - "Rewards": null, - "ConsumerChains": null, - "AssignedKeys": null, - "ProviderKeys": null, - "ConsumerPendingPacketQueueSize": null, - "RegisteredConsumerRewardDenoms": null, - "Proposals": { - "2": { - "RawProposal": { - "Height": 10, - "Power": 500, - "ConsensusAddress": "cosmosvalcons1nx7n5uh0ztxsynn4sje6eyq2ud6rc6klc96w39", - "Deposit": 10000001, - "Status": "PROPOSAL_STATUS_VOTING_PERIOD" - }, - "Type": "main.EquivocationProposal" - } - } - } - } - }, - { - "ActionType": "main.voteGovProposalAction", - "Action": { - "Chain": "provi", - "From": [ - "alice", - "bob", - "carol" - ], - "Vote": [ - "yes", - "yes", - "yes" - ], - "PropNumber": 2 - }, - "State": { - "consu": { - "ValBalances": null, - "ValPowers": { - "alice": 509, - "bob": 500, - "carol": 0 - }, - "StakedTokens": null, - "Params": null, - "Rewards": null, - "ConsumerChains": null, - "AssignedKeys": null, - "ProviderKeys": null, - "ConsumerPendingPacketQueueSize": null, - "RegisteredConsumerRewardDenoms": null, - "Proposals": null - }, - "provi": { - "ValBalances": null, - "ValPowers": { - "alice": 509, - "bob": 0, - "carol": 0 - }, - "StakedTokens": null, - "Params": null, - "Rewards": null, - "ConsumerChains": null, - "AssignedKeys": null, - "ProviderKeys": null, - "ConsumerPendingPacketQueueSize": null, - "RegisteredConsumerRewardDenoms": null, - "Proposals": { - "2": { - "RawProposal": { - "Height": 10, - "Power": 500, - "ConsensusAddress": "cosmosvalcons1nx7n5uh0ztxsynn4sje6eyq2ud6rc6klc96w39", - "Deposit": 10000001, - "Status": "PROPOSAL_STATUS_PASSED" - }, - "Type": "main.EquivocationProposal" - } - } - } - } - }, - { - "ActionType": "main.relayPacketsAction", - "Action": { - "ChainA": "provi", - "ChainB": "consu", - "Port": "provider", - "Channel": 0 - }, - "State": { - "consu": { - "ValBalances": null, - "ValPowers": { - "alice": 509, - "bob": 0, - "carol": 0 - }, - "StakedTokens": null, - "Params": null, - "Rewards": null, - "ConsumerChains": null, - "AssignedKeys": null, - "ProviderKeys": null, - "ConsumerPendingPacketQueueSize": null, - "RegisteredConsumerRewardDenoms": null, - "Proposals": null - }, - "provi": { - "ValBalances": null, - "ValPowers": { - "alice": 509, - "bob": 0, - "carol": 0 - }, - "StakedTokens": null, - "Params": null, - "Rewards": null, - "ConsumerChains": null, - "AssignedKeys": null, - "ProviderKeys": null, - "ConsumerPendingPacketQueueSize": null, - "RegisteredConsumerRewardDenoms": null, ->>>>>>> main "Proposals": null } } diff --git a/tests/e2e/tracehandler_testdata/slashThrottle.json b/tests/e2e/tracehandler_testdata/slashThrottle.json index 181fb4716e..dbca351d49 100644 --- a/tests/e2e/tracehandler_testdata/slashThrottle.json +++ b/tests/e2e/tracehandler_testdata/slashThrottle.json @@ -657,6 +657,7 @@ "ProviderKeys": null, "ConsumerPendingPacketQueueSize": null, "RegisteredConsumerRewardDenoms": null, + "ClientsFrozenHeights": null, "Proposals": null } } @@ -678,6 +679,7 @@ "ProviderKeys": null, "ConsumerPendingPacketQueueSize": 1, "RegisteredConsumerRewardDenoms": null, + "ClientsFrozenHeights": null, "Proposals": null }, "provi": { diff --git a/tests/integration/misbehaviour.go b/tests/integration/misbehaviour.go index e12d12664c..97aef5f2aa 100644 --- a/tests/integration/misbehaviour.go +++ b/tests/integration/misbehaviour.go @@ -379,33 +379,75 @@ func (s *CCVTestSuite) TestCheckMisbehaviour() { clientTMValset := tmtypes.NewValidatorSet(s.consumerChain.Vals.Validators) clientSigners := s.consumerChain.Signers + // create a valid client header + clientHeader := s.consumerChain.CreateTMClientHeader( + s.consumerChain.ChainID, + int64(clientHeight.RevisionHeight+1), + clientHeight, + headerTs, + clientTMValset, + clientTMValset, + clientTMValset, + clientSigners, + ) + // create an alternative validator set using more than 1/3 of the trusted validator set altValset := tmtypes.NewValidatorSet(s.consumerChain.Vals.Validators[0:2]) altSigners := make(map[string]tmtypes.PrivValidator, 2) altSigners[clientTMValset.Validators[0].Address.String()] = clientSigners[clientTMValset.Validators[0].Address.String()] altSigners[clientTMValset.Validators[1].Address.String()] = clientSigners[clientTMValset.Validators[1].Address.String()] + // create a conflicting client with different block ID using + // to alternative validator set + clientHeaderWithDiffBlockID := s.consumerChain.CreateTMClientHeader( + s.consumerChain.ChainID, + int64(clientHeight.RevisionHeight+1), + clientHeight, + headerTs, + altValset, + altValset, + clientTMValset, // trusted valset stays the same + altSigners, + ) + + // create an alternative validator set using less than 1/3 of the trusted validator set + altValset2 := tmtypes.NewValidatorSet(s.consumerChain.Vals.Validators[0:1]) + altSigners2 := make(map[string]tmtypes.PrivValidator, 1) + altSigners2[clientTMValset.Validators[0].Address.String()] = clientSigners[clientTMValset.Validators[0].Address.String()] + + // create a conflicting client header with insufficient voting power + clientHeaderWithInsufficientVotingPower := s.consumerChain.CreateTMClientHeader( + s.consumerChain.ChainID, + int64(clientHeight.RevisionHeight+1), + clientHeight, + // use a different block time to change the header BlockID + headerTs.Add(time.Hour), + altValset2, + altValset2, + clientTMValset, + altSigners2, + ) + testCases := []struct { name string misbehaviour *ibctmtypes.Misbehaviour expPass bool }{ { - "client state not found - shouldn't pass", + "identical headers - shouldn't pass", &ibctmtypes.Misbehaviour{ - ClientId: "clientID", + ClientId: s.path.EndpointA.ClientID, + Header1: clientHeader, + Header2: clientHeader, + }, + false, + }, + { + "misbehaviour isn't for a consumer chain - shouldn't pass", + &ibctmtypes.Misbehaviour{ + ClientId: s.path.EndpointA.ClientID, Header1: s.consumerChain.CreateTMClientHeader( - s.consumerChain.ChainID, - int64(clientHeight.RevisionHeight+1), - clientHeight, - headerTs, - clientTMValset, - clientTMValset, - clientTMValset, - clientSigners, - ), - Header2: s.consumerChain.CreateTMClientHeader( - s.consumerChain.ChainID, + "aChainID", int64(clientHeight.RevisionHeight+1), clientHeight, headerTs, @@ -414,23 +456,16 @@ func (s *CCVTestSuite) TestCheckMisbehaviour() { clientTMValset, altSigners, ), + Header2: clientHeader, }, false, }, { - "invalid misbehaviour with empty header1 - shouldn't pass", + "client ID doesn't correspond to the client ID of consumer chain - shouldn't pass", &ibctmtypes.Misbehaviour{ - Header1: &ibctmtypes.Header{}, - Header2: s.consumerChain.CreateTMClientHeader( - s.consumerChain.ChainID, - int64(clientHeight.RevisionHeight+1), - clientHeight, - headerTs, - altValset, - altValset, - clientTMValset, - altSigners, - ), + ClientId: "clientID", + Header1: clientHeader, + Header2: clientHeaderWithDiffBlockID, }, false, }, @@ -438,16 +473,7 @@ func (s *CCVTestSuite) TestCheckMisbehaviour() { "invalid misbehaviour with different header height - shouldn't pass", &ibctmtypes.Misbehaviour{ ClientId: s.path.EndpointA.ClientID, - Header1: s.consumerChain.CreateTMClientHeader( - s.consumerChain.ChainID, - int64(clientHeight.RevisionHeight+1), - clientHeight, - headerTs, - clientTMValset, - clientTMValset, - clientTMValset, - clientSigners, - ), + Header1: clientHeader, Header2: s.consumerChain.CreateTMClientHeader( s.consumerChain.ChainID, int64(clientHeight.RevisionHeight+2), @@ -461,41 +487,22 @@ func (s *CCVTestSuite) TestCheckMisbehaviour() { }, false, }, - // TODO: should pass after 1401 is merged - // { - // "one header of the misbehaviour has insufficient voting power - shouldn't pass", - // &ibctmtypes.Misbehaviour{ - // ClientId: s.path.EndpointA.ClientID, - // Header1: clientHeader, - // Header2: clientHeader2, - // }, - // false, - // }, + { + "one header of the misbehaviour has insufficient voting power - shouldn't pass", + &ibctmtypes.Misbehaviour{ + ClientId: s.path.EndpointA.ClientID, + Header1: clientHeader, + Header2: clientHeaderWithInsufficientVotingPower, + }, + false, + }, { "valid misbehaviour - should pass", &ibctmtypes.Misbehaviour{ ClientId: s.path.EndpointA.ClientID, - Header1: s.consumerChain.CreateTMClientHeader( - s.consumerChain.ChainID, - int64(clientHeight.RevisionHeight+1), - clientHeight, - headerTs, - clientTMValset, - clientTMValset, - clientTMValset, - clientSigners, - ), + Header1: clientHeader, // create header using a different validator set - Header2: s.consumerChain.CreateTMClientHeader( - s.consumerChain.ChainID, - int64(clientHeight.RevisionHeight+1), - clientHeight, - headerTs, - altValset, - altValset, - clientTMValset, - altSigners, - ), + Header2: clientHeaderWithDiffBlockID, }, true, }, diff --git a/x/ccv/provider/keeper/misbehaviour.go b/x/ccv/provider/keeper/misbehaviour.go index 23b0caeb5a..e019477f4f 100644 --- a/x/ccv/provider/keeper/misbehaviour.go +++ b/x/ccv/provider/keeper/misbehaviour.go @@ -83,11 +83,11 @@ func (k Keeper) GetByzantineValidators(ctx sdk.Context, misbehaviour ibctmtypes. // construct the trusted and conflicted light blocks lightBlock1, err := headerToLightBlock(*misbehaviour.Header1) if err != nil { - return + return validators, err } lightBlock2, err := headerToLightBlock(*misbehaviour.Header2) if err != nil { - return + return validators, err } // Check if the misbehaviour corresponds to an Amnesia attack, @@ -97,7 +97,7 @@ func (k Keeper) GetByzantineValidators(ctx sdk.Context, misbehaviour ibctmtypes. // // Note that we cannot differentiate which of the headers is trusted or malicious, if !headersStateTransitionsAreConflicting(*lightBlock1.Header, *lightBlock2.Header) && lightBlock1.Commit.Round != lightBlock2.Commit.Round { - return + return validators, nil } // compare the signatures of the headers @@ -153,9 +153,21 @@ func headerToLightBlock(h ibctmtypes.Header) (*tmtypes.LightBlock, error) { } // CheckMisbehaviour checks that headers in the given misbehaviour forms -// a valid light client attack and that the corresponding light client isn't expired +// a valid light client attack from an ICS consumer chain and that the light client isn't expired func (k Keeper) CheckMisbehaviour(ctx sdk.Context, misbehaviour ibctmtypes.Misbehaviour) error { - clientState, found := k.clientKeeper.GetClientState(ctx, misbehaviour.ClientId) + // check that the misbehaviour is for an ICS consumer chain + clientId, found := k.GetConsumerClientId(ctx, misbehaviour.Header1.Header.ChainID) + if !found { + return fmt.Errorf("incorrect misbehaviour with conflicting headers from a non-existent consumer chain: %s", misbehaviour.Header1.Header.ChainID) + } else if misbehaviour.ClientId != clientId { + return fmt.Errorf("incorrect misbehaviour: expected client ID for consumer chain %s is %s got %s", + misbehaviour.Header1.Header.ChainID, + clientId, + misbehaviour.ClientId, + ) + } + + clientState, found := k.clientKeeper.GetClientState(ctx, clientId) if !found { return errorsmod.Wrapf(ibcclienttypes.ErrClientNotFound, "cannot check misbehaviour for client with ID %s", misbehaviour.ClientId) } @@ -169,14 +181,19 @@ func (k Keeper) CheckMisbehaviour(ctx sdk.Context, misbehaviour ibctmtypes.Misbe return errorsmod.Wrap(ibcclienttypes.ErrInvalidMisbehaviour, "headers are not at same height") } - // CheckMisbehaviour verifies that the headers have both he same block height and - // different blockID hashes + // CheckForMisbehaviour verifies that the headers have different blockID hashes ok := clientState.CheckForMisbehaviour(ctx, k.cdc, clientStore, &misbehaviour) if !ok { return errorsmod.Wrapf(ibcclienttypes.ErrInvalidMisbehaviour, "invalid misbehaviour for client-id: %s", misbehaviour.ClientId) } - // TODO check misb valset signatures here + // VerifyClientMessage calls verifyMisbehaviour which verifies that the headers in the misbehaviour + // are valid against their respective trusted consensus states and that at least a TrustLevel of the validator set signed their commit, + // see checkMisbehaviourHeader in ibc-go/blob/v7.3.0/modules/light-clients/07-tendermint/misbehaviour_handle.go#L126 + if err := clientState.VerifyClientMessage(ctx, k.cdc, clientStore, &misbehaviour); err != nil { + return err + } + return nil }