Align with EIP-4844: rename getBlobGasPrice to getBlobBaseFee (#2043)

This commit is contained in:
andri lim 2024-02-21 16:14:34 +07:00 committed by GitHub
parent 7b4ef814ea
commit 52aa87c539
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
7 changed files with 10 additions and 10 deletions

View File

@ -46,7 +46,7 @@ func getMinExcessBlobGasForBlobGasPrice(data_gas_price: uint64): uint64 =
while current_data_gas_price < data_gas_price:
current_excess_data_gas += GAS_PER_BLOB.uint64
current_data_gas_price = getBlobGasPrice(current_excess_data_gas).truncate(uint64)
current_data_gas_price = getBlobBaseFee(current_excess_data_gas).truncate(uint64)
return current_excess_data_gas

View File

@ -1,5 +1,5 @@
# Nimbus
# Copyright (c) 2023 Status Research & Development GmbH
# Copyright (c) 2023-2024 Status Research & Development GmbH
# Licensed under either of
# * Apache License, version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or
# http://www.apache.org/licenses/LICENSE-2.0)
@ -96,7 +96,7 @@ proc verifyPayload(step: NewPayloads,
var
totalBlobCount = 0
expectedBlobGasPrice = getBlobGasPrice(expectedExcessBlobGas)
expectedBlobGasPrice = getBlobBaseFee(expectedExcessBlobGas)
for tx in blobTxsInPayload:
let blobCount = tx.versionedHashes.len

View File

@ -113,8 +113,8 @@ proc getTotalBlobGas*(tx: Transaction): uint64 =
proc getTotalBlobGas*(versionedHashesLen: int): uint64 =
GAS_PER_BLOB * versionedHashesLen.uint64
# getBlobGasPrice implements get_data_gas_price from EIP-4844
func getBlobGasPrice*(excessBlobGas: uint64): UInt256 =
# getBlobBaseFee implements get_data_gas_price from EIP-4844
func getBlobBaseFee*(excessBlobGas: uint64): UInt256 =
fakeExponential(
MIN_BLOB_GASPRICE.u256,
excessBlobGas.u256,
@ -124,7 +124,7 @@ func getBlobGasPrice*(excessBlobGas: uint64): UInt256 =
proc calcDataFee*(versionedHashesLen: int,
excessBlobGas: uint64): UInt256 =
getTotalBlobGas(versionedHashesLen).u256 *
getBlobGasPrice(excessBlobGas)
getBlobBaseFee(excessBlobGas)
func blobGasUsed(txs: openArray[Transaction]): uint64 =
for tx in txs:

View File

@ -116,7 +116,7 @@ proc txFeesCovered(xp: TxPoolRef; item: TxItemRef): bool =
if item.tx.txType >= TxEip4844:
let
excessBlobGas = xp.chain.excessBlobGas
blobGasPrice = getBlobGasPrice(excessBlobGas)
blobGasPrice = getBlobBaseFee(excessBlobGas)
if item.tx.maxFeePerBlobGas < blobGasPrice:
debug "invalid tx: maxFeePerBlobGas smaller than blobGasPrice",
maxFeePerBlobGas=item.tx.maxFeePerBlobGas,

View File

@ -362,7 +362,7 @@ proc validateTransaction*(
if tx.txType >= TxEip4844:
# ensure that the user was willing to at least pay the current data gasprice
let blobGasPrice = getBlobGasPrice(excessBlobGas)
let blobGasPrice = getBlobBaseFee(excessBlobGas)
if tx.maxFeePerBlobGas < blobGasPrice:
return err("invalid tx: maxFeePerBlobGas smaller than blobGasPrice. " &
"maxFeePerBlobGas=$1, blobGasPrice=$2" % [$tx.maxFeePerBlobGas, $blobGasPrice])

View File

@ -300,4 +300,4 @@ proc populateReceipt*(receipt: Receipt, gasUsed: GasInt, tx: Transaction,
if tx.txType == TxEip4844:
result.blobGasUsed = some(w3Qty(tx.versionedHashes.len.uint64 * GAS_PER_BLOB.uint64))
result.blobGasPrice = some(getBlobGasPrice(header.excessBlobGas.get(0'u64)))
result.blobGasPrice = some(getBlobBaseFee(header.excessBlobGas.get(0'u64)))

View File

@ -134,7 +134,7 @@ proc setupHost(call: CallParams): TransactionHost =
origin : call.origin.get(call.sender),
gasPrice : call.gasPrice,
versionedHashes: call.versionedHashes,
blobBaseFee : getBlobGasPrice(vmState.blockCtx.excessBlobGas),
blobBaseFee : getBlobBaseFee(vmState.blockCtx.excessBlobGas),
),
forkOverride = call.forkOverride
)