Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

evm: add transactionStateDiffs to LogRequest #350

Merged
merged 1 commit into from
Nov 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"changes": [
{
"packageName": "@subsquid/evm-processor",
"comment": "add transactionStateDiffs to LogRequest",
"type": "minor"
}
],
"packageName": "@subsquid/evm-processor"
}
8 changes: 8 additions & 0 deletions evm/evm-processor/src/ds-rpc/filter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {DataRequest} from '../interfaces/data-request'
function buildLogFilter(dataRequest: DataRequest): EntityFilter<Log, {
transaction?: boolean,
transactionLogs?: boolean,
transactionStateDiffs?: boolean,
transactionTraces?: boolean
}> {
let items = new EntityFilter()
Expand Down Expand Up @@ -139,6 +140,7 @@ export function filterBlock(block: Block, dataRequest: DataRequest): void {

let logsByTransaction = groupBy(block.logs, log => log.transactionIndex)
let tracesByTransaction = groupBy(block.traces, trace => trace.transactionIndex)
let stateDiffsByTransaction = groupBy(block.stateDiffs, diff => diff.transactionIndex)

let include = new IncludeSet()

Expand All @@ -162,6 +164,12 @@ export function filterBlock(block: Block, dataRequest: DataRequest): void {
include.addTrace(trace)
}
}
if (rel.transactionStateDiffs) {
let stateDiffs = stateDiffsByTransaction.get(log.transactionIndex) ?? []
for (let diff of stateDiffs) {
include.addStateDiff(diff)
}
}
}
}

Expand Down
5 changes: 5 additions & 0 deletions evm/evm-processor/src/ds-rpc/request.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,11 @@ function stateDiffsRequested(req?: DataRequest): boolean {
if (tx.stateDiffs) return true
}
}
if (req.logs) {
for (let log of req.logs) {
if (log.transactionStateDiffs) return true
}
}
return false
}

Expand Down
1 change: 1 addition & 0 deletions evm/evm-processor/src/interfaces/data-request.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ export interface LogRequest {
transaction?: boolean
transactionTraces?: boolean
transactionLogs?: boolean
transactionStateDiffs?: boolean
}


Expand Down
Loading