From 504641776cddaba2029b264477257dedbf1dd3c9 Mon Sep 17 00:00:00 2001 From: Arsen Yeremin Date: Fri, 7 Jun 2024 10:36:18 -0700 Subject: [PATCH] devnet settings --- .github/workflows/devnet_deploy_chain.yml | 4 +- docker/chain/Dockerfile | 168 +++++++++++++++------- hardhat/hardhat.config.ts | 5 + pkg/options/configs/devnet.toml | 2 +- 4 files changed, 127 insertions(+), 52 deletions(-) diff --git a/.github/workflows/devnet_deploy_chain.yml b/.github/workflows/devnet_deploy_chain.yml index 460160f3..e7024227 100644 --- a/.github/workflows/devnet_deploy_chain.yml +++ b/.github/workflows/devnet_deploy_chain.yml @@ -10,6 +10,7 @@ jobs: uses: actions/checkout@v4 with: context: app + ref: arsen/build-devnet - name: Configure AWS Credentials uses: aws-actions/configure-aws-credentials@v1 @@ -63,7 +64,8 @@ jobs: docker pull $ECR_REGISTRY/$ECR_REPOSITORY_CHAIN:latest docker run \ -d \ + --privileged \ --restart always \ --name chain \ - -v /data/chain:/data/chain \ + # -v /data/chain:/data/chain \ $ECR_REGISTRY/$ECR_REPOSITORY_CHAIN:latest diff --git a/docker/chain/Dockerfile b/docker/chain/Dockerfile index ffca2460..3b94a3c9 100644 --- a/docker/chain/Dockerfile +++ b/docker/chain/Dockerfile @@ -1,63 +1,131 @@ ARG expose_via=local -FROM golang:1.22.3 AS base +# FROM golang:1.22.3 AS base +FROM docker:24.0.5-dind AS base + + +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 + + + +# FROM base AS expose-cloudflare 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 +WORKDIR /l2chain +COPY . . RUN touch run -RUN echo "#!/bin/bash" >> 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 +# RUN echo "#!/bin/bash" >> run +# RUN ["docker","pull", "offchainlabs/nitro-node:v2.3.4-b4cc111"] +RUN apk update +RUN apk add bash +RUN apk add nodejs +RUN apk add npm -FROM base AS expose-local -EXPOSE 8545 -EXPOSE 8546 -FROM expose-$expose_via AS final -RUN echo "./run-node" >> run -RUN echo "sleep infinity" >> run +# RUN echo "/usr/local/bin/dockerd & " >> run +RUN echo "dockerd-entrypoint.sh & " >> run + + +RUN echo "sleep 2 " >> 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 0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266 "\ +" --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 "\ +" " >> run +# RUN dpkg -i cloudflared-linux-${arch}.deb + + +# RUN echo "sleep 5 " >> 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 + +RUN echo "tail -f /dev/null" >> run + +# FROM base AS expose-local +# EXPOSE 8547 +# EXPOSE 8548 + +# FROM expose-$expose_via AS final +# RUN echo "./run-node" >> run +# RUN echo "sleep infinity" >> run +# RUN /usr/local/bin/dockerd + +RUN wget https://github.com/cloudflare/cloudflared/releases/latest/download/cloudflared-linux-amd64 +RUN echo "cd .." >> run +RUN echo "./cloudflared-linux-amd64 tunnel1 run --token $cloudflare_token_http &" >> run +RUN echo "./cloudflared-linux-amd64 tunnel run --token $cloudflare_token_ws &" >> run + +RUN chmod +x cloudflared-linux-amd64 RUN chmod +x run +# RUN ls + + +ENTRYPOINT ["bash", "./run"] -CMD ["/bin/bash", "./run"] +#example use: +# docker build -t l2:latest -f docker/chain/Dockerfile . +# docker run --privileged l2:latest \ No newline at end of file diff --git a/hardhat/hardhat.config.ts b/hardhat/hardhat.config.ts index 4857b38c..9cbfdc7e 100644 --- a/hardhat/hardhat.config.ts +++ b/hardhat/hardhat.config.ts @@ -54,6 +54,11 @@ const config: HardhatUserConfig = { chainId: 412346, accounts: [getAccount('admin').privateKey], }, + devnet: { + url: 'http://0.0.0.0:8547', + chainId: 412346, + accounts: [getAccount('admin').privateKey], + }, }, etherscan: { diff --git a/pkg/options/configs/devnet.toml b/pkg/options/configs/devnet.toml index 6f1373e9..6217e257 100644 --- a/pkg/options/configs/devnet.toml +++ b/pkg/options/configs/devnet.toml @@ -4,7 +4,7 @@ mediator = ["0x90F79bf6EB2c4f870365E785982E1f101E93b906"] [web3] rpc_url = "wss://devnet-chain-ws.lilypad.tech" -chain_id = 421614 +chain_id = 412346 controller_address = "0x4ed7c70F96B99c776995fB64377f0d4aB3B0e1C1" payments_address = "0x2279B7A0a67DB372996a5FaB50D91eAA73d2eBe6" storage_address = "0xB7f8BC63BbcaD18155201308C8f3540b07f84F5e"