Skip to content

Commit 2f8ef6c

Browse files
mask-ppThegaram
authored andcommitted
fix the bug when calculating l2TxCount. (#479)
* fix bug when calculate l2 tx count * Update version
1 parent 26bbdde commit 2f8ef6c

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

miner/worker.go

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -971,11 +971,6 @@ loop:
971971
}
972972
return atomic.LoadInt32(interrupt) == commitInterruptNewHead, circuitCapacityReached
973973
}
974-
// If we have collected enough transactions then we're done
975-
if !w.chainConfig.Scroll.IsValidL2TxCount(w.current.tcount - w.current.l1TxCount + 1) {
976-
log.Trace("Transaction count limit reached", "have", w.current.tcount-w.current.l1TxCount, "want", w.chainConfig.Scroll.MaxTxPerBlock)
977-
break
978-
}
979974
// If we don't have enough gas for any further transactions then we're done
980975
if w.current.gasPool.Gas() < params.TxGas {
981976
log.Trace("Not enough gas for further transactions", "have", w.current.gasPool, "want", params.TxGas)
@@ -986,6 +981,15 @@ loop:
986981
if tx == nil {
987982
break
988983
}
984+
// If we have collected enough transactions then we're done
985+
l2TxCount := w.current.tcount - w.current.l1TxCount
986+
if !tx.IsL1MessageTx() { // If the next tx is not L1MessageTx type then +1.
987+
l2TxCount++
988+
}
989+
if !w.chainConfig.Scroll.IsValidL2TxCount(l2TxCount) {
990+
log.Trace("Transaction count limit reached", "have", w.current.tcount-w.current.l1TxCount, "want", w.chainConfig.Scroll.MaxTxPerBlock)
991+
break
992+
}
989993
if tx.IsL1MessageTx() && tx.AsL1MessageTx().QueueIndex != w.current.nextL1MsgIndex {
990994
log.Error(
991995
"Unexpected L1 message queue index in worker",

0 commit comments

Comments
 (0)