Skip to content
This repository has been archived by the owner on Jul 22, 2024. It is now read-only.

Add cairo native #943

Merged
merged 151 commits into from
Oct 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
151 commits
Select commit Hold shift + click to select a range
ff8b778
Added cairo native flag
ElFantasma Aug 24, 2023
cf111ea
Merge branch 'main' into add_cairo_native
ElFantasma Aug 24, 2023
bcc873e
Added cairo_native as dependency
ElFantasma Aug 25, 2023
2bf66f1
Partial progress
jrchatruc Aug 25, 2023
e02401b
Progress
jrchatruc Aug 25, 2023
e89a2b9
Partial progress
jrchatruc Aug 25, 2023
db314f7
Point to newly created branch on cairo native
jrchatruc Aug 25, 2023
645d83e
Use updated version of cairo native and make test pass
entropidelic Aug 25, 2023
6fc7b6b
Run test with storage_write and storage_read with cairo native
entropidelic Aug 25, 2023
31ff7e6
Tidy up code
entropidelic Aug 28, 2023
ed17457
Start unhardcoding stuff
jrchatruc Aug 28, 2023
136fb93
Handle return values
jrchatruc Aug 28, 2023
e8e42e3
Tidy up code a little
entropidelic Aug 29, 2023
b775063
Added sierra programs cache
ElFantasma Aug 29, 2023
2726436
Add impl for emit_event and send_l1_message
entropidelic Aug 29, 2023
911cc91
Fix tests
jrchatruc Aug 29, 2023
5f0e87f
Merge branch 'main' into add_cairo_native
jrchatruc Aug 29, 2023
57dfddc
Install LLVM on CI
jrchatruc Aug 29, 2023
5db7741
Test
jrchatruc Aug 29, 2023
e192ee3
Test CI
jrchatruc Aug 29, 2023
0f5f141
Fix lint step
jrchatruc Aug 29, 2023
bda79ce
Save work in progress
entropidelic Aug 30, 2023
dd3e827
Merge remote-tracking branch 'origin/add_cairo_native' into add_cairo…
entropidelic Aug 30, 2023
ad9606c
Merge branch 'add_sierra_cache' into add_cairo_native
jrchatruc Aug 30, 2023
a7fc96e
Unhardcode calldata and entry point
jrchatruc Aug 30, 2023
5857152
Unhardcode more stuff
jrchatruc Aug 30, 2023
0e04bc7
Fix test
jrchatruc Aug 30, 2023
521e278
Add basic implementation for call_contract
entropidelic Aug 30, 2023
9653d23
Add call to get_name to integration test
jrchatruc Aug 30, 2023
621dc88
Merge remote-tracking branch 'origin/add_cairo_native' into add_cairo…
entropidelic Aug 30, 2023
576dfef
Make call_contract impl compile
entropidelic Aug 30, 2023
9f420b2
Merge remote-tracking branch 'origin/add_cairo_native' into add_cairo…
entropidelic Aug 30, 2023
a818b9a
Fix test
jrchatruc Aug 31, 2023
4440467
Pass the correct amount of builtins for every function
jrchatruc Aug 31, 2023
d7a17c3
Improve test legibility
jrchatruc Aug 31, 2023
e4eb32e
Write call_contract test skeleton
entropidelic Aug 31, 2023
08d53fe
Merge remote-tracking branch 'origin/add_cairo_native' into call-cont…
entropidelic Aug 31, 2023
75dde3b
Finish writing test, still bugs to fix
entropidelic Aug 31, 2023
5e31d7c
implement get_execution_info, make increase_allowance work
jrchatruc Aug 31, 2023
284fe9e
More debugging
entropidelic Aug 31, 2023
f21f8b0
Merge remote-tracking branch 'origin/add_cairo_native' into call-cont…
entropidelic Aug 31, 2023
3968527
Basic test for call_contract working
entropidelic Aug 31, 2023
61fd0ad
More progress on testing ERC20
jrchatruc Aug 31, 2023
94ae33a
More progress on test
jrchatruc Aug 31, 2023
dcd316a
Add caller and callee contracts
entropidelic Aug 31, 2023
1608795
Merge remote-tracking branch 'origin/add_cairo_native' into call-cont…
entropidelic Aug 31, 2023
1899c15
Fix call_contract test after merge
entropidelic Aug 31, 2023
73ced69
Fix callee address in tests
entropidelic Aug 31, 2023
af953eb
Polish some details
entropidelic Aug 31, 2023
6837839
Remove use_cairo_native from TransactionExecutionContext
entropidelic Sep 1, 2023
b7ca1f2
Write test skeleton
entropidelic Sep 1, 2023
1b0e711
Add test contracts
entropidelic Sep 1, 2023
b4bd885
Fix tests
jrchatruc Sep 1, 2023
6189a4c
Readd deleted contracts
jrchatruc Sep 1, 2023
dcd8527
Echo contract test passing
entropidelic Sep 1, 2023
394a640
Update cairo compiler to version 2.2.0
jrchatruc Sep 4, 2023
93cd160
Calling another contract with events test is passing
entropidelic Sep 4, 2023
a5aa449
Merge branch 'main' into add_cairo_native
jrchatruc Sep 4, 2023
b4d6774
Merge remote-tracking branch 'origin/add_cairo_native' into echo-cont…
entropidelic Sep 4, 2023
cb49201
Fix failing tests
entropidelic Sep 4, 2023
a4759e6
Remove internal_calls field TODO in CallInfo returned by native_execute
entropidelic Sep 4, 2023
6937c65
Add event_emitter contract
entropidelic Sep 4, 2023
549ba48
Add cairo vm execution to the erc20 test for comparison
jrchatruc Sep 4, 2023
9e3f9a9
Add simple implementation for panics in native execution
entropidelic Sep 4, 2023
75c0ad8
Add some documentation in code
entropidelic Sep 4, 2023
434865a
Assert equality between events, accessed_storage_keys and l1_l2 messa…
jrchatruc Sep 4, 2023
02f765a
Add event_emitter contract
entropidelic Sep 4, 2023
5e911f5
Merge remote-tracking branch 'origin/add_cairo_native' into handle-pa…
entropidelic Sep 4, 2023
b2a943b
Merge branch 'handle-panic-result' into add_cairo_native
entropidelic Sep 4, 2023
9845558
Remove print
entropidelic Sep 4, 2023
1661f20
Remove comments
jrchatruc Sep 5, 2023
97296d6
Move native syscall handler to its own file
jrchatruc Sep 5, 2023
a6d6ca7
Add felt decode to string when program panics
entropidelic Sep 5, 2023
e9e5773
Merge remote-tracking branch 'origin/add_cairo_native' into add_cairo…
entropidelic Sep 5, 2023
ce2fbd9
Make cairo native an optional dependency behind a feature
jrchatruc Sep 5, 2023
849a53e
Move execution result to cairo native
entropidelic Sep 5, 2023
9f5f3c6
Add a README section explaining how to setup cairo native
jrchatruc Sep 5, 2023
c506210
Merge remote-tracking branch 'origin/add_cairo_native' into add_cairo…
entropidelic Sep 5, 2023
be14167
Merge remote-tracking branch 'origin/add_cairo_native' into add_cairo…
entropidelic Sep 5, 2023
3391544
Merge branch 'main' into add_cairo_native
jrchatruc Sep 5, 2023
2442e8c
Fix some clippy issues
entropidelic Sep 5, 2023
cbf91e3
Fix test compilation
jrchatruc Sep 5, 2023
4631e5e
CI test
jrchatruc Sep 5, 2023
f6ec318
Revert "CI test"
jrchatruc Sep 5, 2023
8ab7e62
CI test
jrchatruc Sep 5, 2023
bfb6379
Test
jrchatruc Sep 5, 2023
afd98b4
Merge branch 'main' into add_cairo_native
jrchatruc Sep 5, 2023
78e8b9b
Test
jrchatruc Sep 5, 2023
fc18c98
Address comment about multiple cfgs
jrchatruc Sep 6, 2023
47a2760
Remove unnecessary clone
jrchatruc Sep 6, 2023
395b46f
Test
jrchatruc Sep 6, 2023
333dc51
Test
jrchatruc Sep 6, 2023
76ad108
Switch to special workflow for native integration tests
jrchatruc Sep 6, 2023
7bcb8e9
Fix workflow
jrchatruc Sep 6, 2023
b5a3f93
Merge branch 'main' into add_cairo_native
azteca1998 Sep 7, 2023
2a8c6f0
Fix stuff after merge.
azteca1998 Sep 7, 2023
5863abb
Fix clippy warnings.
azteca1998 Sep 7, 2023
88a0686
Merge branch 'main' into add_cairo_native
azteca1998 Sep 12, 2023
0c0b239
Fix after merge.
azteca1998 Sep 12, 2023
4c1173f
Fix comments.
azteca1998 Sep 12, 2023
2cf0812
Fix `Makefile`.
azteca1998 Sep 12, 2023
3946fcd
Merge branch 'main' into add_cairo_native
azteca1998 Sep 18, 2023
282f3a7
Remove unused import.
azteca1998 Sep 18, 2023
522bfe5
Merge branch 'main' into add_cairo_native
azteca1998 Sep 28, 2023
6995cad
Use transactional state.
azteca1998 Sep 29, 2023
468dd5d
update cairo native to llvm 17 and remove nightly requirement
edg-l Oct 3, 2023
4a08798
Merge remote-tracking branch 'origin/main' into add_cairo_native
edg-l Oct 3, 2023
0b244b2
update ci
edg-l Oct 3, 2023
ef29b0e
upd ci
edg-l Oct 3, 2023
a02e92f
try to fix ci
edg-l Oct 3, 2023
3957b02
use ubuntu on native
edg-l Oct 3, 2023
844c8af
try to fix ci
edg-l Oct 3, 2023
5e3b26d
not needed?
edg-l Oct 3, 2023
ececf28
fix ci
edg-l Oct 3, 2023
5828c2d
update cairo native
edg-l Oct 3, 2023
436fa95
fix nightly usage
edg-l Oct 3, 2023
26e8859
try to fix ci
edg-l Oct 4, 2023
f88c756
dont need a transactional state reader, simply clone the state reader
edg-l Oct 4, 2023
b1bc799
try to fix ci
edg-l Oct 5, 2023
f940c5c
format
edg-l Oct 5, 2023
5268deb
fix again
edg-l Oct 5, 2023
fade284
fix if
edg-l Oct 5, 2023
19fb2e5
values
edg-l Oct 5, 2023
256a15f
force rebuild
edg-l Oct 5, 2023
5471384
make cache track cairo 2 version to trigger rebuilds
edg-l Oct 5, 2023
da9b1de
try no restore key
edg-l Oct 5, 2023
a8b660a
conflcit
edg-l Oct 5, 2023
4b60e83
update readme
edg-l Oct 6, 2023
3f00c4c
fix tests on ci
edg-l Oct 9, 2023
ea54014
update cairo native commit
edg-l Oct 10, 2023
35acebf
fix more tests on ci
edg-l Oct 10, 2023
b1680b1
fix cairo native interface
edg-l Oct 10, 2023
91bd8b4
try ci without cache
edg-l Oct 10, 2023
00d4d9d
setup rustup home
edg-l Oct 10, 2023
29ed37c
make param passing to cairo native not obscure
edg-l Oct 13, 2023
5919dd9
try
edg-l Oct 13, 2023
0963ac6
try again
edg-l Oct 13, 2023
02d28d4
remove large packages
edg-l Oct 13, 2023
800dc09
remove large dirs
edg-l Oct 13, 2023
7c5b729
remove android too
edg-l Oct 13, 2023
e23e02c
polly is needed
edg-l Oct 13, 2023
3b92208
needs sudo
edg-l Oct 13, 2023
f0c4d63
fix cov
edg-l Oct 13, 2023
94f2d5c
fix test for now
edg-l Oct 13, 2023
79084a3
format
edg-l Oct 13, 2023
bc17854
cleanup ci file
edg-l Oct 17, 2023
88ddfbc
use pyenv if available
edg-l Oct 17, 2023
f37ede2
nightly not needed in readme
edg-l Oct 17, 2023
4a4b6ee
add .sierra as generated to gitattributes
edg-l Oct 17, 2023
d1fe32a
fix gitattributes
edg-l Oct 17, 2023
7798ddf
add casm too
edg-l Oct 17, 2023
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
2 changes: 2 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
*.sierra linguist-generated
*.casm linguist-generated
267 changes: 85 additions & 182 deletions .github/workflows/rust-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,240 +9,139 @@ on:

