From 6b7eec66b04b19201712b20a6c09414849765dd0 Mon Sep 17 00:00:00 2001 From: Simon Noetzlin Date: Tue, 29 Aug 2023 15:13:39 +0200 Subject: [PATCH 01/21] fix double voting cli --- x/ccv/provider/client/cli/tx.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/x/ccv/provider/client/cli/tx.go b/x/ccv/provider/client/cli/tx.go index 1d3ccc0011..ed7c72b6b1 100644 --- a/x/ccv/provider/client/cli/tx.go +++ b/x/ccv/provider/client/cli/tx.go @@ -176,7 +176,7 @@ func NewSubmitConsumerDoubleVotingCmd() *cobra.Command { return err } - msg, err := types.NewMsgSubmitConsumerDoubleVoting(submitter, ev, nil) + msg, err := types.NewMsgSubmitConsumerDoubleVoting(submitter, ev, &header) if err != nil { return err } From f254a375aa25a8043ad9f38510aadeb3c8d1486b Mon Sep 17 00:00:00 2001 From: Simon Noetzlin Date: Fri, 1 Sep 2023 15:24:15 +0200 Subject: [PATCH 02/21] add double-signing e2e test --- Dockerfile | 4 +- tests/e2e/actions.go | 25 ++++- tests/e2e/main.go | 4 +- tests/e2e/steps.go | 27 ++--- tests/e2e/steps_double_sign.go | 119 +++++++++++++++++++-- tests/e2e/testnet-scripts/fork-consumer.sh | 2 +- 6 files changed, 152 insertions(+), 29 deletions(-) diff --git a/Dockerfile b/Dockerfile index 03939617be..16bf042319 100644 --- a/Dockerfile +++ b/Dockerfile @@ -28,7 +28,7 @@ RUN go mod tidy RUN make install # Get Hermes build -FROM otacrew/hermes-ics:latest AS hermes-builder +FROM otacrew/hermes-ics:double-voting AS hermes-builder # Get CometMock FROM informalofftermatt/cometmock:latest as cometmock-builder @@ -36,7 +36,7 @@ FROM informalofftermatt/cometmock:latest as cometmock-builder # Get GoRelayer FROM informalofftermatt/gorelayer:nogas AS gorelayer-builder -FROM --platform=linux/amd64 fedora:36 +FROM --platform=linux/arm64 fedora:36 RUN dnf update -y RUN dnf install -y which iproute iputils procps-ng vim-minimal tmux net-tools htop jq USER root diff --git a/tests/e2e/actions.go b/tests/e2e/actions.go index 9c7d41af17..417052a063 100644 --- a/tests/e2e/actions.go +++ b/tests/e2e/actions.go @@ -718,7 +718,7 @@ rpc_addr = "%s" rpc_timeout = "10s" store_prefix = "ibc" trusting_period = "14days" -websocket_addr = "%s" +event_source = { mode = "push", url = "%s", batch_delay = "50ms" } ccv_consumer_chain = %v [chains.gas_price] @@ -1682,6 +1682,29 @@ func (tr TestRun) invokeDoublesignSlash( tr.waitBlocks("provi", 10, 2*time.Minute) } +// Run an instance of the Hermes relayer in the "evidence" mode +// to detect and report the double signing evidences committed on the consumer chain +// to the provider chain +type detectDoubleSigningEvidenceAction struct { + chain chainID +} + +func (tr TestRun) detectDoubleSigningEvidence( + action detectDoubleSigningEvidenceAction, + verbose bool, +) { + chainConfig := tr.chainConfigs[action.chain] + //#nosec G204 -- Bypass linter warning for spawning subprocess with cmd arguments. + fmt.Println("docker", "exec", "-d", tr.containerConfig.instanceName, + "hermes", "evidence", "--chain", string(chainConfig.chainId)) + bz, err := exec.Command("docker", "exec", "-d", tr.containerConfig.instanceName, + "hermes", "evidence", "--chain", string(chainConfig.chainId)).CombinedOutput() + if err != nil { + log.Fatal(err, "\n", string(bz)) + } + tr.waitBlocks("provi", 10, 2*time.Minute) +} + type assignConsumerPubKeyAction struct { chain chainID validator validatorID diff --git a/tests/e2e/main.go b/tests/e2e/main.go index 406a015e63..b3762d65e8 100644 --- a/tests/e2e/main.go +++ b/tests/e2e/main.go @@ -102,7 +102,7 @@ func (tr *TestRun) Run(steps []Step, localSdkPath string, useGaia bool, gaiaTag tr.validateStringLiterals() tr.startDocker() tr.executeSteps(steps) - tr.teardownDocker() + // tr.teardownDocker() } type testRunWithSteps struct { @@ -180,6 +180,8 @@ func (tr *TestRun) runStep(step Step, verbose bool) { tr.updateLightClient(action, verbose) case assertChainIsHaltedAction: tr.assertChainIsHalted(action, verbose) + case detectDoubleSigningEvidenceAction: + tr.detectDoubleSigningEvidence(action, verbose) default: log.Fatalf("unknown action in testRun %s: %#v", tr.name, action) } diff --git a/tests/e2e/steps.go b/tests/e2e/steps.go index 78a56654e6..0e0d36f79a 100644 --- a/tests/e2e/steps.go +++ b/tests/e2e/steps.go @@ -15,19 +15,20 @@ func concatSteps(steps ...[]Step) []Step { var happyPathSteps = concatSteps( stepsStartChains([]string{"consu"}, false), - stepsDelegate("consu"), - stepsAssignConsumerKeyOnStartedChain("consu", "bob"), - stepsUnbond("consu"), - stepsRedelegateForOptOut("consu"), - stepsDowntimeWithOptOut("consu"), - stepsRedelegate("consu"), - stepsDowntime("consu"), - stepsRejectEquivocationProposal("consu", 2), // prop to tombstone bob is rejected - stepsDoubleSignOnProviderAndConsumer("consu"), // carol double signs on provider, bob double signs on consumer - stepsSubmitEquivocationProposal("consu", 2), // now prop to tombstone bob is submitted and accepted - stepsStartRelayer(), - stepsConsumerRemovalPropNotPassing("consu", 3), // submit removal prop but vote no on it - chain should stay - stepsStopChain("consu", 4), // stop chain + stepsDoubleSignOnConsumer("consu"), + // stepsDelegate("consu"), + // stepsAssignConsumerKeyOnStartedChain("consu", "bob"), + // stepsUnbond("consu"), + // stepsRedelegateForOptOut("consu"), + // stepsDowntimeWithOptOut("consu"), + // stepsRedelegate("consu"), + // stepsDowntime("consu"), + // stepsRejectEquivocationProposal("consu", 2), // prop to tombstone bob is rejected + // stepsDoubleSignOnProviderAndConsumer("consu"), // carol double signs on provider, bob double signs on consumer + // stepsSubmitEquivocationProposal("consu", 2), // now prop to tombstone bob is submitted and accepted + // stepsStartRelayer(), + // stepsConsumerRemovalPropNotPassing("consu", 3), // submit removal prop but vote no on it - chain should stay + // stepsStopChain("consu", 4), // stop chain ) var shortHappyPathSteps = concatSteps( diff --git a/tests/e2e/steps_double_sign.go b/tests/e2e/steps_double_sign.go index c007fa5c1c..1ea8c20b94 100644 --- a/tests/e2e/steps_double_sign.go +++ b/tests/e2e/steps_double_sign.go @@ -13,16 +13,16 @@ func stepsDoubleSignOnProviderAndConsumer(consumerName string) []Step { // slash on provider chainID("provi"): ChainState{ ValPowers: &map[validatorID]uint{ - validatorID("alice"): 509, + validatorID("alice"): 510, validatorID("bob"): 500, validatorID("carol"): 0, // from 500 to 0 }, }, chainID(consumerName): ChainState{ ValPowers: &map[validatorID]uint{ - validatorID("alice"): 509, + validatorID("alice"): 510, validatorID("bob"): 500, - validatorID("carol"): 495, // not tombstoned on consumerName yet + validatorID("carol"): 500, // not tombstoned on consumerName yet }, }, }, @@ -38,14 +38,14 @@ func stepsDoubleSignOnProviderAndConsumer(consumerName string) []Step { state: State{ chainID("provi"): ChainState{ ValPowers: &map[validatorID]uint{ - validatorID("alice"): 509, + validatorID("alice"): 510, validatorID("bob"): 500, validatorID("carol"): 0, }, }, chainID(consumerName): ChainState{ ValPowers: &map[validatorID]uint{ - validatorID("alice"): 509, + validatorID("alice"): 510, validatorID("bob"): 500, validatorID("carol"): 0, // tombstoning visible on consumerName }, @@ -63,14 +63,14 @@ func stepsDoubleSignOnProviderAndConsumer(consumerName string) []Step { state: State{ chainID("provi"): ChainState{ ValPowers: &map[validatorID]uint{ - validatorID("alice"): 509, + validatorID("alice"): 510, validatorID("bob"): 500, validatorID("carol"): 0, }, }, chainID(consumerName): ChainState{ ValPowers: &map[validatorID]uint{ - validatorID("alice"): 509, + validatorID("alice"): 510, validatorID("bob"): 500, validatorID("carol"): 0, }, @@ -87,14 +87,14 @@ func stepsDoubleSignOnProviderAndConsumer(consumerName string) []Step { state: State{ chainID("provi"): ChainState{ ValPowers: &map[validatorID]uint{ - validatorID("alice"): 509, + validatorID("alice"): 510, validatorID("bob"): 500, // not tombstoned validatorID("carol"): 0, }, }, chainID(consumerName): ChainState{ ValPowers: &map[validatorID]uint{ - validatorID("alice"): 509, + validatorID("alice"): 510, validatorID("bob"): 500, // not tombstoned validatorID("carol"): 0, }, @@ -112,14 +112,111 @@ func stepsDoubleSignOnProviderAndConsumer(consumerName string) []Step { state: State{ chainID("provi"): ChainState{ ValPowers: &map[validatorID]uint{ - validatorID("alice"): 509, + validatorID("alice"): 510, validatorID("bob"): 500, validatorID("carol"): 0, }, }, chainID(consumerName): ChainState{ ValPowers: &map[validatorID]uint{ - validatorID("alice"): 509, + validatorID("alice"): 510, + validatorID("bob"): 500, // not tombstoned + validatorID("carol"): 0, + }, + }, + }, + }, + } +} + +func stepsDoubleSignOnConsumer(consumerName string) []Step { + return []Step{ + { + action: doublesignSlashAction{ + chain: chainID("consu"), + validator: validatorID("bob"), + }, + state: State{ + chainID("provi"): ChainState{ + ValPowers: &map[validatorID]uint{ + validatorID("alice"): 500, + validatorID("bob"): 500, + validatorID("carol"): 500, + }, + }, + chainID(consumerName): ChainState{ + ValPowers: &map[validatorID]uint{ + validatorID("alice"): 500, + validatorID("bob"): 500, + validatorID("carol"): 500, + }, + }, + }, + }, + { + action: detectDoubleSigningEvidenceAction{ + chain: chainID("consu"), + }, + state: State{ + chainID("provi"): ChainState{ + ValPowers: &map[validatorID]uint{ + validatorID("alice"): 500, + validatorID("bob"): 500, + validatorID("carol"): 0, + }, + }, + chainID(consumerName): ChainState{ + ValPowers: &map[validatorID]uint{ + validatorID("alice"): 500, + validatorID("bob"): 500, + validatorID("carol"): 500, + }, + }, + }, + }, + { + action: relayPacketsAction{ + chainA: chainID("provi"), + chainB: chainID(consumerName), + port: "provider", + channel: 0, + }, + state: State{ + chainID("provi"): ChainState{ + ValPowers: &map[validatorID]uint{ + validatorID("alice"): 500, + validatorID("bob"): 500, + validatorID("carol"): 0, + }, + }, + chainID(consumerName): ChainState{ + ValPowers: &map[validatorID]uint{ + validatorID("alice"): 500, + validatorID("bob"): 500, + validatorID("carol"): 0, + }, + }, + }, + }, + { + // consumer learns about the double sign + action: relayPacketsAction{ + chainA: chainID("provi"), + chainB: chainID(consumerName), + port: "provider", + channel: 0, + }, + state: State{ + chainID("provi"): ChainState{ + ValPowers: &map[validatorID]uint{ + validatorID("alice"): 500, + validatorID("bob"): 500, + validatorID("carol"): 0, + }, + }, + chainID(consumerName): ChainState{ + ValPowers: &map[validatorID]uint{ + validatorID("alice"): 500, validatorID("bob"): 500, // not tombstoned validatorID("carol"): 0, }, diff --git a/tests/e2e/testnet-scripts/fork-consumer.sh b/tests/e2e/testnet-scripts/fork-consumer.sh index 0bf96fcb79..db02ee017e 100644 --- a/tests/e2e/testnet-scripts/fork-consumer.sh +++ b/tests/e2e/testnet-scripts/fork-consumer.sh @@ -63,7 +63,7 @@ rpc_addr = "http://$CONS_CHAIN_PREFIX.252:26658" rpc_timeout = "10s" store_prefix = "ibc" trusting_period = "2days" -websocket_addr = "ws://$CONS_CHAIN_PREFIX.252:26658/websocket" +websocket_addr = "event_source = { mode = 'push', url = 'ws://$CONS_CHAIN_PREFIX.252:26658/websocket' , batch_delay = '50ms' } [chains.gas_price] denom = "stake" From 497d4d6ab92f5cdf564847415317b97c79346d18 Mon Sep 17 00:00:00 2001 From: Simon Noetzlin Date: Fri, 1 Sep 2023 16:44:05 +0200 Subject: [PATCH 03/21] refortmat e2e double voting test --- Dockerfile | 2 +- tests/e2e/actions.go | 2 -- tests/e2e/main.go | 4 +++- tests/e2e/steps.go | 35 ++++++++++++++++++------------ tests/e2e/steps_double_sign.go | 39 ++++++---------------------------- 5 files changed, 32 insertions(+), 50 deletions(-) diff --git a/Dockerfile b/Dockerfile index 16bf042319..aa47792968 100644 --- a/Dockerfile +++ b/Dockerfile @@ -36,7 +36,7 @@ FROM informalofftermatt/cometmock:latest as cometmock-builder # Get GoRelayer FROM informalofftermatt/gorelayer:nogas AS gorelayer-builder -FROM --platform=linux/arm64 fedora:36 +FROM --platform=linux/amd64 fedora:36 RUN dnf update -y RUN dnf install -y which iproute iputils procps-ng vim-minimal tmux net-tools htop jq USER root diff --git a/tests/e2e/actions.go b/tests/e2e/actions.go index 417052a063..516fc02e08 100644 --- a/tests/e2e/actions.go +++ b/tests/e2e/actions.go @@ -1695,8 +1695,6 @@ func (tr TestRun) detectDoubleSigningEvidence( ) { chainConfig := tr.chainConfigs[action.chain] //#nosec G204 -- Bypass linter warning for spawning subprocess with cmd arguments. - fmt.Println("docker", "exec", "-d", tr.containerConfig.instanceName, - "hermes", "evidence", "--chain", string(chainConfig.chainId)) bz, err := exec.Command("docker", "exec", "-d", tr.containerConfig.instanceName, "hermes", "evidence", "--chain", string(chainConfig.chainId)).CombinedOutput() if err != nil { diff --git a/tests/e2e/main.go b/tests/e2e/main.go index b3762d65e8..36fff9d40f 100644 --- a/tests/e2e/main.go +++ b/tests/e2e/main.go @@ -63,7 +63,9 @@ func main() { {DemocracyTestRun(false), rewardDenomConsumerSteps}, {SlashThrottleTestRun(), slashThrottleSteps}, {ConsumerMisbehaviourTestRun(), consumerMisbehaviourSteps}, + {DefaultTestRun(), consumerDoubleSignSteps}, } + if includeMultiConsumer != nil && *includeMultiConsumer { testRuns = append(testRuns, testRunWithSteps{MultiConsumerTestRun(), multipleConsumers}) } @@ -102,7 +104,7 @@ func (tr *TestRun) Run(steps []Step, localSdkPath string, useGaia bool, gaiaTag tr.validateStringLiterals() tr.startDocker() tr.executeSteps(steps) - // tr.teardownDocker() + tr.teardownDocker() } type testRunWithSteps struct { diff --git a/tests/e2e/steps.go b/tests/e2e/steps.go index 0e0d36f79a..8a9f4ccdea 100644 --- a/tests/e2e/steps.go +++ b/tests/e2e/steps.go @@ -15,20 +15,19 @@ func concatSteps(steps ...[]Step) []Step { var happyPathSteps = concatSteps( stepsStartChains([]string{"consu"}, false), - stepsDoubleSignOnConsumer("consu"), - // stepsDelegate("consu"), - // stepsAssignConsumerKeyOnStartedChain("consu", "bob"), - // stepsUnbond("consu"), - // stepsRedelegateForOptOut("consu"), - // stepsDowntimeWithOptOut("consu"), - // stepsRedelegate("consu"), - // stepsDowntime("consu"), - // stepsRejectEquivocationProposal("consu", 2), // prop to tombstone bob is rejected - // stepsDoubleSignOnProviderAndConsumer("consu"), // carol double signs on provider, bob double signs on consumer - // stepsSubmitEquivocationProposal("consu", 2), // now prop to tombstone bob is submitted and accepted - // stepsStartRelayer(), - // stepsConsumerRemovalPropNotPassing("consu", 3), // submit removal prop but vote no on it - chain should stay - // stepsStopChain("consu", 4), // stop chain + stepsDelegate("consu"), + stepsAssignConsumerKeyOnStartedChain("consu", "bob"), + stepsUnbond("consu"), + stepsRedelegateForOptOut("consu"), + stepsDowntimeWithOptOut("consu"), + stepsRedelegate("consu"), + stepsDowntime("consu"), + stepsRejectEquivocationProposal("consu", 2), // prop to tombstone bob is rejected + stepsDoubleSignOnProviderAndConsumer("consu"), // carol double signs on provider, bob double signs on consumer + stepsSubmitEquivocationProposal("consu", 2), // now prop to tombstone bob is submitted and accepted + stepsStartRelayer(), + stepsConsumerRemovalPropNotPassing("consu", 3), // submit removal prop but vote no on it - chain should stay + stepsStopChain("consu", 4), // stop chain ) var shortHappyPathSteps = concatSteps( @@ -95,3 +94,11 @@ var consumerMisbehaviourSteps = concatSteps( // make consumer validator to misbehave and get jail stepsCauseConsumerMisbehaviour("consu"), ) + +var consumerDoubleSignSteps = concatSteps( + // start provider and consumer chain + stepsStartChains([]string{"consu"}, false), + + // make consumer validator to double sign and get jail + stepsCauseDoubleSignOnConsumer("consu"), +) diff --git a/tests/e2e/steps_double_sign.go b/tests/e2e/steps_double_sign.go index 1ea8c20b94..a78e8121c3 100644 --- a/tests/e2e/steps_double_sign.go +++ b/tests/e2e/steps_double_sign.go @@ -129,7 +129,7 @@ func stepsDoubleSignOnProviderAndConsumer(consumerName string) []Step { } } -func stepsDoubleSignOnConsumer(consumerName string) []Step { +func stepsCauseDoubleSignOnConsumer(consumerName string) []Step { return []Step{ { action: doublesignSlashAction{ @@ -161,45 +161,20 @@ func stepsDoubleSignOnConsumer(consumerName string) []Step { chainID("provi"): ChainState{ ValPowers: &map[validatorID]uint{ validatorID("alice"): 500, - validatorID("bob"): 500, - validatorID("carol"): 0, - }, - }, - chainID(consumerName): ChainState{ - ValPowers: &map[validatorID]uint{ - validatorID("alice"): 500, - validatorID("bob"): 500, + validatorID("bob"): 0, validatorID("carol"): 500, }, }, - }, - }, - { - action: relayPacketsAction{ - chainA: chainID("provi"), - chainB: chainID(consumerName), - port: "provider", - channel: 0, - }, - state: State{ - chainID("provi"): ChainState{ - ValPowers: &map[validatorID]uint{ - validatorID("alice"): 500, - validatorID("bob"): 500, - validatorID("carol"): 0, - }, - }, chainID(consumerName): ChainState{ ValPowers: &map[validatorID]uint{ validatorID("alice"): 500, validatorID("bob"): 500, - validatorID("carol"): 0, + validatorID("carol"): 500, }, }, }, }, { - // consumer learns about the double sign action: relayPacketsAction{ chainA: chainID("provi"), chainB: chainID(consumerName), @@ -210,15 +185,15 @@ func stepsDoubleSignOnConsumer(consumerName string) []Step { chainID("provi"): ChainState{ ValPowers: &map[validatorID]uint{ validatorID("alice"): 500, - validatorID("bob"): 500, - validatorID("carol"): 0, + validatorID("bob"): 0, + validatorID("carol"): 500, }, }, chainID(consumerName): ChainState{ ValPowers: &map[validatorID]uint{ validatorID("alice"): 500, - validatorID("bob"): 500, // not tombstoned - validatorID("carol"): 0, + validatorID("bob"): 0, + validatorID("carol"): 500, }, }, }, From 902c1b87b48ad91ba598fe0a83bbabb359f3fbd7 Mon Sep 17 00:00:00 2001 From: Simon Noetzlin Date: Mon, 4 Sep 2023 11:25:11 +0200 Subject: [PATCH 04/21] godoc, revert unwanted changes --- tests/e2e/actions.go | 7 ++++--- tests/e2e/steps_double_sign.go | 22 +++++++++++----------- 2 files changed, 15 insertions(+), 14 deletions(-) diff --git a/tests/e2e/actions.go b/tests/e2e/actions.go index 516fc02e08..d33c0ab55b 100644 --- a/tests/e2e/actions.go +++ b/tests/e2e/actions.go @@ -1682,9 +1682,10 @@ func (tr TestRun) invokeDoublesignSlash( tr.waitBlocks("provi", 10, 2*time.Minute) } -// Run an instance of the Hermes relayer in the "evidence" mode -// to detect and report the double signing evidences committed on the consumer chain -// to the provider chain +// Run an instance of the Hermes relayer in the "evidence" mode, +// which detects the double signing evidences on the consumer chain. +// Each infraction detected is reported to the provider chain using +// a SubmitConsumerDoubleVoting message type detectDoubleSigningEvidenceAction struct { chain chainID } diff --git a/tests/e2e/steps_double_sign.go b/tests/e2e/steps_double_sign.go index a78e8121c3..2069bfc1e8 100644 --- a/tests/e2e/steps_double_sign.go +++ b/tests/e2e/steps_double_sign.go @@ -13,16 +13,16 @@ func stepsDoubleSignOnProviderAndConsumer(consumerName string) []Step { // slash on provider chainID("provi"): ChainState{ ValPowers: &map[validatorID]uint{ - validatorID("alice"): 510, + validatorID("alice"): 509, validatorID("bob"): 500, validatorID("carol"): 0, // from 500 to 0 }, }, chainID(consumerName): ChainState{ ValPowers: &map[validatorID]uint{ - validatorID("alice"): 510, + validatorID("alice"): 509, validatorID("bob"): 500, - validatorID("carol"): 500, // not tombstoned on consumerName yet + validatorID("carol"): 495, // not tombstoned on consumerName yet }, }, }, @@ -38,14 +38,14 @@ func stepsDoubleSignOnProviderAndConsumer(consumerName string) []Step { state: State{ chainID("provi"): ChainState{ ValPowers: &map[validatorID]uint{ - validatorID("alice"): 510, + validatorID("alice"): 509, validatorID("bob"): 500, validatorID("carol"): 0, }, }, chainID(consumerName): ChainState{ ValPowers: &map[validatorID]uint{ - validatorID("alice"): 510, + validatorID("alice"): 509, validatorID("bob"): 500, validatorID("carol"): 0, // tombstoning visible on consumerName }, @@ -63,14 +63,14 @@ func stepsDoubleSignOnProviderAndConsumer(consumerName string) []Step { state: State{ chainID("provi"): ChainState{ ValPowers: &map[validatorID]uint{ - validatorID("alice"): 510, + validatorID("alice"): 509, validatorID("bob"): 500, validatorID("carol"): 0, }, }, chainID(consumerName): ChainState{ ValPowers: &map[validatorID]uint{ - validatorID("alice"): 510, + validatorID("alice"): 509, validatorID("bob"): 500, validatorID("carol"): 0, }, @@ -87,14 +87,14 @@ func stepsDoubleSignOnProviderAndConsumer(consumerName string) []Step { state: State{ chainID("provi"): ChainState{ ValPowers: &map[validatorID]uint{ - validatorID("alice"): 510, + validatorID("alice"): 509, validatorID("bob"): 500, // not tombstoned validatorID("carol"): 0, }, }, chainID(consumerName): ChainState{ ValPowers: &map[validatorID]uint{ - validatorID("alice"): 510, + validatorID("alice"): 509, validatorID("bob"): 500, // not tombstoned validatorID("carol"): 0, }, @@ -112,14 +112,14 @@ func stepsDoubleSignOnProviderAndConsumer(consumerName string) []Step { state: State{ chainID("provi"): ChainState{ ValPowers: &map[validatorID]uint{ - validatorID("alice"): 510, + validatorID("alice"): 509, validatorID("bob"): 500, validatorID("carol"): 0, }, }, chainID(consumerName): ChainState{ ValPowers: &map[validatorID]uint{ - validatorID("alice"): 510, + validatorID("alice"): 509, validatorID("bob"): 500, // not tombstoned validatorID("carol"): 0, }, From 6fb2307698f4a86a9726a3ed29b10be6982863a2 Mon Sep 17 00:00:00 2001 From: Simon Noetzlin Date: Mon, 4 Sep 2023 11:37:31 +0200 Subject: [PATCH 05/21] nit --- tests/e2e/actions.go | 2 +- tests/e2e/steps_double_sign.go | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/tests/e2e/actions.go b/tests/e2e/actions.go index d33c0ab55b..072b89402b 100644 --- a/tests/e2e/actions.go +++ b/tests/e2e/actions.go @@ -1685,7 +1685,7 @@ func (tr TestRun) invokeDoublesignSlash( // Run an instance of the Hermes relayer in the "evidence" mode, // which detects the double signing evidences on the consumer chain. // Each infraction detected is reported to the provider chain using -// a SubmitConsumerDoubleVoting message +// a SubmitConsumerDoubleVoting message. type detectDoubleSigningEvidenceAction struct { chain chainID } diff --git a/tests/e2e/steps_double_sign.go b/tests/e2e/steps_double_sign.go index 2069bfc1e8..81c17db2b1 100644 --- a/tests/e2e/steps_double_sign.go +++ b/tests/e2e/steps_double_sign.go @@ -129,6 +129,7 @@ func stepsDoubleSignOnProviderAndConsumer(consumerName string) []Step { } } +// Steps that make bob double sign on the consumer func stepsCauseDoubleSignOnConsumer(consumerName string) []Step { return []Step{ { @@ -153,6 +154,8 @@ func stepsCauseDoubleSignOnConsumer(consumerName string) []Step { }, }, }, + // detect the double voting infraction + // and jail bob on the provider { action: detectDoubleSigningEvidenceAction{ chain: chainID("consu"), @@ -174,6 +177,7 @@ func stepsCauseDoubleSignOnConsumer(consumerName string) []Step { }, }, }, + // consumer learn about the jailing { action: relayPacketsAction{ chainA: chainID("provi"), From 20b0e35a6d45111bd7bfeb6845417ba752c67c60 Mon Sep 17 00:00:00 2001 From: Simon Noetzlin Date: Tue, 5 Sep 2023 10:13:42 +0200 Subject: [PATCH 06/21] verify dv evidence using malicious validator pubkey in infraction block header --- tests/integration/double_vote.go | 29 +++++++++++++- x/ccv/provider/keeper/double_vote.go | 58 +++++++--------------------- x/ccv/provider/keeper/msg_server.go | 29 +++++++++++++- 3 files changed, 70 insertions(+), 46 deletions(-) diff --git a/tests/integration/double_vote.go b/tests/integration/double_vote.go index 184f7604bb..a0f0195932 100644 --- a/tests/integration/double_vote.go +++ b/tests/integration/double_vote.go @@ -1,9 +1,11 @@ package integration import ( + cryptocodec "github.com/cosmos/cosmos-sdk/crypto/codec" sdk "github.com/cosmos/cosmos-sdk/types" testutil "github.com/cosmos/interchain-security/v2/testutil/crypto" "github.com/cosmos/interchain-security/v2/x/ccv/provider/types" + "github.com/tendermint/tendermint/crypto" tmtypes "github.com/tendermint/tendermint/types" ) @@ -74,10 +76,13 @@ func (s *CCVTestSuite) TestHandleConsumerDoubleVoting() { s.consumerChain.ChainID, ) + provSigner.GetPubKey() + testCases := []struct { name string ev *tmtypes.DuplicateVoteEvidence chainID string + pubkey crypto.PubKey expPass bool }{ { @@ -90,6 +95,20 @@ func (s *CCVTestSuite) TestHandleConsumerDoubleVoting() { Timestamp: s.consumerCtx().BlockTime(), }, "chainID", + consuVal.PubKey, + false, + }, + { + "wrong public key - shouldn't pass", + &tmtypes.DuplicateVoteEvidence{ + VoteA: consuVote, + VoteB: consuVote, + ValidatorPower: consuVal.VotingPower, + TotalVotingPower: consuVal.VotingPower, + Timestamp: s.consumerCtx().BlockTime(), + }, + s.consumerChain.ChainID, + provVal.PubKey, false, }, { @@ -103,6 +122,7 @@ func (s *CCVTestSuite) TestHandleConsumerDoubleVoting() { Timestamp: s.consumerCtx().BlockTime(), }, s.consumerChain.ChainID, + consuVal.PubKey, false, }, { @@ -119,6 +139,7 @@ func (s *CCVTestSuite) TestHandleConsumerDoubleVoting() { Timestamp: s.consumerCtx().BlockTime(), }, s.consumerChain.ChainID, + consuVal.PubKey, true, }, { @@ -132,6 +153,7 @@ func (s *CCVTestSuite) TestHandleConsumerDoubleVoting() { Timestamp: s.consumerCtx().BlockTime(), }, s.consumerChain.ChainID, + provVal.PubKey, true, }, } @@ -144,17 +166,22 @@ func (s *CCVTestSuite) TestHandleConsumerDoubleVoting() { // reset context for each run provCtx := s.providerCtx() - // if the evidence was built using the validator provider address and key, + // if the evidence was built using the validator provider address andkey, // we remove the consumer key assigned to the validator otherwise // HandleConsumerDoubleVoting uses the consumer key to verify the signature if tc.ev.VoteA.ValidatorAddress.String() != consuVal.Address.String() { s.providerApp.GetProviderKeeper().DeleteKeyAssignments(provCtx, s.consumerChain.ChainID) } + // convert validator public key + pk, err := cryptocodec.FromTmPubKeyInterface(tc.pubkey) + s.Require().NoError(err) + err = s.providerApp.GetProviderKeeper().HandleConsumerDoubleVoting( provCtx, tc.ev, tc.chainID, + pk, ) if tc.expPass { diff --git a/x/ccv/provider/keeper/double_vote.go b/x/ccv/provider/keeper/double_vote.go index 171be6b250..626d7694c7 100644 --- a/x/ccv/provider/keeper/double_vote.go +++ b/x/ccv/provider/keeper/double_vote.go @@ -4,7 +4,6 @@ import ( "bytes" "fmt" - cryptocodec "github.com/cosmos/cosmos-sdk/crypto/codec" cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" sdk "github.com/cosmos/cosmos-sdk/types" @@ -14,9 +13,20 @@ import ( tmtypes "github.com/tendermint/tendermint/types" ) -// HandleConsumerDoubleVoting verifies a double voting evidence for a given a consumer chain and, -// if successful, executes the jailing of the malicious validator. -func (k Keeper) HandleConsumerDoubleVoting(ctx sdk.Context, evidence *tmtypes.DuplicateVoteEvidence, chainID string) error { +// HandleConsumerDoubleVoting verifies a double voting evidence for a given a consumer chain ID +// and a public key, if successful, executes the jailing of the malicious validator. +func (k Keeper) HandleConsumerDoubleVoting( + ctx sdk.Context, + evidence *tmtypes.DuplicateVoteEvidence, + chainID string, + pubkey cryptotypes.PubKey, +) error { + + // verifies the double voting evidence using the consumer chain public key + if err := k.VerifyDoubleVotingEvidence(ctx, *evidence, chainID, pubkey); err != nil { + return err + } + // get the validator's consensus address on the provider providerAddr := k.GetProviderAddrFromConsumerAddr( ctx, @@ -24,17 +34,6 @@ func (k Keeper) HandleConsumerDoubleVoting(ctx sdk.Context, evidence *tmtypes.Du types.NewConsumerConsAddress(sdk.ConsAddress(evidence.VoteA.ValidatorAddress.Bytes())), ) - // get validator pubkey used on the consumer chain - pubkey, err := k.getValidatorPubkeyOnConsumer(ctx, chainID, providerAddr) - if err != nil { - return err - } - - // verifies the double voting evidence using the consumer chain public key - if err := k.VerifyDoubleVotingEvidence(ctx, *evidence, chainID, pubkey); err != nil { - return err - } - // execute the jailing k.JailValidator(ctx, providerAddr) @@ -107,32 +106,3 @@ func (k Keeper) VerifyDoubleVotingEvidence( return nil } - -// getValidatorPubkeyOnConsumer returns the public key a validator used on a given consumer chain. -// Note that it can either be an assigned public key or the same public key the validator uses -// on the provider chain. -func (k Keeper) getValidatorPubkeyOnConsumer( - ctx sdk.Context, - chainID string, - providerAddr types.ProviderConsAddress, -) (pubkey cryptotypes.PubKey, err error) { - tmPK, ok := k.GetValidatorConsumerPubKey(ctx, chainID, providerAddr) - if ok { - pubkey, err = cryptocodec.FromTmProtoPublicKey(tmPK) - if err != nil { - return - } - } else { - val, ok := k.stakingKeeper.GetValidatorByConsAddr(ctx, providerAddr.ToSdkConsAddr()) - if !ok { - err = fmt.Errorf("cannot find validator %s", providerAddr.String()) - return - } - pubkey, err = val.ConsPubKey() - if err != nil { - return - } - } - - return -} diff --git a/x/ccv/provider/keeper/msg_server.go b/x/ccv/provider/keeper/msg_server.go index b6b96bb010..0a5ba4554b 100644 --- a/x/ccv/provider/keeper/msg_server.go +++ b/x/ccv/provider/keeper/msg_server.go @@ -4,6 +4,8 @@ import ( "context" "encoding/base64" + cryptocodec "github.com/cosmos/cosmos-sdk/crypto/codec" + errorsmod "cosmossdk.io/errors" sdk "github.com/cosmos/cosmos-sdk/types" stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" @@ -156,7 +158,32 @@ func (k msgServer) SubmitConsumerDoubleVoting(goCtx context.Context, msg *types. return nil, err } - if err := k.Keeper.HandleConsumerDoubleVoting(ctx, evidence, msg.InfractionBlockHeader.Header.ChainID); err != nil { + // parse the validator set of the infraction block header in order + // to find the public key of the validator who double voted + + // get validator set + valset, err := tmtypes.ValidatorSetFromProto(msg.InfractionBlockHeader.ValidatorSet) + if err != nil { + return nil, err + } + + // look for the malicious validator in the validator set + _, validator := valset.GetByAddress(evidence.VoteA.ValidatorAddress) + if validator == nil { + return nil, errorsmod.Wrapf( + ccvtypes.ErrInvalidEvidence, + "misbehaving validator %s cannot be found in the infraction block header validator set", + evidence.VoteA.ValidatorAddress) + } + + pubkey, err := cryptocodec.FromTmPubKeyInterface(validator.PubKey) + if err != nil { + return nil, err + } + + // handle the the double voting evidence using the the chain ID of the infraction block header + // and the malicious validator's public key + if err := k.Keeper.HandleConsumerDoubleVoting(ctx, evidence, msg.InfractionBlockHeader.Header.ChainID, pubkey); err != nil { return &types.MsgSubmitConsumerDoubleVotingResponse{}, err } From 0883d7a8b8d3cc056f74690e1dc6c8fbf3b2a413 Mon Sep 17 00:00:00 2001 From: Simon Noetzlin Date: Wed, 6 Sep 2023 16:51:22 +0200 Subject: [PATCH 07/21] save changes --- Dockerfile | 2 +- tests/e2e/actions.go | 24 +++++++++++++++++++++- tests/e2e/main.go | 14 +++++++------ tests/e2e/steps_consumer_misbehaviour.go | 23 ++++++++++++++++++++- tests/e2e/testnet-scripts/fork-consumer.sh | 6 ++++-- 5 files changed, 58 insertions(+), 11 deletions(-) diff --git a/Dockerfile b/Dockerfile index 03939617be..ba351f2e78 100644 --- a/Dockerfile +++ b/Dockerfile @@ -36,7 +36,7 @@ FROM informalofftermatt/cometmock:latest as cometmock-builder # Get GoRelayer FROM informalofftermatt/gorelayer:nogas AS gorelayer-builder -FROM --platform=linux/amd64 fedora:36 +FROM --platform=linux/arm64 fedora:36 RUN dnf update -y RUN dnf install -y which iproute iputils procps-ng vim-minimal tmux net-tools htop jq USER root diff --git a/tests/e2e/actions.go b/tests/e2e/actions.go index 9c7d41af17..9fe8b5d0d7 100644 --- a/tests/e2e/actions.go +++ b/tests/e2e/actions.go @@ -718,7 +718,7 @@ rpc_addr = "%s" rpc_timeout = "10s" store_prefix = "ibc" trusting_period = "14days" -websocket_addr = "%s" +event_source = { mode = "push", url = "%s", batch_delay = "50ms" } ccv_consumer_chain = %v [chains.gas_price] @@ -1844,3 +1844,25 @@ func (tr TestRun) GetPathNameForGorelayer(chainA, chainB chainID) string { return pathName } + +// Run an instance of the Hermes relayer in the "evidence" mode, +// which detects evidences committed on the consumer chain. +// Each infraction detected is reported to the provider chain using +// either a SubmitConsumerDoubleVoting or a SubmitConsumerMisbehaviour message. +type detectConsumerEvidenceAction struct { + chain chainID +} + +func (tr TestRun) detectConsumerEvidence( + action detectConsumerEvidenceAction, + verbose bool, +) { + chainConfig := tr.chainConfigs[action.chain] + //#nosec G204 -- Bypass linter warning for spawning subprocess with cmd arguments. + bz, err := exec.Command("docker", "exec", "-d", tr.containerConfig.instanceName, + "hermes", "evidence", "--chain", string(chainConfig.chainId)).CombinedOutput() + if err != nil { + log.Fatal(err, "\n", string(bz)) + } + tr.waitBlocks("provi", 10, 2*time.Minute) +} diff --git a/tests/e2e/main.go b/tests/e2e/main.go index 406a015e63..fbae6b88d5 100644 --- a/tests/e2e/main.go +++ b/tests/e2e/main.go @@ -57,11 +57,11 @@ func main() { } testRuns := []testRunWithSteps{ - {ChangeoverTestRun(), changeoverSteps}, - {DefaultTestRun(), happyPathSteps}, - {DemocracyTestRun(true), democracySteps}, - {DemocracyTestRun(false), rewardDenomConsumerSteps}, - {SlashThrottleTestRun(), slashThrottleSteps}, + // {ChangeoverTestRun(), changeoverSteps}, + // {DefaultTestRun(), happyPathSteps}, + // {DemocracyTestRun(true), democracySteps}, + // {DemocracyTestRun(false), rewardDenomConsumerSteps}, + // {SlashThrottleTestRun(), slashThrottleSteps}, {ConsumerMisbehaviourTestRun(), consumerMisbehaviourSteps}, } if includeMultiConsumer != nil && *includeMultiConsumer { @@ -102,7 +102,7 @@ func (tr *TestRun) Run(steps []Step, localSdkPath string, useGaia bool, gaiaTag tr.validateStringLiterals() tr.startDocker() tr.executeSteps(steps) - tr.teardownDocker() + // tr.teardownDocker() } type testRunWithSteps struct { @@ -180,6 +180,8 @@ func (tr *TestRun) runStep(step Step, verbose bool) { tr.updateLightClient(action, verbose) case assertChainIsHaltedAction: tr.assertChainIsHalted(action, verbose) + case detectConsumerEvidenceAction: + tr.detectConsumerEvidence(action, verbose) default: log.Fatalf("unknown action in testRun %s: %#v", tr.name, action) } diff --git a/tests/e2e/steps_consumer_misbehaviour.go b/tests/e2e/steps_consumer_misbehaviour.go index 6401b5f638..f798db0450 100644 --- a/tests/e2e/steps_consumer_misbehaviour.go +++ b/tests/e2e/steps_consumer_misbehaviour.go @@ -218,6 +218,27 @@ func stepsCauseConsumerMisbehaviour(consumerName string) []Step { action: startRelayerAction{}, state: State{}, }, + // detect the ics misbehaviour + // and jail alice on the provider + { + action: detectConsumerEvidenceAction{ + chain: chainID("consu"), + }, + state: State{ + chainID("provi"): ChainState{ + ValPowers: &map[validatorID]uint{ + validatorID("alice"): 0, + validatorID("bob"): 20, + }, + }, + chainID(consumerName): ChainState{ + ValPowers: &map[validatorID]uint{ + validatorID("alice"): 511, + validatorID("bob"): 20, + }, + }, + }, + }, { // update the fork consumer client to create a light client attack // which should trigger a ICS misbehaviour message @@ -237,7 +258,7 @@ func stepsCauseConsumerMisbehaviour(consumerName string) []Step { ClientsFrozenHeights: &map[string]clienttypes.Height{ "07-tendermint-0": { RevisionNumber: 0, - RevisionHeight: 0, + RevisionHeight: 1, }, }, }, diff --git a/tests/e2e/testnet-scripts/fork-consumer.sh b/tests/e2e/testnet-scripts/fork-consumer.sh index 0bf96fcb79..b1ad94b65c 100644 --- a/tests/e2e/testnet-scripts/fork-consumer.sh +++ b/tests/e2e/testnet-scripts/fork-consumer.sh @@ -63,7 +63,7 @@ rpc_addr = "http://$CONS_CHAIN_PREFIX.252:26658" rpc_timeout = "10s" store_prefix = "ibc" trusting_period = "2days" -websocket_addr = "ws://$CONS_CHAIN_PREFIX.252:26658/websocket" +websocket_addr = "event_source = { mode = 'push', url = 'ws://$CONS_CHAIN_PREFIX.252:26658/websocket' , batch_delay = '50ms' } [chains.gas_price] denom = "stake" @@ -85,7 +85,9 @@ rpc_addr = "http://$PROV_CHAIN_PREFIX.4:26658" rpc_timeout = "10s" store_prefix = "ibc" trusting_period = "2days" -websocket_addr = "ws://$PROV_CHAIN_PREFIX.4:26658/websocket" +websocket_addr = "event_source = { mode = 'push', url = 'ws://$PROV_CHAIN_PREFIX.4:26658/websocket' , batch_delay = '50ms' } + + [chains.gas_price] denom = "stake" From fe310f5ce20ba561752abb80b5eb9eed11c66d43 Mon Sep 17 00:00:00 2001 From: Simon Noetzlin Date: Thu, 7 Sep 2023 11:06:12 +0200 Subject: [PATCH 08/21] fix hermes config --- tests/e2e/testnet-scripts/fork-consumer.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/e2e/testnet-scripts/fork-consumer.sh b/tests/e2e/testnet-scripts/fork-consumer.sh index b1ad94b65c..7c12438b71 100644 --- a/tests/e2e/testnet-scripts/fork-consumer.sh +++ b/tests/e2e/testnet-scripts/fork-consumer.sh @@ -63,7 +63,7 @@ rpc_addr = "http://$CONS_CHAIN_PREFIX.252:26658" rpc_timeout = "10s" store_prefix = "ibc" trusting_period = "2days" -websocket_addr = "event_source = { mode = 'push', url = 'ws://$CONS_CHAIN_PREFIX.252:26658/websocket' , batch_delay = '50ms' } +event_source = { mode = 'push', url = 'ws://$CONS_CHAIN_PREFIX.252:26658/websocket' , batch_delay = '50ms' } [chains.gas_price] denom = "stake" @@ -85,7 +85,7 @@ rpc_addr = "http://$PROV_CHAIN_PREFIX.4:26658" rpc_timeout = "10s" store_prefix = "ibc" trusting_period = "2days" -websocket_addr = "event_source = { mode = 'push', url = 'ws://$PROV_CHAIN_PREFIX.4:26658/websocket' , batch_delay = '50ms' } +event_source = { mode = 'push', url = 'ws://$PROV_CHAIN_PREFIX.4:26658/websocket' , batch_delay = '50ms' } From f0d154e9b0d4f6e82ef0531a07d05ac2c4c855b3 Mon Sep 17 00:00:00 2001 From: Simon Noetzlin Date: Fri, 8 Sep 2023 09:47:47 +0200 Subject: [PATCH 09/21] fist successful run --- ajson.json | 45 ++++++++++++++++++++ tests/e2e/actions_consumer_misbehaviour.go | 6 +++ tests/e2e/state.go | 49 ++++++++++++++++++++++ tests/e2e/steps_consumer_misbehaviour.go | 25 +++++------ 4 files changed, 113 insertions(+), 12 deletions(-) create mode 100644 ajson.json diff --git a/ajson.json b/ajson.json new file mode 100644 index 0000000000..da926a02cb --- /dev/null +++ b/ajson.json @@ -0,0 +1,45 @@ +{ + "timestamp": "2023-09-08T06:42:19.746612Z", + "level": "INFO", + "fields": { + "message": "running Hermes v1.6.0+3894e8ec4" + }, + "threadId": "ThreadId(1)" +} +{ + "result": [ + { + "revision_height": 1, + "revision_number": 0 + }, + { + "revision_height": 8, + "revision_number": 0 + }, + { + "revision_height": 12, + "revision_number": 0 + }, + { + "revision_height": 17, + "revision_number": 0 + }, + { + "revision_height": 26, + "revision_number": 0 + }, + { + "revision_height": 35, + "revision_number": 0 + }, + { + "revision_height": 43, + "revision_number": 0 + }, + { + "revision_height": 277, + "revision_number": 0 + } + ], + "status": "success" +} \ No newline at end of file diff --git a/tests/e2e/actions_consumer_misbehaviour.go b/tests/e2e/actions_consumer_misbehaviour.go index 84eb93152c..1b5c3b8d6f 100644 --- a/tests/e2e/actions_consumer_misbehaviour.go +++ b/tests/e2e/actions_consumer_misbehaviour.go @@ -5,6 +5,7 @@ import ( "fmt" "log" "os/exec" + "strconv" "time" ) @@ -61,15 +62,19 @@ func (tr TestRun) forkConsumerChain(action forkConsumerChainAction, verbose bool } type updateLightClientAction struct { + chain chainID hostChain chainID relayerConfig string clientID string + hostClientID string } func (tr TestRun) updateLightClient( action updateLightClientAction, verbose bool, ) { + trustedHeight := tr.getTrustedHeight(action.hostChain, action.hostClientID, 2) + // hermes clear packets ibc0 transfer channel-13 //#nosec G204 -- Bypass linter warning for spawning subprocess with cmd arguments. cmd := exec.Command("docker", "exec", tr.containerConfig.instanceName, "hermes", @@ -78,6 +83,7 @@ func (tr TestRun) updateLightClient( "client", "--client", action.clientID, "--host-chain", string(action.hostChain), + "--trusted-height", strconv.Itoa(int(trustedHeight.RevisionHeight)), ) if verbose { log.Println("updateLightClientAction cmd:", cmd.String()) diff --git a/tests/e2e/state.go b/tests/e2e/state.go index 8d9ba9a81e..0cc6938a54 100644 --- a/tests/e2e/state.go +++ b/tests/e2e/state.go @@ -1,6 +1,7 @@ package main import ( + "bufio" "fmt" "log" "os/exec" @@ -776,3 +777,51 @@ func (tr TestRun) getClientFrozenHeight(chain chainID, clientID string) clientty return clienttypes.Height{RevisionHeight: uint64(revHeight), RevisionNumber: uint64(revNumber)} } + +// hermes --json --config ./root/.hermes/config.toml query client consensus --chain provi --client 07-tendermint-0 | tail -n 1 | jq '.result[2].revision_height') + +func (tr TestRun) getTrustedHeight( + chain chainID, + clientID string, + index int, +) clienttypes.Height { + + //#nosec G204 -- Bypass linter warning for spawning subprocess with cmd arguments. + configureNodeCmd := exec.Command("docker", "exec", tr.containerConfig.instanceName, "hermes", + "--json", "query", "client", "consensus", "--chain", string(chain), + `--client`, clientID, + ) + + cmdReader, err := configureNodeCmd.StdoutPipe() + if err != nil { + log.Fatal(err) + } + + configureNodeCmd.Stderr = configureNodeCmd.Stdout + + if err := configureNodeCmd.Start(); err != nil { + log.Fatal(err) + } + + scanner := bufio.NewScanner(cmdReader) + + var trustedHeight gjson.Result + for scanner.Scan() { + out := scanner.Text() + log.Println("trusted heights: " + out) + if len(gjson.Get(out, "result").Array()) > 0 { + trustedHeight = gjson.Get(out, "result").Array()[2] + } + } + + revHeight, err := strconv.Atoi(trustedHeight.Get("revision_height").String()) + if err != nil { + log.Fatal(err) + } + + revNumber, err := strconv.Atoi(trustedHeight.Get("revision_number").String()) + if err != nil { + log.Fatal(err) + } + return clienttypes.Height{RevisionHeight: uint64(revHeight), RevisionNumber: uint64(revNumber)} +} diff --git a/tests/e2e/steps_consumer_misbehaviour.go b/tests/e2e/steps_consumer_misbehaviour.go index f798db0450..0c099641c2 100644 --- a/tests/e2e/steps_consumer_misbehaviour.go +++ b/tests/e2e/steps_consumer_misbehaviour.go @@ -200,7 +200,6 @@ func stepsStartChainsWithSoftOptOut(consumerName string) []Step { // stepsCauseConsumerMisbehaviour causes a ICS misbehaviour by forking a consumer chain. func stepsCauseConsumerMisbehaviour(consumerName string) []Step { - consumerClientID := "07-tendermint-0" forkRelayerConfig := "/root/.hermes/config_fork.toml" return []Step{ { @@ -227,7 +226,7 @@ func stepsCauseConsumerMisbehaviour(consumerName string) []Step { state: State{ chainID("provi"): ChainState{ ValPowers: &map[validatorID]uint{ - validatorID("alice"): 0, + validatorID("alice"): 511, validatorID("bob"): 20, }, }, @@ -243,9 +242,11 @@ func stepsCauseConsumerMisbehaviour(consumerName string) []Step { // update the fork consumer client to create a light client attack // which should trigger a ICS misbehaviour message action: updateLightClientAction{ + chain: chainID("consu"), + clientID: "07-tendermint-0", hostChain: chainID("provi"), relayerConfig: forkRelayerConfig, // this relayer config uses the "forked" consumer - clientID: consumerClientID, + hostClientID: "07-tendermint-0", // TODO: get client ID by querying consumer genesis }, state: State{ chainID("provi"): ChainState{ @@ -254,7 +255,7 @@ func stepsCauseConsumerMisbehaviour(consumerName string) []Step { validatorID("alice"): 0, validatorID("bob"): 20, }, - // The consumer light client should not be frozen + // The consumer light client should be frozen on the provider ClientsFrozenHeights: &map[string]clienttypes.Height{ "07-tendermint-0": { RevisionNumber: 0, @@ -262,15 +263,15 @@ func stepsCauseConsumerMisbehaviour(consumerName string) []Step { }, }, }, + chainID("consu"): ChainState{ + // consumer should not have learn the jailing of alice + // since its light client is frozen on the provider + ValPowers: &map[validatorID]uint{ + validatorID("alice"): 511, + validatorID("bob"): 20, + }, + }, }, }, - // we expect the consumer chain to be halted since the last VSC packet should - // have updated the alice validator power to 0. - { - action: assertChainIsHaltedAction{ - chain: chainID("consu"), - }, - state: State{}, - }, } } From 612427a89fb2602493acb208dbf049c4db5094ba Mon Sep 17 00:00:00 2001 From: Simon Noetzlin Date: Fri, 8 Sep 2023 09:54:53 +0200 Subject: [PATCH 10/21] nit --- ajson.json | 45 ---------------------- tests/e2e/actions_consumer_misbehaviour.go | 3 +- tests/e2e/steps_consumer_misbehaviour.go | 3 +- 3 files changed, 2 insertions(+), 49 deletions(-) delete mode 100644 ajson.json diff --git a/ajson.json b/ajson.json deleted file mode 100644 index da926a02cb..0000000000 --- a/ajson.json +++ /dev/null @@ -1,45 +0,0 @@ -{ - "timestamp": "2023-09-08T06:42:19.746612Z", - "level": "INFO", - "fields": { - "message": "running Hermes v1.6.0+3894e8ec4" - }, - "threadId": "ThreadId(1)" -} -{ - "result": [ - { - "revision_height": 1, - "revision_number": 0 - }, - { - "revision_height": 8, - "revision_number": 0 - }, - { - "revision_height": 12, - "revision_number": 0 - }, - { - "revision_height": 17, - "revision_number": 0 - }, - { - "revision_height": 26, - "revision_number": 0 - }, - { - "revision_height": 35, - "revision_number": 0 - }, - { - "revision_height": 43, - "revision_number": 0 - }, - { - "revision_height": 277, - "revision_number": 0 - } - ], - "status": "success" -} \ No newline at end of file diff --git a/tests/e2e/actions_consumer_misbehaviour.go b/tests/e2e/actions_consumer_misbehaviour.go index 1b5c3b8d6f..de806181b3 100644 --- a/tests/e2e/actions_consumer_misbehaviour.go +++ b/tests/e2e/actions_consumer_misbehaviour.go @@ -66,14 +66,13 @@ type updateLightClientAction struct { hostChain chainID relayerConfig string clientID string - hostClientID string } func (tr TestRun) updateLightClient( action updateLightClientAction, verbose bool, ) { - trustedHeight := tr.getTrustedHeight(action.hostChain, action.hostClientID, 2) + trustedHeight := tr.getTrustedHeight(action.hostChain, action.clientID, 2) // hermes clear packets ibc0 transfer channel-13 //#nosec G204 -- Bypass linter warning for spawning subprocess with cmd arguments. diff --git a/tests/e2e/steps_consumer_misbehaviour.go b/tests/e2e/steps_consumer_misbehaviour.go index 0c099641c2..665f45e76f 100644 --- a/tests/e2e/steps_consumer_misbehaviour.go +++ b/tests/e2e/steps_consumer_misbehaviour.go @@ -246,7 +246,6 @@ func stepsCauseConsumerMisbehaviour(consumerName string) []Step { clientID: "07-tendermint-0", hostChain: chainID("provi"), relayerConfig: forkRelayerConfig, // this relayer config uses the "forked" consumer - hostClientID: "07-tendermint-0", // TODO: get client ID by querying consumer genesis }, state: State{ chainID("provi"): ChainState{ @@ -264,7 +263,7 @@ func stepsCauseConsumerMisbehaviour(consumerName string) []Step { }, }, chainID("consu"): ChainState{ - // consumer should not have learn the jailing of alice + // consumer should not have learned the jailing of alice // since its light client is frozen on the provider ValPowers: &map[validatorID]uint{ validatorID("alice"): 511, From 64ae54ce068d03ffdac37701c2dc88095af7d3ee Mon Sep 17 00:00:00 2001 From: Simon Noetzlin Date: Fri, 8 Sep 2023 10:07:12 +0200 Subject: [PATCH 11/21] nits --- tests/e2e/actions.go | 4 ++-- tests/e2e/actions_consumer_misbehaviour.go | 2 +- tests/e2e/main.go | 10 +++++----- tests/e2e/state.go | 4 +--- tests/e2e/steps_consumer_misbehaviour.go | 7 ++++--- 5 files changed, 13 insertions(+), 14 deletions(-) diff --git a/tests/e2e/actions.go b/tests/e2e/actions.go index 9fe8b5d0d7..263b432ee4 100644 --- a/tests/e2e/actions.go +++ b/tests/e2e/actions.go @@ -1845,8 +1845,8 @@ func (tr TestRun) GetPathNameForGorelayer(chainA, chainB chainID) string { return pathName } -// Run an instance of the Hermes relayer in the "evidence" mode, -// which detects evidences committed on the consumer chain. +// Run an instance of the Hermes relayer "evidence" command, +// which detects evidences in the consumer chain blocks. // Each infraction detected is reported to the provider chain using // either a SubmitConsumerDoubleVoting or a SubmitConsumerMisbehaviour message. type detectConsumerEvidenceAction struct { diff --git a/tests/e2e/actions_consumer_misbehaviour.go b/tests/e2e/actions_consumer_misbehaviour.go index de806181b3..0da2f9e56f 100644 --- a/tests/e2e/actions_consumer_misbehaviour.go +++ b/tests/e2e/actions_consumer_misbehaviour.go @@ -72,9 +72,9 @@ func (tr TestRun) updateLightClient( action updateLightClientAction, verbose bool, ) { + // retrieve a trusted height of the consumer light client trustedHeight := tr.getTrustedHeight(action.hostChain, action.clientID, 2) - // hermes clear packets ibc0 transfer channel-13 //#nosec G204 -- Bypass linter warning for spawning subprocess with cmd arguments. cmd := exec.Command("docker", "exec", tr.containerConfig.instanceName, "hermes", "--config", action.relayerConfig, diff --git a/tests/e2e/main.go b/tests/e2e/main.go index fbae6b88d5..d3e79f5afe 100644 --- a/tests/e2e/main.go +++ b/tests/e2e/main.go @@ -57,11 +57,11 @@ func main() { } testRuns := []testRunWithSteps{ - // {ChangeoverTestRun(), changeoverSteps}, - // {DefaultTestRun(), happyPathSteps}, - // {DemocracyTestRun(true), democracySteps}, - // {DemocracyTestRun(false), rewardDenomConsumerSteps}, - // {SlashThrottleTestRun(), slashThrottleSteps}, + {ChangeoverTestRun(), changeoverSteps}, + {DefaultTestRun(), happyPathSteps}, + {DemocracyTestRun(true), democracySteps}, + {DemocracyTestRun(false), rewardDenomConsumerSteps}, + {SlashThrottleTestRun(), slashThrottleSteps}, {ConsumerMisbehaviourTestRun(), consumerMisbehaviourSteps}, } if includeMultiConsumer != nil && *includeMultiConsumer { diff --git a/tests/e2e/state.go b/tests/e2e/state.go index 0cc6938a54..ff3ab38150 100644 --- a/tests/e2e/state.go +++ b/tests/e2e/state.go @@ -778,8 +778,6 @@ func (tr TestRun) getClientFrozenHeight(chain chainID, clientID string) clientty return clienttypes.Height{RevisionHeight: uint64(revHeight), RevisionNumber: uint64(revNumber)} } -// hermes --json --config ./root/.hermes/config.toml query client consensus --chain provi --client 07-tendermint-0 | tail -n 1 | jq '.result[2].revision_height') - func (tr TestRun) getTrustedHeight( chain chainID, clientID string, @@ -810,7 +808,7 @@ func (tr TestRun) getTrustedHeight( out := scanner.Text() log.Println("trusted heights: " + out) if len(gjson.Get(out, "result").Array()) > 0 { - trustedHeight = gjson.Get(out, "result").Array()[2] + trustedHeight = gjson.Get(out, "result").Array()[index] } } diff --git a/tests/e2e/steps_consumer_misbehaviour.go b/tests/e2e/steps_consumer_misbehaviour.go index 665f45e76f..5b7615805c 100644 --- a/tests/e2e/steps_consumer_misbehaviour.go +++ b/tests/e2e/steps_consumer_misbehaviour.go @@ -200,6 +200,7 @@ func stepsStartChainsWithSoftOptOut(consumerName string) []Step { // stepsCauseConsumerMisbehaviour causes a ICS misbehaviour by forking a consumer chain. func stepsCauseConsumerMisbehaviour(consumerName string) []Step { + consumerClientID := "07-tendermint-0" forkRelayerConfig := "/root/.hermes/config_fork.toml" return []Step{ { @@ -243,20 +244,20 @@ func stepsCauseConsumerMisbehaviour(consumerName string) []Step { // which should trigger a ICS misbehaviour message action: updateLightClientAction{ chain: chainID("consu"), - clientID: "07-tendermint-0", + clientID: consumerClientID, hostChain: chainID("provi"), relayerConfig: forkRelayerConfig, // this relayer config uses the "forked" consumer }, state: State{ chainID("provi"): ChainState{ - // validator should be jailed on the provider + // alice should be jailed on the provider ValPowers: &map[validatorID]uint{ validatorID("alice"): 0, validatorID("bob"): 20, }, // The consumer light client should be frozen on the provider ClientsFrozenHeights: &map[string]clienttypes.Height{ - "07-tendermint-0": { + consumerClientID: { RevisionNumber: 0, RevisionHeight: 1, }, From 9d6f74699423556c5678947adb9052dea08ae2c6 Mon Sep 17 00:00:00 2001 From: Simon Noetzlin Date: Fri, 8 Sep 2023 10:43:12 +0200 Subject: [PATCH 12/21] nits --- Dockerfile | 2 +- tests/e2e/actions.go | 4 ++-- tests/e2e/main.go | 2 +- tests/e2e/state.go | 1 - tests/e2e/steps_consumer_misbehaviour.go | 4 ++-- 5 files changed, 6 insertions(+), 7 deletions(-) diff --git a/Dockerfile b/Dockerfile index ba351f2e78..03939617be 100644 --- a/Dockerfile +++ b/Dockerfile @@ -36,7 +36,7 @@ FROM informalofftermatt/cometmock:latest as cometmock-builder # Get GoRelayer FROM informalofftermatt/gorelayer:nogas AS gorelayer-builder -FROM --platform=linux/arm64 fedora:36 +FROM --platform=linux/amd64 fedora:36 RUN dnf update -y RUN dnf install -y which iproute iputils procps-ng vim-minimal tmux net-tools htop jq USER root diff --git a/tests/e2e/actions.go b/tests/e2e/actions.go index 263b432ee4..0c47b452e2 100644 --- a/tests/e2e/actions.go +++ b/tests/e2e/actions.go @@ -1845,8 +1845,8 @@ func (tr TestRun) GetPathNameForGorelayer(chainA, chainB chainID) string { return pathName } -// Run an instance of the Hermes relayer "evidence" command, -// which detects evidences in the consumer chain blocks. +// Run an instance of the Hermes relayer using the "evidence" command, +// which detects evidences committed to the blocks of a consumer chain. // Each infraction detected is reported to the provider chain using // either a SubmitConsumerDoubleVoting or a SubmitConsumerMisbehaviour message. type detectConsumerEvidenceAction struct { diff --git a/tests/e2e/main.go b/tests/e2e/main.go index d3e79f5afe..84a06eeab9 100644 --- a/tests/e2e/main.go +++ b/tests/e2e/main.go @@ -102,7 +102,7 @@ func (tr *TestRun) Run(steps []Step, localSdkPath string, useGaia bool, gaiaTag tr.validateStringLiterals() tr.startDocker() tr.executeSteps(steps) - // tr.teardownDocker() + tr.teardownDocker() } type testRunWithSteps struct { diff --git a/tests/e2e/state.go b/tests/e2e/state.go index ff3ab38150..1d6f2c04c3 100644 --- a/tests/e2e/state.go +++ b/tests/e2e/state.go @@ -806,7 +806,6 @@ func (tr TestRun) getTrustedHeight( var trustedHeight gjson.Result for scanner.Scan() { out := scanner.Text() - log.Println("trusted heights: " + out) if len(gjson.Get(out, "result").Array()) > 0 { trustedHeight = gjson.Get(out, "result").Array()[index] } diff --git a/tests/e2e/steps_consumer_misbehaviour.go b/tests/e2e/steps_consumer_misbehaviour.go index 5b7615805c..20b3e88686 100644 --- a/tests/e2e/steps_consumer_misbehaviour.go +++ b/tests/e2e/steps_consumer_misbehaviour.go @@ -213,12 +213,12 @@ func stepsCauseConsumerMisbehaviour(consumerName string) []Step { }, state: State{}, }, + // start relayer to detect IBC misbehaviour { - // start relayer to detect ICS misbehaviour action: startRelayerAction{}, state: State{}, }, - // detect the ics misbehaviour + // detect the ICS misbehaviour // and jail alice on the provider { action: detectConsumerEvidenceAction{ From 0c68fb049c27bd5a4f888c0891f661d1c002fa46 Mon Sep 17 00:00:00 2001 From: Simon Noetzlin Date: Fri, 8 Sep 2023 11:10:25 +0200 Subject: [PATCH 13/21] doc and nits --- tests/e2e/state.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tests/e2e/state.go b/tests/e2e/state.go index 1d6f2c04c3..04eb7c229f 100644 --- a/tests/e2e/state.go +++ b/tests/e2e/state.go @@ -804,10 +804,13 @@ func (tr TestRun) getTrustedHeight( scanner := bufio.NewScanner(cmdReader) var trustedHeight gjson.Result + // iterate on the relayer's response + // and parse the the command "result" for scanner.Scan() { out := scanner.Text() if len(gjson.Get(out, "result").Array()) > 0 { trustedHeight = gjson.Get(out, "result").Array()[index] + break } } From a3c4d362ded80c0aa545f7e2852d45f2f4fcc907 Mon Sep 17 00:00:00 2001 From: Simon Noetzlin Date: Fri, 8 Sep 2023 11:15:04 +0200 Subject: [PATCH 14/21] lint --- tests/e2e/state.go | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/e2e/state.go b/tests/e2e/state.go index 04eb7c229f..d0d908a494 100644 --- a/tests/e2e/state.go +++ b/tests/e2e/state.go @@ -783,7 +783,6 @@ func (tr TestRun) getTrustedHeight( clientID string, index int, ) clienttypes.Height { - //#nosec G204 -- Bypass linter warning for spawning subprocess with cmd arguments. configureNodeCmd := exec.Command("docker", "exec", tr.containerConfig.instanceName, "hermes", "--json", "query", "client", "consensus", "--chain", string(chain), From d9af492e2b21f2a7f493459b3ee12126ce852e6a Mon Sep 17 00:00:00 2001 From: Simon Noetzlin Date: Fri, 8 Sep 2023 11:29:13 +0200 Subject: [PATCH 15/21] refactor --- tests/e2e/actions.go | 22 ---------------------- tests/e2e/steps_double_sign.go | 2 +- 2 files changed, 1 insertion(+), 23 deletions(-) diff --git a/tests/e2e/actions.go b/tests/e2e/actions.go index cacb163021..0c47b452e2 100644 --- a/tests/e2e/actions.go +++ b/tests/e2e/actions.go @@ -1682,28 +1682,6 @@ func (tr TestRun) invokeDoublesignSlash( tr.waitBlocks("provi", 10, 2*time.Minute) } -// Run an instance of the Hermes relayer in the "evidence" mode, -// which detects the double signing evidences on the consumer chain. -// Each infraction detected is reported to the provider chain using -// a SubmitConsumerDoubleVoting message. -type detectDoubleSigningEvidenceAction struct { - chain chainID -} - -func (tr TestRun) detectDoubleSigningEvidence( - action detectDoubleSigningEvidenceAction, - verbose bool, -) { - chainConfig := tr.chainConfigs[action.chain] - //#nosec G204 -- Bypass linter warning for spawning subprocess with cmd arguments. - bz, err := exec.Command("docker", "exec", "-d", tr.containerConfig.instanceName, - "hermes", "evidence", "--chain", string(chainConfig.chainId)).CombinedOutput() - if err != nil { - log.Fatal(err, "\n", string(bz)) - } - tr.waitBlocks("provi", 10, 2*time.Minute) -} - type assignConsumerPubKeyAction struct { chain chainID validator validatorID diff --git a/tests/e2e/steps_double_sign.go b/tests/e2e/steps_double_sign.go index 81c17db2b1..a5485d51f8 100644 --- a/tests/e2e/steps_double_sign.go +++ b/tests/e2e/steps_double_sign.go @@ -157,7 +157,7 @@ func stepsCauseDoubleSignOnConsumer(consumerName string) []Step { // detect the double voting infraction // and jail bob on the provider { - action: detectDoubleSigningEvidenceAction{ + action: detectConsumerEvidenceAction{ chain: chainID("consu"), }, state: State{ From e01aebba73e1c300a8696b0957ed410fdcdb3bd1 Mon Sep 17 00:00:00 2001 From: Simon Noetzlin Date: Fri, 8 Sep 2023 11:34:36 +0200 Subject: [PATCH 16/21] typo --- tests/integration/double_vote.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/integration/double_vote.go b/tests/integration/double_vote.go index a0f0195932..414548ec57 100644 --- a/tests/integration/double_vote.go +++ b/tests/integration/double_vote.go @@ -166,7 +166,7 @@ func (s *CCVTestSuite) TestHandleConsumerDoubleVoting() { // reset context for each run provCtx := s.providerCtx() - // if the evidence was built using the validator provider address andkey, + // if the evidence was built using the validator provider address and key, // we remove the consumer key assigned to the validator otherwise // HandleConsumerDoubleVoting uses the consumer key to verify the signature if tc.ev.VoteA.ValidatorAddress.String() != consuVal.Address.String() { From 3333ac09424cd42afb93bf38f09beed3e9597daf Mon Sep 17 00:00:00 2001 From: Simon Noetzlin Date: Fri, 8 Sep 2023 16:28:28 +0200 Subject: [PATCH 17/21] change hermes docker image --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index aa47792968..03939617be 100644 --- a/Dockerfile +++ b/Dockerfile @@ -28,7 +28,7 @@ RUN go mod tidy RUN make install # Get Hermes build -FROM otacrew/hermes-ics:double-voting AS hermes-builder +FROM otacrew/hermes-ics:latest AS hermes-builder # Get CometMock FROM informalofftermatt/cometmock:latest as cometmock-builder From 546d11941ac091a9892c807d8c98f51aa61114e0 Mon Sep 17 00:00:00 2001 From: Simon Noetzlin Date: Fri, 8 Sep 2023 16:41:04 +0200 Subject: [PATCH 18/21] nits --- tests/e2e/steps.go | 4 ++-- tests/e2e/steps_double_sign.go | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/e2e/steps.go b/tests/e2e/steps.go index 8a9f4ccdea..f91b8d6b0d 100644 --- a/tests/e2e/steps.go +++ b/tests/e2e/steps.go @@ -91,7 +91,7 @@ var changeoverSteps = concatSteps( var consumerMisbehaviourSteps = concatSteps( // start provider and consumer chain stepsStartChainsWithSoftOptOut("consu"), - // make consumer validator to misbehave and get jail + // make a consumer validator to misbehave and get jailed stepsCauseConsumerMisbehaviour("consu"), ) @@ -99,6 +99,6 @@ var consumerDoubleSignSteps = concatSteps( // start provider and consumer chain stepsStartChains([]string{"consu"}, false), - // make consumer validator to double sign and get jail + // make a consumer validator to double sign and get jailed stepsCauseDoubleSignOnConsumer("consu"), ) diff --git a/tests/e2e/steps_double_sign.go b/tests/e2e/steps_double_sign.go index a5485d51f8..a493869464 100644 --- a/tests/e2e/steps_double_sign.go +++ b/tests/e2e/steps_double_sign.go @@ -177,7 +177,7 @@ func stepsCauseDoubleSignOnConsumer(consumerName string) []Step { }, }, }, - // consumer learn about the jailing + // consumer learns about the jailing { action: relayPacketsAction{ chainA: chainID("provi"), From d4ca6959716f3b60dac896f435ec3e50a461702f Mon Sep 17 00:00:00 2001 From: Simon Noetzlin Date: Mon, 11 Sep 2023 13:46:44 +0200 Subject: [PATCH 19/21] Update tests/e2e/steps.go Co-authored-by: Philip Offtermatt <57488781+p-offtermatt@users.noreply.github.com> --- tests/e2e/steps.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/e2e/steps.go b/tests/e2e/steps.go index f91b8d6b0d..ab8e0d2282 100644 --- a/tests/e2e/steps.go +++ b/tests/e2e/steps.go @@ -99,6 +99,6 @@ var consumerDoubleSignSteps = concatSteps( // start provider and consumer chain stepsStartChains([]string{"consu"}, false), - // make a consumer validator to double sign and get jailed + // make a consumer validator double sign and get jailed stepsCauseDoubleSignOnConsumer("consu"), ) From 0b790649a7ea28ea831e85bdb3cc57344517ea37 Mon Sep 17 00:00:00 2001 From: Simon Noetzlin Date: Mon, 11 Sep 2023 13:51:58 +0200 Subject: [PATCH 20/21] address PR comments --- tests/e2e/steps.go | 2 +- tests/e2e/steps_double_sign.go | 14 +++++++------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/tests/e2e/steps.go b/tests/e2e/steps.go index ab8e0d2282..fb506eff5f 100644 --- a/tests/e2e/steps.go +++ b/tests/e2e/steps.go @@ -100,5 +100,5 @@ var consumerDoubleSignSteps = concatSteps( stepsStartChains([]string{"consu"}, false), // make a consumer validator double sign and get jailed - stepsCauseDoubleSignOnConsumer("consu"), + stepsCauseDoubleSignOnConsumer("consu", "provi"), ) diff --git a/tests/e2e/steps_double_sign.go b/tests/e2e/steps_double_sign.go index a493869464..dcce236b46 100644 --- a/tests/e2e/steps_double_sign.go +++ b/tests/e2e/steps_double_sign.go @@ -130,15 +130,15 @@ func stepsDoubleSignOnProviderAndConsumer(consumerName string) []Step { } // Steps that make bob double sign on the consumer -func stepsCauseDoubleSignOnConsumer(consumerName string) []Step { +func stepsCauseDoubleSignOnConsumer(consumerName, providerName string) []Step { return []Step{ { action: doublesignSlashAction{ - chain: chainID("consu"), + chain: chainID(consumerName), validator: validatorID("bob"), }, state: State{ - chainID("provi"): ChainState{ + chainID(providerName): ChainState{ ValPowers: &map[validatorID]uint{ validatorID("alice"): 500, validatorID("bob"): 500, @@ -158,10 +158,10 @@ func stepsCauseDoubleSignOnConsumer(consumerName string) []Step { // and jail bob on the provider { action: detectConsumerEvidenceAction{ - chain: chainID("consu"), + chain: chainID(consumerName), }, state: State{ - chainID("provi"): ChainState{ + chainID(providerName): ChainState{ ValPowers: &map[validatorID]uint{ validatorID("alice"): 500, validatorID("bob"): 0, @@ -180,13 +180,13 @@ func stepsCauseDoubleSignOnConsumer(consumerName string) []Step { // consumer learns about the jailing { action: relayPacketsAction{ - chainA: chainID("provi"), + chainA: chainID(providerName), chainB: chainID(consumerName), port: "provider", channel: 0, }, state: State{ - chainID("provi"): ChainState{ + chainID(providerName): ChainState{ ValPowers: &map[validatorID]uint{ validatorID("alice"): 500, validatorID("bob"): 0, From 8d9eeaef2b6ec83b062eaaac23231fbc25296d98 Mon Sep 17 00:00:00 2001 From: Simon Noetzlin Date: Mon, 11 Sep 2023 15:56:31 +0200 Subject: [PATCH 21/21] nits --- tests/integration/double_vote.go | 2 -- 1 file changed, 2 deletions(-) diff --git a/tests/integration/double_vote.go b/tests/integration/double_vote.go index 414548ec57..c79b92115e 100644 --- a/tests/integration/double_vote.go +++ b/tests/integration/double_vote.go @@ -76,8 +76,6 @@ func (s *CCVTestSuite) TestHandleConsumerDoubleVoting() { s.consumerChain.ChainID, ) - provSigner.GetPubKey() - testCases := []struct { name string ev *tmtypes.DuplicateVoteEvidence