From 3ca92f70e5207901fcd6ee5e7e227cd90a6b8c4e Mon Sep 17 00:00:00 2001 From: Delweng Date: Tue, 1 Aug 2023 15:07:25 +0800 Subject: [PATCH] all: replace data gas to blob gas in comments (#27825) * eth: excessDataGas -> excessBlobGas * consensus: data gas -> blob gas * core: data gas -> blob gas * params: data gas -> blob gas --- consensus/misc/eip4844/eip4844.go | 12 ++++++------ consensus/misc/eip4844/eip4844_test.go | 8 ++++---- core/block_validator.go | 2 +- core/error.go | 4 ++-- core/rawdb/accessors_chain.go | 2 +- core/state_transition.go | 2 +- core/txpool/blobpool/blobpool.go | 2 +- core/txpool/blobpool/blobpool_test.go | 2 +- core/types/transaction.go | 4 ++-- eth/catalyst/api.go | 2 +- params/protocol_params.go | 6 +++--- 11 files changed, 23 insertions(+), 23 deletions(-) diff --git a/consensus/misc/eip4844/eip4844.go b/consensus/misc/eip4844/eip4844.go index 6837abacbe..583bcdeecd 100644 --- a/consensus/misc/eip4844/eip4844.go +++ b/consensus/misc/eip4844/eip4844.go @@ -41,12 +41,12 @@ func VerifyEIP4844Header(parent, header *types.Header) error { if header.BlobGasUsed == nil { return errors.New("header is missing blobGasUsed") } - // Verify that the data gas used remains within reasonable limits. + // Verify that the blob gas used remains within reasonable limits. if *header.BlobGasUsed > params.BlobTxMaxBlobGasPerBlock { - return fmt.Errorf("data gas used %d exceeds maximum allowance %d", *header.BlobGasUsed, params.BlobTxMaxBlobGasPerBlock) + return fmt.Errorf("blob gas used %d exceeds maximum allowance %d", *header.BlobGasUsed, params.BlobTxMaxBlobGasPerBlock) } 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) + return fmt.Errorf("blob gas used %d not a multiple of blob gas per blob %d", header.BlobGasUsed, params.BlobTxBlobGasPerBlob) } // Verify the excessBlobGas is correct based on the parent header var ( @@ -65,8 +65,8 @@ func VerifyEIP4844Header(parent, header *types.Header) error { return nil } -// CalcExcessBlobGas calculates the excess data gas after applying the set of -// blobs on top of the excess data gas. +// CalcExcessBlobGas calculates the excess blob gas after applying the set of +// blobs on top of the excess blob gas. func CalcExcessBlobGas(parentExcessBlobGas uint64, parentBlobGasUsed uint64) uint64 { excessBlobGas := parentExcessBlobGas + parentBlobGasUsed if excessBlobGas < params.BlobTxTargetBlobGasPerBlock { @@ -75,7 +75,7 @@ func CalcExcessBlobGas(parentExcessBlobGas uint64, parentBlobGasUsed uint64) uin return excessBlobGas - params.BlobTxTargetBlobGasPerBlock } -// CalcBlobFee calculates the blobfee from the header's excess data gas field. +// CalcBlobFee calculates the blobfee from the header's excess blob gas field. func CalcBlobFee(excessBlobGas uint64) *big.Int { return fakeExponential(minBlobGasPrice, new(big.Int).SetUint64(excessBlobGas), blobGaspriceUpdateFraction) } diff --git a/consensus/misc/eip4844/eip4844_test.go b/consensus/misc/eip4844/eip4844_test.go index 7b9af04d62..677cdd252c 100644 --- a/consensus/misc/eip4844/eip4844_test.go +++ b/consensus/misc/eip4844/eip4844_test.go @@ -30,19 +30,19 @@ func TestCalcExcessBlobGas(t *testing.T) { blobs uint64 want uint64 }{ - // The excess data gas should not increase from zero if the used blob + // The excess blob gas should not increase from zero if the used blob // slots are below - or equal - to the target. {0, 0, 0}, {0, 1, 0}, {0, params.BlobTxTargetBlobGasPerBlock / params.BlobTxBlobGasPerBlob, 0}, - // If the target data gas is exceeded, the excessBlobGas should increase + // If the target blob gas is exceeded, the excessBlobGas should increase // by however much it was overshot {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 + // The excess blob gas should decrease by however much the target was // under-shot, capped at zero. {params.BlobTxTargetBlobGasPerBlock, params.BlobTxTargetBlobGasPerBlock / params.BlobTxBlobGasPerBlob, params.BlobTxTargetBlobGasPerBlock}, {params.BlobTxTargetBlobGasPerBlock, (params.BlobTxTargetBlobGasPerBlock / params.BlobTxBlobGasPerBlob) - 1, params.BlobTxBlobGasPerBlob}, @@ -52,7 +52,7 @@ func TestCalcExcessBlobGas(t *testing.T) { for _, tt := range tests { 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) + t.Errorf("excess blob gas mismatch: have %v, want %v", result, tt.want) } } } diff --git a/core/block_validator.go b/core/block_validator.go index 085e7ce61c..3c9ac3dc49 100644 --- a/core/block_validator.go +++ b/core/block_validator.go @@ -91,7 +91,7 @@ func (v *BlockValidator) ValidateBody(block *types.Block) error { } 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) + return fmt.Errorf("blob gas used mismatch (header %v, calculated %v)", *header.BlobGasUsed, blobs*params.BlobTxBlobGasPerBlob) } } else { if blobs > 0 { diff --git a/core/error.go b/core/error.go index 8967432a40..4214ed207a 100644 --- a/core/error.go +++ b/core/error.go @@ -102,6 +102,6 @@ var ( ErrSenderNoEOA = errors.New("sender not an eoa") // ErrBlobFeeCapTooLow is returned if the transaction fee cap is less than the - // data gas fee of the block. - ErrBlobFeeCapTooLow = errors.New("max fee per data gas less than block data gas fee") + // blob gas fee of the block. + ErrBlobFeeCapTooLow = errors.New("max fee per blob gas less than block blob gas fee") ) diff --git a/core/rawdb/accessors_chain.go b/core/rawdb/accessors_chain.go index e3f4b3f353..9eeaaee941 100644 --- a/core/rawdb/accessors_chain.go +++ b/core/rawdb/accessors_chain.go @@ -645,7 +645,7 @@ func ReadReceipts(db ethdb.Reader, hash common.Hash, number uint64, time uint64, } else { baseFee = header.BaseFee } - // Compute effective data gas price. + // Compute effective blob gas price. var blobGasPrice *big.Int if header != nil && header.ExcessBlobGas != nil { blobGasPrice = eip4844.CalcBlobFee(*header.ExcessBlobGas) diff --git a/core/state_transition.go b/core/state_transition.go index 13f3f32321..f84757be78 100644 --- a/core/state_transition.go +++ b/core/state_transition.go @@ -467,7 +467,7 @@ func (st *StateTransition) gasUsed() uint64 { return st.initialGas - st.gasRemaining } -// blobGasUsed returns the amount of data gas used by the message. +// blobGasUsed returns the amount of blob 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 07e3e3ff98..fb6257b5af 100644 --- a/core/txpool/blobpool/blobpool.go +++ b/core/txpool/blobpool/blobpool.go @@ -184,7 +184,7 @@ func newBlobTxMeta(id uint64, size uint32, tx *types.Transaction) *blobTxMeta { // - Local txs are meaningless. Mining pools historically used local transactions // for payouts or for backdoor deals. With 1559 in place, the basefee usually // dominates the final price, so 0 or non-0 tip doesn't change much. Blob txs -// retain the 1559 2D gas pricing (and introduce on top a dynamic data gas fee), +// retain the 1559 2D gas pricing (and introduce on top a dynamic blob gas fee), // so locality is moot. With a disk backed blob pool avoiding the resend issue, // there's also no need to save own transactions for later. // diff --git a/core/txpool/blobpool/blobpool_test.go b/core/txpool/blobpool/blobpool_test.go index 343a4642e9..c0fd232bb3 100644 --- a/core/txpool/blobpool/blobpool_test.go +++ b/core/txpool/blobpool/blobpool_test.go @@ -122,7 +122,7 @@ func (bc *testBlockChain) CurrentBlock() *types.Header { } baseFee := lo - // The excess data gas at 2^27 translates into a blob fee higher than mainnet + // The excess blob gas at 2^27 translates into a blob fee higher than mainnet // ether existence, use that as a cap for the tests. lo = new(big.Int) hi = new(big.Int).Exp(big.NewInt(2), big.NewInt(27), nil) diff --git a/core/types/transaction.go b/core/types/transaction.go index 91a20d32a7..e774809c29 100644 --- a/core/types/transaction.go +++ b/core/types/transaction.go @@ -288,10 +288,10 @@ func (tx *Transaction) GasTipCap() *big.Int { return new(big.Int).Set(tx.inner.g // GasFeeCap returns the fee cap per gas of the transaction. func (tx *Transaction) GasFeeCap() *big.Int { return new(big.Int).Set(tx.inner.gasFeeCap()) } -// BlobGas returns the data gas limit of the transaction for blob transactions, 0 otherwise. +// BlobGas returns the blob gas limit of the transaction for blob transactions, 0 otherwise. func (tx *Transaction) BlobGas() uint64 { return tx.inner.blobGas() } -// BlobGasFeeCap returns the data gas fee cap per data gas of the transaction for blob transactions, nil otherwise. +// BlobGasFeeCap returns the blob gas fee cap per blob gas of the transaction for blob transactions, nil otherwise. func (tx *Transaction) BlobGasFeeCap() *big.Int { return tx.inner.blobGasFeeCap() } // BlobHashes returns the hases of the blob commitments for blob transactions, nil otherwise. diff --git a/eth/catalyst/api.go b/eth/catalyst/api.go index eb58c81b4e..1a22194142 100644 --- a/eth/catalyst/api.go +++ b/eth/catalyst/api.go @@ -451,7 +451,7 @@ func (api *ConsensusAPI) NewPayloadV3(params engine.ExecutableData, versionedHas } if params.ExcessBlobGas == nil { - return engine.PayloadStatusV1{Status: engine.INVALID}, engine.InvalidParams.With(fmt.Errorf("nil excessDataGas post-cancun")) + return engine.PayloadStatusV1{Status: engine.INVALID}, engine.InvalidParams.With(errors.New("nil excessBlobGas post-cancun")) } var hashes []common.Hash if versionedHashes != nil { diff --git a/params/protocol_params.go b/params/protocol_params.go index b5c57789be..a407ed1473 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 - 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) + BlobTxMaxBlobGasPerBlock = 1 << 19 // Maximum consumable blob gas for data blobs per block + BlobTxTargetBlobGasPerBlock = 1 << 18 // Target consumable blob 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 + BlobTxBlobGaspriceUpdateFraction = 2225652 // Controls the maximum rate of change for blob gas price BlobTxPointEvaluationPrecompileGas = 50000 // Gas price for the point evaluation precompile. )