Skip to content

Commit

Permalink
fix the bug when calculating l2TxCount. (#479)
Browse files Browse the repository at this point in the history
* fix bug when calculate l2 tx count

* Update version
  • Loading branch information
mask-pp authored and Thegaram committed Aug 25, 2023
1 parent 26bbdde commit 2f8ef6c
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions miner/worker.go
Original file line number Diff line number Diff line change
Expand Up @@ -971,11 +971,6 @@ loop:
}
return atomic.LoadInt32(interrupt) == commitInterruptNewHead, circuitCapacityReached
}
// If we have collected enough transactions then we're done
if !w.chainConfig.Scroll.IsValidL2TxCount(w.current.tcount - w.current.l1TxCount + 1) {
log.Trace("Transaction count limit reached", "have", w.current.tcount-w.current.l1TxCount, "want", w.chainConfig.Scroll.MaxTxPerBlock)
break
}
// If we don't have enough gas for any further transactions then we're done
if w.current.gasPool.Gas() < params.TxGas {
log.Trace("Not enough gas for further transactions", "have", w.current.gasPool, "want", params.TxGas)
Expand All @@ -986,6 +981,15 @@ loop:
if tx == nil {
break
}
// If we have collected enough transactions then we're done
l2TxCount := w.current.tcount - w.current.l1TxCount
if !tx.IsL1MessageTx() { // If the next tx is not L1MessageTx type then +1.
l2TxCount++
}
if !w.chainConfig.Scroll.IsValidL2TxCount(l2TxCount) {
log.Trace("Transaction count limit reached", "have", w.current.tcount-w.current.l1TxCount, "want", w.chainConfig.Scroll.MaxTxPerBlock)
break
}
if tx.IsL1MessageTx() && tx.AsL1MessageTx().QueueIndex != w.current.nextL1MsgIndex {
log.Error(
"Unexpected L1 message queue index in worker",
Expand Down

0 comments on commit 2f8ef6c

Please sign in to comment.