Skip to content

Commit

Permalink
simulator (optimism/p2p): add new simulator to test p2p (#15)
Browse files Browse the repository at this point in the history
* simulator (op): adds new simulator to test p2p

* ci: update test cmd; rename test

* op: rebase + refactor op-node

* go: module cleanup; update ci workflow

* op: go mod tidy

* op: devnet - add method StartVerifier

* op: devnet - pass required flags

* op: devnet - use p2p static flag in entrypoint

* op: devnet - update multiaddr

* simulator (optimism/p2p): verifier - static p2p

* ci: add parallel p2p / rpc workflows

* ci: fix workflows

* simulator (optimism/rpc): bump hive version

* simulators (optimism/rpc): bump go.sum

* op: devnet - pass dynamic p2p node key

* simulators (optimism/p2p): bump hive

* simulators (optimism/p2p): bump go.sum

* simulators (optimism/p2p): use str p2p node key

* simulators (optimism/p2p): bump hive
  • Loading branch information
tuxcanfly authored and mslipper committed Sep 8, 2022
1 parent deef12d commit 6e1e308
Show file tree
Hide file tree
Showing 19 changed files with 991 additions and 421 deletions.
30 changes: 26 additions & 4 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,35 @@ jobs:
# This job runs the optimism test simulations. This requires a virtual
# machine instead of the container-based build environment because hive needs
# to be able to talk to the docker containers it creates.
op-tests:
hive-rpc-tests:
machine:
image: ubuntu-2004:202201-02
steps:
- checkout
- attach_workspace: {at: "/tmp/build"}
- run:
command: "/tmp/build/hive -sim=optimism -client=op-l1,op-l2,op-proposer,op-batcher,op-node |& tee /tmp/build/hive.log"
command: "/tmp/build/hive -sim=optimism/rpc -client=op-l1,op-l2,op-proposer,op-batcher,op-node |& tee /tmp/build/hive-rpc.log"
- run:
command: "! grep 'pass.*=false' /tmp/build/hive.log"
command: "! grep 'pass.*=false' /tmp/build/hive-rpc.log"
- slack/notify:
channel: C03N11M0BBN
event: fail
template: basic_fail_1
- slack/notify:
channel: C03N11M0BBN
event: pass
template: basic_success_1

hive-p2p-tests:
machine:
image: ubuntu-2004:202201-02
steps:
- checkout
- attach_workspace: {at: "/tmp/build"}
- run:
command: "/tmp/build/hive -sim=optimism/p2p -client=op-l1,op-l2,op-proposer,op-batcher,op-node |& tee /tmp/build/hive-p2p.log"
- run:
command: "! grep 'pass.*=false' /tmp/build/hive-p2p.log"
- slack/notify:
channel: C03N11M0BBN
event: fail
Expand Down Expand Up @@ -69,6 +88,9 @@ workflows:
jobs:
- go-test
- build
- op-tests:
- hive-rpc-tests:
requires: ["build"]
context: slack
- hive-p2p-tests:
requires: ["build"]
context: slack
1 change: 1 addition & 0 deletions clients/op-node/opnode-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -48,5 +48,6 @@ exec op-node \
--p2p.listen.ip=0.0.0.0 \
--p2p.listen.tcp=9003 \
--p2p.listen.udp=9003 \
$HIVE_P2P_STATIC_FLAG \
--snapshotlog.file=/snapshot.log \
--p2p.priv.path=/config/p2p-node-key.txt
4 changes: 3 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ require (
github.com/docker/go-connections v0.4.0 // indirect
github.com/docker/go-units v0.4.0 // indirect
github.com/edsrzf/mmap-go v1.0.0 // indirect
github.com/go-logfmt/logfmt v0.5.0 // indirect
github.com/go-ole/go-ole v1.2.5 // indirect
github.com/go-stack/stack v1.8.1 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
Expand All @@ -51,7 +52,7 @@ require (
github.com/opencontainers/image-spec v1.0.3-0.20211202183452-c5a74bcca799 // indirect
github.com/opencontainers/runc v1.1.2 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/prometheus/tsdb v0.10.0 // indirect
github.com/prometheus/tsdb v0.7.1 // indirect
github.com/shirou/gopsutil v3.21.4-0.20210419000835-c7a38de76ee5+incompatible // indirect
github.com/sirupsen/logrus v1.8.1 // indirect
github.com/syndtr/goleveldb v1.0.1-0.20220614013038-64ee5596c38a // indirect
Expand All @@ -60,6 +61,7 @@ require (
go.opencensus.io v0.23.0 // indirect
golang.org/x/crypto v0.0.0-20211202192323-5770296d904e // indirect
golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a // indirect
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c // indirect
gopkg.in/natefinch/npipe.v2 v2.0.0-20160621034901-c1b8fa8bdcce // indirect
)

Expand Down
565 changes: 558 additions & 7 deletions go.sum

Large diffs are not rendered by default.

32 changes: 32 additions & 0 deletions optimism/devnet.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ type Devnet struct {
L1 *Eth1Node
L2 *L2Node
Rollup *OpNode
Verifier *OpNode
Proposer *L2OSNode
Batcher *BSSNode

Expand Down Expand Up @@ -204,6 +205,8 @@ func (d *Devnet) StartOp() error {
"HIVE_L2_URL": fmt.Sprintf("http://%s:%d", d.L2.IP, d.L2.HTTPPort),
"HIVE_L1_ETH_RPC_FLAG": fmt.Sprintf("--l1=ws://%s:%d", d.L1.IP, d.L1.WSPort),
"HIVE_L2_ENGINE_RPC_FLAG": fmt.Sprintf("--l2=ws://%s:%d", d.L2.IP, d.L2.WSPort),

"HIVE_P2P_STATIC_FLAG": "",
}

if op.HasRole("op-sequencer") {
Expand All @@ -217,6 +220,35 @@ func (d *Devnet) StartOp() error {
return nil
}

func (d *Devnet) StartVerifier() error {
op := d.Nodes["op-node"]

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

"HIVE_L1_URL": fmt.Sprintf("http://%s:%d", d.L1.IP, d.L1.HTTPPort),
"HIVE_L2_URL": fmt.Sprintf("http://%s:%d", d.L2.IP, d.L2.HTTPPort),
"HIVE_L1_ETH_RPC_FLAG": fmt.Sprintf("--l1=ws://%s:%d", d.L1.IP, d.L1.WSPort),
"HIVE_L2_ENGINE_RPC_FLAG": fmt.Sprintf("--l2=ws://%s:%d", d.L2.IP, d.L2.WSPort),

"HIVE_SEQUENCER_ENABLED_FLAG": "",
"HIVE_SEQUENCER_KEY_FLAG": "",
// TODO: avoid hardcoding p2p key
"HIVE_P2P_STATIC_FLAG": fmt.Sprintf("--p2p.static=/ip4/%s/tcp/9003/p2p/16Uiu2HAmHqrXGts25TtKMBRHtvhWZLNypsobKoggpZye1XQtJpbZ", d.Rollup.IP),
}

p2pNodeKey := "d30e180aa6c25bac3ba2f0965af5da1934dbabe4505c92ddd1459e5cec27a882"

optimismPortalOpt := hivesim.WithDynamicFile("/OptimismPortalProxy.json", bytesSource([]byte(d.OptimismPortal)))
p2pNodeKeyOpt := hivesim.WithDynamicFile("/config/p2p-node-key.txt", bytesSource([]byte(p2pNodeKey)))
opts := []hivesim.StartOption{executionOpts, optimismPortalOpt, p2pNodeKeyOpt}
d.Verifier = &OpNode{d.T.StartClient(op.Name, opts...), 7545}
return nil
}

func (d *Devnet) StartL2OS() error {
l2os := d.Nodes["op-proposer"]

Expand Down
15 changes: 15 additions & 0 deletions simulators/optimism/p2p/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# This simulation runs JSON-RPC API tests.
FROM golang:1.18-alpine3.15 as builder
RUN apk add --update gcc musl-dev linux-headers

# Build the simulator executable.
ADD . /source
WORKDIR /source
RUN go build -v .

# Build the simulator run container.
FROM alpine:latest
ADD . /source
WORKDIR /source
COPY --from=builder /source/p2p .
ENTRYPOINT ["./p2p"]
6 changes: 6 additions & 0 deletions simulators/optimism/p2p/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Optimism P2P test suite

This test suite tests the P2P protocol between the sequencer and verifier on
the optimism network.

hive --sim optimism/p2p --client=op-l1,op-l2,op-proposer,op-batcher,op-sequencer,op-verifier --docker.output
31 changes: 31 additions & 0 deletions simulators/optimism/p2p/go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
module github.com/ethereum/hive/simulators/optimism/p2p

go 1.18

replace github.com/ethereum/go-ethereum v1.10.17 => github.com/ethereum-optimism/reference-optimistic-geth v0.0.0-20220715235548-70b02481016d

replace github.com/ethereum/hive v0.0.0-20220630112103-4b22dc796d94 => github.com/ethereum-optimism/hive v0.0.0-20220725184331-e0ca18567bc8

require (
github.com/ethereum/go-ethereum v1.10.17
github.com/ethereum/hive v0.0.0-20220630112103-4b22dc796d94
)

require (
github.com/StackExchange/wmi v0.0.0-20210224194228-fe8f1750fd46 // indirect
github.com/btcsuite/btcd/btcec/v2 v2.2.0 // indirect
github.com/deckarep/golang-set v1.8.0 // indirect
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.0.1 // indirect
github.com/go-ole/go-ole v1.2.5 // indirect
github.com/go-stack/stack v1.8.0 // indirect
github.com/golang-jwt/jwt/v4 v4.3.0 // indirect
github.com/golang/snappy v0.0.4 // indirect
github.com/gorilla/websocket v1.4.2 // indirect
github.com/shirou/gopsutil v3.21.4-0.20210419000835-c7a38de76ee5+incompatible // indirect
github.com/syndtr/goleveldb v1.0.1-0.20220614013038-64ee5596c38a // indirect
github.com/tklauser/go-sysconf v0.3.5 // indirect
github.com/tklauser/numcpus v0.2.2 // indirect
golang.org/x/crypto v0.0.0-20211202192323-5770296d904e // indirect
golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a // indirect
gopkg.in/natefinch/npipe.v2 v2.0.0-20160621034901-c1b8fa8bdcce // indirect
)
Loading

0 comments on commit 6e1e308

Please sign in to comment.