Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(taiko_worker): fix a maxBytesPerTxList check issue #282

Merged
merged 3 commits into from
Jul 2, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading