forked from ethereum/hive
-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
simulators/optimism: testnet sim, update p2p sim
- Loading branch information
1 parent
da8bd89
commit e8a4ecc
Showing
14 changed files
with
203 additions
and
74 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,4 +5,5 @@ use ( | |
./optimism | ||
./simulators/optimism/p2p | ||
./simulators/optimism/rpc | ||
./simulators/optimism/testnet | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,5 @@ | ||
# Optimism P2P test suite | ||
# Hive Optimism P2P test suite | ||
|
||
This test suite tests the P2P protocol between the sequencer and verifier on | ||
the optimism network. | ||
This test suite tests the P2P functionality in an Optimism Bedrock testnet. | ||
|
||
hive --sim optimism/p2p --client=op-l1,op-l2,op-proposer,op-batcher,op-sequencer,op-verifier --docker.output | ||
hive --sim optimism/p2p --client=op-l1,op-geth,op-proposer,op-batcher,op-node,op-contracts --docker.output |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
go 1.18 | ||
|
||
use ( | ||
./optimism | ||
./p2p | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# 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, from hive repo root. | ||
# See context.txt for docker build context change. | ||
# We use a go.work file to pull in other go modules of the hive repo. | ||
ADD ./simulators/optimism/testnet/hive.go.work /source/go.work | ||
ADD ./optimism /source/optimism | ||
ADD ./simulators/optimism/testnet /source/testnet | ||
|
||
WORKDIR /source/p2p | ||
RUN go build -v . | ||
|
||
|
||
# Build the simulator run container. | ||
FROM alpine:latest | ||
|
||
COPY --from=builder /source/testnet/testnet . | ||
ENTRYPOINT ["./testnet"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# Hive Optimism Testnet | ||
|
||
This test runs an Optimism Bedrock testnet. | ||
|
||
hive --sim optimism/testnet --client=op-l1,op-geth,op-proposer,op-batcher,op-node,op-contracts --docker.output |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
../../../ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
module github.com/ethereum/hive/simulators/optimism/testnet | ||
|
||
go 1.18 | ||
|
||
replace github.com/ethereum/go-ethereum v1.10.20 => github.com/ethereum-optimism/reference-optimistic-geth v0.0.0-20220715235548-70b02481016d | ||
|
||
replace github.com/ethereum/hive v0.0.0-20220726101544-19cb1f8cc162 => github.com/ethereum-optimism/hive v0.0.0-20220727114344-022fad9696a4 | ||
|
||
require ( | ||
github.com/ethereum/go-ethereum v1.10.20 | ||
github.com/ethereum/hive v0.0.0-20220726101544-19cb1f8cc162 | ||
) | ||
|
||
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.1 // 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 | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
go 1.18 | ||
|
||
use ( | ||
./optimism | ||
./testnet | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,117 @@ | ||
package main | ||
|
||
import ( | ||
"context" | ||
"github.com/ethereum-optimism/optimism/op-node/rollup/driver" | ||
"github.com/ethereum-optimism/optimism/op-proposer/rollupclient" | ||
"github.com/stretchr/testify/assert" | ||
"time" | ||
|
||
"github.com/ethereum/hive/hivesim" | ||
"github.com/ethereum/hive/optimism" | ||
) | ||
|
||
func main() { | ||
suite := hivesim.Suite{ | ||
Name: "optimism p2p", | ||
Description: "This suite runs the P2P tests", | ||
} | ||
|
||
// Add tests for full nodes. | ||
suite.Add(&hivesim.TestSpec{ | ||
Name: "simple p2p testnet", | ||
Description: `This suite runs the a testnet with P2P set up`, | ||
Run: func(t *hivesim.T) { runP2PTests(t) }, | ||
}) | ||
|
||
sim := hivesim.New() | ||
hivesim.MustRunSuite(sim, suite) | ||
} | ||
|
||
// runP2PTests runs the P2P tests between the sequencer and verifier. | ||
func runP2PTests(t *hivesim.T) { | ||
handleErr := func(err error) { | ||
if err != nil { | ||
t.Fatal(err) | ||
} | ||
} | ||
|
||
d := optimism.NewDevnet(t) | ||
|
||
d.InitContracts() | ||
d.InitRollupHardhat() | ||
d.AddEth1() | ||
// wait for L1 to come online before deploying | ||
{ | ||
ctx, cancel := context.WithTimeout(context.Background(), time.Second*10) | ||
defer cancel() | ||
_, err := d.GetEth1(0).EthClient().ChainID(ctx) | ||
handleErr(err) | ||
} | ||
d.DeployL1Hardhat() | ||
|
||
// sequencer stack, on top of first eth1 node | ||
d.AddOpL2() | ||
d.AddOpNode(0, 0) | ||
d.AddOpBatcher(0, 0, 0) | ||
d.AddOpProposer(0, 0, 0) | ||
|
||
// TODO: pass optimism.UnprefixedParams{flag env vars here}.Params() | ||
// hivesim start option to the op nodes to configure p2p networking | ||
|
||
// verifier A | ||
d.AddOpL2() | ||
d.AddOpNode(0, 1) // we attach to the same L1 node, so we don't need to configure L1 networking. | ||
|
||
// verifier B | ||
d.AddOpL2() | ||
d.AddOpNode(0, 2) | ||
|
||
t.Log("waiting for nodes to get onto the network") | ||
time.Sleep(time.Second * 10) | ||
|
||
seq := d.GetOpNode(0) | ||
verifA := d.GetOpNode(1) | ||
verifB := d.GetOpNode(2) | ||
|
||
seqCl := seq.RollupClient() | ||
verifACl := verifA.RollupClient() | ||
verifBCl := verifB.RollupClient() | ||
|
||
ctx, cancel := context.WithCancel(context.Background()) | ||
go func() { | ||
ticker := time.NewTicker(time.Second * 4) | ||
defer ticker.Stop() | ||
|
||
syncStat := func(name string, cl *rollupclient.RollupClient) *driver.SyncStatus { | ||
ctx, cancel := context.WithTimeout(context.Background(), time.Second*4) | ||
seqStat, err := cl.SyncStatus(ctx) | ||
cancel() | ||
if err != nil { | ||
t.Error("failed to get sync status from %s op-node: %v", name, err) | ||
} | ||
return seqStat // may be nil | ||
} | ||
|
||
for { | ||
select { | ||
case <-ticker.C: | ||
// Check that all clients are synced | ||
seqStat := syncStat("sequencer", seqCl) | ||
verAStat := syncStat("verifier-A", verifACl) | ||
verBStat := syncStat("verifier-B", verifBCl) | ||
assert.Equal(t, seqStat, verAStat, "sequencer and verifier A should be synced") | ||
assert.Equal(t, verAStat, verBStat, "verifier A and verifier B should be synced") | ||
case <-ctx.Done(): | ||
t.Log("exiting sync checking loop") | ||
return | ||
} | ||
} | ||
}() | ||
|
||
// Run testnet for duration of 3 sequence windows | ||
time.Sleep(time.Second * time.Duration(d.L1Cfg.Clique.Period*d.RollupCfg.SeqWindowSize*3)) | ||
cancel() | ||
|
||
// TODO: Add P2P tests | ||
} |