Closed neotheprogramist closed 6 months ago
Arrays are represented as pointers to the begining and the end of the data. Is this an enhancement requirement? because i don't understand the bug - main runner does not accept arguments currently at all.
@orizi
I recognized it as a bug because I think I'm using cairo_lang_runner
(which is a part of cairo compiler repo) correctly but in my opinion it produces incorrect results. The main issue is how to use cairo_lang_runner
to pass arrays as arguments correctly to the program.
I'm aware that main runner does not support this feature - that's why I've built my own runner using cairo compiler components.
Oh - i better understand now. Having a look.
Description
While developing a Cairo runner, an issue has arisen related to passing arrays as arguments to the program's main function. The goal was to create a runner enabling the passing of arguments to the entry point, demonstrated by the following program:
However, when using
Arg
fromcairo_lang_runner::{Arg, SierraCasmRunner}
to pass arrays to the main function of a Cairo program, it results in unstable and inefficient behavior.Steps to Reproduce
To reproduce the issue, follow these steps:
array-issues
branch:Expected Result:
'[3, 3, 3, 6]'
(arr1_len, arr1_sum, arr2_len, arr2_sum), but actual result is'[3, 6, 3, 3]'
(content of arr1 and arr2 is swapped).Note: When arr1 and arr2 have different lengths, the lengths are not swapped, and you cannot access the longer array beyond the length of the shorter one.
Result:
CairoRunError(VirtualMachine(FailedToComputeOperands(("op1", Relocatable { segment_index: 10, offset: 3 })))) Error: RunError(FailedRunning)
Additional Question
Concerning array serialization, when passing an array as
(n, a_1, a_2, ..., a_n)
usingArg::Value
, the results are unexpected. For instance:Is there documentation on how arrays should be passed to the Sierra program as an array of
Arg::Value
?Repository Link
GitHub Repository - cairo-args-runner