From 5cf50e965e2707e1ed498955d753c3bdb4394190 Mon Sep 17 00:00:00 2001 From: tmcgroul Date: Tue, 26 Sep 2023 23:42:16 +0300 Subject: [PATCH 1/5] ignore STOP debug frame --- evm/evm-processor/src/ds-rpc/mapping.ts | 3 +++ evm/evm-processor/src/ds-rpc/rpc.ts | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/evm/evm-processor/src/ds-rpc/mapping.ts b/evm/evm-processor/src/ds-rpc/mapping.ts index a7b6dfe2c..2d91a282f 100644 --- a/evm/evm-processor/src/ds-rpc/mapping.ts +++ b/evm/evm-processor/src/ds-rpc/mapping.ts @@ -398,6 +398,9 @@ function* mapDebugFrame(transactionIndex: number, debugFrameResult: rpc.DebugFra } } break + case 'STOP': + // We ignore `STOP` frame because it doesn't affect indexing + break default: throw unexpectedCase(rec.frame.type) } diff --git a/evm/evm-processor/src/ds-rpc/rpc.ts b/evm/evm-processor/src/ds-rpc/rpc.ts index 90a63ba7f..2c4d8d338 100644 --- a/evm/evm-processor/src/ds-rpc/rpc.ts +++ b/evm/evm-processor/src/ds-rpc/rpc.ts @@ -208,7 +208,7 @@ export type TraceTracers = 'trace' | 'stateDiff' export interface DebugFrame { - type: 'CALL' | 'STATICCALL' | 'DELEGATECALL' | 'CREATE' | 'CREATE2' | 'SELFDESTRUCT' | 'INVALID' + type: 'CALL' | 'STATICCALL' | 'DELEGATECALL' | 'CREATE' | 'CREATE2' | 'SELFDESTRUCT' | 'INVALID' | 'STOP' from: Bytes20 to: Bytes20 value?: Qty From e66c4d23a417539a067fe6c5d976357f7d188e7d Mon Sep 17 00:00:00 2001 From: tmcgroul Date: Tue, 26 Sep 2023 23:44:52 +0300 Subject: [PATCH 2/5] changes --- .../evm-processor/stop-trace_2023-09-26-20-44.json | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 common/changes/@subsquid/evm-processor/stop-trace_2023-09-26-20-44.json diff --git a/common/changes/@subsquid/evm-processor/stop-trace_2023-09-26-20-44.json b/common/changes/@subsquid/evm-processor/stop-trace_2023-09-26-20-44.json new file mode 100644 index 000000000..852032c03 --- /dev/null +++ b/common/changes/@subsquid/evm-processor/stop-trace_2023-09-26-20-44.json @@ -0,0 +1,10 @@ +{ + "changes": [ + { + "packageName": "@subsquid/evm-processor", + "comment": "ignore STOP debug frame", + "type": "patch" + } + ], + "packageName": "@subsquid/evm-processor" +} \ No newline at end of file From 54a29144681a92cc34aa87fcf64e0c43fe7bf409 Mon Sep 17 00:00:00 2001 From: tmcgroul Date: Wed, 27 Sep 2023 01:34:30 +0300 Subject: [PATCH 3/5] ingnore STOP frame on traversal --- evm/evm-processor/src/ds-rpc/mapping.ts | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/evm/evm-processor/src/ds-rpc/mapping.ts b/evm/evm-processor/src/ds-rpc/mapping.ts index 2d91a282f..f1100f9ca 100644 --- a/evm/evm-processor/src/ds-rpc/mapping.ts +++ b/evm/evm-processor/src/ds-rpc/mapping.ts @@ -398,9 +398,6 @@ function* mapDebugFrame(transactionIndex: number, debugFrameResult: rpc.DebugFra } } break - case 'STOP': - // We ignore `STOP` frame because it doesn't affect indexing - break default: throw unexpectedCase(rec.frame.type) } @@ -414,7 +411,8 @@ function* traverseDebugFrame(frame: rpc.DebugFrame, traceAddress: number[]): Ite frame: rpc.DebugFrame }> { let subcalls = frame.calls || [] - yield {traceAddress, subtraces: subcalls.length, frame} + // We ignore `STOP` frame because it doesn't affect indexing + if (frame.type != 'STOP') yield {traceAddress, subtraces: subcalls.length, frame} for (let i = 0; i < subcalls.length; i++) { yield* traverseDebugFrame(subcalls[i], [...traceAddress, i]) } From 8638f850fa296392cb3d9da35ce0adb88b2a48b5 Mon Sep 17 00:00:00 2001 From: tmcgroul Date: Thu, 28 Sep 2023 13:37:36 +0300 Subject: [PATCH 4/5] check if STOP trace is the only transaction trace --- evm/evm-processor/src/ds-rpc/mapping.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/evm/evm-processor/src/ds-rpc/mapping.ts b/evm/evm-processor/src/ds-rpc/mapping.ts index f1100f9ca..8ab7024ae 100644 --- a/evm/evm-processor/src/ds-rpc/mapping.ts +++ b/evm/evm-processor/src/ds-rpc/mapping.ts @@ -398,6 +398,10 @@ function* mapDebugFrame(transactionIndex: number, debugFrameResult: rpc.DebugFra } } break + case 'STOP': + // We ignore `STOP` frame because it doesn't affect indexing + assert(debugFrameResult.result.type == 'STOP') + break default: throw unexpectedCase(rec.frame.type) } @@ -411,8 +415,7 @@ function* traverseDebugFrame(frame: rpc.DebugFrame, traceAddress: number[]): Ite frame: rpc.DebugFrame }> { let subcalls = frame.calls || [] - // We ignore `STOP` frame because it doesn't affect indexing - if (frame.type != 'STOP') yield {traceAddress, subtraces: subcalls.length, frame} + yield {traceAddress, subtraces: subcalls.length, frame} for (let i = 0; i < subcalls.length; i++) { yield* traverseDebugFrame(subcalls[i], [...traceAddress, i]) } From 6f0e0857d9972d47a92e9e8f03e65b60edb5c352 Mon Sep 17 00:00:00 2001 From: Eldar Gabdullin Date: Thu, 28 Sep 2023 21:55:38 +0300 Subject: [PATCH 5/5] fix --- evm/evm-processor/src/ds-rpc/mapping.ts | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/evm/evm-processor/src/ds-rpc/mapping.ts b/evm/evm-processor/src/ds-rpc/mapping.ts index 8ab7024ae..662ac8c1b 100644 --- a/evm/evm-processor/src/ds-rpc/mapping.ts +++ b/evm/evm-processor/src/ds-rpc/mapping.ts @@ -1,5 +1,4 @@ import {addErrorContext, assertNotNull, unexpectedCase} from '@subsquid/util-internal' -import {HashAndHeight} from '@subsquid/util-internal-processor-tools' import assert from 'assert' import {AllFields, BlockData, BlockHeader, FieldSelection, Transaction} from '../interfaces/data' import {DataRequest} from '../interfaces/data-request' @@ -338,6 +337,10 @@ function mapTraceStateDiff(transactionIndex: number, address: Bytes20, key: stri function* mapDebugFrame(transactionIndex: number, debugFrameResult: rpc.DebugFrameResult): Iterable { + if (debugFrameResult.result.type == 'STOP') { + assert(!debugFrameResult.result.calls?.length) + return + } for (let rec of traverseDebugFrame(debugFrameResult.result, [])) { let base: EvmTraceBase = { transactionIndex, @@ -398,10 +401,6 @@ function* mapDebugFrame(transactionIndex: number, debugFrameResult: rpc.DebugFra } } break - case 'STOP': - // We ignore `STOP` frame because it doesn't affect indexing - assert(debugFrameResult.result.type == 'STOP') - break default: throw unexpectedCase(rec.frame.type) }