Commit d5f62324 authored by Roberto Bayardo's avatar Roberto Bayardo

improve naming consistency of Config struct variables

parent 88d1b38b
...@@ -37,15 +37,15 @@ type RollupClient interface { ...@@ -37,15 +37,15 @@ type RollupClient interface {
// DriverSetup is the collection of input/output interfaces and configuration that the driver operates on. // DriverSetup is the collection of input/output interfaces and configuration that the driver operates on.
type DriverSetup struct { type DriverSetup struct {
Log log.Logger Log log.Logger
Metr metrics.Metricer Metr metrics.Metricer
RollupCfg *rollup.Config RollupConfig *rollup.Config
Cfg BatcherConfig Config BatcherConfig
Txmgr txmgr.TxManager Txmgr txmgr.TxManager
L1Client L1Client L1Client L1Client
L2Client L2Client L2Client L2Client
RollupClient RollupClient RollupClient RollupClient
Channel ChannelConfig ChannelConfig ChannelConfig
} }
// BatchSubmitter encapsulates a service responsible for submitting L2 tx // BatchSubmitter encapsulates a service responsible for submitting L2 tx
...@@ -74,7 +74,7 @@ type BatchSubmitter struct { ...@@ -74,7 +74,7 @@ type BatchSubmitter struct {
func NewBatchSubmitter(setup DriverSetup) *BatchSubmitter { func NewBatchSubmitter(setup DriverSetup) *BatchSubmitter {
return &BatchSubmitter{ return &BatchSubmitter{
DriverSetup: setup, DriverSetup: setup,
state: NewChannelManager(setup.Log, setup.Metr, setup.Channel, setup.RollupCfg), state: NewChannelManager(setup.Log, setup.Metr, setup.ChannelConfig, setup.RollupConfig),
} }
} }
...@@ -171,7 +171,7 @@ func (l *BatchSubmitter) loadBlocksIntoState(ctx context.Context) error { ...@@ -171,7 +171,7 @@ func (l *BatchSubmitter) loadBlocksIntoState(ctx context.Context) error {
latestBlock = block latestBlock = block
} }
l2ref, err := derive.L2BlockToBlockRef(latestBlock, &l.RollupCfg.Genesis) l2ref, err := derive.L2BlockToBlockRef(latestBlock, &l.RollupConfig.Genesis)
if err != nil { if err != nil {
l.Log.Warn("Invalid L2 block loaded into state", "err", err) l.Log.Warn("Invalid L2 block loaded into state", "err", err)
return err return err
...@@ -183,7 +183,7 @@ func (l *BatchSubmitter) loadBlocksIntoState(ctx context.Context) error { ...@@ -183,7 +183,7 @@ func (l *BatchSubmitter) loadBlocksIntoState(ctx context.Context) error {
// loadBlockIntoState fetches & stores a single block into `state`. It returns the block it loaded. // loadBlockIntoState fetches & stores a single block into `state`. It returns the block it loaded.
func (l *BatchSubmitter) loadBlockIntoState(ctx context.Context, blockNumber uint64) (*types.Block, error) { func (l *BatchSubmitter) loadBlockIntoState(ctx context.Context, blockNumber uint64) (*types.Block, error) {
ctx, cancel := context.WithTimeout(ctx, l.Cfg.NetworkTimeout) ctx, cancel := context.WithTimeout(ctx, l.Config.NetworkTimeout)
defer cancel() defer cancel()
block, err := l.L2Client.BlockByNumber(ctx, new(big.Int).SetUint64(blockNumber)) block, err := l.L2Client.BlockByNumber(ctx, new(big.Int).SetUint64(blockNumber))
if err != nil { if err != nil {
...@@ -201,7 +201,7 @@ func (l *BatchSubmitter) loadBlockIntoState(ctx context.Context, blockNumber uin ...@@ -201,7 +201,7 @@ func (l *BatchSubmitter) loadBlockIntoState(ctx context.Context, blockNumber uin
// calculateL2BlockRangeToStore determines the range (start,end] that should be loaded into the local state. // calculateL2BlockRangeToStore determines the range (start,end] that should be loaded into the local state.
// It also takes care of initializing some local state (i.e. will modify l.lastStoredBlock in certain conditions) // It also takes care of initializing some local state (i.e. will modify l.lastStoredBlock in certain conditions)
func (l *BatchSubmitter) calculateL2BlockRangeToStore(ctx context.Context) (eth.BlockID, eth.BlockID, error) { func (l *BatchSubmitter) calculateL2BlockRangeToStore(ctx context.Context) (eth.BlockID, eth.BlockID, error) {
ctx, cancel := context.WithTimeout(ctx, l.Cfg.NetworkTimeout) ctx, cancel := context.WithTimeout(ctx, l.Config.NetworkTimeout)
defer cancel() defer cancel()
syncStatus, err := l.RollupClient.SyncStatus(ctx) syncStatus, err := l.RollupClient.SyncStatus(ctx)
// Ensure that we have the sync status // Ensure that we have the sync status
...@@ -244,11 +244,11 @@ func (l *BatchSubmitter) calculateL2BlockRangeToStore(ctx context.Context) (eth. ...@@ -244,11 +244,11 @@ func (l *BatchSubmitter) calculateL2BlockRangeToStore(ctx context.Context) (eth.
func (l *BatchSubmitter) loop() { func (l *BatchSubmitter) loop() {
defer l.wg.Done() defer l.wg.Done()
ticker := time.NewTicker(l.Cfg.PollInterval) ticker := time.NewTicker(l.Config.PollInterval)
defer ticker.Stop() defer ticker.Stop()
receiptsCh := make(chan txmgr.TxReceipt[txData]) receiptsCh := make(chan txmgr.TxReceipt[txData])
queue := txmgr.NewQueue[txData](l.killCtx, l.Txmgr, l.Cfg.MaxPendingTransactions) queue := txmgr.NewQueue[txData](l.killCtx, l.Txmgr, l.Config.MaxPendingTransactions)
for { for {
select { select {
...@@ -347,7 +347,7 @@ func (l *BatchSubmitter) sendTransaction(txdata txData, queue *txmgr.Queue[txDat ...@@ -347,7 +347,7 @@ func (l *BatchSubmitter) sendTransaction(txdata txData, queue *txmgr.Queue[txDat
} }
candidate := txmgr.TxCandidate{ candidate := txmgr.TxCandidate{
To: &l.RollupCfg.BatchInboxAddress, To: &l.RollupConfig.BatchInboxAddress,
TxData: data, TxData: data,
GasLimit: intrinsicGas, GasLimit: intrinsicGas,
} }
...@@ -387,7 +387,7 @@ func (l *BatchSubmitter) recordConfirmedTx(id txID, receipt *types.Receipt) { ...@@ -387,7 +387,7 @@ func (l *BatchSubmitter) recordConfirmedTx(id txID, receipt *types.Receipt) {
// l1Tip gets the current L1 tip as a L1BlockRef. The passed context is assumed // l1Tip gets the current L1 tip as a L1BlockRef. The passed context is assumed
// to be a lifetime context, so it is internally wrapped with a network timeout. // to be a lifetime context, so it is internally wrapped with a network timeout.
func (l *BatchSubmitter) l1Tip(ctx context.Context) (eth.L1BlockRef, error) { func (l *BatchSubmitter) l1Tip(ctx context.Context) (eth.L1BlockRef, error) {
tctx, cancel := context.WithTimeout(ctx, l.Cfg.NetworkTimeout) tctx, cancel := context.WithTimeout(ctx, l.Config.NetworkTimeout)
defer cancel() defer cancel()
head, err := l.L1Client.HeaderByNumber(tctx, nil) head, err := l.L1Client.HeaderByNumber(tctx, nil)
if err != nil { if err != nil {
......
...@@ -48,7 +48,7 @@ type BatcherService struct { ...@@ -48,7 +48,7 @@ type BatcherService struct {
RollupConfig *rollup.Config RollupConfig *rollup.Config
// Channel builder parameters // Channel builder parameters
Channel ChannelConfig ChannelConfig ChannelConfig
driver *BatchSubmitter driver *BatchSubmitter
...@@ -90,7 +90,7 @@ func (bs *BatcherService) initFromCLIConfig(ctx context.Context, version string, ...@@ -90,7 +90,7 @@ func (bs *BatcherService) initFromCLIConfig(ctx context.Context, version string,
if err := bs.initRPCClients(ctx, cfg); err != nil { if err := bs.initRPCClients(ctx, cfg); err != nil {
return err return err
} }
if err := bs.initRollupCfg(ctx); err != nil { if err := bs.initRollupConfig(ctx); err != nil {
return fmt.Errorf("failed to load rollup config: %w", err) return fmt.Errorf("failed to load rollup config: %w", err)
} }
if err := bs.initChannelConfig(cfg); err != nil { if err := bs.initChannelConfig(cfg); err != nil {
...@@ -153,12 +153,12 @@ func (bs *BatcherService) initBalanceMonitor(cfg *CLIConfig) { ...@@ -153,12 +153,12 @@ func (bs *BatcherService) initBalanceMonitor(cfg *CLIConfig) {
} }
} }
func (bs *BatcherService) initRollupCfg(ctx context.Context) error { func (bs *BatcherService) initRollupConfig(ctx context.Context) error {
rollupCfg, err := bs.RollupNode.RollupConfig(ctx) rollupConfig, err := bs.RollupNode.RollupConfig(ctx)
if err != nil { if err != nil {
return fmt.Errorf("failed to retrieve rollup config: %w", err) return fmt.Errorf("failed to retrieve rollup config: %w", err)
} }
bs.RollupConfig = rollupCfg bs.RollupConfig = rollupConfig
if err := bs.RollupConfig.Check(); err != nil { if err := bs.RollupConfig.Check(); err != nil {
return fmt.Errorf("invalid rollup config: %w", err) return fmt.Errorf("invalid rollup config: %w", err)
} }
...@@ -166,7 +166,7 @@ func (bs *BatcherService) initRollupCfg(ctx context.Context) error { ...@@ -166,7 +166,7 @@ func (bs *BatcherService) initRollupCfg(ctx context.Context) error {
} }
func (bs *BatcherService) initChannelConfig(cfg *CLIConfig) error { func (bs *BatcherService) initChannelConfig(cfg *CLIConfig) error {
bs.Channel = ChannelConfig{ bs.ChannelConfig = ChannelConfig{
SeqWindowSize: bs.RollupConfig.SeqWindowSize, SeqWindowSize: bs.RollupConfig.SeqWindowSize,
ChannelTimeout: bs.RollupConfig.ChannelTimeout, ChannelTimeout: bs.RollupConfig.ChannelTimeout,
MaxChannelDuration: cfg.MaxChannelDuration, MaxChannelDuration: cfg.MaxChannelDuration,
...@@ -175,7 +175,7 @@ func (bs *BatcherService) initChannelConfig(cfg *CLIConfig) error { ...@@ -175,7 +175,7 @@ func (bs *BatcherService) initChannelConfig(cfg *CLIConfig) error {
CompressorConfig: cfg.CompressorConfig.Config(), CompressorConfig: cfg.CompressorConfig.Config(),
BatchType: cfg.BatchType, BatchType: cfg.BatchType,
} }
if err := bs.Channel.Check(); err != nil { if err := bs.ChannelConfig.Check(); err != nil {
return fmt.Errorf("invalid channel configuration: %w", err) return fmt.Errorf("invalid channel configuration: %w", err)
} }
return nil return nil
...@@ -225,15 +225,15 @@ func (bs *BatcherService) initMetricsServer(cfg *CLIConfig) error { ...@@ -225,15 +225,15 @@ func (bs *BatcherService) initMetricsServer(cfg *CLIConfig) error {
func (bs *BatcherService) initDriver() { func (bs *BatcherService) initDriver() {
bs.driver = NewBatchSubmitter(DriverSetup{ bs.driver = NewBatchSubmitter(DriverSetup{
Log: bs.Log, Log: bs.Log,
Metr: bs.Metrics, Metr: bs.Metrics,
RollupCfg: bs.RollupConfig, RollupConfig: bs.RollupConfig,
Cfg: bs.BatcherConfig, Config: bs.BatcherConfig,
Txmgr: bs.TxManager, Txmgr: bs.TxManager,
L1Client: bs.L1Client, L1Client: bs.L1Client,
L2Client: bs.L2Client, L2Client: bs.L2Client,
RollupClient: bs.RollupNode, RollupClient: bs.RollupNode,
Channel: bs.Channel, ChannelConfig: bs.ChannelConfig,
}) })
} }
......
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