Skip to content

Commit 0e68e48

Browse files
committed
count fix
1 parent 8590393 commit 0e68e48

File tree

2 files changed

+34
-17
lines changed

2 files changed

+34
-17
lines changed

miner/worker.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -834,8 +834,8 @@ func (w *worker) commitTransactions(env *environment, txs *types.TransactionsByP
834834
return atomic.LoadInt32(interrupt) == commitInterruptNewHead
835835
}
836836
// If we have collected enough transactions then we're done
837-
if !w.chainConfig.Scroll.IsValidL2TxCount(w.current.tcount - w.current.l1TxCount + 1) {
838-
log.Trace("Transaction count limit reached", "have", w.current.tcount-w.current.l1TxCount, "want", w.chainConfig.Scroll.MaxTxPerBlock)
837+
if !w.chainConfig.Scroll.IsValidL2TxCount(env.tcount - env.l1TxCount + 1) {
838+
log.Trace("Transaction count limit reached", "have", env.tcount-env.l1TxCount, "want", w.chainConfig.Scroll.MaxTxPerBlock)
839839
break
840840
}
841841
// If we don't have enough gas for any further transactions then we're done
@@ -848,8 +848,8 @@ func (w *worker) commitTransactions(env *environment, txs *types.TransactionsByP
848848
if tx == nil {
849849
break
850850
}
851-
if !w.chainConfig.Scroll.IsValidBlockSize(w.current.blockSize + tx.Size()) {
852-
log.Trace("Block size limit reached", "have", w.current.blockSize, "want", w.chainConfig.Scroll.MaxTxPayloadBytesPerBlock, "tx", tx.Size())
851+
if !w.chainConfig.Scroll.IsValidBlockSize(env.blockSize + tx.Size()) {
852+
log.Trace("Block size limit reached", "have", env.blockSize, "want", w.chainConfig.Scroll.MaxTxPayloadBytesPerBlock, "tx", tx.Size())
853853
txs.Pop() // skip transactions from this account
854854
continue
855855
}
@@ -890,7 +890,7 @@ func (w *worker) commitTransactions(env *environment, txs *types.TransactionsByP
890890
// Everything ok, collect the logs and shift in the next transaction from the same account
891891
coalescedLogs = append(coalescedLogs, logs...)
892892
if tx.IsL1MessageTx() {
893-
w.current.l1TxCount++
893+
env.l1TxCount++
894894
}
895895
env.tcount++
896896
env.blockSize += tx.Size()

miner/worker_l2.go

Lines changed: 29 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,23 @@ func (w *worker) makeHeader(parent *types.Block, timestamp uint64, coinBase comm
9191
// fillTransactions retrieves the pending transactions from the txpool and fills them
9292
// into the given sealing block. The transaction selection and ordering strategy can
9393
// be customized with the plugin in the future.
94-
func (w *worker) fillTransactions(env *environment) {
94+
func (w *worker) fillTransactions(env *environment, l1Transactions types.Transactions) {
95+
if len(l1Transactions) > 0 {
96+
l1Txs := make(map[common.Address]types.Transactions)
97+
for _, tx := range l1Transactions {
98+
sender, _ := types.Sender(env.signer, tx)
99+
senderTxs, ok := l1Txs[sender]
100+
if ok {
101+
senderTxs = append(senderTxs, tx)
102+
l1Txs[sender] = senderTxs
103+
} else {
104+
l1Txs[sender] = types.Transactions{tx}
105+
}
106+
}
107+
txs := types.NewTransactionsByPriceAndNonce(env.signer, l1Txs, env.header.BaseFee)
108+
w.commitTransactions(env, txs, env.header.Coinbase, nil)
109+
}
110+
95111
// Split the pending transactions into locals and remotes
96112
// Fill the block with all available pending transactions.
97113
pending := w.eth.TxPool().Pending(true)
@@ -123,18 +139,19 @@ func (w *worker) generateWork(genParams *generateParams) (*types.Block, *state.S
123139
work.gasPool = new(core.GasPool).AddGas(work.header.GasLimit)
124140
}
125141

126-
for _, tx := range genParams.transactions {
127-
from, _ := types.Sender(work.signer, tx)
128-
// Start executing the transaction
129-
work.state.Prepare(tx.Hash(), work.tcount)
130-
_, err := w.commitTransaction(work, tx, work.header.Coinbase)
131-
if err != nil {
132-
return nil, nil, nil, fmt.Errorf("failed to force-include tx: %s type: %d sender: %s nonce: %d, err: %w", tx.Hash(), tx.Type(), from, tx.Nonce(), err)
133-
}
134-
work.tcount++
135-
}
142+
//for _, tx := range genParams.transactions {
143+
//
144+
// from, _ := types.Sender(work.signer, tx)
145+
// // Start executing the transaction
146+
// work.state.Prepare(tx.Hash(), work.tcount)
147+
// _, err := w.commitTransaction(work, tx, work.header.Coinbase)
148+
// if err != nil {
149+
// return nil, nil, nil, fmt.Errorf("failed to force-include tx: %s type: %d sender: %s nonce: %d, err: %w", tx.Hash(), tx.Type(), from, tx.Nonce(), err)
150+
// }
151+
// work.l1TxCount++
152+
//}
136153

137-
w.fillTransactions(work)
154+
w.fillTransactions(work, genParams.transactions)
138155

139156
block, err := w.engine.FinalizeAndAssemble(w.chain, work.header, work.state, work.txs, nil, work.receipts)
140157
if err != nil {

0 commit comments

Comments
 (0)