Skip to content

feat: add anvil to docker-compose to enable shadowfork #178

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,4 @@ target/
docker-compose/grafana_data/
docker-compose/l2reth/
docker-compose/prometheus_data/
docker-compose/l1devnet/
4 changes: 4 additions & 0 deletions docker-compose/.env.shadow-fork
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# .env.shadow-fork
SHADOW_FORK=true
FORK_BLOCK_NUMBER=8700000
ENV=sepolia
89 changes: 89 additions & 0 deletions docker-compose/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
# Scroll Rollup Node Docker Compose

This guide explains how to use Docker Compose to launch the Scroll Rollup Node, including standard and shadow-fork modes.

---

## Prerequisites
- [Docker](https://docs.docker.com/get-docker/) and [Docker Compose](https://docs.docker.com/compose/install/) installed
- Clone this repository

---

## Quick Start: Launching the Node

1. **Navigate to the `docker-compose` directory:**
```sh
cd docker-compose
```

2. **Start the node and monitoring stack:**
```sh
docker compose up -d
```
This will launch the rollup node, Prometheus, and Grafana with default settings.

3. **Access the services:**
- Rollup Node JSON-RPC: [http://localhost:8545](http://localhost:8545)
- Rollup Node WebSocket: [ws://localhost:8546](ws://localhost:8546)
- Prometheus: [http://localhost:19090](http://localhost:19090)
- Grafana: [http://localhost:13000](http://localhost:13000)

---

## Shadow-Fork Mode

Shadow-fork mode allows you to run the node against a forked L1 chain for testing and development.

### 1. Edit the `.env.shadow-fork` file

The file `docker-compose/.env.shadow-fork` contains environment variables for shadow-fork mode:

```
SHADOW_FORK=true
FORK_BLOCK_NUMBER=8700000 # Change to your desired fork block
ENV=sepolia # Or 'mainnet' for mainnet fork
```

### 2. Launch with the shadow-fork profile

**Recommended (Docker Compose v1.28+):**

```sh
docker compose --env-file .env.shadow-fork --profile shadow-fork up -d
```

- This will start both the L1 devnet and the rollup node in shadow-fork mode.
- The `FORK_BLOCK_NUMBER` and `ENV` variables control the fork point and network.

**Alternative:**
You can also copy or rename `.env.shadow-fork` to `.env` if you want it to be loaded automatically:

```sh
cp .env.shadow-fork .env
# Then run:
docker compose --profile shadow-fork up -d
```

---

## Stopping the Stack

To stop all services:
```sh
docker compose down
```

---

## Troubleshooting
- Make sure the ports (8545, 8546, 19090, 13000) are not used by other processes.
- If you change environment variables, restart the stack with `docker compose down && docker compose up -d`.
- For shadow-fork mode, always ensure you specify the correct `--env-file` or have the right `.env` file in place.

---

## More
- See `docker-compose/docker-compose.yml` for all available services and configuration options.
- For advanced usage, refer to the official [Docker Compose documentation](https://docs.docker.com/compose/).

50 changes: 47 additions & 3 deletions docker-compose/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,30 +1,74 @@
version: '3'

services:
l1-devnet:
image: scrolltech/l1-devnet:v0.0.4
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you provide a reference to the Dockerfile which is used to build this image, please? Is there a reason we don't use the vanilla foundry image (https://github.com/foundry-rs/foundry/pkgs/container/foundry)?

container_name: l1-devnet
entrypoint: ["bash", "-c"]
command: >
'
EXTRA_PARAMS="";
if [ "$${FORK_BLOCK_NUMBER}" != "" ]; then
EXTRA_PARAMS="--fork-block-number $${FORK_BLOCK_NUMBER}";
fi;
if [ "$${ENV:-}" = "sepolia" ]; then
anvil --fork-url http://l1reth-rpc.sepolia.scroll.tech:8545 --chain-id 11155111 --host 0.0.0.0 --block-time 12 $EXTRA_PARAMS
elif [ "$${ENV:-}" = "mainnet" ]; then
anvil --fork-url http://l1geth-rpc.mainnet.scroll.tech:8545/l1 --chain-id 1 --host 0.0.0.0 --block-time 12 $EXTRA_PARAMS
fi
'
profiles:
- shadow-fork
env_file:
- .env.shadow-fork
environment:
- ENV=${ENV}
- FORK_BLOCK_NUMBER=${FORK_BLOCK_NUMBER}
ports:
- "8543:8545" # JSON-RPC
- "8544:8546" # WebSocket
volumes:
- ./l1devnet:/l1devnet
networks:
- scroll-network

rollup-node:
image: scrolltech/rollup-node:v0.0.1-rc9
image: scrolltech/rollup-node:v0.0.1-rc19
container_name: rollup-node
entrypoint: ["sh", "-c"]
command: >
'
if [ "$${ENV:-}" = "dev" ]; then
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
elif [ "$${ENV:-}" = "sepolia" ]; then
if [ "$SHADOW_FORK" = "true" ]; then
URL_PARAMS="--l1.url l1-devnet:8545";
else
URL_PARAMS="--l1.url http://l1reth-rpc.sepolia.scroll.tech:8545";
fi
exec rollup-node node --chain scroll-sepolia --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 --l1.url http://l1reth-rpc.sepolia.scroll.tech:8545 --beacon.url http://l1reth-cl.sepolia.scroll.tech:5052 --network.scroll-wire --network.bridge
--log.stdout.format log-fmt -vvv $URL_PARAMS --beacon.url http://l1reth-cl.sepolia.scroll.tech:5052 --network.scroll-wire --network.bridge
--trusted-peers "enode://29cee709c400533ae038a875b9ca975c8abef9eade956dcf3585e940acd5c0ae916968f514bd37d1278775aad1b7db30f7032a70202a87fd7365bd8de3c9f5fc@44.242.39.33:30303,enode://ceb1636bac5cbb262e5ad5b2cd22014bdb35ffe7f58b3506970d337a63099481814a338dbcd15f2d28757151e3ecd40ba38b41350b793cd0d910ff0436654f8c@35.85.84.250:30303,enode://dd1ac5433c5c2b04ca3166f4cb726f8ff6d2da83dbc16d9b68b1ea83b7079b371eb16ef41c00441b6e85e32e33087f3b7753ea9e8b1e3f26d3e4df9208625e7f@54.148.111.168:30303"
elif [ "$${ENV:-}" = "mainnet" ]; then
if [ "$SHADOW_FORK" = "true" ]; then
URL_PARAMS="--l1.url l1-devnet:8545";
else
URL_PARAMS="--l1.url http://l1geth-rpc.mainnet.scroll.tech:8545/l1";
fi
exec rollup-node node --chain scroll-mainnet --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 --l1.url http://l1geth-rpc.mainnet.scroll.tech:8545/l1 --beacon.url http://l1reth-cl.mainnet.scroll.tech:5052 --network.scroll-wire --network.bridge \
--log.stdout.format log-fmt -vvv $URL_PARAMS --beacon.url http://l1reth-cl.mainnet.scroll.tech:5052 --network.scroll-wire --network.bridge \
--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"
fi
Comment on lines 40 to 65
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we extract this and the command for l1-devnet to bash files - i.e. launch_rollup_node.bash and launch_l1.bash. I think this would make the compose file cleaner. What do you think?

'
env_file:
- .env.shadow-fork
environment:
- ENV=${ENV:-dev}
- SHADOW_FORK=${SHADOW_FORK:-false}
- RUST_LOG=sqlx=off,info
ports:
- "8545:8545" # JSON-RPC
Expand Down
Loading