From 14c8ceb537b629c2ace2ddb302de4674a7a624f5 Mon Sep 17 00:00:00 2001 From: Georgios Konstantopoulos Date: Thu, 16 Feb 2023 16:00:46 -0800 Subject: [PATCH 01/23] feat: reth (#1) * wip * wip * wip * feat: add initial block import part of script (#1) * set up init and import commands * reorder reth commands * change command style * feat: load rest of test chain * feat: enable rpc * fix: correct genesis hex mapper * use apt instead of apk --------- Co-authored-by: Oliver Nordbjerg Co-authored-by: Dan Cline <6798349+Rjected@users.noreply.github.com> --- clients/reth/Dockerfile | 26 +++++++ clients/reth/enode.sh | 8 +++ clients/reth/genesis.json | 15 ++++ clients/reth/mapper.jq | 87 ++++++++++++++++++++++ clients/reth/reth.sh | 147 ++++++++++++++++++++++++++++++++++++++ 5 files changed, 283 insertions(+) create mode 100644 clients/reth/Dockerfile create mode 100644 clients/reth/enode.sh create mode 100644 clients/reth/genesis.json create mode 100644 clients/reth/mapper.jq create mode 100644 clients/reth/reth.sh diff --git a/clients/reth/Dockerfile b/clients/reth/Dockerfile new file mode 100644 index 0000000000..e4281cd46d --- /dev/null +++ b/clients/reth/Dockerfile @@ -0,0 +1,26 @@ +ARG branch=main +FROM paradigmxyz/reth:$branch + +# Install script tools. +RUN apt-get update -y +RUN apt-get install -y bash curl jq + +# Add genesis mapper script. +ADD genesis.json /genesis.json +ADD mapper.jq /mapper.jq + +# Add the startup script. +ADD reth.sh /reth.sh +RUN chmod +x /reth.sh + +# Add the enode URL retriever script. +ADD enode.sh /hive-bin/enode.sh +RUN chmod +x /hive-bin/enode.sh + +# Create version.txt +RUN /usr/local/bin/reth --version | sed -e 's/reth \(.*\)/\1/' > /version.txt + +# Export the usual networking ports to allow outside access to the node. +EXPOSE 8545 8546 30303 30303/udp + +ENTRYPOINT ["/reth.sh"] diff --git a/clients/reth/enode.sh b/clients/reth/enode.sh new file mode 100644 index 0000000000..489756f280 --- /dev/null +++ b/clients/reth/enode.sh @@ -0,0 +1,8 @@ +#!/bin/bash + +set -e + +TARGET_RESPONSE=$(curl -s -X POST -H "Content-Type: application/json" --data '{"jsonrpc":"2.0","method":"admin_nodeInfo","params":[],"id":1}' "127.0.0.1:8545" ) +TARGET_ENODE=$(echo ${TARGET_RESPONSE}| jq -r '.result.enode') + +echo "$TARGET_ENODE" diff --git a/clients/reth/genesis.json b/clients/reth/genesis.json new file mode 100644 index 0000000000..7ca6f39f73 --- /dev/null +++ b/clients/reth/genesis.json @@ -0,0 +1,15 @@ +{ + "coinbase" : "0x8888f1f195afa192cfee860698584c030f4c9db1", + "difficulty" : "0x020000", + "extraData" : "0x42", + "gasLimit" : "0x2fefd8", + "mixHash" : "0x2c85bcbce56429100b2108254bb56906257582aeafcbd682bc9af67a9f5aee46", + "nonce" : "0x78cc16f7b4f65485", + "parentHash" : "0x0000000000000000000000000000000000000000000000000000000000000000", + "timestamp" : "0x54c98c81", + "alloc" : { + "a94f5374fce5edbc8e2a8697c15331677e6ebf0b": { + "balance" : "0x09184e72a000" + } + } +} diff --git a/clients/reth/mapper.jq b/clients/reth/mapper.jq new file mode 100644 index 0000000000..ee5cdd73e5 --- /dev/null +++ b/clients/reth/mapper.jq @@ -0,0 +1,87 @@ +# Removes all empty keys and values in input. +def remove_empty: + . | walk( + if type == "object" then + with_entries( + select( + .value != null and + .value != "" and + .value != [] and + .key != null and + .key != "" + ) + ) + else . + end + ) +; + +# Converts decimal string to number. +def to_int: + if . == null then . else .|tonumber end +; + +# Converts "1" / "0" to boolean. +def to_bool: + if . == null then . else + if . == "1" then true else false end + end +; + +# Converts number to hex, from https://rosettacode.org/wiki/Non-decimal_radices/Convert#jq +def int_to_hex: + def stream: + recurse(if . > 0 then ./16|floor else empty end) | . % 16 ; + if . == 0 then "0x0" + else "0x" + ([stream] | reverse | .[1:] | map(if .<10 then 48+. else 87+. end) | implode) + end +; + +# Converts decimal number in string to hex. +def to_hex: + if . != null and startswith("0x") then . else + if (. != null and . != "") then .|tonumber|int_to_hex else . end + end +; + +# Zero-pads hex string. +def infix_zeros_to_length(s;l): + if . != null then + (.[0:s])+("0"*(l-(.|length)))+(.[s:l]) + else . + end +; + +# Replace config in input. +. + { + "coinbase": (if .coinbase == null then "0x0000000000000000000000000000000000000000" else .coinbase end)|to_hex, + "difficulty": (if .difficulty == null then "0x00" else .difficulty end)|to_hex|infix_zeros_to_length(2;8), + "extraData": (if .extraData == null then "0x00" else .extraData end)|to_hex, + "gasLimit": (if .gasLimit == null then "0x00" else .gasLimit end)|to_hex|infix_zeros_to_length(2;8), + "mixHash": (if .mixHash == null then "0x00" else .mixHash end)|to_hex|infix_zeros_to_length(2;66), + "nonce": (if .nonce == null then "0x00" else .nonce end)|to_hex, + "parentHash": (if .parentHash == null then "0x0000000000000000000000000000000000000000000000000000000000000000" else .parentHash end)|to_hex, + "timestamp": (if .timestamp == null then "0x00" else .timestamp end)|to_hex, + "config": { + "ethash": (if env.HIVE_CLIQUE_PERIOD then null else {} end), + "clique": (if env.HIVE_CLIQUE_PERIOD == null then null else { + "period": env.HIVE_CLIQUE_PERIOD|to_int, + } end), + "chainId": (if env.HIVE_CHAIN_ID == null then 1 else env.HIVE_CHAIN_ID|to_int end), + "homesteadBlock": env.HIVE_FORK_HOMESTEAD|to_int, + "daoForkBlock": env.HIVE_FORK_DAO_BLOCK|to_int, + "daoForkSupport": env.HIVE_FORK_DAO_VOTE|to_bool, + "eip150Block": env.HIVE_FORK_TANGERINE|to_int, + "eip150Hash": env.HIVE_FORK_TANGERINE_HASH, + "eip155Block": env.HIVE_FORK_SPURIOUS|to_int, + "eip158Block": env.HIVE_FORK_SPURIOUS|to_int, + "byzantiumBlock": env.HIVE_FORK_BYZANTIUM|to_int, + "constantinopleBlock": env.HIVE_FORK_CONSTANTINOPLE|to_int, + "petersburgBlock": env.HIVE_FORK_PETERSBURG|to_int, + "istanbulBlock": env.HIVE_FORK_ISTANBUL|to_int, + "muirGlacierBlock": env.HIVE_FORK_MUIR_GLACIER|to_int, + "berlinBlock": env.HIVE_FORK_BERLIN|to_int, + "londonBlock": env.HIVE_FORK_LONDON|to_int, + "terminalTotalDifficulty": env.HIVE_TERMINAL_TOTAL_DIFFICULTY|to_int, + }|remove_empty +} diff --git a/clients/reth/reth.sh b/clients/reth/reth.sh new file mode 100644 index 0000000000..0da4d6605c --- /dev/null +++ b/clients/reth/reth.sh @@ -0,0 +1,147 @@ +#!/bin/bash + +# Startup script to initialize and boot a reth instance. +# +# This script assumes the following files: +# - `reth` binary is located in the filesystem root +# - `genesis.json` file is located in the filesystem root (mandatory) +# - `chain.rlp` file is located in the filesystem root (optional) +# - `blocks` folder is located in the filesystem root (optional) +# +# This script can be configured using the following environment variables: +# +# - HIVE_BOOTNODE enode URL of the remote bootstrap node +# - HIVE_NETWORK_ID network ID number to use for the eth protocol +# - HIVE_FORK_HOMESTEAD block number of the homestead transition +# - HIVE_FORK_DAO_BLOCK block number of the DAO hard-fork transition +# - HIVE_FORK_TANGERINE block number of TangerineWhistle +# - HIVE_FORK_SPURIOUS block number of SpuriousDragon +# - HIVE_FORK_BYZANTIUM block number for Byzantium transition +# - HIVE_FORK_CONSTANTINOPLE block number for Constantinople transition +# - HIVE_FORK_PETERSBURG block number for ConstantinopleFix/Petersburg transition +# - HIVE_FORK_ISTANBUL block number for Istanbul transition +# - HIVE_FORK_MUIR_GLACIER block number for MuirGlacier transition +# - HIVE_LOGLEVEL client log level +# +# These flags are NOT supported by reth +# +# - HIVE_TESTNET whether testnet nonces (2^20) are needed +# - HIVE_GRAPHQL_ENABLED turns on GraphQL server +# - HIVE_CLIQUE_PRIVATEKEY private key for clique mining +# - HIVE_NODETYPE sync and pruning selector (archive, full, light) +# - HIVE_SKIP_POW If set, skip PoW verification during block import +# - HIVE_MINER address to credit with mining rewards +# - HIVE_MINER_EXTRA extra-data field to set for newly minted blocks + +# Immediately abort the script on any error encountered +set -ex + +reth=/usr/local/bin/reth + +case "$HIVE_LOGLEVEL" in + 0|1) FLAGS="$FLAGS -v" ;; + 2) FLAGS="$FLAGS -vv" ;; + 3) FLAGS="$FLAGS -vvv" ;; + 4) FLAGS="$FLAGS -vvvv" ;; + 5) FLAGS="$FLAGS -vvvvv" ;; +esac + +# Create the data directory. +mkdir /reth-hive-db +FLAGS="$FLAGS --db /reth-hive-db" + +# It doesn't make sense to dial out, use only a pre-set bootnode. +if [ "$HIVE_BOOTNODE" != "" ]; then + FLAGS="$FLAGS --bootnodes=$HIVE_BOOTNODE" +fi + +# TODO If a specific network ID is requested, use that +#if [ "$HIVE_NETWORK_ID" != "" ]; then +# FLAGS="$FLAGS --networkid $HIVE_NETWORK_ID" +#else +# FLAGS="$FLAGS --networkid 1337" +#fi + +# Configure the chain. +mv /genesis.json /genesis-input.json +jq -f /mapper.jq /genesis-input.json > /genesis.json + +# Dump genesis +echo "Supplied genesis state:" +cat /genesis.json + +echo "Command flags till now:" +echo $FLAGS + +# Initialize the local testchain with the genesis state +echo "Initializing database with genesis state..." +$reth init $FLAGS --chain /genesis.json + +# make sure we use the same genesis each time +FLAGS="$FLAGS --chain /genesis.json" + +# Don't immediately abort, some imports are meant to fail +set +ex + +# Load the test chain if present +echo "Loading initial blockchain..." +if [ -f /chain.rlp ]; then + echo "Loading initial blockchain..." + $reth import $FLAGS --path /chain.rlp +else + echo "Warning: chain.rlp not found." +fi + +# Load the remainder of the test chain +echo "Loading remaining individual blocks..." +if [ -d /blocks ]; then + echo "Loading remaining individual blocks..." + for file in $(ls /blocks | sort -n); do + echo "Importing " $file + $reth import $FLAGS --path /blocks/$file + done +else + echo "Warning: blocks folder not found." +fi + +set -ex + +# Configure any mining operation +# TODO +#if [ "$HIVE_MINER" != "" ]; then +# FLAGS="$FLAGS --mine --miner.etherbase $HIVE_MINER" +#fi +#if [ "$HIVE_MINER_EXTRA" != "" ]; then +# FLAGS="$FLAGS --miner.extradata $HIVE_MINER_EXTRA" +#fi + +# Import clique signing key. +# TODO +#if [ "$HIVE_CLIQUE_PRIVATEKEY" != "" ]; then +# # Create password file. +# echo "Importing clique key..." +# echo "$HIVE_CLIQUE_PRIVATEKEY" > ./private_key.txt +# +# # Ensure password file is used when running geth in mining mode. +# if [ "$HIVE_MINER" != "" ]; then +# FLAGS="$FLAGS --miner.sigfile private_key.txt" +# fi +#fi + +# Configure RPC. +FLAGS="$FLAGS --http --http.addr=0.0.0.0 --http.api=admin,debug,eth,net" +#FLAGS="$FLAGS --ws" + +# TODO +#if [ "$HIVE_TERMINAL_TOTAL_DIFFICULTY" != "" ]; then +# JWT_SECRET="0x7365637265747365637265747365637265747365637265747365637265747365" +# echo -n $JWT_SECRET > /jwt.secret +# FLAGS="$FLAGS --authrpc.addr=0.0.0.0 --authrpc.jwtsecret=/jwt.secret" +#fi + +# Configure NAT +FLAGS="$FLAGS --nat none" + +# Launch the main client. +echo "Running reth with flags: $FLAGS" +$reth node $FLAGS From 30a34193a9789ca405bede4146640ee86f858810 Mon Sep 17 00:00:00 2001 From: Dan Cline <6798349+Rjected@users.noreply.github.com> Date: Fri, 17 Feb 2023 05:55:57 -0500 Subject: [PATCH 02/23] revert mapper changes (#2) --- clients/reth/mapper.jq | 32 -------------------------------- 1 file changed, 32 deletions(-) diff --git a/clients/reth/mapper.jq b/clients/reth/mapper.jq index ee5cdd73e5..3c0da79ed6 100644 --- a/clients/reth/mapper.jq +++ b/clients/reth/mapper.jq @@ -28,40 +28,8 @@ def to_bool: end ; -# Converts number to hex, from https://rosettacode.org/wiki/Non-decimal_radices/Convert#jq -def int_to_hex: - def stream: - recurse(if . > 0 then ./16|floor else empty end) | . % 16 ; - if . == 0 then "0x0" - else "0x" + ([stream] | reverse | .[1:] | map(if .<10 then 48+. else 87+. end) | implode) - end -; - -# Converts decimal number in string to hex. -def to_hex: - if . != null and startswith("0x") then . else - if (. != null and . != "") then .|tonumber|int_to_hex else . end - end -; - -# Zero-pads hex string. -def infix_zeros_to_length(s;l): - if . != null then - (.[0:s])+("0"*(l-(.|length)))+(.[s:l]) - else . - end -; - # Replace config in input. . + { - "coinbase": (if .coinbase == null then "0x0000000000000000000000000000000000000000" else .coinbase end)|to_hex, - "difficulty": (if .difficulty == null then "0x00" else .difficulty end)|to_hex|infix_zeros_to_length(2;8), - "extraData": (if .extraData == null then "0x00" else .extraData end)|to_hex, - "gasLimit": (if .gasLimit == null then "0x00" else .gasLimit end)|to_hex|infix_zeros_to_length(2;8), - "mixHash": (if .mixHash == null then "0x00" else .mixHash end)|to_hex|infix_zeros_to_length(2;66), - "nonce": (if .nonce == null then "0x00" else .nonce end)|to_hex, - "parentHash": (if .parentHash == null then "0x0000000000000000000000000000000000000000000000000000000000000000" else .parentHash end)|to_hex, - "timestamp": (if .timestamp == null then "0x00" else .timestamp end)|to_hex, "config": { "ethash": (if env.HIVE_CLIQUE_PERIOD then null else {} end), "clique": (if env.HIVE_CLIQUE_PERIOD == null then null else { From 9ab46aa0e08369e624b5114b1e8d28f715452d4c Mon Sep 17 00:00:00 2001 From: Dan Cline <6798349+Rjected@users.noreply.github.com> Date: Fri, 17 Feb 2023 14:17:14 -0500 Subject: [PATCH 03/23] feat: add shanghai fork timestamp to mapper --- clients/reth/mapper.jq | 1 + 1 file changed, 1 insertion(+) diff --git a/clients/reth/mapper.jq b/clients/reth/mapper.jq index 3c0da79ed6..c033bd22ce 100644 --- a/clients/reth/mapper.jq +++ b/clients/reth/mapper.jq @@ -51,5 +51,6 @@ def to_bool: "berlinBlock": env.HIVE_FORK_BERLIN|to_int, "londonBlock": env.HIVE_FORK_LONDON|to_int, "terminalTotalDifficulty": env.HIVE_TERMINAL_TOTAL_DIFFICULTY|to_int, + "shanghaiTime": env.HIVE_SHANGHAI_TIMESTAMP|to_int, }|remove_empty } From 9a2e3901fe7fc61efac0b9a6e9437bd40e00cb19 Mon Sep 17 00:00:00 2001 From: Dan Cline <6798349+Rjected@users.noreply.github.com> Date: Fri, 24 Feb 2023 20:21:09 -0500 Subject: [PATCH 04/23] fix: use new reth import UX (#4) --- clients/reth/reth.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/clients/reth/reth.sh b/clients/reth/reth.sh index 0da4d6605c..b9152be2ef 100644 --- a/clients/reth/reth.sh +++ b/clients/reth/reth.sh @@ -87,7 +87,7 @@ set +ex echo "Loading initial blockchain..." if [ -f /chain.rlp ]; then echo "Loading initial blockchain..." - $reth import $FLAGS --path /chain.rlp + $reth import $FLAGS /chain.rlp else echo "Warning: chain.rlp not found." fi @@ -98,7 +98,7 @@ if [ -d /blocks ]; then echo "Loading remaining individual blocks..." for file in $(ls /blocks | sort -n); do echo "Importing " $file - $reth import $FLAGS --path /blocks/$file + $reth import $FLAGS /blocks/$file done else echo "Warning: blocks folder not found." From 6fdaabae6aa8f2286314c271cde274f0926f0c95 Mon Sep 17 00:00:00 2001 From: Dan Cline <6798349+Rjected@users.noreply.github.com> Date: Fri, 24 Feb 2023 22:13:58 -0500 Subject: [PATCH 05/23] use bootnodes in online steps only (#5) --- clients/reth/reth.sh | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/clients/reth/reth.sh b/clients/reth/reth.sh index b9152be2ef..06d4fdbb9c 100644 --- a/clients/reth/reth.sh +++ b/clients/reth/reth.sh @@ -50,11 +50,6 @@ esac mkdir /reth-hive-db FLAGS="$FLAGS --db /reth-hive-db" -# It doesn't make sense to dial out, use only a pre-set bootnode. -if [ "$HIVE_BOOTNODE" != "" ]; then - FLAGS="$FLAGS --bootnodes=$HIVE_BOOTNODE" -fi - # TODO If a specific network ID is requested, use that #if [ "$HIVE_NETWORK_ID" != "" ]; then # FLAGS="$FLAGS --networkid $HIVE_NETWORK_ID" @@ -104,6 +99,12 @@ else echo "Warning: blocks folder not found." fi +# Only set boot nodes in online steps +# It doesn't make sense to dial out, use only a pre-set bootnode. +if [ "$HIVE_BOOTNODE" != "" ]; then + FLAGS="$FLAGS --bootnodes=$HIVE_BOOTNODE" +fi + set -ex # Configure any mining operation From 72ec39de2fc67dfa42dd0b0188891b3955c7aae4 Mon Sep 17 00:00:00 2001 From: Dan Cline <6798349+Rjected@users.noreply.github.com> Date: Tue, 28 Feb 2023 11:30:22 -0500 Subject: [PATCH 06/23] uncomment JWT section (#6) remove 0x from JWT secret --- clients/reth/reth.sh | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/clients/reth/reth.sh b/clients/reth/reth.sh index 06d4fdbb9c..30028369ce 100644 --- a/clients/reth/reth.sh +++ b/clients/reth/reth.sh @@ -133,12 +133,11 @@ set -ex FLAGS="$FLAGS --http --http.addr=0.0.0.0 --http.api=admin,debug,eth,net" #FLAGS="$FLAGS --ws" -# TODO -#if [ "$HIVE_TERMINAL_TOTAL_DIFFICULTY" != "" ]; then -# JWT_SECRET="0x7365637265747365637265747365637265747365637265747365637265747365" -# echo -n $JWT_SECRET > /jwt.secret -# FLAGS="$FLAGS --authrpc.addr=0.0.0.0 --authrpc.jwtsecret=/jwt.secret" -#fi +if [ "$HIVE_TERMINAL_TOTAL_DIFFICULTY" != "" ]; then + JWT_SECRET="7365637265747365637265747365637265747365637265747365637265747365" + echo -n $JWT_SECRET > /jwt.secret + FLAGS="$FLAGS --authrpc.addr=0.0.0.0 --authrpc.jwtsecret=/jwt.secret" +fi # Configure NAT FLAGS="$FLAGS --nat none" From b2c4bb592196be4888b322ea853c6d979c458c57 Mon Sep 17 00:00:00 2001 From: Dan Cline <6798349+Rjected@users.noreply.github.com> Date: Wed, 8 Mar 2023 20:59:08 -0500 Subject: [PATCH 07/23] use patched chain files for rpc-compat (#7) use fork with correct withdrawals chain --- simulators/ethereum/rpc-compat/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/simulators/ethereum/rpc-compat/Dockerfile b/simulators/ethereum/rpc-compat/Dockerfile index d338a2c1ef..97a3413763 100644 --- a/simulators/ethereum/rpc-compat/Dockerfile +++ b/simulators/ethereum/rpc-compat/Dockerfile @@ -3,7 +3,7 @@ FROM golang:1-alpine as builder RUN apk add --update git ca-certificates gcc musl-dev linux-headers # Clone the tests repo. -RUN git clone --depth 1 https://github.com/ethereum/execution-apis.git /execution-apis +RUN git clone --depth 1 https://github.com/paradigmxyz/execution-apis.git /execution-apis # To run local tests, copy the directory into the same as the simulator and # uncomment the line below From 578c3b1df67b7165f508318aedc3845f3d4d0ffe Mon Sep 17 00:00:00 2001 From: Dan Cline <6798349+Rjected@users.noreply.github.com> Date: Wed, 15 Mar 2023 16:10:29 -0400 Subject: [PATCH 08/23] add shanghai timestamp to rpc-compat tests (#8) --- clients/reth/reth.sh | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/clients/reth/reth.sh b/clients/reth/reth.sh index 30028369ce..67d0ec00f7 100644 --- a/clients/reth/reth.sh +++ b/clients/reth/reth.sh @@ -133,6 +133,12 @@ set -ex FLAGS="$FLAGS --http --http.addr=0.0.0.0 --http.api=admin,debug,eth,net" #FLAGS="$FLAGS --ws" +# Enable continuous sync if mining is disabled +# TODO +# if [ "$HIVE_MINER" == "" ]; then +# FLAGS="$FLAGS --debug.continuous" +# fi + if [ "$HIVE_TERMINAL_TOTAL_DIFFICULTY" != "" ]; then JWT_SECRET="7365637265747365637265747365637265747365637265747365637265747365" echo -n $JWT_SECRET > /jwt.secret From 4385a1eed5d2c48704d29687b52979475a590552 Mon Sep 17 00:00:00 2001 From: Dan Cline <6798349+Rjected@users.noreply.github.com> Date: Sun, 19 Mar 2023 20:21:19 -0400 Subject: [PATCH 09/23] add continuous condition for sync test (#9) --- clients/reth/reth.sh | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/clients/reth/reth.sh b/clients/reth/reth.sh index 67d0ec00f7..77b584a82f 100644 --- a/clients/reth/reth.sh +++ b/clients/reth/reth.sh @@ -105,8 +105,6 @@ if [ "$HIVE_BOOTNODE" != "" ]; then FLAGS="$FLAGS --bootnodes=$HIVE_BOOTNODE" fi -set -ex - # Configure any mining operation # TODO #if [ "$HIVE_MINER" != "" ]; then @@ -134,10 +132,14 @@ FLAGS="$FLAGS --http --http.addr=0.0.0.0 --http.api=admin,debug,eth,net" #FLAGS="$FLAGS --ws" # Enable continuous sync if mining is disabled -# TODO -# if [ "$HIVE_MINER" == "" ]; then -# FLAGS="$FLAGS --debug.continuous" -# fi +if [ "$HIVE_MINER" == "" ]; then + # if there is no chain file then we need to sync with the continuous + # download mode + if [ ! -f /chain.rlp ]; then + FLAGS="$FLAGS --debug.continuous" + fi +fi + if [ "$HIVE_TERMINAL_TOTAL_DIFFICULTY" != "" ]; then JWT_SECRET="7365637265747365637265747365637265747365637265747365637265747365" From 0e0230331b6ea8b7df035cd56d768ce565563c44 Mon Sep 17 00:00:00 2001 From: Dan Cline <6798349+Rjected@users.noreply.github.com> Date: Wed, 22 Mar 2023 18:52:59 -0400 Subject: [PATCH 10/23] fix: add remaining forks to mapper and rpc-compat suite (#10) * fix: add remaining forks to mapper and rpc-compat suite * go fmt --- clients/reth/mapper.jq | 3 +++ clients/reth/reth.sh | 4 ++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/clients/reth/mapper.jq b/clients/reth/mapper.jq index c033bd22ce..858223a2af 100644 --- a/clients/reth/mapper.jq +++ b/clients/reth/mapper.jq @@ -50,7 +50,10 @@ def to_bool: "muirGlacierBlock": env.HIVE_FORK_MUIR_GLACIER|to_int, "berlinBlock": env.HIVE_FORK_BERLIN|to_int, "londonBlock": env.HIVE_FORK_LONDON|to_int, + "arrowGlacierBlock": env.HIVE_FORK_ARROW_GLACIER|to_int, + "grayGlacierBlock": env.HIVE_FORK_GRAY_GLACIER|to_int, "terminalTotalDifficulty": env.HIVE_TERMINAL_TOTAL_DIFFICULTY|to_int, + "terminalTotalDifficultyPassed": env.HIVE_TERMINAL_TOTAL_DIFFICULTY_PASSED|to_bool, "shanghaiTime": env.HIVE_SHANGHAI_TIMESTAMP|to_int, }|remove_empty } diff --git a/clients/reth/reth.sh b/clients/reth/reth.sh index 77b584a82f..21c3e9cda9 100644 --- a/clients/reth/reth.sh +++ b/clients/reth/reth.sh @@ -82,7 +82,7 @@ set +ex echo "Loading initial blockchain..." if [ -f /chain.rlp ]; then echo "Loading initial blockchain..." - $reth import $FLAGS /chain.rlp + RUST_LOG=info $reth import $FLAGS /chain.rlp else echo "Warning: chain.rlp not found." fi @@ -152,4 +152,4 @@ FLAGS="$FLAGS --nat none" # Launch the main client. echo "Running reth with flags: $FLAGS" -$reth node $FLAGS +RUST_LOG=info $reth node $FLAGS From d97991fe43dbadd8f40805ed6f687d0b8c3baf12 Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Thu, 23 Mar 2023 21:28:30 +0100 Subject: [PATCH 11/23] chore: enable ws (#11) --- clients/reth/reth.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/clients/reth/reth.sh b/clients/reth/reth.sh index 21c3e9cda9..315f2aa5e6 100644 --- a/clients/reth/reth.sh +++ b/clients/reth/reth.sh @@ -128,8 +128,8 @@ fi #fi # Configure RPC. -FLAGS="$FLAGS --http --http.addr=0.0.0.0 --http.api=admin,debug,eth,net" -#FLAGS="$FLAGS --ws" +FLAGS="$FLAGS --http --http.addr=0.0.0.0 --http.api=admin,debug,eth,net,web3" +FLAGS="$FLAGS --ws --ws.addr=0.0.0.0 --ws.api=admin,debug,eth,net,web3" # Enable continuous sync if mining is disabled if [ "$HIVE_MINER" == "" ]; then From 4955f41460cdfff02d1d9b62bd139f3d9c38cbb5 Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Thu, 23 Mar 2023 21:29:12 +0100 Subject: [PATCH 12/23] chore: disable ascii (#12) --- clients/reth/reth.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/clients/reth/reth.sh b/clients/reth/reth.sh index 315f2aa5e6..d114c50ccb 100644 --- a/clients/reth/reth.sh +++ b/clients/reth/reth.sh @@ -152,4 +152,5 @@ FLAGS="$FLAGS --nat none" # Launch the main client. echo "Running reth with flags: $FLAGS" +export RUST_LOG_STYLE=never RUST_LOG=info $reth node $FLAGS From aa7f74f684761578c4bf009ddf174c71a124b3a3 Mon Sep 17 00:00:00 2001 From: Dan Cline <6798349+Rjected@users.noreply.github.com> Date: Fri, 31 Mar 2023 19:01:33 -0400 Subject: [PATCH 13/23] feat: ignore error difference when comparing rpc output (#16) * feat: ignore error difference when comparing rpc output * only ignore rpc error message --- simulators/ethereum/rpc-compat/main.go | 29 +++++++++++++++++++++++--- 1 file changed, 26 insertions(+), 3 deletions(-) diff --git a/simulators/ethereum/rpc-compat/main.go b/simulators/ethereum/rpc-compat/main.go index 6bf81d1b9f..42e7d31481 100644 --- a/simulators/ethereum/rpc-compat/main.go +++ b/simulators/ethereum/rpc-compat/main.go @@ -123,11 +123,34 @@ func runTest(t *hivesim.T, c *hivesim.Client, data []byte) error { return fmt.Errorf("invalid test, response before request") } want := []byte(strings.TrimSpace(line)[3:]) // trim leading "<< " - // Now compare. - d, err := diff.New().Compare(resp, want) - if err != nil { + + // Unmarshal to map[string]interface{} to compare. + var wantMap map[string]interface{} + if err := json.Unmarshal(want, &wantMap); err != nil { + return fmt.Errorf("failed to unmarshal value: %s\n", err) + } + + var respMap map[string]interface{} + if err := json.Unmarshal(resp, &respMap); err != nil { return fmt.Errorf("failed to unmarshal value: %s\n", err) } + + if c.Type == "reth" { + // If errors exist in both, make them equal. + // While error comparison might be desirable, error text across + // clients is not standardized, so we should not compare them. + if wantMap["error"] != nil && respMap["error"] != nil { + respError := respMap["error"].(map[string]interface{}) + wantError := wantMap["error"].(map[string]interface{}) + respError["message"] = wantError["message"] + // cast back into the any type + respMap["error"] = respError + } + } + + // Now compare. + d := diff.New().CompareObjects(respMap, wantMap) + // If there is a discrepancy, return error. if d.Modified() { var got map[string]interface{} From 0b745c5cb7970bc4fd89500bedc2c6821fd9397a Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Sat, 1 Apr 2023 20:56:29 +0200 Subject: [PATCH 14/23] feat: enable --auto-mine if clique is set (#15) --- clients/reth/reth.sh | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/clients/reth/reth.sh b/clients/reth/reth.sh index d114c50ccb..aded6fb5d4 100644 --- a/clients/reth/reth.sh +++ b/clients/reth/reth.sh @@ -127,6 +127,11 @@ fi # fi #fi +# If clique is expected enable auto-mine +if [ "$HIVE_CLIQUE_PRIVATEKEY" != "" ]; then + FLAGS="$FLAGS --auto-mine" +fi + # Configure RPC. FLAGS="$FLAGS --http --http.addr=0.0.0.0 --http.api=admin,debug,eth,net,web3" FLAGS="$FLAGS --ws --ws.addr=0.0.0.0 --ws.api=admin,debug,eth,net,web3" From 79d81974911bda9ea9e87d6c29a3fc5b3d58464f Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Wed, 5 Apr 2023 21:17:11 +0200 Subject: [PATCH 15/23] chore: move RUST_LOG_STYLE to top (#19) --- clients/reth/reth.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/clients/reth/reth.sh b/clients/reth/reth.sh index aded6fb5d4..dd00fd11d7 100644 --- a/clients/reth/reth.sh +++ b/clients/reth/reth.sh @@ -36,6 +36,9 @@ # Immediately abort the script on any error encountered set -ex +# no ansi colors +export RUST_LOG_STYLE=never + reth=/usr/local/bin/reth case "$HIVE_LOGLEVEL" in @@ -157,5 +160,4 @@ FLAGS="$FLAGS --nat none" # Launch the main client. echo "Running reth with flags: $FLAGS" -export RUST_LOG_STYLE=never RUST_LOG=info $reth node $FLAGS From f29fd09cba49f93871686c256331604fd9cc4424 Mon Sep 17 00:00:00 2001 From: Dan Cline <6798349+Rjected@users.noreply.github.com> Date: Thu, 20 Apr 2023 00:07:33 -0400 Subject: [PATCH 16/23] feat: ignore error codes in error expects (#20) --- simulators/ethereum/rpc-compat/main.go | 1 + 1 file changed, 1 insertion(+) diff --git a/simulators/ethereum/rpc-compat/main.go b/simulators/ethereum/rpc-compat/main.go index 42e7d31481..2543cf9573 100644 --- a/simulators/ethereum/rpc-compat/main.go +++ b/simulators/ethereum/rpc-compat/main.go @@ -143,6 +143,7 @@ func runTest(t *hivesim.T, c *hivesim.Client, data []byte) error { respError := respMap["error"].(map[string]interface{}) wantError := wantMap["error"].(map[string]interface{}) respError["message"] = wantError["message"] + respError["code"] = wantError["code"] // cast back into the any type respMap["error"] = respError } From 7f7de8d6cd4a1b5c23699a6c92b1d86cfb5ebbc6 Mon Sep 17 00:00:00 2001 From: Dan Cline <6798349+Rjected@users.noreply.github.com> Date: Wed, 26 Apr 2023 15:52:27 -0400 Subject: [PATCH 17/23] fix: use proper bash existence check for continuous (#21) --- clients/reth/reth.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/clients/reth/reth.sh b/clients/reth/reth.sh index dd00fd11d7..da56e87cd4 100644 --- a/clients/reth/reth.sh +++ b/clients/reth/reth.sh @@ -139,8 +139,8 @@ fi FLAGS="$FLAGS --http --http.addr=0.0.0.0 --http.api=admin,debug,eth,net,web3" FLAGS="$FLAGS --ws --ws.addr=0.0.0.0 --ws.api=admin,debug,eth,net,web3" -# Enable continuous sync if mining is disabled -if [ "$HIVE_MINER" == "" ]; then +# Enable continuous sync if there is no CL (ttd == "") and mining is disabled +if [ -z "${HIVE_MINER}" ] && [ -z "${HIVE_CLIQUE_PRIVATEKEY}" ] && [ -z "${HIVE_TERMINAL_TOTAL_DIFFICULTY}" ]; then # if there is no chain file then we need to sync with the continuous # download mode if [ ! -f /chain.rlp ]; then From 362b3e8bcaaad48eae3bb99f5498493955ee2141 Mon Sep 17 00:00:00 2001 From: Dan Cline <6798349+Rjected@users.noreply.github.com> Date: Fri, 28 Apr 2023 04:12:38 -0400 Subject: [PATCH 18/23] fix: use proper bash existence check for auto-mine (#22) --- clients/reth/reth.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/clients/reth/reth.sh b/clients/reth/reth.sh index da56e87cd4..2723b10030 100644 --- a/clients/reth/reth.sh +++ b/clients/reth/reth.sh @@ -131,7 +131,7 @@ fi #fi # If clique is expected enable auto-mine -if [ "$HIVE_CLIQUE_PRIVATEKEY" != "" ]; then +if [ -n "${HIVE_CLIQUE_PRIVATEKEY}" ] || [ -n "${HIVE_MINER}" ]; then FLAGS="$FLAGS --auto-mine" fi From 452485a3ae5d04e2222a7820ba1fe99a06670720 Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Wed, 3 May 2023 09:53:19 +0200 Subject: [PATCH 19/23] chore: remove duplicate output (#23) --- clients/reth/reth.sh | 1 - 1 file changed, 1 deletion(-) diff --git a/clients/reth/reth.sh b/clients/reth/reth.sh index 2723b10030..0465965e93 100644 --- a/clients/reth/reth.sh +++ b/clients/reth/reth.sh @@ -84,7 +84,6 @@ set +ex # Load the test chain if present echo "Loading initial blockchain..." if [ -f /chain.rlp ]; then - echo "Loading initial blockchain..." RUST_LOG=info $reth import $FLAGS /chain.rlp else echo "Warning: chain.rlp not found." From 152d2dac89aa46ef35aa8bc88f0a4583ed30edc3 Mon Sep 17 00:00:00 2001 From: Dan Cline <6798349+Rjected@users.noreply.github.com> Date: Wed, 3 May 2023 11:59:27 +0200 Subject: [PATCH 20/23] use datadir instead of db arg in hive (#24) --- clients/reth/reth.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/clients/reth/reth.sh b/clients/reth/reth.sh index 0465965e93..e829cfd213 100644 --- a/clients/reth/reth.sh +++ b/clients/reth/reth.sh @@ -50,8 +50,8 @@ case "$HIVE_LOGLEVEL" in esac # Create the data directory. -mkdir /reth-hive-db -FLAGS="$FLAGS --db /reth-hive-db" +mkdir /reth-hive-datadir +FLAGS="$FLAGS --datadir /reth-hive-datadir" # TODO If a specific network ID is requested, use that #if [ "$HIVE_NETWORK_ID" != "" ]; then From e49ad3055fc5362eb5e25972935f39631223753c Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Wed, 3 May 2023 15:38:45 +0200 Subject: [PATCH 21/23] fix: only run --auto-mine when clique requested (#25) --- clients/reth/reth.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/clients/reth/reth.sh b/clients/reth/reth.sh index e829cfd213..1a4d092205 100644 --- a/clients/reth/reth.sh +++ b/clients/reth/reth.sh @@ -130,7 +130,7 @@ fi #fi # If clique is expected enable auto-mine -if [ -n "${HIVE_CLIQUE_PRIVATEKEY}" ] || [ -n "${HIVE_MINER}" ]; then +if [ -n "${HIVE_CLIQUE_PRIVATEKEY}" ] || [ -n "${HIVE_CLIQUE_PERIOD}" ]; then FLAGS="$FLAGS --auto-mine" fi From e5a04a59531b93bc40ccbabf738cf921aa3a46db Mon Sep 17 00:00:00 2001 From: Dan Cline <6798349+Rjected@users.noreply.github.com> Date: Fri, 4 Aug 2023 14:57:48 -0400 Subject: [PATCH 22/23] Remove broad error checks and use upstream execution-apis (#27) remove broad error checks and use upstream execution-apis --- simulators/ethereum/rpc-compat/Dockerfile | 2 +- simulators/ethereum/rpc-compat/main.go | 30 +++-------------------- 2 files changed, 4 insertions(+), 28 deletions(-) diff --git a/simulators/ethereum/rpc-compat/Dockerfile b/simulators/ethereum/rpc-compat/Dockerfile index 97a3413763..d338a2c1ef 100644 --- a/simulators/ethereum/rpc-compat/Dockerfile +++ b/simulators/ethereum/rpc-compat/Dockerfile @@ -3,7 +3,7 @@ FROM golang:1-alpine as builder RUN apk add --update git ca-certificates gcc musl-dev linux-headers # Clone the tests repo. -RUN git clone --depth 1 https://github.com/paradigmxyz/execution-apis.git /execution-apis +RUN git clone --depth 1 https://github.com/ethereum/execution-apis.git /execution-apis # To run local tests, copy the directory into the same as the simulator and # uncomment the line below diff --git a/simulators/ethereum/rpc-compat/main.go b/simulators/ethereum/rpc-compat/main.go index 2543cf9573..6bf81d1b9f 100644 --- a/simulators/ethereum/rpc-compat/main.go +++ b/simulators/ethereum/rpc-compat/main.go @@ -123,35 +123,11 @@ func runTest(t *hivesim.T, c *hivesim.Client, data []byte) error { return fmt.Errorf("invalid test, response before request") } want := []byte(strings.TrimSpace(line)[3:]) // trim leading "<< " - - // Unmarshal to map[string]interface{} to compare. - var wantMap map[string]interface{} - if err := json.Unmarshal(want, &wantMap); err != nil { - return fmt.Errorf("failed to unmarshal value: %s\n", err) - } - - var respMap map[string]interface{} - if err := json.Unmarshal(resp, &respMap); err != nil { + // Now compare. + d, err := diff.New().Compare(resp, want) + if err != nil { return fmt.Errorf("failed to unmarshal value: %s\n", err) } - - if c.Type == "reth" { - // If errors exist in both, make them equal. - // While error comparison might be desirable, error text across - // clients is not standardized, so we should not compare them. - if wantMap["error"] != nil && respMap["error"] != nil { - respError := respMap["error"].(map[string]interface{}) - wantError := wantMap["error"].(map[string]interface{}) - respError["message"] = wantError["message"] - respError["code"] = wantError["code"] - // cast back into the any type - respMap["error"] = respError - } - } - - // Now compare. - d := diff.New().CompareObjects(respMap, wantMap) - // If there is a discrepancy, return error. if d.Modified() { var got map[string]interface{} From d3c1cbfeb25d1464268d8204895703727a798695 Mon Sep 17 00:00:00 2001 From: Dan Cline <6798349+Rjected@users.noreply.github.com> Date: Fri, 4 Aug 2023 15:43:32 -0400 Subject: [PATCH 23/23] chore: use tag instead of branch (#28) --- clients/reth/Dockerfile | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/clients/reth/Dockerfile b/clients/reth/Dockerfile index e4281cd46d..27c0789474 100644 --- a/clients/reth/Dockerfile +++ b/clients/reth/Dockerfile @@ -1,5 +1,7 @@ -ARG branch=main -FROM paradigmxyz/reth:$branch +ARG baseimage=paradigmxyz/reth +ARG tag=main + +FROM $baseimage:$tag as builder # Install script tools. RUN apt-get update -y