env:
CARGO_TERM_COLOR: always
RUST_TOOLCHAIN: 1.70.0
CAIRO_PROGRAMS_PATH: |
cairo_programs/**/*.casm
cairo_programs/**/*.sierra
cairo_programs/**/*.json
starknet_programs/**/*.casm
starknet_programs/**/*.sierra
starknet_programs/**/*.json
!starknet_programs/raw_contract_classes/*
RUST_TOOLCHAIN: '1.72.1'

jobs:
build-programs:
strategy:
matrix:
program-target: [
compile-cairo,
compile-starknet,
compile-cairo-1-casm,
compile-cairo-1-sierra,
compile-cairo-2-casm,
compile-cairo-2-sierra,
]
name: Build Cairo programs
runs-on: ubuntu-22.04
build:
name: Build with release profile
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Install Rust $RUST_TOOLCHAIN
uses: dtolnay/rust-toolchain@master
with:
fetch-depth: 0

- name: Fetch from cache
uses: actions/cache@v3
id: cache-programs
with:
path: ${{ env.CAIRO_PROGRAMS_PATH }}
key: ${{ matrix.program-target }}-cache-${{ hashFiles('cairo_programs/**/*.cairo', 'starknet_programs/**/*.cairo') }}
restore-keys: ${{ matrix.program-target }}-cache-

