Skip to content

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
belopash committed Jan 17, 2024
1 parent 9f5ac14 commit 3719dd3
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 8 deletions.
22 changes: 14 additions & 8 deletions evm/evm-processor/src/ds-rpc/filter.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {assertNotNull, weakMemo} from '@subsquid/util-internal'
import {assertNotNull, groupBy, weakMemo} from '@subsquid/util-internal'
import {EntityFilter, FilterBuilder} from '@subsquid/util-internal-processor-tools'
import {Block, Log, StateDiff, Trace, Transaction} from '../mapping/entities'
import {DataRequest} from '../interfaces/data-request'
Expand Down Expand Up @@ -135,8 +135,11 @@ class IncludeSet {
export function filterBlock(block: Block, dataRequest: DataRequest): void {
let items = getItemFilter(dataRequest)

let include = new IncludeSet()
let logsByTransaction = groupBy(block.logs, log => log.transactionIndex)
let tracesByTransaction = groupBy(block.traces, trace => trace.transactionIndex)

let include = new IncludeSet()

if (items.logs.present()) {
for (let log of block.logs) {
let rel = items.logs.match(log)
Expand All @@ -145,13 +148,15 @@ export function filterBlock(block: Block, dataRequest: DataRequest): void {
if (rel.transaction) {
include.addTransaction(log.transaction)
}
if (rel.transactionLogs && log.transaction) {
for (let sibling of log.transaction.logs) {
if (rel.transactionLogs) {
let logs = logsByTransaction.get(log.transactionIndex) ?? []
for (let sibling of logs) {
include.addLog(sibling)
}
}
if (rel.transactionTraces && log.transaction) {
for (let trace of log.transaction.traces) {
if (rel.transactionTraces) {
let traces = tracesByTransaction.get(log.transactionIndex) ?? []
for (let trace of traces) {
include.addTrace(trace)
}
}
Expand Down Expand Up @@ -197,8 +202,9 @@ export function filterBlock(block: Block, dataRequest: DataRequest): void {
if (rel.transaction) {
include.addTransaction(trace.transaction)
}
if (rel.transactionLogs && trace.transaction) {
for (let log of trace.transaction.logs) {
if (rel.transactionLogs) {
let logs = logsByTransaction.get(trace.transactionIndex) ?? []
for (let log of logs) {
include.addLog(log)
}
}
Expand Down
10 changes: 10 additions & 0 deletions evm/evm-processor/src/ds-rpc/request.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,11 @@ function logsRequested(req?: DataRequest): boolean {
if (tx.logs) return true
}
}
if (req.traces) {
for (let trace of req.traces) {
if (trace.transactionLogs) return true
}
}
return false
}

Expand All @@ -65,6 +70,11 @@ function tracesRequested(req?: DataRequest): boolean {
if (tx.traces) return true
}
}
if (req.logs) {
for (let log of req.logs) {
if (log.transactionTraces) return true
}
}
return false
}

Expand Down

0 comments on commit 3719dd3

Please sign in to comment.