Skip to content
4 changes: 2 additions & 2 deletions execution_chain/core/chain/forked_chain.nim
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ func updateBranch(c: ForkedChainRef,
blk: Block,
blkHash: Hash32,
txFrame: CoreDbTxRef,
receipts: sink seq[Receipt]) =
receipts: sink seq[StoredReceipt]) =
if parent.isHead:
parent.appendBlock(blk, blkHash, txFrame, move(receipts))
c.hashToBlock[blkHash] = parent.lastBlockPos
Expand Down Expand Up @@ -862,7 +862,7 @@ proc blockHeader*(c: ForkedChainRef, blk: BlockHashOrNumber): Result[Header, str
return c.headerByHash(blk.hash)
c.headerByNumber(blk.number)

proc receiptsByBlockHash*(c: ForkedChainRef, blockHash: Hash32): Result[seq[Receipt], string] =
proc receiptsByBlockHash*(c: ForkedChainRef, blockHash: Hash32): Result[seq[StoredReceipt], string] =
if blockHash != c.baseBranch.tailHash:
c.hashToBlock.withValue(blockHash, loc):
return ok(loc[].receipts)
Expand Down
8 changes: 4 additions & 4 deletions execution_chain/core/chain/forked_chain/chain_branch.nim
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ type
BlockDesc* = object
blk* : Block
txFrame* : CoreDbTxRef
receipts*: seq[Receipt]
receipts*: seq[StoredReceipt]
hash* : Hash32

BlockPos* = object
Expand Down Expand Up @@ -105,7 +105,7 @@ func branch*(header: Header, hash: Hash32, txFrame: CoreDbTxRef): BranchRef =

func branch*(parent: BranchRef, blk: Block,
hash: Hash32, txFrame: CoreDbTxRef,
receipts: sink seq[Receipt]): BranchRef =
receipts: sink seq[StoredReceipt]): BranchRef =
BranchRef(
blocks: @[BlockDesc(
blk: blk,
Expand All @@ -126,7 +126,7 @@ func header*(loc: BlockPos): Header =
func blk*(loc: BlockPos): Block =
loc.branch.blocks[loc.index].blk

func receipts*(loc: BlockPos): seq[Receipt] =
func receipts*(loc: BlockPos): seq[StoredReceipt] =
loc.branch.blocks[loc.index].receipts

func number*(loc: BlockPos): BlockNumber =
Expand Down Expand Up @@ -154,7 +154,7 @@ func appendBlock*(loc: BlockPos,
blk: Block,
blkHash: Hash32,
txFrame: CoreDbTxRef,
receipts: sink seq[Receipt]) =
receipts: sink seq[StoredReceipt]) =
loc.branch.append(BlockDesc(
blk : blk,
txFrame : txFrame,
Expand Down
4 changes: 2 additions & 2 deletions execution_chain/core/chain/forked_chain/chain_private.nim
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import
proc writeBaggage*(c: ForkedChainRef,
blk: Block, blkHash: Hash32,
txFrame: CoreDbTxRef,
receipts: openArray[Receipt]) =
receipts: openArray[StoredReceipt]) =
template header(): Header =
blk.header

Expand Down Expand Up @@ -58,7 +58,7 @@ proc processBlock*(c: ForkedChainRef,
txFrame: CoreDbTxRef,
blk: Block,
blkHash: Hash32,
finalized: bool): Result[seq[Receipt], string] =
finalized: bool): Result[seq[StoredReceipt], string] =
template header(): Header =
blk.header

Expand Down
7 changes: 3 additions & 4 deletions execution_chain/core/executor/executor_helpers.nim
Original file line number Diff line number Diff line change
Expand Up @@ -41,15 +41,15 @@ func logsBloom(logs: openArray[Log]): LogsBloom =
# Public functions
# ------------------------------------------------------------------------------

func createBloom*(receipts: openArray[Receipt]): Bloom =
func createBloom*(receipts: openArray[StoredReceipt]): Bloom =
var bloom: LogsBloom
for rec in receipts:
bloom.value = bloom.value or logsBloom(rec.logs).value
bloom.value.to(Bloom)

proc makeReceipt*(
vmState: BaseVMState; txType: TxType, callResult: LogResult): Receipt =
var rec: Receipt
vmState: BaseVMState; txType: TxType, callResult: LogResult): StoredReceipt =
var rec: StoredReceipt
if vmState.com.isByzantiumOrLater(vmState.blockNumber):
rec.isHash = false
rec.status = vmState.status
Expand All @@ -62,7 +62,6 @@ proc makeReceipt*(
rec.receiptType = txType
rec.cumulativeGasUsed = vmState.cumulativeGasUsed
assign(rec.logs, callResult.logEntries)
rec.logsBloom = logsBloom(rec.logs).value.to(Bloom)
rec

# ------------------------------------------------------------------------------
Expand Down
10 changes: 5 additions & 5 deletions execution_chain/db/core_db/core_apps.nim
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ iterator getWithdrawals*(
iterator getReceipts*(
db: CoreDbTxRef;
receiptsRoot: Hash32;
): Receipt
): StoredReceipt
{.gcsafe, raises: [RlpError].} =
block body:
if receiptsRoot == EMPTY_ROOT_HASH:
Expand All @@ -142,7 +142,7 @@ iterator getReceipts*(
break body
if data.len == 0:
break body
yield rlp.decode(data, Receipt)
yield rlp.decode(data, StoredReceipt)

# ------------------------------------------------------------------------------
# Public functions
Expand Down Expand Up @@ -493,7 +493,7 @@ proc setHead*(
proc persistReceipts*(
db: CoreDbTxRef;
receiptsRoot: Hash32;
receipts: openArray[Receipt];
receipts: openArray[StoredReceipt];
) =
const info = "persistReceipts()"
if receipts.len == 0:
Expand All @@ -507,9 +507,9 @@ proc persistReceipts*(
proc getReceipts*(
db: CoreDbTxRef;
receiptsRoot: Hash32;
): Result[seq[Receipt], string] =
): Result[seq[StoredReceipt], string] =
wrapRlpException "getReceipts":
var receipts = newSeq[Receipt]()
var receipts = newSeq[StoredReceipt]()
for r in db.getReceipts(receiptsRoot):
receipts.add(r)
return ok(receipts)
Expand Down
2 changes: 1 addition & 1 deletion execution_chain/evm/types.nim
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ type
flags* : set[VMFlag]
fork* : EVMFork
tracer* : TracerRef
receipts* : seq[Receipt]
receipts* : seq[StoredReceipt]
cumulativeGasUsed*: GasInt
gasCosts* : GasCosts
blobGasUsed* : uint64
Expand Down
9 changes: 5 additions & 4 deletions execution_chain/rpc/filters.nim
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,9 @@ proc match*(
proc deriveLogs*(
header: Header,
transactions: openArray[Transaction],
receipts: openArray[Receipt],
receipts: openArray[StoredReceipt | Receipt],
filterOptions: FilterOptions,
txHashes: Opt[seq[Hash32]] = Opt.none(seq[Hash32])
txHashes: Opt[seq[Hash32]] = Opt.none(seq[Hash32]),
): seq[FilterLog] =
## Derive log fields, does not deal with pending log, only the logs with
## full data set
Expand All @@ -81,12 +81,13 @@ proc deriveLogs*(
var logIndex = 0'u64

for i, receipt in receipts:
let logs = receipt.logs.filterIt(it.match(filterOptions.address, filterOptions.topics))
let logs =
receipt.logs.filterIt(it.match(filterOptions.address, filterOptions.topics))
if logs.len > 0:
# TODO avoid recomputing entirely - we should have this cached somewhere
let txHash =
if txHashes.isSome:
txHashes.get[i] # cached txHashes
txHashes.get[i] # cached txHashes
else:
transactions[i].computeRlpHash

Expand Down
2 changes: 1 addition & 1 deletion execution_chain/rpc/oracle.nim
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ type
blockNumber: uint64
header : Header
txs : seq[Transaction]
receipts : seq[Receipt]
receipts : seq[StoredReceipt]

CacheKey = object
number: uint64
Expand Down
6 changes: 4 additions & 2 deletions execution_chain/rpc/rpc_utils.nim
Original file line number Diff line number Diff line change
Expand Up @@ -179,9 +179,11 @@ proc populateBlockObject*(blockHash: Hash32,
result.excessBlobGas = w3Qty(header.excessBlobGas)
result.requestsHash = header.requestsHash

proc populateReceipt*(receipt: Receipt, gasUsed: GasInt, tx: Transaction,
proc populateReceipt*(rec: StoredReceipt, gasUsed: GasInt, tx: Transaction,
txIndex: uint64, header: Header, com: CommonRef): ReceiptObject =
let sender = tx.recoverSender()
let
sender = tx.recoverSender()
receipt = rec.to(Receipt)
var res = ReceiptObject()
res.transactionHash = tx.computeRlpHash
res.transactionIndex = Quantity(txIndex)
Expand Down
4 changes: 2 additions & 2 deletions execution_chain/sync/wire_protocol/handler.nim
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ proc getReceipts*(ctx: EthWireRef,
continue

totalBytes += getEncodedLength(receiptList)
list.add(move(receiptList))
list.add(receiptList.to(seq[Receipt]))

if list.len >= MAX_RECEIPTS_SERVE or
totalBytes > SOFT_RESPONSE_LIMIT:
Expand All @@ -109,7 +109,7 @@ proc getStoredReceipts*(ctx: EthWireRef,
continue

totalBytes += getEncodedLength(receiptList)
list.add(receiptList.to(seq[StoredReceipt]))
list.add(move(receiptList))

if list.len >= MAX_RECEIPTS_SERVE or
totalBytes > SOFT_RESPONSE_LIMIT:
Expand Down
6 changes: 5 additions & 1 deletion execution_chain/utils/utils.nim
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Nimbus
# Copyright (c) 2018-2024 Status Research & Development GmbH
# Copyright (c) 2018-2025 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)
Expand Down Expand Up @@ -30,6 +30,10 @@ template calcTxRoot*(transactions: openArray[Transaction]): Root =
template calcWithdrawalsRoot*(withdrawals: openArray[Withdrawal]): Root =
orderedTrieRoot(withdrawals)

template calcReceiptsRoot*(receipts: openArray[StoredReceipt]): Root =
let recs = receipts.to(seq[Receipt])
orderedTrieRoot(recs)

template calcReceiptsRoot*(receipts: openArray[Receipt]): Root =
orderedTrieRoot(receipts)

Expand Down
Empty file modified scripts/check_copyright_year.sh
100644 → 100755
Empty file.
10 changes: 6 additions & 4 deletions tests/test_block_fixture.nim
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (c) 2023-2024 Status Research & Development GmbH
# Copyright (c) 2023-2025 Status Research & Development GmbH
# Licensed under either of
# * Apache License, version 2.0, ([LICENSE-APACHE](LICENSE-APACHE))
# * MIT license ([LICENSE-MIT](LICENSE-MIT))
Expand All @@ -19,7 +19,8 @@ var receitsRlp = rlpb.listElem(2)

let blockHeader4514995* = headerRlp.read(Header)
let blockBody4514995* = bodyRlp.read(BlockBody)
let receipts4514995* = receitsRlp.read(seq[Receipt])
let recs = receitsRlp.read(seq[Receipt])
let receipts4514995* = recs.to(seq[StoredReceipt])

proc getBlockHeader4514995*(): Header {.gcsafe.} =
var headerRlp = rlpb.listElem(0)
Expand All @@ -29,6 +30,7 @@ proc getBlockBody4514995*(): BlockBody {.gcsafe.} =
var bodyRlp = rlpb.listElem(1)
return bodyRlp.read(BlockBody)

proc getReceipts4514995*(): seq[Receipt] {.gcsafe.} =
proc getReceipts4514995*(): seq[StoredReceipt] {.gcsafe.} =
var receitsRlp = rlpb.listElem(2)
return receitsRlp.read(seq[Receipt])
let recs = receitsRlp.read(seq[Receipt])
return recs.to(seq[StoredReceipt])
10 changes: 6 additions & 4 deletions tools/t8n/transition.nim
Original file line number Diff line number Diff line change
Expand Up @@ -119,13 +119,15 @@ proc genAddress(tx: Transaction, sender: Address): Address =
if tx.to.isNone:
result = generateAddress(sender, tx.nonce)

proc toTxReceipt(rec: Receipt,
proc toTxReceipt(receipt: StoredReceipt,
tx: Transaction,
sender: Address,
txIndex: int,
gasUsed: GasInt): TxReceipt =

let contractAddress = genAddress(tx, sender)
let
contractAddress = genAddress(tx, sender)
rec = receipt.to(Receipt)
TxReceipt(
txType: tx.txType,
root: if rec.isHash: rec.hash else: default(Hash32),
Expand All @@ -140,7 +142,7 @@ proc toTxReceipt(rec: Receipt,
transactionIndex: txIndex
)

proc calcLogsHash(receipts: openArray[Receipt]): Hash32 =
proc calcLogsHash(receipts: openArray[StoredReceipt]): Hash32 =
var logs: seq[Log]
for rec in receipts:
logs.add rec.logs
Expand Down Expand Up @@ -231,7 +233,7 @@ proc exec(ctx: TransContext,
vmState.mutateLedger:
db.applyDAOHardFork()

vmState.receipts = newSeqOfCap[Receipt](ctx.txList.len)
vmState.receipts = newSeqOfCap[StoredReceipt](ctx.txList.len)
vmState.cumulativeGasUsed = 0

if ctx.env.parentBeaconBlockRoot.isSome:
Expand Down
Loading