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

builtin cost rework with fixes #875

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open

builtin cost rework with fixes #875

wants to merge 6 commits into from

Conversation

edg-l
Copy link
Member

@edg-l edg-l commented Oct 22, 2024

This reverts commit 355c250.

We should test this change with a block range we know works with current main, to assert it adds no regressions.

Checklist

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

@codecov-commenter
Copy link

codecov-commenter commented Oct 22, 2024

Codecov Report

Attention: Patch coverage is 83.87097% with 55 lines in your changes missing coverage. Please review.

Project coverage is 82.83%. Comparing base (f39cb35) to head (b566791).

Files with missing lines Patch % Lines
src/executor/contract.rs 80.37% 21 Missing ⚠️
src/libfuncs/gas.rs 86.53% 14 Missing ⚠️
src/executor.rs 72.41% 8 Missing ⚠️
src/metadata/gas.rs 75.86% 7 Missing ⚠️
src/types.rs 0.00% 3 Missing ⚠️
src/executor/jit.rs 90.00% 1 Missing ⚠️
src/utils.rs 95.65% 1 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff            @@
##             main     #875    +/-   ##
========================================
  Coverage   82.82%   82.83%            
========================================
  Files         120      120            
  Lines       34941    35236   +295     
========================================
+ Hits        28941    29187   +246     
- Misses       6000     6049    +49     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link

github-actions bot commented Oct 22, 2024

Benchmarking results

Benchmark for program factorial_2M

Open benchmarks
Command Mean [s] Min [s] Max [s] Relative
Cairo-vm (Rust, Cairo 1) 10.748 ± 0.188 10.518 11.075 23.37 ± 0.48
cairo-native (embedded AOT) 3.237 ± 0.031 3.205 3.313 7.04 ± 0.10
cairo-native (embedded JIT using LLVM's ORC Engine) 3.271 ± 0.056 3.197 3.375 7.11 ± 0.14
cairo-native (standalone AOT) 0.652 ± 0.001 0.651 0.655 1.42 ± 0.02
cairo-native (standalone AOT with -march=native) 0.460 ± 0.005 0.457 0.473 1.00

Benchmark for program fib_2M

Open benchmarks
Command Mean [s] Min [s] Max [s] Relative
Cairo-vm (Rust, Cairo 1) 10.811 ± 0.273 10.439 11.108 1344.75 ± 35.86
cairo-native (embedded AOT) 2.789 ± 0.028 2.742 2.830 346.92 ± 4.54
cairo-native (embedded JIT using LLVM's ORC Engine) 2.860 ± 0.060 2.769 2.966 355.74 ± 8.00
cairo-native (standalone AOT) 0.008 ± 0.000 0.008 0.009 1.00
cairo-native (standalone AOT with -march=native) 0.008 ± 0.000 0.008 0.008 1.00 ± 0.01

Benchmark for program logistic_map

Open benchmarks
Command Mean [s] Min [s] Max [s] Relative
Cairo-vm (Rust, Cairo 1) 4.389 ± 0.039 4.309 4.441 61.25 ± 0.62
cairo-native (embedded AOT) 2.924 ± 0.035 2.881 2.983 40.80 ± 0.53
cairo-native (embedded JIT using LLVM's ORC Engine) 3.084 ± 0.029 3.056 3.153 43.03 ± 0.46
cairo-native (standalone AOT) 0.115 ± 0.000 0.115 0.115 1.60 ± 0.01
cairo-native (standalone AOT with -march=native) 0.072 ± 0.000 0.071 0.074 1.00

Copy link

github-actions bot commented Oct 22, 2024

Benchmark results Main vs HEAD.

Command Mean [s] Min [s] Max [s] Relative
head factorial_2M.cairo (JIT) 3.266 ± 0.014 3.241 3.287 1.02 ± 0.01
base factorial_2M.cairo (JIT) 3.252 ± 0.033 3.212 3.310 1.01 ± 0.01
head factorial_2M.cairo (AOT) 3.218 ± 0.024 3.184 3.257 1.00 ± 0.01
base factorial_2M.cairo (AOT) 3.211 ± 0.015 3.181 3.227 1.00
Command Mean [s] Min [s] Max [s] Relative
head fib_2M.cairo (JIT) 2.778 ± 0.016 2.751 2.803 1.01 ± 0.01
base fib_2M.cairo (JIT) 2.785 ± 0.021 2.758 2.820 1.02 ± 0.01
head fib_2M.cairo (AOT) 2.742 ± 0.021 2.700 2.776 1.00
base fib_2M.cairo (AOT) 2.758 ± 0.023 2.716 2.783 1.01 ± 0.01
Command Mean [s] Min [s] Max [s] Relative
head logistic_map.cairo (JIT) 3.059 ± 0.022 3.027 3.095 1.06 ± 0.01
base logistic_map.cairo (JIT) 3.075 ± 0.018 3.051 3.106 1.07 ± 0.01
head logistic_map.cairo (AOT) 2.886 ± 0.020 2.855 2.911 1.00
base logistic_map.cairo (AOT) 2.914 ± 0.016 2.886 2.938 1.01 ± 0.01

Copy link

github-actions bot commented Oct 22, 2024

✅ Code is now correctly formatted.

@edg-l edg-l changed the title builtin cost rework builtin cost rework with fixes Oct 22, 2024
@edg-l edg-l marked this pull request as ready for review October 22, 2024 12:39
@edg-l edg-l mentioned this pull request Oct 25, 2024
5 tasks
Comment on lines +613 to +634
let entrypoint_function_id = starknet_program
.funcs
.last()
.expect("should have a function")
.id
.clone();

(0..200).par_bridge().for_each(|n| {
let result = executor
.run(
&entrypoint_function_id,
&[n.into()],
Some(u64::MAX as u128),
None,
&mut StubSyscallHandler::default(),
)
.unwrap();

assert_eq!(result.return_values, vec![Felt::from(n), Felt::from(n * 2)]);
assert_eq!(result.remaining_gas, 18446744073709548175);
});
}
Copy link
Contributor

Choose a reason for hiding this comment

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

I think the contract used is to simple to find a possible race condition, maybe we can do the same in the replay, with a larger transaction (one that used to fail). For example, transactions:

  • 0x0310c46edc795c82c71f600159fa9e6c6540cb294df9d156f685bfe62b31a5f4
  • 0x066e1f01420d8e433f6ef64309adb1a830e5af0ea67e3d935de273ca57b3ae5e

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.

5 participants