Skip to content
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
10 changes: 10 additions & 0 deletions crates/query/docs/evm-query-syntax.md
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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:**

Expand Down
25 changes: 25 additions & 0 deletions crates/query/fixtures/ethereum/queries/trace_call_type/query.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"type": "evm",
"fromBlock": 17881390,
"toBlock": 17881870,
"fields": {
"trace": {
"callFrom": true,
"callCallType": true,
"transactionIndex": true,
Comment on lines +7 to +9
"traceAddress": true,
"type": true
},
"block": {
"number": true,
"hash": true,
"parentHash": true
}
},
"traces": [
{
"callFrom": ["0x58df81babdf15276e761808e872a3838cbecbcf9"],
"callCallType": ["staticcall"]
}
]
}
Git LFS file not shown
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
{
"type": "evm",
"fromBlock": 17881390,
"toBlock": 17881870,
"fields": {
"trace": {
"callCallType": true,
"callSighash": true,
"callValue": true,
Comment on lines +6 to +9
"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
},
{
"callCallType": ["call"],
"callSighash": ["0x3598d8ab"],
"callValueNonZero": true
},
{
"suicideBalanceNonZero": true
}
]
}
Git LFS file not shown
21 changes: 21 additions & 0 deletions crates/query/src/query/eth.rs
Original file line number Diff line number Diff line change
Expand Up @@ -571,12 +571,17 @@ request! {
pub r#type: Option<Vec<String>>,
pub create_from: Option<Vec<Bytes>>,
pub create_result_address: Option<Vec<Bytes>>,
pub create_value_non_zero: bool,
pub call_from: Option<Vec<Bytes>>,
pub call_to: Option<Vec<Bytes>>,
pub call_sighash: Option<Vec<Bytes>>,
pub call_call_type: Option<Vec<String>>,
pub call_value_non_zero: bool,
pub suicide_address: Option<Vec<Bytes>>,
pub suicide_refund_address: Option<Vec<Bytes>>,
pub suicide_balance_non_zero: bool,
pub reward_author: Option<Vec<Bytes>>,
pub reward_value_non_zero: bool,
pub transaction: bool,
pub transaction_logs: bool,
pub subtraces: bool,
Expand All @@ -592,12 +597,28 @@ 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_call_type.as_deref());
p.col_in_list("suicide_address", to_lowercase_list(&self.suicide_address));
p.col_in_list(
"suicide_refund_address",
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"));

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be nice to have a comment why "0x01" values don't exist

}
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) {
Expand Down
Loading