Skip to main content

No project description provided

Project description

drawing

🐍 Cairo-rs-py 🐍

EVM interpreter written in Cairo, a sort of ZK-EVM emulator, leveraging STARK proof system.

Report Bug · Request Feature

rust codecov license Telegram Chat

Table of Contents

📖 About

cairo-rs-py adds Python bindings to the cairo-rs Cairo VM.

🌅 Getting Started

Dependencies

  • Rust and Cargo
  • Pyenv and Python 3.9
  • GMP
  • make

Installation

To set up the Python environment, and install necessary Python libraries, run make deps. This command builds two virtual environments, one intended for the Rust VM and the other one for the Original Python VM. It also initializes the submodules of some of the projects we integrated with.

After setting up the environments, you can install the python binary using maturin develop --release.

🚀 Usage

After installation, you can access the cairo-rs VM from Python code. As an example, after compiling the program array_sum into cairo_programs/array_sum.json, you can run it with the VM using:

import cairo_rs_py

with open(f"cairo_programs/array_sum.json") as file:
    runner = cairo_rs_py.CairoRunner(file.read(), "main", "all", False)
    runner.cairo_run(True)

Testing

To run the test suite:

make full-test

Demo

The build_envs.sh script will build two Python virtual environments:

  • cairo-lang containing a pristine installation of cairo-lang==0.10.3;
  • cairo-rs-py containing a patched installation of cairo-lang==0.10.3 that uses cairo-rs-py as dependency. It will also install the required dependencies automatically in Debian-based distributions, CentOs, Fedora and OSX. If you use another OS, you can check how to install them manually below.

To run the script:

./scripts/build_envs.sh

Both virtual environment will be created under the /scripts directory.

To actually use any of the implementations, you would have to activate the environment you want. For example, to use the cairo-rs-py integration you need to run:

source scripts/cairo-rs-py/bin/activate

After activating the cairo-rs-py virtualenv you can try out any Cairo project and it will use cairo-rs. In some cases some projects are coupled to cairo-run or need some extra patching to be able to use the Cairo-rs runner (e.g. Protostar, Zerosync).

Note that the script assumes you have a Rust toolchain, Python 3.9 and the venv program installed.

How to manually install the script dependencies

cairo-lang requires the gmp library to build. You can install it on Debian-based GNU/Linux distributions with:

sudo apt install -y libgmp3-dev

In Mac you can use Homebrew:

brew install gmp

In Mac you'll also need to tell the script where to find the gmp lib:

export CFLAGS=-I/opt/homebrew/opt/gmp/include LDFLAGS=-L/opt/homebrew/opt/gmp/lib
sh build_envs.sh

📊 Benchmarking

To run the benchmarks of the projects we integrated with, first you need to set up the dependencies:

make benchmark-deps

Lastly, run make + the project you desire to try:

benchmark-devnet

🌞 Related Projects

  • cairo-rs: A fast implementation of the Cairo VM in Rust.
  • starknet_in_rust: implementation of Starknet in Rust, powered by the cairo-rs VM.

⚖️ License

This project is licensed under the Apache 2.0 license.

See LICENSE for more information.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

cairo_rs_py-0.1.1.tar.gz (92.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

cairo_rs_py-0.1.1-cp39-cp39-macosx_11_0_arm64.whl (1.2 MB view details)

Uploaded CPython 3.9macOS 11.0+ ARM64

File details

Details for the file cairo_rs_py-0.1.1.tar.gz.

File metadata

  • Download URL: cairo_rs_py-0.1.1.tar.gz
  • Upload date:
  • Size: 92.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.15

File hashes

Hashes for cairo_rs_py-0.1.1.tar.gz
Algorithm Hash digest
SHA256 2022cf8c5e6a5104dbfcbcf40fa2fb21d1f3aa476c43b7a93b9d57404f4ec3c1
MD5 aed5d0118d00cc45b8c59b7b3516b639
BLAKE2b-256 e5cd72806259047c252194c28c32e8fa5973490936431aaca4ab172dc37a1742

See more details on using hashes here.

File details

Details for the file cairo_rs_py-0.1.1-cp39-cp39-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for cairo_rs_py-0.1.1-cp39-cp39-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 c77a09e1f7b9965a9c5e9c8c03dbe450b7ef52f76043d775851166cff22da3ef
MD5 7f63e6b7cc452bc35543aab0deeec86d
BLAKE2b-256 2351dea3461d85b0ed7412a34d0695d80fc029b0e20a9b626c0e5ba0bf5f34dc

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page