Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
7b65e30
Bump blockifier, change deps, make compile
cptartur Aug 22, 2025
cabae3f
Execute simple_package on native
cptartur Aug 22, 2025
160b497
Add simple test with cheat
cptartur Aug 22, 2025
27816a7
Implement chetable syscall handler for native, implement cheating `ge…
cptartur Aug 22, 2025
f9feca0
Formatting
cptartur Aug 25, 2025
7a82606
Add test for nested cheated calls
cptartur Aug 25, 2025
95d6326
TODO initial support for `call_contract`
cptartur Aug 25, 2025
d72db7f
Add tests for library call
cptartur Aug 25, 2025
9d1fd65
Initial support for `library_call`
cptartur Aug 25, 2025
8efd7e1
Add tests for deploy_syscall
cptartur Aug 25, 2025
5f0076e
Support deploy syscall
cptartur Aug 25, 2025
5afd917
Add test for get_block_hash syscall
cptartur Aug 25, 2025
a4bd441
Support get_block_hash syscall
cptartur Aug 25, 2025
8e1a2b0
Move code to dedicated modules
cptartur Aug 25, 2025
ace454a
Some lints
cptartur Aug 25, 2025
c6612ca
Add error handling
cptartur Aug 25, 2025
c819098
Support events and l1 messages spys
cptartur Aug 26, 2025
951a063
Only run cairo native is tracked resources is sierra gas
cptartur Aug 26, 2025
b3922d1
Add empty node to trace on deploy without constructor
cptartur Aug 26, 2025
7285e89
Return resources for native execution
cptartur Aug 26, 2025
3bbcdff
Do not run pre_execute_syscall for get_execution_info_v2
cptartur Aug 26, 2025
e705594
Restore message
cptartur Aug 26, 2025
7cf6bec
Bump blockifier, change deps, make compile (#3713)
ksew1 Sep 3, 2025
d542f6c
Add sierra validation for native (#3714)
ksew1 Sep 8, 2025
cdf4889
Fix ci (#3717)
ksew1 Sep 9, 2025
e470593
Use different blockifier fork branch
cptartur Sep 12, 2025
0aa05a6
Bundle LLVM (#3698)
cptartur Sep 17, 2025
a2741e2
Run tests on native (#3730)
ksew1 Sep 17, 2025
53b71fc
Extend NATIVE_INSTALLATION.md
cptartur Sep 17, 2025
9714590
Update lock
cptartur Sep 17, 2025
f930a77
Update smoke test target
cptartur Sep 18, 2025
3636d14
Disable smoke tests on macos
cptartur Sep 18, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions .github/actions/setup-rust-llvm/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: Setup Rust + LLVM 19
description: Installs Rust and LLVM 19 toolchain

runs:
using: "composite"
steps:
- uses: dtolnay/rust-toolchain@stable

- uses: Swatinem/rust-cache@9d47c6ad4b02e050fd481d890b2ea34778fd09d6

- name: Add LLVM APT repository
uses: myci-actions/add-deb-repo@11
with:
repo: deb http://apt.llvm.org/jammy/ llvm-toolchain-jammy-19 main
repo-name: llvm-repo
keys-asc: https://apt.llvm.org/llvm-snapshot.gpg.key

- name: Install LLVM
shell: bash
run: |
sudo apt-get update
sudo apt-get install -y \
llvm-19 llvm-19-dev llvm-19-runtime \
clang-19 clang-tools-19 \
lld-19 libpolly-19-dev libmlir-19-dev mlir-19-tools

- name: Set environment variables
shell: bash
run: |
echo "MLIR_SYS_190_PREFIX=/usr/lib/llvm-19/" >> $GITHUB_ENV
echo "LLVM_SYS_191_PREFIX=/usr/lib/llvm-19/" >> $GITHUB_ENV
echo "TABLEGEN_190_PREFIX=/usr/lib/llvm-19/" >> $GITHUB_ENV
68 changes: 42 additions & 26 deletions .github/workflows/_build-binaries.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,26 +25,27 @@ jobs:
include:
- target: x86_64-unknown-linux-gnu
os: ubuntu-latest
# Use cross to link oldest GLIBC possible.
cross: true

- target: x86_64-unknown-linux-musl
os: ubuntu-latest
cross: true

- target: aarch64-unknown-linux-gnu
os: ubuntu-latest
cross: true

- target: aarch64-unknown-linux-musl
os: ubuntu-latest
cross: true
system: linux
#
# - target: x86_64-unknown-linux-musl
# os: ubuntu-latest
# system: linux
#
# - target: aarch64-unknown-linux-gnu
# os: ubuntu-latest
# system: linux
#
# - target: aarch64-unknown-linux-musl
# os: ubuntu-latest
# system: linux

- target: x86_64-apple-darwin
os: macos-latest
os: macos-14-large
system: macos

- target: aarch64-apple-darwin
os: macos-latest
system: macos

steps:
- name: Checkout with ref
Expand All @@ -62,21 +63,36 @@ jobs:
rustup target add ${{ matrix.target }}

- uses: Swatinem/rust-cache@9d47c6ad4b02e050fd481d890b2ea34778fd09d6
with:
workspaces: starknet-foundry

- name: Install cross
if: matrix.cross
uses: taiki-e/install-action@cross
- name: Setup LLVM on MacOS
if: matrix.system == 'macos'
run: |
brew install llvm@19
brew reinstall zstd
echo "MLIR_SYS_190_PREFIX=$(brew --prefix llvm@19)" >> $GITHUB_ENV
echo "LLVM_SYS_191_PREFIX=$(brew --prefix llvm@19)" >> $GITHUB_ENV
echo "TABLEGEN_190_PREFIX=$(brew --prefix llvm@19)" >> $GITHUB_ENV
echo "LIBRARY_PATH=/opt/homebrew/lib" >> $GITHUB_ENV

- name: Enable cross-compilation
if: matrix.cross
shell: bash
- name: Install cross
if: matrix.system == 'linux'
run: |
echo "CARGO=cross" >> $GITHUB_ENV
cargo install cross --git https://github.com/cross-rs/cross

- name: Build
run: ${{ env.CARGO }} build --release --locked --target ${{ matrix.target }}
- name: Build MacOS
if: matrix.system == 'macos'
run: |
export MLIR_SYS_190_PREFIX=${{ env.MLIR_SYS_190_PREFIX }}
export LLVM_SYS_191_PREFIX=${{ env.LLVM_SYS_191_PREFIX }}
export TABLEGEN_190_PREFIX=${{ env.TABLEGEN_190_PREFIX }}
export LIBRARY_PATH=${{ env.LIBRARY_PATH }}
cargo build --release --locked --target ${{ matrix.target }}

- name: Build Linux
if: matrix.system == 'linux'
run: |
# Use cross to link oldest GLIBC possible.
cross build --release --locked --target ${{ matrix.target }}

- name: Package
shell: bash
Expand Down
9 changes: 7 additions & 2 deletions .github/workflows/_test-binaries.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,13 @@ jobs:
- target: x86_64-unknown-linux-gnu
os: ubuntu-latest

- target: x86_64-apple-darwin
os: macos-latest
# TODO restore smoke tests on macos
# - target: aarch64-apple-darwin
# os: macos-latest
#
# - target: x86_64-apple-darwin
# # Target macos-latest uses Mac with ARM, macos-14-large is still on Intel
# os: macos-14-large

steps:
- uses: actions/checkout@v4
Expand Down
63 changes: 22 additions & 41 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- uses: Swatinem/rust-cache@9d47c6ad4b02e050fd481d890b2ea34778fd09d6
- uses: ./.github/actions/setup-rust-llvm
- uses: software-mansion/setup-scarb@v1
- uses: software-mansion/setup-universal-sierra-compiler@v1
- run: cargo test --release --lib -p forge
Expand All @@ -30,14 +29,14 @@ jobs:
fail-fast: false
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- uses: Swatinem/rust-cache@9d47c6ad4b02e050fd481d890b2ea34778fd09d6
- uses: ./.github/actions/setup-rust-llvm
- name: Install nextest
uses: taiki-e/install-action@v2
with:
tool: [email protected]
- name: Build and archive tests
run: cargo nextest archive --release -p forge --features skip_plugin_checks --archive-file 'nextest-archive-${{ runner.os }}.tar.zst'
# TODO: run native only on scheduled workflow
run: cargo nextest archive --release -p forge --features skip_plugin_checks,run-native --archive-file 'nextest-archive-${{ runner.os }}.tar.zst'
- name: Upload archive to workflow
uses: actions/upload-artifact@v4
with:
Expand Down Expand Up @@ -123,8 +122,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- uses: Swatinem/rust-cache@9d47c6ad4b02e050fd481d890b2ea34778fd09d6
- uses: ./.github/actions/setup-rust-llvm
- uses: software-mansion/setup-universal-sierra-compiler@v1
- uses: asdf-vm/actions/install@1902764435ca0dd2f3388eea723a4f92a4eb8302
- run: cargo test --package forge e2e::plugin_versions
Expand All @@ -134,8 +132,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- uses: Swatinem/rust-cache@9d47c6ad4b02e050fd481d890b2ea34778fd09d6
- uses: ./.github/actions/setup-rust-llvm
- uses: software-mansion/setup-universal-sierra-compiler@v1

- run: cargo test --package forge --features no_scarb_installed --lib compatibility_check::tests::failing_tool_not_installed
Expand All @@ -152,8 +149,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- uses: Swatinem/rust-cache@9d47c6ad4b02e050fd481d890b2ea34778fd09d6
- uses: ./.github/actions/setup-rust-llvm
- uses: software-mansion/setup-scarb@v1
- uses: software-mansion/setup-universal-sierra-compiler@v1

Expand All @@ -165,29 +161,27 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- uses: Swatinem/rust-cache@9d47c6ad4b02e050fd481d890b2ea34778fd09d6
- uses: ./.github/actions/setup-rust-llvm
- run: cargo test --release -p forge_runner

test-cheatnet:
name: Test Cheatnet
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- uses: Swatinem/rust-cache@9d47c6ad4b02e050fd481d890b2ea34778fd09d6
- uses: ./.github/actions/setup-rust-llvm
- uses: software-mansion/setup-scarb@v1
- uses: software-mansion/setup-universal-sierra-compiler@v1
- name: Run Cheatnet tests
run: cargo test --release -p cheatnet
# TODO: run native only on scheduled workflow
run: cargo test --release -p cheatnet --features run-native

test-data-transformer:
name: Test Data Transformer
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- uses: Swatinem/rust-cache@9d47c6ad4b02e050fd481d890b2ea34778fd09d6
- uses: ./.github/actions/setup-rust-llvm
- name: Run Data Transformer tests
run: cargo test --release -p data-transformer

Expand All @@ -196,12 +190,12 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- uses: Swatinem/rust-cache@9d47c6ad4b02e050fd481d890b2ea34778fd09d6 # v2.7.8
- uses: ./.github/actions/setup-rust-llvm
- uses: software-mansion/setup-scarb@v1
- uses: software-mansion/setup-universal-sierra-compiler@58146c4184fa6ec5e8aaf02309ab85e35f782ed0 # v1.0.0
- name: Run Forge Debugging tests
run: cargo test --release -p forge --features debugging --test main e2e::debugging
# TODO: run native only on scheduled workflow
run: cargo test --release -p forge --features debugging,run-native --test main e2e::debugging

test-forge-scarb-plugin:
name: Test Forge Scarb Plugin
Expand Down Expand Up @@ -234,10 +228,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@b3b07ba8b418998c39fb20f53e8b695cdcc8de1b
with:
toolchain: stable
- uses: Swatinem/rust-cache@9d47c6ad4b02e050fd481d890b2ea34778fd09d6
- uses: ./.github/actions/setup-rust-llvm
- uses: asdf-vm/actions/install@05e0d2ed97b598bfce82fd30daf324ae0c4570e6
- uses: software-mansion/setup-scarb@v1
- uses: software-mansion/setup-universal-sierra-compiler@v1
Expand All @@ -249,10 +240,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@b3b07ba8b418998c39fb20f53e8b695cdcc8de1b
with:
toolchain: stable
- uses: Swatinem/rust-cache@9d47c6ad4b02e050fd481d890b2ea34778fd09d6
- uses: ./.github/actions/setup-rust-llvm
- name: Run tests
run: cargo test --release -p conversions

Expand All @@ -270,12 +258,11 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- uses: software-mansion/setup-universal-sierra-compiler@v1
- uses: Swatinem/rust-cache@9d47c6ad4b02e050fd481d890b2ea34778fd09d6
- uses: ./.github/actions/setup-rust-llvm
- uses: software-mansion/setup-scarb@v1
- uses: software-mansion/setup-universal-sierra-compiler@v1
- run: cargo test --release -p scarb-api
# TODO: run native only on scheduled workflow
- run: cargo test --release -p scarb-api --features run-native

scarbfmt:
runs-on: ubuntu-latest
Expand Down Expand Up @@ -320,10 +307,7 @@ jobs:
RUSTFLAGS: "-Dwarnings"
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@b3b07ba8b418998c39fb20f53e8b695cdcc8de1b
with:
toolchain: stable
- uses: Swatinem/rust-cache@9d47c6ad4b02e050fd481d890b2ea34778fd09d6
- uses: ./.github/actions/setup-rust-llvm
- run: cargo lint

- name: Lint snforge-scarb-plugin
Expand All @@ -340,11 +324,8 @@ jobs:
env:
MDBOOK_VERSION: 0.4.52
steps:
- uses: dtolnay/rust-toolchain@b3b07ba8b418998c39fb20f53e8b695cdcc8de1b
with:
toolchain: stable
- uses: Swatinem/rust-cache@9d47c6ad4b02e050fd481d890b2ea34778fd09d6
- uses: actions/checkout@v4
- uses: ./.github/actions/setup-rust-llvm
- uses: software-mansion/setup-scarb@v1
- uses: software-mansion/setup-universal-sierra-compiler@v1
- name: Install mdBook
Expand Down
41 changes: 41 additions & 0 deletions CAIRO_NATIVE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# Running Cairo Native

<!-- TOC -->
* [Running Cairo Native](#running-cairo-native)
* [Installing Starknet Foundry With Cairo Native Support](#installing-starknet-foundry-with-cairo-native-support)
* [LLVM](#llvm)
* [`ld`](#ld)
* [Linux](#linux)
* [MacOS](#macos)
* [Running Tests](#running-tests)
<!-- TOC -->

## Installing Starknet Foundry With Cairo Native Support

Cairo Native introduces additional dependencies outside of the Rust ecosystem.

### LLVM

LLVM is linked into Starknet Foundry binary, so it doesn't have to be installed separately at the cost an incrased
binary size.

### `ld`

Cairo Native crate makes direct calls to `ld`, which must in turn be installed on the system.

#### Linux

The package `binutils` contains `ld`, install it with package manager relevant to your distribution or build it
from source.

#### MacOS

`ld` is part of the Xcode command line tools. Install it with `xcode-select --install`.

## Running Tests

To run tests run `snforge test --run-native`, without the flag, the execution will still run in the VM.

When running native features that rely on VM trace like test backtrace, profiler, coverage will not work.
Running native enforces the test to run with `sierra-gas` as tracked resource. Tracking vm resources is not possible
with the native execution.
Loading
Loading