From 31bb680997b0d24554ddd3eab8da8e179eed9ee7 Mon Sep 17 00:00:00 2001 From: cui Date: Thu, 14 May 2026 19:45:49 +0800 Subject: [PATCH] miner: re-use basefee and big.Int in loop (#34783) --- miner/worker.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/miner/worker.go b/miner/worker.go index 026bafc4e5..1ecee96688 100644 --- a/miner/worker.go +++ b/miner/worker.go @@ -601,10 +601,14 @@ func (miner *Miner) fillTransactions(ctx context.Context, interrupt *atomic.Int3 // totalFees computes total consumed miner fees in Wei. Block transactions and receipts have to have the same order. func totalFees(block *types.Block, receipts []*types.Receipt) *big.Int { + baseFee := block.BaseFee() feesWei := new(big.Int) + var gasUsed, product big.Int for i, tx := range block.Transactions() { - minerFee, _ := tx.EffectiveGasTip(block.BaseFee()) - feesWei.Add(feesWei, new(big.Int).Mul(new(big.Int).SetUint64(receipts[i].GasUsed), minerFee)) + minerFee, _ := tx.EffectiveGasTip(baseFee) + gasUsed.SetUint64(receipts[i].GasUsed) + product.Mul(&gasUsed, minerFee) + feesWei.Add(feesWei, &product) } return feesWei }