Skip to content
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
44 changes: 44 additions & 0 deletions clients/ops-l1/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
FROM ethereum/client-go:v1.10.16 AS base

RUN apk add --no-cache jq yarn git linux-headers gcompat
RUN /usr/local/bin/geth console --exec 'console.log(admin.nodeInfo.name)' --maxpeers=0 --nodiscover --dev 2>/dev/null | head -1 > /version.txt
ENV GLIBC_KEY=https://alpine-pkgs.sgerrand.com/sgerrand.rsa.pub
ENV GLIBC_KEY_FILE=/etc/apk/keys/sgerrand.rsa.pub
ENV GLIBC_RELEASE=https://github.com/sgerrand/alpine-pkg-glibc/releases/download/2.35-r0/glibc-2.35-r0.apk
RUN wget -q -O ${GLIBC_KEY_FILE} ${GLIBC_KEY} \
&& wget -O glibc.apk ${GLIBC_RELEASE} \
&& apk add glibc.apk --force

# copy forge
FROM ghcr.io/foundry-rs/foundry:latest as foundry
FROM base
COPY --from=foundry /usr/local/bin/forge /usr/local/bin/forge

# Regenerate the L1 genesis file
RUN mkdir /hive
ADD genesis.json /genesis.json
RUN date +%s | xargs printf "0x%x" > /hive/genesis_timestamp
RUN GENESIS_TIMESTAMP=$(cat /hive/genesis_timestamp); jq ". | .timestamp = \"$GENESIS_TIMESTAMP\" " < ./genesis.json > /hive/genesis-l1.json

# Inject the startup script
ADD entrypoint.sh /entrypoint.sh
RUN chmod +x /entrypoint.sh

# Deploy contracts using Hardhat
RUN git clone https://github.com/ethereum-optimism/optimistic-specs /opt
RUN cd /opt && git submodule init && git submodule update
RUN cp -r /opt/packages/contracts /hive/contracts
# Defer until L1 rpc server is up; called from devnet.go
ADD deploy.sh /hive-bin/deploy.sh
RUN chmod +x /hive-bin/deploy.sh

# Helper scripts; called from devnet.go
ADD cat.sh /hive-bin/cat.sh
RUN chmod +x /hive-bin/cat.sh

VOLUME ["/db"]

EXPOSE 8545/tcp
EXPOSE 8546/tcp

ENTRYPOINT ["/bin/sh", "/entrypoint.sh"]
3 changes: 3 additions & 0 deletions clients/ops-l1/cat.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/sh

cat $1
10 changes: 10 additions & 0 deletions clients/ops-l1/deploy.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/sh

cd /hive/contracts
yarn
yarn build
export L2OO_STARTING_BLOCK_TIMESTAMP=$(cat /hive/genesis_timestamp)
echo "L2OO_STARTING_BLOCK_TIMESTAMP=$L2OO_STARTING_BLOCK_TIMESTAMP"
yarn hardhat --network devnetL1 deploy

echo "Deployed L1 contracts"
61 changes: 61 additions & 0 deletions clients/ops-l1/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
#!/bin/sh
set -exu

VERBOSITY=${GETH_VERBOSITY:-3}
GETH_DATA_DIR=/db
GETH_CHAINDATA_DIR="$GETH_DATA_DIR/geth/chaindata"
GETH_KEYSTORE_DIR="$GETH_DATA_DIR/keystore"
CHAIN_ID=$(cat /hive/genesis-l1.json | jq -r .config.chainId)
BLOCK_SIGNER_PRIVATE_KEY="3e4bde571b86929bf08e2aaad9a6a1882664cd5e65b96fff7d03e1c4e6dfa15c"
BLOCK_SIGNER_ADDRESS="0xca062b0fd91172d89bcd4bb084ac4e21972cc467"

if [ ! -d "$GETH_KEYSTORE_DIR" ]; then
echo "$GETH_KEYSTORE_DIR missing, running account import"
echo -n "pwd" > "$GETH_DATA_DIR"/password
echo -n "$BLOCK_SIGNER_PRIVATE_KEY" | sed 's/0x//' > "$GETH_DATA_DIR"/block-signer-key
geth account import \
--datadir="$GETH_DATA_DIR" \
--password="$GETH_DATA_DIR"/password \
"$GETH_DATA_DIR"/block-signer-key
else
echo "$GETH_KEYSTORE_DIR exists."
fi

if [ ! -d "$GETH_CHAINDATA_DIR" ]; then
echo "$GETH_CHAINDATA_DIR missing, running init"
echo "Initializing genesis."
geth --verbosity="$VERBOSITY" init \
--datadir="$GETH_DATA_DIR" \
"/hive/genesis-l1.json"
else
echo "$GETH_CHAINDATA_DIR exists."
fi

# Warning: Archive mode is required, otherwise old trie nodes will be
# pruned within minutes of starting the devnet.

exec geth \
--datadir="$GETH_DATA_DIR" \
--verbosity="$VERBOSITY" \
--http \
--http.corsdomain="*" \
--http.vhosts="*" \
--http.addr=0.0.0.0 \
--http.port=8545 \
--http.api=web3,debug,eth,txpool,net,engine \
--ws \
--ws.addr=0.0.0.0 \
--ws.port=8546 \
--ws.origins="*" \
--ws.api=debug,eth,txpool,net,engine \
--syncmode=full \
--nodiscover \
--maxpeers=1 \
--networkid=$CHAIN_ID \
--unlock=$BLOCK_SIGNER_ADDRESS \
--mine \
--miner.etherbase=$BLOCK_SIGNER_ADDRESS \
--password="$GETH_DATA_DIR"/password \
--allow-insecure-unlock \
--gcmode=archive \
"$@"
Loading