Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 16 additions & 3 deletions miner/worker.go
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ func (miner *Miner) generateWork(genParam *generateParams, witness bool) *newPay
}
return &newPayloadResult{
block: block,
fees: totalFees(block, work.receipts),
fees: totalFees(miner.chainConfig, block, work.receipts),
sidecars: work.sidecars,
stateDB: work.state,
receipts: work.receipts,
Expand Down Expand Up @@ -538,12 +538,25 @@ func (miner *Miner) fillTransactions(interrupt *atomic.Int32, env *environment)
}

// 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 {
func totalFees(chainConfig *params.ChainConfig, block *types.Block, receipts []*types.Receipt) *big.Int {
feesWei := new(big.Int)
var blobBaseFee *big.Int
if block.BlobGasUsed() != nil && block.ExcessBlobGas() != nil {
blobBaseFee = eip4844.CalcBlobFee(chainConfig, block.Header())
}

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))
// TODO (MariusVanDerWijden) add blob fees

// Add blob fees for blob transactions (EIP-4844)
if tx.Type() == types.BlobTxType {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The fee of blobs are burned without paying to block producer. It makes no sense to include them here.

blobGasUsed := receipts[i].BlobGasUsed
if blobGasUsed > 0 && blobBaseFee != nil {
blobFees := new(big.Int).Mul(new(big.Int).SetUint64(blobGasUsed), blobBaseFee)
feesWei.Add(feesWei, blobFees)
}
}
}
return feesWei
}
Expand Down
Loading