Skip to content

KasarLabs/cairo-shooter

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Cairo Shooter

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.

Features

  • 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

Prerequisites

  • Rust and Cargo (latest stable version)
  • Scarb
  • llvm-19 (cairo-native)

Usage

CLI

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 100

Sample Contracts

The repository includes sample Cairo contracts:

Counter Contract

A simple counter contract with functionality to get and increment a counter value.

Fibonacci Contract

A contract to calculate Fibonacci numbers using recursive and iterative approaches.

Benchmarking

Cairo Shooter can be used to benchmark Cairo contract execution:

./target/release/cairo-shooter -p artifacts/fibonacci -e fib_iter -c 20 -i 10

This will execute the fib_iter function with input 20 ten times and display statistics for both standard and native execution:

How It Works

Cairo Shooter uses blockifier, the Starknet execution engine, to execute Cairo contracts locally.

The execution flow works as follows:

  1. Loads a contract from the provided path (Sierra and CASM files)
  2. Sets up a simple state storage for contract interaction
  3. Creates an execution context using blockifier's EntryPointExecutionContext
  4. Executes the contract's entry point using blockifier's CallEntryPoint.execute()
  5. 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

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published