Cairo Shooter is a high-performance benchmarking and execution tool for Cairo contracts. It allows you to execute Cairo smart contracts locally and compare performance between standard and native execution modes.
- Execute Cairo contracts locally with a simple CLI
- Benchmark contract execution performance
- Support for both standard and native execution modes
- Simple storage implementation for testing
- Performance measurement and statistics
- Rust and Cargo (latest stable version)
- Scarb
- llvm-19 (cairo-native)
Cairo Shooter provides a simple CLI to execute Cairo contract functions:
./target/release/cairo-shooter -p <contract_path> -e <entrypoint> -c <calldata> -i <iterations>Options:
-p, --contract_path: Path to the folder containing the compiled contract and sierra files-e, --entrypoint: Name of the entrypoint function to call-c, --calldata: Calldata to pass to the function, comma-separated (supports both decimal and 0x-prefixed hex)-i, --iterations: Number of times to repeat the call (for benchmarking)
Example:
./target/release/cairo-shooter -p artifacts/counter -e increment -i 100The repository includes sample Cairo contracts:
A simple counter contract with functionality to get and increment a counter value.
A contract to calculate Fibonacci numbers using recursive and iterative approaches.
Cairo Shooter can be used to benchmark Cairo contract execution:
./target/release/cairo-shooter -p artifacts/fibonacci -e fib_iter -c 20 -i 10This will execute the fib_iter function with input 20 ten times and display statistics for both standard and native execution:
Cairo Shooter uses blockifier, the Starknet execution engine, to execute Cairo contracts locally.
The execution flow works as follows:
- Loads a contract from the provided path (Sierra and CASM files)
- Sets up a simple state storage for contract interaction
- Creates an execution context using blockifier's
EntryPointExecutionContext - Executes the contract's entry point using blockifier's
CallEntryPoint.execute() - Measures and reports execution performance
The tool supports two execution modes:
- Standard mode: Uses blockifier's standard Cairo VM execution
- Native mode: Uses cairo-native for faster execution through AOT (Ahead-Of-Time) compilation