Skip to content

Commit

Permalink
add fork config
Browse files Browse the repository at this point in the history
  • Loading branch information
mcclurejt committed Jul 9, 2024
1 parent 37059bb commit ac0d239
Show file tree
Hide file tree
Showing 7 changed files with 84 additions and 13 deletions.
5 changes: 3 additions & 2 deletions docker-compose.anvil.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,11 @@ services:
# as soon as transactions are received, or with manual commands.
# this is "hecking fast" mode.
command: |
'anvil --load-state ./data --host 0.0.0.0 --code-size-limit 9999999999 --chain-id ${CHAIN_ID}'
'anvil ${ANVIL_STATE_SOURCE} ${ANVIL_BLOCKTIME} --chain-id=${CHAIN_ID} --host 0.0.0.0 --code-size-limit 9999999999'
volumes:
- artifacts:/src/artifacts/
env_file:
- .env

# Mine the first block to prevent overflow/underflow errors on the first
# read calls.
Expand Down Expand Up @@ -46,6 +48,5 @@ services:
env_file:
- .env


volumes:
artifacts:
5 changes: 0 additions & 5 deletions docker-compose.blocktime.yaml

This file was deleted.

54 changes: 54 additions & 0 deletions docker-compose.fork.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
services:
deployer:
image: ${DEVNET_IMAGE}
command: |
'/src/scripts/configure-clone.sh'
restart: on-failure
env_file:
- .env
volumes:
- artifacts:/src/artifacts/

artifacts:
image: ${ARTIFACTS_IMAGE}
volumes:
- artifacts:/var/www/artifacts/
depends_on:
deployer:
condition: service_completed_successfully

yield-bot:
image: ${DEVNET_IMAGE}
command: |
'cp /src/artifacts/deployments.local.json /src/deployments.local.json && npx hardhat fork:maintain-rate --network mainnet_fork --config hardhat.config.mainnet_fork.ts --show-stack-traces'
restart: unless-stopped
env_file:
- .env
volumes:
- artifacts:/src/artifacts/
depends_on:
deployer:
condition: service_completed_successfully

checkpoint-bot:
depends_on:
deployer:
condition: service_completed_successfully

invariance-check-bot:
depends_on:
deployer:
condition: service_completed_successfully

random-bot:
depends_on:
deployer:
condition: service_completed_successfully

data:
depends_on:
deployer:
condition: service_completed_successfully

volumes:
artifacts:
1 change: 1 addition & 0 deletions env/env.common
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Networking configuration
RPC_URI=http://ethereum:8545
RPC_URL=http://ethereum:8545
# Registry address defaults to looking in artifacts
# This can be overwritten by specifying here.
REGISTRY_ADDRESS=
1 change: 1 addition & 0 deletions env/env.fork
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
NETWORK=mainnet_fork
4 changes: 2 additions & 2 deletions env/env.images
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
# - edge = The newest image regardless of stability

# Anvil
DEVNET_IMAGE=ghcr.io/delvtech/hyperdrive/devnet:1.0.14
TESTNET_IMAGE=ghcr.io/delvtech/hyperdrive/testnet:1.0.14
DEVNET_IMAGE=ghcr.io/delvtech/hyperdrive/devnet:e8c339b7bd05a11c204c907e7fb66500bb1b7dcd
TESTNET_IMAGE=ghcr.io/delvtech/hyperdrive/testnet:e8c339b7bd05a11c204c907e7fb66500bb1b7dcd

