From 401f92725988388122cc653b7fe68485cafa406c Mon Sep 17 00:00:00 2001 From: JoeGruff Date: Tue, 17 Dec 2024 16:29:44 +0900 Subject: [PATCH] harness: Update eth to work with geth 1.14 and up. --- dex/testing/eth/create-node.sh | 91 ++----------- dex/testing/eth/harness.sh | 226 ++++----------------------------- 2 files changed, 40 insertions(+), 277 deletions(-) diff --git a/dex/testing/eth/create-node.sh b/dex/testing/eth/create-node.sh index 594071ec45..bafe13844b 100755 --- a/dex/testing/eth/create-node.sh +++ b/dex/testing/eth/create-node.sh @@ -5,19 +5,10 @@ set -ex # The following are required script arguments. TMUX_WIN_ID=$1 NAME=$2 -NODE_PORT=$3 -CHAIN_ADDRESS=$4 -CHAIN_PASSWORD=$5 -CHAIN_ADDRESS_JSON=$6 -CHAIN_ADDRESS_JSON_FILE_NAME=$7 -ADDRESS_JSON=$8 -ADDRESS_JSON_FILE_NAME=$9 -NODE_KEY=${10} -SYNC_MODE=${11} -AUTHRPC_PORT=${12} -HTTP_PORT=${13} -WS_PORT=${14} -WS_MODULES=${15} +AUTHRPC_PORT=${3} +HTTP_PORT=${4} +WS_PORT=${5} +WS_MODULES=${6} GROUP_DIR="${NODES_ROOT}/${NAME}" MINE_JS="${GROUP_DIR}/mine.js" @@ -33,10 +24,8 @@ geth --datadir="${NODE_DIR}" \$* EOF 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}" < "${NODES_ROOT}/harness-ctl/mine-${NAME}" < "${GROUP_DIR}/password" < "${NODE_DIR}/eth.conf" <> "${NODE_DIR}/eth.conf" < "${NODE_DIR}/keystore/$CHAIN_ADDRESS_JSON_FILE_NAME" < "${NODE_DIR}/keystore/$ADDRESS_JSON_FILE_NAME" < "${NODE_DIR}/geth/nodekey" <&1 | tee ${NODE_DIR}/${NAME}.log" C-m - -else - # Start the eth node listening restricted to localhost and our custom - # configuration file. - tmux send-keys -t "$TMUX_WIN_ID" "${NODES_ROOT}/harness-ctl/${NAME} --allow-insecure-unlock --rpc.enabledeprecatedpersonal " \ - "--config ${NODE_DIR}/eth.conf --verbosity 5 ${HTTP_OPT} 2>&1 | tee " \ - "${NODE_DIR}/${NAME}.log" C-m -fi +# Start the eth node with the chain account unlocked, listening restricted to +# localhost, and our custom configuration file. +tmux send-keys -t "$TMUX_WIN_ID" "${NODES_ROOT}/harness-ctl/${NAME} " \ + "--config ${NODE_DIR}/eth.conf " \ + "--verbosity 5 --vmdebug --http --http.port " \ + "${HTTP_PORT} --ws --ws.port ${WS_PORT} --ws.api ${WS_MODULES} " \ + "--dev --dev.period 5 2>&1 | tee ${NODE_DIR}/${NAME}.log" C-m diff --git a/dex/testing/eth/harness.sh b/dex/testing/eth/harness.sh index 1f1ee3e2f0..d1f117cfa3 100755 --- a/dex/testing/eth/harness.sh +++ b/dex/testing/eth/harness.sh @@ -1,42 +1,15 @@ #!/usr/bin/env bash -# tmux script that sets up an eth simnet harness. It sets up four separate nodes. -# alpha and beta nodes are synced in snap mode. They emulate nodes used by the -# dcrdex server. Either has the authority to mine blocks. They start with -# pre-allocated funds. gamma and delta are synced in light mode and emulate -# nodes used by bisonw. They are sent some funds after being created. The -# harness waits for all nodes to sync before allowing tmux input. +# tmux script that sets up an eth simnet harness. There is only one node in +# --dev mode. set -ex SESSION="eth-harness" -CHAIN_ADDRESS_JSON_FILE_NAME="UTC--2021-01-27T08-20-38.123221057Z--9ebba10a6136607688ca4f27fab70e23938cd027" -CHAIN_ADDRESS="9ebba10a6136607688ca4f27fab70e23938cd027" -CHAIN_ADDRESS_JSON='{"address":"9ebba10a6136607688ca4f27fab70e23938cd027","crypto":{"cipher":"aes-128-ctr","ciphertext":"dcfbe17de6f315c732855111b782496d76b2d703169afddaaa69e1bc9e02ec51","cipherparams":{"iv":"907e5e050649d1c5c0be782ec7db5cf1"},"kdf":"scrypt","kdfparams":{"dklen":32,"n":262144,"p":1,"r":8,"salt":"060f4e16d601069a6bccae0693a15cd72090baf1ab20e408c89883117d4f7c51"},"mac":"b9ca7dad75a04b77dc7751a814c051f32752603334e4bb4046caf927196a5579"},"id":"74805e39-6a2f-46eb-8125-70c41d12c6d9","version":3}' - -ALPHA_ADDRESS="18d65fb8d60c1199bb1ad381be47aa692b482605" -ALPHA_ADDRESS_JSON_FILE_NAME="UTC--2021-01-28T08-47-02.993754951Z--18d65fb8d60c1199bb1ad381be47aa692b482605" -ALPHA_ADDRESS_JSON='{"address":"18d65fb8d60c1199bb1ad381be47aa692b482605","crypto":{"cipher":"aes-128-ctr","ciphertext":"927bc2432492fc4bbe9acfe0042f5cd2cef25aff251ac1fb2f420ee85e3b6ee4","cipherparams":{"iv":"89e7333535aed5284abd52f841d30c95"},"kdf":"scrypt","kdfparams":{"dklen":32,"n":262144,"p":1,"r":8,"salt":"6fe29ea59d166989be533da62d79802a6b0cef26a9766fa363c7a4bb4c263b5f"},"mac":"c7e2b6c4538c373b2c4e0be7b343db618d39cc68fa872909059357ff36743ca0"},"id":"0e2b9cef-d659-4a26-8739-879129ed0b63","version":3}' -ALPHA_NODE_KEY="71d810d39333296b518c846a3e49eca55f998fd7994998bb3e5048567f2f073c" -ALPHA_ENODE="897c84f6e4f18195413c1d02927e6a4093f5e7574b52bdec6f20844c4f1f6dd3f16036a9e600bd8681ab50fd8dd144df4a6ba9dd8722bb578a86aaa8222c964f" -ALPHA_NODE_PORT="30304" ALPHA_AUTHRPC_PORT="8552" ALPHA_HTTP_PORT="38556" ALPHA_WS_PORT="38557" ALPHA_WS_MODULES="eth" -BETA_ADDRESS="4f8ef3892b65ed7fc356ff473a2ef2ae5ec27a06" -BETA_ADDRESS_JSON_FILE_NAME="UTC--2021-01-27T08-20-58.179642501Z--4f8ef3892b65ed7fc356ff473a2ef2ae5ec27a06" -BETA_ADDRESS_JSON='{"address":"4f8ef3892b65ed7fc356ff473a2ef2ae5ec27a06","crypto":{"cipher":"aes-128-ctr","ciphertext":"c5672bb829df9e209ca8ce18dbdd1fed69c603d639e06ab09127b672a609c121","cipherparams":{"iv":"24460eb2934c8b61cee3ad0aa7b843c0"},"kdf":"scrypt","kdfparams":{"dklen":32,"n":262144,"p":1,"r":8,"salt":"1f85da881994ca7b4a23f0698da70500a4b79f97a4450b83b129ebf3b4c28f50"},"mac":"1ecea707f1bffa1f6f944cb47e83118d8179e8a5005b83c88610b7e8692a1197"},"id":"56633762-6fb1-4cbf-8396-3a2e4661f7d4","version":3}' -BETA_NODE_KEY="0f3f23a0f14202da009bd59a96457098acea901986629e54d5be1eea32fc404a" -BETA_ENODE="b1d3e358ee5c9b268e911f2cab47bc12d0e65c80a6d2b453fece34facc9ac3caed14aa3bc7578166bb08c5bc9719e5a2267ae14e0b42da393f4d86f6d5829061" -BETA_NODE_PORT="30305" -BETA_AUTHRPC_PORT="8553" -BETA_HTTP_PORT="38558" -BETA_WS_PORT="38559" -BETA_WS_MODULES="eth,txpool" - -# TODO: Light nodes broken as of geth 1.13.4-stable. Enable them when possible. - # TESTING_ADDRESS is used by the client's internal node. TESTING_ADDRESS="946dfaB1AD7caCFeF77dE70ea68819a30acD4577" SIMNET_TOKEN_ADDRESS="946dfaB1AD7caCFeF77dE70ea68819a30acD4577" @@ -45,9 +18,6 @@ ERC20_SWAP_V0="60a060405234801561001057600080fd5b50604051610e92380380610e9283398 TEST_TOKEN="608060405234801561001057600080fd5b50604051610aec380380610aec83398101604081905261002f91610140565b6040805180820190915260098152682a32b9ba2a37b5b2b760b91b602082015260039061005c9082610209565b506040805180820190915260038152621514d560ea1b60208201526004906100849082610209565b506005805460ff191660ff929092169190911790556909513ea9de0243800000600255600060208190526902544faa778090e000007f7d4921c2bc32c0110a31d16f4efb43c7a1228f1df7af765f608241dee5c62ebc8190557f59603491850c7d11499afe95b334ccfd92b48b36a15df31ef59ff5813fe3708281905573d12ab7cf72ccf1f3882ec99ddc53cd415635c3be9091527f5bd8dfce2dbb581d0922a094c40bab2f7d2f0ea9aaf275bf0fcc0f027a2ff91d556102c8565b60006020828403121561015257600080fd5b815160ff8116811461016357600080fd5b9392505050565b634e487b7160e01b600052604160045260246000fd5b600181811c9082168061019457607f821691505b6020821081036101b457634e487b7160e01b600052602260045260246000fd5b50919050565b601f82111561020457600081815260208120601f850160051c810160208610156101e15750805b601f850160051c820191505b81811015610200578281556001016101ed565b5050505b505050565b81516001600160401b038111156102225761022261016a565b610236816102308454610180565b846101ba565b602080601f83116001811461026b57600084156102535750858301515b600019600386901b1c1916600185901b178555610200565b600085815260208120601f198616915b8281101561029a5788860151825594840194600190910190840161027b565b50858210156102b85787850151600019600388901b60f8161c191681555b5050505050600190811b01905550565b610815806102d76000396000f3fe608060405234801561001057600080fd5b50600436106100a95760003560e01c806370a082311161007157806370a08231146101295780638ba4cc3c1461015257806395d89b4114610167578063a9059cbb1461016f578063ce714b5114610182578063dd62ed3e1461019557600080fd5b806306fdde03146100ae578063095ea7b3146100cc57806318160ddd146100ef57806323b872dd14610101578063313ce56714610114575b600080fd5b6100b66101ce565b6040516100c3919061065f565b60405180910390f35b6100df6100da3660046106c9565b610260565b60405190151581526020016100c3565b6002545b6040519081526020016100c3565b6100df61010f3660046106f3565b610277565b60055460405160ff90911681526020016100c3565b6100f361013736600461072f565b6001600160a01b031660009081526020819052604090205490565b6101656101603660046106c9565b610326565b005b6100b661036e565b6100df61017d3660046106c9565b61037d565b6100df6101903660046106f3565b61038a565b6100f36101a3366004610751565b6001600160a01b03918216600090815260016020908152604080832093909416825291909152205490565b6060600380546101dd90610784565b80601f016020809104026020016040519081016040528092919081815260200182805461020990610784565b80156102565780601f1061022b57610100808354040283529160200191610256565b820191906000526020600020905b81548152906001019060200180831161023957829003601f168201915b5050505050905090565b600061026d3384846103a1565b5060015b92915050565b6000610284848484610490565b6001600160a01b03841660009081526001602090815260408083203384529091529020548281101561030e5760405162461bcd60e51b815260206004820152602860248201527f45524332303a207472616e7366657220616d6f756e74206578636565647320616044820152676c6c6f77616e636560c01b60648201526084015b60405180910390fd5b61031b85338584036103a1565b506001949350505050565b806002600082825461033891906107be565b90915550506001600160a01b038216600090815260208190526040812080548392906103659084906107be565b90915550505050565b6060600480546101dd90610784565b600061026d338484610490565b60006103978484846103a1565b5060019392505050565b6001600160a01b0383166104035760405162461bcd60e51b8152602060048201526024808201527f45524332303a20617070726f76652066726f6d20746865207a65726f206164646044820152637265737360e01b6064820152608401610305565b6001600160a01b0382166104645760405162461bcd60e51b815260206004820152602260248201527f45524332303a20617070726f766520746f20746865207a65726f206164647265604482015261737360f01b6064820152608401610305565b6001600160a01b0392831660009081526001602090815260408083209490951682529290925291902055565b6001600160a01b0383166104f45760405162461bcd60e51b815260206004820152602560248201527f45524332303a207472616e736665722066726f6d20746865207a65726f206164604482015264647265737360d81b6064820152608401610305565b6001600160a01b0382166105565760405162461bcd60e51b815260206004820152602360248201527f45524332303a207472616e7366657220746f20746865207a65726f206164647260448201526265737360e81b6064820152608401610305565b6001600160a01b038316600090815260208190526040902054818110156105ce5760405162461bcd60e51b815260206004820152602660248201527f45524332303a207472616e7366657220616d6f756e7420657863656564732062604482015265616c616e636560d01b6064820152608401610305565b6001600160a01b038085166000908152602081905260408082208585039055918516815290812080548492906106059084906107be565b92505081905550826001600160a01b0316846001600160a01b03167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef8460405161065191815260200190565b60405180910390a350505050565b600060208083528351808285015260005b8181101561068c57858101830151858201604001528201610670565b506000604082860101526040601f19601f8301168501019250505092915050565b80356001600160a01b03811681146106c457600080fd5b919050565b600080604083850312156106dc57600080fd5b6106e5836106ad565b946020939093013593505050565b60008060006060848603121561070857600080fd5b610711846106ad565b925061071f602085016106ad565b9150604084013590509250925092565b60006020828403121561074157600080fd5b61074a826106ad565b9392505050565b6000806040838503121561076457600080fd5b61076d836106ad565b915061077b602084016106ad565b90509250929050565b600181811c9082168061079857607f821691505b6020821081036107b857634e487b7160e01b600052602260045260246000fd5b50919050565b8082018082111561027157634e487b7160e01b600052601160045260246000fdfea2646970667358221220a1dec430e536a5a10a28fc4b864936f9d148be4c0a5db1246a0865556ca3bdde64736f6c63430008120033" MULTIBALANCE_BIN="608060405234801561001057600080fd5b50610483806100206000396000f3fe608060405234801561001057600080fd5b506004361061002b5760003560e01c8063d3e5ca8714610030575b600080fd5b61004361003e3660046102a5565b610059565b604051610050919061032b565b60405180910390f35b60606000610068836001610385565b67ffffffffffffffff8111156100805761008061039e565b6040519080825280602002602001820160405280156100a9578160200160208202803683370190505b509050846001600160a01b031631816000815181106100ca576100ca6103b4565b60200260200101818152505060005b838110156102805760008585838181106100f5576100f56103b4565b905060200201602081019061010a91906103ca565b905060006060826001600160a01b03167f70a08231b98ef4ca268c9cc3f6b4590e4bfec28280db06bb5d45e689f2a360be8a60405160240161015b91906001600160a01b0391909116815260200190565b60408051601f198184030181529181526020820180516001600160e01b03166001600160e01b031990941693909317909252905161019991906103ec565b600060405180830381855afa9150503d80600081146101d4576040519150601f19603f3d011682016040523d82523d6000602084013e6101d9565b606091505b509092509050816102285760405162461bcd60e51b815260206004820152601560248201527418985b185b98d953d98818d85b1b0819985a5b1959605a1b604482015260640160405180910390fd5b60008180602001905181019061023e919061041b565b9050808661024d876001610385565b8151811061025d5761025d6103b4565b60200260200101818152505050505050808061027890610434565b9150506100d9565b50949350505050565b80356001600160a01b03811681146102a057600080fd5b919050565b6000806000604084860312156102ba57600080fd5b6102c384610289565b9250602084013567ffffffffffffffff808211156102e057600080fd5b818601915086601f8301126102f457600080fd5b81358181111561030357600080fd5b8760208260051b850101111561031857600080fd5b6020830194508093505050509250925092565b6020808252825182820181905260009190848201906040850190845b8181101561036357835183529284019291840191600101610347565b50909695505050505050565b634e487b7160e01b600052601160045260246000fd5b808201808211156103985761039861036f565b92915050565b634e487b7160e01b600052604160045260246000fd5b634e487b7160e01b600052603260045260246000fd5b6000602082840312156103dc57600080fd5b6103e582610289565b9392505050565b6000825160005b8181101561040d57602081860181015185830152016103f3565b506000920191825250919050565b60006020828403121561042d57600080fd5b5051919050565b6000600182016104465761044661036f565b506001019056fea26469706673582212207074e3e189a2692e2841f7943a9de24bcdbca943ee6bfcbd83a2fa6e43ec497b64736f6c63430008120033" -# PASSWORD is the password used to unlock all accounts/wallets/addresses. -PASSWORD="abc" - export NODES_ROOT=~/dextest/eth export GENESIS_JSON_FILE_LOCATION="${NODES_ROOT}/genesis.json" @@ -56,7 +26,6 @@ if [ -d "${NODES_ROOT}" ]; then fi mkdir -p "${NODES_ROOT}/alpha" -mkdir -p "${NODES_ROOT}/beta" mkdir -p "${NODES_ROOT}/harness-ctl" echo "Writing ctl scripts" @@ -64,82 +33,38 @@ echo "Writing ctl scripts" # Control Scripts ################################################################################ -# Write genesis json. ".*Block" fields represent block height where certain -# protocols take effect. "clique" is our proof of authority scheme. One block -# can be mined per second with a signature belonging to the address in -# "extradata". The addresses in the "alloc" field are allocated "balance". -# Values are in wei. 1*10^18 wei is equal to one eth. Addresses are allocated -# 11,000 eth. The addresses belong to alpha and beta nodes and two others are -# used in tests. -cat > "${NODES_ROOT}/genesis.json" < "${NODES_ROOT}/harness-ctl/send.js" < "${NODES_ROOT}/harness-ctl/sendtoaddress" < "${NODES_ROOT}/harness-ctl/deploy.js" < "${NODES_ROOT}/harness-ctl/reorg" < "${NODES_ROOT}/harness-ctl/quit" < "${NODES_ROOT}/test_tx_hash.txt" < "${NODES_ROOT}/harness-ctl/loadTestToken.js" < "${NODES_ROOT}/harness-ctl/loadTestToken.js" < 1 ? web3.eth.accounts[1] : web3.eth.accounts[0] - personal.unlockAccount(web3.eth.defaultAccount, '${PASSWORD}') function transfer (tokenAddr, decimals, addr, val) { addr = addr.startsWith('0x') ? addr : '0x'+addr @@ -375,6 +200,8 @@ cat > "${NODES_ROOT}/harness-ctl/sendUSDT" < "${NODES_ROOT}/usdc_swap_contract_address.txt" <