From 51b8c3df2f864f7c0a77a195f772d43734a8b2c8 Mon Sep 17 00:00:00 2001 From: JoeGruff Date: Mon, 19 Jul 2021 11:46:16 +0900 Subject: [PATCH] harness/eth: Fix mining script. Immediatly stopping the miner after starting to mine was causing transactions to not be included in blocks. Change to start once and stop a fraction of a second before N blocks should be mined. Update internal geth to slightly after 1.10.5 and set harness to start at the london fork. --- dex/testing/eth/README.md | 2 ++ dex/testing/eth/create-node.sh | 26 +++++++++----------------- dex/testing/eth/harness.sh | 3 +-- go.mod | 2 +- go.sum | 9 ++++----- 5 files changed, 17 insertions(+), 25 deletions(-) diff --git a/dex/testing/eth/README.md b/dex/testing/eth/README.md index 0022acb4e2..fb2389639d 100644 --- a/dex/testing/eth/README.md +++ b/dex/testing/eth/README.md @@ -8,6 +8,8 @@ sandboxed environment for testing dex swap transactions. The harness depends on [geth](https://github.com/ethereum/go-ethereum/tree/master/cmd/geth) to run. +It also requires tmux and bc. + ## Using You must have `geth` in `PATH` to use the harness. diff --git a/dex/testing/eth/create-node.sh b/dex/testing/eth/create-node.sh index c1486e1f85..0dd33b9792 100755 --- a/dex/testing/eth/create-node.sh +++ b/dex/testing/eth/create-node.sh @@ -31,6 +31,7 @@ chmod +x "${NODES_ROOT}/harness-ctl/${NAME}" # Write mine script if CHAIN_ADDRESS is present. if [ "${CHAIN_ADDRESS}" != "_" ]; then + # The mining script may end up mining more or less blocks than specified. cat > "${NODES_ROOT}/harness-ctl/mine-${NAME}" < /dev/null + sleep \$(echo "\$NUM-0.9" | bc) + "${NODES_ROOT}/harness-ctl/${NAME}" attach --exec 'miner.stop()' > /dev/null + AFTER=\$("${NODES_ROOT}/harness-ctl/${NAME}" attach --exec 'eth.blockNumber') + DIFF=\$((AFTER-BEFORE)) + echo "Mined \$DIFF blocks." EOF chmod +x "${NODES_ROOT}/harness-ctl/mine-${NAME}" - # Write mining javascript. - # NOTE: This sometimes mines more than one block. It is a race. This returns - # the number of blocks mined within the lifespan of the function, but one more - # MAY be mined after returning. - cat > "${MINE_JS}" < "${GROUP_DIR}/password" < "${NODES_ROOT}/genesis.json" <