Skip to content

Commit 4894313

Browse files
committed
feat: support proofs ExEx
1 parent a294d4a commit 4894313

1 file changed

Lines changed: 74 additions & 1 deletion

File tree

reth/reth-entrypoint

Lines changed: 74 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@ DISCOVERY_PORT="${DISCOVERY_PORT:-30303}"
1111
P2P_PORT="${P2P_PORT:-30303}"
1212
ADDITIONAL_ARGS=""
1313
BINARY="./base-reth-node"
14+
NODE_TYPE="${NODE_TYPE:-base}"
15+
RETH_HISTORICAL_PROOFS="${RETH_HISTORICAL_PROOFS:-false}"
16+
RETH_HISTORICAL_PROOFS_STORAGE_PATH="${RETH_HISTORICAL_PROOFS_STORAGE_PATH:-}"
17+
LOG_LEVEL="${LOG_LEVEL:-info}"
1418

1519
if [[ -z "${RETH_CHAIN:-}" ]]; then
1620
echo "expected RETH_CHAIN to be set" 1>&2
@@ -25,18 +29,87 @@ else
2529
echo "Running in vanilla node mode (no Flashblocks URL provided)"
2630
fi
2731

32+
case "$LOG_LEVEL" in
33+
"debug")
34+
LOG_LEVEL="vvvv"
35+
;;
36+
"warn")
37+
LOG_LEVEL="vv"
38+
;;
39+
"info"|*)
40+
LOG_LEVEL="vvv"
41+
;;
42+
esac
43+
2844
# Add pruning for base
2945
if [[ "${RETH_PRUNING_ARGS+x}" = x ]]; then
3046
echo "Adding pruning arguments: $RETH_PRUNING_ARGS"
3147
ADDITIONAL_ARGS="$ADDITIONAL_ARGS $RETH_PRUNING_ARGS"
3248
fi
3349

50+
if [[ "$RETH_HISTORICAL_PROOFS" == "true" && -n "$RETH_HISTORICAL_PROOFS_STORAGE_PATH" ]]; then
51+
# reth doesn't like starting an old database in RO mode, so we have to start the reth node, wait for it to start up, then shut it down first
52+
"$BINARY" node \
53+
-$LOG_LEVEL \
54+
--datadir="$RETH_DATA_DIR" \
55+
--log.stdout.format json \
56+
--http \
57+
--http.addr=127.0.0.1 \
58+
--http.port="$RPC_PORT" \
59+
--http.api=eth \
60+
--chain "$RETH_CHAIN" &
61+
62+
PID=$!
63+
64+
MAX_WAIT=$((60 * 60 * 6)) # 6 hours (static file manager init is slow)
65+
66+
# wait for json-rpc to return a block number greater than 0 (synced beyond genesis)
67+
while true; do
68+
RESPONSE=$(curl -s -X POST -H "Content-Type: application/json" -d '{"jsonrpc":"2.0","method":"eth_getBlockByNumber","params":["latest", false],"id":1}' http://127.0.0.1:"$RPC_PORT" 2>/dev/null || true)
69+
70+
if echo "$RESPONSE" | grep -q '"number":"0x0"'; then
71+
echo "waiting for reth node to sync beyond genesis block"
72+
elif echo "$RESPONSE" | grep -q '"result"'; then
73+
# curl succeeded and returned a valid result with block number != 0x0
74+
break
75+
else
76+
echo "waiting for reth node to start up"
77+
fi
78+
79+
sleep 1
80+
MAX_WAIT=$((MAX_WAIT - 1))
81+
if [ "$MAX_WAIT" -eq 0 ]; then
82+
echo "timed out waiting for reth node to start up"
83+
kill "$PID"
84+
exit 1
85+
fi
86+
done
87+
88+
# shut down gracefully
89+
kill "$PID"
90+
91+
wait "$PID"
92+
echo "reth node initialized"
93+
94+
ADDITIONAL_ARGS="$ADDITIONAL_ARGS --proofs-history --proofs-history.storage-path=$RETH_HISTORICAL_PROOFS_STORAGE_PATH"
95+
96+
# in this case, we need to run the init script first (idempotent)
97+
"$BINARY" proofs init \
98+
-$LOG_LEVEL \
99+
--log.stdout.format json \
100+
--chain "$RETH_CHAIN" \
101+
--datadir="$RETH_DATA_DIR" \
102+
--proofs-history.storage-path=$RETH_HISTORICAL_PROOFS_STORAGE_PATH
103+
104+
sleep 60
105+
fi
106+
34107
mkdir -p "$RETH_DATA_DIR"
35108
echo "Starting reth with additional args: $ADDITIONAL_ARGS"
36109
echo "$OP_NODE_L2_ENGINE_AUTH_RAW" > "$OP_NODE_L2_ENGINE_AUTH"
37110

38111
exec "$BINARY" node \
39-
-vvv \
112+
-$LOG_LEVEL \
40113
--datadir="$RETH_DATA_DIR" \
41114
--log.stdout.format json \
42115
--ws \

0 commit comments

Comments
 (0)