diff --git a/.env.mainnet b/.env.mainnet index c9d6badc..f599d5dc 100644 --- a/.env.mainnet +++ b/.env.mainnet @@ -52,3 +52,6 @@ OP_NODE_ROLLUP_LOAD_PROTOCOL_VERSIONS=true # OP_GETH_BOOTNODES=enode://87a32fd13bd596b2ffca97020e31aef4ddcc1bbd4b95bb633d16c1329f654f34049ed240a36b449fda5e5225d70fe40bc667f53c304b71f8e68fc9d448690b51@3.231.138.188:30301,enode://ca21ea8f176adb2e229ce2d700830c844af0ea941a1d8152a9513b966fe525e809c3a6c73a2c18a12b74ed6ec4380edf91662778fe0b79f6a591236e49e176f9@184.72.129.189:30301,enode://acf4507a211ba7c1e52cdf4eef62cdc3c32e7c9c47998954f7ba024026f9a6b2150cd3f0b734d9c78e507ab70d59ba61dfe5c45e1078c7ad0775fb251d7735a2@3.220.145.177:30301,enode://8a5a5006159bf079d06a04e5eceab2a1ce6e0f721875b2a9c96905336219dbe14203d38f70f3754686a6324f786c2f9852d8c0dd3adac2d080f4db35efc678c5@3.231.11.52:30301,enode://cdadbe835308ad3557f9a1de8db411da1a260a98f8421d62da90e71da66e55e98aaa8e90aa7ce01b408a54e4bd2253d701218081ded3dbe5efbbc7b41d7cef79@54.198.153.150:30301 # OP_NETHERMIND_BOOTNODES=enode://87a32fd13bd596b2ffca97020e31aef4ddcc1bbd4b95bb633d16c1329f654f34049ed240a36b449fda5e5225d70fe40bc667f53c304b71f8e68fc9d448690b51@3.231.138.188:30301,enode://ca21ea8f176adb2e229ce2d700830c844af0ea941a1d8152a9513b966fe525e809c3a6c73a2c18a12b74ed6ec4380edf91662778fe0b79f6a591236e49e176f9@184.72.129.189:30301,enode://acf4507a211ba7c1e52cdf4eef62cdc3c32e7c9c47998954f7ba024026f9a6b2150cd3f0b734d9c78e507ab70d59ba61dfe5c45e1078c7ad0775fb251d7735a2@3.220.145.177:30301,enode://8a5a5006159bf079d06a04e5eceab2a1ce6e0f721875b2a9c96905336219dbe14203d38f70f3754686a6324f786c2f9852d8c0dd3adac2d080f4db35efc678c5@3.231.11.52:30301,enode://cdadbe835308ad3557f9a1de8db411da1a260a98f8421d62da90e71da66e55e98aaa8e90aa7ce01b408a54e4bd2253d701218081ded3dbe5efbbc7b41d7cef79@54.198.153.150:30301 # OP_GETH_SYNCMODE=snap + +# For Flashblocks node +# RETH_FB_WEBSOCKET_URL=wss://mainnet.flashblocks.base.org/ws \ No newline at end of file diff --git a/.env.sepolia b/.env.sepolia index 37d0f4bc..22db6a69 100644 --- a/.env.sepolia +++ b/.env.sepolia @@ -48,3 +48,6 @@ OP_NODE_ROLLUP_LOAD_PROTOCOL_VERSIONS=true # OP_GETH_BOOTNODES=enode://548f715f3fc388a7c917ba644a2f16270f1ede48a5d88a4d14ea287cc916068363f3092e39936f1a3e7885198bef0e5af951f1d7b1041ce8ba4010917777e71f@18.210.176.114:30301,enode://6f10052847a966a725c9f4adf6716f9141155b99a0fb487fea3f51498f4c2a2cb8d534e680ee678f9447db85b93ff7c74562762c3714783a7233ac448603b25f@107.21.251.55:30301 # OP_NETHERMIND_BOOTNODES=enode://548f715f3fc388a7c917ba644a2f16270f1ede48a5d88a4d14ea287cc916068363f3092e39936f1a3e7885198bef0e5af951f1d7b1041ce8ba4010917777e71f@18.210.176.114:30301,enode://6f10052847a966a725c9f4adf6716f9141155b99a0fb487fea3f51498f4c2a2cb8d534e680ee678f9447db85b93ff7c74562762c3714783a7233ac448603b25f@107.21.251.55:30301 # OP_GETH_SYNCMODE=snap + +# For Flashblocks node +# RETH_FB_WEBSOCKET_URL=wss://sepolia.flashblocks.base.org/ws diff --git a/.gitignore b/.gitignore index 27ac158c..b3a0a47d 100644 --- a/.gitignore +++ b/.gitignore @@ -2,4 +2,4 @@ /geth-data/ /reth-data/ /nethermind-data/ -.DS_Store +.DS_Store \ No newline at end of file diff --git a/README.md b/README.md index 7bcb931f..5e831f04 100644 --- a/README.md +++ b/README.md @@ -74,7 +74,7 @@ docker compose up --build > > Supported clients: > - geth -> - reth +> - reth (with Flashblocks support option, see [Reth Node README](./reth/README.md)) > - nethermind 4. You should now be able to `curl` your Base node: diff --git a/docker-compose.yml b/docker-compose.yml index 3c88d2c6..c98fce9a 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -12,6 +12,8 @@ services: command: [ "bash", "./execution-entrypoint" ] volumes: - ${HOST_DATA_DIR}:/data + environment: + - NODE_TYPE=${NODE_TYPE:-vanilla} env_file: - ${NETWORK_ENV:?.env.mainnet} # Requires NETWORK_ENV to be set, defaults to mainnet node: diff --git a/reth/Dockerfile b/reth/Dockerfile index 8547ac81..16dbdd11 100644 --- a/reth/Dockerfile +++ b/reth/Dockerfile @@ -22,14 +22,31 @@ WORKDIR /app RUN apt-get update && apt-get -y upgrade && apt-get install -y git libclang-dev pkg-config curl build-essential ENV REPO=https://github.com/paradigmxyz/reth.git -ENV VERSION=v1.3.11 -ENV COMMIT=e0e85aa10b98fa92d32c3e820c7ed2cee0b02931 +ENV VERSION=v1.3.12 +ENV COMMIT=6f8e7258f4733279080e4bd8345ce50538a40d6e RUN git clone $REPO --branch $VERSION --single-branch . && \ git switch -c branch-$VERSION && \ bash -c '[ "$(git rev-parse HEAD)" = "$COMMIT" ]' RUN cargo build --bin op-reth --profile maxperf --manifest-path crates/optimism/bin/Cargo.toml +FROM rust:1.85 AS reth-base + +WORKDIR /app + +RUN apt-get update && apt-get -y upgrade && \ + apt-get install -y git libclang-dev pkg-config curl build-essential && \ + rm -rf /var/lib/apt/lists/* + +ENV REPO=https://github.com/base/node-reth.git +ENV VERSION=main +ENV COMMIT=c23179dc3531a988e483b05d306539cca99f9a5c +RUN git clone $REPO --branch $VERSION --single-branch . && \ + git switch -c branch-$VERSION && \ + bash -c '[ "$(git rev-parse HEAD)" = "$COMMIT" ]' || (echo "Commit hash verification failed" && exit 1) + +RUN cargo build --bin base-reth-node --release + FROM ubuntu:22.04 RUN apt-get update && \ @@ -41,6 +58,7 @@ WORKDIR /app COPY --from=op /app/op-node/bin/op-node ./ COPY --from=reth /app/target/maxperf/op-reth ./ +COPY --from=reth-base /app/target/release/base-reth-node ./ COPY supervisord.conf /etc/supervisor/conf.d/supervisord.conf COPY ./reth/reth-entrypoint ./execution-entrypoint COPY op-node-entrypoint . diff --git a/reth/README.md b/reth/README.md new file mode 100644 index 00000000..887f13b1 --- /dev/null +++ b/reth/README.md @@ -0,0 +1,45 @@ +# Running a Reth Node + +This is a unified implementation of the Reth node set up that supports running both standard Reth or Base Reth with Flashblocks support. + +## Setup + +- See hardware requirements mentioned in the master README +- For Base Reth mode: Access to a Flashblocks websocket endpoint (for `RETH_FB_WEBSOCKET_URL`) + - We provide public websocket endpoints for mainnet and devnet, included in `.env.mainnet` and `.env.sepolia` + +## Node Type Selection + +Use the `NODE_TYPE` environment variable to select the implementation: + +- `NODE_TYPE=vanilla` - Standard Reth implementation (default) +- `NODE_TYPE=base` - Base L2 Reth implementation with Flashblocks support + +## Running the Node + +The node follows the standard `docker-compose` workflow in the master README. + +```bash +# Run standard Reth node +CLIENT=reth docker-compose up + +# Run Base L2 Reth node with Flashblocks support +NODE_TYPE=base CLIENT=reth docker-compose up +``` + +## Testing Flashblocks RPC Methods + +When running in Base mode (`NODE_TYPE=base`), you can query a pending block using the Flashblocks RPC: + +```bash +curl -X POST \ + --data '{"jsonrpc":"2.0","method":"eth_getBlockByNumber","params":["pending", false],"id":1}' \ + http://localhost:8545 +``` + +## Additional RPC Methods + +For a complete list of supported RPC methods, refer to: + +- [Standard Ethereum JSON-RPC](https://ethereum.org/en/developers/docs/apis/json-rpc/) +- [Flashblocks RPC Methods](https://docs.base.org/chain/flashblocks#rpc-api) (Base mode only) diff --git a/reth/reth-entrypoint b/reth/reth-entrypoint index ca546dfe..9e6a9060 100755 --- a/reth/reth-entrypoint +++ b/reth/reth-entrypoint @@ -6,16 +6,32 @@ RPC_PORT="${RPC_PORT:-8545}" WS_PORT="${WS_PORT:-8546}" AUTHRPC_PORT="${AUTHRPC_PORT:-8551}" METRICS_PORT="${METRICS_PORT:-6060}" +ADDITIONAL_ARGS="" if [[ -z "$RETH_CHAIN" ]]; then echo "expected RETH_CHAIN to be set" 1>&2 exit 1 fi +# Add Flashblocks support for base mode +if [[ "$NODE_TYPE" == "base" && -n "$RETH_FB_WEBSOCKET_URL" ]]; then + ADDITIONAL_ARGS="--websocket-url=$RETH_FB_WEBSOCKET_URL" + echo "Enabling Flashblocks support with endpoint: $RETH_FB_WEBSOCKET_URL" +fi + +# Select binary based on NODE_TYPE +if [[ "$NODE_TYPE" == "base" ]]; then + echo "Starting Base Reth node" + BINARY="./base-reth-node" +else + echo "Starting vanilla Reth node" + BINARY="./op-reth" +fi + mkdir -p $RETH_DATA_DIR echo "$OP_NODE_L2_ENGINE_AUTH_RAW" > "$OP_NODE_L2_ENGINE_AUTH" -exec ./op-reth node \ +exec $BINARY node \ -vvv \ --datadir="$RETH_DATA_DIR" \ --log.stdout.format log-fmt \ @@ -35,4 +51,5 @@ exec ./op-reth node \ --metrics=0.0.0.0:"$METRICS_PORT" \ --chain "$RETH_CHAIN" \ --rollup.sequencer-http=$RETH_SEQUENCER_HTTP \ - --rollup.disable-tx-pool-gossip + --rollup.disable-tx-pool-gossip \ + $ADDITIONAL_ARGS