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

Add documentation for stylusTracer output #1790

Merged
merged 4 commits into from
Nov 8, 2024
Merged
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
Expand Up @@ -131,3 +131,71 @@ Note that if the sync process encounters an error while trying to collect the da
- If `batchSeen` > `batchProcessed`, some batches have still not been processed
- If `msgCount` > `messageOfLastBlock`, some messages have been processed, but not all relevant blocks have been built (this is usually the longest stage while syncing a new node)
- If `broadcasterQueuedMessagesPos` > `msgCount`, the feed is ahead of the last message known to the node

### `debug_traceTransaction`

The Nitro node provides a native tracer for debugging Stylus contracts called `stylusTracer`, which returns a JSON array with objects containing the metadata for each executed HostIO.
HostIOs are calls the WasmVM makes to read and write data in the EVM.
With the result of this tracer and the code for the Stylus contract, you have all the data to understand what happened in a Stylus transaction.

:::info

The `cargo-stylus` command-line tool uses the `stylusTracer` to replay transactions locally inside a debugger.
More information can be found on [How to debug Stylus transactions using Cargo Stylus Replay](/stylus/how-tos/debugging-stylus-tx).

:::

The table below describes each field of the `stylusTracer` return value.

| Field Name | Description |
| ---------- | --------------------------------------------------------------- |
| `name` | Name of the execute HostIO. |
| `args` | Arguments of the HostIO encoded as hex. |
| `outs` | Outputs of the HostIO encoded as hex. |
| `startInk` | Amount of Ink before executing the HostIO. |
| `endInk` | Amount of Ink after executing the HostIO. |
| `address` | For \*call HostIOs, the address of the called contract. |
| `steps` | For \*call HostIOs, the steps performed by the called contract. |

For example, the command below illustrates how to call this tracer for a transaction.

```
curl -s \
-X POST \
-H "Content-Type: application/json" \
-d '{"jsonrpc":"2.0","method":"debug_traceTransaction","params":["<transaction-hash>", {"tracer": "stylusTracer"}],"id":1}' \
<nitro-node-rpc>
```

The result of this call will be something along the lines of.

```
{
"jsonrpc": "2.0",
"id": 1,
"result": [
{
"args": "0x00000024",
"endInk": 116090000,
"name": "user_entrypoint",
"outs": "0x",
"startInk": 116090000
},
{
"args": "0x",
"endInk": 116057558,
"name": "msg_reentrant",
"outs": "0x00000000",
"startInk": 116065958
},
{
"args": "0x",
"endInk": 115937952,
"name": "read_args",
"outs": "0x6c5283490000000000000000000000003bdff922e18bc03f1cf7b2a8b65a070cbec944f2",
"startInk": 115951512
},
...
]
}
```
Loading