Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/pirapira/vmtrace_visualizer
A program that annotates a vm trace with dataflow information
https://github.com/pirapira/vmtrace_visualizer
Last synced: 3 months ago
JSON representation
A program that annotates a vm trace with dataflow information
- Host: GitHub
- URL: https://github.com/pirapira/vmtrace_visualizer
- Owner: pirapira
- License: apache-2.0
- Created: 2016-09-27T15:03:20.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2022-03-24T10:31:47.000Z (almost 3 years ago)
- Last Synced: 2024-10-03T12:37:34.583Z (3 months ago)
- Language: Ruby
- Size: 360 KB
- Stars: 35
- Watchers: 8
- Forks: 6
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
- License: LICENSE
Awesome Lists containing this project
README
# Ethereum VM trace visualizer
![Dataflow visualized](https://yoichihirai.com/spam.png)
[geth](https://github.com/ethereum/go-ethereum) outputs a VM trace for an Ethereum
transaction, by [`debug.traceTransaction()` function](https://github.com/ethereum/go-ethereum/wiki/Management-APIs#debug_tracetransaction).
This repository contains a small ruby program that annotates the traces with the original steps that produced the operands.The enricher tries to answer questions like
* how does this contract calculate the value it sends?
* how does this contract determine the address it calls?on concrete transaction logs.
Currently the enricher keeps track of the origins of values on the stack.
## Usage
After checking out this repository:
```
ruby src/enricher.rb example/example_1.json | less
```
is a way to use it.## Example
Before the transformation
```
{
"depth":1,
"error":null,
"gas":977788,
"gasCost":20,
"memory":[
"0000000000000000000000000000000000000000000000000000000000000000",
"0000000000000000000000000000000000000000000000000000000000000000",
"0000000000000000000000000000000000000000000000000000000000000060"
],
"op":"EXP",
"pc":9,
"stack":[
"00000000000000000000000000000000000000000000000000000000000000e0",
"0000000000000000000000000000000000000000000000000000000000000002"
],
"storage":{}
},
```After the transformation
```diff
{
"depth":1,
"error":null,
"gas":977788,
"gasCost":20,
"memory":[
"0000000000000000000000000000000000000000000000000000000000000000",
"0000000000000000000000000000000000000000000000000000000000000000",
"0000000000000000000000000000000000000000000000000000000000000060"
],
"op":"EXP",
"pc":9,
"stack":[
"00000000000000000000000000000000000000000000000000000000000000e0",
"0000000000000000000000000000000000000000000000000000000000000002"
],
"storage":{
},
+ "step":5,
+ "arg_origins":[
+ {
+ "depth":1,
+ "step":3
+ },
+ {
+ "depth":1,
+ "step":4
+ }
+ ]
},```
## Graphviz output
As a preparation, you need the `graphviz` tools:
```
sudo apt install graphviz
```Then,
```
ruby src/enricher.rb -g example/example_1.json > graph.dot && \
dot -Tpdf graph.dot -o graph.pdf
```
would produce a data-flow diagram in `graph.pdf`.## How to obtain vm traces
The input JSON can be obtained from `geth` RPC. See `example/get_example_1.sh` for how.