From 7c90249e92d1268d1bbdc65c3f1aa074e945ff02 Mon Sep 17 00:00:00 2001 From: StackOverflowExcept1on <109800286+StackOverflowExcept1on@users.noreply.github.com> Date: Fri, 13 Mar 2026 15:33:32 +0300 Subject: [PATCH] feat(ethexe): add Dockerfile for ethereum & ethexe node --- ethexe/Dockerfile | 24 ++++++ ethexe/contracts/.dockerignore | 15 ++++ ethexe/contracts/.gitignore | 4 +- ethexe/contracts/Dockerfile | 75 +++++++++++++++++++ ethexe/contracts/README.md | 6 +- .../deploy.sh} | 0 ethexe/docker-compose.yml | 16 ++++ 7 files changed, 134 insertions(+), 6 deletions(-) create mode 100644 ethexe/Dockerfile create mode 100644 ethexe/contracts/.dockerignore create mode 100644 ethexe/contracts/Dockerfile rename ethexe/{scripts/deploy-ethereum-contracts.sh => contracts/deploy.sh} (100%) create mode 100644 ethexe/docker-compose.yml diff --git a/ethexe/Dockerfile b/ethexe/Dockerfile new file mode 100644 index 00000000000..27d8d236c4a --- /dev/null +++ b/ethexe/Dockerfile @@ -0,0 +1,24 @@ +FROM ubuntu:24.04 AS builder +WORKDIR / +ENV PATH="${PATH}:/root/.cargo/bin" +RUN apt update && \ + apt install --no-install-recommends --yes \ + build-essential \ + ca-certificates \ + clang \ + curl \ + git \ + protobuf-compiler && \ + rm -rf /var/lib/apt/lists/* && \ + curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- --default-toolchain none -y && \ + git clone --depth 1 --recurse-submodules https://github.com/gear-tech/gear.git && \ + cd gear && \ + cargo clean && \ + cargo build --package ethexe-cli --release && \ + cp ./target/release/ethexe ethexe-bin && \ + rm -rf /root/.cargo/registry /root/.cargo/git target + +FROM ubuntu:24.04 +WORKDIR /vara-eth-node +COPY --from=builder /gear/ethexe-bin /usr/local/bin/ethexe +CMD ["ethexe", "run"] diff --git a/ethexe/contracts/.dockerignore b/ethexe/contracts/.dockerignore new file mode 100644 index 00000000000..29771cfc707 --- /dev/null +++ b/ethexe/contracts/.dockerignore @@ -0,0 +1,15 @@ +# Compiler files +cache/ +out/ + +# Ignores development broadcast logs +broadcast/ + +# Docs +docs/ + +# Dotenv file +.env + +# npm +package-lock.json diff --git a/ethexe/contracts/.gitignore b/ethexe/contracts/.gitignore index a3f3e37cac4..29771cfc707 100644 --- a/ethexe/contracts/.gitignore +++ b/ethexe/contracts/.gitignore @@ -3,9 +3,7 @@ cache/ out/ # Ignores development broadcast logs -!/broadcast -/broadcast/*/31337/ -/broadcast/**/dry-run/ +broadcast/ # Docs docs/ diff --git a/ethexe/contracts/Dockerfile b/ethexe/contracts/Dockerfile new file mode 100644 index 00000000000..55cbf1f7a9b --- /dev/null +++ b/ethexe/contracts/Dockerfile @@ -0,0 +1,75 @@ +FROM ubuntu:24.04 AS builder +# required +ARG PRIVATE_KEY +ARG ROUTER_AGGREGATED_PUBLIC_KEY_X +ARG ROUTER_AGGREGATED_PUBLIC_KEY_Y +ARG ROUTER_VERIFIABLE_SECRET_SHARING_COMMITMENT +ARG ROUTER_VALIDATORS_LIST +# optional +ARG SENDER_ADDRESS +ARG IS_POA="true" +# constants +ARG RPC_URL="http://127.0.0.1:8545" +ARG PREDEFINED_PRIVATE_KEY="0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80" +WORKDIR /contracts +COPY . . +ENV PATH="${PATH}:/root/.foundry/bin" +ENV NVM_DIR="/root/.nvm" +RUN test -n "${PRIVATE_KEY}" || { echo "PRIVATE_KEY is required" >&2; exit 1; } && \ + test -n "${ROUTER_AGGREGATED_PUBLIC_KEY_X}" || { echo "ROUTER_AGGREGATED_PUBLIC_KEY_X is required" >&2; exit 1; } && \ + test -n "${ROUTER_AGGREGATED_PUBLIC_KEY_Y}" || { echo "ROUTER_AGGREGATED_PUBLIC_KEY_Y is required" >&2; exit 1; } && \ + test -n "${ROUTER_VERIFIABLE_SECRET_SHARING_COMMITMENT}" || { echo "ROUTER_VERIFIABLE_SECRET_SHARING_COMMITMENT is required" >&2; exit 1; } && \ + test -n "${ROUTER_VALIDATORS_LIST}" || { echo "ROUTER_VALIDATORS_LIST is required" >&2; exit 1; } && \ + apt update && \ + apt install --no-install-recommends --yes \ + ca-certificates \ + curl \ + git \ + jq && \ + rm -rf /var/lib/apt/lists/* && \ + curl -L https://foundry.paradigm.xyz | bash && \ + foundryup && \ + forge --version && \ + forge compiler resolve && \ + curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.4/install.sh | bash && \ + \. "$NVM_DIR/nvm.sh" && \ + nvm install --lts && \ + npm install -g npm@latest && \ + node --version && \ + npm --version && \ + npx @openzeppelin/upgrades-core@^1.37.0 && \ + ( \ + anvil --dump-state ./chain-state.json & \ + ANVIL_PID=$! && \ + cast block-number --rpc-url $RPC_URL && \ + # 100 ETH in wei for each address + cast send \ + --rpc-url $RPC_URL \ + --value 100000000000000000000 \ + --private-key $PREDEFINED_PRIVATE_KEY \ + $(cast wallet addr --private-key $PRIVATE_KEY) && \ + test -n "$SENDER_ADDRESS" && cast send \ + --rpc-url $RPC_URL \ + --value 100000000000000000000 \ + --private-key $PREDEFINED_PRIVATE_KEY \ + $SENDER_ADDRESS || true && \ + echo "$ROUTER_VALIDATORS_LIST" | tr ',' '\n' | \ + while read VALIDATOR_ADDRESS; do \ + cast send \ + --rpc-url $RPC_URL \ + --value 100000000000000000000 \ + --private-key $PREDEFINED_PRIVATE_KEY \ + "$VALIDATOR_ADDRESS" || true; \ + done && \ + ./deploy.sh $RPC_URL && \ + sleep 5 && \ + kill -2 $ANVIL_PID && \ + wait $ANVIL_PID \ + ) + +FROM ubuntu:24.04 +WORKDIR /vara-eth-ethereum-node +COPY --from=builder /contracts/chain-state.json . +COPY --from=builder /root/.foundry/bin/anvil /usr/local/bin/anvil +EXPOSE 8545 +CMD ["anvil", "--block-time", "12", "--load-state", "./chain-state.json", "--host", "0.0.0.0"] diff --git a/ethexe/contracts/README.md b/ethexe/contracts/README.md index 099e7dcc47a..9fba7385dfe 100644 --- a/ethexe/contracts/README.md +++ b/ethexe/contracts/README.md @@ -52,12 +52,12 @@ $ source .env # When running local node, execute `unset ETHERSCAN_API_KEY` to skip verification $ unset ETHERSCAN_API_KEY -$ ../scripts/deploy-ethereum-contracts.sh $LOCAL_RPC_URL +$ ./deploy.sh $LOCAL_RPC_URL # When deploying to network, execute `export ETHERSCAN_API_KEY=$ETHERSCAN_API_KEY` $ export ETHERSCAN_API_KEY=$ETHERSCAN_API_KEY -$ ../scripts/deploy-ethereum-contracts.sh $MAINNET_RPC_URL -$ ../scripts/deploy-ethereum-contracts.sh $HOODI_RPC_URL +$ ./deploy.sh $MAINNET_RPC_URL +$ ./deploy.sh $HOODI_RPC_URL ``` _Notes:_ diff --git a/ethexe/scripts/deploy-ethereum-contracts.sh b/ethexe/contracts/deploy.sh similarity index 100% rename from ethexe/scripts/deploy-ethereum-contracts.sh rename to ethexe/contracts/deploy.sh diff --git a/ethexe/docker-compose.yml b/ethexe/docker-compose.yml new file mode 100644 index 00000000000..7e57c6788aa --- /dev/null +++ b/ethexe/docker-compose.yml @@ -0,0 +1,16 @@ +services: + vara-eth-ethereum-node: + container_name: vara-eth-ethereum-node + image: gear-tech/vara-eth-ethereum-node:latest + build: + context: ./contracts + dockerfile: Dockerfile + args: + PRIVATE_KEY: ${PRIVATE_KEY} + ROUTER_AGGREGATED_PUBLIC_KEY_X: ${ROUTER_AGGREGATED_PUBLIC_KEY_X} + ROUTER_AGGREGATED_PUBLIC_KEY_Y: ${ROUTER_AGGREGATED_PUBLIC_KEY_Y} + ROUTER_VERIFIABLE_SECRET_SHARING_COMMITMENT: ${ROUTER_VERIFIABLE_SECRET_SHARING_COMMITMENT} + ROUTER_VALIDATORS_LIST: ${ROUTER_VALIDATORS_LIST} + SENDER_ADDRESS: ${SENDER_ADDRESS} + ports: + - 8545:8545