# This is not pretty, but we need `make` to see the compiled programs are
# actually newer than the sources, otherwise it will try to rebuild them
- name: Restore timestamps
uses: chetan/git-restore-mtime-action@v1

toolchain: $RUST_TOOLCHAIN
components: rustfmt, clippy
- name: Python3 Build
if: ${{ steps.cache-programs.outputs.cache-hit != 'true' }}
uses: actions/setup-python@v4
with:
python-version: '3.9'
cache: 'pip'

- name: Install deps
if: ${{ steps.cache-programs.outputs.cache-hit != 'true' }}
run: make deps

- name: Build programs
if: ${{ steps.cache-programs.outputs.cache-hit != 'true' }}
run: make -j ${{ matrix.program-target }}

# NOTE: used to reduce the amount of cache steps we need in later jobs
# TODO: remove this cache once the workflow finishes
merge-caches:
name: Merge Cairo programs cache
runs-on: ubuntu-22.04
needs: build-programs
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Fetch from cache (compile-cairo)
uses: actions/cache/restore@v3
id: cache-programs
with:
path: ${{ env.CAIRO_PROGRAMS_PATH }}
key: compile-cairo-cache-${{ hashFiles('cairo_programs/**/*.cairo', 'starknet_programs/**/*.cairo') }}
fail-on-cache-miss: true

- name: Fetch from cache (compile-starknet)
uses: actions/cache/restore@v3
with:
path: ${{ env.CAIRO_PROGRAMS_PATH }}
key: compile-starknet-cache-${{ hashFiles('cairo_programs/**/*.cairo', 'starknet_programs/**/*.cairo') }}
fail-on-cache-miss: true

- name: Fetch from cache (compile-cairo-1-casm)
uses: actions/cache/restore@v3
with:
path: ${{ env.CAIRO_PROGRAMS_PATH }}
key: compile-cairo-1-casm-cache-${{ hashFiles('cairo_programs/**/*.cairo', 'starknet_programs/**/*.cairo') }}
fail-on-cache-miss: true

- name: Fetch from cache (compile-cairo-1-sierra)
uses: actions/cache/restore@v3
with:
path: ${{ env.CAIRO_PROGRAMS_PATH }}
key: compile-cairo-1-sierra-cache-${{ hashFiles('cairo_programs/**/*.cairo', 'starknet_programs/**/*.cairo') }}
fail-on-cache-miss: true

- name: Fetch from cache (compile-cairo-2-casm)
uses: actions/cache/restore@v3
with:
path: ${{ env.CAIRO_PROGRAMS_PATH }}
key: compile-cairo-2-casm-cache-${{ hashFiles('cairo_programs/**/*.cairo', 'starknet_programs/**/*.cairo') }}
fail-on-cache-miss: true

