From faf81f297e194308e8ea9eb4f9f10993eb94749c Mon Sep 17 00:00:00 2001 From: David Date: Tue, 2 Jul 2024 13:06:34 +0800 Subject: [PATCH 1/3] fix(taiko_worker): fix a `maxBytesPerTxList` check issue --- miner/taiko_worker.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/miner/taiko_worker.go b/miner/taiko_worker.go index 01b2cded9dfe..cc0ae328fbda 100644 --- a/miner/taiko_worker.go +++ b/miner/taiko_worker.go @@ -327,7 +327,7 @@ func (w *worker) commitL2Transactions( } // Encode and compress the txList, if the byte length is > maxBytesPerTxList, remove the latest tx and break. - b, err := encodeAndComporeessTxList(append(env.txs, tx)) + 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() From 90d34cb930ce8129cb943ad243f1cd8685bf0c70 Mon Sep 17 00:00:00 2001 From: David Date: Tue, 2 Jul 2024 14:01:15 +0800 Subject: [PATCH 2/3] feat: more changes --- miner/taiko_worker.go | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/miner/taiko_worker.go b/miner/taiko_worker.go index cc0ae328fbda..ad1d8a497541 100644 --- a/miner/taiko_worker.go +++ b/miner/taiko_worker.go @@ -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 { @@ -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. + 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(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 - } } return lastTransaction From 210a7bb7abb069ddd3b610a5361b5e61e3183100 Mon Sep 17 00:00:00 2001 From: David Date: Tue, 2 Jul 2024 14:07:58 +0800 Subject: [PATCH 3/3] feat: more changes --- miner/taiko_worker.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/miner/taiko_worker.go b/miner/taiko_worker.go index ad1d8a497541..353a02513c3f 100644 --- a/miner/taiko_worker.go +++ b/miner/taiko_worker.go @@ -320,7 +320,7 @@ loop: env.tcount++ txs.Shift() - // Encode and compress the txList, if the byte length is > maxBytesPerTxList, remove the latest tx. + // 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)