-
Notifications
You must be signed in to change notification settings - Fork 157
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into hyper-threading-workflow
- Loading branch information
Showing
52 changed files
with
2,147 additions
and
1,064 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -194,6 +194,10 @@ jobs: | |
smoke: | ||
needs: merge-caches | ||
name: Make sure all builds work | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
crate: ["vm", "cairo-vm-cli", "cairo1-run"] | ||
runs-on: ubuntu-22.04 | ||
steps: | ||
- name: Install Rust | ||
|
@@ -210,6 +214,7 @@ jobs: | |
uses: taiki-e/install-action@v2 | ||
with: | ||
tool: cargo-all-features | ||
|
||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
|
||
|
@@ -226,19 +231,86 @@ jobs: | |
fail-on-cache-miss: true | ||
|
||
# NOTE: we do this separately because --workspace operates in weird ways | ||
- name: Check all features (vm) | ||
- name: Check all features (${{ matrix.crate }}) | ||
run: | | ||
cd vm | ||
cd ${{ matrix.crate }} | ||
cargo check-all-features | ||
cargo check-all-features --workspace --all-targets | ||
smoke-workspace: | ||
needs: merge-caches | ||
name: Make sure all builds work (workspace) | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
chunk: [1, 2, 3, 4, 5, 6] | ||
runs-on: ubuntu-22.04 | ||
steps: | ||
- name: Install Rust | ||
uses: dtolnay/[email protected] | ||
with: | ||
targets: wasm32-unknown-unknown | ||
|
||
- name: Set up cargo cache | ||
uses: Swatinem/rust-cache@v2 | ||
with: | ||
cache-on-failure: true | ||
|
||
- name: Install cargo-all-features | ||
uses: taiki-e/install-action@v2 | ||
with: | ||
tool: cargo-all-features | ||
|
||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
|
||
- name: Download proof programs symlinks | ||
uses: actions/download-artifact@master | ||
with: | ||
name: proof_programs | ||
path: cairo_programs/proof_programs/ | ||
|
||
- name: Fetch programs | ||
uses: actions/cache/restore@v3 | ||
with: | ||
path: ${{ env.CAIRO_PROGRAMS_PATH }} | ||
key: all-programs-cache-${{ hashFiles('cairo_programs/**/*.cairo', 'examples/wasm-demo/src/array_sum.cairo') }} | ||
fail-on-cache-miss: true | ||
|
||
- name: Check all features (CLI) | ||
run: | | ||
cd cairo-vm-cli | ||
cargo check-all-features | ||
- name: Check all features (workspace) | ||
run: | | ||
cargo check-all-features --workspace --all-targets | ||
cargo check-all-features --n-chunks 6 --chunk ${{ matrix.chunk }} --workspace --all-targets | ||
smoke-no-std: | ||
needs: merge-caches | ||
name: Make sure all builds work (no_std) | ||
runs-on: ubuntu-22.04 | ||
steps: | ||
- name: Install Rust | ||
uses: dtolnay/[email protected] | ||
with: | ||
targets: wasm32-unknown-unknown | ||
|
||
- name: Set up cargo cache | ||
uses: Swatinem/rust-cache@v2 | ||
with: | ||
cache-on-failure: true | ||
|
||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
|
||
- name: Download proof programs symlinks | ||
uses: actions/download-artifact@master | ||
with: | ||
name: proof_programs | ||
path: cairo_programs/proof_programs/ | ||
|
||
- name: Fetch programs | ||
uses: actions/cache/restore@v3 | ||
with: | ||
path: ${{ env.CAIRO_PROGRAMS_PATH }} | ||
key: all-programs-cache-${{ hashFiles('cairo_programs/**/*.cairo', 'examples/wasm-demo/src/array_sum.cairo') }} | ||
fail-on-cache-miss: true | ||
|
||
- name: Check no-std | ||
run: | | ||
|
@@ -251,7 +323,7 @@ jobs: | |
strategy: | ||
fail-fast: false | ||
matrix: | ||
special_features: ["", "extensive_hints"] | ||
special_features: ["", "extensive_hints", "mod_builtin"] | ||
target: [ test#1, test#2, test#3, test#4, test-no_std#1, test-no_std#2, test-no_std#3, test-no_std#4, test-wasm ] | ||
name: Run tests | ||
runs-on: ubuntu-22.04 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,124 @@ | ||
// This file is a copy of common/modulo.cairo + added structs from common/cairo_builtins.cairo so that we can run modulo programs in CI | ||
from starkware.cairo.common.math import safe_div, unsigned_div_rem | ||
from starkware.cairo.common.registers import get_label_location | ||
|
||
// Represents a 384-bit unsigned integer d0 + 2**96 * d1 + 2**192 * d2 + 2**288 * d3 | ||
// where each di is in [0, 2**96). | ||
struct UInt384 { | ||
d0: felt, | ||
d1: felt, | ||
d2: felt, | ||
d3: felt, | ||
} | ||
|
||
// Specifies the Add and Mul Mod builtins memory structure. | ||
struct ModBuiltin { | ||
// The modulus. | ||
p: UInt384, | ||
// A pointer to input values, the intermediate results and the output. | ||
values_ptr: UInt384*, | ||
// A pointer to offsets inside the values array, defining the circuit. | ||
// The offsets array should contain 3 * n elements. | ||
offsets_ptr: felt*, | ||
// The number of operations to perform. | ||
n: felt, | ||
} | ||
|
||
const BATCH_SIZE = 1; | ||
|
||
// Returns the smallest felt 0 <= q < rc_bound such that x <= q * y. | ||
func div_ceil{range_check_ptr}(x: felt, y: felt) -> felt { | ||
let (q, r) = unsigned_div_rem(x, y); | ||
if (r != 0) { | ||
return q + 1; | ||
} else { | ||
return q; | ||
} | ||
} | ||
|
||
// Fills the first instance of the add_mod and mul_mod builtins and calls the fill_memory hint to | ||
// fill the rest of the instances and the missing values in the values table. | ||
// | ||
// This function uses a hardcoded value of batch_size=8, and asserts the instance definitions use | ||
// the same value. | ||
func run_mod_p_circuit_with_large_batch_size{ | ||
range_check_ptr, add_mod_ptr: ModBuiltin*, mul_mod_ptr: ModBuiltin* | ||
}( | ||
p: UInt384, | ||
values_ptr: UInt384*, | ||
add_mod_offsets_ptr: felt*, | ||
add_mod_n: felt, | ||
mul_mod_offsets_ptr: felt*, | ||
mul_mod_n: felt, | ||
) { | ||
const BATCH_SIZE = 8; | ||
let add_mod_n_instances = div_ceil(add_mod_n, BATCH_SIZE); | ||
assert add_mod_ptr[0] = ModBuiltin( | ||
p=p, | ||
values_ptr=values_ptr, | ||
offsets_ptr=add_mod_offsets_ptr, | ||
n=add_mod_n_instances * BATCH_SIZE, | ||
); | ||
|
||
let mul_mod_n_instances = div_ceil(mul_mod_n, BATCH_SIZE); | ||
assert mul_mod_ptr[0] = ModBuiltin( | ||
p=p, | ||
values_ptr=values_ptr, | ||
offsets_ptr=mul_mod_offsets_ptr, | ||
n=mul_mod_n_instances * BATCH_SIZE, | ||
); | ||
|
||
%{ | ||
from starkware.cairo.lang.builtins.modulo.mod_builtin_runner import ModBuiltinRunner | ||
assert builtin_runners["add_mod_builtin"].instance_def.batch_size == ids.BATCH_SIZE | ||
assert builtin_runners["mul_mod_builtin"].instance_def.batch_size == ids.BATCH_SIZE | ||
ModBuiltinRunner.fill_memory( | ||
memory=memory, | ||
add_mod=(ids.add_mod_ptr.address_, builtin_runners["add_mod_builtin"], ids.add_mod_n), | ||
mul_mod=(ids.mul_mod_ptr.address_, builtin_runners["mul_mod_builtin"], ids.mul_mod_n), | ||
) | ||
%} | ||
|
||
let add_mod_ptr = &add_mod_ptr[add_mod_n_instances]; | ||
let mul_mod_ptr = &mul_mod_ptr[mul_mod_n_instances]; | ||
return (); | ||
} | ||
|
||
// Fills the first instance of the add_mod and mul_mod builtins and calls the fill_memory hint to | ||
// fill the rest of the instances and the missing values in the values table. | ||
// | ||
// This function uses a hardcoded value of batch_size=1, and asserts the instance definitions use | ||
// the same value. | ||
func run_mod_p_circuit{add_mod_ptr: ModBuiltin*, mul_mod_ptr: ModBuiltin*}( | ||
p: UInt384, | ||
values_ptr: UInt384*, | ||
add_mod_offsets_ptr: felt*, | ||
add_mod_n: felt, | ||
mul_mod_offsets_ptr: felt*, | ||
mul_mod_n: felt, | ||
) { | ||
assert add_mod_ptr[0] = ModBuiltin( | ||
p=p, values_ptr=values_ptr, offsets_ptr=add_mod_offsets_ptr, n=add_mod_n | ||
); | ||
|
||
assert mul_mod_ptr[0] = ModBuiltin( | ||
p=p, values_ptr=values_ptr, offsets_ptr=mul_mod_offsets_ptr, n=mul_mod_n | ||
); | ||
|
||
%{ | ||
from starkware.cairo.lang.builtins.modulo.mod_builtin_runner import ModBuiltinRunner | ||
assert builtin_runners["add_mod_builtin"].instance_def.batch_size == 1 | ||
assert builtin_runners["mul_mod_builtin"].instance_def.batch_size == 1 | ||
ModBuiltinRunner.fill_memory( | ||
memory=memory, | ||
add_mod=(ids.add_mod_ptr.address_, builtin_runners["add_mod_builtin"], ids.add_mod_n), | ||
mul_mod=(ids.mul_mod_ptr.address_, builtin_runners["mul_mod_builtin"], ids.mul_mod_n), | ||
) | ||
%} | ||
|
||
let add_mod_ptr = &add_mod_ptr[add_mod_n]; | ||
let mul_mod_ptr = &mul_mod_ptr[mul_mod_n]; | ||
return (); | ||
} |
Oops, something went wrong.