Add blobGasPrice and blobGasUsed to ReceiptObject of RPC
This commit is contained in:
parent
69254e614f
commit
25bc8e4b22
|
@ -106,8 +106,8 @@ proc verifyPayload(step: NewPayloads,
|
||||||
let r = client.txReceipt(tx.rlpHash)
|
let r = client.txReceipt(tx.rlpHash)
|
||||||
let expectedBlobGasUsed = blobCount.uint64 * GAS_PER_BLOB
|
let expectedBlobGasUsed = blobCount.uint64 * GAS_PER_BLOB
|
||||||
|
|
||||||
#r.ExpectBlobGasUsed(expectedBlobGasUsed)
|
r.expectBlobGasUsed(expectedBlobGasUsed)
|
||||||
#r.ExpectBlobGasPrice(expectedBlobGasPrice)
|
r.expectBlobGasPrice(expectedBlobGasPrice)
|
||||||
|
|
||||||
if totalBlobCount != step.expectedIncludedBlobCount:
|
if totalBlobCount != step.expectedIncludedBlobCount:
|
||||||
error "expected blobs in transactions",
|
error "expected blobs in transactions",
|
||||||
|
|
|
@ -312,6 +312,8 @@ type
|
||||||
stateRoot*: Option[Hash256]
|
stateRoot*: Option[Hash256]
|
||||||
status*: Option[bool]
|
status*: Option[bool]
|
||||||
effectiveGasPrice*: GasInt
|
effectiveGasPrice*: GasInt
|
||||||
|
blobGasUsed*: Option[uint64]
|
||||||
|
blobGasPrice*: Option[UInt256]
|
||||||
|
|
||||||
RPCTx* = object
|
RPCTx* = object
|
||||||
txType*: TxType
|
txType*: TxType
|
||||||
|
@ -353,6 +355,8 @@ proc toRPCReceipt(rec: eth_api.ReceiptObject): RPCReceipt =
|
||||||
stateRoot: rec.root,
|
stateRoot: rec.root,
|
||||||
status: maybeBool(rec.status),
|
status: maybeBool(rec.status),
|
||||||
effectiveGasPrice: hexToInt(string rec.effectiveGasPrice, GasInt),
|
effectiveGasPrice: hexToInt(string rec.effectiveGasPrice, GasInt),
|
||||||
|
blobGasUsed: maybeU64(rec.blobGasUsed),
|
||||||
|
blobGasPrice: maybeU256(rec.blobGasPrice),
|
||||||
)
|
)
|
||||||
|
|
||||||
proc toRPCTx(tx: eth_api.TransactionObject): RPCTx =
|
proc toRPCTx(tx: eth_api.TransactionObject): RPCTx =
|
||||||
|
|
|
@ -24,10 +24,10 @@ import
|
||||||
./cancun_tests
|
./cancun_tests
|
||||||
|
|
||||||
proc combineTests(): seq[TestDesc] =
|
proc combineTests(): seq[TestDesc] =
|
||||||
result.add wdTestList
|
#result.add wdTestList
|
||||||
result.add ecTestList
|
#result.add ecTestList
|
||||||
result.add authTestList
|
#result.add authTestList
|
||||||
result.add engineTestList
|
#result.add engineTestList
|
||||||
result.add cancunTestList
|
result.add cancunTestList
|
||||||
|
|
||||||
let
|
let
|
||||||
|
|
|
@ -240,6 +240,24 @@ template expectBalanceEqual*(res: untyped, expectedBalance: UInt256) =
|
||||||
testCond res.get == expectedBalance:
|
testCond res.get == expectedBalance:
|
||||||
error "invalid balance", expect=expectedBalance, get=res.get
|
error "invalid balance", expect=expectedBalance, get=res.get
|
||||||
|
|
||||||
|
template expectBlobGasUsed*(res: untyped, expected: uint64) =
|
||||||
|
testCond res.isOk:
|
||||||
|
error "expectBlobGasUsed", msg=res.error
|
||||||
|
let rec = res.get
|
||||||
|
testCond rec.blobGasUsed.isSome:
|
||||||
|
error "expect blobGasUsed isSome"
|
||||||
|
testCond rec.blobGasUsed.get == expected:
|
||||||
|
error "expectBlobGasUsed", expect=expected, get=rec.blobGasUsed.get
|
||||||
|
|
||||||
|
template expectBlobGasPrice*(res: untyped, expected: UInt256) =
|
||||||
|
testCond res.isOk:
|
||||||
|
error "expectBlobGasPrice", msg=res.error
|
||||||
|
let rec = res.get
|
||||||
|
testCond rec.blobGasPrice.isSome:
|
||||||
|
error "expect blobGasPrice isSome"
|
||||||
|
testCond rec.blobGasPrice.get == expected:
|
||||||
|
error "expectBlobGasPrice", expect=expected, get=rec.blobGasPrice.get
|
||||||
|
|
||||||
func timestamp*(x: ExecutableData): auto =
|
func timestamp*(x: ExecutableData): auto =
|
||||||
x.basePayload.timestamp
|
x.basePayload.timestamp
|
||||||
|
|
||||||
|
|
|
@ -157,6 +157,9 @@ type
|
||||||
# Before EIP-1559, this is equal to the transaction's gas price.
|
# Before EIP-1559, this is equal to the transaction's gas price.
|
||||||
# After, it is equal to baseFeePerGas + min(maxFeePerGas - baseFeePerGas, maxPriorityFeePerGas).
|
# After, it is equal to baseFeePerGas + min(maxFeePerGas - baseFeePerGas, maxPriorityFeePerGas).
|
||||||
|
|
||||||
|
blobGasUsed*: Option[HexQuantityStr] # uint64
|
||||||
|
blobGasPrice*: Option[HexQuantityStr] # UInt256
|
||||||
|
|
||||||
FilterOptions* = object
|
FilterOptions* = object
|
||||||
# Parameter from user
|
# Parameter from user
|
||||||
fromBlock*: Option[string] # (optional, default: "latest") integer block number, or "latest" for the last mined block or "pending", "earliest" for not yet mined transactions.
|
fromBlock*: Option[string] # (optional, default: "latest") integer block number, or "latest" for the last mined block or "pending", "earliest" for not yet mined transactions.
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
# Nimbus
|
# Nimbus
|
||||||
# Copyright (c) 2018 Status Research & Development GmbH
|
# Copyright (c) 2018-2023 Status Research & Development GmbH
|
||||||
# Licensed under either of
|
# Licensed under either of
|
||||||
# * Apache License, version 2.0, ([LICENSE-APACHE](LICENSE-APACHE))
|
# * Apache License, version 2.0, ([LICENSE-APACHE](LICENSE-APACHE))
|
||||||
# * MIT license ([LICENSE-MIT](LICENSE-MIT))
|
# * MIT license ([LICENSE-MIT](LICENSE-MIT))
|
||||||
|
@ -9,11 +9,17 @@
|
||||||
|
|
||||||
{.push raises: [].}
|
{.push raises: [].}
|
||||||
|
|
||||||
import hexstrings, eth/[common, keys], stew/byteutils,
|
import
|
||||||
../db/core_db, strutils, algorithm, options, json,
|
std/[strutils, algorithm, options, json],
|
||||||
../constants, stint, rpc_types,
|
./hexstrings,
|
||||||
|
./rpc_types,
|
||||||
|
eth/[common, keys],
|
||||||
|
stew/byteutils,
|
||||||
|
../db/core_db,
|
||||||
|
../constants, stint,
|
||||||
../utils/utils, ../transaction,
|
../utils/utils, ../transaction,
|
||||||
../transaction/call_evm
|
../transaction/call_evm,
|
||||||
|
../core/eip4844
|
||||||
|
|
||||||
const
|
const
|
||||||
defaultTag = "latest"
|
defaultTag = "latest"
|
||||||
|
@ -164,8 +170,8 @@ proc toAccessTupleList(list: openArray[AccessPair]): seq[AccessTuple] =
|
||||||
for x in list:
|
for x in list:
|
||||||
result.add toAccessTuple(x)
|
result.add toAccessTuple(x)
|
||||||
|
|
||||||
proc populateTransactionObject*(tx: Transaction,
|
proc populateTransactionObject*(tx: Transaction,
|
||||||
header: Option[BlockHeader] = none(BlockHeader),
|
header: Option[BlockHeader] = none(BlockHeader),
|
||||||
txIndex: Option[int] = none(int)): TransactionObject
|
txIndex: Option[int] = none(int)): TransactionObject
|
||||||
{.gcsafe, raises: [ValidationError].} =
|
{.gcsafe, raises: [ValidationError].} =
|
||||||
result.`type` = encodeQuantity(tx.txType.uint64)
|
result.`type` = encodeQuantity(tx.txType.uint64)
|
||||||
|
@ -304,3 +310,7 @@ proc populateReceipt*(receipt: Receipt, gasUsed: GasInt, tx: Transaction,
|
||||||
|
|
||||||
let normTx = eip1559TxNormalization(tx, header.baseFee.truncate(GasInt))
|
let normTx = eip1559TxNormalization(tx, header.baseFee.truncate(GasInt))
|
||||||
result.effectiveGasPrice = encodeQuantity(normTx.gasPrice.uint64)
|
result.effectiveGasPrice = encodeQuantity(normTx.gasPrice.uint64)
|
||||||
|
|
||||||
|
if tx.txType == TxEip4844:
|
||||||
|
result.blobGasUsed = some(encodeQuantity(tx.versionedHashes.len.uint64 * GAS_PER_BLOB.uint64))
|
||||||
|
result.blobGasPrice = some(encodeQuantity(getBlobGasprice(header.excessBlobGas.get(0'u64))))
|
||||||
|
|
Loading…
Reference in New Issue