Skip to content

Commit 57268f7

Browse files
authored
all: rename dataGas to blobGas (ethereum#27789)
1 parent 0f4b21f commit 57268f7

32 files changed

+224
-225
lines changed

beacon/engine/gen_ed.go

Lines changed: 10 additions & 10 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

beacon/engine/types.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,8 @@ type ExecutableData struct {
6262
BlockHash common.Hash `json:"blockHash" gencodec:"required"`
6363
Transactions [][]byte `json:"transactions" gencodec:"required"`
6464
Withdrawals []*types.Withdrawal `json:"withdrawals"`
65-
DataGasUsed *uint64 `json:"dataGasUsed"`
66-
ExcessDataGas *uint64 `json:"excessDataGas"`
65+
BlobGasUsed *uint64 `json:"blobGasUsed"`
66+
ExcessBlobGas *uint64 `json:"excessBlobGas"`
6767
}
6868

6969
// JSON type overrides for executableData.
@@ -76,8 +76,8 @@ type executableDataMarshaling struct {
7676
ExtraData hexutil.Bytes
7777
LogsBloom hexutil.Bytes
7878
Transactions []hexutil.Bytes
79-
DataGasUsed *hexutil.Uint64
80-
ExcessDataGas *hexutil.Uint64
79+
BlobGasUsed *hexutil.Uint64
80+
ExcessBlobGas *hexutil.Uint64
8181
}
8282

8383
//go:generate go run github.com/fjl/gencodec -type ExecutionPayloadEnvelope -field-override executionPayloadEnvelopeMarshaling -out gen_epe.go
@@ -224,8 +224,8 @@ func ExecutableDataToBlock(params ExecutableData, versionedHashes []common.Hash)
224224
Extra: params.ExtraData,
225225
MixDigest: params.Random,
226226
WithdrawalsHash: withdrawalsRoot,
227-
ExcessDataGas: params.ExcessDataGas,
228-
DataGasUsed: params.DataGasUsed,
227+
ExcessBlobGas: params.ExcessBlobGas,
228+
BlobGasUsed: params.BlobGasUsed,
229229
}
230230
block := types.NewBlockWithHeader(header).WithBody(txs, nil /* uncles */).WithWithdrawals(params.Withdrawals)
231231
if block.Hash() != params.BlockHash {
@@ -253,8 +253,8 @@ func BlockToExecutableData(block *types.Block, fees *big.Int, blobs []kzg4844.Bl
253253
Random: block.MixDigest(),
254254
ExtraData: block.Extra(),
255255
Withdrawals: block.Withdrawals(),
256-
DataGasUsed: block.DataGasUsed(),
257-
ExcessDataGas: block.ExcessDataGas(),
256+
BlobGasUsed: block.BlobGasUsed(),
257+
ExcessBlobGas: block.ExcessBlobGas(),
258258
}
259259
blobsBundle := BlobsBundleV1{
260260
Commitments: make([]hexutil.Bytes, 0),

consensus/beacon/consensus.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -269,13 +269,13 @@ func (beacon *Beacon) verifyHeader(chain consensus.ChainHeaderReader, header, pa
269269
if !shanghai && header.WithdrawalsHash != nil {
270270
return fmt.Errorf("invalid withdrawalsHash: have %x, expected nil", header.WithdrawalsHash)
271271
}
272-
// Verify the existence / non-existence of excessDataGas
272+
// Verify the existence / non-existence of excessBlobGas
273273
cancun := chain.Config().IsCancun(header.Number, header.Time)
274-
if !cancun && header.ExcessDataGas != nil {
275-
return fmt.Errorf("invalid excessDataGas: have %d, expected nil", header.ExcessDataGas)
274+
if !cancun && header.ExcessBlobGas != nil {
275+
return fmt.Errorf("invalid excessBlobGas: have %d, expected nil", header.ExcessBlobGas)
276276
}
277-
if !cancun && header.DataGasUsed != nil {
278-
return fmt.Errorf("invalid dataGasUsed: have %d, expected nil", header.DataGasUsed)
277+
if !cancun && header.BlobGasUsed != nil {
278+
return fmt.Errorf("invalid blobGasUsed: have %d, expected nil", header.BlobGasUsed)
279279
}
280280
if cancun {
281281
if err := eip4844.VerifyEIP4844Header(parent, header); err != nil {

consensus/misc/eip4844/eip4844.go

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -26,58 +26,58 @@ import (
2626
)
2727

2828
var (
29-
minDataGasPrice = big.NewInt(params.BlobTxMinDataGasprice)
30-
dataGaspriceUpdateFraction = big.NewInt(params.BlobTxDataGaspriceUpdateFraction)
29+
minBlobGasPrice = big.NewInt(params.BlobTxMinBlobGasprice)
30+
blobGaspriceUpdateFraction = big.NewInt(params.BlobTxBlobGaspriceUpdateFraction)
3131
)
3232

33-
// VerifyEIP4844Header verifies the presence of the excessDataGas field and that
34-
// if the current block contains no transactions, the excessDataGas is updated
33+
// VerifyEIP4844Header verifies the presence of the excessBlobGas field and that
34+
// if the current block contains no transactions, the excessBlobGas is updated
3535
// accordingly.
3636
func VerifyEIP4844Header(parent, header *types.Header) error {
3737
// Verify the header is not malformed
38-
if header.ExcessDataGas == nil {
39-
return errors.New("header is missing excessDataGas")
38+
if header.ExcessBlobGas == nil {
39+
return errors.New("header is missing excessBlobGas")
4040
}
41-
if header.DataGasUsed == nil {
42-
return errors.New("header is missing dataGasUsed")
41+
if header.BlobGasUsed == nil {
42+
return errors.New("header is missing blobGasUsed")
4343
}
4444
// Verify that the data gas used remains within reasonable limits.
45-
if *header.DataGasUsed > params.BlobTxMaxDataGasPerBlock {
46-
return fmt.Errorf("data gas used %d exceeds maximum allowance %d", *header.DataGasUsed, params.BlobTxMaxDataGasPerBlock)
45+
if *header.BlobGasUsed > params.BlobTxMaxBlobGasPerBlock {
46+
return fmt.Errorf("data gas used %d exceeds maximum allowance %d", *header.BlobGasUsed, params.BlobTxMaxBlobGasPerBlock)
4747
}
48-
if *header.DataGasUsed%params.BlobTxDataGasPerBlob != 0 {
49-
return fmt.Errorf("data gas used %d not a multiple of data gas per blob %d", header.DataGasUsed, params.BlobTxDataGasPerBlob)
48+
if *header.BlobGasUsed%params.BlobTxBlobGasPerBlob != 0 {
49+
return fmt.Errorf("data gas used %d not a multiple of data gas per blob %d", header.BlobGasUsed, params.BlobTxBlobGasPerBlob)
5050
}
51-
// Verify the excessDataGas is correct based on the parent header
51+
// Verify the excessBlobGas is correct based on the parent header
5252
var (
53-
parentExcessDataGas uint64
54-
parentDataGasUsed uint64
53+
parentExcessBlobGas uint64
54+
parentBlobGasUsed uint64
5555
)
56-
if parent.ExcessDataGas != nil {
57-
parentExcessDataGas = *parent.ExcessDataGas
58-
parentDataGasUsed = *parent.DataGasUsed
56+
if parent.ExcessBlobGas != nil {
57+
parentExcessBlobGas = *parent.ExcessBlobGas
58+
parentBlobGasUsed = *parent.BlobGasUsed
5959
}
60-
expectedExcessDataGas := CalcExcessDataGas(parentExcessDataGas, parentDataGasUsed)
61-
if *header.ExcessDataGas != expectedExcessDataGas {
62-
return fmt.Errorf("invalid excessDataGas: have %d, want %d, parent excessDataGas %d, parent blobDataUsed %d",
63-
*header.ExcessDataGas, expectedExcessDataGas, parentExcessDataGas, parentDataGasUsed)
60+
expectedExcessBlobGas := CalcExcessBlobGas(parentExcessBlobGas, parentBlobGasUsed)
61+
if *header.ExcessBlobGas != expectedExcessBlobGas {
62+
return fmt.Errorf("invalid excessBlobGas: have %d, want %d, parent excessBlobGas %d, parent blobDataUsed %d",
63+
*header.ExcessBlobGas, expectedExcessBlobGas, parentExcessBlobGas, parentBlobGasUsed)
6464
}
6565
return nil
6666
}
6767

68-
// CalcExcessDataGas calculates the excess data gas after applying the set of
68+
// CalcExcessBlobGas calculates the excess data gas after applying the set of
6969
// blobs on top of the excess data gas.
70-
func CalcExcessDataGas(parentExcessDataGas uint64, parentDataGasUsed uint64) uint64 {
71-
excessDataGas := parentExcessDataGas + parentDataGasUsed
72-
if excessDataGas < params.BlobTxTargetDataGasPerBlock {
70+
func CalcExcessBlobGas(parentExcessBlobGas uint64, parentBlobGasUsed uint64) uint64 {
71+
excessBlobGas := parentExcessBlobGas + parentBlobGasUsed
72+
if excessBlobGas < params.BlobTxTargetBlobGasPerBlock {
7373
return 0
7474
}
75-
return excessDataGas - params.BlobTxTargetDataGasPerBlock
75+
return excessBlobGas - params.BlobTxTargetBlobGasPerBlock
7676
}
7777

7878
// CalcBlobFee calculates the blobfee from the header's excess data gas field.
79-
func CalcBlobFee(excessDataGas uint64) *big.Int {
80-
return fakeExponential(minDataGasPrice, new(big.Int).SetUint64(excessDataGas), dataGaspriceUpdateFraction)
79+
func CalcBlobFee(excessBlobGas uint64) *big.Int {
80+
return fakeExponential(minBlobGasPrice, new(big.Int).SetUint64(excessBlobGas), blobGaspriceUpdateFraction)
8181
}
8282

8383
// fakeExponential approximates factor * e ** (numerator / denominator) using

consensus/misc/eip4844/eip4844_test.go

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ import (
2424
"github.com/ethereum/go-ethereum/params"
2525
)
2626

27-
func TestCalcExcessDataGas(t *testing.T) {
27+
func TestCalcExcessBlobGas(t *testing.T) {
2828
var tests = []struct {
2929
excess uint64
3030
blobs uint64
@@ -34,23 +34,23 @@ func TestCalcExcessDataGas(t *testing.T) {
3434
// slots are below - or equal - to the target.
3535
{0, 0, 0},
3636
{0, 1, 0},
37-
{0, params.BlobTxTargetDataGasPerBlock / params.BlobTxDataGasPerBlob, 0},
37+
{0, params.BlobTxTargetBlobGasPerBlock / params.BlobTxBlobGasPerBlob, 0},
3838

39-
// If the target data gas is exceeded, the excessDataGas should increase
39+
// If the target data gas is exceeded, the excessBlobGas should increase
4040
// by however much it was overshot
41-
{0, (params.BlobTxTargetDataGasPerBlock / params.BlobTxDataGasPerBlob) + 1, params.BlobTxDataGasPerBlob},
42-
{1, (params.BlobTxTargetDataGasPerBlock / params.BlobTxDataGasPerBlob) + 1, params.BlobTxDataGasPerBlob + 1},
43-
{1, (params.BlobTxTargetDataGasPerBlock / params.BlobTxDataGasPerBlob) + 2, 2*params.BlobTxDataGasPerBlob + 1},
41+
{0, (params.BlobTxTargetBlobGasPerBlock / params.BlobTxBlobGasPerBlob) + 1, params.BlobTxBlobGasPerBlob},
42+
{1, (params.BlobTxTargetBlobGasPerBlock / params.BlobTxBlobGasPerBlob) + 1, params.BlobTxBlobGasPerBlob + 1},
43+
{1, (params.BlobTxTargetBlobGasPerBlock / params.BlobTxBlobGasPerBlob) + 2, 2*params.BlobTxBlobGasPerBlob + 1},
4444

4545
// The excess data gas should decrease by however much the target was
4646
// under-shot, capped at zero.
47-
{params.BlobTxTargetDataGasPerBlock, params.BlobTxTargetDataGasPerBlock / params.BlobTxDataGasPerBlob, params.BlobTxTargetDataGasPerBlock},
48-
{params.BlobTxTargetDataGasPerBlock, (params.BlobTxTargetDataGasPerBlock / params.BlobTxDataGasPerBlob) - 1, params.BlobTxDataGasPerBlob},
49-
{params.BlobTxTargetDataGasPerBlock, (params.BlobTxTargetDataGasPerBlock / params.BlobTxDataGasPerBlob) - 2, 0},
50-
{params.BlobTxDataGasPerBlob - 1, (params.BlobTxTargetDataGasPerBlock / params.BlobTxDataGasPerBlob) - 1, 0},
47+
{params.BlobTxTargetBlobGasPerBlock, params.BlobTxTargetBlobGasPerBlock / params.BlobTxBlobGasPerBlob, params.BlobTxTargetBlobGasPerBlock},
48+
{params.BlobTxTargetBlobGasPerBlock, (params.BlobTxTargetBlobGasPerBlock / params.BlobTxBlobGasPerBlob) - 1, params.BlobTxBlobGasPerBlob},
49+
{params.BlobTxTargetBlobGasPerBlock, (params.BlobTxTargetBlobGasPerBlock / params.BlobTxBlobGasPerBlob) - 2, 0},
50+
{params.BlobTxBlobGasPerBlob - 1, (params.BlobTxTargetBlobGasPerBlock / params.BlobTxBlobGasPerBlob) - 1, 0},
5151
}
5252
for _, tt := range tests {
53-
result := CalcExcessDataGas(tt.excess, tt.blobs*params.BlobTxDataGasPerBlob)
53+
result := CalcExcessBlobGas(tt.excess, tt.blobs*params.BlobTxBlobGasPerBlob)
5454
if result != tt.want {
5555
t.Errorf("excess data gas mismatch: have %v, want %v", result, tt.want)
5656
}
@@ -59,7 +59,7 @@ func TestCalcExcessDataGas(t *testing.T) {
5959

6060
func TestCalcBlobFee(t *testing.T) {
6161
tests := []struct {
62-
excessDataGas uint64
62+
excessBlobGas uint64
6363
blobfee int64
6464
}{
6565
{0, 1},
@@ -68,7 +68,7 @@ func TestCalcBlobFee(t *testing.T) {
6868
{10 * 1024 * 1024, 111},
6969
}
7070
for i, tt := range tests {
71-
have := CalcBlobFee(tt.excessDataGas)
71+
have := CalcBlobFee(tt.excessBlobGas)
7272
if have.Int64() != tt.blobfee {
7373
t.Errorf("test %d: blobfee mismatch: have %v want %v", i, have, tt.blobfee)
7474
}

core/block_validator.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -84,14 +84,14 @@ func (v *BlockValidator) ValidateBody(block *types.Block) error {
8484
// Blob transactions may be present after the Cancun fork.
8585
var blobs int
8686
for _, tx := range block.Transactions() {
87-
// Count the number of blobs to validate against the header's dataGasUsed
87+
// Count the number of blobs to validate against the header's blobGasUsed
8888
blobs += len(tx.BlobHashes())
8989
// The individual checks for blob validity (version-check + not empty)
9090
// happens in the state_transition check.
9191
}
92-
if header.DataGasUsed != nil {
93-
if want := *header.DataGasUsed / params.BlobTxDataGasPerBlob; uint64(blobs) != want { // div because the header is surely good vs the body might be bloated
94-
return fmt.Errorf("data gas used mismatch (header %v, calculated %v)", *header.DataGasUsed, blobs*params.BlobTxDataGasPerBlob)
92+
if header.BlobGasUsed != nil {
93+
if want := *header.BlobGasUsed / params.BlobTxBlobGasPerBlob; uint64(blobs) != want { // div because the header is surely good vs the body might be bloated
94+
return fmt.Errorf("data gas used mismatch (header %v, calculated %v)", *header.BlobGasUsed, blobs*params.BlobTxBlobGasPerBlob)
9595
}
9696
} else {
9797
if blobs > 0 {

core/blockchain.go

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2028,17 +2028,15 @@ func (bc *BlockChain) recoverAncestors(block *types.Block) (common.Hash, error)
20282028
// collectLogs collects the logs that were generated or removed during
20292029
// the processing of a block. These logs are later announced as deleted or reborn.
20302030
func (bc *BlockChain) collectLogs(b *types.Block, removed bool) []*types.Log {
2031-
var dataGasPrice *big.Int
2032-
excessDataGas := b.ExcessDataGas()
2033-
if excessDataGas != nil {
2034-
dataGasPrice = eip4844.CalcBlobFee(*excessDataGas)
2031+
var blobGasPrice *big.Int
2032+
excessBlobGas := b.ExcessBlobGas()
2033+
if excessBlobGas != nil {
2034+
blobGasPrice = eip4844.CalcBlobFee(*excessBlobGas)
20352035
}
2036-
20372036
receipts := rawdb.ReadRawReceipts(bc.db, b.Hash(), b.NumberU64())
2038-
if err := receipts.DeriveFields(bc.chainConfig, b.Hash(), b.NumberU64(), b.Time(), b.BaseFee(), dataGasPrice, b.Transactions()); err != nil {
2037+
if err := receipts.DeriveFields(bc.chainConfig, b.Hash(), b.NumberU64(), b.Time(), b.BaseFee(), blobGasPrice, b.Transactions()); err != nil {
20392038
log.Error("Failed to derive block receipts fields", "hash", b.Hash(), "number", b.NumberU64(), "err", err)
20402039
}
2041-
20422040
var logs []*types.Log
20432041
for _, receipt := range receipts {
20442042
for _, log := range receipt.Logs {

core/evm.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ func NewEVMBlockContext(header *types.Header, chain ChainContext, author *common
6666
BaseFee: baseFee,
6767
GasLimit: header.GasLimit,
6868
Random: random,
69-
ExcessDataGas: header.ExcessDataGas,
69+
ExcessBlobGas: header.ExcessBlobGas,
7070
}
7171
}
7272

core/gen_genesis.go

Lines changed: 10 additions & 10 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)