Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add WASM example #1315

Merged
merged 40 commits into from
Jul 15, 2023
Merged

feat: add WASM example #1315

merged 40 commits into from
Jul 15, 2023

Conversation

MegaRedHand
Copy link
Contributor

@MegaRedHand MegaRedHand commented Jul 4, 2023

Description

This PR moves the cairo-vm-wasm example to this repo and updates it.

We can later improve it, maybe adding an input and passing it to the Cairo program.

Checklist

  • Linked to Github Issue
  • Unit tests added
  • Integration tests added.
  • This change requires new documentation.
    • Documentation has been added/updated.
    • CHANGELOG has been updated.

@github-actions
Copy link

github-actions bot commented Jul 4, 2023

Benchmark Results for unmodified programs 🚀

Command Mean [s] Min [s] Max [s] Relative
base big_factorial 4.126 ± 0.013 4.116 4.156 1.00
head big_factorial 4.134 ± 0.020 4.109 4.169 1.00 ± 0.01
Command Mean [s] Min [s] Max [s] Relative
base big_fibonacci 3.505 ± 0.013 3.492 3.530 1.00
head big_fibonacci 3.514 ± 0.013 3.501 3.546 1.00 ± 0.01
Command Mean [s] Min [s] Max [s] Relative
base blake2s_integration_benchmark 9.684 ± 0.082 9.618 9.828 1.00 ± 0.01
head blake2s_integration_benchmark 9.649 ± 0.006 9.644 9.666 1.00
Command Mean [s] Min [s] Max [s] Relative
base compare_arrays_200000 3.555 ± 0.008 3.546 3.572 1.00
head compare_arrays_200000 3.576 ± 0.008 3.568 3.595 1.01 ± 0.00
Command Mean [s] Min [s] Max [s] Relative
base dict_integration_benchmark 2.398 ± 0.005 2.391 2.406 1.00 ± 0.00
head dict_integration_benchmark 2.393 ± 0.003 2.390 2.400 1.00
Command Mean [s] Min [s] Max [s] Relative
base field_arithmetic_get_square_benchmark 1.762 ± 0.007 1.753 1.778 1.00
head field_arithmetic_get_square_benchmark 1.765 ± 0.006 1.759 1.775 1.00 ± 0.01
Command Mean [s] Min [s] Max [s] Relative
base integration_builtins 9.569 ± 0.019 9.538 9.597 1.00 ± 0.00
head integration_builtins 9.528 ± 0.010 9.516 9.549 1.00
Command Mean [s] Min [s] Max [s] Relative
base keccak_integration_benchmark 9.732 ± 0.019 9.713 9.763 1.00
head keccak_integration_benchmark 9.760 ± 0.031 9.738 9.821 1.00 ± 0.00
Command Mean [s] Min [s] Max [s] Relative
base linear_search 3.551 ± 0.010 3.539 3.566 1.00
head linear_search 3.594 ± 0.011 3.582 3.612 1.01 ± 0.00
Command Mean [s] Min [s] Max [s] Relative
base math_cmp_and_pow_integration_benchmark 2.599 ± 0.005 2.593 2.610 1.00
head math_cmp_and_pow_integration_benchmark 2.630 ± 0.009 2.621 2.653 1.01 ± 0.00
Command Mean [s] Min [s] Max [s] Relative
base math_integration_benchmark 2.340 ± 0.006 2.332 2.349 1.00
head math_integration_benchmark 2.355 ± 0.004 2.349 2.363 1.01 ± 0.00
Command Mean [s] Min [s] Max [s] Relative
base memory_integration_benchmark 2.051 ± 0.006 2.042 2.060 1.00
head memory_integration_benchmark 2.068 ± 0.005 2.061 2.075 1.01 ± 0.00
Command Mean [s] Min [s] Max [s] Relative
base operations_with_data_structures_benchmarks 2.286 ± 0.006 2.278 2.294 1.00
head operations_with_data_structures_benchmarks 2.299 ± 0.006 2.293 2.312 1.01 ± 0.00
Command Mean [ms] Min [ms] Max [ms] Relative
base pedersen 837.8 ± 1.2 836.4 840.3 1.00
head pedersen 840.1 ± 1.3 838.6 842.4 1.00 ± 0.00
Command Mean [s] Min [s] Max [s] Relative
base poseidon_integration_benchmark 1.478 ± 0.005 1.470 1.487 1.00
head poseidon_integration_benchmark 1.488 ± 0.004 1.485 1.496 1.01 ± 0.00
Command Mean [s] Min [s] Max [s] Relative
base secp_integration_benchmark 2.783 ± 0.005 2.777 2.791 1.00
head secp_integration_benchmark 2.791 ± 0.006 2.785 2.801 1.00 ± 0.00
Command Mean [s] Min [s] Max [s] Relative
base set_integration_benchmark 1.447 ± 0.003 1.442 1.451 1.00
head set_integration_benchmark 1.449 ± 0.002 1.448 1.453 1.00 ± 0.00
Command Mean [s] Min [s] Max [s] Relative
base uint256_integration_benchmark 6.434 ± 0.017 6.424 6.482 1.00
head uint256_integration_benchmark 6.468 ± 0.023 6.443 6.509 1.01 ± 0.00

@MegaRedHand MegaRedHand changed the title (WIP) chore: move WASM example to workspace chore: move WASM example to workspace Jul 7, 2023
@MegaRedHand MegaRedHand changed the title chore: move WASM example to workspace feat: add WASM example Jul 7, 2023
@MegaRedHand MegaRedHand marked this pull request as ready for review July 7, 2023 15:46
@codecov
Copy link

