Commit b151d50d authored by Sebastian Stammler's avatar Sebastian Stammler

op-batcher: Start SequencerWindow timeout tracking (WIP)

parent 32dc4735
...@@ -20,6 +20,9 @@ type ( ...@@ -20,6 +20,9 @@ type (
// L1 block timestamp of channel timeout. 0 if no timeout set yet. // L1 block timestamp of channel timeout. 0 if no timeout set yet.
timeout uint64 timeout uint64
// sequencer window timeout block. 0 if not set yet.
swTimeoutBlock uint64
// marked as full if a) max RLP input bytes, b) max num frames or c) max // marked as full if a) max RLP input bytes, b) max num frames or c) max
// allowed frame index (uint16) has been reached // allowed frame index (uint16) has been reached
fullErr error fullErr error
...@@ -32,6 +35,9 @@ type ( ...@@ -32,6 +35,9 @@ type (
} }
ChannelConfig struct { ChannelConfig struct {
// Number of epochs (L1 blocks) per sequencing window, including the epoch
// L1 origin block itself
SeqWindowSize uint64
// The maximum number of L1 blocks that the inclusion transactions of a // The maximum number of L1 blocks that the inclusion transactions of a
// channel's frames can span. // channel's frames can span.
ChannelTimeout uint64 ChannelTimeout uint64
...@@ -158,14 +164,19 @@ func (c *channelBuilder) AddBlock(block *types.Block) error { ...@@ -158,14 +164,19 @@ func (c *channelBuilder) AddBlock(block *types.Block) error {
return c.FullErr() return c.FullErr()
} }
_, err := c.co.AddBlock(block) batch, err := derive.BlockToBatch(block)
if errors.Is(err, derive.ErrTooManyRLPBytes) { if err != nil {
return fmt.Errorf("converting block to batch: %w", err)
}
if _, err = c.co.AddBatch(batch); errors.Is(err, derive.ErrTooManyRLPBytes) {
c.setFullErr(err) c.setFullErr(err)
return c.FullErr() return c.FullErr()
} else if err != nil { } else if err != nil {
return fmt.Errorf("adding block to channel out: %w", err) return fmt.Errorf("adding block to channel out: %w", err)
} }
c.blocks = append(c.blocks, block) c.blocks = append(c.blocks, block)
c.updateSwTimeout(batch)
if c.InputTargetReached() { if c.InputTargetReached() {
c.setFullErr(ErrInputTargetReached) c.setFullErr(ErrInputTargetReached)
...@@ -175,6 +186,14 @@ func (c *channelBuilder) AddBlock(block *types.Block) error { ...@@ -175,6 +186,14 @@ func (c *channelBuilder) AddBlock(block *types.Block) error {
return nil return nil
} }
func (c *channelBuilder) updateSwTimeout(batch *derive.BatchData) {
if c.swTimeoutBlock != 0 {
return
}
// TODO: subtract safety margin
c.swTimeoutBlock = uint64(batch.EpochNum) + c.cfg.SeqWindowSize
}
// InputTargetReached says whether the target amount of input data has been // InputTargetReached says whether the target amount of input data has been
// reached in this channel builder. No more blocks can be added afterwards. // reached in this channel builder. No more blocks can be added afterwards.
func (c *channelBuilder) InputTargetReached() bool { func (c *channelBuilder) InputTargetReached() bool {
......
...@@ -77,6 +77,11 @@ func NewBatchSubmitterFromCLIConfig(cfg CLIConfig, l log.Logger) (*BatchSubmitte ...@@ -77,6 +77,11 @@ func NewBatchSubmitterFromCLIConfig(cfg CLIConfig, l log.Logger) (*BatchSubmitte
return nil, err return nil, err
} }
rcfg, err := rollupClient.RollupConfig(ctx)
if err != nil {
return nil, err
}
txManagerConfig := txmgr.Config{ txManagerConfig := txmgr.Config{
ResubmissionTimeout: cfg.ResubmissionTimeout, ResubmissionTimeout: cfg.ResubmissionTimeout,
ReceiptQueryInterval: time.Second, ReceiptQueryInterval: time.Second,
...@@ -95,6 +100,7 @@ func NewBatchSubmitterFromCLIConfig(cfg CLIConfig, l log.Logger) (*BatchSubmitte ...@@ -95,6 +100,7 @@ func NewBatchSubmitterFromCLIConfig(cfg CLIConfig, l log.Logger) (*BatchSubmitte
SignerFnFactory: signer, SignerFnFactory: signer,
BatchInboxAddress: batchInboxAddress, BatchInboxAddress: batchInboxAddress,
Channel: ChannelConfig{ Channel: ChannelConfig{
SeqWindowSize: rcfg.SeqWindowSize,
ChannelTimeout: cfg.ChannelTimeout, ChannelTimeout: cfg.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
......
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