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

Compilation error fixes #32

Merged
merged 13 commits into from
Feb 27, 2024
18 changes: 18 additions & 0 deletions .github/actions/setup-native-dep/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: 'Setup Cairo Native Dependencies'
description: 'Sets up LLVM and GMP libraries'

runs:
using: "composite"
steps:
- 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
shell: bash
- name: Install gmplib
run: sudo apt install -y libgmp3-dev
shell: bash
111 changes: 95 additions & 16 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,30 +1,89 @@
name: ERC20 Native Tests
name: CI

on:
push:
branches:
- main
- main-v[0-9].**
tags:
- v[0-9].**

pull_request:
workflow_dispatch:
types:
- opened
- reopened
- synchronize
- auto_merge_enabled
- edited

env:
MLIR_SYS_170_PREFIX: /usr/lib/llvm-17
LLVM_SYS_170_PREFIX: /usr/lib/llvm-17
TABLEGEN_170_PREFIX: /usr/lib/llvm-17

jobs:
erc20-native-tests:
env:
MLIR_SYS_170_PREFIX: /usr/lib/llvm-17
LLVM_SYS_170_PREFIX: /usr/lib/llvm-17
TABLEGEN_170_PREFIX: /usr/lib/llvm-17
commitlint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Install commitlint
run: npm install --global @commitlint/cli @commitlint/config-conventional

- name: Validate PR commits with commitlint
if: github.event_name == 'pull_request'
run: commitlint --from ${{ github.event.pull_request.base.sha }} --to ${{ github.event.pull_request.head.sha }} --verbose

- name: Validate PR title with commitlint
if: github.event_name != 'merge_group' && github.event_name != 'push' && !(contains(github.event.pull_request.title, '/merge-main') || contains(github.event.pull_request.title, '/merge main'))
run: echo "${{ github.event.pull_request.title }}" | commitlint --verbose

format:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: dtolnay/rust-toolchain@master
with:
components: rustfmt
toolchain: nightly-2023-07-05
- uses: Swatinem/rust-cache@v2
- run: scripts/rust_fmt.sh --check

clippy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: dtolnay/rust-toolchain@stable
with:
components: clippy
- uses: Swatinem/rust-cache@v2
- name: add llvm deb repository
uses: myci-actions/add-deb-repo@10
- name: Set up Native Dependencies
uses: ./.github/actions/setup-native-dep
- run: scripts/clippy.sh

run-tests:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Native Dependencies
uses: ./.github/actions/setup-native-dep
- uses: actions-rs/toolchain@v1
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: Install gmplib
run: sudo apt install -y libgmp3-dev
profile: minimal
toolchain: stable
- uses: Swatinem/rust-cache@v2
- run: cargo test

erc20-native-tests:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- uses: Swatinem/rust-cache@v2
- name: Set up Native Dependencies
uses: ./.github/actions/setup-native-dep
- uses: actions/checkout@v3
with:
repository: 'lambdaclass/cairo_native'
Expand All @@ -38,3 +97,23 @@ jobs:
cd ../.. &&
cd crates/blockifier &&
cargo test --test erc20_tests --features testing

udeps:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: dtolnay/rust-toolchain@master
name: "Rust Toolchain Setup"
with:
toolchain: nightly-2023-07-05
- name: Set up Native Dependencies
uses: ./.github/actions/setup-native-dep
- uses: Swatinem/rust-cache@v2
id: "cache-cargo"
- if: ${{ steps.cache-cargo.outputs.cache-hit != 'true' }}
name: "Download and run cargo-udeps"
run: |
wget -O - -c https://github.com/est31/cargo-udeps/releases/download/v0.1.35/cargo-udeps-v0.1.35-x86_64-unknown-linux-gnu.tar.gz | tar -xz
cargo-udeps-*/cargo-udeps udeps
env:
RUSTUP_TOOLCHAIN: nightly-2023-07-05
34 changes: 34 additions & 0 deletions .github/workflows/compiled_cairo.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: CI

on:
push:
branches:
- main
tags:
- v[0-9].**

pull_request:
types:
- opened
- reopened
- synchronize
paths:
- 'crates/blockifier/feature_contracts/cairo0/**'

jobs:
verify_cairo_file_dependencies:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
with:
components: rustfmt
toolchain: nightly-2023-07-05
- uses: Swatinem/rust-cache@v2
- uses: actions/setup-python@v4
with:
python-version: '3.9'
cache: 'pip'
- run:
pip install -r crates/blockifier/tests/requirements.txt;
cargo test verify_feature_contracts -- --include-ignored
33 changes: 33 additions & 0 deletions .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: Coverage

on: [pull_request, push]

jobs:
coverage:
runs-on: ubuntu-latest
env:
CARGO_TERM_COLOR: always
MLIR_SYS_170_PREFIX: /usr/lib/llvm-17
LLVM_SYS_170_PREFIX: /usr/lib/llvm-17
TABLEGEN_170_PREFIX: /usr/lib/llvm-17
steps:
- uses: actions/checkout@v3
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
- uses: Swatinem/rust-cache@v2
- name: Set up Native Dependencies
uses: ./.github/actions/setup-native-dep
- name: Install cargo-llvm-cov
uses: taiki-e/install-action@cargo-llvm-cov
- name: Generate code coverage
run: cargo llvm-cov --codecov --output-path codecov.json
env:
SEED: 0
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3
with:
token: ${{ secrets.CODECOV_TOKEN }}
verbose: true
fail_ci_if_error: true
24 changes: 24 additions & 0 deletions .github/workflows/post-merge.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: post-merge

