Skip to content

Commit

Permalink
update op-e2e setup
Browse files Browse the repository at this point in the history
  • Loading branch information
hamdiallam committed Sep 12, 2024
1 parent 935de9c commit 26f631c
Showing 1 changed file with 28 additions and 4 deletions.
32 changes: 28 additions & 4 deletions op-e2e/setup.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import (
"github.com/ethereum/go-ethereum/common/hexutil"
"github.com/ethereum/go-ethereum/core"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/eth/ethconfig"
"github.com/ethereum/go-ethereum/ethclient"
"github.com/ethereum/go-ethereum/log"
"github.com/ethereum/go-ethereum/node"
Expand Down Expand Up @@ -280,6 +281,9 @@ type SystemConfig struct {
// Explicitly disable batcher, for tests that rely on unsafe L2 payloads
DisableBatcher bool

// Explicitly disable setting `RollupSequencerHTTP` to forward txs from sentry nodes
DisableTxForwarder bool

// Configure data-availability type that is used by the batcher.
DataAvailabilityType batcherFlags.DataAvailabilityType

Expand Down Expand Up @@ -624,32 +628,52 @@ func (cfg SystemConfig) Start(t *testing.T, _opts ...SystemConfigOption) (*Syste
return nil, err
}

// Ordered such that the Sequencer is initialized first. Setup this way so that
// the `RollupSequencerHTTP` GethOption can be supplied to any sentry nodes.
l2Nodes := []string{RoleSeq}
for name := range cfg.Nodes {
if name == RoleL1 {
return nil, fmt.Errorf("node name %s is reserved for L1 node", RoleL1)
if name == RoleSeq {
continue
}
l2Nodes = append(l2Nodes, name)
}

for _, name := range l2Nodes {
var ethClient services.EthInstance
if cfg.ExternalL2Shim == "" {
if name != RoleSeq && !cfg.DisableTxForwarder {
cfg.GethOptions[name] = append(cfg.GethOptions[name], func(ethCfg *ethconfig.Config, nodeCfg *node.Config) error {
ethCfg.RollupSequencerHTTP = sys.EthInstances[RoleSeq].UserRPC().RPC()
return nil
})
}

l2Geth, err := geth.InitL2(name, l2Genesis, cfg.JWTFilePath, cfg.GethOptions[name]...)
if err != nil {
return nil, err
}
err = l2Geth.Node.Start()
if err != nil {
if err := l2Geth.Node.Start(); err != nil {
return nil, err
}

ethClient = l2Geth
} else {
if len(cfg.GethOptions[name]) > 0 {
t.Skip("External L2 nodes do not support configuration through GethOptions")
}

if name != RoleSeq && !cfg.DisableTxForwarder {
cfg.Loggers[name].Warn("External L2 nodes do not support `RollupSequencerHTTP` configuration. No tx forwarding support.")
}

ethClient = (&ExternalRunner{
Name: name,
BinPath: cfg.ExternalL2Shim,
Genesis: l2Genesis,
JWTPath: cfg.JWTFilePath,
}).Run(t)
}

sys.EthInstances[name] = ethClient
}

Expand Down

0 comments on commit 26f631c

Please sign in to comment.