Skip to content

Commit

Permalink
fix(taiko_worker): fix a maxBytesPerTxList check issue (taikoxyz#282)
Browse files Browse the repository at this point in the history
* fix(taiko_worker): fix a `maxBytesPerTxList` check issue

* feat: more changes

* feat: more changes
  • Loading branch information
davidtaikocha authored and lwedge99 committed Jul 2, 2024
1 parent 992ac69 commit 99d82e3
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions miner/taiko_worker.go
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,7 @@ func (w *worker) commitL2Transactions(
env.txs = append(env.txs, firstTransaction)
}

loop:
for {
// If we don't have enough gas for any further transactions then we're done.
if env.gasPool.Gas() < params.TxGas {
Expand Down Expand Up @@ -319,25 +320,24 @@ func (w *worker) commitL2Transactions(
env.tcount++
txs.Shift()

// Encode and compress the txList, if the byte length is > maxBytesPerTxList, remove the latest tx and break.
b, err := encodeAndComporeessTxList(env.txs)
if err != nil {
log.Trace("Failed to rlp encode and compress the pending transaction %s: %w", tx.Hash(), err)
txs.Pop()
continue
}
if len(b) > int(maxBytesPerTxList) {
lastTransaction = env.txs[env.tcount-1]
env.txs = env.txs[0 : env.tcount-1]
break loop
}
default:
// Transaction is regarded as invalid, drop all consecutive transactions from
// the same sender because of `nonce-too-high` clause.
log.Trace("Transaction failed, account skipped", "hash", ltx.Hash, "err", err)
txs.Pop()
}

// Encode and compress the txList, if the byte length is > maxBytesPerTxList, remove the latest tx and break.
b, err := encodeAndComporeessTxList(append(env.txs, tx))
if err != nil {
log.Trace("Failed to rlp encode and compress the pending transaction %s: %w", tx.Hash(), err)
txs.Pop()
continue
}
if len(b) > int(maxBytesPerTxList) {
lastTransaction = env.txs[env.tcount-1]
env.txs = env.txs[0 : env.tcount-1]
break
}
}

return lastTransaction
Expand Down

0 comments on commit 99d82e3

Please sign in to comment.