Skip to content

Commit

Permalink
feat(miner): compress the txlist bytes after checking the transaction…
Browse files Browse the repository at this point in the history
… is executable (#269)

* feat(miner): introduce `bytesLimitCheckStep`

* feat: compress

* Update miner/taiko_worker.go

Co-authored-by: Roger <50648015+RogerLamTd@users.noreply.github.com>

---------

Co-authored-by: Roger <50648015+RogerLamTd@users.noreply.github.com>
  • Loading branch information
davidtaikocha and RogerLamTd committed Jun 6, 2024
1 parent 8bd80e4 commit aa70708
Showing 1 changed file with 13 additions and 11 deletions.
24 changes: 13 additions & 11 deletions miner/taiko_worker.go
Original file line number Diff line number Diff line change
Expand Up @@ -265,16 +265,6 @@ func (w *worker) commitL2Transactions(
// during transaction acceptance is the transaction pool.
from, _ := types.Sender(env.signer, tx)

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) {
break
}

// Check whether the tx is replay protected. If we're not in the EIP155 hf
// phase, start ignoring the sender until we do.
if tx.Protected() && !w.chainConfig.IsEIP155(env.header.Number) {
Expand All @@ -286,7 +276,7 @@ func (w *worker) commitL2Transactions(
// Start executing the transaction
env.state.SetTxContext(tx.Hash(), env.tcount)

_, err = w.commitTransaction(env, tx)
_, err := w.commitTransaction(env, tx)
switch {
case errors.Is(err, core.ErrNonceTooLow):
// New head notification data race between the transaction pool and miner, shift
Expand All @@ -304,6 +294,18 @@ func (w *worker) commitL2Transactions(
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) {
env.txs = env.txs[0 : env.tcount-1]
break
}
}
}

Expand Down

0 comments on commit aa70708

Please sign in to comment.