mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-24 05:36:46 +00:00
miner: add blob fees
remove todo
This commit is contained in:
parent
c3ef6c77c2
commit
417b5f73e2
1 changed files with 16 additions and 3 deletions
|
|
@ -168,7 +168,7 @@ func (miner *Miner) generateWork(genParam *generateParams, witness bool) *newPay
|
||||||
}
|
}
|
||||||
return &newPayloadResult{
|
return &newPayloadResult{
|
||||||
block: block,
|
block: block,
|
||||||
fees: totalFees(block, work.receipts),
|
fees: totalFees(miner.chainConfig, block, work.receipts),
|
||||||
sidecars: work.sidecars,
|
sidecars: work.sidecars,
|
||||||
stateDB: work.state,
|
stateDB: work.state,
|
||||||
receipts: work.receipts,
|
receipts: work.receipts,
|
||||||
|
|
@ -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.
|
// 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)
|
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() {
|
for i, tx := range block.Transactions() {
|
||||||
minerFee, _ := tx.EffectiveGasTip(block.BaseFee())
|
minerFee, _ := tx.EffectiveGasTip(block.BaseFee())
|
||||||
feesWei.Add(feesWei, new(big.Int).Mul(new(big.Int).SetUint64(receipts[i].GasUsed), minerFee))
|
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 {
|
||||||
|
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
|
return feesWei
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue