Skip to content

Commit 0ded110

Browse files
authored
core: infer blobGasUsed in chain maker (#28212)
Same way that the gasUsed in header is updated when a tx is added we should update blob gas used instead of requiring caller to set it manually.
1 parent 1f6e639 commit 0ded110

File tree

2 files changed

+3
-8
lines changed

2 files changed

+3
-8
lines changed

core/chain_makers.go

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -88,11 +88,6 @@ func (b *BlockGen) SetPoS() {
8888
b.header.Difficulty = new(big.Int)
8989
}
9090

91-
// SetBlobGas sets the data gas used by the blob in the generated block.
92-
func (b *BlockGen) SetBlobGas(blobGasUsed uint64) {
93-
b.header.BlobGasUsed = &blobGasUsed
94-
}
95-
9691
// addTx adds a transaction to the generated block. If no coinbase has
9792
// been set, the block's coinbase is set to the zero address.
9893
//
@@ -111,6 +106,9 @@ func (b *BlockGen) addTx(bc *BlockChain, vmConfig vm.Config, tx *types.Transacti
111106
}
112107
b.txs = append(b.txs, tx)
113108
b.receipts = append(b.receipts, receipt)
109+
if b.header.BlobGasUsed != nil {
110+
*b.header.BlobGasUsed += receipt.BlobGasUsed
111+
}
114112
}
115113

116114
// AddTx adds a transaction to the generated block. If no coinbase has

internal/ethapi/api_test.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1448,9 +1448,6 @@ func setupReceiptBackend(t *testing.T, genBlocks int) (*testBackend, []common.Ha
14481448
b.AddTx(tx)
14491449
txHashes[i] = tx.Hash()
14501450
}
1451-
if i == 5 {
1452-
b.SetBlobGas(params.BlobTxBlobGasPerBlob)
1453-
}
14541451
b.SetPoS()
14551452
})
14561453
return backend, txHashes

0 commit comments

Comments
 (0)