Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Configuration update for Arbitrum #154

Merged
merged 1 commit into from
Jun 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions .github/workflows/devnet_deploy_chain.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,20 +50,21 @@ 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: |
docker stop chain || true
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
5 changes: 1 addition & 4 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -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
Expand Down
114 changes: 63 additions & 51 deletions docker/chain/Dockerfile
Original file line number Diff line number Diff line change
@@ -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
AquiGorka marked this conversation as resolved.
Show resolved Hide resolved
AquiGorka marked this conversation as resolved.
Show resolved Hide resolved
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"]
6 changes: 5 additions & 1 deletion hardhat/hardhat.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,11 @@ const config: HardhatUserConfig = {
chainId: CHAIN_ID,
accounts: [getAccount('admin').privateKey],
},

devnet: {
url: 'http://0.0.0.0:8547',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@arsen3d are we sure about this value? cc @bgins

chainId: 412346,
accounts: [getAccount('admin').privateKey],
},
},
etherscan: {
apiKey: process.env.ETHERSCAN_API_KEY,
Expand Down
2 changes: 1 addition & 1 deletion stack
Original file line number Diff line number Diff line change
Expand Up @@ -288,4 +288,4 @@ function run() {
doppler run --preserve-env -p run -c dev -- go run . run "$@"
}

eval "$@"
eval "$@"
Loading