Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Localnet Update #383

Merged
merged 7 commits into from
Jan 31, 2025
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
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
128 changes: 50 additions & 78 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: 120s
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 All @@ -265,7 +275,7 @@ services:
- "./deploy-config.json:/git/optimism/packages/contracts-bedrock/deploy-config/devnetL1.json"
- "./prestate-proof.json:/git/optimism/op-program/bin/prestate-proof.json"
- { type: "tmpfs", target: "/tmp" }
restart: on-failure
restart: always
networks:
e2e:

Expand All @@ -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: 120s
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 All @@ -300,7 +311,7 @@ services:
- "./deploy-config.json:/git/optimism/packages/contracts-bedrock/deploy-config/devnetL1.json"
- "./prestate-proof.json:/git/optimism/op-program/bin/prestate-proof.json"
- { type: "tmpfs", target: "/tmp" }
restart: on-failure
restart: always
networks:
e2e:

Expand All @@ -316,11 +327,10 @@ services:
condition: "service_started"
op-geth-l2:
condition: "service_healthy"
bssd:
condition: "service_started"
healthcheck:
test: ["CMD-SHELL", "nc -w 1 -vz 0.0.0.0 9222"]
timeout: 1s
retries: 300
interval: 1s
start_period: 180s
environment:
OP_NODE_BSS_WS: "http://bssd:8081/v1/ws"
command:
Expand Down Expand Up @@ -375,11 +385,10 @@ services:
condition: "service_started"
op-geth-l2-2:
condition: "service_healthy"
bssd:
condition: "service_started"
healthcheck:
test: ["CMD-SHELL", "nc -w 1 -vz 0.0.0.0 9222"]
timeout: 1s
retries: 300
interval: 1s
start_period: 180s
environment:
OP_NODE_BSS_WS: "http://bssd:8081/v1/ws"
command:
Expand Down Expand Up @@ -431,11 +440,10 @@ services:
condition: "service_started"
op-geth-l2-3:
condition: "service_healthy"
bssd:
condition: "service_started"
healthcheck:
test: ["CMD-SHELL", "nc -w 1 -vz 0.0.0.0 9222"]
timeout: 1s
retries: 300
interval: 1s
start_period: 180s
environment:
OP_NODE_BSS_WS: "http://bssd:8081/v1/ws"
command:
Expand Down Expand Up @@ -482,6 +490,8 @@ services:
deploy:
restart_policy:
condition: "any"
healthcheck:
start_period: 180s
command:
- "op-batcher/bin/op-batcher"
- "--l2-eth-rpc=http://op-geth-l2:8546,http://op-geth-l2-2:8546,http://op-geth-l2-3:8546"
Expand All @@ -505,6 +515,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 +536,20 @@ 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"
healthcheck:
start_period: 180s
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,9 +583,11 @@ services:
e2e:
depends_on:
op-node:
condition: "service_healthy"
condition: "service_started"
op-geth-l2:
condition: "service_healthy"
healthcheck:
start_period: 180s
ports:
- "127.0.0.1:50050:50050"

Expand Down Expand Up @@ -648,9 +620,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 +655,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 +689,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
Loading