Skip to content

Commit

Permalink
simulators (op): refactor - add bss client (#6)
Browse files Browse the repository at this point in the history
* simulators (op): refactor - add bss client

* clients (ops-l1): add batchsubmitter faucet

* clients (op): rename for new build

* simulators (op): update go mod
  • Loading branch information
tuxcanfly authored and mslipper committed Sep 8, 2022
1 parent 8b0eaa2 commit e8f075f
Show file tree
Hide file tree
Showing 18 changed files with 245 additions and 43 deletions.
20 changes: 20 additions & 0 deletions clients/ops-bss/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
FROM golang:1.18.0-alpine3.15 as builder

RUN apk add --no-cache make gcc musl-dev linux-headers git jq bash

RUN git clone https://github.com/ethereum-optimism/optimistic-specs /app

WORKDIR /app
RUN make op-batcher

FROM alpine:3.15

RUN apk add jq curl

COPY --from=builder /app/op-batcher/bin/op-batcher /usr/local/bin
COPY ./bss-entrypoint.sh /bss-entrypoint.sh
COPY ./rollup.json /rollup.json

RUN op-batcher --version 2>/dev/null | head -1 > /version.txt

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

# Generate the bss config.

L2_URL="http://172.17.0.4:9545"

# Grab the L2 genesis. We can use cURL here to retry.
L2_GENESIS=$(curl \
--silent \
--fail \
--retry 10 \
--retry-delay 2 \
--retry-connrefused \
-X POST \
-H "Content-Type: application/json" \
--data '{"jsonrpc":"2.0","method":"eth_getBlockByNumber","params":["0x0", false],"id":1}' \
$L2_URL)

SEQUENCER_GENESIS_HASH="$(echo $L2_GENESIS | jq -r '.result.hash')"
SEQUENCER_BATCH_INBOX_ADDRESS="$(cat /rollup.json | jq -r '.batch_inbox_address')"

exec op-batcher \
--l1-eth-rpc=http://172.17.0.3:8545 \
--l2-eth-rpc=http://172.17.0.4:9545 \
--rollup-rpc=http://172.17.0.5:7545 \
--min-l1-tx-size-bytes=1 \
--max-l1-tx-size-bytes=120000 \
--poll-interval=1s \
--num-confirmations=1 \
--safe-abort-nonce-too-low-count=3 \
--resubmission-timeout=30s \
--mnemonic="test test test test test test test test test test test junk" \
--sequencer-hd-path="m/44'/60'/0'/0/2" \
--sequencer-history-db-filename="history_db.json" \
--sequencer-genesis-hash=$SEQUENCER_GENESIS_HASH \
--sequencer-batch-inbox-address=$SEQUENCER_BATCH_INBOX_ADDRESS \
--log-terminal=true
1 change: 1 addition & 0 deletions clients/ops-bss/bss-key.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
bf7604d9d3a1c7748642b1b7b05c2bd219c9faa91458b370f85e5a40f3b03af7
2 changes: 2 additions & 0 deletions clients/ops-bss/hive.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
roles:
- "ops-bss"
33 changes: 33 additions & 0 deletions clients/ops-bss/rollup.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{
"genesis": {
"l1": {
"hash": "0x21837b23495539c19e4b85d3d115c740c677d2609480eb67c3b2bb218a3ffd8f",
"number": 0
},
"l2": {
"hash": "0x00574ae7ed85cf485dd148011ab78c138becdd65b3078bd46c94c55766c8fc7a",
"number": 0
},
"l2_time": 1647573629
},

"block_time": 2,

"max_sequencer_drift": 10,

"seq_window_size": 2,

"l1_chain_id": 900,

"l2_chain_id": 901,

"p2p_sequencer_address": "0x9965507D1a55bcC2695C58ba16FB37d819B0A4dc",

"fee_recipient_address": "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266",

"batch_inbox_address": "0xff00000000000000000000000000000000000002",

"batch_sender_address": "0x3C44CdDdB6a900fa2b585dd299e03d12FA4293BC",

"deposit_contract_address": "0xdeaddeaddeaddeaddeaddeaddeaddeaddead0001"
}
3 changes: 3 additions & 0 deletions clients/ops-l1/genesis.json
Original file line number Diff line number Diff line change
Expand Up @@ -796,6 +796,9 @@
"de3829a23df1479438622a08a116e8eb3f620bb5": {
"balance": "0x200000000000000000000000000000000000000000000000000000000000000"
},
"3C44CdDdB6a900fa2b585dd299e03d12FA4293BC": {
"balance": "0x200000000000000000000000000000000000000000000000000000000000000"
},
"f39fd6e51aad88f6f4ce6ab8827279cfffb92266": {
"balance": "0x200000000000000000000000000000000000000000000000000000000000000"
},
Expand Down
6 changes: 3 additions & 3 deletions clients/ops-l2os/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,16 @@ RUN apk add --no-cache make gcc musl-dev linux-headers git jq bash
RUN git clone https://github.com/ethereum-optimism/optimistic-specs /app

WORKDIR /app
RUN make l2os
RUN make op-proposer

FROM alpine:3.15

RUN apk add --no-cache curl jq

COPY --from=builder /app/bin/l2os /usr/local/bin
COPY --from=builder /app/op-proposer/bin/op-proposer /usr/local/bin
COPY l2os-entrypoint.sh /l2os-entrypoint.sh

RUN /app/bin/l2os --version 2>/dev/null | head -1 > /version.txt
RUN op-proposer --version 2>/dev/null | head -1 > /version.txt

# TODO
# RUN export L2OO_ADDRESS=
Expand Down
7 changes: 4 additions & 3 deletions clients/ops-l2os/l2os-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,15 @@ curl \

L2OO_ADDRESS=$(jq -r .address < /L2OutputOracle.json)

exec l2os \
exec op-proposer \
--l1-eth-rpc http://172.17.0.3:8545 \
--l2-eth-rpc http://172.17.0.4:9545 \
--rollup-rpc http://172.17.0.5:7545 \
--l2oo-address $L2OO_ADDRESS \
--poll-interval 10s \
--num-confirmations 1 \
--safe-abort-nonce-too-low-count 3 \
--resubmission-timeout 30s \
--mnemonic "test test test test test test test test test test test junk" \
--l2-output-hd-path "m/44'/60'/0'/0/1"
--l2-output-hd-path "m/44'/60'/0'/0/1" \
--l2oo-address $L2OO_ADDRESS \
--log-terminal=true
12 changes: 6 additions & 6 deletions clients/ops-opnode/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,20 @@ RUN apk add --no-cache make gcc musl-dev linux-headers git jq bash
RUN git clone https://github.com/ethereum-optimism/optimistic-specs /app

WORKDIR /app
RUN make opnode
RUN make op-node

FROM alpine:3.15

RUN apk add jq curl

COPY --from=builder /app/bin/op /usr/local/bin
COPY --from=builder /app/op-node/bin/op-node /usr/local/bin
COPY ./opnode-entrypoint.sh /opnode-entrypoint.sh
COPY ./rollup.json /rollup.json
RUN mkdir /config
RUN mkdir /hive
COPY ./bss-key.txt /config
RUN mkdir /hive /config
COPY p2p-node-key.txt /config
COPY p2p-sequencer-key.txt /config

RUN /app/bin/opnode --version 2>/dev/null | head -1 > /version.txt
RUN op-node --version 2>/dev/null | head -1 > /version.txt

EXPOSE 7545/tcp

Expand Down
11 changes: 8 additions & 3 deletions clients/ops-opnode/opnode-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,17 @@ jq ". | .genesis.l1.hash = \"$(echo $L1_GENESIS | jq -r '.result.hash')\"" < /ro
jq ". | .genesis.l2_time = $(echo $L2_GENESIS | jq -r '.result.timestamp' | xargs printf "%d")" | \
jq ". | .deposit_contract_address = \"$DEPOSIT_CONTRACT_ADDRESS\"" > /hive/rollup.json

exec op \
exec op-node \
--l1=ws://172.17.0.3:8546 \
--l2=ws://172.17.0.4:9546 \
--sequencing.enabled \
--p2p.sequencer.key=/config/p2p-sequencer-key.txt \
--rollup.config=/hive/rollup.json \
--batchsubmitter.key=/config/bss-key.txt \
--l2.eth=http://172.17.0.4:9545 \
--rpc.addr=0.0.0.0 \
--rpc.port=7545
--rpc.port=7545 \
--p2p.listen.ip=0.0.0.0 \
--p2p.listen.tcp=9003 \
--p2p.listen.udp=9003 \
--snapshotlog.file=/snapshot.log \
--p2p.priv.path=/config/p2p-node-key.txt
1 change: 1 addition & 0 deletions clients/ops-opnode/p2p-node-key.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
dae4671006c60a3619556ace98eca6f6e092948d05b13070a27ac492a4fba419
1 change: 1 addition & 0 deletions clients/ops-opnode/p2p-sequencer-key.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
8b3a350cf5c34c9194ca85829a2df0ec3153be0318b5e2d3348e872092edffba
6 changes: 5 additions & 1 deletion clients/ops-opnode/rollup.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,15 @@

"l1_chain_id": 900,

"l2_chain_id": 901,

"p2p_sequencer_address": "0x9965507D1a55bcC2695C58ba16FB37d819B0A4dc",

"fee_recipient_address": "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266",

"batch_inbox_address": "0xff00000000000000000000000000000000000002",

"batch_sender_address": "0xde3829a23df1479438622a08a116e8eb3f620bb5",
"batch_sender_address": "0x3C44CdDdB6a900fa2b585dd299e03d12FA4293BC",

"deposit_contract_address": "0xdeaddeaddeaddeaddeaddeaddeaddeaddead0001"
}
39 changes: 30 additions & 9 deletions simulators/optimism/devnet/devnet.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,12 @@ type Devnet struct {
l2 *L2Node
op *OpNode
l2os *L2OSNode
bss *BSSNode

genesisTimestamp string
withdrawerBytecode string
l1BlockBytecode string
l2Genesis string
l2Genesis string

l2OutputOracle string
optimismPortal string
Expand All @@ -55,7 +56,7 @@ func (d *Devnet) Start() {
if err != nil {
d.t.Fatal(err)
}
var eth1, l2, op, l2os *hivesim.ClientDefinition
var eth1, l2, op, l2os, bss *hivesim.ClientDefinition
for _, client := range clientTypes {
if client.HasRole("ops-l1") {
eth1 = client
Expand All @@ -69,10 +70,13 @@ func (d *Devnet) Start() {
if client.HasRole("ops-l2os") {
l2os = client
}
if client.HasRole("ops-bss") {
bss = client
}
}

if eth1 == nil || l2 == nil || op == nil || l2os == nil {
d.t.Fatal("ops-l1, ops-l2, ops-opnode, ops-l2os required")
if eth1 == nil || l2 == nil || op == nil || l2os == nil || bss == nil {
d.t.Fatal("ops-l1, ops-l2, ops-opnode, ops-l2os, ops-bss required")
}

// Generate genesis for execution clients
Expand All @@ -97,6 +101,7 @@ func (d *Devnet) Start() {
d.nodes["ops-l2"] = l2
d.nodes["ops-opnode"] = op
d.nodes["ops-l2os"] = l2os
d.nodes["ops-bss"] = bss
}

func (d *Devnet) Wait() error {
Expand Down Expand Up @@ -156,11 +161,11 @@ func (d *Devnet) StartL2() error {
l2 := d.nodes["ops-l2"]

executionOpts := hivesim.Params{
"HIVE_CHECK_LIVE_PORT": "9545",
"HIVE_LOGLEVEL": os.Getenv("HIVE_LOGLEVEL"),
"HIVE_NODETYPE": "full",
"HIVE_NETWORK_ID": networkID.String(),
"HIVE_CHAIN_ID": chainID.String(),
"HIVE_CHECK_LIVE_PORT": "9545",
"HIVE_LOGLEVEL": os.Getenv("HIVE_LOGLEVEL"),
"HIVE_NODETYPE": "full",
"HIVE_NETWORK_ID": networkID.String(),
"HIVE_CHAIN_ID": chainID.String(),
}

genesisTimestampOpt := hivesim.WithDynamicFile("/genesis_timestamp", bytesSource([]byte(d.genesisTimestamp)))
Expand Down Expand Up @@ -211,3 +216,19 @@ func (d *Devnet) StartL2OS() error {
d.op = &OpNode{d.t.StartClient(op.Name, opts...)}
return nil
}

func (d *Devnet) StartBSS() error {
op := d.nodes["ops-bss"]

executionOpts := hivesim.Params{
"HIVE_CHECK_LIVE_PORT": "0",
"HIVE_CATALYST_ENABLED": "1",
"HIVE_LOGLEVEL": os.Getenv("HIVE_LOGLEVEL"),
"HIVE_NODETYPE": "full",
}

optimismPortalOpt := hivesim.WithDynamicFile("/OptimismPortal.json", bytesSource([]byte(d.optimismPortal)))
opts := []hivesim.StartOption{executionOpts, optimismPortalOpt}
d.op = &OpNode{d.t.StartClient(op.Name, opts...)}
return nil
}
40 changes: 22 additions & 18 deletions simulators/optimism/devnet/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -2,46 +2,50 @@ module github.com/ethereum-optimism/hive/simulators/optimism/devnet

go 1.17

replace github.com/ethereum/go-ethereum v1.10.15 => github.com/ethereum-optimism/reference-optimistic-geth v0.0.0-20220411203319-ad60590374c8
replace github.com/ethereum/go-ethereum v1.10.17 => github.com/ethereum-optimism/reference-optimistic-geth v0.0.0-20220512193241-32ef0bba48ce

require (
github.com/ethereum/go-ethereum v1.10.15
github.com/ethereum/hive v0.0.0-20220214133341-52d82682a461
github.com/kr/pretty v0.2.1
github.com/ethereum/go-ethereum v1.10.17
github.com/ethereum/hive v0.0.0-20220506091324-ee8d44878b25
github.com/kr/pretty v0.3.0
)

require (
github.com/StackExchange/wmi v0.0.0-20210224194228-fe8f1750fd46 // indirect
github.com/VictoriaMetrics/fastcache v1.6.0 // indirect
github.com/btcsuite/btcd/btcec/v2 v2.1.2 // indirect
github.com/StackExchange/wmi v1.2.1 // indirect
github.com/VictoriaMetrics/fastcache v1.10.0 // indirect
github.com/btcsuite/btcd/btcec/v2 v2.2.0 // indirect
github.com/cespare/cp v1.1.1 // indirect
github.com/cespare/xxhash/v2 v2.1.1 // indirect
github.com/cespare/xxhash/v2 v2.1.2 // indirect
github.com/deckarep/golang-set v1.8.0 // indirect
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.0.1 // indirect
github.com/gballet/go-libpcsclite v0.0.0-20191108122812-4678299bea08 // indirect
github.com/go-kit/kit v0.9.0 // indirect
github.com/go-ole/go-ole v1.2.5 // indirect
github.com/go-stack/stack v1.8.0 // indirect
github.com/go-ole/go-ole v1.2.6 // indirect
github.com/go-stack/stack v1.8.1 // indirect
github.com/golang-jwt/jwt/v4 v4.4.1 // indirect
github.com/golang/snappy v0.0.4 // indirect
github.com/google/uuid v1.2.0 // indirect
github.com/gorilla/websocket v1.4.2 // indirect
github.com/google/uuid v1.3.0 // indirect
github.com/gorilla/websocket v1.5.0 // indirect
github.com/hashicorp/golang-lru v0.5.5-0.20210104140557-80c98217689d // indirect
github.com/holiman/bloomfilter/v2 v2.0.3 // indirect
github.com/holiman/uint256 v1.2.0 // indirect
github.com/kr/text v0.2.0 // indirect
github.com/mattn/go-runewidth v0.0.9 // indirect
github.com/mattn/go-runewidth v0.0.13 // indirect
github.com/olekukonko/tablewriter v0.0.5 // indirect
github.com/onsi/gomega v1.10.3 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/prometheus/tsdb v0.10.0 // indirect
github.com/rivo/uniseg v0.2.0 // indirect
github.com/rjeczalik/notify v0.9.2 // indirect
github.com/shirou/gopsutil v3.21.4-0.20210419000835-c7a38de76ee5+incompatible // indirect
github.com/rogpeppe/go-internal v1.8.1 // indirect
github.com/shirou/gopsutil v3.21.11+incompatible // indirect
github.com/status-im/keycard-go v0.0.0-20190424133014-d95853db0f48 // indirect
github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7 // indirect
github.com/tklauser/go-sysconf v0.3.5 // indirect
github.com/tklauser/numcpus v0.2.2 // indirect
github.com/tklauser/go-sysconf v0.3.10 // indirect
github.com/tklauser/numcpus v0.5.0 // indirect
github.com/tyler-smith/go-bip39 v1.0.2 // indirect
golang.org/x/crypto v0.0.0-20211202192323-5770296d904e // indirect
golang.org/x/sys v0.0.0-20211124211545-fe61309f8881 // indirect
github.com/yusufpapurcu/wmi v1.2.2 // indirect
golang.org/x/crypto v0.0.0-20220516162934-403b01795ae8 // indirect
golang.org/x/sys v0.0.0-20220513210249-45d2b4557a2a // indirect
gopkg.in/natefinch/npipe.v2 v2.0.0-20160621034901-c1b8fa8bdcce // indirect
)
Loading

0 comments on commit e8f075f

Please sign in to comment.