mirror of
https://github.com/status-im/nimbus-eth1.git
synced 2025-01-11 21:04:11 +00:00
json rpc: eth_getTransactionReceipt: add effectiveGasPrice field
This commit is contained in:
parent
fdbabf0b80
commit
8d208acaf9
@ -17,7 +17,8 @@ import
|
||||
../db/[db_chain, state_db],
|
||||
rpc_types, rpc_utils,
|
||||
../transaction/call_evm,
|
||||
../utils/tx_pool
|
||||
../utils/tx_pool,
|
||||
../chain_config
|
||||
|
||||
#[
|
||||
Note:
|
||||
@ -387,12 +388,13 @@ proc setupEthRpc*(node: EthereumNode, ctx: EthContext, chain: BaseChainDB, txPoo
|
||||
var
|
||||
idx = 0
|
||||
prevGasUsed = GasInt(0)
|
||||
fork = toFork(chain.networkParams.config, header.blockNumber)
|
||||
|
||||
for receipt in chain.getReceipts(header.receiptRoot):
|
||||
let gasUsed = receipt.cumulativeGasUsed - prevGasUsed
|
||||
prevGasUsed = receipt.cumulativeGasUsed
|
||||
if idx == txDetails.index:
|
||||
return some(populateReceipt(receipt, gasUsed, tx, txDetails.index, header))
|
||||
return some(populateReceipt(receipt, gasUsed, tx, txDetails.index, header, fork))
|
||||
idx.inc
|
||||
|
||||
server.rpc("eth_getUncleByBlockHashAndIndex") do(data: EthHashStr, quantity: HexQuantityStr) -> Option[BlockObject]:
|
||||
|
@ -117,6 +117,9 @@ type
|
||||
logsBloom*: FixedBytes[256] # bloom filter for light clients to quickly retrieve related logs.
|
||||
root*: Option[Hash256] # post-transaction stateroot (pre Byzantium).
|
||||
status*: Option[int] # 1 = success, 0 = failure.
|
||||
effectiveGasPrice*: HexQuantityStr # The actual value per gas deducted from the senders account.
|
||||
# Before EIP-1559, this is equal to the transaction's gas price.
|
||||
# After, it is equal to baseFeePerGas + min(maxFeePerGas - baseFeePerGas, maxPriorityFeePerGas).
|
||||
|
||||
FilterDataKind* = enum fkItem, fkList
|
||||
FilterData* = object
|
||||
|
@ -11,7 +11,7 @@ import hexstrings, eth/[common, rlp, keys, trie/db], stew/byteutils, nimcrypto,
|
||||
../db/db_chain, strutils, algorithm, options, times, json,
|
||||
../constants, stint, hexstrings, rpc_types,
|
||||
../utils, ../transaction,
|
||||
../transaction/call_evm
|
||||
../transaction/call_evm, ../forks
|
||||
|
||||
func toAddress*(value: EthAddressStr): EthAddress = hexToPaddedByteArray[20](value.string)
|
||||
|
||||
@ -170,7 +170,7 @@ proc populateBlockObject*(header: BlockHeader, chain: BaseChainDB, fullTx: bool,
|
||||
for x in chain.getBlockTransactionHashes(header):
|
||||
result.transactions.add %(x)
|
||||
|
||||
proc populateReceipt*(receipt: Receipt, gasUsed: GasInt, tx: Transaction, txIndex: int, header: BlockHeader): ReceiptObject =
|
||||
proc populateReceipt*(receipt: Receipt, gasUsed: GasInt, tx: Transaction, txIndex: int, header: BlockHeader, fork: Fork): ReceiptObject =
|
||||
result.transactionHash = tx.rlpHash
|
||||
result.transactionIndex = encodeQuantity(txIndex.uint)
|
||||
result.blockHash = header.hash
|
||||
@ -195,3 +195,6 @@ proc populateReceipt*(receipt: Receipt, gasUsed: GasInt, tx: Transaction, txInde
|
||||
else:
|
||||
# 1 = success, 0 = failure.
|
||||
result.status = some(receipt.status.int)
|
||||
|
||||
let normTx = eip1559TxNormalization(tx, header.baseFee.truncate(GasInt), fork)
|
||||
result.effectiveGasPrice = encodeQuantity(normTx.gasPrice.uint64)
|
||||
|
Loading…
x
Reference in New Issue
Block a user