https://github.com/reilabs/starknet-replay
CLI tool to replay Starknet transactions and profile libfuncs usage.
https://github.com/reilabs/starknet-replay
blockchain cairo-lang rust starknet-ecosystem
Last synced: 3 months ago
JSON representation
CLI tool to replay Starknet transactions and profile libfuncs usage.
- Host: GitHub
- URL: https://github.com/reilabs/starknet-replay
- Owner: reilabs
- License: apache-2.0
- Created: 2024-04-15T18:24:01.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2024-12-23T23:43:51.000Z (5 months ago)
- Last Synced: 2025-01-13T19:19:40.206Z (4 months ago)
- Topics: blockchain, cairo-lang, rust, starknet-ecosystem
- Language: Rust
- Homepage:
- Size: 321 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 13
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Starknet Replay
`starknet-replay` is a CLI application to replay Starknet transactions. The
state of the blockchain is queried using the Starknet RPC protocol. It also
reports the frequency with which each `libfunc` has been called when replaying
the transactions.It's possible to export the histogram of the most frequently used libfuncs by
number of calls. The data plotted in the histogram is filtered to only include
the libfuncs that amount to 80% of the total calls in the replay. This helps
readability and visual analysis.Only `INVOKE` transactions of Sierra contracts are used for this report because
only Sierra contracts use libfuncs and only `INVOKE` transactions execute Sierra
code. Rejected transactions are included because they are still useful to
indicate which `libfunc` users need.Gathering this data allows actions to be taken based on libfunc usage, examples
of which include designating certain functions for extra scrutiny based on their
popularity and allowing deprecation of less-used libfuncs. This information
allows allows analysis of how libfunc usage changes over time, and how new
functions are adopted by the community.## How to Use
```bash
cargo run --release -- --rpc-url --start-block --end-block
````STARKNET_JSONRPC_ENDPOINT` is the url of the RPC enpoint.
This tool makes use of `tracing` library for log purposes. For this reason set
`RUST_LOG` at least at `info` level to see the raw output of libfunc statistics.## Example
```bash
cargo run --release -- --rpc-url https://starknet-mainnet.public.blastapi.io/rpc/v0_7 --start-block 632917 --end-block 632917 --svg-out "histogram.svg"
```The command above replays all transactions of block
[632917](https://starkscan.co/block/632917#transactions) and saves the libfunc
histogram in the file named `"histogram.svg"`.## Requirements
This crate is compatible with Rust 1.78. Both x86 and ARM are supported.
`blockifier` dependency is not compatible with Rust 1.81+. `pathfinder_simp`
dependency is not compatible with Rust 1.83+ on ARM.## Useful links
- [Starknet](https://docs.starknet.io/documentation/)
- [Libfunc](https://github.com/lambdaclass/cairo_native?tab=readme-ov-file#implemented-library-functions)
- [Starknet Transactions](https://docs.starknet.io/documentation/architecture_and_concepts/Network_Architecture/transactions/)
- [`tracing`](https://github.com/tokio-rs/tracing)