Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
14c8ceb
feat: reth (#1)
gakonst Feb 17, 2023
30a3419
revert mapper changes (#2)
Rjected Feb 17, 2023
9ab46aa
feat: add shanghai fork timestamp to mapper
Rjected Feb 17, 2023
9a2e390
fix: use new reth import UX (#4)
Rjected Feb 25, 2023
6fdaaba
use bootnodes in online steps only (#5)
Rjected Feb 25, 2023
72ec39d
uncomment JWT section (#6)
Rjected Feb 28, 2023
b2c4bb5
use patched chain files for rpc-compat (#7)
Rjected Mar 9, 2023
578c3b1
add shanghai timestamp to rpc-compat tests (#8)
Rjected Mar 15, 2023
4385a1e
add continuous condition for sync test (#9)
Rjected Mar 20, 2023
0e02303
fix: add remaining forks to mapper and rpc-compat suite (#10)
Rjected Mar 22, 2023
d97991f
chore: enable ws (#11)
mattsse Mar 23, 2023
4955f41
chore: disable ascii (#12)
mattsse Mar 23, 2023
aa7f74f
feat: ignore error difference when comparing rpc output (#16)
Rjected Mar 31, 2023
0b745c5
feat: enable --auto-mine if clique is set (#15)
mattsse Apr 1, 2023
79d8197
chore: move RUST_LOG_STYLE to top (#19)
mattsse Apr 5, 2023
f29fd09
feat: ignore error codes in error expects (#20)
Rjected Apr 20, 2023
7f7de8d
fix: use proper bash existence check for continuous (#21)
Rjected Apr 26, 2023
362b3e8
fix: use proper bash existence check for auto-mine (#22)
Rjected Apr 28, 2023
452485a
chore: remove duplicate output (#23)
mattsse May 3, 2023
152d2da
use datadir instead of db arg in hive (#24)
Rjected May 3, 2023
e49ad30
fix: only run --auto-mine when clique requested (#25)
mattsse May 3, 2023
e5a04a5
Remove broad error checks and use upstream execution-apis (#27)
Rjected Aug 4, 2023
d3c1cbf
chore: use tag instead of branch (#28)
Rjected Aug 4, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions clients/reth/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
ARG baseimage=paradigmxyz/reth
ARG tag=main

FROM $baseimage:$tag as builder

# 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"]
8 changes: 8 additions & 0 deletions clients/reth/enode.sh
Original file line number Diff line number Diff line change
@@ -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"
15 changes: 15 additions & 0 deletions clients/reth/genesis.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"coinbase" : "0x8888f1f195afa192cfee860698584c030f4c9db1",
"difficulty" : "0x020000",
"extraData" : "0x42",
"gasLimit" : "0x2fefd8",
"mixHash" : "0x2c85bcbce56429100b2108254bb56906257582aeafcbd682bc9af67a9f5aee46",
"nonce" : "0x78cc16f7b4f65485",
"parentHash" : "0x0000000000000000000000000000000000000000000000000000000000000000",
"timestamp" : "0x54c98c81",
"alloc" : {
"a94f5374fce5edbc8e2a8697c15331677e6ebf0b": {
"balance" : "0x09184e72a000"
}
}
}
59 changes: 59 additions & 0 deletions clients/reth/mapper.jq
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
# 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
;

# Replace config in input.
. + {
"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,
"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
}
162 changes: 162 additions & 0 deletions clients/reth/reth.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,162 @@
#!/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

# no ansi colors
export RUST_LOG_STYLE=never

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-datadir
FLAGS="$FLAGS --datadir /reth-hive-datadir"

# 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
RUST_LOG=info $reth import $FLAGS /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 /blocks/$file
done
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

# 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

# If clique is expected enable auto-mine
if [ -n "${HIVE_CLIQUE_PRIVATEKEY}" ] || [ -n "${HIVE_CLIQUE_PERIOD}" ]; 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"

# 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
FLAGS="$FLAGS --debug.continuous"
fi
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"

# Launch the main client.
echo "Running reth with flags: $FLAGS"
RUST_LOG=info $reth node $FLAGS