on:
pull_request:
types:
- closed
jobs:
if_merged:
if: github.event.pull_request.merged == true
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
with:
components: rustfmt
toolchain: nightly-2023-07-05
- uses: Swatinem/rust-cache@v2
- uses: actions/setup-python@v4
with:
python-version: '3.9'
cache: 'pip'
- run:
pip install -r crates/blockifier/tests/requirements.txt;
cargo test -- --include-ignored
15 changes: 15 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
name: Build Release

on:
push:
tags:
- BLOCKIFIER-v[0-9].**

jobs:
build_python_wheels:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- run: |
cd crates/native_blockifier/
./build.sh
23 changes: 23 additions & 0 deletions .github/workflows/verify-deps.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: Nightly Latest Dependencies Check

on:
schedule:
- cron: '0 0 * * *' # Runs at 00:00 UTC every day

jobs:
latest_deps:
name: Latest Dependencies
runs-on: ubuntu-latest
continue-on-error: true
steps:
- uses: actions/checkout@v3
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
- name: Update Dependencies
run: cargo update --verbose
- name: Build
run: cargo build --verbose
- name: Test
run: cargo test --verbose
8 changes: 3 additions & 5 deletions crates/blockifier/src/execution/contract_class.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ use cairo_lang_casm;
use cairo_lang_casm::hints::Hint;
use cairo_lang_sierra::program::Program as SierraProgram;
use cairo_lang_starknet_classes::casm_contract_class::{CasmContractClass, CasmContractEntryPoint};
use cairo_lang_starknet_classes::NestedIntList;
use cairo_lang_starknet_classes::contract_class::{
ContractClass as SierraContractClass, ContractEntryPoints as SierraContractEntryPoints,
};
use cairo_lang_starknet_classes::NestedIntList;
use cairo_vm::serde::deserialize_program::{
ApTracking, FlowTrackingData, HintParams, ReferenceManager,
};
Expand All @@ -28,14 +28,13 @@ use starknet_api::deprecated_contract_class::{
};

use super::execution_utils::poseidon_hash_many_cost;
use super::sierra_utils::contract_entrypoint_to_entrypoint_selector;
use crate::abi::abi_utils::selector_from_name;
use crate::abi::constants::{self, CONSTRUCTOR_ENTRY_POINT_NAME};
use crate::execution::entry_point::CallEntryPoint;
use crate::execution::errors::{ContractClassError, PreExecutionError};
use crate::execution::execution_utils::{felt_to_stark_felt, sn_api_to_cairo_vm_program};

use super::sierra_utils::contract_entrypoint_to_entrypoint_selector;

/// Represents a runnable Starknet contract class (meaning, the program is runnable by the VM).
/// We wrap the actual class in an Arc to avoid cloning the program when cloning the class.
// Note: when deserializing from a SN API class JSON string, the ABI field is ignored
Expand Down Expand Up @@ -109,7 +108,7 @@ impl ContractClassV0 {
+ self.n_builtins()
+ self.bytecode_length()
+ 1; // Hinted class hash.
// The hashed data size is approximately the number of hashes (invoked in hash chains).
// The hashed data size is approximately the number of hashes (invoked in hash chains).
let n_steps = constants::N_STEPS_PER_PEDERSEN * hashed_data_size;

ExecutionResources {
Expand Down Expand Up @@ -428,7 +427,6 @@ impl ClassInfo {
ContractClass::V0(_) => (0, sierra_program_length == 0),
ContractClass::V1(_) => (1, sierra_program_length > 0),
ContractClass::V1Sierra(_) => todo!("Sierra contract class version and condition"),

};

if condition {
Expand Down
13 changes: 9 additions & 4 deletions crates/blockifier/src/execution/native_syscall_handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@ use starknet_api::transaction::{
};
use starknet_types_core::felt::Felt;

use super::sierra_utils::{chain_id_to_felt, contract_address_to_felt, felt_to_starkfelt, starkfelt_to_felt};
use super::sierra_utils::{
chain_id_to_felt, contract_address_to_felt, felt_to_starkfelt, starkfelt_to_felt,
};
use crate::abi::constants;
use crate::execution::call_info::{CallInfo, MessageToL1, OrderedEvent, OrderedL2ToL1Message};
use crate::execution::common_hints::ExecutionMode;
Expand Down Expand Up @@ -94,11 +96,12 @@ impl<'state> StarkNetSyscallHandler for NativeSyscallHandler<'state> {
sequencer_address: contract_address_to_felt(block_context.sequencer_address),
};

let signature = account_tx_context.signature().0.into_iter().map(starkfelt_to_felt).collect();
let signature =
account_tx_context.signature().0.into_iter().map(starkfelt_to_felt).collect();

let tx_info = TxInfo {
version: starkfelt_to_felt(account_tx_context.version().0),
account_contract_address: contract_address_to_felt(account_tx_context.sender_address(),),
account_contract_address: contract_address_to_felt(account_tx_context.sender_address()),
// todo(rodro): it is ok to unwrap as default? Also, will this be deprecated soon?
max_fee: account_tx_context.max_fee().unwrap_or_default().0,
signature,
Expand Down Expand Up @@ -135,7 +138,9 @@ impl<'state> StarkNetSyscallHandler for NativeSyscallHandler<'state> {
},
tx_info: TxV2Info {
version: starkfelt_to_felt(account_tx_context.version().0),
account_contract_address: contract_address_to_felt(account_tx_context.sender_address()),
account_contract_address: contract_address_to_felt(
account_tx_context.sender_address(),
),
max_fee: account_tx_context.max_fee().unwrap_or_default().0,
signature: vec![],
transaction_hash: Default::default(),
Expand Down
Loading
Loading