From 07be71aa678a0ad204c62a6eb6033a526c0bef27 Mon Sep 17 00:00:00 2001 From: Philip Offtermatt <57488781+p-offtermatt@users.noreply.github.com> Date: Wed, 14 Jun 2023 10:51:38 +0200 Subject: [PATCH] feat: integrate cometmock (#989) * Add gorelayer and CometMock to Dockerfile * Add option to start with cometmock in start-chain script * Start adding support for rly * Adjust relayer start action * Add entrypoint for short happy path steps * Add . nosec G204 and waiting for blocks * Adjust rly config: Gas is free * Remove optout steps from short happy path * Use separate redelegate step for short happy path * Wait for blocks after unbonding * Make naming more descriptive and add comments * Add comment to chain name sorting and improve comments * Update start-chain.sh Address comments form joint review session with @MSalopek * Fix typo --- Dockerfile | 8 + tests/e2e/actions.go | 286 +++++++++++++++++- tests/e2e/config.go | 10 + tests/e2e/main.go | 24 +- tests/e2e/state.go | 5 + tests/e2e/step_delegation.go | 65 +++- tests/e2e/steps.go | 12 +- tests/e2e/steps_democracy.go | 9 +- tests/e2e/steps_double_sign.go | 9 +- tests/e2e/steps_downtime.go | 24 +- tests/e2e/steps_multi_consumer_delegation.go | 18 +- tests/e2e/steps_multi_consumer_double_sign.go | 15 +- tests/e2e/steps_multi_consumer_downtime.go | 27 +- tests/e2e/steps_reward_denom.go | 9 +- tests/e2e/steps_start_chains.go | 3 +- tests/e2e/steps_stop_chain.go | 6 +- .../e2e/steps_submit_equivocation_proposal.go | 3 +- tests/e2e/testnet-scripts/start-chain.sh | 65 +++- 18 files changed, 534 insertions(+), 64 deletions(-) diff --git a/Dockerfile b/Dockerfile index 0da9141620..ac528fa8fb 100644 --- a/Dockerfile +++ b/Dockerfile @@ -30,12 +30,20 @@ RUN make install # Get Hermes build FROM ghcr.io/informalsystems/hermes:1.4.1 AS hermes-builder +# Get CometMock +FROM informalofftermatt/cometmock:latest as cometmock-builder + +# Get GoRelayer +FROM informalofftermatt/gorelayer:nogas AS gorelayer-builder + 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 COPY --from=hermes-builder /usr/bin/hermes /usr/local/bin/ +COPY --from=cometmock-builder /usr/local/bin/cometmock /usr/local/bin/cometmock +COPY --from=gorelayer-builder /bin/rly /usr/local/bin/ COPY --from=is-builder /go/bin/interchain-security-pd /usr/local/bin/interchain-security-pd COPY --from=is-builder /go/bin/interchain-security-cd /usr/local/bin/interchain-security-cd diff --git a/tests/e2e/actions.go b/tests/e2e/actions.go index 4a4c471f79..b1e6863b7a 100644 --- a/tests/e2e/actions.go +++ b/tests/e2e/actions.go @@ -122,6 +122,13 @@ func (tr TestRun) startChain( genesisChanges = chainConfig.genesisChanges } + var cometmockArg string + if tr.useCometmock { + cometmockArg = "true" + } else { + cometmockArg = "false" + } + //#nosec G204 -- Bypass linter warning for spawning subprocess with cmd arguments. cmd := exec.Command("docker", "exec", tr.containerConfig.instanceName, "/bin/bash", "/testnet-scripts/start-chain.sh", chainConfig.binaryName, string(vals), @@ -132,6 +139,7 @@ func (tr TestRun) startChain( // lower timeout_commit means the blocks are produced faster making the test run shorter // with short timeout_commit (eg. timeout_commit = 1s) some nodes may miss blocks causing the test run to fail tr.tendermintConfigOverride, + cometmockArg, ) cmdReader, err := cmd.StdoutPipe() @@ -587,9 +595,80 @@ websocket_addr = "%s" numerator = "1" ` +// Set up the config for a new chain for gorelayer. +// This config is added to the container as a file. +// We then add the chain to the relayer, using this config as the chain config with `rly chains add --file` +// This is functionally similar to the config used by Hermes for chains, e.g. gas is free. +const gorelayerChainConfigTemplate = ` +{ + "type": "cosmos", + "value": { + "key": "default", + "chain-id": "%s", + "rpc-addr": "%s", + "account-prefix": "cosmos", + "keyring-backend": "test", + "gas-adjustment": 1.2, + "gas-prices": "0.00stake", + "debug": true, + "timeout": "20s", + "output-format": "json", + "sign-mode": "direct" + } +}` + func (tr TestRun) addChainToRelayer( action addChainToRelayerAction, verbose bool, +) { + if !tr.useGorelayer { + tr.addChainToHermes(action, verbose) + } else { + tr.addChainToGorelayer(action, verbose) + } +} + +func (tr TestRun) addChainToGorelayer( + action addChainToRelayerAction, + verbose bool, +) { + queryNodeIP := tr.getQueryNodeIP(action.chain) + chainId := tr.chainConfigs[action.chain].chainId + rpcAddr := "http://" + queryNodeIP + ":26658" + + chainConfig := fmt.Sprintf(gorelayerChainConfigTemplate, + chainId, + rpcAddr, + ) + + //#nosec G204 -- Bypass linter warning for spawning subprocess with cmd arguments. + bz, err := exec.Command("docker", "exec", tr.containerConfig.instanceName, "rly", "config", "init").CombinedOutput() + if err != nil && !strings.Contains(string(bz), "config already exists") { + log.Fatal(err, "\n", string(bz)) + } + + chainConfigFileName := fmt.Sprintf("/root/%s_config.json", chainId) + + bashCommand := fmt.Sprintf(`echo '%s' >> %s`, chainConfig, chainConfigFileName) + //#nosec G204 -- Bypass linter warning for spawning subprocess with cmd arguments. + bz, err = exec.Command("docker", "exec", tr.containerConfig.instanceName, "bash", "-c", + bashCommand).CombinedOutput() + if err != nil { + log.Fatal(err, "\n", string(bz)) + } + + //#nosec G204 -- Bypass linter warning for spawning subprocess with cmd arguments. + addChainCommand := exec.Command("docker", "exec", tr.containerConfig.instanceName, "rly", "chains", "add", "--file", chainConfigFileName, string(chainId)) + executeCommand(addChainCommand, "add chain") + + //#nosec G204 -- Bypass linter warning for spawning subprocess with cmd arguments. + keyRestoreCommand := exec.Command("docker", "exec", tr.containerConfig.instanceName, "rly", "keys", "restore", string(chainId), "default", tr.validatorConfigs[action.validator].mnemonic) + executeCommand(keyRestoreCommand, "restore keys") +} + +func (tr TestRun) addChainToHermes( + action addChainToRelayerAction, + verbose bool, ) { queryNodeIP := tr.getQueryNodeIP(action.chain) chainId := tr.chainConfigs[action.chain].chainId @@ -638,6 +717,26 @@ func (tr TestRun) addChainToRelayer( } } +// This config file is used by gorelayer to create a path between chains. +// Since the tests assume we use a certain client-id for certain paths, +// in the config we specify the client id, e.g. 07-tendermint-5. +// The src-channel-filter is empty because we want to relay all channels. +const gorelayerPathConfigTemplate = `{ + "src": { + "chain-id": "%s", + "client-id": "07-tendermint-%v" + }, + "dst": { + "chain-id": "%s", + "client-id": "07-tendermint-%v" + }, + "src-channel-filter": { + "rule": "", + "channel-list": [] + } +} +` + type addIbcConnectionAction struct { chainA chainID chainB chainID @@ -648,6 +747,67 @@ type addIbcConnectionAction struct { func (tr TestRun) addIbcConnection( action addIbcConnectionAction, verbose bool, +) { + if !tr.useGorelayer { + tr.addIbcConnectionHermes(action, verbose) + } else { + tr.addIbcConnectionGorelayer(action, verbose) + } +} + +func (tr TestRun) addIbcConnectionGorelayer( + action addIbcConnectionAction, + verbose bool, +) { + pathName := tr.GetPathNameForGorelayer(action.chainA, action.chainB) + + pathConfig := fmt.Sprintf(gorelayerPathConfigTemplate, action.chainA, action.clientA, action.chainB, action.clientB) + + pathConfigFileName := fmt.Sprintf("/root/%s_config.json", pathName) + + bashCommand := fmt.Sprintf(`echo '%s' >> %s`, pathConfig, pathConfigFileName) + //#nosec G204 -- Bypass linter warning for spawning subprocess with cmd arguments. + pathConfigCommand := exec.Command("docker", "exec", tr.containerConfig.instanceName, "bash", "-c", + bashCommand) + executeCommand(pathConfigCommand, "add path config") + + //#nosec G204 -- Bypass linter warning for spawning subprocess with cmd arguments. + newPathCommand := exec.Command("docker", "exec", tr.containerConfig.instanceName, "rly", + "paths", "add", + string(tr.chainConfigs[action.chainA].chainId), + string(tr.chainConfigs[action.chainB].chainId), + pathName, + "--file", pathConfigFileName, + ) + + executeCommand(newPathCommand, "new path") + + //#nosec G204 -- Bypass linter warning for spawning subprocess with cmd arguments. + newClientsCommand := exec.Command("docker", "exec", tr.containerConfig.instanceName, "rly", + "transact", "clients", + pathName, + ) + + executeCommand(newClientsCommand, "new clients") + + tr.waitBlocks(action.chainA, 1, 10*time.Second) + tr.waitBlocks(action.chainB, 1, 10*time.Second) + + //#nosec G204 -- Bypass linter warning for spawning subprocess with cmd arguments. + newConnectionCommand := exec.Command("docker", "exec", tr.containerConfig.instanceName, "rly", + "transact", "connection", + pathName, + ) + + executeCommand(newConnectionCommand, "new connection") + + tr.waitBlocks(action.chainA, 1, 10*time.Second) + tr.waitBlocks(action.chainB, 1, 10*time.Second) +} + +func (tr TestRun) addIbcConnectionHermes( + action addIbcConnectionAction, + verbose bool, ) { //#nosec G204 -- Bypass linter warning for spawning subprocess with cmd arguments. cmd := exec.Command("docker", "exec", tr.containerConfig.instanceName, "hermes", @@ -692,10 +852,40 @@ type addIbcChannelAction struct { order string } -type startHermesAction struct{} +type startRelayerAction struct{} + +func (tr TestRun) startRelayer( + action startRelayerAction, + verbose bool, +) { + if tr.useGorelayer { + tr.startGorelayer(action, verbose) + } else { + tr.startHermes(action, verbose) + } +} + +func (tr TestRun) startGorelayer( + action startRelayerAction, + verbose bool, +) { + // gorelayer start is running in detached mode + //#nosec G204 -- Bypass linter warning for spawning subprocess with cmd arguments. + cmd := exec.Command("docker", "exec", "-d", tr.containerConfig.instanceName, "rly", + "start", + ) + + if err := cmd.Start(); err != nil { + log.Fatal(err) + } + + if verbose { + fmt.Println("started gorelayer") + } +} func (tr TestRun) startHermes( - action startHermesAction, + action startRelayerAction, verbose bool, ) { // hermes start is running in detached mode @@ -716,6 +906,35 @@ func (tr TestRun) startHermes( func (tr TestRun) addIbcChannel( action addIbcChannelAction, verbose bool, +) { + if tr.useGorelayer { + tr.addIbcChannelGorelayer(action, verbose) + } else { + tr.addIbcChannelHermes(action, verbose) + } +} + +func (tr TestRun) addIbcChannelGorelayer( + action addIbcChannelAction, + verbose bool, +) { + pathName := tr.GetPathNameForGorelayer(action.chainA, action.chainB) + //#nosec G204 -- Bypass linter warning for spawning subprocess with cmd arguments. + cmd := exec.Command("docker", "exec", tr.containerConfig.instanceName, "rly", + "transact", "channel", + pathName, + "--src-port", action.portA, + "--dst-port", action.portB, + "--version", tr.containerConfig.ccvVersion, + "--order", action.order, + "--debug", + ) + executeCommand(cmd, "addChannel") +} + +func (tr TestRun) addIbcChannelHermes( + action addIbcChannelAction, + verbose bool, ) { //#nosec G204 -- Bypass linter warning for spawning subprocess with cmd arguments. cmd := exec.Command("docker", "exec", tr.containerConfig.instanceName, "hermes", @@ -773,6 +992,10 @@ func (tr TestRun) transferChannelComplete( action transferChannelCompleteAction, verbose bool, ) { + if tr.useGorelayer { + log.Fatal("transferChannelComplete is not implemented for rly") + } + //#nosec G204 -- Bypass linter warning for spawning subprocess with chanOpenTryCmd arguments. chanOpenTryCmd := exec.Command("docker", "exec", tr.containerConfig.instanceName, "hermes", "tx", "chan-open-try", @@ -841,7 +1064,8 @@ func executeCommand(cmd *exec.Cmd, cmdName string) { } type relayPacketsAction struct { - chain chainID + chainA chainID + chainB chainID port string channel uint } @@ -849,11 +1073,43 @@ type relayPacketsAction struct { func (tr TestRun) relayPackets( action relayPacketsAction, verbose bool, +) { + if tr.useGorelayer { + tr.relayPacketsGorelayer(action, verbose) + } else { + tr.relayPacketsHermes(action, verbose) + } +} + +func (tr TestRun) relayPacketsGorelayer( + action relayPacketsAction, + verbose bool, +) { + pathName := tr.GetPathNameForGorelayer(action.chainA, action.chainB) + + // rly transact relay-packets [path-name] --channel [channel-id] + //#nosec G204 -- Bypass linter warning for spawning subprocess with cmd arguments. + cmd := exec.Command("docker", "exec", tr.containerConfig.instanceName, "rly", "transact", "flush", + pathName, + "channel-"+fmt.Sprint(action.channel), + ) + if verbose { + log.Println("relayPackets cmd:", cmd.String()) + } + bz, err := cmd.CombinedOutput() + if err != nil { + log.Fatal(err, "\n", string(bz)) + } +} + +func (tr TestRun) relayPacketsHermes( + action relayPacketsAction, + verbose bool, ) { // 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", "clear", "packets", - "--chain", string(tr.chainConfigs[action.chain].chainId), + "--chain", string(tr.chainConfigs[action.chainA].chainId), "--port", action.port, "--channel", "channel-"+fmt.Sprint(action.channel), ) @@ -866,7 +1122,7 @@ func (tr TestRun) relayPackets( log.Fatal(err, "\n", string(bz)) } - tr.waitBlocks(action.chain, 1, 30*time.Second) + tr.waitBlocks(action.chainA, 1, 30*time.Second) } type relayRewardPacketsToProviderAction struct { @@ -886,7 +1142,7 @@ func (tr TestRun) relayRewardPacketsToProvider( tr.waitBlocks(action.consumerChain, uint(blockPerDistribution-currentBlock+1), 60*time.Second) } - tr.relayPackets(relayPacketsAction{chain: action.consumerChain, port: action.port, channel: action.channel}, verbose) + tr.relayPackets(relayPacketsAction{chainA: action.consumerChain, chainB: action.providerChain, port: action.port, channel: action.channel}, verbose) tr.waitBlocks(action.providerChain, 1, 10*time.Second) } @@ -929,6 +1185,8 @@ func (tr TestRun) delegateTokens( if err != nil { log.Fatal(err, "\n", string(bz)) } + + tr.waitBlocks(action.chain, 1, 10*time.Second) } type unbondTokensAction struct { @@ -971,6 +1229,8 @@ func (tr TestRun) unbondTokens( if err != nil { log.Fatal(err, "\n", string(bz)) } + + tr.waitBlocks(action.chain, 1, 10*time.Second) } type redelegateTokensAction struct { @@ -1370,3 +1630,17 @@ func (tr TestRun) waitForSlashThrottleDequeue( func uintPointer(i uint) *uint { return &i } + +// GetPathNameForGorelayer returns the name of the path between two given chains used by Gorelayer. +// Since paths are bidirectional, we need either chain to be able to be provided as first or second argument +// and still return the same name, so we sort the chain names alphabetically. +func (tr TestRun) GetPathNameForGorelayer(chainA, chainB chainID) string { + var pathName string + if string(chainA) < string(chainB) { + pathName = string(chainA) + "-" + string(chainB) + } else { + pathName = string(chainB) + "-" + string(chainA) + } + + return pathName +} diff --git a/tests/e2e/config.go b/tests/e2e/config.go index 6d7e36d637..cc755cb97a 100644 --- a/tests/e2e/config.go +++ b/tests/e2e/config.go @@ -70,6 +70,8 @@ type TestRun struct { tendermintConfigOverride string localSdkPath string useGaia bool + useCometmock bool // if false, nodes run CometBFT + useGorelayer bool // if false, Hermes is used as the relayer gaiaTag string name string @@ -339,6 +341,14 @@ func (s *TestRun) SetDockerConfig(localSdkPath string, useGaia bool, gaiaTag str s.localSdkPath = localSdkPath } +func (s *TestRun) SetCometMockConfig(useCometmock bool) { + s.useCometmock = useCometmock +} + +func (s *TestRun) SetRelayerConfig(useRly bool) { + s.useGorelayer = useRly +} + // validateStringLiterals enforces that configs follow the constraints // necessary to to execute the tests // diff --git a/tests/e2e/main.go b/tests/e2e/main.go index 8ef9d93b7a..141f8a8cd8 100644 --- a/tests/e2e/main.go +++ b/tests/e2e/main.go @@ -16,12 +16,19 @@ import ( ) var ( - verbose = flag.Bool("verbose", false, "turn verbose logging on/off") - happyPathOnly = flag.Bool("happy-path-only", false, "run happy path tests only") + verbose = flag.Bool("verbose", false, "turn verbose logging on/off") + happyPathOnly = flag.Bool("happy-path-only", false, "run happy path tests only") + shortHappyPathOnly = flag.Bool("short-happy-path", false, `run abridged happy path tests only. +This is like the happy path, but skips steps +that involve starting or stopping nodes for the same chain outside of the chain setup or teardown. +In particular, this skips steps related to downtime and double signing. +This is suited for CometMock+Gorelayer testing`) includeMultiConsumer = flag.Bool("include-multi-consumer", false, "include multiconsumer tests in run") parallel = flag.Bool("parallel", false, "run all tests in parallel") localSdkPath = flag.String("local-sdk-path", "", "path of a local sdk version to build and reference in integration tests") + useCometmock = flag.Bool("use-cometmock", false, "use cometmock instead of CometBFT") + useGorelayer = flag.Bool("use-gorelayer", false, "use go relayer instead of Hermes") ) var ( @@ -35,6 +42,13 @@ var ( func main() { flag.Parse() + if shortHappyPathOnly != nil && *shortHappyPathOnly { + fmt.Println("=============== running short happy path only ===============") + tr := DefaultTestRun() + tr.Run(shortHappyPathSteps, *localSdkPath, *useGaia, *gaiaTag) + return + } + if happyPathOnly != nil && *happyPathOnly { fmt.Println("=============== running happy path only ===============") tr := DefaultTestRun() @@ -80,6 +94,8 @@ func main() { // Docker containers are torn down after the test run is complete. func (tr *TestRun) Run(steps []Step, localSdkPath string, useGaia bool, gaiaTag string) { tr.SetDockerConfig(localSdkPath, useGaia, gaiaTag) + tr.SetCometMockConfig(*useCometmock) + tr.SetRelayerConfig(*useGorelayer) tr.validateStringLiterals() tr.startDocker() @@ -142,8 +158,8 @@ func (tr *TestRun) runStep(step Step, verbose bool) { tr.assignConsumerPubKey(action, verbose) case slashThrottleDequeue: tr.waitForSlashThrottleDequeue(action, verbose) - case startHermesAction: - tr.startHermes(action, verbose) + case startRelayerAction: + tr.startRelayer(action, verbose) case registerConsumerRewardDenomAction: tr.registerConsumerRewardDenom(action, verbose) default: diff --git a/tests/e2e/state.go b/tests/e2e/state.go index 98483ffb7e..9127c65df8 100644 --- a/tests/e2e/state.go +++ b/tests/e2e/state.go @@ -669,6 +669,11 @@ func (tr TestRun) getRegisteredConsumerRewardDenoms(chain chainID) []string { } func (tr TestRun) getValidatorNode(chain chainID, validator validatorID) string { + // for CometMock, validatorNodes are all the same address as the query node (which is CometMocks address) + if tr.useCometmock { + return tr.getQueryNode(chain) + } + return "tcp://" + tr.getValidatorIP(chain, validator) + ":26658" } diff --git a/tests/e2e/step_delegation.go b/tests/e2e/step_delegation.go index 8e9f090736..f33fc136d4 100644 --- a/tests/e2e/step_delegation.go +++ b/tests/e2e/step_delegation.go @@ -46,7 +46,8 @@ func stepsDelegate(consumerName string) []Step { }, { action: relayPacketsAction{ - chain: chainID("provi"), + chainA: chainID("provi"), + chainB: chainID(consumerName), port: "provider", channel: 0, }, @@ -110,7 +111,8 @@ func stepsUnbond(consumerName string) []Step { }, { action: relayPacketsAction{ - chain: chainID("provi"), + chainA: chainID("provi"), + chainB: chainID(consumerName), port: "provider", channel: 0, }, @@ -160,7 +162,8 @@ func stepsRedelegateForOptOut(consumerName string) []Step { }, { action: relayPacketsAction{ - chain: chainID("provi"), + chainA: chainID("provi"), + chainB: chainID(consumerName), port: "provider", channel: 0, }, @@ -212,7 +215,61 @@ func stepsRedelegate(consumerName string) []Step { }, { action: relayPacketsAction{ - chain: chainID("provi"), + chainA: chainID("provi"), + chainB: chainID(consumerName), + port: "provider", + channel: 0, + }, + state: State{ + chainID(consumerName): ChainState{ + ValPowers: &map[validatorID]uint{ + // Now power changes are seen by consumer + validatorID("alice"): 509, + validatorID("bob"): 500, + validatorID("carol"): 501, + }, + }, + }, + }, + } +} + +// stepsRedelegate tests redelegation and resulting validator power changes. +func stepsRedelegateShort(consumerName string) []Step { + return []Step{ + { + action: redelegateTokensAction{ + chain: chainID("provi"), + src: validatorID("alice"), + dst: validatorID("carol"), + txSender: validatorID("alice"), + // Leave alice with majority stake so non-faulty validators maintain more than + // 2/3 voting power during downtime tests below, avoiding chain halt + amount: 1000000, + }, + state: State{ + chainID("provi"): ChainState{ + ValPowers: &map[validatorID]uint{ + validatorID("alice"): 509, + validatorID("bob"): 500, + // carol always uses a consumer assigned key + validatorID("carol"): 501, + }, + }, + chainID(consumerName): ChainState{ + ValPowers: &map[validatorID]uint{ + // Voting power changes not seen by consumer yet + validatorID("alice"): 510, + validatorID("bob"): 500, + validatorID("carol"): 500, + }, + }, + }, + }, + { + action: relayPacketsAction{ + chainA: chainID("provi"), + chainB: chainID(consumerName), port: "provider", channel: 0, }, diff --git a/tests/e2e/steps.go b/tests/e2e/steps.go index 234672546b..8c0b4b2661 100644 --- a/tests/e2e/steps.go +++ b/tests/e2e/steps.go @@ -25,11 +25,21 @@ var happyPathSteps = concatSteps( 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 - stepsStartHermes(), + stepsStartRelayer(), stepsConsumerRemovalPropNotPassing("consu", 3), // submit removal prop but vote no on it - chain should stay stepsStopChain("consu", 4), // stop chain ) +var shortHappyPathSteps = concatSteps( + stepsStartChains([]string{"consu"}, false), + stepsDelegate("consu"), + stepsUnbond("consu"), + stepsRedelegateShort("consu"), + stepsStartRelayer(), + stepsConsumerRemovalPropNotPassing("consu", 2), // submit removal prop but vote no on it - chain should stay + stepsStopChain("consu", 3), // stop chain +) + var slashThrottleSteps = concatSteps( stepsStartChains([]string{"consu"}, false), stepsDelegate("consu"), diff --git a/tests/e2e/steps_democracy.go b/tests/e2e/steps_democracy.go index 9f5915f71d..686fbf1c49 100644 --- a/tests/e2e/steps_democracy.go +++ b/tests/e2e/steps_democracy.go @@ -195,7 +195,8 @@ func stepsDemocracy(consumerName string) []Step { }, { action: relayPacketsAction{ - chain: chainID("provi"), + chainA: chainID("provi"), + chainB: chainID(consumerName), port: "provider", channel: 0, }, @@ -221,7 +222,8 @@ func stepsDemocracy(consumerName string) []Step { // and can now be relayed as packet to consumer { action: relayPacketsAction{ - chain: chainID("provi"), + chainA: chainID("provi"), + chainB: chainID(consumerName), port: "provider", channel: 0, }, @@ -260,7 +262,8 @@ func stepsDemocracy(consumerName string) []Step { }, { action: relayPacketsAction{ - chain: chainID("provi"), + chainA: chainID("provi"), + chainB: chainID(consumerName), port: "provider", channel: 0, }, diff --git a/tests/e2e/steps_double_sign.go b/tests/e2e/steps_double_sign.go index e4efca4bb5..c007fa5c1c 100644 --- a/tests/e2e/steps_double_sign.go +++ b/tests/e2e/steps_double_sign.go @@ -30,7 +30,8 @@ func stepsDoubleSignOnProviderAndConsumer(consumerName string) []Step { { // relay power change to consumerName action: relayPacketsAction{ - chain: chainID("provi"), + chainA: chainID("provi"), + chainB: chainID(consumerName), port: "provider", channel: 0, // consumerName channel }, @@ -78,7 +79,8 @@ func stepsDoubleSignOnProviderAndConsumer(consumerName string) []Step { }, { action: relayPacketsAction{ - chain: chainID("provi"), + chainA: chainID("provi"), + chainB: chainID(consumerName), port: "provider", channel: 0, }, @@ -102,7 +104,8 @@ func stepsDoubleSignOnProviderAndConsumer(consumerName string) []Step { { // consumer learns about the double sign action: relayPacketsAction{ - chain: chainID("provi"), + chainA: chainID("provi"), + chainB: chainID(consumerName), port: "provider", channel: 0, }, diff --git a/tests/e2e/steps_downtime.go b/tests/e2e/steps_downtime.go index af2d2f237e..74cb349000 100644 --- a/tests/e2e/steps_downtime.go +++ b/tests/e2e/steps_downtime.go @@ -39,7 +39,8 @@ func stepsDowntime(consumerName string) []Step { }, { action: relayPacketsAction{ - chain: chainID("provi"), + chainA: chainID("provi"), + chainB: chainID(consumerName), port: "provider", channel: 0, }, @@ -65,7 +66,8 @@ func stepsDowntime(consumerName string) []Step { // and can now be relayed as packet to consumer { action: relayPacketsAction{ - chain: chainID("provi"), + chainA: chainID("provi"), + chainB: chainID(consumerName), port: "provider", channel: 0, }, @@ -106,7 +108,8 @@ func stepsDowntime(consumerName string) []Step { }, { action: relayPacketsAction{ - chain: chainID("provi"), + chainA: chainID("provi"), + chainB: chainID(consumerName), port: "provider", channel: 0, }, @@ -150,7 +153,8 @@ func stepsDowntime(consumerName string) []Step { }, { action: relayPacketsAction{ - chain: chainID("provi"), + chainA: chainID("provi"), + chainB: chainID(consumerName), port: "provider", channel: 0, }, @@ -188,7 +192,8 @@ func stepsDowntime(consumerName string) []Step { }, { action: relayPacketsAction{ - chain: chainID("provi"), + chainA: chainID("provi"), + chainB: chainID(consumerName), port: "provider", channel: 0, }, @@ -236,7 +241,8 @@ func stepsDowntimeWithOptOut(consumerName string) []Step { }, { action: relayPacketsAction{ - chain: chainID("provi"), + chainA: chainID("provi"), + chainB: chainID(consumerName), port: "provider", channel: 0, }, @@ -314,7 +320,8 @@ func stepsThrottledDowntime(consumerName string) []Step { }, { action: relayPacketsAction{ - chain: chainID("provi"), + chainA: chainID("provi"), + chainB: chainID(consumerName), port: "provider", channel: 0, }, @@ -376,7 +383,8 @@ func stepsThrottledDowntime(consumerName string) []Step { // and can now be relayed as packet to consumer { action: relayPacketsAction{ - chain: chainID("provi"), + chainA: chainID("provi"), + chainB: chainID(consumerName), port: "provider", channel: 0, }, diff --git a/tests/e2e/steps_multi_consumer_delegation.go b/tests/e2e/steps_multi_consumer_delegation.go index 106307629d..45536c0679 100644 --- a/tests/e2e/steps_multi_consumer_delegation.go +++ b/tests/e2e/steps_multi_consumer_delegation.go @@ -38,7 +38,8 @@ func stepsMultiConsumerDelegate(consumer1, consumer2 string) []Step { { // relay changes to consumer1 action: relayPacketsAction{ - chain: chainID("provi"), + chainA: chainID("provi"), + chainB: chainID(consumer1), port: "provider", channel: 0, // consumer1 channel }, @@ -69,7 +70,8 @@ func stepsMultiConsumerDelegate(consumer1, consumer2 string) []Step { { // relay changes to consumer2 action: relayPacketsAction{ - chain: chainID("provi"), + chainA: chainID("provi"), + chainB: chainID(consumer2), port: "provider", channel: 1, // consumer2 channel }, @@ -138,7 +140,8 @@ func stepsMultiConsumerUnbond(consumer1, consumer2 string) []Step { { // relay to consumer1 action: relayPacketsAction{ - chain: chainID("provi"), + chainA: chainID("provi"), + chainB: chainID(consumer1), port: "provider", channel: 0, // consumer1 channel }, @@ -169,7 +172,8 @@ func stepsMultiConsumerUnbond(consumer1, consumer2 string) []Step { { // relay to consumer2 action: relayPacketsAction{ - chain: chainID("provi"), + chainA: chainID("provi"), + chainB: chainID(consumer2), port: "provider", channel: 1, // consumer2 channel }, @@ -242,7 +246,8 @@ func stepsMultiConsumerRedelegate(consumer1, consumer2 string) []Step { { // relay to consumer1 action: relayPacketsAction{ - chain: chainID("provi"), + chainA: chainID("provi"), + chainB: chainID(consumer1), port: "provider", channel: 0, // consumer1 channel }, @@ -273,7 +278,8 @@ func stepsMultiConsumerRedelegate(consumer1, consumer2 string) []Step { { // relay to consumer2 action: relayPacketsAction{ - chain: chainID("provi"), + chainA: chainID("provi"), + chainB: chainID(consumer2), port: "provider", channel: 1, // consumer1 channel }, diff --git a/tests/e2e/steps_multi_consumer_double_sign.go b/tests/e2e/steps_multi_consumer_double_sign.go index a50f21e11f..d12eb37eff 100644 --- a/tests/e2e/steps_multi_consumer_double_sign.go +++ b/tests/e2e/steps_multi_consumer_double_sign.go @@ -45,7 +45,8 @@ func stepsMultiConsumerDoubleSign(consumer1, consumer2 string) []Step { { // relay power change to consumer1 action: relayPacketsAction{ - chain: chainID("provi"), + chainA: chainID("provi"), + chainB: chainID(consumer1), port: "provider", channel: 0, // consumer1 channel }, @@ -76,7 +77,8 @@ func stepsMultiConsumerDoubleSign(consumer1, consumer2 string) []Step { { // relay power change to consumer2 action: relayPacketsAction{ - chain: chainID("provi"), + chainA: chainID("provi"), + chainB: chainID(consumer2), port: "provider", channel: 1, // consumer2 channel }, @@ -137,7 +139,8 @@ func stepsMultiConsumerDoubleSign(consumer1, consumer2 string) []Step { }, { action: relayPacketsAction{ - chain: chainID("provi"), + chainA: chainID("provi"), + chainB: chainID(consumer1), port: "provider", channel: 0, // consumer1 channel }, @@ -168,7 +171,8 @@ func stepsMultiConsumerDoubleSign(consumer1, consumer2 string) []Step { { // consumer1 learns about the double sign action: relayPacketsAction{ - chain: chainID("provi"), + chainA: chainID("provi"), + chainB: chainID(consumer1), port: "provider", channel: 0, // consumer1 channel }, @@ -199,7 +203,8 @@ func stepsMultiConsumerDoubleSign(consumer1, consumer2 string) []Step { { // consumer2 learns about the double sign action: relayPacketsAction{ - chain: chainID("provi"), + chainA: chainID("provi"), + chainB: chainID(consumer2), port: "provider", channel: 1, // consumer2 channel }, diff --git a/tests/e2e/steps_multi_consumer_downtime.go b/tests/e2e/steps_multi_consumer_downtime.go index 181ced029f..ce6cbdff59 100644 --- a/tests/e2e/steps_multi_consumer_downtime.go +++ b/tests/e2e/steps_multi_consumer_downtime.go @@ -40,7 +40,8 @@ func stepsMultiConsumerDowntimeFromConsumer(consumer1, consumer2 string) []Step // Downtime jailing and corresponding voting power change are processed by provider // Validator powers are unchanged on consumer chains action: relayPacketsAction{ - chain: chainID("provi"), + chainA: chainID("provi"), + chainB: chainID(consumer1), port: "provider", channel: 0, }, @@ -73,7 +74,8 @@ func stepsMultiConsumerDowntimeFromConsumer(consumer1, consumer2 string) []Step // and can now be relayed as packet to consumer // consumer1 will now see the validator power changes - consumer2 will not (had not been relayed) action: relayPacketsAction{ - chain: chainID("provi"), + chainA: chainID("provi"), + chainB: chainID(consumer1), port: "provider", channel: 0, // consumer1 chan }, @@ -100,7 +102,8 @@ func stepsMultiConsumerDowntimeFromConsumer(consumer1, consumer2 string) []Step { // both consumer1 and consumer will now see the validator power changes action: relayPacketsAction{ - chain: chainID("provi"), + chainA: chainID("provi"), + chainB: chainID(consumer2), port: "provider", channel: 1, // consumer2 chan }, @@ -156,7 +159,8 @@ func stepsMultiConsumerDowntimeFromConsumer(consumer1, consumer2 string) []Step { // relay to consumer 1 action: relayPacketsAction{ - chain: chainID("provi"), + chainA: chainID("provi"), + chainB: chainID(consumer1), port: "provider", channel: 0, }, @@ -187,7 +191,8 @@ func stepsMultiConsumerDowntimeFromConsumer(consumer1, consumer2 string) []Step { // relay to consumer2 action: relayPacketsAction{ - chain: chainID("provi"), + chainA: chainID("provi"), + chainB: chainID(consumer2), port: "provider", channel: 1, // consumer2 chan }, @@ -255,7 +260,8 @@ func stepsMultiConsumerDowntimeFromProvider(consumer1, consumer2 string) []Step }, { action: relayPacketsAction{ - chain: chainID("provi"), + chainA: chainID("provi"), + chainB: chainID(consumer1), port: "provider", channel: 0, // consumer 1 channel }, @@ -288,7 +294,8 @@ func stepsMultiConsumerDowntimeFromProvider(consumer1, consumer2 string) []Step }, { action: relayPacketsAction{ - chain: chainID("provi"), + chainA: chainID("provi"), + chainB: chainID(consumer2), port: "provider", channel: 1, // consumer2 channel }, @@ -349,7 +356,8 @@ func stepsMultiConsumerDowntimeFromProvider(consumer1, consumer2 string) []Step }, { action: relayPacketsAction{ - chain: chainID("provi"), + chainA: chainID("provi"), + chainB: chainID(consumer1), port: "provider", channel: 0, // consumer1 channel }, @@ -380,7 +388,8 @@ func stepsMultiConsumerDowntimeFromProvider(consumer1, consumer2 string) []Step }, { action: relayPacketsAction{ - chain: chainID("provi"), + chainA: chainID("provi"), + chainB: chainID(consumer2), port: "provider", channel: 1, // consumer2 channel }, diff --git a/tests/e2e/steps_reward_denom.go b/tests/e2e/steps_reward_denom.go index bc26f38d27..dc10ccb7c6 100644 --- a/tests/e2e/steps_reward_denom.go +++ b/tests/e2e/steps_reward_denom.go @@ -193,7 +193,8 @@ func stepsRewardDenomConsumer(consumerName string) []Step { }, { action: relayPacketsAction{ - chain: chainID("provi"), + chainA: chainID("provi"), + chainB: chainID(consumerName), port: "provider", channel: 0, }, @@ -219,7 +220,8 @@ func stepsRewardDenomConsumer(consumerName string) []Step { // and can now be relayed as packet to consumer { action: relayPacketsAction{ - chain: chainID("provi"), + chainA: chainID("provi"), + chainB: chainID(consumerName), port: "provider", channel: 0, }, @@ -258,7 +260,8 @@ func stepsRewardDenomConsumer(consumerName string) []Step { }, { action: relayPacketsAction{ - chain: chainID("provi"), + chainA: chainID("provi"), + chainB: chainID(consumerName), port: "provider", channel: 0, }, diff --git a/tests/e2e/steps_start_chains.go b/tests/e2e/steps_start_chains.go index e3ba9d9ad8..c51042e8c8 100644 --- a/tests/e2e/steps_start_chains.go +++ b/tests/e2e/steps_start_chains.go @@ -265,7 +265,8 @@ func stepsAssignConsumerKeyOnStartedChain(consumerName, validator string) []Step }, { action: relayPacketsAction{ - chain: chainID("provi"), + chainA: chainID("provi"), + chainB: chainID(consumerName), port: "provider", channel: 0, }, diff --git a/tests/e2e/steps_stop_chain.go b/tests/e2e/steps_stop_chain.go index 229b40b215..9cef49a9ea 100644 --- a/tests/e2e/steps_stop_chain.go +++ b/tests/e2e/steps_stop_chain.go @@ -2,11 +2,11 @@ package main import "time" -// start hermes so that all messages are relayed -func stepsStartHermes() []Step { +// start relayer so that all messages are relayed +func stepsStartRelayer() []Step { return []Step{ { - action: startHermesAction{}, + action: startRelayerAction{}, state: State{}, }, } diff --git a/tests/e2e/steps_submit_equivocation_proposal.go b/tests/e2e/steps_submit_equivocation_proposal.go index f8a91d5362..8af1d2464d 100644 --- a/tests/e2e/steps_submit_equivocation_proposal.go +++ b/tests/e2e/steps_submit_equivocation_proposal.go @@ -122,7 +122,8 @@ func stepsSubmitEquivocationProposal(consumerName string, propNumber uint) []Ste { // relay power change to consumer1 action: relayPacketsAction{ - chain: chainID("provi"), + chainA: chainID("provi"), + chainB: chainID(consumerName), port: "provider", channel: 0, }, diff --git a/tests/e2e/testnet-scripts/start-chain.sh b/tests/e2e/testnet-scripts/start-chain.sh index b4d139ec27..9d6e73fdbb 100644 --- a/tests/e2e/testnet-scripts/start-chain.sh +++ b/tests/e2e/testnet-scripts/start-chain.sh @@ -33,6 +33,18 @@ SKIP_GENTX=$6 # A sed string modifying the tendermint config TENDERMINT_CONFIG_TRANSFORM=$7 +# whether to use CometMock +USE_COMETMOCK=$8 + +# stores a comma separated list of nodes addresses +# needed for CometMock - these are the addresses that the ABCI servers of the apps are listening on +NODE_LISTEN_ADDR_STR="" # example value: 7.7.8.6:26655,7.7.8.4:26655,7.7.8.5:26655 + +# stores a comma separated list of nodes home folders +# needed for CometMock - validator nodes have their private keys in their home directories, and CometMock +# reads the keys to sign with from there +NODE_HOMES="" # example value: /consu/validatorcarol,/consu/validatoralice,/consu/validatorbob + # CREATE VALIDATORS AND DO GENESIS CEREMONY @@ -219,10 +231,13 @@ do VAL_IP_SUFFIX=$(echo "$VALIDATORS" | jq -r ".[$i].ip_suffix") NET_NAMESPACE_NAME="$CHAIN_ID-$VAL_ID" - GAIA_HOME="--home /$CHAIN_ID/validator$VAL_ID" + NODE_HOME="/$CHAIN_ID/validator$VAL_ID" + GAIA_HOME="--home $NODE_HOME" + NODE_HOMES="$NODE_HOME,$NODE_HOMES" RPC_ADDRESS="--rpc.laddr tcp://$CHAIN_IP_PREFIX.$VAL_IP_SUFFIX:26658" GRPC_ADDRESS="--grpc.address $CHAIN_IP_PREFIX.$VAL_IP_SUFFIX:9091" LISTEN_ADDRESS="--address tcp://$CHAIN_IP_PREFIX.$VAL_IP_SUFFIX:26655" + NODE_LISTEN_ADDR_STR="$CHAIN_IP_PREFIX.$VAL_IP_SUFFIX:26655,$NODE_LISTEN_ADDR_STR" P2P_ADDRESS="--p2p.laddr tcp://$CHAIN_IP_PREFIX.$VAL_IP_SUFFIX:26656" # LOG_LEVEL="--log_level trace" # switch to trace to see panic messages and rich and all debug msgs LOG_LEVEL="--log_level info" @@ -246,7 +261,13 @@ do PERSISTENT_PEERS="--p2p.persistent_peers ${PERSISTENT_PEERS:1}" ARGS="$GAIA_HOME $LISTEN_ADDRESS $RPC_ADDRESS $GRPC_ADDRESS $LOG_LEVEL $P2P_ADDRESS $ENABLE_WEBGRPC $PERSISTENT_PEERS" - ip netns exec $NET_NAMESPACE_NAME $BIN $ARGS start &> /$CHAIN_ID/validator$VAL_ID/logs & + if [[ "$USE_COMETMOCK" == "true" ]]; then + # to start with CometMock, ensure ABCI server uses grpc (--transport=grpc) and the app is started without in-process CometBFT (--with-tendermint=false) + ip netns exec $NET_NAMESPACE_NAME $BIN $ARGS start --transport=grpc --with-tendermint=false &> /$CHAIN_ID/validator$VAL_ID/logs & + else + ip netns exec $NET_NAMESPACE_NAME $BIN $ARGS start &> /$CHAIN_ID/validator$VAL_ID/logs & + fi + done ## SETUP DOUBLE SIGNING NODE NETWORK NAMESPACE @@ -321,16 +342,46 @@ QUERY_PERSISTENT_PEERS="--p2p.persistent_peers ${QUERY_PERSISTENT_PEERS:1}" ## START NODE ARGS="$QUERY_GAIA_HOME $QUERY_LISTEN_ADDRESS $QUERY_RPC_ADDRESS $QUERY_GRPC_ADDRESS $QUERY_LOG_LEVEL $QUERY_P2P_ADDRESS $QUERY_ENABLE_WEBGRPC $QUERY_PERSISTENT_PEERS" -ip netns exec $QUERY_NET_NAMESPACE_NAME $BIN $ARGS start &> /$CHAIN_ID/$QUERY_NODE_ID/logs & + +# Query node is only started if CometMock is not used - with CometMock, it takes the role of the query node +if [[ "$USE_COMETMOCK" != "true" ]]; then + ip netns exec $QUERY_NET_NAMESPACE_NAME $BIN $ARGS start &> /$CHAIN_ID/$QUERY_NODE_ID/logs & +fi ## DONE START NODE +echo "Node addresses:" +echo $NODE_LISTEN_ADDR_STR + +echo "Node homes:" +echo $NODE_HOMES + +NODE_LISTEN_ADDR_STR=${NODE_LISTEN_ADDR_STR%?} +NODE_HOMES=${NODE_HOMES%?} + + +# CometMock takes the role of the query node +if [[ "$USE_COMETMOCK" == "true" ]]; then + sleep 2 + ip netns exec $QUERY_NET_NAMESPACE_NAME cometmock $NODE_LISTEN_ADDR_STR /$CHAIN_ID/genesis.json tcp://$CHAIN_IP_PREFIX.$QUERY_IP_SUFFIX:26658 $NODE_HOMES &> cometmock_${CHAIN_ID}_out.log & + sleep 3 +fi + +# exit + # poll for chain start -set +e -until $BIN query block --node "tcp://$CHAIN_IP_PREFIX.$QUERY_IP_SUFFIX:26658" | grep -q -v '{"block_id":{"hash":"","parts":{"total":0,"hash":""}},"block":null}'; do sleep 0.3 ; done -set -e +if [[ "$USE_COMETMOCK" == "true" ]]; then + set +e + until $BIN query block --node "tcp://$CHAIN_IP_PREFIX.$QUERY_IP_SUFFIX:26658"; do sleep 0.3 ; done + set -e +else + set +e + until $BIN query block --node "tcp://$CHAIN_IP_PREFIX.$QUERY_IP_SUFFIX:26658" | grep -q -v '{"block_id":{"hash":"","parts":{"total":0,"hash": + ""}},"block":null}'; do sleep 0.3 ; done + set -e +fi echo "done!!!!!!!!" -read -p "Press Return to Close..." \ No newline at end of file +read -p "Press Return to Close..."