Commit 65888071 authored by Sebastian Stammler's avatar Sebastian Stammler

op-batcher: Add rollup cfg to Config and query during startup

This avoids having to provide rollup configuration as flags to the
batcher; also avoids possible inconsistencies.
parent b151d50d
package batcher package batcher
import ( import (
"math/big"
"time" "time"
"github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common"
...@@ -10,6 +9,7 @@ import ( ...@@ -10,6 +9,7 @@ import (
"github.com/urfave/cli" "github.com/urfave/cli"
"github.com/ethereum-optimism/optimism/op-batcher/flags" "github.com/ethereum-optimism/optimism/op-batcher/flags"
"github.com/ethereum-optimism/optimism/op-node/rollup"
"github.com/ethereum-optimism/optimism/op-node/sources" "github.com/ethereum-optimism/optimism/op-node/sources"
opcrypto "github.com/ethereum-optimism/optimism/op-service/crypto" opcrypto "github.com/ethereum-optimism/optimism/op-service/crypto"
oplog "github.com/ethereum-optimism/optimism/op-service/log" oplog "github.com/ethereum-optimism/optimism/op-service/log"
...@@ -29,10 +29,9 @@ type Config struct { ...@@ -29,10 +29,9 @@ type Config struct {
TxManagerConfig txmgr.Config TxManagerConfig txmgr.Config
From common.Address From common.Address
SignerFnFactory opcrypto.SignerFactory SignerFnFactory opcrypto.SignerFactory
ChainID *big.Int
// Where to send the batch txs to. // RollupConfig is queried at startup
BatchInboxAddress common.Address Rollup *rollup.Config
// Channel creation parameters // Channel creation parameters
Channel ChannelConfig Channel ChannelConfig
......
...@@ -50,11 +50,6 @@ func NewBatchSubmitterFromCLIConfig(cfg CLIConfig, l log.Logger) (*BatchSubmitte ...@@ -50,11 +50,6 @@ func NewBatchSubmitterFromCLIConfig(cfg CLIConfig, l log.Logger) (*BatchSubmitte
return nil, err return nil, err
} }
batchInboxAddress, err := parseAddress(cfg.SequencerBatchInboxAddress)
if err != nil {
return nil, err
}
// Connect to L1 and L2 providers. Perform these last since they are the // Connect to L1 and L2 providers. Perform these last since they are the
// most expensive. // most expensive.
l1Client, err := dialEthClientWithTimeout(ctx, cfg.L1EthRpc) l1Client, err := dialEthClientWithTimeout(ctx, cfg.L1EthRpc)
...@@ -72,14 +67,9 @@ func NewBatchSubmitterFromCLIConfig(cfg CLIConfig, l log.Logger) (*BatchSubmitte ...@@ -72,14 +67,9 @@ func NewBatchSubmitterFromCLIConfig(cfg CLIConfig, l log.Logger) (*BatchSubmitte
return nil, err return nil, err
} }
chainID, err := l1Client.ChainID(ctx)
if err != nil {
return nil, err
}
rcfg, err := rollupClient.RollupConfig(ctx) rcfg, err := rollupClient.RollupConfig(ctx)
if err != nil { if err != nil {
return nil, err return nil, fmt.Errorf("querying rollup config: %w", err)
} }
txManagerConfig := txmgr.Config{ txManagerConfig := txmgr.Config{
...@@ -93,15 +83,14 @@ func NewBatchSubmitterFromCLIConfig(cfg CLIConfig, l log.Logger) (*BatchSubmitte ...@@ -93,15 +83,14 @@ func NewBatchSubmitterFromCLIConfig(cfg CLIConfig, l log.Logger) (*BatchSubmitte
L1Client: l1Client, L1Client: l1Client,
L2Client: l2Client, L2Client: l2Client,
RollupNode: rollupClient, RollupNode: rollupClient,
ChainID: chainID,
PollInterval: cfg.PollInterval, PollInterval: cfg.PollInterval,
TxManagerConfig: txManagerConfig, TxManagerConfig: txManagerConfig,
From: fromAddress, From: fromAddress,
SignerFnFactory: signer, SignerFnFactory: signer,
BatchInboxAddress: batchInboxAddress, Rollup: rcfg,
Channel: ChannelConfig{ Channel: ChannelConfig{
SeqWindowSize: rcfg.SeqWindowSize, SeqWindowSize: rcfg.SeqWindowSize,
ChannelTimeout: cfg.ChannelTimeout, ChannelTimeout: rcfg.ChannelTimeout,
ChannelSubTimeout: cfg.ChannelSubTimeout, ChannelSubTimeout: cfg.ChannelSubTimeout,
MaxFrameSize: cfg.MaxL1TxSize - 1, // subtract 1 byte for version MaxFrameSize: cfg.MaxL1TxSize - 1, // subtract 1 byte for version
TargetFrameSize: cfg.TargetL1TxSize - 1, // subtract 1 byte for version TargetFrameSize: cfg.TargetL1TxSize - 1, // subtract 1 byte for version
...@@ -129,7 +118,9 @@ func NewBatchSubmitter(cfg Config, l log.Logger) (*BatchSubmitter, error) { ...@@ -129,7 +118,9 @@ func NewBatchSubmitter(cfg Config, l log.Logger) (*BatchSubmitter, error) {
return &BatchSubmitter{ return &BatchSubmitter{
Config: cfg, Config: cfg,
txMgr: NewTransactionManager(l, cfg.TxManagerConfig, cfg.BatchInboxAddress, cfg.ChainID, cfg.From, cfg.L1Client, cfg.SignerFnFactory(cfg.ChainID)), txMgr: NewTransactionManager(l,
cfg.TxManagerConfig, cfg.Rollup.BatchInboxAddress, cfg.Rollup.L1ChainID,
cfg.From, cfg.L1Client, cfg.SignerFnFactory(cfg.Rollup.L1ChainID)),
done: make(chan struct{}), done: make(chan struct{}),
// TODO: this context only exists because the event loop doesn't reach done // TODO: this context only exists because the event loop doesn't reach done
// if the tx manager is blocking forever due to e.g. insufficient balance. // if the tx manager is blocking forever due to e.g. insufficient balance.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment