Skip to content

Commit

Permalink
Implement three trace APIs:
Browse files Browse the repository at this point in the history
- trace_block
- trace_filter
- trace_transaction

Plus tests and docs
  • Loading branch information
maxconway committed Jan 21, 2025
1 parent a34220f commit e006a82
Show file tree
Hide file tree
Showing 6 changed files with 570 additions and 10 deletions.
63 changes: 63 additions & 0 deletions docs/api/trace/trace_block.doc.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
# Title

trace_block

# Keywords

block,trace,parity

# Description

Returns traces created at given block. The traces are returned in transaction index order.

# Curl

```shell
curl -d '{
"id": "1",
"jsonrpc": "2.0",
"method": "trace_block",
"params": ["0x2ed119"]
}' -H "Content-Type: application/json" -X POST "{{ _api_url }}"
```

# Response

```json
{
"jsonrpc": "2.0",
"id": 1,
"result": [
{
"output": "0x",
"stateDiff": null,
"trace": [{
"action": {
"from": "0x1c39ba39e4735cb65978d4db400ddd70a72dc750",
"gas": "0x0",
"value": "0x1",
"callType": "call",
"to": "0x2910543af39aba0cd09dbb2d50200b3e800a63d2"
},
"result": {
"gasUsed": "0x0",
"output": "0x"
},
"subtraces": 0,
"traceAddress": [],
"type": "call"
}],
"vmTrace": null
}
]
}
```

# Arguments

| Parameter | Type | Required | Description |
|-----------|--------|----------|---------------------------------|
| `id` | string | Required | `"1"` |
| `jsonrpc` | string | Required | `"2.0"` |
| `method` | string | Required | `"trace_block"` |
| `params` | array | Required | `[blockNumber]` Block number or tag |
79 changes: 79 additions & 0 deletions docs/api/trace/trace_filter.doc.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
# Title

trace_filter

# Keywords

trace,filter,parity

# Description

Returns traces matching given filter. The traces are returned in transaction index order.

# Curl

```shell
curl -d '{
"id": "1",
"jsonrpc": "2.0",
"method": "trace_filter",
"params": [{
"fromBlock": "0x2ed119",
"toBlock": "0x2ed119",
"fromAddress": ["0x1c39ba39e4735cb65978d4db400ddd70a72dc750"],
"toAddress": ["0x2910543af39aba0cd09dbb2d50200b3e800a63d2"],
"after": 0,
"count": 100
}]
}' -H "Content-Type: application/json" -X POST "{{ _api_url }}"
```

# Response

```json
{
"jsonrpc": "2.0",
"id": 1,
"result": [
{
"output": "0x",
"stateDiff": null,
"trace": [{
"action": {
"from": "0x1c39ba39e4735cb65978d4db400ddd70a72dc750",
"gas": "0x0",
"value": "0x1",
"callType": "call",
"to": "0x2910543af39aba0cd09dbb2d50200b3e800a63d2"
},
"result": {
"gasUsed": "0x0",
"output": "0x"
},
"subtraces": 0,
"traceAddress": [],
"type": "call"
}],
"vmTrace": null
}
]
}
```

# Arguments

| Parameter | Type | Required | Description |
|-----------|--------|----------|------------------------------------------------------|
| `id` | string | Required | `"1"` |
| `jsonrpc` | string | Required | `"2.0"` |
| `method` | string | Required | `"trace_filter"` |
| `params` | array | Required | `[filterOptions]` Object containing filter options: |

Filter Options:

- `fromBlock`: `BlockNumber` - (optional) From this block
- `toBlock`: `BlockNumber` - (optional) To this block
- `fromAddress`: `[Address]` - (optional) Sent from these addresses
- `toAddress`: `[Address]` - (optional) Sent to these addresses
- `after`: `Integer` - (optional) The offset trace number
- `count`: `Integer` - (optional) Integer number of traces to display in a batch
73 changes: 73 additions & 0 deletions docs/api/trace/trace_transaction.doc.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
# Title

trace_transaction

# Keywords

transaction,trace,parity

# Description

Returns all traces of given transaction. The traces are returned in transaction index order and each trace object has the following format.

# Curl

```shell
curl -d '{
"id": "1",
"jsonrpc": "2.0",
"method": "trace_transaction",
"params": ["0x17104ac9d3312d8c136b7f44d4b8b47852618065ebfa534bd2d3b5ef218ca1f3"]
}' -H "Content-Type: application/json" -X POST "{{ _api_url }}"
```

# Response

```json
{
"jsonrpc": "2.0",
"id": 1,
"result": {
"output": "0x",
"stateDiff": {
"0x00...01": {
"balance": {
"*": {
"from": "0x100",
"to": "0x110"
}
},
"code": "=",
"nonce": "=",
"storage": {}
}
},
"trace": {
"action": {
"from": "0x627306090abab3a6e1400e9345bc60c78a8bef57",
"gas": "0x1dcd12a0",
"value": "0x0",
"callType": "call",
"input": "0x",
"to": "0xf12b5dd4ead5f743c6baa640b0216200e89b60da"
},
"result": {
"gasUsed": "0x0",
"output": "0x"
},
"subtraces": 0,
"traceAddress": [],
"type": "call"
}
}
}
```

# Arguments

| Parameter | Type | Required | Description |
|-----------|--------|----------|----------------------------------------|
| `id` | string | Required | `"1"` |
| `jsonrpc` | string | Required | `"2.0"` |
| `method` | string | Required | `"trace_transaction"` |
| `params` | array | Required | `[transactionHash]` Transaction hash |
Loading

0 comments on commit e006a82

Please sign in to comment.