Skip to content

Commit

Permalink
Merge branch 'segment-arena-builtin' into verify-secure-program-segme…
Browse files Browse the repository at this point in the history
…nt-size
  • Loading branch information
fmoletta committed Mar 31, 2023
2 parents 8f56444 + 9a5f06f commit 5307f97
Show file tree
Hide file tree
Showing 49 changed files with 315 additions and 143 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/bench.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:
with:
python-version: '3.9'
- name: Install test dependencies
run: pip install ecdsa fastecdsa sympy cairo-lang==0.11.0
run: pip install -r requirements.txt
- name: Run benchmark
run: make benchmark-action
- name: Store benchmark result
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/bench_pull_request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
with:
python-version: '3.9'
- name: Install test dependencies
run: pip install ecdsa fastecdsa sympy cairo-lang==0.11.0
run: pip install -r requirements.txt
- name: Run benchmark
run: make benchmark-action
- name: Store benchmark result
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/iai_main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
python-version: '3.9'
- name: Install test dependencies
run: |
pip install ecdsa fastecdsa sympy cairo-lang==0.11.0
pip install -r requirements.txt
sudo apt update
sudo apt install -y valgrind
- uses: actions/checkout@v3
Expand Down
14 changes: 8 additions & 6 deletions .github/workflows/iai_pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,16 @@ jobs:
uses: actions/setup-python@v4
with:
python-version: '3.9'
- name: Checkout
uses: actions/checkout@v3
with:
ref: ${{ github.event.pull_request.base.sha }}
- name: Install test dependencies
# Note: change cairo-lang version is not set to 0.11 because main is still on 0.10.3 and this workflow would fail
run: |
pip install ecdsa fastecdsa sympy typeguard==2.13.0 cairo-lang==0.10.3
pip install ecdsa fastecdsa sympy typeguard==2.13.0 cairo-lang==0.10.3
sudo apt update
sudo apt install -y valgrind
- uses: actions/checkout@v3
with:
ref: ${{ github.event.pull_request.base.sha }}
- name: Initialize IAI cache for ${{ github.event.pull_request.base.sha }}
uses: actions/cache@v3
id: cache-iai-results
Expand Down Expand Up @@ -54,12 +55,13 @@ jobs:
uses: actions/setup-python@v4
with:
python-version: '3.9'
- name: Checkout
uses: actions/checkout@v3
- name: Install test dependencies
run: |
pip install ecdsa fastecdsa sympy cairo-lang==0.11.0
pip install -r requirements.txt
sudo apt update
sudo apt install -y valgrind
- uses: actions/checkout@v3
- name: Initialize IAI cache for ${{ github.event.pull_request.base.sha }}
uses: actions/cache@v3
id: cache-iai-results
Expand Down
4 changes: 4 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ jobs:
profile: minimal
toolchain: stable
override: true
- name: Publish crate cairo-take_until_unbalanced
env:
CRATES_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
run: cargo publish --token ${CRATES_TOKEN} --all-features --manifest-path ./deps/parse-hyperlinks/Cargo.toml
- name: Publish crate cairo-felt
env:
CRATES_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
Expand Down
12 changes: 6 additions & 6 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,12 @@ jobs:

- name: Set up cargo cache
uses: Swatinem/rust-cache@v2

- name: Install test dependencies
run: pip install ecdsa fastecdsa sympy cairo-lang==0.11.0
- uses: actions/checkout@v3
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
fetch-depth: 0
- name: Install test dependencies
run: pip install -r requirements.txt
- name: Format
run: cargo fmt --all -- --check
- name: Build
Expand All @@ -63,7 +63,7 @@ jobs:
- name: Restore timestamps
uses: chetan/git-restore-mtime-action@v1
- name: Install dependencies
run: pip install ecdsa fastecdsa sympy cairo-lang==0.11.0
run: pip install -r requirements.txt
- name: Run tests
run: make -j test
- name: Run tests no_std
Expand Down
26 changes: 13 additions & 13 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 5 additions & 5 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ members = [".", "felt", "cairo-vm-cli", "./deps/parse-hyperlinks"]

