Skip to content

Commit 1ffce34

Browse files
authored
feat: add anvil to docker-compose to enable shadowfork (#178)
* feat: add l1 anvil for shadow fork * refactor: docker compose shadow-fork * update docker image * fix: l1-devent host issue * add README for docker-compose * chore: move docker compose command to separate files * fix: add launch order dependency
1 parent 7bb6759 commit 1ffce34

File tree

6 files changed

+169
-20
lines changed

6 files changed

+169
-20
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,3 +26,4 @@ target/
2626
docker-compose/grafana_data/
2727
docker-compose/l2reth/
2828
docker-compose/prometheus_data/
29+
docker-compose/l1devnet/

docker-compose/.env.shadow-fork

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# .env.shadow-fork
2+
SHADOW_FORK=true
3+
FORK_BLOCK_NUMBER=8700000
4+
ENV=sepolia

docker-compose/README.md

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
# Scroll Rollup Node Docker Compose
2+
3+
This guide explains how to use Docker Compose to launch the Scroll Rollup Node, including standard and shadow-fork modes.
4+
5+
---
6+
7+
## Prerequisites
8+
- [Docker](https://docs.docker.com/get-docker/) and [Docker Compose](https://docs.docker.com/compose/install/) installed
9+
- Clone this repository
10+
11+
---
12+
13+
## Quick Start: Launching the Node
14+
15+
1. **Navigate to the `docker-compose` directory:**
16+
```sh
17+
cd docker-compose
18+
```
19+
20+
2. **Start the node and monitoring stack:**
21+
```sh
22+
docker compose up -d
23+
```
24+
This will launch the rollup node, Prometheus, and Grafana with default settings.
25+
26+
3. **Access the services:**
27+
- Rollup Node JSON-RPC: [http://localhost:8545](http://localhost:8545)
28+
- Rollup Node WebSocket: [ws://localhost:8546](ws://localhost:8546)
29+
- Prometheus: [http://localhost:19090](http://localhost:19090)
30+
- Grafana: [http://localhost:13000](http://localhost:13000)
31+
32+
---
33+
34+
## Shadow-Fork Mode
35+
36+
Shadow-fork mode allows you to run the node against a forked L1 chain for testing and development.
37+
38+
### 1. Edit the `.env.shadow-fork` file
39+
40+
The file `docker-compose/.env.shadow-fork` contains environment variables for shadow-fork mode:
41+
42+
```
43+
SHADOW_FORK=true
44+
FORK_BLOCK_NUMBER=8700000 # Change to your desired fork block
45+
ENV=sepolia # Or 'mainnet' for mainnet fork
46+
```
47+
48+
### 2. Launch with the shadow-fork profile
49+
50+
**Recommended (Docker Compose v1.28+):**
51+
52+
```sh
53+
docker compose --env-file .env.shadow-fork --profile shadow-fork up -d
54+
```
55+
56+
- This will start both the L1 devnet and the rollup node in shadow-fork mode.
57+
- The `FORK_BLOCK_NUMBER` and `ENV` variables control the fork point and network.
58+
59+
**Alternative:**
60+
You can also copy or rename `.env.shadow-fork` to `.env` if you want it to be loaded automatically:
61+
62+
```sh
63+
cp .env.shadow-fork .env
64+
# Then run:
65+
docker compose --profile shadow-fork up -d
66+
```
67+
68+
---
69+
70+
## Stopping the Stack
71+
72+
To stop all services:
73+
```sh
74+
docker compose down
75+
```
76+
77+
---
78+
79+
## Troubleshooting
80+
- Make sure the ports (8545, 8546, 19090, 13000) are not used by other processes.
81+
- If you change environment variables, restart the stack with `docker compose down && docker compose up -d`.
82+
- For shadow-fork mode, always ensure you specify the correct `--env-file` or have the right `.env` file in place.
83+
84+
---
85+
86+
## More
87+
- See `docker-compose/docker-compose.yml` for all available services and configuration options.
88+
- For advanced usage, refer to the official [Docker Compose documentation](https://docs.docker.com/compose/).
89+

docker-compose/docker-compose.yml

Lines changed: 34 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,53 @@
11
version: '3'
22

33
services:
4+
l1-devnet:
5+
image: ghcr.io/foundry-rs/foundry:v1.2.3
6+
container_name: l1-devnet
7+
entrypoint: ["bash", "/launch_l1.bash"]
8+
profiles:
9+
- shadow-fork
10+
env_file:
11+
- .env.shadow-fork
12+
environment:
13+
- ENV=${ENV}
14+
- FORK_BLOCK_NUMBER=${FORK_BLOCK_NUMBER}
15+
ports:
16+
- "8543:8545" # JSON-RPC
17+
- "8544:8546" # WebSocket
18+
volumes:
19+
- ./l1devnet:/l1devnet
20+
- ./launch_l1.bash:/launch_l1.bash
21+
healthcheck:
22+
test: ["CMD", "cast", "bn", "-r", "http://localhost:8545"]
23+
interval: 3s
24+
timeout: 2s
25+
retries: 20
26+
networks:
27+
- scroll-network
28+
429
rollup-node:
5-
image: scrolltech/rollup-node:v0.0.1-rc9
30+
image: scrolltech/rollup-node:v0.0.1-rc19
631
container_name: rollup-node
7-
entrypoint: ["sh", "-c"]
8-
command: >
9-
'
10-
if [ "$${ENV:-}" = "dev" ]; then
11-
exec rollup-node node --chain dev --datadir=/l2reth --metrics=0.0.0.0:6060 --disable-discovery --http --http.addr=0.0.0.0 --http.port=8545 --http.corsdomain "*" --http.api admin,debug,eth,net,trace,txpool,web3,rpc,reth,ots,flashbots,miner,mev --ws --ws.addr 0.0.0.0 --ws.port 8546 --ws.api admin,debug,eth,net,trace,txpool,web3,rpc,reth,ots,flashbots,miner,mev --log.stdout.format log-fmt -vvv --sequencer.enabled --sequencer.block-time 250 --sequencer.payload-building-duration 230 --txpool.pending-max-count=1000000 --builder.gaslimit=10000000000 --rpc.max-connections=5000
12-
elif [ "$${ENV:-}" = "sepolia" ]; then
13-
exec rollup-node node --chain scroll-sepolia --datadir=/l2reth --metrics=0.0.0.0:6060 --disable-discovery \
14-
--http --http.addr=0.0.0.0 --http.port=8545 --http.corsdomain "*" --http.api admin,debug,eth,net,trace,txpool,web3,rpc,reth,ots,flashbots,miner,mev \
15-
--ws --ws.addr 0.0.0.0 --ws.port 8546 --ws.api admin,debug,eth,net,trace,txpool,web3,rpc,reth,ots,flashbots,miner,mev \
16-
--log.stdout.format log-fmt -vvv --l1.url http://l1reth-rpc.sepolia.scroll.tech:8545 --beacon.url http://l1reth-cl.sepolia.scroll.tech:5052 --network.scroll-wire --network.bridge
17-
--trusted-peers "enode://29cee709c400533ae038a875b9ca975c8abef9eade956dcf3585e940acd5c0ae916968f514bd37d1278775aad1b7db30f7032a70202a87fd7365bd8de3c9f5fc@44.242.39.33:30303,enode://ceb1636bac5cbb262e5ad5b2cd22014bdb35ffe7f58b3506970d337a63099481814a338dbcd15f2d28757151e3ecd40ba38b41350b793cd0d910ff0436654f8c@35.85.84.250:30303,enode://dd1ac5433c5c2b04ca3166f4cb726f8ff6d2da83dbc16d9b68b1ea83b7079b371eb16ef41c00441b6e85e32e33087f3b7753ea9e8b1e3f26d3e4df9208625e7f@54.148.111.168:30303"
18-
elif [ "$${ENV:-}" = "mainnet" ]; then
19-
exec rollup-node node --chain scroll-mainnet --datadir=/l2reth --metrics=0.0.0.0:6060 --disable-discovery \
20-
--http --http.addr=0.0.0.0 --http.port=8545 --http.corsdomain "*" --http.api admin,debug,eth,net,trace,txpool,web3,rpc,reth,ots,flashbots,miner,mev
21-
--ws --ws.addr 0.0.0.0 --ws.port 8546 --ws.api admin,debug,eth,net,trace,txpool,web3,rpc,reth,ots,flashbots,miner,mev \
22-
--log.stdout.format log-fmt -vvv --l1.url http://l1geth-rpc.mainnet.scroll.tech:8545/l1 --beacon.url http://l1reth-cl.mainnet.scroll.tech:5052 --network.scroll-wire --network.bridge \
23-
--trusted-peers "enode://c6ac91f43df3d63916ac1ae411cdd5ba249d55d48a7bec7f8cd5bb351a31aba437e5a69e8a1de74d73fdfeba8af1cfe9caf9846ecd3abf60d1ffdf4925b55b23@54.186.123.248:30303,enode://fdcc807b5d1353f3a1e98b90208ce6ef1b7d446136e51eaa8ad657b55518a2f8b37655e42375d61622e6ea18f3faf9d070c9bbdf012cf5484bcbad33b7a15fb1@44.227.91.206:30303,enode://6beb5a3efbb39be73d17630b6da48e94c0ce7ec665172111463cb470197b20c12faa1fa6f835b81c28571277d1017e65c4e426cc92a46141cf69118ecf28ac03@44.237.194.52:30303,enode://7cf893d444eb8e129dca0f6485b3df579911606e7c728be4fa55fcc5f155a37c3ce07d217ccec5447798bde465ac2bdba2cb8763d107e9f3257e787579e9f27e@52.35.203.107:30303,enode://c7b2d94e95da343db6e667a01cef90376a592f2d277fbcbf6e9c9186734ed8003d01389571bd10cdbab7a6e5adfa6f0c7b55644d0db24e0b9deb4ec80f842075@54.70.236.187:30303"
24-
fi
25-
'
32+
entrypoint: ["bash", "/launch_rollup_node.bash"]
33+
env_file:
34+
- .env.shadow-fork
2635
environment:
2736
- ENV=${ENV:-dev}
37+
- SHADOW_FORK=${SHADOW_FORK:-false}
2838
- RUST_LOG=sqlx=off,info
2939
ports:
3040
- "8545:8545" # JSON-RPC
3141
- "8546:8546" # WebSocket
3242
- "6060:6060" # Metrics
3343
volumes:
3444
- ./l2reth:/l2reth
45+
- ./launch_rollup_node.bash:/launch_rollup_node.bash
3546
networks:
3647
- scroll-network
48+
depends_on:
49+
l1-devnet:
50+
condition: service_healthy
3751

3852
prometheus:
3953
image: prom/prometheus:latest

docker-compose/launch_l1.bash

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#!/usr/bin/env bash
2+
set -e
3+
4+
EXTRA_PARAMS=""
5+
if [ "${FORK_BLOCK_NUMBER}" != "" ]; then
6+
EXTRA_PARAMS="--fork-block-number ${FORK_BLOCK_NUMBER}"
7+
fi
8+
9+
if [ "${ENV:-}" = "sepolia" ]; then
10+
exec anvil --fork-url http://l1reth-rpc.sepolia.scroll.tech:8545 --chain-id 11155111 --host 0.0.0.0 --block-time 12 $EXTRA_PARAMS
11+
elif [ "${ENV:-}" = "mainnet" ]; then
12+
exec anvil --fork-url http://l1geth-rpc.mainnet.scroll.tech:8545/l1 --chain-id 1 --host 0.0.0.0 --block-time 12 $EXTRA_PARAMS
13+
fi
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#!/usr/bin/env bash
2+
set -e
3+
4+
if [ "${ENV:-}" = "dev" ]; then
5+
exec rollup-node node --chain dev --datadir=/l2reth --metrics=0.0.0.0:6060 --disable-discovery --http --http.addr=0.0.0.0 --http.port=8545 --http.corsdomain "*" --http.api admin,debug,eth,net,trace,txpool,web3,rpc,reth,ots,flashbots,miner,mev --ws --ws.addr=0.0.0.0 --ws.port=8546 --ws.api admin,debug,eth,net,trace,txpool,web3,rpc,reth,ots,flashbots,miner,mev --log.stdout.format log-fmt -vvv --sequencer.enabled --sequencer.block-time 250 --sequencer.payload-building-duration 230 --txpool.pending-max-count=1000000 --builder.gaslimit=10000000000 --rpc.max-connections=5000
6+
elif [ "${ENV:-}" = "sepolia" ]; then
7+
if [ "${SHADOW_FORK}" = "true" ]; then
8+
URL_PARAMS="--l1.url http://l1-devnet:8545"
9+
else
10+
URL_PARAMS="--l1.url http://l1reth-rpc.sepolia.scroll.tech:8545"
11+
fi
12+
exec rollup-node node --chain scroll-sepolia --datadir=/l2reth --metrics=0.0.0.0:6060 --disable-discovery \
13+
--http --http.addr=0.0.0.0 --http.port=8545 --http.corsdomain "*" --http.api admin,debug,eth,net,trace,txpool,web3,rpc,reth,ots,flashbots,miner,mev \
14+
--ws --ws.addr=0.0.0.0 --ws.port=8546 --ws.api admin,debug,eth,net,trace,txpool,web3,rpc,reth,ots,flashbots,miner,mev \
15+
--log.stdout.format log-fmt -vvv $URL_PARAMS --beacon.url http://l1reth-cl.sepolia.scroll.tech:5052 --network.scroll-wire --network.bridge \
16+
--trusted-peers "enode://29cee709c400533ae038a875b9ca975c8abef9eade956dcf3585e940acd5c0ae916968f514bd37d1278775aad1b7db30f7032a70202a87fd7365bd8de3c9f5fc@44.242.39.33:30303,enode://ceb1636bac5cbb262e5ad5b2cd22014bdb35ffe7f58b3506970d337a63099481814a338dbcd15f2d28757151e3ecd40ba38b41350b793cd0d910ff0436654f8c@35.85.84.250:30303,enode://dd1ac5433c5c2b04ca3166f4cb726f8ff6d2da83dbc16d9b68b1ea83b7079b371eb16ef41c00441b6e85e32e33087f3b7753ea9e8b1e3f26d3e4df9208625e7f@54.148.111.168:30303"
17+
elif [ "${ENV:-}" = "mainnet" ]; then
18+
if [ "${SHADOW_FORK}" = "true" ]; then
19+
URL_PARAMS="--l1.url http://l1-devnet:8545"
20+
else
21+
URL_PARAMS="--l1.url http://l1geth-rpc.mainnet.scroll.tech:8545/l1"
22+
fi
23+
exec rollup-node node --chain scroll-mainnet --datadir=/l2reth --metrics=0.0.0.0:6060 --disable-discovery \
24+
--http --http.addr=0.0.0.0 --http.port=8545 --http.corsdomain "*" --http.api admin,debug,eth,net,trace,txpool,web3,rpc,reth,ots,flashbots,miner,mev \
25+
--ws --ws.addr=0.0.0.0 --ws.port=8546 --ws.api admin,debug,eth,net,trace,txpool,web3,rpc,reth,ots,flashbots,miner,mev \
26+
--log.stdout.format log-fmt -vvv $URL_PARAMS --beacon.url http://l1reth-cl.mainnet.scroll.tech:5052 --network.scroll-wire --network.bridge \
27+
--trusted-peers "enode://c6ac91f43df3d63916ac1ae411cdd5ba249d55d48a7bec7f8cd5bb351a31aba437e5a69e8a1de74d73fdfeba8af1cfe9caf9846ecd3abf60d1ffdf4925b55b23@54.186.123.248:30303,enode://fdcc807b5d1353f3a1e98b90208ce6ef1b7d446136e51eaa8ad657b55518a2f8b37655e42375d61622e6ea18f3faf9d070c9bbdf012cf5484bcbad33b7a15fb1@44.227.91.206:30303,enode://6beb5a3efbb39be73d17630b6da48e94c0ce7ec665172111463cb470197b20c12faa1fa6f835b81c28571277d1017e65c4e426cc92a46141cf69118ecf28ac03@44.237.194.52:30303,enode://7cf893d444eb8e129dca0f6485b3df579911606e7c728be4fa55fcc5f155a37c3ce07d217ccec5447798bde465ac2bdba2cb8763d107e9f3257e787579e9f27e@52.35.203.107:30303,enode://c7b2d94e95da343db6e667a01cef90376a592f2d277fbcbf6e9c9186734ed8003d01389571bd10cdbab7a6e5adfa6f0c7b55644d0db24e0b9deb4ec80f842075@54.70.236.187:30303"
28+
fi

0 commit comments

Comments
 (0)