Commit 236b92e7 authored by Conner Fromknecht's avatar Conner Fromknecht

chore: prepare for iterative batch-tx size reduction

This commit places the batch sequencer tx size check inside of a for
loop so that the we can continue to whittle away batch tx sizes until
satisfying the configured maximum. This doesn't result in a behavioral
change, as the for loop exits after the first iteration. This is done to
make the behavioral changes more apparent in subsequent commits.
parent 6780c473
...@@ -166,43 +166,45 @@ func (d *Driver) SubmitBatchTx( ...@@ -166,43 +166,45 @@ func (d *Driver) SubmitBatchTx(
} }
shouldStartAt := start.Uint64() shouldStartAt := start.Uint64()
batchParams, err := GenSequencerBatchParams( for {
shouldStartAt, d.cfg.BlockOffset, batchElements, batchParams, err := GenSequencerBatchParams(
) shouldStartAt, d.cfg.BlockOffset, batchElements,
if err != nil { )
return nil, err if err != nil {
} return nil, err
}
log.Info(name+" batch params", "params", fmt.Sprintf("%#v", batchParams)) log.Info(name+" batch params", "params", fmt.Sprintf("%#v", batchParams))
batchArguments, err := batchParams.Serialize() batchArguments, err := batchParams.Serialize()
if err != nil { if err != nil {
return nil, err return nil, err
} }
appendSequencerBatchID := d.ctcABI.Methods[appendSequencerBatchMethodName].ID appendSequencerBatchID := d.ctcABI.Methods[appendSequencerBatchMethodName].ID
batchCallData := append(appendSequencerBatchID, batchArguments...) batchCallData := append(appendSequencerBatchID, batchArguments...)
if uint64(len(batchCallData)) > d.cfg.MaxTxSize { if uint64(len(batchCallData)) > d.cfg.MaxTxSize {
panic("call data too large") panic("call data too large")
} }
// Record the batch_tx_build_time. // Record the batch_tx_build_time.
batchTxBuildTime := float64(time.Since(batchTxBuildStart) / time.Millisecond) batchTxBuildTime := float64(time.Since(batchTxBuildStart) / time.Millisecond)
d.metrics.BatchTxBuildTime.Set(batchTxBuildTime) d.metrics.BatchTxBuildTime.Set(batchTxBuildTime)
d.metrics.NumTxPerBatch.Observe(float64(len(blocks))) d.metrics.NumTxPerBatch.Observe(float64(len(blocks)))
log.Info(name+" batch call data", "data", hex.EncodeToString(batchCallData)) log.Info(name+" batch call data", "data", hex.EncodeToString(batchCallData))
opts, err := bind.NewKeyedTransactorWithChainID( opts, err := bind.NewKeyedTransactorWithChainID(
d.cfg.PrivKey, d.cfg.ChainID, d.cfg.PrivKey, d.cfg.ChainID,
) )
if err != nil { if err != nil {
return nil, err return nil, err
} }
opts.Nonce = nonce opts.Nonce = nonce
opts.Context = ctx opts.Context = ctx
opts.GasPrice = gasPrice opts.GasPrice = gasPrice
return d.rawCtcContract.RawTransact(opts, batchCallData) return d.rawCtcContract.RawTransact(opts, batchCallData)
}
} }
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