Skip to content

Commit

Permalink
ci: Improve timestamp management in devnet (ethereum-optimism#329)
Browse files Browse the repository at this point in the history
This change sets timestamps to the current timestamp on fresh devnet deploys. This avoids the devnet having to fill in a bunch of blocks on startup. The timestamp is preserved between runs; `make devnet-clean` will erase the timestamp data if you want to start anew.
  • Loading branch information
mslipper authored Apr 7, 2022
1 parent 355f413 commit 9d16305
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 5 deletions.
3 changes: 2 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ devnet-up:
DEPOSIT_FEED_BYTECODE=$(shell cat ./packages/contracts/artifacts/contracts/L1/DepositFeed.sol/DepositFeed.json | jq .deployedBytecode) \
L1_BLOCK_INFO_BYTECODE=$(shell cat ./packages/contracts/artifacts/contracts/L2/L1Block.sol/L1Block.json | jq .deployedBytecode) \
WITHDRAWER_BYTECODE=$(shell cat ./packages/contracts/artifacts/contracts/L2/Withdrawer.sol/Withdrawer.json | jq .deployedBytecode) \
docker-compose up --build)
GENESIS_TIMESTAMP=$(shell date +%s) \
BUILDKIT_PROGRESS=plain docker-compose up --build)
.PHONY: devnet-up

devnet-down:
Expand Down
8 changes: 6 additions & 2 deletions ops/Dockerfile.l1
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
FROM ethereum/client-go:v1.10.16

ARG DEPOSIT_FEED_BYTECODE=""
ARG GENESIS_TIMESTAMP=""

RUN apk add --no-cache jq

COPY entrypoint.sh /entrypoint.sh
COPY genesis-l1.json /genesis.json

RUN cat /genesis.json | jq ". | .alloc.deaddeaddeaddeaddeaddeaddeaddeaddead0001.code = \"$DEPOSIT_FEED_BYTECODE\"" | tee /genesis-with-bytecode.json && \
mv /genesis-with-bytecode.json /genesis.json
RUN cat /genesis.json | \
jq ". | .alloc.deaddeaddeaddeaddeaddeaddeaddeaddead0001.code = \"$DEPOSIT_FEED_BYTECODE\"" | \
jq ". | .timestamp = \"$GENESIS_TIMESTAMP\"" | \
tee /genesis-with-bytecode.json && \
mv /genesis-with-bytecode.json /genesis.json

VOLUME ["/db"]

Expand Down
2 changes: 2 additions & 0 deletions ops/Dockerfile.l2
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ FROM ethereumoptimism/reference-optimistic-geth:latest

ARG L1_BLOCK_INFO_BYTECODE=""
ARG WITHDRAWER_BYTECODE=""
ARG GENESIS_TIMESTAMP=""

RUN apk add --no-cache jq

Expand All @@ -10,6 +11,7 @@ COPY genesis-l2.json /genesis.json

RUN cat /genesis.json | jq ". | .alloc.\"4200000000000000000000000000000000000014\".code = \"$L1_BLOCK_INFO_BYTECODE\"" \
| jq ". | .alloc.\"4200000000000000000000000000000000000015\".code = \"$WITHDRAWER_BYTECODE\"" \
| jq ". | .timestamp = \"$GENESIS_TIMESTAMP\"" \
| tee /genesis-with-bytecode.json && \
mv /genesis-with-bytecode.json /genesis.json

Expand Down
2 changes: 2 additions & 0 deletions ops/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ services:
dockerfile: Dockerfile.l1
args:
DEPOSIT_FEED_BYTECODE: $DEPOSIT_FEED_BYTECODE
GENESIS_TIMESTAMP: $GENESIS_TIMESTAMP
ports:
- "8545:8545"
volumes:
Expand All @@ -23,6 +24,7 @@ services:
args:
L1_BLOCK_INFO_BYTECODE: $L1_BLOCK_INFO_BYTECODE
WITHDRAWER_BYTECODE: $WITHDRAWER_BYTECODE
GENESIS_TIMESTAMP: $GENESIS_TIMESTAMP
ports:
- "9545:8545"
volumes:
Expand Down
2 changes: 1 addition & 1 deletion ops/genesis-l1.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
}
},
"nonce": "0x0",
"timestamp": "0x624DCCEC",
"timestamp": "",
"extraData": "0x0000000000000000000000000000000000000000000000000000000000000000ca062b0fd91172d89bcd4bb084ac4e21972cc4670000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
"gasLimit": "0x47b760",
"difficulty": "0x1",
Expand Down
2 changes: 1 addition & 1 deletion ops/genesis-l2.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"terminalTotalDifficulty": 0
},
"nonce": "0x1234",
"timestamp": "0x624DCCEC",
"timestamp": "",
"extraData": "0x",
"gasLimit": "0x4c4b40",
"difficulty": "0x1",
Expand Down

0 comments on commit 9d16305

Please sign in to comment.