# Infra
ARTIFACTS_IMAGE=ghcr.io/delvtech/infra/artifacts:0.0.8
Expand Down
27 changes: 23 additions & 4 deletions setup_env.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,9 @@ if [[ $# -eq 0 ]] || [[ "$1" == "--help" ]]; then
echo " --develop : Fund accounts and enable anvil, data, and ports. Suitable for local development work."
echo " --remote-service-bots : Runs service bots on a remote chain."
echo "Flags:"
echo " --anvil : Spin up an Anvil node, deploy Hyperdrive to it, and serve artifacts on an nginx server."
echo " --blocktime : Sets the anvil node to run in blocktime mode."
echo " --anvil : Spin up a fresh Anvil node, deploy Hyperdrive to it, and serve artifacts for the fresh deploy on an nginx server."
echo " --blocktime : Sets the anvil node to run in blocktime mode. (not included in --all)"
echo " --fork : Sets the anvil node to fork mainnet. (not included in --all)"
echo " --testnet : Uses the testnet hyperdrive image with restricted mint access."
echo " --frontend : Build the frontend container."
echo " --postgres : Runs a postgres db container for storing data."
Expand All @@ -28,6 +29,7 @@ fi
# Parse all of the arguments
## Initialize variables
ANVIL=false
FORK=false
BLOCKTIME=false
TESTNET=false
FRONTEND=false
Expand All @@ -46,6 +48,7 @@ while [[ $# -gt 0 ]]; do
--all)
ANVIL=true
# Don't run blocktime here, we want chain to be in fast mode
# Don't run fork here, forks cannot save/load state
# Don't run testnet image here since random bots need to be able to mint
FRONTEND=true
POSTGRES=true
Expand Down Expand Up @@ -75,6 +78,9 @@ while [[ $# -gt 0 ]]; do
--blocktime)
BLOCKTIME=true
;;
--fork)
FORK=true
;;
--testnet)
TESTNET=true
;;
Expand Down Expand Up @@ -117,6 +123,7 @@ echo "# Environment for Docker compose" >>.env
# turned on using docker compose profiles.
anvil_compose="docker-compose.anvil.yaml"
blocktime_compose="docker-compose.blocktime.yaml"
fork_compose="docker-compose.fork.yaml"
testnet_compose="docker-compose.testnet.yaml"
frontend_compose="docker-compose.frontend.yaml"
postgres_compose="docker-compose.postgres.yaml"
Expand All @@ -130,6 +137,9 @@ full_compose_files="COMPOSE_FILE=$anvil_compose:$frontend_compose:$postgres_comp
if $BLOCKTIME; then
full_compose_files+="$blocktime_compose:"
fi
if $FORK; then
full_compose_files+="$fork_compose:"
fi
if $TESTNET; then
full_compose_files+="$testnet_compose:"
fi
Expand All @@ -150,6 +160,7 @@ echo $full_compose_files >>.env
# should be started.
anvil_profile="anvil"
blocktime_profile="blocktime"
fork_profile="fork"
frontend_profile="frontend"
postgres_profile="postgres"
data_profile="data"
Expand All @@ -164,6 +175,9 @@ fi
if $BLOCKTIME; then
full_compose_profiles+="$blocktime_profile,"
fi
if $FORK; then
full_compose_profiles+="$fork_profile,"
fi
if $FRONTEND; then
full_compose_profiles+="$frontend_profile,"
fi
Expand Down Expand Up @@ -199,9 +213,14 @@ echo "" >>.env
cat env/env.common >> .env

# optionally cat env.anvil to .env file if --anvil
# set fork url if FORK is true
# set block time if BLOCKTIME is true
if $ANVIL; then
echo "" >>.env
cat env/env.anvil >>.env
cat env/env.anvil >> .env
echo "" >>.env
[[ $FORK = true ]] && echo "ANVIL_STATE_SOURCE='--fork-url <must provide mainnet rpc endpoint>'" >> .env || echo \'ANVIL_STATE_SOURCE='--load-state ./data'\' >>.env
[[ $BLOCKTIME = true ]] && echo ANVIL_BLOCKTIME='--block-time ${BLOCK_TIME}' >>.env
fi

echo "" >>.env
Expand All @@ -226,7 +245,7 @@ if $FRONTEND; then
fi

# optionally add an env.frontend to .env file if --postgres or --data
# POSTGRES uses these flags to launch postgres.
# POSTGRES uses these flags to launch postgres.
# All agent0 images uses these flags to connect
if $POSTGRES || $DATA || $SERVICE_BOT || $RANDOM_BOT || $RATE_BOT; then
echo "" >>.env
Expand Down

0 comments on commit ac0d239

Please sign in to comment.