Skip to content

Commit

Permalink
localnet update
Browse files Browse the repository at this point in the history
* add hvm phase 0 testing commits to localnet
* add hvm phase 0 starting timestamp to docker compose up
* make dependencies in docker compose more robust
  • Loading branch information
ClaytonNorthey92 committed Jan 29, 2025
1 parent 5cc01b7 commit 5db32e8
Show file tree
Hide file tree
Showing 5 changed files with 90 additions and 106 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/localnet-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ jobs:
run: docker compose -f ./e2e/docker-compose.yml build

- name: "run localnet"
run: docker compose -f ./e2e/docker-compose.yml up -d
run: HVM_PHASE0_TIMESTAMP=$(date --date='+120 seconds' +%s) docker compose -f ./e2e/docker-compose.yml up -d

- name: "kill an op-node after 15 seconds, then wait 3 minutes (the healthcheck interval + time for another sequencer to take over)"
run: sleep 15 && docker compose -f ./e2e/docker-compose.yml down op-node && sleep 180
Expand Down
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,10 @@ To run the full Hemi stack (non-sequencing), please see [NODE_RUNNING](localnode
Blocks at a **high rate**:

```shell
docker compose -f ./e2e/docker-compose.yml up --build
docker compose -f ./e2e/docker-compose.yml build

# set the hvm phase 0 timestamp slightly in the future, but ensure that all op-geths have the same
HVM_PHASE0_TIMESTAMP=$(date --date='+120 seconds' +%s) docker compose -f ./e2e/docker-compose.yml up
```

> [!NOTE]
Expand Down
118 changes: 39 additions & 79 deletions e2e/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,10 @@ services:
restart_policy:
condition: "any"
depends_on:
- "bitcoind"
bitcoind:
condition: "service_started"
raft:
condition: "service_completed_successfully"
command:
- "bitcoin-cli"
- "-regtest=1"
Expand Down Expand Up @@ -207,15 +210,21 @@ services:
dockerfile: "optimism-stack.Dockerfile"
context: "."
depends_on:
- "geth-l1"
geth-l1:
condition: "service_started"
bitcoind:
condition: "service_started"
bitcoind-initialblocks:
condition: "service_completed_successfully"
healthcheck:
test: ["CMD-SHELL", "nc -w 1 -vz 0.0.0.0 30303"]
timeout: 1s
test: ["CMD-SHELL", "ls /tmp/datadir/geth.ipc"]
interval: 5s
retries: 300
interval: 1s
start_period: 30s
environment:
ADMIN_PRIVATE_KEY: "${ADMIN_PRIVATE_KEY}"
OP_GETH_L1_RPC: "http://geth-l1:8545"
HVM_PHASE0_TIMESTAMP: ${HVM_PHASE0_TIMESTAMP}
working_dir: "/tmp"
command:
- "sh"
Expand All @@ -242,14 +251,15 @@ services:
op-geth-l2:
condition: "service_healthy"
healthcheck:
test: ["CMD-SHELL", "nc -w 1 -vz 0.0.0.0 30303"]
timeout: 1s
test: ["CMD-SHELL", "ls /tmp/datadir/geth.ipc"]
interval: 5s
retries: 300
interval: 1s
start_period: 30s
environment:
ADMIN_PRIVATE_KEY: "${ADMIN_PRIVATE_KEY}"
OP_GETH_L1_RPC: "http://geth-l1:8545"
ENTRYPOINT_SKIP_GENESIS: "true"
HVM_PHASE0_TIMESTAMP: ${HVM_PHASE0_TIMESTAMP}
working_dir: "/tmp"
command:
- "sh"
Expand Down Expand Up @@ -277,14 +287,15 @@ services:
op-geth-l2:
condition: "service_healthy"
healthcheck:
test: ["CMD-SHELL", "nc -w 1 -vz 0.0.0.0 30303"]
timeout: 1s
test: ["CMD-SHELL", "ls /tmp/datadir/geth.ipc"]
interval: 5s
retries: 300
interval: 1s
start_period: 30s
environment:
ADMIN_PRIVATE_KEY: "${ADMIN_PRIVATE_KEY}"
OP_GETH_L1_RPC: "http://geth-l1:8545"
ENTRYPOINT_SKIP_GENESIS: "true"
HVM_PHASE0_TIMESTAMP: ${HVM_PHASE0_TIMESTAMP}
working_dir: "/tmp"
command:
- "sh"
Expand Down Expand Up @@ -316,11 +327,8 @@ services:
condition: "service_started"
op-geth-l2:
condition: "service_healthy"
healthcheck:
test: ["CMD-SHELL", "nc -w 1 -vz 0.0.0.0 9222"]
timeout: 1s
retries: 300
interval: 1s
bssd:
condition: "service_started"
environment:
OP_NODE_BSS_WS: "http://bssd:8081/v1/ws"
command:
Expand Down Expand Up @@ -375,11 +383,8 @@ services:
condition: "service_started"
op-geth-l2-2:
condition: "service_healthy"
healthcheck:
test: ["CMD-SHELL", "nc -w 1 -vz 0.0.0.0 9222"]
timeout: 1s
retries: 300
interval: 1s
bssd:
condition: "service_started"
environment:
OP_NODE_BSS_WS: "http://bssd:8081/v1/ws"
command:
Expand Down Expand Up @@ -431,11 +436,8 @@ services:
condition: "service_started"
op-geth-l2-3:
condition: "service_healthy"
healthcheck:
test: ["CMD-SHELL", "nc -w 1 -vz 0.0.0.0 9222"]
timeout: 1s
retries: 300
interval: 1s
bssd:
condition: "service_started"
environment:
OP_NODE_BSS_WS: "http://bssd:8081/v1/ws"
command:
Expand Down Expand Up @@ -505,6 +507,10 @@ services:
condition: "service_healthy"
op-node:
condition: "service_started"
op-node-2:
condition: "service_started"
op-node-3:
condition: "service_started"
networks:
e2e:

Expand All @@ -522,64 +528,18 @@ services:
condition: "service_healthy"
op-node:
condition: "service_started"
command:
- "op-proposer/bin/op-proposer"
- "--poll-interval=1s"
- "--rpc.port=8560"
- "--l2oo-address=${L2OO_ADDRESS}"
- "--private-key=${ADMIN_PRIVATE_KEY}"
- "--l1-eth-rpc=http://geth-l1:8545"
- "--rollup-rpc=http://op-node:8547,http://op-node-2:8547,http://op-node-3:8547"
networks:
e2e:

op-proposer-2:
build:
dockerfile: "optimism-stack.Dockerfile"
context: "."
deploy:
restart_policy:
condition: "any"
depends_on:
geth-l1:
condition: "service_started"
op-geth-l2-2:
condition: "service_healthy"
op-node-2:
condition: "service_started"
command:
- "op-proposer/bin/op-proposer"
- "--poll-interval=1s"
- "--rpc.port=8560"
- "--rollup-rpc=http://op-node-2:8547"
- "--l2oo-address=${L2OO_ADDRESS}"
- "--private-key=${ADMIN_PRIVATE_KEY}"
- "--l1-eth-rpc=http://geth-l1:8545"
networks:
e2e:

op-proposer-3:
build:
dockerfile: "optimism-stack.Dockerfile"
context: "."
deploy:
restart_policy:
condition: "any"
depends_on:
geth-l1:
condition: "service_started"
op-geth-l2-3:
condition: "service_healthy"
op-node-3:
condition: "service_started"
command:
- "op-proposer/bin/op-proposer"
- "--poll-interval=1s"
- "--rpc.port=8560"
- "--rollup-rpc=http://op-node-3:8547"
- "--l2oo-address=${L2OO_ADDRESS}"
- "--private-key=${ADMIN_PRIVATE_KEY}"
- "--l1-eth-rpc=http://geth-l1:8545"
- "--rollup-rpc=http://op-node:8547,http://op-node-2:8547,http://op-node-3:8547"
networks:
e2e:

Expand Down Expand Up @@ -613,7 +573,7 @@ services:
e2e:
depends_on:
op-node:
condition: "service_healthy"
condition: "service_started"
op-geth-l2:
condition: "service_healthy"
ports:
Expand Down Expand Up @@ -648,9 +608,9 @@ services:
e2e:
depends_on:
op-node-2:
condition: "service_healthy"
condition: "service_started"
op-geth-l2-2:
condition: "service_healthy"
condition: "service_started"
ports:
- "127.0.0.1:50051:50051"

Expand Down Expand Up @@ -683,9 +643,9 @@ services:
e2e:
depends_on:
op-node-3:
condition: "service_healthy"
condition: "service_started"
op-geth-l2-3:
condition: "service_healthy"
condition: "service_started"
ports:
- "127.0.0.1:50052:50052"

Expand Down Expand Up @@ -717,4 +677,4 @@ networks:
e2e:
ipam:
config:
- subnet: 192.169.0.0/16
- subnet: 192.169.0.0/16
25 changes: 21 additions & 4 deletions e2e/entrypointl2.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,21 @@ if [ -z "${ENTRYPOINT_SKIP_GENESIS}" ]; then
sh /tmp/genesisl2.sh
fi

/bin/geth init --datadir /tmp/datadir /l2configs/genesis.json

/git/op-geth/build/bin/geth init --datadir /tmp/datadir /l2configs/genesis.json
BESTBLOCKHASH=$(curl --data-binary '{"jsonrpc": "1.0", "id": "curltest", "method": "getbestblockhash", "params": []}' -H 'content-type: text/plain;' http://user:password@bitcoind:18443/ | jq '.result')

/git/op-geth/build/bin/geth \
echo "best block hash $BESTBLOCKHASH"

curl --data-binary "{\"jsonrpc\": \"1.0\", \"id\": \"curltest\", \"method\": \"getblockheader\", \"params\": [$BESTBLOCKHASH]}" -H 'content-type: text/plain;' http://user:password@bitcoind:18443/

BLOCKHEIGHT=$(curl --data-binary "{\"jsonrpc\": \"1.0\", \"id\": \"curltest\", \"method\": \"getblockheader\", \"params\": [$BESTBLOCKHASH]}" -H 'content-type: text/plain;' http://user:password@bitcoind:18443/ | jq '.result.height')

BLOCKHEADER=$(curl --data-binary "{\"jsonrpc\": \"1.0\", \"id\": \"curltest\", \"method\": \"getblockheader\", \"params\": [$BESTBLOCKHASH, false]}" -H 'content-type: text/plain;' http://user:password@bitcoind:18443/ | jq -r '.result')

echo "setting hvm genesis to $BLOCKHEADER:$BLOCKHEIGHT"

/bin/geth \
--keystore \
/tmp/keystore \
--password \
Expand Down Expand Up @@ -43,8 +54,14 @@ fi
--authrpc.jwtsecret=/tmp/jwt.hex \
--gpo.maxprice=1 \
--tbc.network=localnet \
--tbc.initheight=1 \
--tbc.seeds='bitcoind:18444' \
--override.ecotone=1725868497 \
--override.canyon=1725868497 \
--override.cancun=1725868497
--override.cancun=1725868497 \
--hvm.headerdatadir=/tbc/headers \
--tbc.leveldbhome=/tbc/tbcdatadir \
--hvm.genesisheader=$BLOCKHEADER \
--hvm.genesisheight=$BLOCKHEIGHT \
--hvm.enabled \
--override.hvm0=$HVM_PHASE0_TIMESTAMP \
--tbc.network=localnet
46 changes: 25 additions & 21 deletions e2e/optimism-stack.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,30 @@
# Use of this source code is governed by the MIT License,
# which can be found in the LICENSE file.

FROM golang:1.22.6-bookworm@sha256:f020456572fc292e9627b3fb435c6de5dfb8020fbcef1fd7b65dd092c0ac56bb
FROM golang:1.23.4-bookworm@sha256:ef30001eeadd12890c7737c26f3be5b3a8479ccdcdc553b999c84879875a27ce AS build_1

RUN apt-get update
WORKDIR /git

RUN apt-get install -y nodejs npm jq
ARG OP_GETH_CACHE_BREAK=12F2
RUN git clone https://github.com/hemilabs/op-geth
WORKDIR /git/op-geth
RUN git checkout db09f46746b33a008d32d550b4ed0e91c33f1cd4

RUN npm install -g pnpm
WORKDIR /git/op-geth

RUN make

RUN go build -o /tmp ./...

FROM golang:1.22.6-bookworm@sha256:f020456572fc292e9627b3fb435c6de5dfb8020fbcef1fd7b65dd092c0ac56bb AS build_2

# store the latest geth here, build with go 1.23
COPY --from=build_1 /tmp/geth /bin/geth

RUN apt-get update

RUN apt-get install -y jq nodejs npm

WORKDIR /git

RUN curl -L https://foundry.paradigm.xyz | bash

Expand All @@ -20,25 +35,14 @@ ENV PATH="${PATH}:/root/.foundry/bin"

RUN foundryup

ARG OP_GETH_CACHE_BREAK=12F
RUN git clone https://github.com/hemilabs/op-geth
WORKDIR /git/op-geth
RUN git checkout 4c818bcfa33873c808cfb697ea1b713748338117
RUN npm install -g pnpm

WORKDIR /git

ARG OPTIMISM_CACHE_BREAK=1
COPY --from=build_1 /git/op-geth /git/op-geth
WORKDIR /git
RUN git clone https://github.com/hemilabs/optimism
WORKDIR /git/optimism
RUN git checkout adf68923d2b278641e405dd5bfc4f53196d58bbe

WORKDIR /git/op-geth

RUN make
RUN go install ./...

WORKDIR /git/optimism

RUN git checkout 5467ea32639c3cad6845161107939097587436d6
RUN git submodule update --init --recursive
RUN pnpm install
RUN pnpm install:abigen
Expand All @@ -62,4 +66,4 @@ WORKDIR /git/optimism

RUN make devnet-allocs

RUN apt-get install -y netcat-openbsd
RUN apt-get install -y netcat-openbsd

0 comments on commit 5db32e8

Please sign in to comment.