diff --git a/docker-compose.agent0-bots.yaml b/docker-compose.agent0-bots.yaml new file mode 100644 index 0000000..0fab327 --- /dev/null +++ b/docker-compose.agent0-bots.yaml @@ -0,0 +1,38 @@ +services: + checkpoint-bot: + image: ${AGENT0_IMAGE} + profiles: + - "service-bot" + command: | + /bin/sh -c "sleep 1; python scripts/checkpoint_bots.py --pool-check-sleep-blocks 30 --infra" + env_file: + - .env + + invariance-check-bot: + image: ${AGENT0_IMAGE} + profiles: + - "service-bot" + command: | + /bin/sh -c "sleep 1; python scripts/fuzz_bot_invariant_checks.py --pool-check-sleep-blocks 30 --infra" + env_file: + - .env + + random-bot: + image: ${AGENT0_IMAGE} + profiles: + - "random-bot" + command: | + /bin/sh -c "sleep 1; python scripts/remote_fuzz_bots.py --pool-check-sleep-blocks 10000 --infra" + env_file: + - .env + + # TODO rewrite rate bot in agent0 + rate-bot: + image: ${RATE_BOT_IMAGE} + profiles: + - "rate-bot" + volumes: + - artifacts:/artifacts/ + +volumes: + artifacts: diff --git a/docker-compose.anvil.yaml b/docker-compose.anvil.yaml index c40ed28..a59dd89 100644 --- a/docker-compose.anvil.yaml +++ b/docker-compose.anvil.yaml @@ -1,4 +1,3 @@ -version: "3.9" services: ethereum: image: ${DEVNET_IMAGE} @@ -41,20 +40,5 @@ services: volumes: - artifacts:/var/www/artifacts/ - # TODO make single container for all pools - checkpoint-bot-erc4626: - image: ${AGENT0_IMAGE} - command: | - /bin/sh -c "sleep 1; python scripts/checkpoint_bot.py --pool erc4626_hyperdrive --fund" - env_file: - - .env - - checkpoint-bot-steth: - image: ${AGENT0_IMAGE} - command: | - /bin/sh -c "sleep 1; python scripts/checkpoint_bot.py --pool steth_hyperdrive --fund" - env_file: - - .env - volumes: artifacts: diff --git a/docker-compose.blocktime.yaml b/docker-compose.blocktime.yaml index 1dd434c..d977e67 100644 --- a/docker-compose.blocktime.yaml +++ b/docker-compose.blocktime.yaml @@ -1,4 +1,3 @@ -version: "3.9" services: ethereum: # This file overwrites docker-compose.anvil.yaml diff --git a/docker-compose.data.yaml b/docker-compose.data.yaml index 36c3e60..fd4b088 100644 --- a/docker-compose.data.yaml +++ b/docker-compose.data.yaml @@ -1,4 +1,3 @@ -version: "3.9" services: data: @@ -15,7 +14,7 @@ services: profiles: - "data" working_dir: /app/ - command: /bin/sh -c "python scripts/run_data_analysis.py" + command: /bin/sh -c "python scripts/run_analyze_data.py" env_file: - .env @@ -37,15 +36,5 @@ services: mem_reservation: "1g" restart: always - # Set initial username mappings - init-usernames: - image: ${AGENT0_IMAGE} - profiles: - - "data" - working_dir: /app/ - command: /bin/sh -c "python scripts/update_usernames.py" - env_file: - - .env - volumes: artifacts: diff --git a/docker-compose.frontend.yaml b/docker-compose.frontend.yaml index a15d627..2b1bef4 100644 --- a/docker-compose.frontend.yaml +++ b/docker-compose.frontend.yaml @@ -1,4 +1,3 @@ -version: "3.9" services: frontend: diff --git a/docker-compose.fuzz-bot.yaml b/docker-compose.fuzz-bot.yaml deleted file mode 100644 index 5027cd9..0000000 --- a/docker-compose.fuzz-bot.yaml +++ /dev/null @@ -1,47 +0,0 @@ -version: "3.9" -services: - # TODO make single container for all pools - fuzz-erc4626: - image: ${AGENT0_IMAGE} - profiles: - - "fuzz" - working_dir: /app/ - command: /bin/sh -c "DEVELOP=true python scripts/fuzz_bots.py --pool erc4626_hyperdrive" - env_file: - - .env - volumes: - - .crash_report:/app/.crash_report - - fuzz-steth: - image: ${AGENT0_IMAGE} - profiles: - - "fuzz" - working_dir: /app/ - command: /bin/sh -c "DEVELOP=true python scripts/fuzz_bots.py --pool steth_hyperdrive" - env_file: - - .env - volumes: - - .crash_report:/app/.crash_report - - fuzz-invariant-check-erc4626: - image: ${AGENT0_IMAGE} - profiles: - - "fuzz" - working_dir: /app/ - command: /bin/sh -c "sleep 1; python scripts/fuzz_bot_invariant_checks.py --pool erc4626_hyperdrive" - env_file: - - .env - volumes: - - .crash_report:/app/.crash_report - - - fuzz-invariant-check-steth: - image: ${AGENT0_IMAGE} - profiles: - - "fuzz" - working_dir: /app/ - command: /bin/sh -c "sleep 1; python scripts/fuzz_bot_invariant_checks.py --pool steth_hyperdrive" - env_file: - - .env - volumes: - - .crash_report:/app/.crash_report diff --git a/docker-compose.ports.yaml b/docker-compose.ports.yaml index 45a62c0..30b8297 100644 --- a/docker-compose.ports.yaml +++ b/docker-compose.ports.yaml @@ -1,4 +1,3 @@ -version: "3.9" services: ethereum: diff --git a/docker-compose.postgres.yaml b/docker-compose.postgres.yaml index ef2df05..b1ef98d 100644 --- a/docker-compose.postgres.yaml +++ b/docker-compose.postgres.yaml @@ -1,7 +1,4 @@ -version: '3.9' - services: - db: image: postgres profiles: @@ -10,4 +7,4 @@ services: environment: POSTGRES_PASSWORD: password POSTGRES_USER: admin - POSTGRES_DB: postgres_db + POSTGRES_DB: agent0_db diff --git a/docker-compose.rate-bot.yaml b/docker-compose.rate-bot.yaml deleted file mode 100644 index 44c42b4..0000000 --- a/docker-compose.rate-bot.yaml +++ /dev/null @@ -1,11 +0,0 @@ -version: "3.9" -services: - rate-bot: - image: ${RATE_BOT_IMAGE} - profiles: - - "dynamic-rate" - volumes: - - artifacts:/artifacts/ - -volumes: - artifacts: diff --git a/docker-compose.testnet.yaml b/docker-compose.testnet.yaml index 6f37839..cd5b609 100644 --- a/docker-compose.testnet.yaml +++ b/docker-compose.testnet.yaml @@ -1,4 +1,3 @@ -version: "3.9" services: ethereum: # This file overwrites docker-compose.anvil.yaml diff --git a/env/env.images b/env/env.images index 566ed3d..60095c7 100644 --- a/env/env.images +++ b/env/env.images @@ -5,8 +5,8 @@ # - edge = The newest image regardless of stability # Anvil -DEVNET_IMAGE=ghcr.io/delvtech/hyperdrive/devnet:1.0.1 -TESTNET_IMAGE=ghcr.io/delvtech/hyperdrive/testnet:1.0.1 +DEVNET_IMAGE=ghcr.io/delvtech/hyperdrive/devnet:1.0.10 +TESTNET_IMAGE=ghcr.io/delvtech/hyperdrive/testnet:1.0.10 # Infra ARTIFACTS_IMAGE=ghcr.io/delvtech/infra/artifacts:0.0.8 @@ -14,8 +14,7 @@ FUND_ACCOUNTS_IMAGE=ghcr.io/delvtech/infra/fund-accounts:0.0.8 RATE_BOT_IMAGE=ghcr.io/delvtech/infra/rate-bot:0.0.8 # Agent0 (bots) -# TODO cut release and set here -AGENT0_IMAGE=ghcr.io/delvtech/agent0/agent0:0.18.1 +AGENT0_IMAGE=ghcr.io/delvtech/agent0/agent0:0.20.2 # Frontend -FRONTEND_IMAGE=ghcr.io/delvtech/hyperdrive-frontend/hyperdrive-frontend:1.0.7 +FRONTEND_IMAGE=ghcr.io/delvtech/hyperdrive-frontend/hyperdrive-frontend:1.6.5 diff --git a/env/env.postgres b/env/env.postgres index 4249d7f..bddaa53 100644 --- a/env/env.postgres +++ b/env/env.postgres @@ -1,5 +1,5 @@ POSTGRES_USER=admin POSTGRES_PASSWORD=password -POSTGRES_DB=postgres_db +POSTGRES_DB=agent0_db POSTGRES_HOST="db" POSTGRES_PORT=5432 diff --git a/setup_env.sh b/setup_env.sh index 8273c5e..976f595 100755 --- a/setup_env.sh +++ b/setup_env.sh @@ -6,21 +6,21 @@ # Check if no arguments or --help is passed if [[ $# -eq 0 ]] || [[ "$1" == "--help" ]]; then echo "Usage: ./setup_env.sh [flags]" - echo "Flags:" + echo "Flag Groups:" echo " --all : Fund accounts and enable all components: anvil, data, postgres, frontend, and ports." - echo " --competition : Fund accounts and enable anvil on block time with testnet image, data (without postgres), and ports. Use this for a trading competition deployment." echo " --develop : Fund accounts and enable anvil, data, and ports. Suitable for local development work." - echo " --fuzz : Enable anvil on block time, data, and ports. Runs fuzzbots and outputs crash reports." + 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 " --testnet : Uses the testnet hyperdrive image with restricted mint access." echo " --frontend : Build the frontend container." - echo " --data : Runs the data framework, querying the chain and writing to postgres." echo " --postgres : Runs a postgres db container for storing data." + echo " --data : Runs the data framework, querying the chain and writing to postgres." + echo " --service-bot : Runs checkpoint bot and invariance check bots on the chain." + echo " --random-bot : Runs random bots on the chain." echo " --ports : Expose docker images to your machine, as specified in env/env.ports." echo " --fund-accounts : Fund accounts from /accounts/balances.json." - echo " --dynamic-rate : Yield source will have a dynamic variable rate." - echo " --fuzzbot : Runs fuzzbots on the chain." + echo " --rate-bot : Yield source will have a dynamic variable rate." exit 0 fi @@ -30,49 +30,39 @@ ANVIL=false BLOCKTIME=false TESTNET=false FRONTEND=false -DATA=false POSTGRES=false +DATA=false PORTS=false +SERVICE_BOT=false +RANDOM_BOT=false +RATE_BOT=false FUND_ACCOUNTS=false -DYNAMIC_RATE=false -FUZZBOT=false ## Loop through the arguments while [[ $# -gt 0 ]]; do case $1 in + # Flag groups --all) ANVIL=true + # Don't run blocktime here, we want chain to be in fast mode + # Don't run testnet image here since random bots need to be able to mint FRONTEND=true - DATA=true POSTGRES=true - PORTS=true - FUND_ACCOUNTS=true - DYNAMIC_RATE=true - ;; - --competition) - ANVIL=true - BLOCKTIME=true - TESTNET=true DATA=true PORTS=true + SERVICE_BOT=true + RANDOM_BOT=true + RATE_BOT=true FUND_ACCOUNTS=true - DYNAMIC_RATE=true ;; --develop) ANVIL=true POSTGRES=true - PORTS=true DATA=true - FUND_ACCOUNTS=true - ;; - --fuzz) - ANVIL=true - BLOCKTIME=true - DATA=true - POSTGRES=true PORTS=true - FUZZBOT=true + FUND_ACCOUNTS=true ;; + # Flags --anvil) ANVIL=true ;; @@ -94,14 +84,14 @@ while [[ $# -gt 0 ]]; do --ports) PORTS=true ;; - --fund-accounts) - FUND_ACCOUNTS=true + --service-bot) + SERVICE_BOT=true ;; - --dynamic-rate) - DYNAMIC_RATE=true + --rate-bot) + RATE_BOT=true ;; - --fuzzbot) - FUZZBOT=true + --fund-accounts) + FUND_ACCOUNTS=true ;; *) echo "Unknown flag: $1" @@ -120,15 +110,17 @@ echo "# Environment for Docker compose" >>.env # all of the services in the compose context. We determine which layers are # turned on using docker compose profiles. anvil_compose="docker-compose.anvil.yaml" -data_compose="docker-compose.data.yaml" -rate_bot_compose="docker-compose.rate-bot.yaml" -fuzz_bot_compose="docker-compose.fuzz-bot.yaml" +blocktime_compose="docker-compose.blocktime.yaml" +testnet_compose="docker-compose.testnet.yaml" frontend_compose="docker-compose.frontend.yaml" postgres_compose="docker-compose.postgres.yaml" -testnet_compose="docker-compose.testnet.yaml" -blocktime_compose="docker-compose.blocktime.yaml" +data_compose="docker-compose.data.yaml" +service_bot_compose="docker-compose.agent0-bots.yaml" ports_compose="docker-compose.ports.yaml" -full_compose_files="COMPOSE_FILE=$anvil_compose:$data_compose:$frontend_compose:$postgres_compose:$rate_bot_compose:$fuzz_bot_compose:" + +# We default to using profiles to control which services are turned on. +full_compose_files="COMPOSE_FILE=$anvil_compose:$frontend_compose:$postgres_compose:$data_compose:$service_bot_compose:" +# We only add controls here if these compose files update existing services. if $BLOCKTIME; then full_compose_files+="$blocktime_compose:" fi @@ -150,14 +142,18 @@ echo $full_compose_files >>.env # Set up the COMPOSE_PROFILES environment variable. This toggles which layers # should be started. +blocktime_profile="blocktime" frontend_profile="frontend" postgres_profile="postgres" data_profile="data" +service_bot_profile="service-bot" +random_bot_profile="random-bot" +rate_bot_profile="rate-bot" fund_accounts_profile="fund-accounts" -blocktime_profile="blocktime" -dynamic_rate_profile="dynamic-rate" -fuzz_bot_profile="fuzz" full_compose_profiles="COMPOSE_PROFILES=" +if $BLOCKTIME; then + full_compose_profiles+="$blocktime_profile," +fi if $FRONTEND; then full_compose_profiles+="$frontend_profile," fi @@ -167,17 +163,17 @@ fi if $DATA; then full_compose_profiles+="$data_profile," fi -if $FUND_ACCOUNTS; then - full_compose_profiles+="$fund_accounts_profile," +if $SERVICE_BOT; then + full_compose_profiles+="$service_bot_profile," fi -if $BLOCKTIME; then - full_compose_profiles+="$blocktime_profile," +if $RANDOM_BOT; then + full_compose_profiles+="$random_bot_profile," fi -if $DYNAMIC_RATE; then - full_compose_profiles+="$dynamic_rate_profile," +if $RATE_BOT; then + full_compose_profiles+="$rate_bot_profile," fi -if $FUZZBOT; then - full_compose_profiles+="$fuzz_bot_profile," +if $FUND_ACCOUNTS; then + full_compose_profiles+="$fund_accounts_profile," fi # Check if "," is at the end of the string if [[ $full_compose_profiles == *"," ]]; then @@ -206,6 +202,12 @@ if $ANVIL; then cat env/env.anvil >>.env fi +# optionally add an env.time to .env file if --blocktime +if $BLOCKTIME; then + echo "" >>.env + cat env/env.time >>.env +fi + # optionally add an env.frontend to .env file if --frontend if $FRONTEND; then echo "" >>.env @@ -213,16 +215,11 @@ if $FRONTEND; then fi # optionally add an env.frontend to .env file if --postgres or --data -# POSTGRES uses these flags to launch postgres, DATA uses these flags to connect -if $POSTGRES || $DATA; then +# 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 cat env/env.postgres >> .env fi -# optionally add an env.time to .env file if --blocktime -if $BLOCKTIME; then - echo "" >>.env - cat env/env.time >>.env -fi - echo "Environment filed created at .env" diff --git a/test/test_compose.sh b/test/test_compose.sh index b59cffa..e726af0 100644 --- a/test/test_compose.sh +++ b/test/test_compose.sh @@ -38,23 +38,10 @@ if [ -z "$(docker compose ps -q artifacts)" ]; then exit 1 fi -# The checkpoint-bot service should be running. -if [ -z "$(docker compose ps -q checkpoint-bot-erc4626)" ]; then - echo "Checkpoint bot service exited unexpectedly:" - docker logs $dirname-checkpoint-bot-erc4626-1 - exit 1 -fi - -if [ -z "$(docker compose ps -q checkpoint-bot-steth)" ]; then - echo "Checkpoint bot service exited unexpectedly:" - docker logs $dirname-checkpoint-bot-steth-1 - exit 1 -fi - -# The rate-bot service should be running. -if [ -z "$(docker compose ps -q rate-bot)" ]; then - echo "Rate bot service exited unexpectedly:" - docker logs $dirname-rate-bot-1 +# The frontend service should be running. +if [ -z "$(docker compose ps -q frontend)" ]; then + echo "Frontend service exited unexpectedly:" + docker logs $dirname-frontend-1 exit 1 fi @@ -65,6 +52,13 @@ if [ -z "$(docker compose ps -q data)" ]; then exit 1 fi +# The analysis service should be running. +if [ -z "$(docker compose ps -q analysis)" ]; then + echo "Analysis service exited unexpectedly:" + docker logs $dirname-analysis-1 + exit 1 +fi + # The dashboard service should be running. if [ -z "$(docker compose ps -q dashboard)" ]; then echo "Dashboard service exited unexpectedly:" @@ -79,11 +73,33 @@ if [ -z "$(docker compose ps -q db)" ]; then exit 1 fi -# The frontend service should be running. -if [ -z "$(docker compose ps -q frontend)" ]; then - echo "Frontend service exited unexpectedly:" - docker logs $dirname-frontend-1 +# The checkpoint-bot service should be running. +if [ -z "$(docker compose ps -q checkpoint-bot)" ]; then + echo "Checkpoint bot service exited unexpectedly:" + docker logs $dirname-checkpoint-bot-1 + exit 1 +fi + +# The rate-bot service should be running. +if [ -z "$(docker compose ps -q rate-bot)" ]; then + echo "Rate bot service exited unexpectedly:" + docker logs $dirname-rate-bot-1 + exit 1 +fi + +# The invariance-check-bot service should be running. +if [ -z "$(docker compose ps -q invariance-check-bot)" ]; then + echo "Invariance check bot service exited unexpectedly:" + docker logs $dirname-invariance-check-bot-1 exit 1 fi +# The random-bot service should be running. +if [ -z "$(docker compose ps -q random-bot)" ]; then + echo "Random bot service exited unexpectedly:" + docker logs $dirname-random-bot-1 + exit 1 +fi + + echo "Containers ran successfully!"