diff --git a/packages/block/docs/classes/Block.md b/packages/block/docs/classes/Block.md index 601461ac9a..c455eb4ede 100644 --- a/packages/block/docs/classes/Block.md +++ b/packages/block/docs/classes/Block.md @@ -344,9 +344,9 @@ ___ ▸ **validateBlobTransactions**(`parentHeader`): `void` -Validates that data gas fee for each transaction is greater than or equal to the -dataGasPrice for the block and that total data gas in block is less than maximum -data gas per block +Validates that blob gas fee for each transaction is greater than or equal to the +dataGasPrice for the block and that total blob gas in block is less than maximum +blob gas per block #### Parameters diff --git a/packages/block/docs/classes/BlockHeader.md b/packages/block/docs/classes/BlockHeader.md index 553c4d64e7..c915e88cd5 100644 --- a/packages/block/docs/classes/BlockHeader.md +++ b/packages/block/docs/classes/BlockHeader.md @@ -319,7 +319,7 @@ EIP-4399: After merge to PoS, `mixHash` supplanted as `prevRandao` ▸ **calcDataFee**(`numBlobs`): `bigint` -Returns the total fee for data gas spent for including blobs in block. +Returns the total fee for blob gas spent for including blobs in block. #### Parameters @@ -331,7 +331,7 @@ Returns the total fee for data gas spent for including blobs in block. `bigint` -the total data gas fee for numBlobs blobs +the total blob gas fee for numBlobs blobs #### Defined in @@ -359,7 +359,7 @@ ___ ▸ **calcNextExcessDataGas**(): `bigint` -Calculates the excess data gas for next (hopefully) post EIP 4844 block. +Calculates the excess blob gas for next (hopefully) post EIP 4844 block. #### Returns @@ -542,13 +542,13 @@ ___ ▸ **getDataGasPrice**(): `bigint` -Returns the price per unit of data gas for a blob transaction in the current/pending block +Returns the price per unit of blob gas for a blob transaction in the current/pending block #### Returns `bigint` -the price in gwei per unit of data gas spent +the price in gwei per unit of blob gas spent #### Defined in diff --git a/packages/block/src/block.ts b/packages/block/src/block.ts index db2bcd5d6c..5f0105fc8a 100644 --- a/packages/block/src/block.ts +++ b/packages/block/src/block.ts @@ -468,9 +468,9 @@ export class Block { */ getTransactionsValidationErrors(): string[] { const errors: string[] = [] - let dataGasUsed = BigInt(0) - const dataGasLimit = this.common.param('gasConfig', 'maxDataGasPerBlock') - const dataGasPerBlob = this.common.param('gasConfig', 'dataGasPerBlob') + let blobGasUsed = BigInt(0) + const blobGasLimit = this.common.param('gasConfig', 'maxblobGasPerBlock') + const blobGasPerBlob = this.common.param('gasConfig', 'blobGasPerBlob') // eslint-disable-next-line prefer-const for (let [i, tx] of this.transactions.entries()) { @@ -490,10 +490,10 @@ export class Block { } if (this.common.isActivatedEIP(4844) === true) { if (tx instanceof BlobEIP4844Transaction) { - dataGasUsed += BigInt(tx.numBlobs()) * dataGasPerBlob - if (dataGasUsed > dataGasLimit) { + blobGasUsed += BigInt(tx.numBlobs()) * blobGasPerBlob + if (blobGasUsed > blobGasLimit) { errs.push( - `tx causes total data gas of ${dataGasUsed} to exceed maximum data gas per block of ${dataGasLimit}` + `tx causes total blob gas of ${blobGasUsed} to exceed maximum blob gas per block of ${blobGasLimit}` ) } } @@ -504,8 +504,8 @@ export class Block { } if (this.common.isActivatedEIP(4844) === true) { - if (dataGasUsed !== this.header.dataGasUsed) { - errors.push(`invalid dataGasUsed expected=${this.header.dataGasUsed} actual=${dataGasUsed}`) + if (blobGasUsed !== this.header.blobGasUsed) { + errors.push(`invalid blobGasUsed expected=${this.header.blobGasUsed} actual=${blobGasUsed}`) } } @@ -559,48 +559,48 @@ export class Block { } /** - * Validates that data gas fee for each transaction is greater than or equal to the - * dataGasPrice for the block and that total data gas in block is less than maximum - * data gas per block + * Validates that blob gas fee for each transaction is greater than or equal to the + * blobGasPrice for the block and that total blob gas in block is less than maximum + * blob gas per block * @param parentHeader header of parent block */ validateBlobTransactions(parentHeader: BlockHeader) { if (this.common.isActivatedEIP(4844)) { - const dataGasLimit = this.common.param('gasConfig', 'maxDataGasPerBlock') - const dataGasPerBlob = this.common.param('gasConfig', 'dataGasPerBlob') - let dataGasUsed = BigInt(0) + const blobGasLimit = this.common.param('gasConfig', 'maxblobGasPerBlock') + const blobGasPerBlob = this.common.param('gasConfig', 'blobGasPerBlob') + let blobGasUsed = BigInt(0) for (const tx of this.transactions) { if (tx instanceof BlobEIP4844Transaction) { - const dataGasPrice = this.header.getDataGasPrice() - if (tx.maxFeePerDataGas < dataGasPrice) { + const blobGasPrice = this.header.getBlobGasPrice() + if (tx.maxFeePerblobGas < blobGasPrice) { throw new Error( - `blob transaction maxFeePerDataGas ${ - tx.maxFeePerDataGas - } < than block data gas price ${dataGasPrice} - ${this.errorStr()}` + `blob transaction maxFeePerblobGas ${ + tx.maxFeePerblobGas + } < than block blob gas price ${blobGasPrice} - ${this.errorStr()}` ) } - dataGasUsed += BigInt(tx.versionedHashes.length) * dataGasPerBlob + blobGasUsed += BigInt(tx.versionedHashes.length) * blobGasPerBlob - if (dataGasUsed > dataGasLimit) { + if (blobGasUsed > blobGasLimit) { throw new Error( - `tx causes total data gas of ${dataGasUsed} to exceed maximum data gas per block of ${dataGasLimit}` + `tx causes total blob gas of ${blobGasUsed} to exceed maximum blob gas per block of ${blobGasLimit}` ) } } } - if (this.header.dataGasUsed !== dataGasUsed) { + if (this.header.blobGasUsed !== blobGasUsed) { throw new Error( - `block dataGasUsed mismatch: have ${this.header.dataGasUsed}, want ${dataGasUsed}` + `block blobGasUsed mismatch: have ${this.header.blobGasUsed}, want ${blobGasUsed}` ) } - const expectedExcessDataGas = parentHeader.calcNextExcessDataGas() - if (this.header.excessDataGas !== expectedExcessDataGas) { + const expectedExcessBlobGas = parentHeader.calcNextExcessBlobGas() + if (this.header.excessBlobGas !== expectedExcessBlobGas) { throw new Error( - `block excessDataGas mismatch: have ${this.header.excessDataGas}, want ${expectedExcessDataGas}` + `block excessBlobGas mismatch: have ${this.header.excessBlobGas}, want ${expectedExcessBlobGas}` ) } } diff --git a/packages/block/src/from-beacon-payload.ts b/packages/block/src/from-beacon-payload.ts index a2d68a4f8d..f0cea6b412 100644 --- a/packages/block/src/from-beacon-payload.ts +++ b/packages/block/src/from-beacon-payload.ts @@ -27,8 +27,8 @@ export type BeaconPayloadJson = { block_hash: string transactions: string[] withdrawals?: BeaconWithdrawal[] - data_gas_used?: string - excess_data_gas?: string + blob_gas_used?: string + excess_blob_gas?: string parent_beacon_block_root?: string } @@ -63,11 +63,11 @@ export function executionPayloadFromBeaconPayload(payload: BeaconPayloadJson): E })) } - if (payload.data_gas_used !== undefined && payload.data_gas_used !== null) { - executionPayload.dataGasUsed = bigIntToHex(BigInt(payload.data_gas_used)) + if (payload.blob_gas_used !== undefined && payload.blob_gas_used !== null) { + executionPayload.blobGasUsed = bigIntToHex(BigInt(payload.blob_gas_used)) } - if (payload.excess_data_gas !== undefined && payload.excess_data_gas !== null) { - executionPayload.excessDataGas = bigIntToHex(BigInt(payload.excess_data_gas)) + if (payload.excess_blob_gas !== undefined && payload.excess_blob_gas !== null) { + executionPayload.excessBlobGas = bigIntToHex(BigInt(payload.excess_blob_gas)) } if (payload.parent_beacon_block_root !== undefined && payload.parent_beacon_block_root !== null) { executionPayload.parentBeaconBlockRoot = payload.parent_beacon_block_root diff --git a/packages/block/src/header-from-rpc.ts b/packages/block/src/header-from-rpc.ts index 363b67faec..1f475efeed 100644 --- a/packages/block/src/header-from-rpc.ts +++ b/packages/block/src/header-from-rpc.ts @@ -28,8 +28,8 @@ export function blockHeaderFromRpc(blockParams: JsonRpcBlock, options?: BlockOpt nonce, baseFeePerGas, withdrawalsRoot, - dataGasUsed, - excessDataGas, + blobGasUsed, + excessBlobGas, } = blockParams const blockHeader = BlockHeader.fromHeaderData( @@ -51,8 +51,8 @@ export function blockHeaderFromRpc(blockParams: JsonRpcBlock, options?: BlockOpt nonce, baseFeePerGas, withdrawalsRoot, - dataGasUsed, - excessDataGas, + blobGasUsed, + excessBlobGas, }, options ) diff --git a/packages/block/src/header.ts b/packages/block/src/header.ts index 97c3e344f7..0ae1eb5169 100644 --- a/packages/block/src/header.ts +++ b/packages/block/src/header.ts @@ -54,8 +54,8 @@ export class BlockHeader { public readonly nonce: Uint8Array public readonly baseFeePerGas?: bigint public readonly withdrawalsRoot?: Uint8Array - public readonly dataGasUsed?: bigint - public readonly excessDataGas?: bigint + public readonly blobGasUsed?: bigint + public readonly excessBlobGas?: bigint public readonly parentBeaconBlockRoot?: Uint8Array public readonly common: Common @@ -109,7 +109,7 @@ export class BlockHeader { */ public static fromValuesArray(values: BlockHeaderBytes, opts: BlockOptions = {}) { const headerData = valuesArrayToHeaderData(values) - const { number, baseFeePerGas, excessDataGas, dataGasUsed, parentBeaconBlockRoot } = headerData + const { number, baseFeePerGas, excessBlobGas, blobGasUsed, parentBeaconBlockRoot } = headerData const header = BlockHeader.fromHeaderData(headerData, opts) // eslint-disable-next-line @typescript-eslint/strict-boolean-expressions if (header.common.isActivatedEIP(1559) && baseFeePerGas === undefined) { @@ -121,10 +121,10 @@ export class BlockHeader { } // eslint-disable-next-line @typescript-eslint/strict-boolean-expressions if (header.common.isActivatedEIP(4844)) { - if (excessDataGas === undefined) { - throw new Error('invalid header. excessDataGas should be provided') - } else if (dataGasUsed === undefined) { - throw new Error('invalid header. dataGasUsed should be provided') + if (excessBlobGas === undefined) { + throw new Error('invalid header. excessBlobGas should be provided') + } else if (blobGasUsed === undefined) { + throw new Error('invalid header. blobGasUsed should be provided') } } if (header.common.isActivatedEIP(4788) && parentBeaconBlockRoot === undefined) { @@ -210,8 +210,8 @@ export class BlockHeader { : BigInt(7) : undefined, withdrawalsRoot: this.common.isActivatedEIP(4895) ? KECCAK256_RLP : undefined, - dataGasUsed: this.common.isActivatedEIP(4844) ? BigInt(0) : undefined, - excessDataGas: this.common.isActivatedEIP(4844) ? BigInt(0) : undefined, + blobGasUsed: this.common.isActivatedEIP(4844) ? BigInt(0) : undefined, + excessBlobGas: this.common.isActivatedEIP(4844) ? BigInt(0) : undefined, parentBeaconBlockRoot: this.common.isActivatedEIP(4788) ? zeros(32) : undefined, } @@ -219,10 +219,10 @@ export class BlockHeader { toType(headerData.baseFeePerGas, TypeOutput.BigInt) ?? hardforkDefaults.baseFeePerGas const withdrawalsRoot = toType(headerData.withdrawalsRoot, TypeOutput.Uint8Array) ?? hardforkDefaults.withdrawalsRoot - const dataGasUsed = - toType(headerData.dataGasUsed, TypeOutput.BigInt) ?? hardforkDefaults.dataGasUsed - const excessDataGas = - toType(headerData.excessDataGas, TypeOutput.BigInt) ?? hardforkDefaults.excessDataGas + const blobGasUsed = + toType(headerData.blobGasUsed, TypeOutput.BigInt) ?? hardforkDefaults.blobGasUsed + const excessBlobGas = + toType(headerData.excessBlobGas, TypeOutput.BigInt) ?? hardforkDefaults.excessBlobGas const parentBeaconBlockRoot = toType(headerData.parentBeaconBlockRoot, TypeOutput.Uint8Array) ?? hardforkDefaults.parentBeaconBlockRoot @@ -238,12 +238,12 @@ export class BlockHeader { } if (!this.common.isActivatedEIP(4844)) { - if (headerData.dataGasUsed !== undefined) { - throw new Error('data gas used can only be provided with EIP4844 activated') + if (headerData.blobGasUsed !== undefined) { + throw new Error('blob gas used can only be provided with EIP4844 activated') } - if (headerData.excessDataGas !== undefined) { - throw new Error('excess data gas can only be provided with EIP4844 activated') + if (headerData.excessBlobGas !== undefined) { + throw new Error('excess blob gas can only be provided with EIP4844 activated') } } @@ -270,8 +270,8 @@ export class BlockHeader { this.nonce = nonce this.baseFeePerGas = baseFeePerGas this.withdrawalsRoot = withdrawalsRoot - this.dataGasUsed = dataGasUsed - this.excessDataGas = excessDataGas + this.blobGasUsed = blobGasUsed + this.excessBlobGas = excessBlobGas this.parentBeaconBlockRoot = parentBeaconBlockRoot this._genericFormatValidation() this._validateDAOExtraData() @@ -576,46 +576,46 @@ export class BlockHeader { } /** - * Returns the price per unit of data gas for a blob transaction in the current/pending block - * @returns the price in gwei per unit of data gas spent + * Returns the price per unit of blob gas for a blob transaction in the current/pending block + * @returns the price in gwei per unit of blob gas spent */ - getDataGasPrice(): bigint { - if (this.excessDataGas === undefined) { - throw new Error('header must have excessDataGas field populated') + getBlobGasPrice(): bigint { + if (this.excessBlobGas === undefined) { + throw new Error('header must have excessBlobGas field populated') } return fakeExponential( - this.common.param('gasPrices', 'minDataGasPrice'), - this.excessDataGas, - this.common.param('gasConfig', 'dataGasPriceUpdateFraction') + this.common.param('gasPrices', 'minBlobGasPrice'), + this.excessBlobGas, + this.common.param('gasConfig', 'blobGasPriceUpdateFraction') ) } /** - * Returns the total fee for data gas spent for including blobs in block. + * Returns the total fee for blob gas spent for including blobs in block. * * @param numBlobs number of blobs in the transaction/block - * @returns the total data gas fee for numBlobs blobs + * @returns the total blob gas fee for numBlobs blobs */ calcDataFee(numBlobs: number): bigint { - const dataGasPerBlob = this.common.param('gasConfig', 'dataGasPerBlob') - const dataGasUsed = dataGasPerBlob * BigInt(numBlobs) + const blobGasPerBlob = this.common.param('gasConfig', 'blobGasPerBlob') + const blobGasUsed = blobGasPerBlob * BigInt(numBlobs) - const dataGasPrice = this.getDataGasPrice() - return dataGasUsed * dataGasPrice + const blobGasPrice = this.getBlobGasPrice() + return blobGasUsed * blobGasPrice } /** - * Calculates the excess data gas for next (hopefully) post EIP 4844 block. + * Calculates the excess blob gas for next (hopefully) post EIP 4844 block. */ - public calcNextExcessDataGas(): bigint { + public calcNextExcessBlobGas(): bigint { // The validation of the fields and 4844 activation is already taken care in BlockHeader constructor - const targetGasConsumed = (this.excessDataGas ?? BigInt(0)) + (this.dataGasUsed ?? BigInt(0)) - const targetDataGasPerBlock = this.common.param('gasConfig', 'targetDataGasPerBlock') + const targetGasConsumed = (this.excessBlobGas ?? BigInt(0)) + (this.blobGasUsed ?? BigInt(0)) + const targetBlobGasPerBlock = this.common.param('gasConfig', 'targetBlobGasPerBlock') - if (targetGasConsumed <= targetDataGasPerBlock) { + if (targetGasConsumed <= targetBlobGasPerBlock) { return BigInt(0) } else { - return targetGasConsumed - targetDataGasPerBlock + return targetGasConsumed - targetBlobGasPerBlock } } @@ -649,8 +649,8 @@ export class BlockHeader { rawItems.push(this.withdrawalsRoot!) } if (this.common.isActivatedEIP(4844) === true) { - rawItems.push(bigIntToUnpaddedBytes(this.dataGasUsed!)) - rawItems.push(bigIntToUnpaddedBytes(this.excessDataGas!)) + rawItems.push(bigIntToUnpaddedBytes(this.blobGasUsed!)) + rawItems.push(bigIntToUnpaddedBytes(this.excessBlobGas!)) } if (this.common.isActivatedEIP(4788) === true) { rawItems.push(this.parentBeaconBlockRoot!) @@ -922,8 +922,8 @@ export class BlockHeader { jsonDict.baseFeePerGas = bigIntToHex(this.baseFeePerGas!) } if (this.common.isActivatedEIP(4844) === true) { - jsonDict.dataGasUsed = bigIntToHex(this.dataGasUsed!) - jsonDict.excessDataGas = bigIntToHex(this.excessDataGas!) + jsonDict.blobGasUsed = bigIntToHex(this.blobGasUsed!) + jsonDict.excessBlobGas = bigIntToHex(this.excessBlobGas!) } if (this.common.isActivatedEIP(4788) === true) { jsonDict.parentBeaconBlockRoot = bytesToHex(this.parentBeaconBlockRoot!) diff --git a/packages/block/src/helpers.ts b/packages/block/src/helpers.ts index 1856846cce..e26ebeb5d2 100644 --- a/packages/block/src/helpers.ts +++ b/packages/block/src/helpers.ts @@ -40,8 +40,8 @@ export function valuesArrayToHeaderData(values: BlockHeaderBytes): HeaderData { nonce, baseFeePerGas, withdrawalsRoot, - dataGasUsed, - excessDataGas, + blobGasUsed, + excessBlobGas, parentBeaconBlockRoot, ] = values @@ -70,8 +70,8 @@ export function valuesArrayToHeaderData(values: BlockHeaderBytes): HeaderData { nonce, baseFeePerGas, withdrawalsRoot, - dataGasUsed, - excessDataGas, + blobGasUsed, + excessBlobGas, parentBeaconBlockRoot, } } diff --git a/packages/block/src/types.ts b/packages/block/src/types.ts index b6938164c6..be47d9e81a 100644 --- a/packages/block/src/types.ts +++ b/packages/block/src/types.ts @@ -92,8 +92,8 @@ export interface HeaderData { nonce?: BytesLike baseFeePerGas?: BigIntLike withdrawalsRoot?: BytesLike - dataGasUsed?: BigIntLike - excessDataGas?: BigIntLike + blobGasUsed?: BigIntLike + excessBlobGas?: BigIntLike parentBeaconBlockRoot?: BytesLike } @@ -157,8 +157,8 @@ export interface JsonHeader { nonce?: string baseFeePerGas?: string withdrawalsRoot?: string - dataGasUsed?: string - excessDataGas?: string + blobGasUsed?: string + excessBlobGas?: string parentBeaconBlockRoot?: string } @@ -189,8 +189,8 @@ export interface JsonRpcBlock { baseFeePerGas?: string // If EIP-1559 is enabled for this block, returns the base fee per gas withdrawals?: Array // If EIP-4895 is enabled for this block, array of withdrawals withdrawalsRoot?: string // If EIP-4895 is enabled for this block, the root of the withdrawal trie of the block. - dataGasUsed?: string // If EIP-4844 is enabled for this block, returns the data gas used for the block - excessDataGas?: string // If EIP-4844 is enabled for this block, returns the excess data gas for the block + blobGasUsed?: string // If EIP-4844 is enabled for this block, returns the blob gas used for the block + excessBlobGas?: string // If EIP-4844 is enabled for this block, returns the excess blob gas for the block parentBeaconBlockRoot?: string // If EIP-4788 is enabled for this block, returns parent beacon block root } @@ -219,7 +219,7 @@ export type ExecutionPayload = { blockHash: PrefixedHexString // DATA, 32 Bytes transactions: PrefixedHexString[] // Array of DATA - Array of transaction rlp strings, withdrawals?: WithdrawalV1[] // Array of withdrawal objects - dataGasUsed?: PrefixedHexString // QUANTITY, 64 Bits - excessDataGas?: PrefixedHexString // QUANTITY, 64 Bits + blobGasUsed?: PrefixedHexString // QUANTITY, 64 Bits + excessBlobGas?: PrefixedHexString // QUANTITY, 64 Bits parentBeaconBlockRoot?: PrefixedHexString // QUANTITY, 64 Bits } diff --git a/packages/block/test/eip4788block.spec.ts b/packages/block/test/eip4788block.spec.ts index d59fab5a12..e74d5b7fc9 100644 --- a/packages/block/test/eip4788block.spec.ts +++ b/packages/block/test/eip4788block.spec.ts @@ -30,22 +30,22 @@ describe('EIP4788 header tests', () => { () => { BlockHeader.fromHeaderData( { - dataGasUsed: 1n, + blobGasUsed: 1n, }, { common: earlyCommon, } ) }, - 'data gas used can only be provided with EIP4844 activated', + 'blob gas used can only be provided with EIP4844 activated', undefined, - 'should throw when setting dataGasUsed with EIP4844 not being activated' + 'should throw when setting blobGasUsed with EIP4844 not being activated' ) assert.doesNotThrow(() => { BlockHeader.fromHeaderData( { - excessDataGas: 0n, - dataGasUsed: 0n, + excessBlobGas: 0n, + blobGasUsed: 0n, parentBeaconBlockRoot: zeros(32), }, { @@ -64,7 +64,7 @@ describe('EIP4788 header tests', () => { assert.equal( block.toJSON().header?.parentBeaconBlockRoot, bytesToHex(zeros(32)), - 'JSON output includes excessDataGas' + 'JSON output includes excessBlobGas' ) }) }) diff --git a/packages/block/test/eip4844block.spec.ts b/packages/block/test/eip4844block.spec.ts index 6e154fd7ae..7548e0c42e 100644 --- a/packages/block/test/eip4844block.spec.ts +++ b/packages/block/test/eip4844block.spec.ts @@ -30,7 +30,7 @@ const common = Common.fromGethGenesis(gethGenesis, { chain: 'customChain', hardfork: Hardfork.Cancun, }) -const dataGasPerBlob = common.param('gasConfig', 'dataGasPerBlob') +const blobGasPerBlob = common.param('gasConfig', 'blobGasPerBlob') describe('EIP4844 header tests', () => { it('should work', () => { @@ -41,47 +41,47 @@ describe('EIP4844 header tests', () => { () => { BlockHeader.fromHeaderData( { - excessDataGas: 1n, + excessBlobGas: 1n, }, { common: earlyCommon, } ) }, - 'excess data gas can only be provided with EIP4844 activated', + 'excess blob gas can only be provided with EIP4844 activated', undefined, - 'should throw when setting excessDataGas with EIP4844 not being activated' + 'should throw when setting excessBlobGas with EIP4844 not being activated' ) assert.throws( () => { BlockHeader.fromHeaderData( { - dataGasUsed: 1n, + blobGasUsed: 1n, }, { common: earlyCommon, } ) }, - 'data gas used can only be provided with EIP4844 activated', + 'blob gas used can only be provided with EIP4844 activated', undefined, - 'should throw when setting dataGasUsed with EIP4844 not being activated' + 'should throw when setting blobGasUsed with EIP4844 not being activated' ) - const excessDataGas = BlockHeader.fromHeaderData( + const excessBlobGas = BlockHeader.fromHeaderData( {}, { common, skipConsensusFormatValidation: true } - ).excessDataGas + ).excessBlobGas assert.equal( - excessDataGas, + excessBlobGas, 0n, - 'instantiates block with reasonable default excess data gas value when not provided' + 'instantiates block with reasonable default excess blob gas value when not provided' ) assert.doesNotThrow(() => { BlockHeader.fromHeaderData( { - excessDataGas: 0n, + excessBlobGas: 0n, }, { common, @@ -97,54 +97,54 @@ describe('EIP4844 header tests', () => { { common, skipConsensusFormatValidation: true } ) assert.equal( - block.toJSON().header?.excessDataGas, + block.toJSON().header?.excessBlobGas, '0x0', - 'JSON output includes excessDataGas' + 'JSON output includes excessBlobGas' ) } }) }) -describe('data gas tests', () => { +describe('blob gas tests', () => { it('should work', () => { if (isBrowser() === false) { const preShardingHeader = BlockHeader.fromHeaderData({}) - let excessDataGas = preShardingHeader.calcNextExcessDataGas() + let excessBlobGas = preShardingHeader.calcNextExcessBlobGas() assert.equal( - excessDataGas, + excessBlobGas, 0n, - 'excess data gas where 4844 is not active on header should be 0' + 'excess blob gas where 4844 is not active on header should be 0' ) assert.throws( () => preShardingHeader.calcDataFee(1), - 'header must have excessDataGas field', + 'header must have excessBlobGas field', undefined, - 'calcDataFee throws when header has no excessDataGas field' + 'calcDataFee throws when header has no excessBlobGas field' ) const lowGasHeader = BlockHeader.fromHeaderData( - { number: 1, excessDataGas: 5000 }, + { number: 1, excessBlobGas: 5000 }, { common, skipConsensusFormatValidation: true } ) - excessDataGas = lowGasHeader.calcNextExcessDataGas() - let dataGasPrice = lowGasHeader.getDataGasPrice() + excessBlobGas = lowGasHeader.calcNextExcessBlobGas() + let blobGasPrice = lowGasHeader.getBlobGasPrice() assert.equal( - excessDataGas, + excessBlobGas, 0n, - 'excess data gas should be 0 for small parent header data gas' + 'excess blob gas should be 0 for small parent header blob gas' ) - assert.equal(dataGasPrice, 1n, 'data gas price should be 1n when low or no excess data gas') + assert.equal(blobGasPrice, 1n, 'blob gas price should be 1n when low or no excess blob gas') const highGasHeader = BlockHeader.fromHeaderData( - { number: 1, excessDataGas: 6291456, dataGasUsed: BigInt(6) * dataGasPerBlob }, + { number: 1, excessBlobGas: 6291456, blobGasUsed: BigInt(6) * blobGasPerBlob }, { common, skipConsensusFormatValidation: true } ) - excessDataGas = highGasHeader.calcNextExcessDataGas() - dataGasPrice = highGasHeader.getDataGasPrice() - assert.equal(excessDataGas, 6684672n) - assert.equal(dataGasPrice, 6n, 'computed correct data gas price') + excessBlobGas = highGasHeader.calcNextExcessBlobGas() + blobGasPrice = highGasHeader.getBlobGasPrice() + assert.equal(excessBlobGas, 6684672n) + assert.equal(blobGasPrice, 6n, 'computed correct blob gas price') assert.equal(lowGasHeader.calcDataFee(1), 131072n, 'compute data fee correctly') assert.equal(highGasHeader.calcDataFee(4), 3145728n, 'compute data fee correctly') @@ -165,7 +165,7 @@ describe('transaction validation tests', () => { versionedHashes, blobs, kzgCommitments: commitments, - maxFeePerDataGas: 100000000n, + maxFeePerblobGas: 100000000n, gasLimit: 0xffffffn, to: randomBytes(20), }, @@ -176,7 +176,7 @@ describe('transaction validation tests', () => { versionedHashes, blobs, kzgCommitments: commitments, - maxFeePerDataGas: 1n, + maxFeePerblobGas: 1n, gasLimit: 0xffffffn, to: randomBytes(20), }, @@ -184,10 +184,10 @@ describe('transaction validation tests', () => { ).sign(randomBytes(32)) const parentHeader = BlockHeader.fromHeaderData( - { number: 1n, excessDataGas: 4194304, dataGasUsed: 0 }, + { number: 1n, excessBlobGas: 4194304, blobGasUsed: 0 }, { common, skipConsensusFormatValidation: true } ) - const excessDataGas = parentHeader.calcNextExcessDataGas() + const excessBlobGas = parentHeader.calcNextExcessBlobGas() // eslint-disable-next-line no-inner-declarations function getBlock(transactions: TypedTransaction[]) { @@ -197,8 +197,8 @@ describe('transaction validation tests', () => { { number: 2n, parentHash: parentHeader.hash(), - excessDataGas, - dataGasUsed: BigInt(blobs) * dataGasPerBlob, + excessBlobGas, + blobGasUsed: BigInt(blobs) * blobGasPerBlob, }, { common, skipConsensusFormatValidation: true } ) @@ -217,42 +217,42 @@ describe('transaction validation tests', () => { assert.doesNotThrow( () => blockWithValidTx.validateBlobTransactions(parentHeader), - 'does not throw when all tx maxFeePerDataGas are >= to block data gas fee' + 'does not throw when all tx maxFeePerblobGas are >= to block blob gas fee' ) const blockJson = blockWithValidTx.toJSON() - blockJson.header!.dataGasUsed = '0x0' + blockJson.header!.blobGasUsed = '0x0' const blockWithInvalidHeader = Block.fromBlockData(blockJson, { common }) assert.throws( () => blockWithInvalidHeader.validateBlobTransactions(parentHeader), - 'block dataGasUsed mismatch', + 'block blobGasUsed mismatch', undefined, - 'throws with correct error message when tx maxFeePerDataGas less than block data gas fee' + 'throws with correct error message when tx maxFeePerblobGas less than block blob gas fee' ) assert.throws( () => blockWithInvalidTx.validateBlobTransactions(parentHeader), - 'than block data gas price', + 'than block blob gas price', undefined, - 'throws with correct error message when tx maxFeePerDataGas less than block data gas fee' + 'throws with correct error message when tx maxFeePerblobGas less than block blob gas fee' ) assert.throws( () => blockWithInvalidTx.validateBlobTransactions(parentHeader), - 'than block data gas price', + 'than block blob gas price', undefined, - 'throws with correct error message when tx maxFeePerDataGas less than block data gas fee' + 'throws with correct error message when tx maxFeePerblobGas less than block blob gas fee' ) assert.throws( () => blockWithTooManyBlobs.validateBlobTransactions(parentHeader), - 'exceed maximum data gas per block', + 'exceed maximum blob gas per block', undefined, - 'throws with correct error message when tx maxFeePerDataGas less than block data gas fee' + 'throws with correct error message when tx maxFeePerblobGas less than block blob gas fee' ) assert.ok( blockWithTooManyBlobs .getTransactionsValidationErrors() .join(' ') - .includes('exceed maximum data gas per block'), + .includes('exceed maximum blob gas per block'), 'tx erros includes correct error message when too many blobs in a block' ) } diff --git a/packages/block/test/from-beacon-payload.spec.ts b/packages/block/test/from-beacon-payload.spec.ts index dba26f3db9..4476585b63 100644 --- a/packages/block/test/from-beacon-payload.spec.ts +++ b/packages/block/test/from-beacon-payload.spec.ts @@ -21,7 +21,7 @@ describe('[fromExecutionPayloadJson]: 4844 devnet 5', () => { try { const block = await Block.fromBeaconPayloadJson(payload, { common }) const parentHeader = BlockHeader.fromHeaderData( - { excessDataGas: BigInt(0), dataGasUsed: block.header.excessDataGas! + BigInt(393216) }, + { excessBlobGas: BigInt(0), blobGasUsed: block.header.excessBlobGas! + BigInt(393216) }, { common } ) block.validateBlobTransactions(parentHeader) @@ -46,9 +46,9 @@ describe('[fromExecutionPayloadJson]: 4844 devnet 5', () => { } }) - it('should validate excess data gas', async () => { + it('should validate excess blob gas', async () => { try { - // construct a payload with a different excess data gas but matching hash + // construct a payload with a different excess blob gas but matching hash const block = await Block.fromBeaconPayloadJson( { ...payload87475, @@ -56,12 +56,12 @@ describe('[fromExecutionPayloadJson]: 4844 devnet 5', () => { }, { common } ) - const parentHeader = BlockHeader.fromHeaderData({ excessDataGas: BigInt(0) }, { common }) + const parentHeader = BlockHeader.fromHeaderData({ excessBlobGas: BigInt(0) }, { common }) block.validateBlobTransactions(parentHeader) assert.fail(`should have failed constructing the block`) } catch (e) { assert.ok(true, `correctly failed constructing block, error: ${e}`) - assert.ok(`${e}`.includes('block excessDataGas mismatch'), 'failed with correct error') + assert.ok(`${e}`.includes('block excessBlobGas mismatch'), 'failed with correct error') } }) }) diff --git a/packages/block/test/testdata/payload-slot-87335.json b/packages/block/test/testdata/payload-slot-87335.json index ffdcc9839d..78716c7b92 100644 --- a/packages/block/test/testdata/payload-slot-87335.json +++ b/packages/block/test/testdata/payload-slot-87335.json @@ -19,7 +19,7 @@ "0x03f897850120b996ed80840bebc200843b9aca078303345094c8d369b164361a8961286cfbab3bc10f962185a88080c08411e1a300e1a0011df88a2971c8a7ac494a7ba37ec1acaa1fc1edeeb38c839b5d1693d47b69b080a032f122f06e5802224db4c8a58fd22c75173a713f63f89936f811c144b9e40129a043a2a872cbfa5727007adf6a48febe5f190d2e4cd5ed6122823fb6ff47ecda32" ], "withdrawals": [], - "excess_data_gas": "262144", - "data_gas_used": "524288", + "excess_blob_gas": "262144", + "blob_gas_used": "524288", "parent_beacon_block_root": "0x1344ac29ccbab1c5208e04edf83d897b9679143cda921caf9959d4e7547267ea" } diff --git a/packages/block/test/testdata/payload-slot-87475.json b/packages/block/test/testdata/payload-slot-87475.json index ea345e7ee1..affb78e545 100644 --- a/packages/block/test/testdata/payload-slot-87475.json +++ b/packages/block/test/testdata/payload-slot-87475.json @@ -19,7 +19,7 @@ "0x03f8dc850120b996ed06841dcd6500843b9aca0783033450948a185c5a7941b20253a2923690dd54a9e7bfd0a980b844a8d55bda000000000000000000000000573d9cd570267bb9d1547192e51e5c8d017d70340000000000000000000000000000000000000000000000000000000000000000c08411e1a300e1a0011df88a2971c8a7ac494a7ba37ec1acaa1fc1edeeb38c839b5d1693d47b69b001a0f6e51ba86726dad6fe6e07f97b90c94ab79251ba2b1f900cb794dcc513d65952a02babf887931c21d86caf54a044803109023041bb9db1e1d5884b06ae52881793" ], "withdrawals": [], - "excess_data_gas": "131072", - "data_gas_used": "393216", + "excess_blob_gas": "131072", + "blob_gas_used": "393216", "parent_beacon_block_root": "0xc76b6a3716175e2d3f03d63eb75ddba0868d24a369d95416c49229c46a3370fe" } diff --git a/packages/blockchain/src/blockchain.ts b/packages/blockchain/src/blockchain.ts index 0bd3a6c299..0cc0c37b41 100644 --- a/packages/blockchain/src/blockchain.ts +++ b/packages/blockchain/src/blockchain.ts @@ -612,9 +612,9 @@ export class Blockchain implements BlockchainInterface { } if (header.common.isActivatedEIP(4844) === true) { - const expectedExcessDataGas = parentHeader.calcNextExcessDataGas() - if (header.excessDataGas !== expectedExcessDataGas) { - throw new Error(`expected data gas: ${expectedExcessDataGas}, got: ${header.excessDataGas}`) + const expectedExcessBlobGas = parentHeader.calcNextExcessBlobGas() + if (header.excessBlobGas !== expectedExcessBlobGas) { + throw new Error(`expected blob gas: ${expectedExcessBlobGas}, got: ${header.excessBlobGas}`) } } } diff --git a/packages/client/devnets/4844-interop/tools/txGenerator.ts b/packages/client/devnets/4844-interop/tools/txGenerator.ts index 41b65df817..4212b3a0d4 100644 --- a/packages/client/devnets/4844-interop/tools/txGenerator.ts +++ b/packages/client/devnets/4844-interop/tools/txGenerator.ts @@ -48,7 +48,7 @@ async function run(data: any) { blobs, kzgCommitments: commitments, versionedHashes: hashes, - maxFeePerDataGas: undefined, + maxFeePerblobGas: undefined, maxPriorityFeePerGas: undefined, maxFeePerGas: undefined, nonce: undefined, @@ -57,7 +57,7 @@ async function run(data: any) { txData.maxFeePerGas = BigInt(1000000000) txData.maxPriorityFeePerGas = BigInt(100000000) - txData.maxFeePerDataGas = BigInt(1000) + txData.maxFeePerblobGas = BigInt(1000) txData.gasLimit = BigInt(28000000) const nonce = await getNonce(client, sender.toString()) txData.nonce = BigInt(nonce) diff --git a/packages/client/src/miner/pendingBlock.ts b/packages/client/src/miner/pendingBlock.ts index 51627bee9e..7394c3f2b1 100644 --- a/packages/client/src/miner/pendingBlock.ts +++ b/packages/client/src/miner/pendingBlock.ts @@ -141,7 +141,7 @@ export class PendingBlock { const builder = await vm.buildBlock({ parentBlock, - // excessDataGas will be correctly calculated and set in buildBlock constructor, + // excessBlobGas will be correctly calculated and set in buildBlock constructor, // unless already explicity provided in headerData headerData: { ...headerData, @@ -161,9 +161,9 @@ export class PendingBlock { // Get if and how many blobs are allowed in the tx let allowedBlobs if (vm.common.isActivatedEIP(4844)) { - const dataGasLimit = vm.common.param('gasConfig', 'maxDataGasPerBlock') - const dataGasPerBlob = vm.common.param('gasConfig', 'dataGasPerBlob') - allowedBlobs = Number(dataGasLimit / dataGasPerBlob) + const blobGasLimit = vm.common.param('gasConfig', 'maxblobGasPerBlock') + const blobGasPerBlob = vm.common.param('gasConfig', 'blobGasPerBlob') + allowedBlobs = Number(blobGasLimit / blobGasPerBlob) } else { allowedBlobs = 0 } @@ -225,9 +225,9 @@ export class PendingBlock { let allowedBlobs if (vm.common.isActivatedEIP(4844)) { const bundle = this.blobsBundles.get(payloadId) ?? { blobs: [], commitments: [], proofs: [] } - const dataGasLimit = vm.common.param('gasConfig', 'maxDataGasPerBlock') - const dataGasPerBlob = vm.common.param('gasConfig', 'dataGasPerBlob') - allowedBlobs = Number(dataGasLimit / dataGasPerBlob) - bundle.blobs.length + const blobGasLimit = vm.common.param('gasConfig', 'maxblobGasPerBlock') + const blobGasPerBlob = vm.common.param('gasConfig', 'blobGasPerBlob') + allowedBlobs = Number(blobGasLimit / blobGasPerBlob) - bundle.blobs.length } else { allowedBlobs = 0 } diff --git a/packages/client/src/rpc/helpers.ts b/packages/client/src/rpc/helpers.ts index 89af843ca1..ddfe6dc8a9 100644 --- a/packages/client/src/rpc/helpers.ts +++ b/packages/client/src/rpc/helpers.ts @@ -31,7 +31,7 @@ export const jsonRpcTx = (tx: TypedTransaction, block?: Block, txIndex?: number) v: txJSON.v!, r: txJSON.r!, s: txJSON.s!, - maxFeePerDataGas: txJSON.maxFeePerDataGas, + maxFeePerblobGas: txJSON.maxFeePerblobGas, versionedHashes: txJSON.versionedHashes, } } diff --git a/packages/client/src/rpc/modules/engine.ts b/packages/client/src/rpc/modules/engine.ts index 931a9e6d45..ee61ae4580 100644 --- a/packages/client/src/rpc/modules/engine.ts +++ b/packages/client/src/rpc/modules/engine.ts @@ -51,7 +51,7 @@ type WithdrawalV1 = Exclude[number] export type ExecutionPayloadV1 = ExecutionPayload export type ExecutionPayloadV2 = ExecutionPayloadV1 & { withdrawals: WithdrawalV1[] } // parentBeaconBlockRoot comes separate in new payloads and needs to be added to payload data -export type ExecutionPayloadV3 = ExecutionPayloadV2 & { excessDataGas: Uint64; dataGasUsed: Uint64 } +export type ExecutionPayloadV3 = ExecutionPayloadV2 & { excessBlobGas: Uint64; blobGasUsed: Uint64 } export type ForkchoiceStateV1 = { headBlockHash: Bytes32 @@ -130,8 +130,8 @@ const executionPayloadV2FieldValidators = { } const executionPayloadV3FieldValidators = { ...executionPayloadV2FieldValidators, - dataGasUsed: validators.uint64, - excessDataGas: validators.uint64, + blobGasUsed: validators.uint64, + excessBlobGas: validators.uint64, } const forkchoiceFieldValidators = { @@ -183,8 +183,8 @@ export const blockToExecutionPayload = (block: Block, value: bigint, bundle?: Bl timestamp: header.timestamp!, extraData: header.extraData!, baseFeePerGas: header.baseFeePerGas!, - dataGasUsed: header.dataGasUsed, - excessDataGas: header.excessDataGas, + blobGasUsed: header.blobGasUsed, + excessBlobGas: header.excessBlobGas, blockHash: bytesToHex(block.hash()), prevRandao: header.mixHash!, transactions, diff --git a/packages/client/src/rpc/modules/eth.ts b/packages/client/src/rpc/modules/eth.ts index 2068cc8f74..7a33acae30 100644 --- a/packages/client/src/rpc/modules/eth.ts +++ b/packages/client/src/rpc/modules/eth.ts @@ -68,8 +68,8 @@ type JsonRpcReceipt = { // It also returns either: root?: string // DATA, 32 bytes of post-transaction stateroot (pre Byzantium) status?: string // QUANTITY, either 1 (success) or 0 (failure) - dataGasUsed?: string // QUANTITY, data gas consumed by transaction (if blob transaction) - dataGasPrice?: string // QUAntity, data gas price for block including this transaction (if blob transaction) + blobGasUsed?: string // QUANTITY, blob gas consumed by transaction (if blob transaction) + blobGasPrice?: string // QUAntity, blob gas price for block including this transaction (if blob transaction) } type JsonRpcLog = { removed: boolean // TAG - true when the log was removed, due to a chain reorganization. false if it's a valid log. @@ -129,8 +129,8 @@ const jsonRpcBlock = async ( uncles: block.uncleHeaders.map((uh) => bytesToHex(uh.hash())), baseFeePerGas: header.baseFeePerGas, ...withdrawalsAttr, - dataGasUsed: header.dataGasUsed, - excessDataGas: header.excessDataGas, + blobGasUsed: header.blobGasUsed, + excessBlobGas: header.excessBlobGas, } } @@ -167,8 +167,8 @@ const jsonRpcReceipt = async ( txIndex: number, logIndex: number, contractAddress?: Address, - dataGasUsed?: bigint, - dataGasPrice?: bigint + blobGasUsed?: bigint, + blobGasPrice?: bigint ): Promise => ({ transactionHash: bytesToHex(tx.hash()), transactionIndex: intToHex(txIndex), @@ -192,8 +192,8 @@ const jsonRpcReceipt = async ( ((receipt as PostByzantiumTxReceipt).status as unknown) instanceof Uint8Array ? intToHex((receipt as PostByzantiumTxReceipt).status) : undefined, - dataGasUsed: dataGasUsed !== undefined ? bigIntToHex(dataGasUsed) : undefined, - dataGasPrice: dataGasPrice !== undefined ? bigIntToHex(dataGasPrice) : undefined, + blobGasUsed: blobGasUsed !== undefined ? bigIntToHex(blobGasUsed) : undefined, + blobGasPrice: blobGasPrice !== undefined ? bigIntToHex(blobGasPrice) : undefined, }) /** @@ -747,7 +747,7 @@ export class Eth { }) const { totalGasSpent, createdAddress } = runBlockResult.results[txIndex] - const { dataGasPrice, dataGasUsed } = runBlockResult.receipts[txIndex] as EIP4844BlobTxReceipt + const { blobGasPrice, blobGasUsed } = runBlockResult.receipts[txIndex] as EIP4844BlobTxReceipt return await jsonRpcReceipt( receipt, totalGasSpent, @@ -757,8 +757,8 @@ export class Eth { txIndex, logIndex, createdAddress, - dataGasUsed, - dataGasPrice + blobGasUsed, + blobGasPrice ) } catch (error: any) { throw { @@ -898,13 +898,13 @@ export class Eth { // Blob Transactions sent over RPC are expected to be in Network Wrapper format tx = BlobEIP4844Transaction.fromSerializedBlobTxNetworkWrapper(txBuf, { common }) - const dataGasLimit = common.param('gasConfig', 'maxDataGasPerBlock') - const dataGasPerBlob = common.param('gasConfig', 'dataGasPerBlob') + const blobGasLimit = common.param('gasConfig', 'maxblobGasPerBlock') + const blobGasPerBlob = common.param('gasConfig', 'blobGasPerBlob') - if (BigInt((tx.blobs ?? []).length) * dataGasPerBlob > dataGasLimit) { + if (BigInt((tx.blobs ?? []).length) * blobGasPerBlob > blobGasLimit) { throw Error( `tx blobs=${(tx.blobs ?? []).length} exceeds block limit=${ - dataGasLimit / dataGasPerBlob + blobGasLimit / blobGasPerBlob }` ) } diff --git a/packages/client/src/rpc/util/CLConnectionManager.ts b/packages/client/src/rpc/util/CLConnectionManager.ts index 7819ce50f1..e276787af5 100644 --- a/packages/client/src/rpc/util/CLConnectionManager.ts +++ b/packages/client/src/rpc/util/CLConnectionManager.ts @@ -157,9 +157,9 @@ export class CLConnectionManager { if ('withdrawals' in payload.payload && payload.payload.withdrawals !== null) { msg += ` withdrawals=${(payload.payload as ExecutionPayloadV2).withdrawals.length}` } - if ('excessDataGas' in payload.payload && payload.payload.excessDataGas !== null) { - msg += ` dataGasUsed=${(payload.payload as ExecutionPayloadV3).dataGasUsed} excessDataGas=${ - (payload.payload as ExecutionPayloadV3).excessDataGas + if ('excessBlobGas' in payload.payload && payload.payload.excessBlobGas !== null) { + msg += ` blobGasUsed=${(payload.payload as ExecutionPayloadV3).blobGasUsed} excessBlobGas=${ + (payload.payload as ExecutionPayloadV3).excessBlobGas }` } return msg diff --git a/packages/client/src/service/txpool.ts b/packages/client/src/service/txpool.ts index 051735455e..ca1098ff24 100644 --- a/packages/client/src/service/txpool.ts +++ b/packages/client/src/service/txpool.ts @@ -245,12 +245,12 @@ export class TxPool { } if (addedTx instanceof BlobEIP4844Transaction && existingTx instanceof BlobEIP4844Transaction) { - const minDataGasFee = - (existingTx.maxFeePerDataGas * - (existingTx.maxFeePerDataGas * BigInt(MIN_GAS_PRICE_BUMP_PERCENT))) / + const minblobGasFee = + (existingTx.maxFeePerblobGas * + (existingTx.maxFeePerblobGas * BigInt(MIN_GAS_PRICE_BUMP_PERCENT))) / BigInt(100) - if (addedTx.maxFeePerDataGas < minDataGasFee) { - throw new Error('replacement data gas too low') + if (addedTx.maxFeePerblobGas < minblobGasFee) { + throw new Error('replacement blob gas too low') } } } diff --git a/packages/client/test/miner/pendingBlock.spec.ts b/packages/client/test/miner/pendingBlock.spec.ts index 6f47980e4f..5ce3350b65 100644 --- a/packages/client/test/miner/pendingBlock.spec.ts +++ b/packages/client/test/miner/pendingBlock.spec.ts @@ -373,7 +373,7 @@ describe('[PendingBlock]', async () => { blobs: [...blobs, ...blobs, ...blobs], kzgCommitments: [...commitments, ...commitments, ...commitments], kzgProofs: [...proofs, ...proofs, ...proofs], - maxFeePerDataGas: 100000000n, + maxFeePerblobGas: 100000000n, gasLimit: 0xffffffn, maxFeePerGas: 1000000000n, maxPriorityFeePerGas: 100000000n, @@ -446,7 +446,7 @@ describe('[PendingBlock]', async () => { versionedHashes, kzgCommitments: commitments, kzgProofs: proofs, - maxFeePerDataGas: 100000000n, + maxFeePerblobGas: 100000000n, gasLimit: 0xffffffn, maxFeePerGas: 1000000000n, maxPriorityFeePerGas: 100000000n, diff --git a/packages/client/test/rpc/engine/getPayloadBodiesByHashV1.spec.ts b/packages/client/test/rpc/engine/getPayloadBodiesByHashV1.spec.ts index 6a488499d6..54889a7b95 100644 --- a/packages/client/test/rpc/engine/getPayloadBodiesByHashV1.spec.ts +++ b/packages/client/test/rpc/engine/getPayloadBodiesByHashV1.spec.ts @@ -51,7 +51,7 @@ describe(method, () => { const tx = TransactionFactory.fromTxData( { type: 0x01, - maxFeePerDataGas: 1n, + maxFeePerblobGas: 1n, maxFeePerGas: 10000000000n, maxPriorityFeePerGas: 100000000n, gasLimit: 30000000n, @@ -61,7 +61,7 @@ describe(method, () => { const tx2 = TransactionFactory.fromTxData( { type: 0x01, - maxFeePerDataGas: 1n, + maxFeePerblobGas: 1n, maxFeePerGas: 10000000000n, maxPriorityFeePerGas: 100000000n, gasLimit: 30000000n, @@ -141,7 +141,7 @@ describe(method, () => { const tx = TransactionFactory.fromTxData( { type: 0x01, - maxFeePerDataGas: 1n, + maxFeePerblobGas: 1n, maxFeePerGas: 10000000000n, maxPriorityFeePerGas: 100000000n, gasLimit: 30000000n, @@ -151,7 +151,7 @@ describe(method, () => { const tx2 = TransactionFactory.fromTxData( { type: 0x01, - maxFeePerDataGas: 1n, + maxFeePerblobGas: 1n, maxFeePerGas: 10000000000n, maxPriorityFeePerGas: 100000000n, gasLimit: 30000000n, diff --git a/packages/client/test/rpc/engine/getPayloadBodiesByRangeV1.spec.ts b/packages/client/test/rpc/engine/getPayloadBodiesByRangeV1.spec.ts index c71ed0e9b0..da19f15461 100644 --- a/packages/client/test/rpc/engine/getPayloadBodiesByRangeV1.spec.ts +++ b/packages/client/test/rpc/engine/getPayloadBodiesByRangeV1.spec.ts @@ -56,7 +56,7 @@ describe(method, () => { const tx = TransactionFactory.fromTxData( { type: 0x01, - maxFeePerDataGas: 1n, + maxFeePerblobGas: 1n, maxFeePerGas: 10000000000n, maxPriorityFeePerGas: 100000000n, gasLimit: 30000000n, @@ -66,7 +66,7 @@ describe(method, () => { const tx2 = TransactionFactory.fromTxData( { type: 0x01, - maxFeePerDataGas: 1n, + maxFeePerblobGas: 1n, maxFeePerGas: 10000000000n, maxPriorityFeePerGas: 100000000n, gasLimit: 30000000n, @@ -149,7 +149,7 @@ describe(method, () => { const tx = TransactionFactory.fromTxData( { type: 0x01, - maxFeePerDataGas: 1n, + maxFeePerblobGas: 1n, maxFeePerGas: 10000000000n, maxPriorityFeePerGas: 100000000n, gasLimit: 30000000n, @@ -159,7 +159,7 @@ describe(method, () => { const tx2 = TransactionFactory.fromTxData( { type: 0x01, - maxFeePerDataGas: 1n, + maxFeePerblobGas: 1n, maxFeePerGas: 10000000000n, maxPriorityFeePerGas: 100000000n, gasLimit: 30000000n, diff --git a/packages/client/test/rpc/engine/getPayloadV3.spec.ts b/packages/client/test/rpc/engine/getPayloadV3.spec.ts index cc2a56c562..a248df1a70 100644 --- a/packages/client/test/rpc/engine/getPayloadV3.spec.ts +++ b/packages/client/test/rpc/engine/getPayloadV3.spec.ts @@ -109,7 +109,7 @@ describe(method, () => { blobs: txBlobs, kzgCommitments: txCommitments, kzgProofs: txProofs, - maxFeePerDataGas: 1n, + maxFeePerblobGas: 1n, maxFeePerGas: 10000000000n, maxPriorityFeePerGas: 100000000n, gasLimit: 30000000n, @@ -127,8 +127,8 @@ describe(method, () => { '0x0a4f946a9dac3f6d2b86d02dfa6cf221b4fe72bbaff51b50cee4c5784156dd52', 'built expected block' ) - assert.equal(executionPayload.excessDataGas, '0x0', 'correct execess data gas') - assert.equal(executionPayload.dataGasUsed, '0x20000', 'correct data gas used') + assert.equal(executionPayload.excessBlobGas, '0x0', 'correct execess blob gas') + assert.equal(executionPayload.blobGasUsed, '0x20000', 'correct blob gas used') const { commitments, proofs, blobs } = blobsBundle assert.ok( commitments.length === proofs.length && commitments.length === blobs.length, diff --git a/packages/client/test/rpc/engine/newPayloadV3.spec.ts b/packages/client/test/rpc/engine/newPayloadV3.spec.ts index 88510545e5..ff49e763b8 100644 --- a/packages/client/test/rpc/engine/newPayloadV3.spec.ts +++ b/packages/client/test/rpc/engine/newPayloadV3.spec.ts @@ -36,8 +36,8 @@ describe(`${method}: call with executionPayloadV3`, () => { const validBlock = { ...blockData, withdrawals: [], - dataGasUsed: '0x0', - excessDataGas: '0x0', + blobGasUsed: '0x0', + excessBlobGas: '0x0', } const req = params(method, [validBlock, [], parentBeaconBlockRoot]) @@ -61,8 +61,8 @@ describe(`${method}: call with executionPayloadV3`, () => { ...blockData, timestamp: bigIntToHex(BigInt(cancunTime)), withdrawals: [], - dataGasUsed: '0x0', - excessDataGas: '0x0', + blobGasUsed: '0x0', + excessBlobGas: '0x0', blockHash: '0x6ec6f32e6931199f8f84faf46a59bc9a1e65a23aa73ca21278b5cb48aa2d059d', stateRoot: '0x454a9db6943b17a5f88aea507d0c3f4420d533d143b4eb5194cc7589d721b024', } diff --git a/packages/client/test/rpc/engine/newPayloadV3VersionedHashes.spec.ts b/packages/client/test/rpc/engine/newPayloadV3VersionedHashes.spec.ts index 1b3257cb72..6e236ba517 100644 --- a/packages/client/test/rpc/engine/newPayloadV3VersionedHashes.spec.ts +++ b/packages/client/test/rpc/engine/newPayloadV3VersionedHashes.spec.ts @@ -12,7 +12,7 @@ import type { HttpServer } from 'jayson' const method = 'engine_newPayloadV3' -// blocks are missing excessDataGas and dataGasUsed which will be set to default 0 for 4844 blocks +// blocks are missing excessBlobGas and blobGasUsed which will be set to default 0 for 4844 blocks // however its not required to set to correct value to test for versioned hashes test cases const [blockData] = blocks @@ -40,8 +40,8 @@ describe(`${method}: Cancun validations`, () => { parentHash: '0x2559e851470f6e7bbed1db474980683e8c315bfce99b2a6ef47c057c04de7858', blockHash: '0xb8b9607bd09f0c18bccfa4dcb6fe355f07d383c902f0fc2a1671cf20792e131c', withdrawals: [], - dataGasUsed: '0x0', - excessDataGas: '0x0', + blobGasUsed: '0x0', + excessBlobGas: '0x0', }, // versioned hashes ['0x3434', '0x2334'], @@ -72,8 +72,8 @@ describe(`${method}: Cancun validations`, () => { // two blob transactions but no versioned hashes transactions: [txString, txString], withdrawals: [], - dataGasUsed: '0x40000', - excessDataGas: '0x0', + blobGasUsed: '0x40000', + excessBlobGas: '0x0', }, ] req = params(method, blockDataNoneHashes) @@ -88,8 +88,8 @@ describe(`${method}: Cancun validations`, () => { // two blob transactions but no versioned hashes transactions: [txString, txString], withdrawals: [], - dataGasUsed: '0x40000', - excessDataGas: '0x0', + blobGasUsed: '0x40000', + excessBlobGas: '0x0', }, txVersionedHashesString, ] @@ -106,8 +106,8 @@ describe(`${method}: Cancun validations`, () => { parentHash: '0x2559e851470f6e7bbed1db474980683e8c315bfce99b2a6ef47c057c04de7858', blockHash: '0xeea272bb9ac158550c645a1b0666727a5fefa4a865f8d4c642a87143d2abef39', withdrawals: [], - dataGasUsed: '0x40000', - excessDataGas: '0x0', + blobGasUsed: '0x40000', + excessBlobGas: '0x0', // two blob transactions but missing versioned hash of second transactions: [txString, txString], }, @@ -130,8 +130,8 @@ describe(`${method}: Cancun validations`, () => { parentHash: '0x2559e851470f6e7bbed1db474980683e8c315bfce99b2a6ef47c057c04de7858', blockHash: '0xeea272bb9ac158550c645a1b0666727a5fefa4a865f8d4c642a87143d2abef39', withdrawals: [], - dataGasUsed: '0x40000', - excessDataGas: '0x0', + blobGasUsed: '0x40000', + excessBlobGas: '0x0', // two blob transactions but mismatching versioned hash of second transactions: [txString, txString], }, @@ -154,8 +154,8 @@ describe(`${method}: Cancun validations`, () => { parentHash: '0x2559e851470f6e7bbed1db474980683e8c315bfce99b2a6ef47c057c04de7858', blockHash: '0xeea272bb9ac158550c645a1b0666727a5fefa4a865f8d4c642a87143d2abef39', withdrawals: [], - dataGasUsed: '0x40000', - excessDataGas: '0x0', + blobGasUsed: '0x40000', + excessBlobGas: '0x0', // two blob transactions with matching versioned hashes transactions: [txString, txString], }, diff --git a/packages/client/test/rpc/eth/getTransactionReceipt.spec.ts b/packages/client/test/rpc/eth/getTransactionReceipt.spec.ts index a7fb4dfaa1..a52115b615 100644 --- a/packages/client/test/rpc/eth/getTransactionReceipt.spec.ts +++ b/packages/client/test/rpc/eth/getTransactionReceipt.spec.ts @@ -94,7 +94,7 @@ describe(method, () => { await baseRequest(server, req, 200, expectRes) }) - it('get dataGasUsed/dataGasPrice in blob tx receipt', async () => { + it('get blobGasUsed/blobGasPrice in blob tx receipt', async () => { const isBrowser = new Function('try {return this===window;}catch(e){ return false;}') if (isBrowser() === true) { assert.ok(true) @@ -122,7 +122,7 @@ describe(method, () => { blobs, kzgCommitments: commitments, kzgProofs: proofs, - maxFeePerDataGas: 1000000n, + maxFeePerblobGas: 1000000n, gasLimit: 0xffffn, maxFeePerGas: 10000000n, maxPriorityFeePerGas: 1000000n, @@ -136,8 +136,8 @@ describe(method, () => { const req = params(method, [bytesToHex(tx.hash())]) const expectRes = (res: any) => { - assert.equal(res.body.result.dataGasUsed, '0x20000', 'receipt has correct data gas usage') - assert.equal(res.body.result.dataGasPrice, '0x1', 'receipt has correct data gas price') + assert.equal(res.body.result.blobGasUsed, '0x20000', 'receipt has correct blob gas usage') + assert.equal(res.body.result.blobGasPrice, '0x1', 'receipt has correct blob gas price') } await baseRequest(server, req, 200, expectRes) diff --git a/packages/client/test/rpc/eth/sendRawTransaction.spec.ts b/packages/client/test/rpc/eth/sendRawTransaction.spec.ts index 5ace09d87d..52761b6346 100644 --- a/packages/client/test/rpc/eth/sendRawTransaction.spec.ts +++ b/packages/client/test/rpc/eth/sendRawTransaction.spec.ts @@ -249,7 +249,7 @@ describe(method, () => { blobs, kzgCommitments: commitments, kzgProofs: proofs, - maxFeePerDataGas: 1000000n, + maxFeePerblobGas: 1000000n, gasLimit: 0xffffn, maxFeePerGas: 10000000n, maxPriorityFeePerGas: 1000000n, @@ -264,7 +264,7 @@ describe(method, () => { blobs, kzgCommitments: commitments, kzgProofs: proofs, - maxFeePerDataGas: 1000000n, + maxFeePerblobGas: 1000000n, gasLimit: 0xfffffn, maxFeePerGas: 100000000n, maxPriorityFeePerGas: 10000000n, @@ -284,7 +284,7 @@ describe(method, () => { assert.equal(res.body.error, undefined, 'initial blob transaction accepted') } - const expectRes2 = checkError(INVALID_PARAMS, 'replacement data gas too low') + const expectRes2 = checkError(INVALID_PARAMS, 'replacement blob gas too low') await baseRequest(server, req, 200, expectRes, false) await baseRequest(server, req2, 200, expectRes2) diff --git a/packages/client/test/sim/4844devnet5.spec.ts b/packages/client/test/sim/4844devnet5.spec.ts index d6da94fe1e..64440d6a99 100644 --- a/packages/client/test/sim/4844devnet5.spec.ts +++ b/packages/client/test/sim/4844devnet5.spec.ts @@ -76,7 +76,7 @@ describe(`running txes on ${rpcUrl}`, async () => { { to: bytesToHex(randomBytes(20)), chainId, - maxFeePerDataGas: BigInt(process.env.MAX_DATAFEE ?? 100000000n), + maxFeePerblobGas: BigInt(process.env.MAX_DATAFEE ?? 100000000n), maxPriorityFeePerGas: BigInt(process.env.MAX_PRIORITY ?? 100000000n), maxFeePerGas: BigInt(process.env.MAX_FEE ?? 1000000000n), gasLimit: BigInt(process.env.GAS_LIMIT ?? 0xffffffn), diff --git a/packages/client/test/sim/sharding.spec.ts b/packages/client/test/sim/sharding.spec.ts index 06f3c7a9de..16259af0b3 100644 --- a/packages/client/test/sim/sharding.spec.ts +++ b/packages/client/test/sim/sharding.spec.ts @@ -100,7 +100,7 @@ describe('sharding/eip4844 hardfork tests', async () => { ) }) - it('data gas fee market tests', async () => { + it('blob gas fee market tests', async () => { const txns = await createBlobTxs( 4, 4096, @@ -110,7 +110,7 @@ describe('sharding/eip4844 hardfork tests', async () => { { to: bytesToHex(randomBytes(20)), chainId: 1, - maxFeePerDataGas: BigInt(1000) as any, + maxFeePerblobGas: BigInt(1000) as any, maxPriorityFeePerGas: BigInt(1) as any, maxFeePerGas: '0xff' as any, gasLimit: BigInt(1000000) as any, @@ -136,7 +136,7 @@ describe('sharding/eip4844 hardfork tests', async () => { [txReceipt.result.blockHash, false], 2.0 ) - assert.ok(BigInt(block1.result.excessDataGas) > 0n, 'block1 has excess data gas > 0') + assert.ok(BigInt(block1.result.excessBlobGas) > 0n, 'block1 has excess blob gas > 0') }) it('point precompile contract test', async () => { diff --git a/packages/client/test/sim/simutils.ts b/packages/client/test/sim/simutils.ts index 9fce1c0b73..90b917e39b 100644 --- a/packages/client/test/sim/simutils.ts +++ b/packages/client/test/sim/simutils.ts @@ -311,7 +311,7 @@ export const runBlobTx = async ( kzgCommitments: commitments, kzgProofs: proofs, versionedHashes: hashes, - maxFeePerDataGas: undefined, + maxFeePerblobGas: undefined, maxPriorityFeePerGas: undefined, maxFeePerGas: undefined, nonce: undefined, @@ -321,7 +321,7 @@ export const runBlobTx = async ( txData.maxFeePerGas = '0xff' txData.maxPriorityFeePerGas = BigInt(1) - txData.maxFeePerDataGas = BigInt(1000) + txData.maxFeePerblobGas = BigInt(1000) txData.gasLimit = BigInt(1000000) const nonce = await client.request('eth_getTransactionCount', [sender.toString(), 'latest'], 2.0) txData.nonce = BigInt(nonce.result) @@ -357,7 +357,7 @@ export const createBlobTxs = async ( to?: string value?: bigint chainId?: number - maxFeePerDataGas: bigint + maxFeePerblobGas: bigint maxPriorityFeePerGas: bigint maxFeePerGas: bigint gasLimit: bigint diff --git a/packages/client/test/sim/txGenerator.ts b/packages/client/test/sim/txGenerator.ts index b098b7d41f..b814b3187a 100644 --- a/packages/client/test/sim/txGenerator.ts +++ b/packages/client/test/sim/txGenerator.ts @@ -107,7 +107,7 @@ async function run(data: any) { blobs, kzgCommitments: commitments, versionedHashes: hashes, - maxFeePerDataGas: undefined, + maxFeePerblobGas: undefined, maxPriorityFeePerGas: undefined, maxFeePerGas: undefined, nonce: undefined, @@ -116,7 +116,7 @@ async function run(data: any) { txData.maxFeePerGas = BigInt(1000000000) txData.maxPriorityFeePerGas = BigInt(100000000) - txData.maxFeePerDataGas = BigInt(1000) + txData.maxFeePerblobGas = BigInt(1000) txData.gasLimit = BigInt(28000000) const nonce = await getNonce(client, sender.toString()) txData.nonce = BigInt(nonce) diff --git a/packages/common/src/eips.ts b/packages/common/src/eips.ts index 39df407a47..896a232cff 100644 --- a/packages/common/src/eips.ts +++ b/packages/common/src/eips.ts @@ -390,21 +390,21 @@ export const EIPs: EIPsDict = { minimumHardfork: Hardfork.Paris, requiredEIPs: [1559, 2718, 2930, 4895], gasConfig: { - dataGasPerBlob: { + blobGasPerBlob: { v: 131072, - d: 'The base fee for data gas per blob', + d: 'The base fee for blob gas per blob', }, - targetDataGasPerBlock: { + targetBlobGasPerBlock: { v: 393216, - d: 'The target data gas consumed per block', + d: 'The target blob gas consumed per block', }, - maxDataGasPerBlock: { + maxblobGasPerBlock: { v: 786432, - d: 'The max data gas allowable per block', + d: 'The max blob gas allowable per block', }, - dataGasPriceUpdateFraction: { + blobGasPriceUpdateFraction: { v: 3338477, - d: 'The denominator used in the exponential when calculating a data gas price', + d: 'The denominator used in the exponential when calculating a blob gas price', }, }, gasPrices: { @@ -412,9 +412,9 @@ export const EIPs: EIPsDict = { v: 12000, d: 'The basic gas fee for each blob', }, - minDataGasPrice: { + minBlobGasPrice: { v: 1, - d: 'The minimum fee per data gas', + d: 'The minimum fee per blob gas', }, kzgPointEvaluationGasPrecompilePrice: { v: 50000, diff --git a/packages/common/src/types.ts b/packages/common/src/types.ts index a5f6435a24..c882be2bc4 100644 --- a/packages/common/src/types.ts +++ b/packages/common/src/types.ts @@ -46,7 +46,7 @@ export interface GenesisBlockConfig { nonce: string extraData: string baseFeePerGas?: string - excessDataGas?: string + excessBlobGas?: string } export interface HardforkTransitionConfig { diff --git a/packages/common/src/utils.ts b/packages/common/src/utils.ts index ec3ac1a53f..8a6d0bcd05 100644 --- a/packages/common/src/utils.ts +++ b/packages/common/src/utils.ts @@ -37,7 +37,7 @@ function parseGethParams(json: any, mergeForkIdPostMerge: boolean = true) { gasLimit, coinbase, baseFeePerGas, - excessDataGas, + excessBlobGas, }: { name: string config: any @@ -46,7 +46,7 @@ function parseGethParams(json: any, mergeForkIdPostMerge: boolean = true) { gasLimit: string coinbase: string baseFeePerGas: string - excessDataGas: string + excessBlobGas: string } = json let { extraData, timestamp, nonce }: { extraData: string; timestamp: string; nonce: string } = json @@ -87,7 +87,7 @@ function parseGethParams(json: any, mergeForkIdPostMerge: boolean = true) { mixHash, coinbase, baseFeePerGas, - excessDataGas, + excessBlobGas, }, hardfork: undefined as string | undefined, hardforks: [] as ConfigHardfork[], diff --git a/packages/evm/src/types.ts b/packages/evm/src/types.ts index ced5e363c6..5cec8e597f 100644 --- a/packages/evm/src/types.ts +++ b/packages/evm/src/types.ts @@ -308,9 +308,9 @@ export interface ExecResult { */ gasRefund?: bigint /** - * Amount of data gas consumed by the transaction + * Amount of blob gas consumed by the transaction */ - dataGasUsed?: bigint + blobGasUsed?: bigint } /** diff --git a/packages/tx/README.md b/packages/tx/README.md index 8118fe511e..4966dee062 100644 --- a/packages/tx/README.md +++ b/packages/tx/README.md @@ -75,7 +75,7 @@ Hardforks adding features and/or tx types: | Hardfork | Introduced | Description | | ---------------- | ---------- | ------------------------------------------------------------------------------------------------------- | | `spuriousDragon` |  `v2.0.0` |  `EIP-155` replay protection (disable by setting HF pre-`spuriousDragon`) | -| `istanbul` |  `v2.1.1`  | Support for reduced non-zero call data gas prices ([EIP-2028](https://eips.ethereum.org/EIPS/eip-2028)) | +| `istanbul` |  `v2.1.1`  | Support for reduced non-zero call blob gas prices ([EIP-2028](https://eips.ethereum.org/EIPS/eip-2028)) | | `muirGlacier` |  `v2.1.2` |  - | | `berlin` | `v3.1.0` |  `EIP-2718` Typed Transactions, Optional Access Lists Tx Type `EIP-2930` | | `london` | `v3.2.0` | `EIP-1559` Transactions | diff --git a/packages/tx/docs/interfaces/BlobEIP4844TxData.md b/packages/tx/docs/interfaces/BlobEIP4844TxData.md index 234c5817ee..899dc6b552 100644 --- a/packages/tx/docs/interfaces/BlobEIP4844TxData.md +++ b/packages/tx/docs/interfaces/BlobEIP4844TxData.md @@ -170,7 +170,7 @@ ___ • `Optional` **maxFeePerDataGas**: `BigIntLike` -The maximum fee per data gas paid for the transaction +The maximum fee per blob gas paid for the transaction #### Defined in diff --git a/packages/tx/src/eip4844Transaction.ts b/packages/tx/src/eip4844Transaction.ts index 314dfe6acb..d378f64a8f 100644 --- a/packages/tx/src/eip4844Transaction.ts +++ b/packages/tx/src/eip4844Transaction.ts @@ -87,7 +87,7 @@ export class BlobEIP4844Transaction extends BaseTransaction toBytes(vh)) @@ -274,7 +274,7 @@ export class BlobEIP4844Transaction extends BaseTransaction bytesToHex(hash)), } } @@ -568,7 +568,7 @@ export class BlobEIP4844Transaction extends BaseTransaction { const txData = { type: 0x03, versionedHashes: [concatBytes(new Uint8Array([1]), randomBytes(31))], - maxFeePerDataGas: 1n, + maxFeePerblobGas: 1n, } const tx = BlobEIP4844Transaction.fromTxData(txData, { common }) assert.equal(tx.type, 3, 'successfully instantiated a blob transaction from txData') @@ -80,7 +80,7 @@ describe('fromTxData using from a json', () => { to: '0xffb38a7a99e3e2335be83fc74b7faa19d5531243', chainId: '0x28757b3', accessList: null, - maxFeePerDataGas: '0xb2d05e00', + maxFeePerblobGas: '0xb2d05e00', versionedHashes: ['0x01b0a4cdd5f55589f5c5b4d46c76704bb6ce95c0a8c09f77f197a57808dded28'], } const txMeta = { @@ -97,7 +97,7 @@ describe('fromTxData using from a json', () => { const tx = BlobEIP4844Transaction.fromTxData(txData, { common: c }) assert.ok(true, 'Should be able to parse a json data and hash it') - assert.equal(typeof tx.maxFeePerDataGas, 'bigint', 'should be able to parse correctly') + assert.equal(typeof tx.maxFeePerblobGas, 'bigint', 'should be able to parse correctly') assert.equal(bytesToHex(tx.serialize()), txMeta.serialized, 'serialization should match') // TODO: fix the hash assert.equal(bytesToHex(tx.hash()), txMeta.hash, 'hash should match') @@ -131,7 +131,7 @@ describe('EIP4844 constructor tests - invalid scenarios', () => { if (isBrowser() === false) { const baseTxData = { type: 0x03, - maxFeePerDataGas: 1n, + maxFeePerblobGas: 1n, } const shortVersionHash = { versionedHashes: [concatBytes(new Uint8Array([3]), randomBytes(3))], @@ -187,7 +187,7 @@ describe('Network wrapper tests', () => { blobs, kzgCommitments: commitments, kzgProofs: proofs, - maxFeePerDataGas: 100000000n, + maxFeePerblobGas: 100000000n, gasLimit: 0xffffffn, to: randomBytes(20), }, @@ -226,7 +226,7 @@ describe('Network wrapper tests', () => { const simpleBlobTx = BlobEIP4844Transaction.fromTxData( { blobsData: ['hello world'], - maxFeePerDataGas: 100000000n, + maxFeePerblobGas: 100000000n, gasLimit: 0xffffffn, to: randomBytes(20), }, @@ -245,7 +245,7 @@ describe('Network wrapper tests', () => { { blobsData: ['hello world'], blobs: ['hello world'], - maxFeePerDataGas: 100000000n, + maxFeePerblobGas: 100000000n, gasLimit: 0xffffffn, to: randomBytes(20), }, @@ -262,7 +262,7 @@ describe('Network wrapper tests', () => { { blobsData: ['hello world'], kzgCommitments: ['0xabcd'], - maxFeePerDataGas: 100000000n, + maxFeePerblobGas: 100000000n, gasLimit: 0xffffffn, to: randomBytes(20), }, @@ -279,7 +279,7 @@ describe('Network wrapper tests', () => { { blobsData: ['hello world'], versionedHashes: ['0x01cd'], - maxFeePerDataGas: 100000000n, + maxFeePerblobGas: 100000000n, gasLimit: 0xffffffn, to: randomBytes(20), }, @@ -296,7 +296,7 @@ describe('Network wrapper tests', () => { { blobsData: ['hello world'], kzgProofs: ['0x01cd'], - maxFeePerDataGas: 100000000n, + maxFeePerblobGas: 100000000n, gasLimit: 0xffffffn, to: randomBytes(20), }, @@ -313,7 +313,7 @@ describe('Network wrapper tests', () => { blobs: [], kzgCommitments: [], kzgProofs: [], - maxFeePerDataGas: 100000000n, + maxFeePerblobGas: 100000000n, gasLimit: 0xffffffn, to: randomBytes(20), }, @@ -337,7 +337,7 @@ describe('Network wrapper tests', () => { blobs: blobs.slice(1), kzgCommitments: commitments, kzgProofs: proofs, - maxFeePerDataGas: 100000000n, + maxFeePerblobGas: 100000000n, gasLimit: 0xffffffn, to: randomBytes(20), }, @@ -364,7 +364,7 @@ describe('Network wrapper tests', () => { blobs, kzgCommitments: commitments, kzgProofs: proofs, - maxFeePerDataGas: 100000000n, + maxFeePerblobGas: 100000000n, gasLimit: 0xffffffn, to: randomBytes(20), }, @@ -394,7 +394,7 @@ describe('Network wrapper tests', () => { blobs, kzgCommitments: commitments, kzgProofs: proofs, - maxFeePerDataGas: 100000000n, + maxFeePerblobGas: 100000000n, gasLimit: 0xffffffn, to: randomBytes(20), }, @@ -429,7 +429,7 @@ describe('hash() and signature verification', () => { versionedHashes: [ hexToBytes('0x01624652859a6e98ffc1608e2af0147ca4e86e1ce27672d8d3f3c9d4ffd6ef7e'), ], - maxFeePerDataGas: 10000000n, + maxFeePerblobGas: 10000000n, gasLimit: 123457n, maxFeePerGas: 42n, maxPriorityFeePerGas: 10n, @@ -478,7 +478,7 @@ describe('Network wrapper deserialization test', () => { to: '0x1f738d535998ba73b31f38f1ecf6a6ad013eaa20', chainId: '0x1', accessList: [], - maxFeePerDataGas: '0x5f5e100', + maxFeePerblobGas: '0x5f5e100', versionedHashes: ['0x0172f7e05f83dde3e36fb3de430f65c09efb9dbbbf53826e1c1c9780b8fb9520'], } const txMeta = { diff --git a/packages/vm/src/buildBlock.ts b/packages/vm/src/buildBlock.ts index fc5e7cfbd9..3e8f93c2c3 100644 --- a/packages/vm/src/buildBlock.ts +++ b/packages/vm/src/buildBlock.ts @@ -42,9 +42,9 @@ export class BlockBuilder { */ gasUsed = BigInt(0) /** - * The cumulative data gas used by the blobs in a block + * The cumulative blob gas used by the blobs in a block */ - dataGasUsed = BigInt(0) + blobGasUsed = BigInt(0) /** * Value of the block, represented by the final transaction fees * acruing to the miner. @@ -90,9 +90,9 @@ export class BlockBuilder { if ( this.vm.common.isActivatedEIP(4844) === true && - typeof this.headerData.excessDataGas === 'undefined' + typeof this.headerData.excessBlobGas === 'undefined' ) { - this.headerData.excessDataGas = opts.parentBlock.header.calcNextExcessDataGas() + this.headerData.excessBlobGas = opts.parentBlock.header.calcNextExcessBlobGas() } } @@ -195,14 +195,14 @@ export class BlockBuilder { // cannot be greater than the remaining gas in the block const blockGasLimit = toType(this.headerData.gasLimit, TypeOutput.BigInt) - const dataGasLimit = this.vm.common.param('gasConfig', 'maxDataGasPerBlock') - const dataGasPerBlob = this.vm.common.param('gasConfig', 'dataGasPerBlob') + const blobGasLimit = this.vm.common.param('gasConfig', 'maxblobGasPerBlock') + const blobGasPerBlob = this.vm.common.param('gasConfig', 'blobGasPerBlob') const blockGasRemaining = blockGasLimit - this.gasUsed if (tx.gasLimit > blockGasRemaining) { throw new Error('tx has a higher gas limit than the remaining gas in the block') } - let dataGasUsed = undefined + let blobGasUsed = undefined if (tx instanceof BlobEIP4844Transaction) { if (this.blockOpts.common?.isActivatedEIP(4844) !== true) { throw Error('eip4844 not activated yet for adding a blob transaction') @@ -214,17 +214,17 @@ export class BlockBuilder { throw new Error('blobs missing for 4844 transaction') } - if (this.dataGasUsed + BigInt(blobTx.numBlobs()) * dataGasPerBlob > dataGasLimit) { - throw new Error('block data gas limit reached') + if (this.blobGasUsed + BigInt(blobTx.numBlobs()) * blobGasPerBlob > blobGasLimit) { + throw new Error('block blob gas limit reached') } - dataGasUsed = this.dataGasUsed + blobGasUsed = this.blobGasUsed } const header = { ...this.headerData, gasUsed: this.gasUsed, - // correct excessDataGas should already part of headerData used above - dataGasUsed, + // correct excessBlobGas should already part of headerData used above + blobGasUsed, } const blockData = { header, transactions: this.transactions } @@ -235,7 +235,7 @@ export class BlockBuilder { // If tx is a blob transaction, remove blobs/kzg commitments before adding to block per EIP-4844 if (tx instanceof BlobEIP4844Transaction) { const txData = tx as BlobEIP4844Transaction - this.dataGasUsed += BigInt(txData.versionedHashes.length) * dataGasPerBlob + this.blobGasUsed += BigInt(txData.versionedHashes.length) * blobGasPerBlob tx = BlobEIP4844Transaction.minimalFromNetworkWrapper(txData, { common: this.blockOpts.common, }) @@ -291,9 +291,9 @@ export class BlockBuilder { // timestamp should already be set in constructor const timestamp = this.headerData.timestamp ?? BigInt(0) - let dataGasUsed = undefined + let blobGasUsed = undefined if (this.vm.common.isActivatedEIP(4844) === true) { - dataGasUsed = this.dataGasUsed + blobGasUsed = this.blobGasUsed } const headerData = { @@ -305,8 +305,8 @@ export class BlockBuilder { logsBloom, gasUsed, timestamp, - // correct excessDataGas should already be part of headerData used above - dataGasUsed, + // correct excessBlobGas should already be part of headerData used above + blobGasUsed, } if (consensusType === ConsensusType.ProofOfWork) { @@ -353,7 +353,6 @@ export class BlockBuilder { } export async function buildBlock(this: VM, opts: BuildBlockOpts): Promise { - // let opts override excessDataGas if there is some value passed there const blockBuilder = new BlockBuilder(this, opts) await blockBuilder.initState() return blockBuilder diff --git a/packages/vm/src/runTx.ts b/packages/vm/src/runTx.ts index d37e0679fe..fb26c64204 100644 --- a/packages/vm/src/runTx.ts +++ b/packages/vm/src/runTx.ts @@ -277,8 +277,8 @@ async function _runTx(this: VM, opts: RunTxOpts): Promise { // Check balance against max potential cost (for EIP 1559 and 4844) let maxCost = tx.value - let dataGasPrice = BigInt(0) - let totalDataGas = BigInt(0) + let blobGasPrice = BigInt(0) + let totalblobGas = BigInt(0) if (tx.supports(Capability.EIP1559FeeMarket)) { // EIP-1559 spec: // The signer must be able to afford the transaction @@ -295,23 +295,23 @@ async function _runTx(this: VM, opts: RunTxOpts): Promise { // the signer must be able to afford the transaction // assert signer(tx).balance >= tx.message.gas * tx.message.max_fee_per_gas + get_total_data_gas(tx) * tx.message.max_fee_per_data_gas const castTx = tx as BlobEIP4844Transaction - totalDataGas = castTx.common.param('gasConfig', 'dataGasPerBlob') * BigInt(castTx.numBlobs()) - maxCost += totalDataGas * castTx.maxFeePerDataGas + totalblobGas = castTx.common.param('gasConfig', 'blobGasPerBlob') * BigInt(castTx.numBlobs()) + maxCost += totalblobGas * castTx.maxFeePerblobGas - // 4844 minimum datagas price check + // 4844 minimum blobGas price check if (opts.block === undefined) { const msg = _errorMsg( - `Block option must be supplied to compute data gas price`, + `Block option must be supplied to compute blob gas price`, this, block, tx ) throw new Error(msg) } - dataGasPrice = opts.block.header.getDataGasPrice() - if (castTx.maxFeePerDataGas < dataGasPrice) { + blobGasPrice = opts.block.header.getBlobGasPrice() + if (castTx.maxFeePerblobGas < blobGasPrice) { const msg = _errorMsg( - `Transaction's maxFeePerDataGas ${castTx.maxFeePerDataGas}) is less than block dataGasPrice (${dataGasPrice}).`, + `Transaction's maxFeePerblobGas ${castTx.maxFeePerblobGas}) is less than block blobGasPrice (${blobGasPrice}).`, this, block, tx @@ -377,9 +377,9 @@ async function _runTx(this: VM, opts: RunTxOpts): Promise { // Update from account's balance const txCost = tx.gasLimit * gasPrice - const dataGasCost = totalDataGas * dataGasPrice + const blobGasCost = totalblobGas * blobGasPrice fromAccount.balance -= txCost - fromAccount.balance -= dataGasCost + fromAccount.balance -= blobGasCost if (opts.skipBalance === true && fromAccount.balance < BigInt(0)) { fromAccount.balance = BigInt(0) } @@ -443,9 +443,9 @@ async function _runTx(this: VM, opts: RunTxOpts): Promise { debugGas(`tx add baseFee ${txBaseFee} to totalGasSpent (-> ${results.totalGasSpent})`) } - // Add data gas used to result + // Add blob gas used to result if (isBlobEIP4844Tx(tx)) { - results.dataGasUsed = totalDataGas + results.blobGasUsed = totalblobGas } // Process any gas refund @@ -556,8 +556,8 @@ async function _runTx(this: VM, opts: RunTxOpts): Promise { tx, results, cumulativeGasUsed, - totalDataGas, - dataGasPrice + totalblobGas, + blobGasPrice ) /** @@ -607,16 +607,16 @@ function txLogsBloom(logs?: any[]): Bloom { * @param tx The transaction * @param txResult The tx result * @param cumulativeGasUsed The gas used in the block including this tx - * @param dataGasUsed The data gas used in the tx - * @param dataGasPrice The data gas price for the block including this tx + * @param blobGasUsed The blob gas used in the tx + * @param blobGasPrice The blob gas price for the block including this tx */ export async function generateTxReceipt( this: VM, tx: TypedTransaction, txResult: RunTxResult, cumulativeGasUsed: bigint, - dataGasUsed?: bigint, - dataGasPrice?: bigint + blobGasUsed?: bigint, + blobGasPrice?: bigint ): Promise { const baseReceipt: BaseTxReceipt = { cumulativeBlockGasUsed: cumulativeGasUsed, @@ -655,8 +655,8 @@ export async function generateTxReceipt( // Typed EIP-2718 Transaction if (isBlobEIP4844Tx(tx)) { receipt = { - dataGasUsed, - dataGasPrice, + blobGasUsed, + blobGasPrice, status: txResult.execResult.exceptionError ? 0 : 1, ...baseReceipt, } as EIP4844BlobTxReceipt diff --git a/packages/vm/src/types.ts b/packages/vm/src/types.ts index 227355a96c..182f74bea4 100644 --- a/packages/vm/src/types.ts +++ b/packages/vm/src/types.ts @@ -49,19 +49,19 @@ export interface PostByzantiumTxReceipt extends BaseTxReceipt { export interface EIP4844BlobTxReceipt extends PostByzantiumTxReceipt { /** - * Data gas consumed by a transaction + * blob gas consumed by a transaction * * Note: This value is not included in the receiptRLP used for encoding the receiptsRoot in a block * and is only provided as part of receipt metadata. */ - dataGasUsed: bigint + blobGasUsed: bigint /** - * Data gas price for block transaction was included in + * blob gas price for block transaction was included in * * Note: This valus is not included in the `receiptRLP` used for encoding the `receiptsRoot` in a block * and is only provided as part of receipt metadata. */ - dataGasPrice: bigint + blobGasPrice: bigint } export type VMEvents = { @@ -392,9 +392,9 @@ export interface RunTxResult extends EVMResult { minerValue: bigint /** - * This is the data gas units times the fee per data gas for 4844 transactions + * This is the blob gas units times the fee per blob gas for 4844 transactions */ - dataGasUsed?: bigint + blobGasUsed?: bigint } export interface AfterTxEvent extends RunTxResult { diff --git a/packages/vm/test/api/EIPs/eip-4844-blobs.spec.ts b/packages/vm/test/api/EIPs/eip-4844-blobs.spec.ts index e504397705..118892da68 100644 --- a/packages/vm/test/api/EIPs/eip-4844-blobs.spec.ts +++ b/packages/vm/test/api/EIPs/eip-4844-blobs.spec.ts @@ -79,7 +79,7 @@ describe('EIP4844 tests', () => { kzgCommitments: commitments, kzgProofs: proofs, maxFeePerGas: 10000000000n, - maxFeePerDataGas: 100000000n, + maxFeePerblobGas: 100000000n, gasLimit: 0xffffn, to: hexToBytes('0xffb38a7a99e3e2335be83fc74b7faa19d5531243'), }, @@ -97,8 +97,8 @@ describe('EIP4844 tests', () => { 'blob transaction should be same' ) - const dataGasPerBlob = common.param('gasConfig', 'dataGasPerBlob') - assert.equal(block.header.dataGasUsed, dataGasPerBlob, 'data gas used for 1 blob should match') + const blobGasPerBlob = common.param('gasConfig', 'blobGasPerBlob') + assert.equal(block.header.blobGasUsed, blobGasPerBlob, 'blob gas used for 1 blob should match') // block should successfully execute with VM.runBlock and have same outputs const result = await vmCopy.runBlock({ block, skipBlockValidation: true }) diff --git a/packages/vm/test/api/runTx.spec.ts b/packages/vm/test/api/runTx.spec.ts index b4215290e7..ff4631f305 100644 --- a/packages/vm/test/api/runTx.spec.ts +++ b/packages/vm/test/api/runTx.spec.ts @@ -882,7 +882,7 @@ describe('runTx tests', () => { { header: BlockHeader.fromHeaderData( { - excessDataGas: 0n, + excessBlobGas: 0n, number: 1, parentHash: blockchain.genesisBlock.hash(), }, @@ -910,7 +910,7 @@ describe('runTx tests', () => { { header: BlockHeader.fromHeaderData( { - excessDataGas: 1n, + excessBlobGas: 1n, number: 2, parentHash: (await blockchain.getBlock(1n)).hash(), // Faking parent hash with getBlock stub }, @@ -924,7 +924,7 @@ describe('runTx tests', () => { ) const res = await vm.runTx({ tx, block, skipBalance: true }) assert.ok(res.execResult.exceptionError === undefined, 'simple blob tx run succeeds') - assert.equal(res.dataGasUsed, 131072n, 'returns correct data gas used for 1 blob') + assert.equal(res.blobGasUsed, 131072n, 'returns correct blob gas used for 1 blob') Blockchain.prototype.getBlock = oldGetBlockFunction } }) diff --git a/packages/vm/test/api/utils.ts b/packages/vm/test/api/utils.ts index 8d3c6be2e4..4ff50cd4e7 100644 --- a/packages/vm/test/api/utils.ts +++ b/packages/vm/test/api/utils.ts @@ -97,7 +97,7 @@ export function getTransaction( txParams['gasPrice'] = undefined txParams['maxFeePerGas'] = BigInt(1000000000) txParams['maxPriorityFeePerGas'] = BigInt(10) - txParams['maxFeePerDataGas'] = BigInt(100) + txParams['maxFeePerblobGas'] = BigInt(100) txParams['blobs'] = getBlobs('hello world') txParams['kzgCommitments'] = blobsToCommitments(txParams['blobs']) txParams['kzgProofs'] = txParams['blobs'].map((blob: Uint8Array, ctx: number) =>