From 5a57743c4e8c8439b443dc2dbac3fbbcdf5fc6de Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C3=A9ter=20Szil=C3=A1gyi?= Date: Thu, 27 Jul 2023 14:46:25 +0300 Subject: [PATCH] all: rename dataGas to blobGas --- beacon/engine/gen_ed.go | 20 ++++----- beacon/engine/types.go | 16 +++---- consensus/beacon/consensus.go | 10 ++--- consensus/misc/eip4844/eip4844.go | 58 +++++++++++++------------- consensus/misc/eip4844/eip4844_test.go | 26 ++++++------ core/block_validator.go | 8 ++-- core/blockchain.go | 12 +++--- core/evm.go | 2 +- core/gen_genesis.go | 20 ++++----- core/genesis.go | 24 +++++------ core/rawdb/accessors_chain.go | 10 ++--- core/state_processor_test.go | 14 +++---- core/state_transition.go | 24 +++++------ core/txpool/blobpool/blobpool.go | 14 +++---- core/txpool/blobpool/blobpool_test.go | 8 ++-- core/txpool/validation.go | 4 +- core/types/block.go | 48 ++++++++++----------- core/types/gen_header_json.go | 20 ++++----- core/types/gen_header_rlp.go | 12 +++--- core/types/gen_receipt_json.go | 20 ++++----- core/types/receipt.go | 10 ++--- core/types/receipt_test.go | 16 +++---- core/types/transaction_marshalling.go | 10 ++--- core/types/tx_blob.go | 4 +- core/vm/evm.go | 2 +- eth/catalyst/api.go | 2 +- eth/downloader/queue.go | 6 +-- light/odr_util.go | 10 ++--- params/protocol_params.go | 10 ++--- tests/gen_sttransaction.go | 4 +- tests/state_test.go | 3 ++ tests/state_test_util.go | 2 +- 32 files changed, 224 insertions(+), 225 deletions(-) diff --git a/beacon/engine/gen_ed.go b/beacon/engine/gen_ed.go index 884b7160e8d79..6893d64a1626a 100644 --- a/beacon/engine/gen_ed.go +++ b/beacon/engine/gen_ed.go @@ -32,8 +32,8 @@ func (e ExecutableData) MarshalJSON() ([]byte, error) { BlockHash common.Hash `json:"blockHash" gencodec:"required"` Transactions []hexutil.Bytes `json:"transactions" gencodec:"required"` Withdrawals []*types.Withdrawal `json:"withdrawals"` - DataGasUsed *hexutil.Uint64 `json:"dataGasUsed"` - ExcessDataGas *hexutil.Uint64 `json:"excessDataGas"` + BlobGasUsed *hexutil.Uint64 `json:"blobGasUsed"` + ExcessBlobGas *hexutil.Uint64 `json:"excessBlobGas"` } var enc ExecutableData enc.ParentHash = e.ParentHash @@ -56,8 +56,8 @@ func (e ExecutableData) MarshalJSON() ([]byte, error) { } } enc.Withdrawals = e.Withdrawals - enc.DataGasUsed = (*hexutil.Uint64)(e.DataGasUsed) - enc.ExcessDataGas = (*hexutil.Uint64)(e.ExcessDataGas) + enc.BlobGasUsed = (*hexutil.Uint64)(e.BlobGasUsed) + enc.ExcessBlobGas = (*hexutil.Uint64)(e.ExcessBlobGas) return json.Marshal(&enc) } @@ -79,8 +79,8 @@ func (e *ExecutableData) UnmarshalJSON(input []byte) error { BlockHash *common.Hash `json:"blockHash" gencodec:"required"` Transactions []hexutil.Bytes `json:"transactions" gencodec:"required"` Withdrawals []*types.Withdrawal `json:"withdrawals"` - DataGasUsed *hexutil.Uint64 `json:"dataGasUsed"` - ExcessDataGas *hexutil.Uint64 `json:"excessDataGas"` + BlobGasUsed *hexutil.Uint64 `json:"blobGasUsed"` + ExcessBlobGas *hexutil.Uint64 `json:"excessBlobGas"` } var dec ExecutableData if err := json.Unmarshal(input, &dec); err != nil { @@ -148,11 +148,11 @@ func (e *ExecutableData) UnmarshalJSON(input []byte) error { if dec.Withdrawals != nil { e.Withdrawals = dec.Withdrawals } - if dec.DataGasUsed != nil { - e.DataGasUsed = (*uint64)(dec.DataGasUsed) + if dec.BlobGasUsed != nil { + e.BlobGasUsed = (*uint64)(dec.BlobGasUsed) } - if dec.ExcessDataGas != nil { - e.ExcessDataGas = (*uint64)(dec.ExcessDataGas) + if dec.ExcessBlobGas != nil { + e.ExcessBlobGas = (*uint64)(dec.ExcessBlobGas) } return nil } diff --git a/beacon/engine/types.go b/beacon/engine/types.go index d96bece8560b2..f1801edd1a93c 100644 --- a/beacon/engine/types.go +++ b/beacon/engine/types.go @@ -62,8 +62,8 @@ type ExecutableData struct { BlockHash common.Hash `json:"blockHash" gencodec:"required"` Transactions [][]byte `json:"transactions" gencodec:"required"` Withdrawals []*types.Withdrawal `json:"withdrawals"` - DataGasUsed *uint64 `json:"dataGasUsed"` - ExcessDataGas *uint64 `json:"excessDataGas"` + BlobGasUsed *uint64 `json:"blobGasUsed"` + ExcessBlobGas *uint64 `json:"excessBlobGas"` } // JSON type overrides for executableData. @@ -76,8 +76,8 @@ type executableDataMarshaling struct { ExtraData hexutil.Bytes LogsBloom hexutil.Bytes Transactions []hexutil.Bytes - DataGasUsed *hexutil.Uint64 - ExcessDataGas *hexutil.Uint64 + BlobGasUsed *hexutil.Uint64 + ExcessBlobGas *hexutil.Uint64 } //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) Extra: params.ExtraData, MixDigest: params.Random, WithdrawalsHash: withdrawalsRoot, - ExcessDataGas: params.ExcessDataGas, - DataGasUsed: params.DataGasUsed, + ExcessBlobGas: params.ExcessBlobGas, + BlobGasUsed: params.BlobGasUsed, } block := types.NewBlockWithHeader(header).WithBody(txs, nil /* uncles */).WithWithdrawals(params.Withdrawals) if block.Hash() != params.BlockHash { @@ -253,8 +253,8 @@ func BlockToExecutableData(block *types.Block, fees *big.Int, blobs []kzg4844.Bl Random: block.MixDigest(), ExtraData: block.Extra(), Withdrawals: block.Withdrawals(), - DataGasUsed: block.DataGasUsed(), - ExcessDataGas: block.ExcessDataGas(), + BlobGasUsed: block.BlobGasUsed(), + ExcessBlobGas: block.ExcessBlobGas(), } blobsBundle := BlobsBundleV1{ Commitments: make([]hexutil.Bytes, 0), diff --git a/consensus/beacon/consensus.go b/consensus/beacon/consensus.go index 65a776c03a954..58a210c16c84d 100644 --- a/consensus/beacon/consensus.go +++ b/consensus/beacon/consensus.go @@ -269,13 +269,13 @@ func (beacon *Beacon) verifyHeader(chain consensus.ChainHeaderReader, header, pa if !shanghai && header.WithdrawalsHash != nil { return fmt.Errorf("invalid withdrawalsHash: have %x, expected nil", header.WithdrawalsHash) } - // Verify the existence / non-existence of excessDataGas + // Verify the existence / non-existence of excessBlobGas cancun := chain.Config().IsCancun(header.Number, header.Time) - if !cancun && header.ExcessDataGas != nil { - return fmt.Errorf("invalid excessDataGas: have %d, expected nil", header.ExcessDataGas) + if !cancun && header.ExcessBlobGas != nil { + return fmt.Errorf("invalid excessBlobGas: have %d, expected nil", header.ExcessBlobGas) } - if !cancun && header.DataGasUsed != nil { - return fmt.Errorf("invalid dataGasUsed: have %d, expected nil", header.DataGasUsed) + if !cancun && header.BlobGasUsed != nil { + return fmt.Errorf("invalid blobGasUsed: have %d, expected nil", header.BlobGasUsed) } if cancun { if err := eip4844.VerifyEIP4844Header(parent, header); err != nil { diff --git a/consensus/misc/eip4844/eip4844.go b/consensus/misc/eip4844/eip4844.go index 2d0678dd4a1c2..6837abacbebc8 100644 --- a/consensus/misc/eip4844/eip4844.go +++ b/consensus/misc/eip4844/eip4844.go @@ -26,58 +26,58 @@ import ( ) var ( - minDataGasPrice = big.NewInt(params.BlobTxMinDataGasprice) - dataGaspriceUpdateFraction = big.NewInt(params.BlobTxDataGaspriceUpdateFraction) + minBlobGasPrice = big.NewInt(params.BlobTxMinBlobGasprice) + blobGaspriceUpdateFraction = big.NewInt(params.BlobTxBlobGaspriceUpdateFraction) ) -// VerifyEIP4844Header verifies the presence of the excessDataGas field and that -// if the current block contains no transactions, the excessDataGas is updated +// VerifyEIP4844Header verifies the presence of the excessBlobGas field and that +// if the current block contains no transactions, the excessBlobGas is updated // accordingly. func VerifyEIP4844Header(parent, header *types.Header) error { // Verify the header is not malformed - if header.ExcessDataGas == nil { - return errors.New("header is missing excessDataGas") + if header.ExcessBlobGas == nil { + return errors.New("header is missing excessBlobGas") } - if header.DataGasUsed == nil { - return errors.New("header is missing dataGasUsed") + if header.BlobGasUsed == nil { + return errors.New("header is missing blobGasUsed") } // Verify that the data gas used remains within reasonable limits. - if *header.DataGasUsed > params.BlobTxMaxDataGasPerBlock { - return fmt.Errorf("data gas used %d exceeds maximum allowance %d", *header.DataGasUsed, params.BlobTxMaxDataGasPerBlock) + if *header.BlobGasUsed > params.BlobTxMaxBlobGasPerBlock { + return fmt.Errorf("data gas used %d exceeds maximum allowance %d", *header.BlobGasUsed, params.BlobTxMaxBlobGasPerBlock) } - if *header.DataGasUsed%params.BlobTxDataGasPerBlob != 0 { - return fmt.Errorf("data gas used %d not a multiple of data gas per blob %d", header.DataGasUsed, params.BlobTxDataGasPerBlob) + if *header.BlobGasUsed%params.BlobTxBlobGasPerBlob != 0 { + return fmt.Errorf("data gas used %d not a multiple of data gas per blob %d", header.BlobGasUsed, params.BlobTxBlobGasPerBlob) } - // Verify the excessDataGas is correct based on the parent header + // Verify the excessBlobGas is correct based on the parent header var ( - parentExcessDataGas uint64 - parentDataGasUsed uint64 + parentExcessBlobGas uint64 + parentBlobGasUsed uint64 ) - if parent.ExcessDataGas != nil { - parentExcessDataGas = *parent.ExcessDataGas - parentDataGasUsed = *parent.DataGasUsed + if parent.ExcessBlobGas != nil { + parentExcessBlobGas = *parent.ExcessBlobGas + parentBlobGasUsed = *parent.BlobGasUsed } - expectedExcessDataGas := CalcExcessDataGas(parentExcessDataGas, parentDataGasUsed) - if *header.ExcessDataGas != expectedExcessDataGas { - return fmt.Errorf("invalid excessDataGas: have %d, want %d, parent excessDataGas %d, parent blobDataUsed %d", - *header.ExcessDataGas, expectedExcessDataGas, parentExcessDataGas, parentDataGasUsed) + expectedExcessBlobGas := CalcExcessBlobGas(parentExcessBlobGas, parentBlobGasUsed) + if *header.ExcessBlobGas != expectedExcessBlobGas { + return fmt.Errorf("invalid excessBlobGas: have %d, want %d, parent excessBlobGas %d, parent blobDataUsed %d", + *header.ExcessBlobGas, expectedExcessBlobGas, parentExcessBlobGas, parentBlobGasUsed) } return nil } -// CalcExcessDataGas calculates the excess data gas after applying the set of +// CalcExcessBlobGas calculates the excess data gas after applying the set of // blobs on top of the excess data gas. -func CalcExcessDataGas(parentExcessDataGas uint64, parentDataGasUsed uint64) uint64 { - excessDataGas := parentExcessDataGas + parentDataGasUsed - if excessDataGas < params.BlobTxTargetDataGasPerBlock { +func CalcExcessBlobGas(parentExcessBlobGas uint64, parentBlobGasUsed uint64) uint64 { + excessBlobGas := parentExcessBlobGas + parentBlobGasUsed + if excessBlobGas < params.BlobTxTargetBlobGasPerBlock { return 0 } - return excessDataGas - params.BlobTxTargetDataGasPerBlock + return excessBlobGas - params.BlobTxTargetBlobGasPerBlock } // CalcBlobFee calculates the blobfee from the header's excess data gas field. -func CalcBlobFee(excessDataGas uint64) *big.Int { - return fakeExponential(minDataGasPrice, new(big.Int).SetUint64(excessDataGas), dataGaspriceUpdateFraction) +func CalcBlobFee(excessBlobGas uint64) *big.Int { + return fakeExponential(minBlobGasPrice, new(big.Int).SetUint64(excessBlobGas), blobGaspriceUpdateFraction) } // fakeExponential approximates factor * e ** (numerator / denominator) using diff --git a/consensus/misc/eip4844/eip4844_test.go b/consensus/misc/eip4844/eip4844_test.go index d3f1e8702bcda..7b9af04d62f4e 100644 --- a/consensus/misc/eip4844/eip4844_test.go +++ b/consensus/misc/eip4844/eip4844_test.go @@ -24,7 +24,7 @@ import ( "github.com/ethereum/go-ethereum/params" ) -func TestCalcExcessDataGas(t *testing.T) { +func TestCalcExcessBlobGas(t *testing.T) { var tests = []struct { excess uint64 blobs uint64 @@ -34,23 +34,23 @@ func TestCalcExcessDataGas(t *testing.T) { // slots are below - or equal - to the target. {0, 0, 0}, {0, 1, 0}, - {0, params.BlobTxTargetDataGasPerBlock / params.BlobTxDataGasPerBlob, 0}, + {0, params.BlobTxTargetBlobGasPerBlock / params.BlobTxBlobGasPerBlob, 0}, - // If the target data gas is exceeded, the excessDataGas should increase + // If the target data gas is exceeded, the excessBlobGas should increase // by however much it was overshot - {0, (params.BlobTxTargetDataGasPerBlock / params.BlobTxDataGasPerBlob) + 1, params.BlobTxDataGasPerBlob}, - {1, (params.BlobTxTargetDataGasPerBlock / params.BlobTxDataGasPerBlob) + 1, params.BlobTxDataGasPerBlob + 1}, - {1, (params.BlobTxTargetDataGasPerBlock / params.BlobTxDataGasPerBlob) + 2, 2*params.BlobTxDataGasPerBlob + 1}, + {0, (params.BlobTxTargetBlobGasPerBlock / params.BlobTxBlobGasPerBlob) + 1, params.BlobTxBlobGasPerBlob}, + {1, (params.BlobTxTargetBlobGasPerBlock / params.BlobTxBlobGasPerBlob) + 1, params.BlobTxBlobGasPerBlob + 1}, + {1, (params.BlobTxTargetBlobGasPerBlock / params.BlobTxBlobGasPerBlob) + 2, 2*params.BlobTxBlobGasPerBlob + 1}, // The excess data gas should decrease by however much the target was // under-shot, capped at zero. - {params.BlobTxTargetDataGasPerBlock, params.BlobTxTargetDataGasPerBlock / params.BlobTxDataGasPerBlob, params.BlobTxTargetDataGasPerBlock}, - {params.BlobTxTargetDataGasPerBlock, (params.BlobTxTargetDataGasPerBlock / params.BlobTxDataGasPerBlob) - 1, params.BlobTxDataGasPerBlob}, - {params.BlobTxTargetDataGasPerBlock, (params.BlobTxTargetDataGasPerBlock / params.BlobTxDataGasPerBlob) - 2, 0}, - {params.BlobTxDataGasPerBlob - 1, (params.BlobTxTargetDataGasPerBlock / params.BlobTxDataGasPerBlob) - 1, 0}, + {params.BlobTxTargetBlobGasPerBlock, params.BlobTxTargetBlobGasPerBlock / params.BlobTxBlobGasPerBlob, params.BlobTxTargetBlobGasPerBlock}, + {params.BlobTxTargetBlobGasPerBlock, (params.BlobTxTargetBlobGasPerBlock / params.BlobTxBlobGasPerBlob) - 1, params.BlobTxBlobGasPerBlob}, + {params.BlobTxTargetBlobGasPerBlock, (params.BlobTxTargetBlobGasPerBlock / params.BlobTxBlobGasPerBlob) - 2, 0}, + {params.BlobTxBlobGasPerBlob - 1, (params.BlobTxTargetBlobGasPerBlock / params.BlobTxBlobGasPerBlob) - 1, 0}, } for _, tt := range tests { - result := CalcExcessDataGas(tt.excess, tt.blobs*params.BlobTxDataGasPerBlob) + result := CalcExcessBlobGas(tt.excess, tt.blobs*params.BlobTxBlobGasPerBlob) if result != tt.want { t.Errorf("excess data gas mismatch: have %v, want %v", result, tt.want) } @@ -59,7 +59,7 @@ func TestCalcExcessDataGas(t *testing.T) { func TestCalcBlobFee(t *testing.T) { tests := []struct { - excessDataGas uint64 + excessBlobGas uint64 blobfee int64 }{ {0, 1}, @@ -68,7 +68,7 @@ func TestCalcBlobFee(t *testing.T) { {10 * 1024 * 1024, 111}, } for i, tt := range tests { - have := CalcBlobFee(tt.excessDataGas) + have := CalcBlobFee(tt.excessBlobGas) if have.Int64() != tt.blobfee { t.Errorf("test %d: blobfee mismatch: have %v want %v", i, have, tt.blobfee) } diff --git a/core/block_validator.go b/core/block_validator.go index 4ea623cf47fc1..085e7ce61c3e1 100644 --- a/core/block_validator.go +++ b/core/block_validator.go @@ -84,14 +84,14 @@ func (v *BlockValidator) ValidateBody(block *types.Block) error { // Blob transactions may be present after the Cancun fork. var blobs int for _, tx := range block.Transactions() { - // Count the number of blobs to validate against the header's dataGasUsed + // Count the number of blobs to validate against the header's blobGasUsed blobs += len(tx.BlobHashes()) // The individual checks for blob validity (version-check + not empty) // happens in the state_transition check. } - if header.DataGasUsed != nil { - if want := *header.DataGasUsed / params.BlobTxDataGasPerBlob; uint64(blobs) != want { // div because the header is surely good vs the body might be bloated - return fmt.Errorf("data gas used mismatch (header %v, calculated %v)", *header.DataGasUsed, blobs*params.BlobTxDataGasPerBlob) + if header.BlobGasUsed != nil { + if want := *header.BlobGasUsed / params.BlobTxBlobGasPerBlob; uint64(blobs) != want { // div because the header is surely good vs the body might be bloated + return fmt.Errorf("data gas used mismatch (header %v, calculated %v)", *header.BlobGasUsed, blobs*params.BlobTxBlobGasPerBlob) } } else { if blobs > 0 { diff --git a/core/blockchain.go b/core/blockchain.go index 50064b38384e3..2f549806c6038 100644 --- a/core/blockchain.go +++ b/core/blockchain.go @@ -2028,17 +2028,15 @@ func (bc *BlockChain) recoverAncestors(block *types.Block) (common.Hash, error) // collectLogs collects the logs that were generated or removed during // the processing of a block. These logs are later announced as deleted or reborn. func (bc *BlockChain) collectLogs(b *types.Block, removed bool) []*types.Log { - var dataGasPrice *big.Int - excessDataGas := b.ExcessDataGas() - if excessDataGas != nil { - dataGasPrice = eip4844.CalcBlobFee(*excessDataGas) + var blobGasPrice *big.Int + excessBlobGas := b.ExcessBlobGas() + if excessBlobGas != nil { + blobGasPrice = eip4844.CalcBlobFee(*excessBlobGas) } - receipts := rawdb.ReadRawReceipts(bc.db, b.Hash(), b.NumberU64()) - if err := receipts.DeriveFields(bc.chainConfig, b.Hash(), b.NumberU64(), b.Time(), b.BaseFee(), dataGasPrice, b.Transactions()); err != nil { + if err := receipts.DeriveFields(bc.chainConfig, b.Hash(), b.NumberU64(), b.Time(), b.BaseFee(), blobGasPrice, b.Transactions()); err != nil { log.Error("Failed to derive block receipts fields", "hash", b.Hash(), "number", b.NumberU64(), "err", err) } - var logs []*types.Log for _, receipt := range receipts { for _, log := range receipt.Logs { diff --git a/core/evm.go b/core/evm.go index f4e6aa43f4271..104f2c09dc1da 100644 --- a/core/evm.go +++ b/core/evm.go @@ -66,7 +66,7 @@ func NewEVMBlockContext(header *types.Header, chain ChainContext, author *common BaseFee: baseFee, GasLimit: header.GasLimit, Random: random, - ExcessDataGas: header.ExcessDataGas, + ExcessBlobGas: header.ExcessBlobGas, } } diff --git a/core/gen_genesis.go b/core/gen_genesis.go index 9a8b279d257bf..38614252a3804 100644 --- a/core/gen_genesis.go +++ b/core/gen_genesis.go @@ -31,8 +31,8 @@ func (g Genesis) MarshalJSON() ([]byte, error) { GasUsed math.HexOrDecimal64 `json:"gasUsed"` ParentHash common.Hash `json:"parentHash"` BaseFee *math.HexOrDecimal256 `json:"baseFeePerGas"` - ExcessDataGas *math.HexOrDecimal64 `json:"excessDataGas"` - DataGasUsed *math.HexOrDecimal64 `json:"dataGasUsed"` + ExcessBlobGas *math.HexOrDecimal64 `json:"excessBlobGas"` + BlobGasUsed *math.HexOrDecimal64 `json:"blobGasUsed"` } var enc Genesis enc.Config = g.Config @@ -53,8 +53,8 @@ func (g Genesis) MarshalJSON() ([]byte, error) { enc.GasUsed = math.HexOrDecimal64(g.GasUsed) enc.ParentHash = g.ParentHash enc.BaseFee = (*math.HexOrDecimal256)(g.BaseFee) - enc.ExcessDataGas = (*math.HexOrDecimal64)(g.ExcessDataGas) - enc.DataGasUsed = (*math.HexOrDecimal64)(g.DataGasUsed) + enc.ExcessBlobGas = (*math.HexOrDecimal64)(g.ExcessBlobGas) + enc.BlobGasUsed = (*math.HexOrDecimal64)(g.BlobGasUsed) return json.Marshal(&enc) } @@ -74,8 +74,8 @@ func (g *Genesis) UnmarshalJSON(input []byte) error { GasUsed *math.HexOrDecimal64 `json:"gasUsed"` ParentHash *common.Hash `json:"parentHash"` BaseFee *math.HexOrDecimal256 `json:"baseFeePerGas"` - ExcessDataGas *math.HexOrDecimal64 `json:"excessDataGas"` - DataGasUsed *math.HexOrDecimal64 `json:"dataGasUsed"` + ExcessBlobGas *math.HexOrDecimal64 `json:"excessBlobGas"` + BlobGasUsed *math.HexOrDecimal64 `json:"blobGasUsed"` } var dec Genesis if err := json.Unmarshal(input, &dec); err != nil { @@ -126,11 +126,11 @@ func (g *Genesis) UnmarshalJSON(input []byte) error { if dec.BaseFee != nil { g.BaseFee = (*big.Int)(dec.BaseFee) } - if dec.ExcessDataGas != nil { - g.ExcessDataGas = (*uint64)(dec.ExcessDataGas) + if dec.ExcessBlobGas != nil { + g.ExcessBlobGas = (*uint64)(dec.ExcessBlobGas) } - if dec.DataGasUsed != nil { - g.DataGasUsed = (*uint64)(dec.DataGasUsed) + if dec.BlobGasUsed != nil { + g.BlobGasUsed = (*uint64)(dec.BlobGasUsed) } return nil } diff --git a/core/genesis.go b/core/genesis.go index d55c2cb67260e..33716d0b61dff 100644 --- a/core/genesis.go +++ b/core/genesis.go @@ -63,8 +63,8 @@ type Genesis struct { GasUsed uint64 `json:"gasUsed"` ParentHash common.Hash `json:"parentHash"` BaseFee *big.Int `json:"baseFeePerGas"` // EIP-1559 - ExcessDataGas *uint64 `json:"excessDataGas"` // EIP-4844 - DataGasUsed *uint64 `json:"dataGasUsed"` // EIP-4844 + ExcessBlobGas *uint64 `json:"excessBlobGas"` // EIP-4844 + BlobGasUsed *uint64 `json:"blobGasUsed"` // EIP-4844 } func ReadGenesis(db ethdb.Database) (*Genesis, error) { @@ -99,8 +99,8 @@ func ReadGenesis(db ethdb.Database) (*Genesis, error) { genesis.Mixhash = genesisHeader.MixDigest genesis.Coinbase = genesisHeader.Coinbase genesis.BaseFee = genesisHeader.BaseFee - genesis.ExcessDataGas = genesisHeader.ExcessDataGas - genesis.DataGasUsed = genesisHeader.DataGasUsed + genesis.ExcessBlobGas = genesisHeader.ExcessBlobGas + genesis.BlobGasUsed = genesisHeader.BlobGasUsed return &genesis, nil } @@ -228,8 +228,8 @@ type genesisSpecMarshaling struct { Difficulty *math.HexOrDecimal256 Alloc map[common.UnprefixedAddress]GenesisAccount BaseFee *math.HexOrDecimal256 - ExcessDataGas *math.HexOrDecimal64 - DataGasUsed *math.HexOrDecimal64 + ExcessBlobGas *math.HexOrDecimal64 + BlobGasUsed *math.HexOrDecimal64 } type genesisAccountMarshaling struct { @@ -477,13 +477,13 @@ func (g *Genesis) ToBlock() *types.Block { withdrawals = make([]*types.Withdrawal, 0) } if conf.IsCancun(num, g.Timestamp) { - head.ExcessDataGas = g.ExcessDataGas - head.DataGasUsed = g.DataGasUsed - if head.ExcessDataGas == nil { - head.ExcessDataGas = new(uint64) + head.ExcessBlobGas = g.ExcessBlobGas + head.BlobGasUsed = g.BlobGasUsed + if head.ExcessBlobGas == nil { + head.ExcessBlobGas = new(uint64) } - if head.DataGasUsed == nil { - head.DataGasUsed = new(uint64) + if head.BlobGasUsed == nil { + head.BlobGasUsed = new(uint64) } } } diff --git a/core/rawdb/accessors_chain.go b/core/rawdb/accessors_chain.go index 152f70f891161..e3f4b3f35318b 100644 --- a/core/rawdb/accessors_chain.go +++ b/core/rawdb/accessors_chain.go @@ -645,14 +645,12 @@ func ReadReceipts(db ethdb.Reader, hash common.Hash, number uint64, time uint64, } else { baseFee = header.BaseFee } - // Compute effective data gas price. - var dataGasPrice *big.Int - if header != nil && header.ExcessDataGas != nil { - dataGasPrice = eip4844.CalcBlobFee(*header.ExcessDataGas) + var blobGasPrice *big.Int + if header != nil && header.ExcessBlobGas != nil { + blobGasPrice = eip4844.CalcBlobFee(*header.ExcessBlobGas) } - - if err := receipts.DeriveFields(config, hash, number, time, baseFee, dataGasPrice, body.Transactions); err != nil { + if err := receipts.DeriveFields(config, hash, number, time, baseFee, blobGasPrice, body.Transactions); err != nil { log.Error("Failed to derive block receipts fields", "hash", hash, "number", number, "err", err) return nil } diff --git a/core/state_processor_test.go b/core/state_processor_test.go index 67fe95976c44f..b0b0db1a25d8b 100644 --- a/core/state_processor_test.go +++ b/core/state_processor_test.go @@ -402,14 +402,14 @@ func GenerateBadBlock(parent *types.Block, engine consensus.Engine, txs types.Tr header.Root = common.BytesToHash(hasher.Sum(nil)) if config.IsCancun(header.Number, header.Time) { var pExcess, pUsed = uint64(0), uint64(0) - if parent.ExcessDataGas() != nil { - pExcess = *parent.ExcessDataGas() - pUsed = *parent.DataGasUsed() + if parent.ExcessBlobGas() != nil { + pExcess = *parent.ExcessBlobGas() + pUsed = *parent.BlobGasUsed() } - excess := eip4844.CalcExcessDataGas(pExcess, pUsed) - used := uint64(nBlobs * params.BlobTxDataGasPerBlob) - header.ExcessDataGas = &excess - header.DataGasUsed = &used + excess := eip4844.CalcExcessBlobGas(pExcess, pUsed) + used := uint64(nBlobs * params.BlobTxBlobGasPerBlob) + header.ExcessBlobGas = &excess + header.BlobGasUsed = &used } // Assemble and return the final block for sealing if config.IsShanghai(header.Number, header.Time) { diff --git a/core/state_transition.go b/core/state_transition.go index da256ddcadd7c..6cfe1d9c1a06d 100644 --- a/core/state_transition.go +++ b/core/state_transition.go @@ -241,18 +241,18 @@ func (st *StateTransition) buyGas() error { balanceCheck.Add(balanceCheck, st.msg.Value) } if st.evm.ChainConfig().IsCancun(st.evm.Context.BlockNumber, st.evm.Context.Time) { - if dataGas := st.dataGasUsed(); dataGas > 0 { - if st.evm.Context.ExcessDataGas == nil { + if blobGas := st.blobGasUsed(); blobGas > 0 { + if st.evm.Context.ExcessBlobGas == nil { // programming error panic("missing field excess data gas") } - // Check that the user has enough funds to cover dataGasUsed * tx.BlobGasFeeCap - blobBalanceCheck := new(big.Int).SetUint64(dataGas) + // Check that the user has enough funds to cover blobGasUsed * tx.BlobGasFeeCap + blobBalanceCheck := new(big.Int).SetUint64(blobGas) blobBalanceCheck.Mul(blobBalanceCheck, st.msg.BlobGasFeeCap) balanceCheck.Add(balanceCheck, blobBalanceCheck) - // Pay for dataGasUsed * actual blob fee - blobFee := new(big.Int).SetUint64(dataGas) - blobFee.Mul(blobFee, eip4844.CalcBlobFee(*st.evm.Context.ExcessDataGas)) + // Pay for blobGasUsed * actual blob fee + blobFee := new(big.Int).SetUint64(blobGas) + blobFee.Mul(blobFee, eip4844.CalcBlobFee(*st.evm.Context.ExcessBlobGas)) mgval.Add(mgval, blobFee) } } @@ -331,9 +331,9 @@ func (st *StateTransition) preCheck() error { } if st.evm.ChainConfig().IsCancun(st.evm.Context.BlockNumber, st.evm.Context.Time) { - if st.dataGasUsed() > 0 { + if st.blobGasUsed() > 0 { // Check that the user is paying at least the current blob fee - blobFee := eip4844.CalcBlobFee(*st.evm.Context.ExcessDataGas) + blobFee := eip4844.CalcBlobFee(*st.evm.Context.ExcessBlobGas) if st.msg.BlobGasFeeCap.Cmp(blobFee) < 0 { return fmt.Errorf("%w: address %v have %v want %v", ErrBlobFeeCapTooLow, st.msg.From.Hex(), st.msg.BlobGasFeeCap, blobFee) } @@ -471,7 +471,7 @@ func (st *StateTransition) gasUsed() uint64 { return st.initialGas - st.gasRemaining } -// dataGasUsed returns the amount of data gas used by the message. -func (st *StateTransition) dataGasUsed() uint64 { - return uint64(len(st.msg.BlobHashes) * params.BlobTxDataGasPerBlob) +// blobGasUsed returns the amount of data gas used by the message. +func (st *StateTransition) blobGasUsed() uint64 { + return uint64(len(st.msg.BlobHashes) * params.BlobTxBlobGasPerBlob) } diff --git a/core/txpool/blobpool/blobpool.go b/core/txpool/blobpool/blobpool.go index 3f34e3925f565..07e3e3ff986da 100644 --- a/core/txpool/blobpool/blobpool.go +++ b/core/txpool/blobpool/blobpool.go @@ -53,7 +53,7 @@ const ( // maxBlobsPerTransaction is the maximum number of blobs a single transaction // is allowed to contain. Whilst the spec states it's unlimited, the block // data slots are protocol bound, which implicitly also limit this. - maxBlobsPerTransaction = params.BlobTxMaxDataGasPerBlock / params.BlobTxDataGasPerBlob + maxBlobsPerTransaction = params.BlobTxMaxBlobGasPerBlock / params.BlobTxBlobGasPerBlob // txAvgSize is an approximate byte size of a transaction metadata to avoid // tiny overflows causing all txs to move a shelf higher, wasting disk space. @@ -400,10 +400,10 @@ func (p *BlobPool) Init(gasTip *big.Int, head *types.Header, reserve txpool.Addr } var ( basefee = uint256.MustFromBig(misc.CalcBaseFee(p.chain.Config(), p.head)) - blobfee = uint256.MustFromBig(big.NewInt(params.BlobTxMinDataGasprice)) + blobfee = uint256.MustFromBig(big.NewInt(params.BlobTxMinBlobGasprice)) ) - if p.head.ExcessDataGas != nil { - blobfee = uint256.MustFromBig(eip4844.CalcBlobFee(*p.head.ExcessDataGas)) + if p.head.ExcessBlobGas != nil { + blobfee = uint256.MustFromBig(eip4844.CalcBlobFee(*p.head.ExcessBlobGas)) } p.evict = newPriceHeap(basefee, blobfee, &p.index) @@ -773,10 +773,10 @@ func (p *BlobPool) Reset(oldHead, newHead *types.Header) { // Reset the price heap for the new set of basefee/blobfee pairs var ( basefee = uint256.MustFromBig(misc.CalcBaseFee(p.chain.Config(), newHead)) - blobfee = uint256.MustFromBig(big.NewInt(params.BlobTxMinDataGasprice)) + blobfee = uint256.MustFromBig(big.NewInt(params.BlobTxMinBlobGasprice)) ) - if newHead.ExcessDataGas != nil { - blobfee = uint256.MustFromBig(eip4844.CalcBlobFee(*newHead.ExcessDataGas)) + if newHead.ExcessBlobGas != nil { + blobfee = uint256.MustFromBig(eip4844.CalcBlobFee(*newHead.ExcessBlobGas)) } p.evict.reinit(basefee, blobfee, false) diff --git a/core/txpool/blobpool/blobpool_test.go b/core/txpool/blobpool/blobpool_test.go index d1980b0423516..343a4642e9f51 100644 --- a/core/txpool/blobpool/blobpool_test.go +++ b/core/txpool/blobpool/blobpool_test.go @@ -137,14 +137,14 @@ func (bc *testBlockChain) CurrentBlock() *types.Header { lo = mid } } - excessDataGas := lo.Uint64() + excessBlobGas := lo.Uint64() return &types.Header{ Number: blockNumber, Time: blockTime, GasLimit: gasLimit, BaseFee: baseFee, - ExcessDataGas: &excessDataGas, + ExcessBlobGas: &excessBlobGas, } } @@ -523,7 +523,7 @@ func TestOpenDrops(t *testing.T) { chain := &testBlockChain{ config: testChainConfig, basefee: uint256.NewInt(params.InitialBaseFee), - blobfee: uint256.NewInt(params.BlobTxMinDataGasprice), + blobfee: uint256.NewInt(params.BlobTxMinBlobGasprice), statedb: statedb, } pool := New(Config{Datadir: storage}, chain) @@ -638,7 +638,7 @@ func TestOpenIndex(t *testing.T) { chain := &testBlockChain{ config: testChainConfig, basefee: uint256.NewInt(params.InitialBaseFee), - blobfee: uint256.NewInt(params.BlobTxMinDataGasprice), + blobfee: uint256.NewInt(params.BlobTxMinBlobGasprice), statedb: statedb, } pool := New(Config{Datadir: storage}, chain) diff --git a/core/txpool/validation.go b/core/txpool/validation.go index 67c39a99396f9..e1c0f314c789e 100644 --- a/core/txpool/validation.go +++ b/core/txpool/validation.go @@ -116,8 +116,8 @@ func ValidateTransaction(tx *types.Transaction, blobs []kzg4844.Blob, commits [] if len(hashes) == 0 { return fmt.Errorf("blobless blob transaction") } - if len(hashes) > params.BlobTxMaxDataGasPerBlock/params.BlobTxDataGasPerBlob { - return fmt.Errorf("too many blobs in transaction: have %d, permitted %d", len(hashes), params.BlobTxMaxDataGasPerBlock/params.BlobTxDataGasPerBlob) + if len(hashes) > params.BlobTxMaxBlobGasPerBlock/params.BlobTxBlobGasPerBlob { + return fmt.Errorf("too many blobs in transaction: have %d, permitted %d", len(hashes), params.BlobTxMaxBlobGasPerBlock/params.BlobTxBlobGasPerBlob) } if len(blobs) != len(hashes) { return fmt.Errorf("invalid number of %d blobs compared to %d blob hashes", len(blobs), len(hashes)) diff --git a/core/types/block.go b/core/types/block.go index b8478e5a1086a..c0373abb15e48 100644 --- a/core/types/block.go +++ b/core/types/block.go @@ -85,11 +85,11 @@ type Header struct { // WithdrawalsHash was added by EIP-4895 and is ignored in legacy headers. WithdrawalsHash *common.Hash `json:"withdrawalsRoot" rlp:"optional"` - // ExcessDataGas was added by EIP-4844 and is ignored in legacy headers. - ExcessDataGas *uint64 `json:"excessDataGas" rlp:"optional"` + // ExcessBlobGas was added by EIP-4844 and is ignored in legacy headers. + ExcessBlobGas *uint64 `json:"excessBlobGas" rlp:"optional"` - // DataGasUsed was added by EIP-4844 and is ignored in legacy headers. - DataGasUsed *uint64 `json:"dataGasUsed" rlp:"optional"` + // BlobGasUsed was added by EIP-4844 and is ignored in legacy headers. + BlobGasUsed *uint64 `json:"blobGasUsed" rlp:"optional"` } // field type overrides for gencodec @@ -102,8 +102,8 @@ type headerMarshaling struct { Extra hexutil.Bytes BaseFee *hexutil.Big Hash common.Hash `json:"hash"` // adds call to Hash() in MarshalJSON - ExcessDataGas *hexutil.Uint64 - DataGasUsed *hexutil.Uint64 + ExcessBlobGas *hexutil.Uint64 + BlobGasUsed *hexutil.Uint64 } // Hash returns the block hash of the header, which is simply the keccak256 hash of its @@ -284,13 +284,13 @@ func CopyHeader(h *Header) *Header { cpy.WithdrawalsHash = new(common.Hash) *cpy.WithdrawalsHash = *h.WithdrawalsHash } - if h.ExcessDataGas != nil { - cpy.ExcessDataGas = new(uint64) - *cpy.ExcessDataGas = *h.ExcessDataGas + if h.ExcessBlobGas != nil { + cpy.ExcessBlobGas = new(uint64) + *cpy.ExcessBlobGas = *h.ExcessBlobGas } - if h.DataGasUsed != nil { - cpy.DataGasUsed = new(uint64) - *cpy.DataGasUsed = *h.DataGasUsed + if h.BlobGasUsed != nil { + cpy.BlobGasUsed = new(uint64) + *cpy.BlobGasUsed = *h.BlobGasUsed } return &cpy } @@ -360,22 +360,22 @@ func (b *Block) Withdrawals() Withdrawals { return b.withdrawals } -func (b *Block) ExcessDataGas() *uint64 { - var excessDataGas *uint64 - if b.header.ExcessDataGas != nil { - excessDataGas = new(uint64) - *excessDataGas = *b.header.ExcessDataGas +func (b *Block) ExcessBlobGas() *uint64 { + var excessBlobGas *uint64 + if b.header.ExcessBlobGas != nil { + excessBlobGas = new(uint64) + *excessBlobGas = *b.header.ExcessBlobGas } - return excessDataGas + return excessBlobGas } -func (b *Block) DataGasUsed() *uint64 { - var dataGasUsed *uint64 - if b.header.DataGasUsed != nil { - dataGasUsed = new(uint64) - *dataGasUsed = *b.header.DataGasUsed +func (b *Block) BlobGasUsed() *uint64 { + var blobGasUsed *uint64 + if b.header.BlobGasUsed != nil { + blobGasUsed = new(uint64) + *blobGasUsed = *b.header.BlobGasUsed } - return dataGasUsed + return blobGasUsed } func (b *Block) Header() *Header { return CopyHeader(b.header) } diff --git a/core/types/gen_header_json.go b/core/types/gen_header_json.go index fe246d54ecd81..12a4d1bb7b430 100644 --- a/core/types/gen_header_json.go +++ b/core/types/gen_header_json.go @@ -33,8 +33,8 @@ func (h Header) MarshalJSON() ([]byte, error) { Nonce BlockNonce `json:"nonce"` BaseFee *hexutil.Big `json:"baseFeePerGas" rlp:"optional"` WithdrawalsHash *common.Hash `json:"withdrawalsRoot" rlp:"optional"` - ExcessDataGas *hexutil.Uint64 `json:"excessDataGas" rlp:"optional"` - DataGasUsed *hexutil.Uint64 `json:"dataGasUsed" rlp:"optional"` + ExcessBlobGas *hexutil.Uint64 `json:"excessBlobGas" rlp:"optional"` + BlobGasUsed *hexutil.Uint64 `json:"blobGasUsed" rlp:"optional"` Hash common.Hash `json:"hash"` } var enc Header @@ -55,8 +55,8 @@ func (h Header) MarshalJSON() ([]byte, error) { enc.Nonce = h.Nonce enc.BaseFee = (*hexutil.Big)(h.BaseFee) enc.WithdrawalsHash = h.WithdrawalsHash - enc.ExcessDataGas = (*hexutil.Uint64)(h.ExcessDataGas) - enc.DataGasUsed = (*hexutil.Uint64)(h.DataGasUsed) + enc.ExcessBlobGas = (*hexutil.Uint64)(h.ExcessBlobGas) + enc.BlobGasUsed = (*hexutil.Uint64)(h.BlobGasUsed) enc.Hash = h.Hash() return json.Marshal(&enc) } @@ -81,8 +81,8 @@ func (h *Header) UnmarshalJSON(input []byte) error { Nonce *BlockNonce `json:"nonce"` BaseFee *hexutil.Big `json:"baseFeePerGas" rlp:"optional"` WithdrawalsHash *common.Hash `json:"withdrawalsRoot" rlp:"optional"` - ExcessDataGas *hexutil.Uint64 `json:"excessDataGas" rlp:"optional"` - DataGasUsed *hexutil.Uint64 `json:"dataGasUsed" rlp:"optional"` + ExcessBlobGas *hexutil.Uint64 `json:"excessBlobGas" rlp:"optional"` + BlobGasUsed *hexutil.Uint64 `json:"blobGasUsed" rlp:"optional"` } var dec Header if err := json.Unmarshal(input, &dec); err != nil { @@ -151,11 +151,11 @@ func (h *Header) UnmarshalJSON(input []byte) error { if dec.WithdrawalsHash != nil { h.WithdrawalsHash = dec.WithdrawalsHash } - if dec.ExcessDataGas != nil { - h.ExcessDataGas = (*uint64)(dec.ExcessDataGas) + if dec.ExcessBlobGas != nil { + h.ExcessBlobGas = (*uint64)(dec.ExcessBlobGas) } - if dec.DataGasUsed != nil { - h.DataGasUsed = (*uint64)(dec.DataGasUsed) + if dec.BlobGasUsed != nil { + h.BlobGasUsed = (*uint64)(dec.BlobGasUsed) } return nil } diff --git a/core/types/gen_header_rlp.go b/core/types/gen_header_rlp.go index f488931f1fb00..efa92c43af59f 100644 --- a/core/types/gen_header_rlp.go +++ b/core/types/gen_header_rlp.go @@ -42,8 +42,8 @@ func (obj *Header) EncodeRLP(_w io.Writer) error { w.WriteBytes(obj.Nonce[:]) _tmp1 := obj.BaseFee != nil _tmp2 := obj.WithdrawalsHash != nil - _tmp3 := obj.ExcessDataGas != nil - _tmp4 := obj.DataGasUsed != nil + _tmp3 := obj.ExcessBlobGas != nil + _tmp4 := obj.BlobGasUsed != nil if _tmp1 || _tmp2 || _tmp3 || _tmp4 { if obj.BaseFee == nil { w.Write(rlp.EmptyString) @@ -62,17 +62,17 @@ func (obj *Header) EncodeRLP(_w io.Writer) error { } } if _tmp3 || _tmp4 { - if obj.ExcessDataGas == nil { + if obj.ExcessBlobGas == nil { w.Write([]byte{0x80}) } else { - w.WriteUint64((*obj.ExcessDataGas)) + w.WriteUint64((*obj.ExcessBlobGas)) } } if _tmp4 { - if obj.DataGasUsed == nil { + if obj.BlobGasUsed == nil { w.Write([]byte{0x80}) } else { - w.WriteUint64((*obj.DataGasUsed)) + w.WriteUint64((*obj.BlobGasUsed)) } } w.ListEnd(_tmp0) diff --git a/core/types/gen_receipt_json.go b/core/types/gen_receipt_json.go index b7949cc78fee0..a2eca9bbc10d5 100644 --- a/core/types/gen_receipt_json.go +++ b/core/types/gen_receipt_json.go @@ -26,8 +26,8 @@ func (r Receipt) MarshalJSON() ([]byte, error) { ContractAddress common.Address `json:"contractAddress"` GasUsed hexutil.Uint64 `json:"gasUsed" gencodec:"required"` EffectiveGasPrice *hexutil.Big `json:"effectiveGasPrice"` - DataGasUsed uint64 `json:"dataGasUsed,omitempty"` - DataGasPrice *big.Int `json:"dataGasPrice,omitempty"` + BlobGasUsed uint64 `json:"blobGasUsed,omitempty"` + BlobGasPrice *big.Int `json:"blobGasPrice,omitempty"` BlockHash common.Hash `json:"blockHash,omitempty"` BlockNumber *hexutil.Big `json:"blockNumber,omitempty"` TransactionIndex hexutil.Uint `json:"transactionIndex"` @@ -43,8 +43,8 @@ func (r Receipt) MarshalJSON() ([]byte, error) { enc.ContractAddress = r.ContractAddress enc.GasUsed = hexutil.Uint64(r.GasUsed) enc.EffectiveGasPrice = (*hexutil.Big)(r.EffectiveGasPrice) - enc.DataGasUsed = r.DataGasUsed - enc.DataGasPrice = r.DataGasPrice + enc.BlobGasUsed = r.BlobGasUsed + enc.BlobGasPrice = r.BlobGasPrice enc.BlockHash = r.BlockHash enc.BlockNumber = (*hexutil.Big)(r.BlockNumber) enc.TransactionIndex = hexutil.Uint(r.TransactionIndex) @@ -64,8 +64,8 @@ func (r *Receipt) UnmarshalJSON(input []byte) error { ContractAddress *common.Address `json:"contractAddress"` GasUsed *hexutil.Uint64 `json:"gasUsed" gencodec:"required"` EffectiveGasPrice *hexutil.Big `json:"effectiveGasPrice"` - DataGasUsed *uint64 `json:"dataGasUsed,omitempty"` - DataGasPrice *big.Int `json:"dataGasPrice,omitempty"` + BlobGasUsed *uint64 `json:"blobGasUsed,omitempty"` + BlobGasPrice *big.Int `json:"blobGasPrice,omitempty"` BlockHash *common.Hash `json:"blockHash,omitempty"` BlockNumber *hexutil.Big `json:"blockNumber,omitempty"` TransactionIndex *hexutil.Uint `json:"transactionIndex"` @@ -109,11 +109,11 @@ func (r *Receipt) UnmarshalJSON(input []byte) error { if dec.EffectiveGasPrice != nil { r.EffectiveGasPrice = (*big.Int)(dec.EffectiveGasPrice) } - if dec.DataGasUsed != nil { - r.DataGasUsed = *dec.DataGasUsed + if dec.BlobGasUsed != nil { + r.BlobGasUsed = *dec.BlobGasUsed } - if dec.DataGasPrice != nil { - r.DataGasPrice = dec.DataGasPrice + if dec.BlobGasPrice != nil { + r.BlobGasPrice = dec.BlobGasPrice } if dec.BlockHash != nil { r.BlockHash = *dec.BlockHash diff --git a/core/types/receipt.go b/core/types/receipt.go index 2428aeec88a89..831a07bf1d4c5 100644 --- a/core/types/receipt.go +++ b/core/types/receipt.go @@ -63,8 +63,8 @@ type Receipt struct { ContractAddress common.Address `json:"contractAddress"` GasUsed uint64 `json:"gasUsed" gencodec:"required"` EffectiveGasPrice *big.Int `json:"effectiveGasPrice"` // required, but tag omitted for backwards compatibility - DataGasUsed uint64 `json:"dataGasUsed,omitempty"` - DataGasPrice *big.Int `json:"dataGasPrice,omitempty"` + BlobGasUsed uint64 `json:"blobGasUsed,omitempty"` + BlobGasPrice *big.Int `json:"blobGasPrice,omitempty"` // Inclusion information: These fields provide information about the inclusion of the // transaction corresponding to this receipt. @@ -315,7 +315,7 @@ func (rs Receipts) EncodeIndex(i int, w *bytes.Buffer) { // DeriveFields fills the receipts with their computed fields based on consensus // data and contextual infos like containing block and transactions. -func (rs Receipts) DeriveFields(config *params.ChainConfig, hash common.Hash, number uint64, time uint64, baseFee *big.Int, dataGasPrice *big.Int, txs []*Transaction) error { +func (rs Receipts) DeriveFields(config *params.ChainConfig, hash common.Hash, number uint64, time uint64, baseFee *big.Int, blobGasPrice *big.Int, txs []*Transaction) error { signer := MakeSigner(config, new(big.Int).SetUint64(number), time) logIndex := uint(0) @@ -330,8 +330,8 @@ func (rs Receipts) DeriveFields(config *params.ChainConfig, hash common.Hash, nu // EIP-4844 blob transaction fields if txs[i].Type() == BlobTxType { - rs[i].DataGasUsed = txs[i].BlobGas() - rs[i].DataGasPrice = dataGasPrice + rs[i].BlobGasUsed = txs[i].BlobGas() + rs[i].BlobGasPrice = blobGasPrice } // block location fields diff --git a/core/types/receipt_test.go b/core/types/receipt_test.go index f779cd8f4589c..a7b26444712fe 100644 --- a/core/types/receipt_test.go +++ b/core/types/receipt_test.go @@ -272,8 +272,8 @@ var ( TxHash: txs[5].Hash(), GasUsed: 6, EffectiveGasPrice: big.NewInt(1066), - DataGasUsed: params.BlobTxDataGasPerBlob, - DataGasPrice: big.NewInt(920), + BlobGasUsed: params.BlobTxBlobGasPerBlob, + BlobGasPrice: big.NewInt(920), BlockHash: blockHash, BlockNumber: blockNumber, TransactionIndex: 5, @@ -287,8 +287,8 @@ var ( TxHash: txs[6].Hash(), GasUsed: 7, EffectiveGasPrice: big.NewInt(1077), - DataGasUsed: 3 * params.BlobTxDataGasPerBlob, - DataGasPrice: big.NewInt(920), + BlobGasUsed: 3 * params.BlobTxBlobGasPerBlob, + BlobGasPrice: big.NewInt(920), BlockHash: blockHash, BlockNumber: blockNumber, TransactionIndex: 6, @@ -309,9 +309,9 @@ func TestDecodeEmptyTypedReceipt(t *testing.T) { func TestDeriveFields(t *testing.T) { // Re-derive receipts. basefee := big.NewInt(1000) - dataGasPrice := big.NewInt(920) + blobGasPrice := big.NewInt(920) derivedReceipts := clearComputedFieldsOnReceipts(receipts) - err := Receipts(derivedReceipts).DeriveFields(params.TestChainConfig, blockHash, blockNumber.Uint64(), blockTime, basefee, dataGasPrice, txs) + err := Receipts(derivedReceipts).DeriveFields(params.TestChainConfig, blockHash, blockNumber.Uint64(), blockTime, basefee, blobGasPrice, txs) if err != nil { t.Fatalf("DeriveFields(...) = %v, want ", err) } @@ -509,8 +509,8 @@ func clearComputedFieldsOnReceipt(receipt *Receipt) *Receipt { cpy.GasUsed = 0xffffffff cpy.Logs = clearComputedFieldsOnLogs(receipt.Logs) cpy.EffectiveGasPrice = big.NewInt(0) - cpy.DataGasUsed = 0 - cpy.DataGasPrice = nil + cpy.BlobGasUsed = 0 + cpy.BlobGasPrice = nil return &cpy } diff --git a/core/types/transaction_marshalling.go b/core/types/transaction_marshalling.go index 8e3db617703a5..a29ec2f6e611f 100644 --- a/core/types/transaction_marshalling.go +++ b/core/types/transaction_marshalling.go @@ -37,7 +37,7 @@ type txJSON struct { GasPrice *hexutil.Big `json:"gasPrice"` MaxPriorityFeePerGas *hexutil.Big `json:"maxPriorityFeePerGas"` MaxFeePerGas *hexutil.Big `json:"maxFeePerGas"` - MaxFeePerDataGas *hexutil.Big `json:"maxFeePerDataGas,omitempty"` + MaxFeePerBlobGas *hexutil.Big `json:"maxFeePerBlobGas,omitempty"` Value *hexutil.Big `json:"value"` Input *hexutil.Bytes `json:"input"` AccessList *AccessList `json:"accessList,omitempty"` @@ -106,7 +106,7 @@ func (tx *Transaction) MarshalJSON() ([]byte, error) { enc.Gas = (*hexutil.Uint64)(&itx.Gas) enc.MaxFeePerGas = (*hexutil.Big)(itx.GasFeeCap.ToBig()) enc.MaxPriorityFeePerGas = (*hexutil.Big)(itx.GasTipCap.ToBig()) - enc.MaxFeePerDataGas = (*hexutil.Big)(itx.BlobFeeCap.ToBig()) + enc.MaxFeePerBlobGas = (*hexutil.Big)(itx.BlobFeeCap.ToBig()) enc.Value = (*hexutil.Big)(itx.Value.ToBig()) enc.Input = (*hexutil.Bytes)(&itx.Data) enc.AccessList = &itx.AccessList @@ -309,10 +309,10 @@ func (tx *Transaction) UnmarshalJSON(input []byte) error { return errors.New("missing required field 'maxFeePerGas' for txdata") } itx.GasFeeCap = uint256.MustFromBig((*big.Int)(dec.MaxFeePerGas)) - if dec.MaxFeePerDataGas == nil { - return errors.New("missing required field 'maxFeePerDataGas' for txdata") + if dec.MaxFeePerBlobGas == nil { + return errors.New("missing required field 'maxFeePerBlobGas' for txdata") } - itx.BlobFeeCap = uint256.MustFromBig((*big.Int)(dec.MaxFeePerDataGas)) + itx.BlobFeeCap = uint256.MustFromBig((*big.Int)(dec.MaxFeePerBlobGas)) if dec.Value == nil { return errors.New("missing required field 'value' in transaction") } diff --git a/core/types/tx_blob.go b/core/types/tx_blob.go index 34c01ee014c3a..a08121bf1416a 100644 --- a/core/types/tx_blob.go +++ b/core/types/tx_blob.go @@ -35,7 +35,7 @@ type BlobTx struct { Value *uint256.Int Data []byte AccessList AccessList - BlobFeeCap *uint256.Int // a.k.a. maxFeePerDataGas + BlobFeeCap *uint256.Int // a.k.a. maxFeePerBlobGas BlobHashes []common.Hash // Signature values @@ -105,7 +105,7 @@ func (tx *BlobTx) gasPrice() *big.Int { return tx.GasFeeCap.ToBig() } func (tx *BlobTx) value() *big.Int { return tx.Value.ToBig() } func (tx *BlobTx) nonce() uint64 { return tx.Nonce } func (tx *BlobTx) to() *common.Address { tmp := tx.To; return &tmp } -func (tx *BlobTx) blobGas() uint64 { return params.BlobTxDataGasPerBlob * uint64(len(tx.BlobHashes)) } +func (tx *BlobTx) blobGas() uint64 { return params.BlobTxBlobGasPerBlob * uint64(len(tx.BlobHashes)) } func (tx *BlobTx) blobGasFeeCap() *big.Int { return tx.BlobFeeCap.ToBig() } func (tx *BlobTx) blobHashes() []common.Hash { return tx.BlobHashes } diff --git a/core/vm/evm.go b/core/vm/evm.go index 54395136a4546..40e2f3554f466 100644 --- a/core/vm/evm.go +++ b/core/vm/evm.go @@ -74,7 +74,7 @@ type BlockContext struct { Difficulty *big.Int // Provides information for DIFFICULTY BaseFee *big.Int // Provides information for BASEFEE Random *common.Hash // Provides information for PREVRANDAO - ExcessDataGas *uint64 // ExcessDataGas field in the header, needed to compute the data + ExcessBlobGas *uint64 // ExcessBlobGas field in the header, needed to compute the data } // TxContext provides the EVM with information about a transaction. diff --git a/eth/catalyst/api.go b/eth/catalyst/api.go index 2e3a236e00bc1..eb58c81b4ed79 100644 --- a/eth/catalyst/api.go +++ b/eth/catalyst/api.go @@ -450,7 +450,7 @@ func (api *ConsensusAPI) NewPayloadV3(params engine.ExecutableData, versionedHas return engine.PayloadStatusV1{Status: engine.INVALID}, engine.InvalidParams.With(errors.New("newPayloadV3 called pre-cancun")) } - if params.ExcessDataGas == nil { + if params.ExcessBlobGas == nil { return engine.PayloadStatusV1{Status: engine.INVALID}, engine.InvalidParams.With(fmt.Errorf("nil excessDataGas post-cancun")) } var hashes []common.Hash diff --git a/eth/downloader/queue.go b/eth/downloader/queue.go index 8c82d7f072d0d..c1df3b4e66b0b 100644 --- a/eth/downloader/queue.go +++ b/eth/downloader/queue.go @@ -801,7 +801,7 @@ func (q *queue) DeliverBodies(id string, txLists [][]*types.Transaction, txListH // and zero before the Cancun hardfork var blobs int for _, tx := range txLists[index] { - // Count the number of blobs to validate against the header's dataGasUsed + // Count the number of blobs to validate against the header's blobGasUsed blobs += len(tx.BlobHashes()) // Validate the data blobs individually too @@ -816,8 +816,8 @@ func (q *queue) DeliverBodies(id string, txLists [][]*types.Transaction, txListH } } } - if header.DataGasUsed != nil { - if want := *header.DataGasUsed / params.BlobTxDataGasPerBlob; uint64(blobs) != want { // div because the header is surely good vs the body might be bloated + if header.BlobGasUsed != nil { + if want := *header.BlobGasUsed / params.BlobTxBlobGasPerBlob; uint64(blobs) != want { // div because the header is surely good vs the body might be bloated return errInvalidBody } } else { diff --git a/light/odr_util.go b/light/odr_util.go index 60894588244f7..02379ce5fff63 100644 --- a/light/odr_util.go +++ b/light/odr_util.go @@ -176,13 +176,13 @@ func GetBlockReceipts(ctx context.Context, odr OdrBackend, hash common.Hash, num genesis := rawdb.ReadCanonicalHash(odr.Database(), 0) config := rawdb.ReadChainConfig(odr.Database(), genesis) - var dataGasPrice *big.Int - excessDataGas := block.ExcessDataGas() - if excessDataGas != nil { - dataGasPrice = eip4844.CalcBlobFee(*excessDataGas) + var blobGasPrice *big.Int + excessBlobGas := block.ExcessBlobGas() + if excessBlobGas != nil { + blobGasPrice = eip4844.CalcBlobFee(*excessBlobGas) } - if err := receipts.DeriveFields(config, block.Hash(), block.NumberU64(), block.Time(), block.BaseFee(), dataGasPrice, block.Transactions()); err != nil { + if err := receipts.DeriveFields(config, block.Hash(), block.NumberU64(), block.Time(), block.BaseFee(), blobGasPrice, block.Transactions()); err != nil { return nil, err } rawdb.WriteReceipts(odr.Database(), hash, number, receipts) diff --git a/params/protocol_params.go b/params/protocol_params.go index 9a0b8115b13c7..b5c57789be2dc 100644 --- a/params/protocol_params.go +++ b/params/protocol_params.go @@ -163,11 +163,11 @@ const ( BlobTxBytesPerFieldElement = 32 // Size in bytes of a field element BlobTxFieldElementsPerBlob = 4096 // Number of field elements stored in a single data blob BlobTxHashVersion = 0x01 // Version byte of the commitment hash - BlobTxMaxDataGasPerBlock = 1 << 19 // Maximum consumable data gas for data blobs per block - BlobTxTargetDataGasPerBlock = 1 << 18 // Target consumable data gas for data blobs per block (for 1559-like pricing) - BlobTxDataGasPerBlob = 1 << 17 // Gas consumption of a single data blob (== blob byte size) - BlobTxMinDataGasprice = 1 // Minimum gas price for data blobs - BlobTxDataGaspriceUpdateFraction = 2225652 // Controls the maximum rate of change for data gas price + BlobTxMaxBlobGasPerBlock = 1 << 19 // Maximum consumable data gas for data blobs per block + BlobTxTargetBlobGasPerBlock = 1 << 18 // Target consumable data gas for data blobs per block (for 1559-like pricing) + BlobTxBlobGasPerBlob = 1 << 17 // Gas consumption of a single data blob (== blob byte size) + BlobTxMinBlobGasprice = 1 // Minimum gas price for data blobs + BlobTxBlobGaspriceUpdateFraction = 2225652 // Controls the maximum rate of change for data gas price BlobTxPointEvaluationPrecompileGas = 50000 // Gas price for the point evaluation precompile. ) diff --git a/tests/gen_sttransaction.go b/tests/gen_sttransaction.go index 11278833157d8..f47da494fa812 100644 --- a/tests/gen_sttransaction.go +++ b/tests/gen_sttransaction.go @@ -28,7 +28,7 @@ func (s stTransaction) MarshalJSON() ([]byte, error) { Value []string `json:"value"` PrivateKey hexutil.Bytes `json:"secretKey"` BlobVersionedHashes []common.Hash `json:"blobVersionedHashes,omitempty"` - BlobGasFeeCap *math.HexOrDecimal256 `json:"maxFeePerDataGas,omitempty"` + BlobGasFeeCap *math.HexOrDecimal256 `json:"maxFeePerBlobGas,omitempty"` } var enc stTransaction enc.GasPrice = (*math.HexOrDecimal256)(s.GasPrice) @@ -65,7 +65,7 @@ func (s *stTransaction) UnmarshalJSON(input []byte) error { Value []string `json:"value"` PrivateKey *hexutil.Bytes `json:"secretKey"` BlobVersionedHashes []common.Hash `json:"blobVersionedHashes,omitempty"` - BlobGasFeeCap *math.HexOrDecimal256 `json:"maxFeePerDataGas,omitempty"` + BlobGasFeeCap *math.HexOrDecimal256 `json:"maxFeePerBlobGas,omitempty"` } var dec stTransaction if err := json.Unmarshal(input, &dec); err != nil { diff --git a/tests/state_test.go b/tests/state_test.go index 61ce8aab39568..782f1b0b4c294 100644 --- a/tests/state_test.go +++ b/tests/state_test.go @@ -58,6 +58,9 @@ func TestState(t *testing.T) { // EOF is not part of cancun st.skipLoad(`^stEOF/`) + // EIP-4844 tests need to be regenerated due to the data-to-blob rename + st.skipLoad(`^stEIP4844-blobtransactions/`) + // Expected failures: // These EIP-4844 tests need to be regenerated. st.fails(`stEIP4844-blobtransactions/opcodeBlobhashOutOfRange.json`, "test has incorrect state root") diff --git a/tests/state_test_util.go b/tests/state_test_util.go index 721fe8f5c889c..42f0c662ee42e 100644 --- a/tests/state_test_util.go +++ b/tests/state_test_util.go @@ -114,7 +114,7 @@ type stTransaction struct { Value []string `json:"value"` PrivateKey []byte `json:"secretKey"` BlobVersionedHashes []common.Hash `json:"blobVersionedHashes,omitempty"` - BlobGasFeeCap *big.Int `json:"maxFeePerDataGas,omitempty"` + BlobGasFeeCap *big.Int `json:"maxFeePerBlobGas,omitempty"` } type stTransactionMarshaling struct {