From 70cff6cd9a5cb83acb4cefb52c8fc165864a9087 Mon Sep 17 00:00:00 2001 From: tmcgroul Date: Mon, 8 Jun 2026 13:51:20 +0300 Subject: [PATCH 1/5] allow to filter traces by call type --- .../queries/trace_call_type/query.json | 25 +++++++++++++++++++ .../queries/trace_call_type/result.json | 3 +++ crates/query/src/query/eth.rs | 2 ++ 3 files changed, 30 insertions(+) create mode 100644 crates/query/fixtures/ethereum/queries/trace_call_type/query.json create mode 100644 crates/query/fixtures/ethereum/queries/trace_call_type/result.json diff --git a/crates/query/fixtures/ethereum/queries/trace_call_type/query.json b/crates/query/fixtures/ethereum/queries/trace_call_type/query.json new file mode 100644 index 00000000..4d9b96b9 --- /dev/null +++ b/crates/query/fixtures/ethereum/queries/trace_call_type/query.json @@ -0,0 +1,25 @@ +{ + "type": "evm", + "fromBlock": 17881390, + "toBlock": 17881870, + "fields": { + "trace": { + "callFrom": true, + "callType": true, + "transactionIndex": true, + "traceAddress": true, + "type": true + }, + "block": { + "number": true, + "hash": true, + "parentHash": true + } + }, + "traces": [ + { + "callFrom": ["0x58df81babdf15276e761808e872a3838cbecbcf9"], + "callType": ["staticcall"] + } + ] +} \ No newline at end of file diff --git a/crates/query/fixtures/ethereum/queries/trace_call_type/result.json b/crates/query/fixtures/ethereum/queries/trace_call_type/result.json new file mode 100644 index 00000000..c0b284e1 --- /dev/null +++ b/crates/query/fixtures/ethereum/queries/trace_call_type/result.json @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:542a37a1fca0ed0c472a50bc4a05fc99b2ec0b4464adea6fdb81e57b7c2b86b5 +size 578038 diff --git a/crates/query/src/query/eth.rs b/crates/query/src/query/eth.rs index b67d9e88..70e6d669 100644 --- a/crates/query/src/query/eth.rs +++ b/crates/query/src/query/eth.rs @@ -574,6 +574,7 @@ request! { pub call_from: Option>, pub call_to: Option>, pub call_sighash: Option>, + pub call_type: Option>, pub suicide_address: Option>, pub suicide_refund_address: Option>, pub reward_author: Option>, @@ -592,6 +593,7 @@ impl TraceRequest { p.col_in_list("call_from", to_lowercase_list(&self.call_from)); p.col_in_list("call_to", to_lowercase_list(&self.call_to)); p.col_in_list("call_sighash", to_lowercase_list(&self.call_sighash)); + p.col_in_list("call_type", self.call_type.as_deref()); p.col_in_list("suicide_address", to_lowercase_list(&self.suicide_address)); p.col_in_list( "suicide_refund_address", From 86cd97e68f1b318e1e7f32b86ad6c9d16d788b7d Mon Sep 17 00:00:00 2001 From: tmcgroul Date: Mon, 8 Jun 2026 18:31:07 +0300 Subject: [PATCH 2/5] allow to filter out zero value traces --- .../queries/trace_value_non_zero/query.json | 38 +++++++++++++++++++ .../queries/trace_value_non_zero/result.json | 3 ++ crates/query/src/query/eth.rs | 16 ++++++++ 3 files changed, 57 insertions(+) create mode 100644 crates/query/fixtures/ethereum/queries/trace_value_non_zero/query.json create mode 100644 crates/query/fixtures/ethereum/queries/trace_value_non_zero/result.json diff --git a/crates/query/fixtures/ethereum/queries/trace_value_non_zero/query.json b/crates/query/fixtures/ethereum/queries/trace_value_non_zero/query.json new file mode 100644 index 00000000..56c1acbc --- /dev/null +++ b/crates/query/fixtures/ethereum/queries/trace_value_non_zero/query.json @@ -0,0 +1,38 @@ +{ + "type": "evm", + "fromBlock": 17881390, + "toBlock": 17881870, + "fields": { + "trace": { + "callType": true, + "callSighash": true, + "callValue": true, + "createResultAddress": true, + "createValue": true, + "suicideRefundAddress": true, + "suicideBalance": true, + "rewardValue": true, + "transactionIndex": true, + "traceAddress": true, + "type": true + }, + "block": { + "number": true, + "hash": true, + "parentHash": true + } + }, + "traces": [ + { + "createValueNonZero": true + }, + { + "callType": ["call"], + "callSighash": ["0x3598d8ab"], + "callValueNonZero": true + }, + { + "suicideBalanceNonZero": true + } + ] +} \ No newline at end of file diff --git a/crates/query/fixtures/ethereum/queries/trace_value_non_zero/result.json b/crates/query/fixtures/ethereum/queries/trace_value_non_zero/result.json new file mode 100644 index 00000000..6303410a --- /dev/null +++ b/crates/query/fixtures/ethereum/queries/trace_value_non_zero/result.json @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:02c2c84a41eec2e10ec66ee53628660a9b067694d07abd165fb076492889742c +size 33225 diff --git a/crates/query/src/query/eth.rs b/crates/query/src/query/eth.rs index 70e6d669..943be074 100644 --- a/crates/query/src/query/eth.rs +++ b/crates/query/src/query/eth.rs @@ -571,13 +571,17 @@ request! { pub r#type: Option>, pub create_from: Option>, pub create_result_address: Option>, + pub create_value_non_zero: bool, pub call_from: Option>, pub call_to: Option>, pub call_sighash: Option>, pub call_type: Option>, + pub call_value_non_zero: bool, pub suicide_address: Option>, pub suicide_refund_address: Option>, + pub suicide_balance_non_zero: bool, pub reward_author: Option>, + pub reward_value_non_zero: bool, pub transaction: bool, pub transaction_logs: bool, pub subtraces: bool, @@ -600,6 +604,18 @@ impl TraceRequest { to_lowercase_list(&self.suicide_refund_address) ); p.col_in_list("reward_author", to_lowercase_list(&self.reward_author)); + if self.call_value_non_zero { + p.col_gt_eq("call_value", Some("0x1")); + } + if self.create_value_non_zero { + p.col_gt_eq("create_value", Some("0x1")); + } + if self.suicide_balance_non_zero { + p.col_gt_eq("suicide_balance", Some("0x1")); + } + if self.reward_value_non_zero { + p.col_gt_eq("reward_value", Some("0x1")); + } } fn relations(&self, scan: &mut ScanBuilder) { From 0a71cf04df7694787d1d4377dadc3195a9def083 Mon Sep 17 00:00:00 2001 From: tmcgroul Date: Thu, 18 Jun 2026 19:04:19 +0300 Subject: [PATCH 3/5] rename callType filter to callCallType --- .../fixtures/ethereum/queries/trace_call_type/query.json | 4 ++-- .../fixtures/ethereum/queries/trace_call_type/result.json | 4 ++-- .../fixtures/ethereum/queries/trace_value_non_zero/query.json | 4 ++-- .../ethereum/queries/trace_value_non_zero/result.json | 4 ++-- crates/query/src/query/eth.rs | 4 ++-- 5 files changed, 10 insertions(+), 10 deletions(-) diff --git a/crates/query/fixtures/ethereum/queries/trace_call_type/query.json b/crates/query/fixtures/ethereum/queries/trace_call_type/query.json index 4d9b96b9..239383d1 100644 --- a/crates/query/fixtures/ethereum/queries/trace_call_type/query.json +++ b/crates/query/fixtures/ethereum/queries/trace_call_type/query.json @@ -5,7 +5,7 @@ "fields": { "trace": { "callFrom": true, - "callType": true, + "callCallType": true, "transactionIndex": true, "traceAddress": true, "type": true @@ -19,7 +19,7 @@ "traces": [ { "callFrom": ["0x58df81babdf15276e761808e872a3838cbecbcf9"], - "callType": ["staticcall"] + "callCallType": ["staticcall"] } ] } \ No newline at end of file diff --git a/crates/query/fixtures/ethereum/queries/trace_call_type/result.json b/crates/query/fixtures/ethereum/queries/trace_call_type/result.json index c0b284e1..5cee134f 100644 --- a/crates/query/fixtures/ethereum/queries/trace_call_type/result.json +++ b/crates/query/fixtures/ethereum/queries/trace_call_type/result.json @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:542a37a1fca0ed0c472a50bc4a05fc99b2ec0b4464adea6fdb81e57b7c2b86b5 -size 578038 +oid sha256:567a5d16ab94687d3c86741acd7a996ade3abcdc95e8b9c5d9b13a58119a1e9d +size 586330 diff --git a/crates/query/fixtures/ethereum/queries/trace_value_non_zero/query.json b/crates/query/fixtures/ethereum/queries/trace_value_non_zero/query.json index 56c1acbc..d027a875 100644 --- a/crates/query/fixtures/ethereum/queries/trace_value_non_zero/query.json +++ b/crates/query/fixtures/ethereum/queries/trace_value_non_zero/query.json @@ -4,7 +4,7 @@ "toBlock": 17881870, "fields": { "trace": { - "callType": true, + "callCallType": true, "callSighash": true, "callValue": true, "createResultAddress": true, @@ -27,7 +27,7 @@ "createValueNonZero": true }, { - "callType": ["call"], + "callCallType": ["call"], "callSighash": ["0x3598d8ab"], "callValueNonZero": true }, diff --git a/crates/query/fixtures/ethereum/queries/trace_value_non_zero/result.json b/crates/query/fixtures/ethereum/queries/trace_value_non_zero/result.json index 6303410a..9f89d5ca 100644 --- a/crates/query/fixtures/ethereum/queries/trace_value_non_zero/result.json +++ b/crates/query/fixtures/ethereum/queries/trace_value_non_zero/result.json @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:02c2c84a41eec2e10ec66ee53628660a9b067694d07abd165fb076492889742c -size 33225 +oid sha256:60046d9f03d0cbde99348304c1b2c74be956e06c10d9eb16d1fa033df6f6b69e +size 33477 diff --git a/crates/query/src/query/eth.rs b/crates/query/src/query/eth.rs index 943be074..3d719171 100644 --- a/crates/query/src/query/eth.rs +++ b/crates/query/src/query/eth.rs @@ -575,7 +575,7 @@ request! { pub call_from: Option>, pub call_to: Option>, pub call_sighash: Option>, - pub call_type: Option>, + pub call_call_type: Option>, pub call_value_non_zero: bool, pub suicide_address: Option>, pub suicide_refund_address: Option>, @@ -597,7 +597,7 @@ impl TraceRequest { p.col_in_list("call_from", to_lowercase_list(&self.call_from)); p.col_in_list("call_to", to_lowercase_list(&self.call_to)); p.col_in_list("call_sighash", to_lowercase_list(&self.call_sighash)); - p.col_in_list("call_type", self.call_type.as_deref()); + p.col_in_list("call_type", self.call_call_type.as_deref()); p.col_in_list("suicide_address", to_lowercase_list(&self.suicide_address)); p.col_in_list( "suicide_refund_address", From 55617e4a0d224690b11f43588930e90ad5f94e41 Mon Sep 17 00:00:00 2001 From: tmcgroul Date: Thu, 18 Jun 2026 19:14:02 +0300 Subject: [PATCH 4/5] add new filters to evm-query-syntax docs --- crates/query/docs/evm-query-syntax.md | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/crates/query/docs/evm-query-syntax.md b/crates/query/docs/evm-query-syntax.md index 3a02cb72..64fb40cd 100644 --- a/crates/query/docs/evm-query-syntax.md +++ b/crates/query/docs/evm-query-syntax.md @@ -290,12 +290,17 @@ Item requests define filters for selecting blockchain data. Multiple requests of "type": ["call", "create"], "createFrom": ["0x..."], "createResultAddress": ["0x..."], + "createValueNonZero": true, "callFrom": ["0x..."], "callTo": ["0x..."], "callSighash": ["0x..."], + "callCallType": ["call", "delegatecall"], + "callValueNonZero": true, "suicideAddress": ["0x..."], "suicideRefundAddress": ["0x..."], + "suicideBalanceNonZero": true, "rewardAuthor": ["0x..."], + "rewardValueNonZero": true, "transaction": true, "transactionLogs": true, "subtraces": true, @@ -312,12 +317,17 @@ Item requests define filters for selecting blockchain data. Multiple requests of | `type` | string[] | Match traces of these types: `"create"`, `"call"`, `"suicide"`, `"reward"` | | `createFrom` | string[] | Match create traces from any of these addresses | | `createResultAddress` | string[] | Match create traces that deployed contracts at these addresses | +| `createValueNonZero` | boolean | When `true`, only match create traces where `createValue` is non-zero and non-null | | `callFrom` | string[] | Match call traces from any of these addresses | | `callTo` | string[] | Match call traces to any of these addresses | | `callSighash` | string[] | Match call traces with any of these function selectors | +| `callCallType` | string[] | Match call traces with any of these call types: `"call"`, `"delegatecall"`, `"staticcall"`, `"callcode"` | +| `callValueNonZero` | boolean | When `true`, only match call traces where `callValue` is non-zero and non-null | | `suicideAddress` | string[] | Match suicide traces for any of these contract addresses | | `suicideRefundAddress` | string[] | Match suicide traces refunding to any of these addresses | +| `suicideBalanceNonZero` | boolean | When `true`, only match suicide traces where `suicideBalance` is non-zero and non-null | | `rewardAuthor` | string[] | Match reward traces to any of these authors | +| `rewardValueNonZero` | boolean | When `true`, only match reward traces where `rewardValue` is non-zero and non-null | **Relation fields:** From 33dacc45080a5308ef9ee88f9239ff28cf2ded2b Mon Sep 17 00:00:00 2001 From: tmcgroul Date: Thu, 18 Jun 2026 19:23:22 +0300 Subject: [PATCH 5/5] add a comment that 0x01 values don't exist --- crates/query/src/query/eth.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/crates/query/src/query/eth.rs b/crates/query/src/query/eth.rs index 3d719171..72832be9 100644 --- a/crates/query/src/query/eth.rs +++ b/crates/query/src/query/eth.rs @@ -604,6 +604,9 @@ impl TraceRequest { to_lowercase_list(&self.suicide_refund_address) ); p.col_in_list("reward_author", to_lowercase_list(&self.reward_author)); + + // Hex values are stored in minimal form (no leading zeros), + // so "0x01" never exists in the data. if self.call_value_non_zero { p.col_gt_eq("call_value", Some("0x1")); }