Skip to content

Commit b32641c

Browse files
clients/ethereumjs: add faster local test dockerfile (#940)
1 parent 4427675 commit b32641c

File tree

3 files changed

+155
-4
lines changed

3 files changed

+155
-4
lines changed

clients/ethereumjs/.dockerignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
ethereumjs-monorepo/packages/ethereum-tests
2+
ethereumjs-monorepo/packages/*/node_modules
3+
ethereumjs-monorepo/packages/vm/benchmarks
4+
ethereumjs-monorepo/node_modules
5+
!ethereumjs-monorepo/node_modules/@ethereumjs

clients/ethereumjs/Dockerfile.local

Lines changed: 56 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,23 +6,75 @@ FROM node:18-alpine
66
RUN apk update && apk add --no-cache bash git jq curl python3 gcc make g++ \
77
&& rm -rf /var/cache/apk/*
88

9+
RUN npm i -g ts-node
10+
911
# Default local client path: clients/ethereumjs/<ethereumjs-monorepo>
1012
ARG local_path=ethereumjs-monorepo
11-
COPY $local_path ethereumjs-monorepo
13+
14+
COPY ${local_path}/config ethereumjs-monorepo/config
15+
COPY ${local_path}/package-lock.json ethereumjs-monorepo/package-lock.json
16+
COPY ${local_path}/package.json ethereumjs-monorepo/package.json
17+
COPY ${local_path}/scripts ethereumjs-monorepo/scripts
18+
19+
COPY ${local_path}/packages/block/package.json ethereumjs-monorepo/packages/block/package.json
20+
COPY ${local_path}/packages/blockchain/package.json ethereumjs-monorepo/packages/blockchain/package.json
21+
COPY ${local_path}/packages/client/package.json ethereumjs-monorepo/packages/client/package.json
22+
COPY ${local_path}/packages/common/package.json ethereumjs-monorepo/packages/common/package.json
23+
COPY ${local_path}/packages/devp2p/package.json ethereumjs-monorepo/packages/devp2p/package.json
24+
COPY ${local_path}/packages/ethash/package.json ethereumjs-monorepo/packages/ethash/package.json
25+
COPY ${local_path}/packages/evm/package.json ethereumjs-monorepo/packages/evm/package.json
26+
COPY ${local_path}/packages/genesis/package.json ethereumjs-monorepo/packages/genesis/package.json
27+
COPY ${local_path}/packages/rlp/package.json ethereumjs-monorepo/packages/rlp/package.json
28+
COPY ${local_path}/packages/statemanager/package.json ethereumjs-monorepo/packages/statemanager/package.json
29+
COPY ${local_path}/packages/trie/package.json ethereumjs-monorepo/packages/trie/package.json
30+
COPY ${local_path}/packages/tx/package.json ethereumjs-monorepo/packages/tx/package.json
31+
COPY ${local_path}/packages/util/package.json ethereumjs-monorepo/packages/util/package.json
32+
COPY ${local_path}/packages/verkle/package.json ethereumjs-monorepo/packages/verkle/package.json
33+
COPY ${local_path}/packages/vm/package.json ethereumjs-monorepo/packages/vm/package.json
34+
COPY ${local_path}/packages/wallet/package.json ethereumjs-monorepo/packages/wallet/package.json
35+
36+
# for npm run prepare
37+
RUN cd ethereumjs-monorepo && git init
38+
39+
RUN cd ethereumjs-monorepo && cp package.json package.json.bak && npm pkg set scripts.postinstall="echo no-postinstall"
1240
RUN cd ethereumjs-monorepo && npm i
41+
RUN cd ethereumjs-monorepo && cp package.json.bak package.json && rm package.json.bak
42+
43+
COPY ${local_path}/node_modules/@ethereumjs ethereumjs-monorepo/node_modules/@ethereumjs
44+
45+
COPY ${local_path}/packages/rlp ethereumjs-monorepo/packages/rlp
46+
COPY ${local_path}/packages/util ethereumjs-monorepo/packages/util
47+
COPY ${local_path}/packages/verkle ethereumjs-monorepo/packages/verkle
48+
COPY ${local_path}/packages/wallet ethereumjs-monorepo/packages/wallet
49+
COPY ${local_path}/packages/common ethereumjs-monorepo/packages/common
50+
COPY ${local_path}/packages/devp2p ethereumjs-monorepo/packages/devp2p
51+
COPY ${local_path}/packages/genesis ethereumjs-monorepo/packages/genesis
52+
COPY ${local_path}/packages/trie ethereumjs-monorepo/packages/trie
53+
COPY ${local_path}/packages/statemanager ethereumjs-monorepo/packages/statemanager
54+
COPY ${local_path}/packages/tx ethereumjs-monorepo/packages/tx
55+
COPY ${local_path}/packages/evm ethereumjs-monorepo/packages/evm
56+
COPY ${local_path}/packages/block ethereumjs-monorepo/packages/block
57+
COPY ${local_path}/packages/ethash ethereumjs-monorepo/packages/ethash
58+
COPY ${local_path}/packages/blockchain ethereumjs-monorepo/packages/blockchain
59+
COPY ${local_path}/packages/vm ethereumjs-monorepo/packages/vm
60+
61+
RUN cd ethereumjs-monorepo/packages/client && cp package.json package.json.bak && npm pkg set scripts.build="echo no-build"
62+
RUN cd ethereumjs-monorepo && npm run build --workspaces
63+
64+
COPY ${local_path}/packages/client ethereumjs-monorepo/packages/client
1365

1466
# Create version.txt
1567
RUN cd ethereumjs-monorepo/packages/client && npm ethereumjs --version > /version.txt
1668

1769
# Add genesis mapper script, startup script, and enode URL retriever script
1870
ADD genesis.json /genesis.json
1971
ADD mapper.jq /mapper.jq
20-
ADD ethereumjs.sh /ethereumjs.sh
72+
ADD ethereumjs-local.sh /ethereumjs-local.sh
2173
ADD enode.sh /hive-bin/enode.sh
2274
ADD jwtsecret /jwtsecret
2375

2476
# Set execute permissions for scripts
25-
RUN chmod +x /ethereumjs.sh /hive-bin/enode.sh
77+
RUN chmod +x /ethereumjs-local.sh /hive-bin/enode.sh
2678

2779
# Expose networking ports
2880
EXPOSE 8545 8546 8551 8547 30303 30303/udp
@@ -32,4 +84,4 @@ EXPOSE 8545 8546 8551 8547 30303 30303/udp
3284
# since memory may spike during certain network conditions.
3385
ENV NODE_OPTIONS=--max_old_space_size=6144
3486

35-
ENTRYPOINT ["/ethereumjs.sh"]
87+
ENTRYPOINT ["/ethereumjs-local.sh"]
Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
#!/bin/bash
2+
3+
# Startup script to initialize and boot a ethereum-js instance.
4+
#
5+
# This script assumes the following files:
6+
# - `genesis.json` file is located in the filesystem root (mandatory)
7+
# - `chain.rlp` file is located in the filesystem root (optional)
8+
# - `blocks` folder is located in the filesystem root (optional)
9+
# - `keys` folder is located in the filesystem root (optional)
10+
#
11+
# This script assumes the following environment variables:
12+
#
13+
# - HIVE_BOOTNODE enode URL of the remote bootstrap node
14+
# - HIVE_NETWORK_ID network ID number to use for the eth protocol
15+
# - HIVE_NODETYPE sync and pruning selector (archive, full, light)
16+
#
17+
# Forks:
18+
#
19+
# - HIVE_FORK_HOMESTEAD block number of the homestead hard-fork transition
20+
# - HIVE_FORK_DAO_BLOCK block number of the DAO hard-fork transition
21+
# - HIVE_FORK_DAO_VOTE whether the node support (or opposes) the DAO fork
22+
# - HIVE_FORK_TANGERINE block number of Tangerine Whistle transition
23+
# - HIVE_FORK_SPURIOUS block number of Spurious Dragon transition
24+
# - HIVE_FORK_BYZANTIUM block number for Byzantium transition
25+
# - HIVE_FORK_CONSTANTINOPLE block number for Constantinople transition
26+
# - HIVE_FORK_PETERSBURG block number for ConstantinopleFix/PetersBurg transition
27+
# - HIVE_FORK_ISTANBUL block number for Istanbul transition
28+
# - HIVE_FORK_MUIRGLACIER block number for Muir Glacier transition
29+
# - HIVE_FORK_BERLIN block number for Berlin transition
30+
# - HIVE_FORK_LONDON block number for London
31+
#
32+
# Clique PoA:
33+
#
34+
# - HIVE_CLIQUE_PERIOD enables clique support. value is block time in seconds.
35+
# - HIVE_CLIQUE_PRIVATEKEY private key for clique mining
36+
#
37+
# Other:
38+
#
39+
# - HIVE_MINER enable mining. value is coinbase address.
40+
# - HIVE_MINER_EXTRA extra-data field to set for newly minted blocks
41+
# - HIVE_LOGLEVEL client loglevel (0-5)
42+
# - HIVE_GRAPHQL_ENABLED enables graphql on port 8545
43+
# - HIVE_LES_SERVER set to '1' to enable LES server
44+
45+
46+
# Immediately abort the script on any error encountered
47+
set -e
48+
49+
cd /ethereumjs-monorepo/packages/client/
50+
51+
ethereumjs="ts-node /ethereumjs-monorepo/packages/client/bin/cli.ts"
52+
FLAGS="--gethGenesis /genesis.json --rpc --rpcEngine --saveReceipts --rpcAddr 0.0.0.0 --rpcEngineAddr 0.0.0.0 --rpcEnginePort 8551 --ws false --logLevel debug --rpcDebug all --rpcDebugVerbose all --isSingleNode"
53+
54+
# Configure the chain.
55+
mv /genesis.json /genesis-input.json
56+
jq -f /mapper.jq /genesis-input.json > /genesis.json
57+
58+
# Dump genesis.
59+
if [ "$HIVE_LOGLEVEL" -lt 4 ]; then
60+
echo "Supplied genesis state (trimmed, use --sim.loglevel 4 or 5 for full output):"
61+
jq 'del(.alloc[] | select(.balance == "0x123450000000000000000"))' /genesis.json
62+
else
63+
echo "Supplied genesis state:"
64+
cat /genesis.json
65+
fi
66+
67+
# Import clique signing key.
68+
if [ "$HIVE_CLIQUE_PRIVATEKEY" != "" ]; then
69+
# Create password file.
70+
echo "Importing clique key..."
71+
echo -n "$HIVE_CLIQUE_PRIVATEKEY" > /private_key.txt
72+
# Ensure password file is used when running ethereumjs in mining mode.
73+
if [ "$HIVE_MINER" != "" ]; then
74+
FLAGS="$FLAGS --mine --unlock /private_key.txt --minerCoinbase $HIVE_MINER"
75+
fi
76+
fi
77+
78+
if [ "$HIVE_TERMINAL_TOTAL_DIFFICULTY" != "" ]; then
79+
FLAGS="$FLAGS --jwt-secret /jwtsecret"
80+
fi
81+
82+
# Load the test chain if present
83+
echo "Loading initial blockchain..."
84+
if [ -f /chain.rlp ]; then
85+
FLAGS="$FLAGS --loadBlocksFromRlp=/chain.rlp"
86+
else
87+
echo "Warning: chain.rlp not found."
88+
fi
89+
90+
if [ "$HIVE_BOOTNODE" != "" ]; then
91+
FLAGS="$FLAGS --bootnodes=$HIVE_BOOTNODE"
92+
fi
93+
echo "Running ethereumjs with flags $FLAGS"
94+
$ethereumjs $FLAGS

0 commit comments

Comments
 (0)