- name: Fetch from cache (compile-cairo-2-sierra)
uses: actions/cache/restore@v3
with:
path: ${{ env.CAIRO_PROGRAMS_PATH }}
key: compile-cairo-2-sierra-cache-${{ hashFiles('cairo_programs/**/*.cairo', 'starknet_programs/**/*.cairo') }}
fail-on-cache-miss: true

- name: Fetch from cache (compile-cairo-2-sierra)
uses: actions/cache/restore@v3
with:
path: ${{ env.CAIRO_PROGRAMS_PATH }}
key: compile-cairo-2-sierra-cache-${{ hashFiles('cairo_programs/**/*.cairo', 'starknet_programs/**/*.cairo') }}
fail-on-cache-miss: true

- name: Merge caches
uses: actions/cache/save@v3
with:
path: ${{ env.CAIRO_PROGRAMS_PATH }}
key: all-programs-cache-${{ hashFiles('cairo_programs/**/*.cairo', 'starknet_programs/**/*.cairo') }}

build:
name: Build with release profile
needs: merge-caches
runs-on: ubuntu-22.04
steps:
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
with:
toolchain: ${{ env.RUST_TOOLCHAIN }}
components: rustfmt, clippy
- uses: Swatinem/rust-cache@v2
with:
cache-on-failure: true
- name: Checkout
uses: actions/checkout@v3
- name: Fetch programs
uses: actions/cache/restore@v3
with:
path: ${{ env.CAIRO_PROGRAMS_PATH }}
key: all-programs-cache-${{ hashFiles('cairo_programs/**/*.cairo', 'starknet_programs/**/*.cairo') }}
fail-on-cache-miss: true

- name: Install deps
run: make deps
- name: Build
run: cargo build --release --workspace
run: make build

lint:
name: Lint with fmt and clippy
needs: merge-caches
runs-on: ubuntu-22.04
runs-on: ubuntu-latest
steps:
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
- name: Checkout
uses: actions/checkout@v3
- name: Install Rust $RUST_TOOLCHAIN
uses: dtolnay/rust-toolchain@master
with:
toolchain: $RUST_TOOLCHAIN
components: rustfmt, clippy
- name: Python3 Build
uses: actions/setup-python@v4
with:
toolchain: ${{ env.RUST_TOOLCHAIN }}
components: rustfmt, clippy
python-version: '3.9'
cache: 'pip'
- uses: Swatinem/rust-cache@v2
with:
cache-on-failure: true
- name: Checkout
uses: actions/checkout@v3
- name: Fetch programs
uses: actions/cache/restore@v3
with:
path: ${{ env.CAIRO_PROGRAMS_PATH }}
key: all-programs-cache-${{ hashFiles('cairo_programs/**/*.cairo', 'starknet_programs/**/*.cairo') }}
fail-on-cache-miss: true

- name: Install deps
run: make deps
- name: Format
run: cargo fmt --all -- --check
- name: Run clippy
run: cargo clippy --workspace --all-targets -- -D warnings
run: make clippy

