Skip to content

Commit 33cf09d

Browse files
authored
drop logsBloom support (#3292)
* drop logsBloom support * fix: fluffy and t8n * fix: multi-type * remove commented out code * bump nim-eth to
1 parent 7864cdc commit 33cf09d

File tree

14 files changed

+46
-36
lines changed

14 files changed

+46
-36
lines changed

execution_chain/core/chain/forked_chain.nim

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ func updateBranch(c: ForkedChainRef,
6161
blk: Block,
6262
blkHash: Hash32,
6363
txFrame: CoreDbTxRef,
64-
receipts: sink seq[Receipt]) =
64+
receipts: sink seq[StoredReceipt]) =
6565
if parent.isHead:
6666
parent.appendBlock(blk, blkHash, txFrame, move(receipts))
6767
c.hashToBlock[blkHash] = parent.lastBlockPos
@@ -919,7 +919,7 @@ proc blockHeader*(c: ForkedChainRef, blk: BlockHashOrNumber): Result[Header, str
919919
return c.headerByHash(blk.hash)
920920
c.headerByNumber(blk.number)
921921

922-
proc receiptsByBlockHash*(c: ForkedChainRef, blockHash: Hash32): Result[seq[Receipt], string] =
922+
proc receiptsByBlockHash*(c: ForkedChainRef, blockHash: Hash32): Result[seq[StoredReceipt], string] =
923923
if blockHash != c.baseBranch.tailHash:
924924
c.hashToBlock.withValue(blockHash, loc):
925925
return ok(loc[].receipts)

execution_chain/core/chain/forked_chain/chain_branch.nim

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ type
1919
BlockDesc* = object
2020
blk* : Block
2121
txFrame* : CoreDbTxRef
22-
receipts*: seq[Receipt]
22+
receipts*: seq[StoredReceipt]
2323
hash* : Hash32
2424

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

106106
func branch*(parent: BranchRef, blk: Block,
107107
hash: Hash32, txFrame: CoreDbTxRef,
108-
receipts: sink seq[Receipt]): BranchRef =
108+
receipts: sink seq[StoredReceipt]): BranchRef =
109109
BranchRef(
110110
blocks: @[BlockDesc(
111111
blk: blk,
@@ -126,7 +126,7 @@ func header*(loc: BlockPos): Header =
126126
func blk*(loc: BlockPos): Block =
127127
loc.branch.blocks[loc.index].blk
128128

129-
func receipts*(loc: BlockPos): seq[Receipt] =
129+
func receipts*(loc: BlockPos): seq[StoredReceipt] =
130130
loc.branch.blocks[loc.index].receipts
131131

132132
func number*(loc: BlockPos): BlockNumber =
@@ -154,7 +154,7 @@ func appendBlock*(loc: BlockPos,
154154
blk: Block,
155155
blkHash: Hash32,
156156
txFrame: CoreDbTxRef,
157-
receipts: sink seq[Receipt]) =
157+
receipts: sink seq[StoredReceipt]) =
158158
loc.branch.append(BlockDesc(
159159
blk : blk,
160160
txFrame : txFrame,

execution_chain/core/chain/forked_chain/chain_private.nim

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import
2121
proc writeBaggage*(c: ForkedChainRef,
2222
blk: Block, blkHash: Hash32,
2323
txFrame: CoreDbTxRef,
24-
receipts: openArray[Receipt]) =
24+
receipts: openArray[StoredReceipt]) =
2525
template header(): Header =
2626
blk.header
2727

@@ -58,7 +58,7 @@ proc processBlock*(c: ForkedChainRef,
5858
txFrame: CoreDbTxRef,
5959
blk: Block,
6060
blkHash: Hash32,
61-
finalized: bool): Result[seq[Receipt], string] =
61+
finalized: bool): Result[seq[StoredReceipt], string] =
6262
template header(): Header =
6363
blk.header
6464

execution_chain/core/executor/executor_helpers.nim

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,15 +41,15 @@ func logsBloom(logs: openArray[Log]): LogsBloom =
4141
# Public functions
4242
# ------------------------------------------------------------------------------
4343

44-
func createBloom*(receipts: openArray[Receipt]): Bloom =
44+
func createBloom*(receipts: openArray[StoredReceipt]): Bloom =
4545
var bloom: LogsBloom
4646
for rec in receipts:
4747
bloom.value = bloom.value or logsBloom(rec.logs).value
4848
bloom.value.to(Bloom)
4949

5050
proc makeReceipt*(
51-
vmState: BaseVMState; txType: TxType, callResult: LogResult): Receipt =
52-
var rec: Receipt
51+
vmState: BaseVMState; txType: TxType, callResult: LogResult): StoredReceipt =
52+
var rec: StoredReceipt
5353
if vmState.com.isByzantiumOrLater(vmState.blockNumber):
5454
rec.isHash = false
5555
rec.status = vmState.status
@@ -62,7 +62,6 @@ proc makeReceipt*(
6262
rec.receiptType = txType
6363
rec.cumulativeGasUsed = vmState.cumulativeGasUsed
6464
assign(rec.logs, callResult.logEntries)
65-
rec.logsBloom = logsBloom(rec.logs).value.to(Bloom)
6665
rec
6766

6867
# ------------------------------------------------------------------------------

execution_chain/db/core_db/core_apps.nim

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ iterator getWithdrawals*(
129129
iterator getReceipts*(
130130
db: CoreDbTxRef;
131131
receiptsRoot: Hash32;
132-
): Receipt
132+
): StoredReceipt
133133
{.gcsafe, raises: [RlpError].} =
134134
block body:
135135
if receiptsRoot == EMPTY_ROOT_HASH:
@@ -142,7 +142,7 @@ iterator getReceipts*(
142142
break body
143143
if data.len == 0:
144144
break body
145-
yield rlp.decode(data, Receipt)
145+
yield rlp.decode(data, StoredReceipt)
146146

147147
# ------------------------------------------------------------------------------
148148
# Public functions
@@ -493,7 +493,7 @@ proc setHead*(
493493
proc persistReceipts*(
494494
db: CoreDbTxRef;
495495
receiptsRoot: Hash32;
496-
receipts: openArray[Receipt];
496+
receipts: openArray[StoredReceipt];
497497
) =
498498
const info = "persistReceipts()"
499499
if receipts.len == 0:
@@ -507,9 +507,9 @@ proc persistReceipts*(
507507
proc getReceipts*(
508508
db: CoreDbTxRef;
509509
receiptsRoot: Hash32;
510-
): Result[seq[Receipt], string] =
510+
): Result[seq[StoredReceipt], string] =
511511
wrapRlpException "getReceipts":
512-
var receipts = newSeq[Receipt]()
512+
var receipts = newSeq[StoredReceipt]()
513513
for r in db.getReceipts(receiptsRoot):
514514
receipts.add(r)
515515
return ok(receipts)

execution_chain/evm/types.nim

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ type
4949
flags* : set[VMFlag]
5050
fork* : EVMFork
5151
tracer* : TracerRef
52-
receipts* : seq[Receipt]
52+
receipts* : seq[StoredReceipt]
5353
cumulativeGasUsed*: GasInt
5454
gasCosts* : GasCosts
5555
blobGasUsed* : uint64

execution_chain/rpc/filters.nim

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,9 @@ proc match*(
6464
proc deriveLogs*(
6565
header: Header,
6666
transactions: openArray[Transaction],
67-
receipts: openArray[Receipt],
67+
receipts: openArray[StoredReceipt | Receipt],
6868
filterOptions: FilterOptions,
69-
txHashes: Opt[seq[Hash32]] = Opt.none(seq[Hash32])
69+
txHashes: Opt[seq[Hash32]] = Opt.none(seq[Hash32]),
7070
): seq[FilterLog] =
7171
## Derive log fields, does not deal with pending log, only the logs with
7272
## full data set
@@ -81,12 +81,13 @@ proc deriveLogs*(
8181
var logIndex = 0'u64
8282

8383
for i, receipt in receipts:
84-
let logs = receipt.logs.filterIt(it.match(filterOptions.address, filterOptions.topics))
84+
let logs =
85+
receipt.logs.filterIt(it.match(filterOptions.address, filterOptions.topics))
8586
if logs.len > 0:
8687
# TODO avoid recomputing entirely - we should have this cached somewhere
8788
let txHash =
8889
if txHashes.isSome:
89-
txHashes.get[i] # cached txHashes
90+
txHashes.get[i] # cached txHashes
9091
else:
9192
transactions[i].computeRlpHash
9293

execution_chain/rpc/oracle.nim

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ type
4444
blockNumber: uint64
4545
header : Header
4646
txs : seq[Transaction]
47-
receipts : seq[Receipt]
47+
receipts : seq[StoredReceipt]
4848

4949
CacheKey = object
5050
number: uint64

execution_chain/rpc/rpc_utils.nim

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -179,9 +179,11 @@ proc populateBlockObject*(blockHash: Hash32,
179179
result.excessBlobGas = w3Qty(header.excessBlobGas)
180180
result.requestsHash = header.requestsHash
181181

182-
proc populateReceipt*(receipt: Receipt, gasUsed: GasInt, tx: Transaction,
182+
proc populateReceipt*(rec: StoredReceipt, gasUsed: GasInt, tx: Transaction,
183183
txIndex: uint64, header: Header, com: CommonRef): ReceiptObject =
184-
let sender = tx.recoverSender()
184+
let
185+
sender = tx.recoverSender()
186+
receipt = rec.to(Receipt)
185187
var res = ReceiptObject()
186188
res.transactionHash = tx.computeRlpHash
187189
res.transactionIndex = Quantity(txIndex)

execution_chain/sync/wire_protocol/handler.nim

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ proc getReceipts*(ctx: EthWireRef,
8989
continue
9090

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

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

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

114114
if list.len >= MAX_RECEIPTS_SERVE or
115115
totalBytes > SOFT_RESPONSE_LIMIT:

0 commit comments

Comments
 (0)