From ed8431c736ab67dc825316b8ea35ca5c7f078563 Mon Sep 17 00:00:00 2001 From: Rahul Kothari Date: Fri, 13 Oct 2023 09:50:30 +0100 Subject: [PATCH] feat(docker-sandbox): allow forks in sandbox (#2831) Currently you can't fork anvil on the sandbox. This PR enables this. Instructions: ``` export FORK_BLOCK_NUMBER=17514288 export FORK_URL= ``` Now run the sandbox! Blocks #2726 --- yarn-project/aztec-sandbox/docker-compose.yml | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/yarn-project/aztec-sandbox/docker-compose.yml b/yarn-project/aztec-sandbox/docker-compose.yml index 5e66423bb29..24b74540038 100644 --- a/yarn-project/aztec-sandbox/docker-compose.yml +++ b/yarn-project/aztec-sandbox/docker-compose.yml @@ -2,7 +2,15 @@ version: '3' services: ethereum: image: ghcr.io/foundry-rs/foundry@sha256:29ba6e34379e79c342ec02d437beb7929c9e254261e8032b17e187be71a2609f - command: '"anvil --silent -p 8545 --host 0.0.0.0 --chain-id 31337"' + command: > + sh -c ' + if [ -n "$FORK_BLOCK_NUMBER" ] && [ -n "$FORK_URL" ]; then + exec anvil -p 8545 --host 0.0.0.0 --chain-id 31337 --fork-url "$FORK_URL" --fork-block-number "$FORK_BLOCK_NUMBER" + elif [ -n "$FORK_URL" ]; then + exec anvil -p 8545 --host 0.0.0.0 --chain-id 31337 --fork-url "$FORK_URL" + else + exec anvil -p 8545 --host 0.0.0.0 --chain-id 31337 + fi' ports: - '${SANDBOX_ANVIL_PORT:-8545}:8545'