Open clexmond opened 1 year ago
can you remove some of the inlining or split into some functions? generally - the issue here is the fact that you have a single function here with a pretty extreme ap change.
can you remove some of the inlining or split into some functions? generally - the issue here is the fact that you have a single function here with a pretty extreme ap change.
Splitting into functions on its own fails, I am going to try splitting and including #[inline(never)]
also maybe try adding a internal::revoke_ap_tracking();
at the start of the large function.
I suspect this all has something to do with the attempt to align ap over all the functions branches.
also maybe try adding a
internal::revoke_ap_tracking();
at the start of the large function. I suspect this all has something to do with the attempt to align ap over all the functions branches.
Splitting up into functions with #[inline(never)]
and adding internal::revoke_ap_tracking();
doesn't seem to make any difference. Execution still fails to proceed at the same line. Only distinction is the error reflects the following rather than a casting error:
Caused by:
#369->#370: Got 'Offset overflow' error while moving [6].
Updating here: adding revoke_ap_tracking() in the middle fixed this. We should do this in the compiler
Just confirming that the inclusion of internal::revoke_ap_tracking()
here https://github.com/influenceth/cubit/blob/noise/src/procgen/simplex3.cairo#L94 did solve the issue.
@orizi @spapinistarkware bump on this issue. Just encountered it in a different codebase, applying the internal::revoke_ap_tracking()
helped, but I presume that's a temporary hack.
has anyone successfully declared a Starknet contract using this method? I'm hitting an issue when declaring the contract
Error: StarkException: (400, {'code': <StarknetErrorCode.COMPILATION_FAILED: 3>, 'message': "Compilation failed. Error: Compilation failed.\n\nCaused by:\n #5140->#5141: Got 'Offset overflow' error while moving [25].\n"})
Easy to reproduce by commenting out https://github.com/influenceth/cubit/blob/main/src/procgen/simplex3.cairo#L83 and running tests (or trying to deploy a contract using that method).
Currently getting the following error still:
cairo-test .
thread 'main' panicked at 'Failed to cast from 52100.', ~/.cairo/v2.0.1/crates/cairo-lang-utils/src/casts.rs:8:35
stack backtrace:
0: rust_begin_unwind
at /rustc/e9e1bbc7a820c472b39d3de54b3049bf14050655/library/std/src/panicking.rs:578:5
1: core::panicking::panic_fmt
at /rustc/e9e1bbc7a820c472b39d3de54b3049bf14050655/library/core/src/panicking.rs:67:14
2: <cairo_lang_casm::cell_expression::CellExpression as cairo_lang_casm::ap_change::ApplyApChange>::apply_known_ap_change
3: alloc::vec::in_place_collect::<impl alloc::vec::spec_from_iter::SpecFromIter<T,I> for alloc::vec::Vec<T>>::from_iter
4: core::iter::adapters::try_process
5: cairo_lang_casm::ap_change::ApplyApChange::apply_ap_change
6: cairo_lang_sierra_to_casm::annotations::ProgramAnnotations::propagate_annotations
7: cairo_lang_sierra_to_casm::compiler::compile
8: cairo_lang_runner::SierraCasmRunner::new
9: cairo_lang_test_runner::run_tests
10: cairo_lang_test_runner::TestRunner::run
11: cairo_test::main
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
make: *** [test] Error 101
I have a feeling deploying a contract with this totally messes up the gas calculations
Check this tx: https://testnet.starkscan.co/tx/0x7644341a28aaa7a2b753b7e53d98564ec3d18129857b52eacda9951f66ab20d#overview
STEPS
47302
MEMORY
7471
PEDERSEN_BUILTIN
14
RANGE_CHECK_BUILTIN
8515
The function is not that complex and only updates a single storage slot, but this gas is insane...
Bug Report
Cairo version:
Commit 66357681
Current behavior:
When calling a fairly involved method (specifically a port of this
noise3
method https://github.com/influenceth/cairo-rand-64x61/blob/master/contracts/cairo_rand_64x61/simplex.cairo)cairo-test
exits roughly 2/3rds of the way through with the following (full Rust backtrace included):Expected behavior:
Method should execute and return as it did in Cairo 0.
Steps to reproduce / related code:
Pull the
noise
branch and run thesimplex3_test
suite. Execution will fail prior to line 97: https://github.com/influenceth/cubit/blob/noise/src/procgen/simplex3.cairo#L97Additional Information:
cairo-compile .
succeeds without error.