Skip to content
Open
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
24 changes: 24 additions & 0 deletions ethexe/Dockerfile
Original file line number Diff line number Diff line change
@@ -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"]
15 changes: 15 additions & 0 deletions ethexe/contracts/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Compiler files
cache/
out/

# Ignores development broadcast logs
broadcast/

# Docs
docs/

# Dotenv file
.env

# npm
package-lock.json
4 changes: 1 addition & 3 deletions ethexe/contracts/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@ cache/
out/

# Ignores development broadcast logs
!/broadcast
/broadcast/*/31337/
/broadcast/**/dry-run/
broadcast/

# Docs
docs/
Expand Down
75 changes: 75 additions & 0 deletions ethexe/contracts/Dockerfile
Original file line number Diff line number Diff line change
@@ -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"]
6 changes: 3 additions & 3 deletions ethexe/contracts/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:_
Expand Down
File renamed without changes.
16 changes: 16 additions & 0 deletions ethexe/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -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
Loading