From 507e40a49b8c6ad420b82ab7df32a172141f0888 Mon Sep 17 00:00:00 2001 From: Jihoon Song Date: Sat, 30 Nov 2024 17:54:25 +0900 Subject: [PATCH] miner: include inclusion list transactions when building a payload --- miner/worker.go | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/miner/worker.go b/miner/worker.go index 6790a6ec98..5c310d2666 100644 --- a/miner/worker.go +++ b/miner/worker.go @@ -472,6 +472,41 @@ func (miner *Miner) fillTransactions(interrupt *atomic.Int32, env *environment) return err } } + + // Fill the block with transactions in the inclusion list that are not included in the block. + isIncluded := make(map[common.Hash]bool) + for _, txs := range pendingPlainTxs { + for _, tx := range txs { + isIncluded[tx.Hash] = true + } + } + for _, txs := range pendingBlobTxs { + for _, tx := range txs { + isIncluded[tx.Hash] = true + } + } + + pendingInclusionListTxs := make([]*types.Transaction, 0) + for _, tx := range env.inclusionList { + if isIncluded[tx.Hash()] { + continue + } + + pendingInclusionListTxs = append(pendingInclusionListTxs, tx) + } + + if len(pendingInclusionListTxs) > 0 { + gasLimit := env.header.GasLimit + if env.gasPool == nil { + env.gasPool = new(core.GasPool).AddGas(gasLimit) + } + + for _, tx := range pendingInclusionListTxs { + env.state.SetTxContext(tx.Hash(), env.tcount) + miner.commitTransaction(env, tx) // Error is simply ignored. A transaction that cannot be appended at the end of the block can be skipped. + } + } + return nil }