tests:
env:
INFURA_API_KEY: ${{ secrets.INFURA_API_KEY }}
MLIR_SYS_170_PREFIX: /usr/lib/llvm-17/
TABLEGEN_170_PREFIX: /usr/lib/llvm-17/
strategy:
fail-fast: false
matrix:
target: [ test-cairo-1, test-cairo-2, test-doctests ]
target: [ test-cairo-1, test-cairo-2, test-doctests, test-cairo-native ]
name: Run tests
needs: merge-caches
runs-on: ubuntu-22.04
runs-on: ubuntu-latest
steps:
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
- name: Checkout
uses: actions/checkout@v3
- name: Install Rust $RUST_TOOLCHAIN
uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ env.RUST_TOOLCHAIN }}
components: rustfmt, clippy
toolchain: $RUST_TOOLCHAIN
components: rustfmt, clippy
- name: Python3 Build
uses: actions/setup-python@v4
with:
python-version: '3.9'
cache: 'pip'
- uses: Swatinem/rust-cache@v2
with:
cache-on-failure: true
- name: Checkout
uses: actions/checkout@v3

- name: Fetch programs
uses: actions/cache/restore@v3
with:
path: ${{ env.CAIRO_PROGRAMS_PATH }}
key: all-programs-cache-${{ hashFiles('cairo_programs/**/*.cairo', 'starknet_programs/**/*.cairo') }}
fail-on-cache-miss: true

- name: Install deps
run: make deps

- name: Install testing tools
# TODO: remove `if` when nextest adds doctests support
if: ${{ matrix.target != 'test-doctests' }}
uses: taiki-e/install-action@v2
with:
tool: [email protected]

- name: check and free hdd space left
run: |
echo "Listing 20 largest packages"
dpkg-query -Wf '${Installed-Size}\t${Package}\n' | sort -n | tail -n 20
df -h
sudo apt-get update
sudo apt-get remove -y '^llvm-.*'
sudo apt-get remove -y 'php.*'
sudo apt-get remove -y '^dotnet-.*'
sudo apt-get remove -y '^temurin-.*'
sudo apt-get remove -y azure-cli google-cloud-cli microsoft-edge-stable google-chrome-stable firefox powershell mono-devel
sudo apt-get autoremove -y
sudo apt-get clean
df -h
echo "Removing large directories"
# deleting 15GB
sudo rm -rf /usr/share/dotnet/
sudo rm -rf /usr/local/lib/android
df -h
- name: add llvm deb repository
uses: myci-actions/add-deb-repo@10
with:
repo: deb http://apt.llvm.org/jammy/ llvm-toolchain-jammy-17 main
repo-name: llvm-repo
keys-asc: https://apt.llvm.org/llvm-snapshot.gpg.key
- name: Install LLVM
run: sudo apt-get install llvm-17 llvm-17-dev llvm-17-runtime clang-17 clang-tools-17 lld-17 libpolly-17-dev libmlir-17-dev mlir-17-tools
- name: Run tests (${{ matrix.target }})
run: make ${{ matrix.target }}

coverage:
needs: merge-caches
name: Generate and upload coverage report
runs-on: ubuntu-22.04
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Install Rust
uses: dtolnay/rust-toolchain@nightly
with:
toolchain: ${{ env.RUST_TOOLCHAIN }}

- name: Set nightly as default
run: rustup default nightly

- name: Install testing tools
uses: taiki-e/install-action@v2
- name: Install Rust nightly
uses: dtolnay/rust-toolchain@master
with:
tool: [email protected],cargo-llvm-cov
toolchain: nightly

- uses: Swatinem/rust-cache@v2
with:
Expand All @@ -255,13 +154,17 @@ jobs:
path: lcov.info
key: coverage-cache-${{ github.sha }}

- name: Fetch programs
if: steps.restore-report.outputs.cache-hit != 'true'
uses: actions/cache/restore@v3
- name: Python3 Build
uses: actions/setup-python@v4
with:
path: ${{ env.CAIRO_PROGRAMS_PATH }}
key: all-programs-cache-${{ hashFiles('cairo_programs/**/*.cairo', 'starknet_programs/**/*.cairo') }}
fail-on-cache-miss: true
python-version: '3.9'
cache: 'pip'
- uses: Swatinem/rust-cache@v2
with:
cache-on-failure: true

- name: Install deps
run: make deps

- name: Generate coverage report
if: steps.restore-report.outputs.cache-hit != 'true'
Expand Down
Loading