[package]
name = "cairo-vm"
version = "0.2.0"
version = "0.2.2"
edition = "2021"
license = "Apache-2.0"
description = "Blazing fast Cairo interpreter"
Expand Down Expand Up @@ -48,10 +48,10 @@ serde_json = { version = "1.0", features = [
"arbitrary_precision",
], default-features = false }
hex = { version = "0.4.3", default-features = false }
bincode = { tag = "v2.0.0-rc.2", git = "https://github.com/bincode-org/bincode.git", default-features = false, features = [
bincode = { version = "2.0.0-rc.2", tag = "v2.0.0-rc.2", git = "https://github.com/bincode-org/bincode.git", default-features = false, features = [
"serde",
] }
starknet-crypto = { version = "0.4.1", default-features = false, features = ["signature-display"] }
starknet-crypto = { version = "0.4.2", default-features = false, features = ["signature-display"] }
sha3 = { version = "0.10.1", default-features = false }
rand_core = { version = "0.6.4", default-features = false }
lazy_static = { version = "1.4.0", default-features = false, features = [
Expand All @@ -71,8 +71,8 @@ thiserror-no-std = "2.0.2"
# https://stackoverflow.com/questions/70630556/parse-allowing-nested-parentheses-in-nom
# There is a proposal for extending nom::delimited to use this function:
# https://github.com/Geal/nom/issues/1253
parse-hyperlinks = { path = "./deps/parse-hyperlinks", version = "0.23.4", default-features = false }
felt = { package = "cairo-felt", path = "./felt", version = "0.2.0", default-features = false }
parse-hyperlinks = { package = "cairo-take_until_unbalanced", path = "./deps/parse-hyperlinks", version = "0.24.1", default-features = false }
felt = { package = "cairo-felt", path = "./felt", version = "0.2.2", default-features = false }
bitvec = "1"

[target.'cfg(target_arch = "wasm32")'.dev-dependencies]
Expand Down
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -96,10 +96,10 @@ deps:
cargo install --version 0.5.9 cargo-llvm-cov
pyenv install pypy3.7-7.3.9
pyenv global pypy3.7-7.3.9
pip install typeguard==2.13.0 cairo-lang==0.10.3
pip install -r requirements.txt
pyenv install 3.7.12
pyenv global 3.7.12
pip install typeguard==2.13.0 cairo-lang==0.10.3
pip install -r requirements.txt

$(RELBIN):
cargo build --release
Expand Down
1 change: 1 addition & 0 deletions cairo-vm-cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ fn main() -> Result<(), Error> {
let cairo_run_config = cairo_run::CairoRunConfig {
entrypoint: &args.entrypoint,
trace_enabled,
relocate_mem: args.memory_file.is_some(),
layout: &args.layout,
proof_mode: args.proof_mode,
secure_run: args.secure_run,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ from blake2s_integration_tests import run_tests
from starkware.cairo.common.cairo_builtins import BitwiseBuiltin

func main{range_check_ptr, bitwise_ptr: BitwiseBuiltin*}() {
run_tests(100);
run_tests(300);

return ();
}
2 changes: 1 addition & 1 deletion cairo_programs/benchmarks/compare_arrays_200000.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ func fill_array(array: felt*, base: felt, step: felt, array_length: felt, iterat

func main() {
alloc_locals;
tempvar array_length = 50000;
tempvar array_length = 250000;
let (array_a: felt*) = alloc();
let (array_b: felt*) = alloc();
fill_array(array_a, 7, 3, array_length, 0);
Expand Down
2 changes: 1 addition & 1 deletion cairo_programs/benchmarks/dict_integration_benchmark.cairo
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from dict_integration_tests import run_tests

func main{range_check_ptr: felt}() {
run_tests(100);
run_tests(200);

return ();
}
12 changes: 1 addition & 11 deletions cairo_programs/benchmarks/factorial_multirun.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,11 @@ func factorial(n) -> (result: felt) {
return (n * a,);
}

// factorial(n), t + 1 times
func factorial_wrapper(n, t) {
factorial(n);
if (t != 0) {
factorial_wrapper(n, t - 1);
}
return ();
}

func main() {
// Make sure the factorial(10) == 3628800
let (y) = factorial(10);
y = 3628800;

// factorial(10000), 11 times
factorial_wrapper(10000, 10);
factorial(2000000);
return ();
}
13 changes: 1 addition & 12 deletions cairo_programs/benchmarks/fibonacci_1000_multirun.cairo
Original file line number Diff line number Diff line change
@@ -1,17 +1,6 @@
func main() {
fib_wrapper(50);
ret;
}
fib(1, 1, 1500000);

func fib_wrapper(n) {
// Call fib(1, 1, 1000).
let result: felt = fib(1, 1, 1000);

// Make sure the 1000th Fibonacci number is 222450955505511890955301767713383614666194461405743219770606958667979327682.
assert result = 222450955505511890955301767713383614666194461405743219770606958667979327682;
if (n != 0) {
fib_wrapper(n - 1);
}
ret;
}

Expand Down
2 changes: 1 addition & 1 deletion cairo_programs/benchmarks/integration_builtins.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ func main{
}() {
let num_a = 123568;
let num_b = 5673940;
builtins_wrapper_iter(num_a, num_b, 1000);
builtins_wrapper_iter(num_a, num_b, 10000);

return ();
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ from keccak_integration_tests import run_test
from starkware.cairo.common.cairo_builtins import BitwiseBuiltin

func main{range_check_ptr: felt, bitwise_ptr: BitwiseBuiltin*}() -> () {
run_test(100);
run_test(300);
return ();
}
10 changes: 5 additions & 5 deletions cairo_programs/benchmarks/linear_search.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@ func main() {
alloc_locals;
let (felt_array: felt*) = alloc();

fill_array(felt_array, 10001, 0);
fill_array(felt_array, 400001, 0);

let (index_1) = search(10000, felt_array, 0, 10001);
assert index_1 = 10000;
let (index_2) = search(5000, felt_array, 0, 10001);
assert index_2 = 5000;
let (index_1) = search(400000, felt_array, 0, 400001);
assert index_1 = 400000;
let (index_2) = search(200000, felt_array, 0, 400001);
assert index_2 = 200000;
ret;
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from math_cmp_and_pow_integration_tests import run_tests

func main{range_check_ptr}() -> () {
run_tests(100);
run_tests(30000);
return ();
}
12 changes: 11 additions & 1 deletion cairo_programs/benchmarks/math_integration_benchmark.cairo
Original file line number Diff line number Diff line change
@@ -1,6 +1,16 @@
from math_integration_tests import run_tests

func main{range_check_ptr}() -> () {
func repeat{range_check_ptr}(n) -> () {
if (n == 0) {
return ();
}
run_tests(1000);
return repeat(n - 1);
}

func main{range_check_ptr}() -> () {
//FIXME: there seems to be a bug that causes failures for bigger values.
//For now just run these several times instead.
repeat(8);
return ();
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from memory_integration_tests import run_tests

func main() -> () {
run_tests(100, 100);
run_tests(200, 300);
return ();
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ from operations_with_data_structures import run_tests
from starkware.cairo.common.cairo_builtins import BitwiseBuiltin

func main{range_check_ptr: felt, bitwise_ptr: BitwiseBuiltin*}() {
run_tests(0, 300);
run_tests(0, 500);
return ();
}
2 changes: 1 addition & 1 deletion cairo_programs/benchmarks/secp_integration_benchmark.cairo
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from secp_integration_tests import run_tests

func main{range_check_ptr}() {
run_tests(0, 4);
run_tests(0, 10);
return ();
}
2 changes: 1 addition & 1 deletion cairo_programs/benchmarks/set_integration_benchmark.cairo
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from set_integration_tests import run_tests

func main{range_check_ptr}() -> () {
run_tests(1000);
run_tests(8000);
return ();
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ from starkware.cairo.common.cairo_builtins import BitwiseBuiltin
from uint256_integration_tests import run_tests

func main{range_check_ptr, bitwise_ptr: BitwiseBuiltin*}() -> () {
run_tests(1000);
run_tests(4000);
return ();
}
Loading

1 comment on commit 5307f97

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Performance Alert ⚠️

Possible performance regression was detected for benchmark.
Benchmark result of this commit is worse than the previous benchmark result exceeding threshold 1.30.

Benchmark suite Current: 5307f97 Previous: 27e6165 Ratio
cairo_run(cairo_programs/benchmarks/keccak_integration_benchmark.json) 3094741478 ns/iter (± 76445242) 2166831756 ns/iter (± 9008632) 1.43
cairo_run(cairo_programs/benchmarks/secp_integration_benchmark.json) 3030339776 ns/iter (± 76016124) 2221281309 ns/iter (± 6790907) 1.36
cairo_run(cairo_programs/benchmarks/blake2s_integration_benchmark.json) 2890724527 ns/iter (± 39795998) 2049159344 ns/iter (± 4792450) 1.41
cairo_run(cairo_programs/benchmarks/set_integration_benchmark.json) 2361935867 ns/iter (± 49849139) 1601307251 ns/iter (± 12744224) 1.48

This comment was automatically generated by workflow using github-action-benchmark.

CC: @unbalancedparentheses

Please sign in to comment.