Compare commits

..

1 Commits

Author SHA1 Message Date
Péter Garamvölgyi
2962fa4b0e batch proposer: only sleep if we failed to create batch (#388) 2023-03-22 22:16:31 +08:00
2 changed files with 15 additions and 9 deletions

View File

@@ -229,14 +229,18 @@ func (p *BatchProposer) tryProposeBatch() {
return
}
p.proposeBatch(blocks)
batchCreated := p.proposeBatch(blocks)
// while size of batchDataBuffer < commitCalldataMinSize,
// proposer keeps fetching and porposing batches.
if p.getBatchDataBufferSize() >= p.commitCalldataMinSize {
return
}
// wait for watcher to insert l2 traces.
time.Sleep(time.Second)
if !batchCreated {
// wait for watcher to insert l2 traces.
time.Sleep(time.Second)
}
}
}
@@ -285,9 +289,9 @@ func (p *BatchProposer) tryCommitBatches() {
}
}
func (p *BatchProposer) proposeBatch(blocks []*types.BlockInfo) {
func (p *BatchProposer) proposeBatch(blocks []*types.BlockInfo) bool {
if len(blocks) == 0 {
return
return false
}
if blocks[0].GasUsed > p.batchGasThreshold {
@@ -300,7 +304,7 @@ func (p *BatchProposer) proposeBatch(blocks []*types.BlockInfo) {
bridgeL2BatchesGasCreatedRateMeter.Mark(int64(blocks[0].GasUsed))
bridgeL2BatchesCreatedRateMeter.Mark(1)
}
return
return true
}
if blocks[0].TxNum > p.batchTxNumThreshold {
@@ -313,7 +317,7 @@ func (p *BatchProposer) proposeBatch(blocks []*types.BlockInfo) {
bridgeL2BatchesGasCreatedRateMeter.Mark(int64(blocks[0].GasUsed))
bridgeL2BatchesCreatedRateMeter.Mark(1)
}
return
return true
}
var gasUsed, txNum uint64
@@ -333,7 +337,7 @@ func (p *BatchProposer) proposeBatch(blocks []*types.BlockInfo) {
// if it's not old enough we will skip proposing the batch,
// otherwise we will still propose a batch
if !reachThreshold && blocks[0].BlockTimestamp+p.batchTimeSec > uint64(time.Now().Unix()) {
return
return false
}
if err := p.createBatchForBlocks(blocks); err != nil {
@@ -343,6 +347,8 @@ func (p *BatchProposer) proposeBatch(blocks []*types.BlockInfo) {
bridgeL2BatchesGasCreatedRateMeter.Mark(int64(gasUsed))
bridgeL2BatchesCreatedRateMeter.Mark(int64(len(blocks)))
}
return true
}
func (p *BatchProposer) createBatchForBlocks(blocks []*types.BlockInfo) error {

View File

@@ -5,7 +5,7 @@ import (
"runtime/debug"
)
var tag = "alpha-v2.4"
var tag = "alpha-v2.5"
var commit = func() string {
if info, ok := debug.ReadBuildInfo(); ok {