diff --git a/README.md b/README.md index ef37745..07b00b8 100644 --- a/README.md +++ b/README.md @@ -5,8 +5,12 @@ Runs off-chain services on a local anvil chain to help test 4337 functionality. ## 🖥️ Running locally ### Running the devnet +#### 1. copy [`docker-compose.devnet.yaml`](https://github.com/jakim929/aa-playground/blob/main/docker-compose.devnet.yaml) and [`.env.devnet`](https://github.com/jakim929/aa-playground/blob/main/.env.devnet) to your repo + +#### 2. Run services + ```sh -docker compose --env-file ./.env.devnet up +docker compose -f docker-compose.devnet.yaml --env-file ./.env.devnet up ``` This will: @@ -16,7 +20,7 @@ This will: 3. 📡 Launch the following bundler services against anvil node - [skandha](https://github.com/etherspot/skandha) (TypeScript, by [etherspot.io](https://etherspot.io/)) - [transeptor-bundler](https://github.com/transeptorlabs/transeptor-bundler) (TypesScript, by [Transeptor Labs](https://transeptorlabs.io/)) - - [rundler](https://github.com/alchemyplatform/rundler) (Rust, by [Alchemy](https://www.alchemy.com/)) + - [rundler](https://github.com/alchemyplatform/rundler) (Rust, by [Alchemy](https://www.alchemy.com/)) [COMING SOON 🔜] - Note: Rundler doesn't support unsafe mode yet, avoid using until this [issue](https://github.com/alchemyplatform/rundler/issues/470) is closed 4. 🌍 Set up a nginx reverse proxy at http://0.0.0.0:3010 with the following services: @@ -27,7 +31,6 @@ This will: | Anvil RPC (chainId: 31337) | `http://0.0.0.0:8545` | `http://0.0.0.0:3010/anvil-rpc` | | Skandha Bundler RPC | - | `http://0.0.0.0:3010/skandha-bundler-rpc` | | Transeptor Bundler RPC | - | `http://0.0.0.0:3010/transeptor-bundler-rpc` | -| Rundler Bundler RPC | - | `http://0.0.0.0:3010/rundler-bundler-rpc` | ## 📝 Basic Contract Deployments | Contract | Address | @@ -57,3 +60,22 @@ Made by [zerodev](https://zerodev.app/), Kernel is a modular smart account, and | [Kernel ECDSAValidator](https://github.com/zerodevapp/kernel/blob/main/src/validator/ECDSAValidator.sol) | `0x5A24eDA104aFb5d9181C57f7F46651ceBC5DdC7D` | + +## 🔨 Developing locally / building from scratch + +#### 1. Clone the repo +```sh +git clone --recurse-submodules https://github.com/jakim929/aa-playground.git +cd aa-playground +``` + +#### 2. Run services +```sh +docker compose --env-file ./.env.devnet up +``` + +or to use pre-built images on docker-hub + +```sh +docker compose -f docker-compose.devnet.yaml --env-file ./.env.devnet up +``` \ No newline at end of file diff --git a/docker-compose.devnet.yaml b/docker-compose.devnet.yaml new file mode 100644 index 0000000..aded422 --- /dev/null +++ b/docker-compose.devnet.yaml @@ -0,0 +1,82 @@ +version: '3.4' +services: + anvil: + image: ghcr.io/foundry-rs/foundry + restart: unless-stopped + container_name: anvil + environment: + - ANVIL_IP_ADDR=0.0.0.0 + command: ['anvil --block-time 2 --chain-id $CHAIN_ID'] + ports: + - "8545:8545" + healthcheck: + test: "cast block-number --rpc-url http://0.0.0.0:8545" + interval: 3s + timeout: 2s + + anvil-setup: + image: jakim929/aa-playground:anvil-setup-latest + container_name: anvil-setup + environment: + - RPC_URL=http://anvil:8545 + - DEPLOYER_EOA_PRIVATE_KEY=$DEPLOYER_EOA_PRIVATE_KEY + - ENTRYPOINT_CONTRACT_ADDRESS=$ENTRYPOINT_CONTRACT_ADDRESS + depends_on: + anvil: + condition: service_healthy + restart: "no" + + bundler-reverse-proxy-nginx: + image: jakim929/aa-playground:bundler-reverse-proxy-latest + container_name: bundler-reverse-proxy + ports: + - "3010:80" + depends_on: + anvil: + condition: service_healthy + skandha-bundler: + condition: service_healthy + transeptor-bundler: + condition: service_healthy + + skandha-bundler: + image: jakim929/aa-playground:skandha-latest + container_name: skandha-bundler + entrypoint: ["sh", "-c", "echo '{\"networks\":{\"dev\":{\"entryPoints\":[\"$ENTRYPOINT_CONTRACT_ADDRESS\"],\"relayer\":\"$BUNDLER_EOA_PRIVATE_KEY\",\"beneficiary\":\"$BUNDLER_EOA_ADDRESS\",\"rpcEndpoint\":\"http://anvil:8545\",\"minInclusionDenominator\":10,\"throttlingSlack\":10,\"banSlack\":10}}}' > /usr/app/config.json && node ./packages/cli/bin/skandha standalone"] + healthcheck: + test: > + wget --header='Content-Type: application/json' --no-verbose --tries=1 --output-document=- --spider --post-data='{"jsonrpc":"2.0","id":"1","method":"test","params":[]}' http://localhost:14337/$CHAIN_ID || exit 1 + interval: 3s + timeout: 3s + retries: 3 + start_period: 10s + depends_on: + anvil-setup: + condition: service_completed_successfully + + transeptor-bundler: + image: jakim929/aa-playground:transeptor-bundler-latest + container_name: transeptor-bundler + environment: + - MNEMONIC=$BUNDLER_EOA_MNEMONIC + - BENEFICIARY=$BUNDLER_EOA_ADDRESS + command: > + --port 4000 + --network http://anvil:8545 + --txMode base + --httpApi web3,eth,debug + --auto + --autoBundleInterval 12000 + --unsafe + healthcheck: + test: > + wget --header='Content-Type: application/json' --no-verbose --tries=1 --output-document=- --spider --post-data='{"jsonrpc":"2.0","id":"1","method":"test","params":[]}' http://localhost:4000/rpc || exit 1 + interval: 3s + timeout: 3s + retries: 3 + start_period: 10s + depends_on: + anvil-setup: + condition: service_completed_successfully + + \ No newline at end of file diff --git a/docker-compose.yaml b/docker-compose.yaml index eadf2c6..c634341 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -15,7 +15,6 @@ services: timeout: 2s anvil-setup: - image: aa-playground/anvil-setup-latest build: context: . dockerfile: Dockerfile @@ -31,7 +30,6 @@ services: restart: "no" bundler-reverse-proxy-nginx: - image: jakim929/aa-playground/bundler-reverse-proxy-latest build: context: . dockerfile: Dockerfile @@ -42,15 +40,15 @@ services: depends_on: anvil: condition: service_healthy - rundler-bundler: - condition: service_healthy skandha-bundler: condition: service_healthy transeptor-bundler: condition: service_healthy skandha-bundler: - image: jakim929/aa-playground:skandha-latest + build: + context: ./bundlers/skandha + dockerfile: ./Dockerfile container_name: skandha-bundler entrypoint: ["sh", "-c", "echo '{\"networks\":{\"dev\":{\"entryPoints\":[\"$ENTRYPOINT_CONTRACT_ADDRESS\"],\"relayer\":\"$BUNDLER_EOA_PRIVATE_KEY\",\"beneficiary\":\"$BUNDLER_EOA_ADDRESS\",\"rpcEndpoint\":\"http://anvil:8545\",\"minInclusionDenominator\":10,\"throttlingSlack\":10,\"banSlack\":10}}}' > /usr/app/config.json && node ./packages/cli/bin/skandha standalone"] healthcheck: @@ -64,26 +62,10 @@ services: anvil-setup: condition: service_completed_successfully - rundler-bundler: - image: jakim929/aa-playground:rundler-latest - container_name: rundler-bundler - environment: - - ENTRY_POINTS=$ENTRYPOINT_CONTRACT_ADDRESS - - NODE_HTTP=http://anvil:8545 - - CHAIN_ID=$CHAIN_ID - - BUILDER_PRIVATE_KEY=$BUNDLER_EOA_PRIVATE_KEY - healthcheck: - test: curl --fail http://localhost:3000/health || exit 1 - interval: 3s - timeout: 3s - retries: 3 - start_period: 10s - depends_on: - anvil-setup: - condition: service_completed_successfully - transeptor-bundler: - image: jakim929/aa-playground:transeptor-bundler-latest + build: + context: ./bundlers/transeptor-bundler + dockerfile: ./Dockerfile container_name: transeptor-bundler environment: - MNEMONIC=$BUNDLER_EOA_MNEMONIC diff --git a/nginx.reverse-proxy.conf b/nginx.reverse-proxy.conf index 37d2f0e..e87bd89 100644 --- a/nginx.reverse-proxy.conf +++ b/nginx.reverse-proxy.conf @@ -10,10 +10,6 @@ upstream transeptor-bundler { server transeptor-bundler:4000; } -upstream rundler-bundler { - server rundler-bundler:3000; -} - server { listen 80; server_name localhost; @@ -78,25 +74,4 @@ server { proxy_pass http://skandha-bundler/31337; } - - location /rundler-bundler-rpc { - if ($request_method = 'OPTIONS') { - add_header 'Access-Control-Max-Age' 1728000; - add_header 'Access-Control-Allow-Origin' '*'; - add_header 'Access-Control-Allow-Headers' 'Authorization,Accept,Origin,DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Content-Range,Range,Alchemy-Aa-Sdk-Version,Alchemy-Aa-Sdk-Signer,Alchemy-Aa-Sdk-Factory-Address'; - add_header 'Access-Control-Allow-Methods' 'GET,POST,OPTIONS,PUT,DELETE,PATCH'; - add_header 'Content-Type' 'application/json'; - add_header 'Content-Length' 0; - return 204; - } - - add_header 'Access-Control-Allow-Origin' '*'; - add_header 'Access-Control-Allow-Headers' 'Authorization,Accept,Origin,DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Content-Range,Range'; - add_header 'Access-Control-Allow-Methods' 'GET,POST,OPTIONS,PUT,DELETE,PATCH'; - proxy_hide_header 'Alchemy-Aa-Sdk-Signer'; - proxy_hide_header 'Alchemy-Aa-Sdk-Factory-Address'; - proxy_hide_header 'Alchemy-Aa-Sdk-Version'; - - proxy_pass http://rundler-bundler; - } }