codecov bot commented Jul 7, 2023

Codecov Report

Merging #1315 (a3f7624) into main (2d5b2cc) will increase coverage by 0.01%.
The diff coverage is 99.73%.

@@            Coverage Diff             @@
##             main    #1315      +/-   ##
==========================================
+ Coverage   97.53%   97.54%   +0.01%     
==========================================
  Files          92       92              
  Lines       37474    37695     +221     
==========================================
+ Hits        36549    36770     +221     
  Misses        925      925              
Impacted Files Coverage Δ
vm/src/cairo_run.rs 99.50% <ø> (ø)
vm/src/vm/runners/cairo_runner.rs 97.92% <97.72%> (+0.01%) ⬆️
felt/src/bigint_felt.rs 93.91% <100.00%> (-0.01%) ⬇️
felt/src/lib_bigint_felt.rs 90.00% <100.00%> (+0.37%) ⬆️
felt/src/lib_lambdaworks.rs 97.88% <100.00%> (+0.09%) ⬆️
vm/src/serde/deserialize_program.rs 97.32% <100.00%> (+0.06%) ⬆️
vm/src/types/program.rs 99.52% <100.00%> (+0.05%) ⬆️
vm/src/utils.rs 99.50% <100.00%> (+<0.01%) ⬆️
vm/src/vm/hooks.rs 100.00% <100.00%> (ø)
vm/src/vm/vm_core.rs 97.79% <100.00%> (-0.01%) ⬇️

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@MegaRedHand MegaRedHand mentioned this pull request Jul 13, 2023
6 tasks
@Oppen
Copy link
Member

Oppen commented Jul 14, 2023

@juanbono I see we're stuck waiting for a "Run tests" job. That doesn't exist, can we remove it? We want "QA / Run tests" instead in all its variants (I see some missing).

@MegaRedHand
Copy link
Contributor Author

We need to remove the "Run tests (test)" required check and add:

  • Run tests (test#1)
  • Run tests (test#2)
  • Run tests (lambdaworks-felt, test#1)
  • Run tests (lambdaworks-felt, test#2)
  • Run tests (lambdaworks-felt, test-no_std)
  • Run tests (lambdaworks-felt, test-wasm)

@MegaRedHand
Copy link
Contributor Author

I'm leaving this here for any future reappearances of this problem (Unhandled exception. System.IO.IOException: No space left on device):

Ideally, we would enable some option of llvm-cov that doesn't produce intermediate artifacts (.profraw files). Alas, I didn't find any way to do this, so I assume it isn't possible.

We can work around this problem by:

  • freeing disk space on the GitHub runners via maximize-build-disk-space action (this is a hack),
  • dividing the tests into more partitions and running them in parallel,
  • dividing the tests into more partitions but running them sequentially, while cleaning *.profraw files in-between runs,

@@ -184,17 +187,16 @@ jobs:
- name: Check no-std
run: |
cd ensure-no_std
cargo build --no-default-features
cargo build
cargo check --no-default-features
Copy link
Member

Choose a reason for hiding this comment

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

I think it is better to run cargo build instead of a check.

@pefontana pefontana added this pull request to the merge queue Jul 15, 2023
Merged via the queue into main with commit 8bc9215 Jul 15, 2023
36 checks passed
@pefontana pefontana deleted the move-wasm-example branch July 15, 2023 14:10
kariy pushed a commit to dojoengine/cairo-rs that referenced this pull request Jul 25, 2023
* Add example to workspace

* Rename example to wasm-demo, and add keywords

* Update example

* Update readme and links

* Make example show result

* Remove license, makefile, cairo contract

* Add contract source

* Update readme

* Update main readme

* Update changelog

* Compile example program in CI

* Build example program also in CI

* Modify dependencies in Makefile

* Compile example program in test_install workflow

* Cache correctly

* Activate venv before running make check

* Set pyenv local version in install scripts

* Remove venv activation from test_install

* Install requirements also in pyenv

* Add pyenv shims to PATH

* Add pyenv shims to path (now for real)

* Remove unneeded command and add instructions

* Fix workflow

* Merge install and compile steps

* Source script

* Apply Oppen's suggestions

* Add keywords to cli; use check instead of build

* Upload coverage from both runs and run on release

* Don't run in release

* Shallow clone repo before tests (+prints)

* Partition tests to reduce .profraw amount

* Fix: don't use '/' in the name

* Fix cache path

* Print only on debug

* Remove fetch-depth: 1 as it's the default

* Remove prints
kariy pushed a commit to dojoengine/cairo-rs that referenced this pull request Jul 25, 2023
* Add example to workspace

* Rename example to wasm-demo, and add keywords

* Update example

* Update readme and links

* Make example show result

* Remove license, makefile, cairo contract

* Add contract source

* Update readme

* Update main readme

* Update changelog

* Compile example program in CI

* Build example program also in CI

* Modify dependencies in Makefile

* Compile example program in test_install workflow

* Cache correctly

* Activate venv before running make check

* Set pyenv local version in install scripts

* Remove venv activation from test_install

* Install requirements also in pyenv

* Add pyenv shims to PATH

* Add pyenv shims to path (now for real)

* Remove unneeded command and add instructions

* Fix workflow

* Merge install and compile steps

* Source script

* Apply Oppen's suggestions

* Add keywords to cli; use check instead of build

* Upload coverage from both runs and run on release

* Don't run in release

* Shallow clone repo before tests (+prints)

* Partition tests to reduce .profraw amount

* Fix: don't use '/' in the name

* Fix cache path

* Print only on debug

* Remove fetch-depth: 1 as it's the default

* Remove prints
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants