Skip to content

Commit

Permalink
Merge branch 'main' into update-logo
Browse files Browse the repository at this point in the history
  • Loading branch information
pefontana authored Apr 17, 2024
2 parents 29c0727 + 584eaa2 commit 91eba85
Show file tree
Hide file tree
Showing 143 changed files with 7,070 additions and 2,977 deletions.
110 changes: 110 additions & 0 deletions .github/workflows/hyper_threading_benchmarks.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
name: Benchmark Hyper Threading

on:
pull_request:
branches:
- main

jobs:
benchmark:
runs-on: ubuntu-latest
steps:
- name: Checkout PR
uses: actions/checkout@v2
with:
ref: ${{ github.head_ref }}

- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: '3.9'

- name: Install Dependencies
run: |
pip install -r requirements.txt
sudo apt update
sudo apt-get install -y hyperfine
- name: Install Rust
uses: dtolnay/rust-toolchain@1.74.1
with:
components: rustfmt, clippy

- name: Compile PR Version
run: |
cargo build --release -p hyper_threading
cp target/release/hyper_threading ${{ github.workspace }}/hyper_threading_pr
cp ./examples/hyper_threading/hyper-threading-workflow.sh ${{ github.workspace }}/hyper-threading-workflow.sh
- name: Upload PR Binary
uses: actions/upload-artifact@v4
with:
name: hyper_threading_pr_binary
path: ${{ github.workspace }}/hyper_threading_pr

- name: Upload Workflow Script
uses: actions/upload-artifact@v4
with:
name: hyper_threading_workflow_script
path: ${{ github.workspace }}/hyper-threading-workflow.sh


- name: Checkout Main Branch
uses: actions/checkout@v2
with:
ref: 'main'

- name: Compile Main Version
run: |
cargo build --release -p hyper_threading
cp target/release/hyper_threading ${{ github.workspace }}/hyper_threading_main
- name: Download hyper_threading_pr_binary
uses: actions/download-artifact@v4
with:
name: hyper_threading_pr_binary
path: ${{ github.workspace }}/

- name: Download hyper_threading_workflow_script
uses: actions/download-artifact@v4
with:
name: hyper_threading_workflow_script
path: ${{ github.workspace }}/

- name: Compile programs
run: make cairo_bench_programs

- name: Run Benchmarks
run: |
cd ${{ github.workspace }}
chmod +x ./hyper_threading_main
chmod +x ./hyper_threading_pr
chmod +x hyper-threading-workflow.sh
./hyper-threading-workflow.sh
- name: Compare Results
run: |
cat result.md
- name: Find comment
uses: peter-evans/find-comment@v2
id: fc
with:
issue-number: ${{ github.event.pull_request.number }}
comment-author: 'github-actions[bot]'
body-includes: "**Hyper Thereading Benchmark results**"

- name: Create comment
if: steps.fc.outputs.comment-id == ''
uses: peter-evans/create-or-update-comment@v3
with:
issue-number: ${{ github.event.pull_request.number }}
body-path: result.md

- name: Update comment
if: steps.fc.outputs.comment-id != ''
uses: peter-evans/create-or-update-comment@v3
with:
comment-id: ${{ steps.fc.outputs.comment-id }}
body-path: result.md
edit-mode: replace
129 changes: 120 additions & 9 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -210,6 +214,7 @@ jobs:
uses: taiki-e/install-action@v2
with:
tool: cargo-all-features

- name: Checkout
uses: actions/checkout@v3

Expand All @@ -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/rust-toolchain@1.74.1
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/rust-toolchain@1.74.1
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: |
Expand All @@ -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
Expand Down Expand Up @@ -613,3 +685,42 @@ jobs:
cairo-compile cairo_programs/array_sum.cairo --no_debug_info --output cairo_programs/array_sum.json
cd examples/wasm-demo
wasm-pack build --target=web
compare-factorial-outputs-all-layouts:
name: Compare factorial outputs for all layouts
needs: [ build-programs, build-release ]
runs-on: ubuntu-22.04
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Python3 Build
uses: actions/setup-python@v4
with:
python-version: '3.9'
cache: 'pip'

- name: Install cairo-lang and deps
run: pip install -r requirements.txt

- name: Fetch release binary
uses: actions/cache/restore@v3
with:
key: cli-bin-rel-${{ github.sha }}
path: target/release/cairo-vm-cli
fail-on-cache-miss: true

- 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: cairo_proof_programs-cache-${{ hashFiles('cairo_programs/**/*.cairo', 'examples/wasm-demo/src/array_sum.cairo') }}
fail-on-cache-miss: true

- name: Run script
run: ./vm/src/tests/compare_factorial_outputs_all_layouts.sh
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
**/*.memory
**/*.air_public_input
**/*.air_private_input
**/*.pie.zip
**/*.swp
bench/results
.python-version
Expand Down
87 changes: 87 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,95 @@

#### Upcoming Changes

* Bump `starknet-types-core` version + Use the lib's pedersen hash [#1692](https://github.com/lambdaclass/cairo-vm/pull/1692)

* refactor: Remove unused code & use constants whenever possible for builtin instance definitions[#1707](https://github.com/lambdaclass/cairo-vm/pull/1707)

* feat: missing EC hints for Starknet OS 0.13.1 [#1706](https://github.com/lambdaclass/cairo-vm/pull/1706)

* fix(BREAKING): Use program builtins in `initialize_main_entrypoint` & `read_return_values`[#1703](https://github.com/lambdaclass/cairo-vm/pull/1703)
* `initialize_main_entrypoint` now iterates over the program builtins when building the stack & inserts 0 for any missing builtin
* `read_return_values` now only computes the final stack of the builtins in the program
* BREAKING: `read_return_values` now takes a boolean argument `allow_missing_builtins`
* Added method `BuiltinRunner::identifier` to get the `BuiltinName` of each builtin
* BREAKING: `OutputBuiltinRunner::get_public_memory` now takes a reference to `MemorySegmentManager`
* BREAKING: method `VirtualMachine::get_memory_segment_addresses` moved to `CairoRunner::get_memory_segment_addresses`

* feat(BREAKING): Add range_check96 builtin[#1698](https://github.com/lambdaclass/cairo-vm/pull/1698)
* Add the new `range_check96` builtin to the `all_cairo` layout.
* `RangeCheckBuiltinRunner` changes:
* Remove field `n_parts`, replacing it with const generic `N_PARTS`.
* Remome `n_parts` argument form method `new`.
* Remove field `_bound`, replacing it with public method `bound`.
* Add public methods `name` & `n_parts`.

* feat(BREAKING): Add mod builtin [#1673](https://github.com/lambdaclass/cairo-vm/pull/1673)

Main Changes:
* Add the new `ModBuiltinRunner`, implementing the builtins `add_mod` & `mul_mod`
* Adds `add_mod` & `mul_mod` to the `all_cairo` & `dynamic` layouts under the `mod_builtin` feature flag. This will be added to the main code in a future update.
* Add method `VirtualMachine::fill_memory` in order to perform the new builtin's main logic from within hints
* Add hints to run arithmetic circuits using `add_mod` and/or `mul_mod` builtins

Other Changes:
* BREAKING: BuiltinRunner method signature change from
`air_private_input(&self, memory: &Memory) -> Vec<PrivateInput>` to `pub fn air_private_input(&self, segments: &MemorySegmentManager) -> Vec<PrivateInput>`
* Add `MayleRelocatable::sub_usize`
* Implement `Add<u32> for Relocatable`
* Add `Memory::get_usize`
* BREAKING: Clean up unused/duplicated code from builtins module:
* Remove unused method `get_memory_segment_addresses` from all builtin runners & the enum
* Remove empty implementations of `deduce_memory_cell` & `add_validation_rules` from all builtin runners
* Remove duplicated implementation of `final_stack` from all builtin runners except output and move it to the enum implementation

* bugfix(BREAKING): Handle off2 immediate case in `get_integer_from_reference`[#1701](https://github.com/lambdaclass/cairo-vm/pull/1701)
* `get_integer_from_reference` & `get_integer_from_var_name` output changed from `Result<Cow<'a, Felt252>, HintError>` to `Result<Felt252, HintError>`

* feat: Reorganized builtins to be in the top of stack at the end of a run (Cairo1).

* BREAKING: Remove `CairoRunner::add_additional_hash_builtin` & `VirtualMachine::disable_trace`[#1658](https://github.com/lambdaclass/cairo-vm/pull/1658)

* feat: output builtin add_attribute method [#1691](https://github.com/lambdaclass/cairo-vm/pull/1691)

* feat: add a method to retrieve the output builtin from the VM [#1690](https://github.com/lambdaclass/cairo-vm/pull/1690)

* feat: Add zero segment [#1668](https://github.com/lambdaclass/cairo-vm/pull/1668)

* feat: Bump cairo_lang to 0.13.1 in testing env [#1687](https://github.com/lambdaclass/cairo-vm/pull/1687)

* feat(BREAKING): Use return type info from sierra when serializing return values in cairo1-run crate [#1665](https://github.com/lambdaclass/cairo-vm/pull/1665)
* Removed public function `serialize_output`.
* Add field `serialize_output` to `Cairo1RunConfig`.
* Function `cairo_run_program` now returns an extra `Option<String>` value with the serialized output if `serialize_output` is enabled in the config.
* Output serialization improved as it now uses the sierra program data to identify return value's types.

* feat: Create hyper_threading crate to benchmark the `cairo-vm` in a hyper-threaded environment [#1679](https://github.com/lambdaclass/cairo-vm/pull/1679)

* feat: add a `--tracer` option which hosts a web server that shows the line by line execution of cairo code along with memory registers [#1265](https://github.com/lambdaclass/cairo-vm/pull/1265)

* feat: Fix error handling in `initialize_state`[#1657](https://github.com/lambdaclass/cairo-vm/pull/1657)

* feat: Make air public inputs deserializable [#1657](https://github.com/lambdaclass/cairo-vm/pull/1648)

* feat: Show only layout builtins in air private input [#1651](https://github.com/lambdaclass/cairo-vm/pull/1651)

* feat: Sort builtin segment info upon serialization for Cairo PIE [#1654](https://github.com/lambdaclass/cairo-vm/pull/1654)

* feat: Fix output serialization for cairo 1 [#1645](https://github.com/lambdaclass/cairo-vm/pull/1645)
* Reverts changes added by #1630
* Extends the serialization of Arrays added by the `print_output` flag to Spans and Dictionaries
* Now dereferences references upon serialization

* feat: Add flag to append return values to output segment when not running in proof_mode [#1646](https://github.com/lambdaclass/cairo-vm/pull/1646)
* Adds the flag `append_return_values` to both the CLI and `Cairo1RunConfig` struct.
* Enabling flag will add the output builtin and the necessary instructions to append the return values to the output builtin's memory segment.

* feat: Compute program hash chain [#1647](https://github.com/lambdaclass/cairo-vm/pull/1647)

* feat: Add cairo1-run output pretty-printing for felts, arrays/spans and dicts [#1630](https://github.com/lambdaclass/cairo-vm/pull/1630)

* feat: output builtin features for bootloader support [#1580](https://github.com/lambdaclass/cairo-vm/pull/1580)

#### [1.0.0-rc1] - 2024-02-23

* Bump `starknet-types-core` dependency version to 0.0.9 [#1628](https://github.com/lambdaclass/cairo-vm/pull/1628)
Expand Down
2 changes: 1 addition & 1 deletion CODEOWNERS
Original file line number Diff line number Diff line change
@@ -1 +1 @@
* @igaray @Oppen @fmoletta @entropidelic @juanbono @pefontana
* @igaray @Oppen @fmoletta @juanbono @pefontana
Loading

0 comments on commit 91eba85

Please sign in to comment.