From 93cc037e39ccb9448726ba4083f03158dbf5d0d3 Mon Sep 17 00:00:00 2001 From: arsen3d Date: Thu, 13 Jun 2024 10:44:59 -0700 Subject: [PATCH] Configuration update for Arbitrum (#154) --- .github/workflows/devnet_deploy_chain.yml | 9 +- .gitignore | 5 +- docker/chain/Dockerfile | 114 ++++++++++++---------- hardhat/hardhat.config.ts | 6 +- stack | 2 +- 5 files changed, 75 insertions(+), 61 deletions(-) diff --git a/.github/workflows/devnet_deploy_chain.yml b/.github/workflows/devnet_deploy_chain.yml index 460160f3..d1052715 100644 --- a/.github/workflows/devnet_deploy_chain.yml +++ b/.github/workflows/devnet_deploy_chain.yml @@ -50,9 +50,9 @@ jobs: ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }} ECR_REPOSITORY_CHAIN: ${{ secrets.ECR_REPOSITORY_CHAIN }} with: - host: ${{ secrets.EC2_HOST_CHAIN }} - username: ${{ secrets.EC2_USERNAME_CHAIN }} - key: ${{ secrets.EC2_PRIVATE_KEY_CHAIN }} + host: ${{ secrets.DEVNET_EC2_HOST_CHAIN }} + username: ${{ secrets.DEVNET_EC2_USERNAME_CHAIN }} + key: ${{ secrets.DEVNET_EC2_PRIVATE_KEY_CHAIN }} envs: ECR_REGISTRY, ECR_REPOSITORY_CHAIN script_stop: true script: | @@ -60,10 +60,11 @@ jobs: docker rm chain || true aws ecr get-login-password --region us-east-1 | docker login --username AWS --password-stdin $ECR_REGISTRY docker system prune -af + docker system prune --volumes -f docker pull $ECR_REGISTRY/$ECR_REPOSITORY_CHAIN:latest docker run \ -d \ --restart always \ + --privileged \ --name chain \ - -v /data/chain:/data/chain \ $ECR_REGISTRY/$ECR_REPOSITORY_CHAIN:latest diff --git a/.gitignore b/.gitignore index 4577b70e..caa95de3 100644 --- a/.gitignore +++ b/.gitignore @@ -1,10 +1,7 @@ hardhat/node_modules hardhat/artifacts hardhat/cache -hardhat/deployments/hardhat -hardhat/deployments/localhost -hardhat/deployments/geth -hardhat/deployments +hardhat/deployments/* hardhat/typechain-types node_modules/* # Ignore the binary executable diff --git a/docker/chain/Dockerfile b/docker/chain/Dockerfile index ffca2460..a25598e7 100644 --- a/docker/chain/Dockerfile +++ b/docker/chain/Dockerfile @@ -1,63 +1,75 @@ ARG expose_via=local +ARG arch=amd64 -FROM golang:1.22.3 AS base +FROM docker:24.0.5-dind AS base +ARG admin_address="0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266" -ARG arch=amd64 -ARG cloudflare_token_http="not-a-token" -ARG cloudflare_token_ws="not-a-token" -ARG geth_version=v1.13.5 - -WORKDIR /geth - -RUN git clone --quiet --branch ${geth_version} --depth 1 https://github.com/ethereum/go-ethereum . -RUN --mount=type=cache,target=/go/pkg/mod --mount=type=cache,target=/root/.cache/go-build go run build/ci.go install -static ./cmd/geth - -RUN /geth/build/bin/geth version -RUN mv /geth/build/bin/geth /usr/local/bin/ - -ARG admin_address="0x0" - -RUN touch fund-admin -RUN echo "#!/bin/bash" >> fund-admin -RUN echo "geth --exec \"eth.sendTransaction({from: eth.coinbase, to: \\\"${admin_address}\\\", value: new web3.BigNumber(eth.getBalance(eth.coinbase)).minus(web3.toWei(1, \\\"ether\\\")) })\" attach /data/chain/geth.ipc" >> fund-admin -RUN chmod +x fund-admin - -RUN touch run-node -RUN echo "#!/bin/bash" >> run-node -RUN echo "geth --datadir /data/chain --dev --ws --ws.api web3,eth,net --ws.addr 0.0.0.0 --ws.port 8546 --ws.origins '*' --http --http.api web3,eth,net --http.addr 0.0.0.0 --http.corsdomain '*' --http.port 8545 --http.vhosts '*' &" >> run-node -RUN chmod +x run-node - -RUN touch reset -RUN echo "#!/bin/bash" >> reset -RUN echo "echo '- Kill geth'" >> reset -RUN echo "pkill -INT geth" >> reset -RUN echo "sleep 5" >> reset -RUN echo "echo '- Clear data'" >> reset -RUN echo "rm -rf /data/chain/*" >> reset -RUN echo "echo '- Restart geth'" >> reset -RUN echo "./run-node" >> reset -RUN echo "sleep 5" >> reset -RUN echo "echo '- Fund admin'" >> reset -RUN echo "./fund-admin" >> reset -RUN echo "echo '- Done'" >> reset -RUN chmod +x reset +RUN apk update +RUN apk add bash +RUN apk add nodejs +RUN apk add npm + +WORKDIR /l2chain +COPY . . RUN touch run RUN echo "#!/bin/bash" >> run +RUN echo "dockerd-entrypoint.sh & " >> run +RUN echo "until docker info >/dev/null 2>&1; do " >> run +RUN echo " echo 'Waiting for Docker to start...'" >> run +RUN echo " sleep 1" >> run +RUN echo "done" >> run + +RUN echo "docker pull offchainlabs/nitro-node:v2.3.4-b4cc111 " >> run + +RUN echo "docker run -d --name devnet -p 0.0.0.0:8547:8547 -p 0.0.0.0:8548:8548 offchainlabs/nitro-node:v2.3.4-b4cc111 "\ +" --init.dev-init " \ +" --init.dev-init-address $admin_address "\ +" --node.dangerous.no-l1-listener "\ +" --node.parent-chain-reader.enable=false "\ +" --parent-chain.id=1337 "\ +" --chain.id=412346 "\ +" --persistent.chain /tmp/dev-test "\ +" --node.sequencer "\ +" --execution.sequencer.enable "\ +" --node.dangerous.no-sequencer-coordinator "\ +" --node.staker.enable=false "\ +" --init.empty=false "\ +" --http.port 8547 "\ +" --http.addr 0.0.0.0 "\ +" --ws.port 8548 "\ +" --ws.addr 0.0.0.0 "\ +" --http.corsdomain=* "\ +" --http.vhosts=* "\ +" --ws.origins=* "\ +" " >> run + +RUN echo "until wget -qO- http://0.0.0.0:8547 >/dev/null 2>&1; do " >> run +RUN echo " echo 'Waiting for Nitro to start...'" >> run +RUN echo " sleep 1" >> run +RUN echo "done" >> run + +RUN echo "cd hardhat" >> run +RUN echo "npm install" >> run +RUN echo "npx hardhat deploy --network devnet" >> run +RUN echo "npx hardhat run scripts/fund-services-ether.ts --network devnet" >> run +RUN echo "npx hardhat run scripts/fund-services-tokens.ts --network devnet " >> run +RUN echo "npx hardhat run scripts/print-l2-config.ts --network devnet" >> run FROM base AS expose-cloudflare -RUN curl -L --output cloudflared.deb https://github.com/cloudflare/cloudflared/releases/latest/download/cloudflared-linux-${arch}.deb -RUN dpkg -i cloudflared.deb -RUN echo "cloudflared tunnel --metrics 0.0.0.0:11111 run --token $cloudflare_token_http --url http://localhost:8545 &" >> run -RUN echo "cloudflared tunnel --metrics 0.0.0.0:11112 run --token $cloudflare_token_ws --url http://localhost:8546 &" >> run +ARG cloudflare_token_http="not-a-token" +ARG cloudflare_token_ws="not-a-token" + +RUN wget https://github.com/cloudflare/cloudflared/releases/latest/download/cloudflared-linux-amd64 +RUN echo "cd .." >> run +RUN echo "./cloudflared-linux-amd64 tunnel run --token $cloudflare_token_http &" >> run +RUN echo "./cloudflared-linux-amd64 tunnel run --token $cloudflare_token_ws &" >> run +RUN chmod +x cloudflared-linux-amd64 FROM base AS expose-local -EXPOSE 8545 -EXPOSE 8546 +RUN echo "cd .." >> run -FROM expose-$expose_via AS final -RUN echo "./run-node" >> run -RUN echo "sleep infinity" >> run +FROM expose-$expose_via AS FINAL RUN chmod +x run - -CMD ["/bin/bash", "./run"] +RUN echo "wait -n" >> run +ENTRYPOINT ["bash", "./run"] diff --git a/hardhat/hardhat.config.ts b/hardhat/hardhat.config.ts index 46149dc2..70457e7f 100644 --- a/hardhat/hardhat.config.ts +++ b/hardhat/hardhat.config.ts @@ -34,7 +34,11 @@ const config: HardhatUserConfig = { chainId: CHAIN_ID, accounts: [getAccount('admin').privateKey], }, - + devnet: { + url: 'http://0.0.0.0:8547', + chainId: 412346, + accounts: [getAccount('admin').privateKey], + }, }, etherscan: { apiKey: process.env.ETHERSCAN_API_KEY, diff --git a/stack b/stack index 84c22a55..bc3681f4 100755 --- a/stack +++ b/stack @@ -289,4 +289,4 @@ function run() { doppler run --preserve-env -p run -c dev -- go run . run "$@" } -eval "$@" +eval "$@" \ No newline at end of file