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

Add print_output flag to cairo-1 crate #1575

Merged
merged 98 commits into from
Jan 23, 2024
Merged

Conversation

fmoletta
Copy link
Contributor

@fmoletta fmoletta commented Jan 15, 2024

When activating the print_output flag, the program output will be serialized and printed out by the CLI.
This new serialization will recursively fetch arrays from memory and print them out instead of just showing the start and end addresses for the top-level array.
For this example program:

use core::array::SpanTrait;
use core::array::ArrayTrait;

fn main() -> Array<Array<u32>> {
    let mut numbers = ArrayTrait::new();
    let mut numbers_a = ArrayTrait::new();
    let mut numbers_b = ArrayTrait::new();
    numbers_a.append(4_u32);
    numbers_a.append(3_u32);
    numbers_b.append(2_u32);
    numbers_b.append(1_u32);
    numbers.append(numbers_a);
    numbers.append(numbers_b);

    numbers
}

Current output (main branch), no flags:

Return values : [5:0, 5:4]

New output, print_output flag:

Program Output : [[4 3] [2 1]]

No output will be shown if print_output is not enabled (unless the program returns a panic result)

The decision to lock the output behind a cli flag is both to match the standard behaviour we have in the cairo-vm-cli crate for cairo 0 execution and to avoid having to execute the argument serialization logic when outputs are not needed

Addresses #1564

@fmoletta fmoletta linked an issue Jan 18, 2024 that may be closed by this pull request
juanbono
juanbono previously approved these changes Jan 22, 2024
Oppen
Oppen previously approved these changes Jan 22, 2024
@Oppen Oppen added this pull request to the merge queue Jan 22, 2024
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to a conflict with the base branch Jan 22, 2024
@fmoletta fmoletta dismissed stale reviews from Oppen, juanbono, and pefontana via bc6f1de January 22, 2024 19:20
pefontana
pefontana previously approved these changes Jan 23, 2024
edg-l
edg-l previously approved these changes Jan 23, 2024
juanbono
juanbono previously approved these changes Jan 23, 2024
@pefontana pefontana added this pull request to the merge queue Jan 23, 2024
@pefontana pefontana removed this pull request from the merge queue due to a manual request Jan 23, 2024
@pefontana pefontana dismissed stale reviews from juanbono, edg-l, and themself via f1c6731 January 23, 2024 21:47
@pefontana pefontana enabled auto-merge January 23, 2024 21:51
@pefontana pefontana added this pull request to the merge queue Jan 23, 2024
Merged via the queue into main with commit 0a39534 Jan 23, 2024
49 of 50 checks passed
@pefontana pefontana deleted the serialize_array_outputs branch January 23, 2024 22:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Incorrect Serialization of Struct Return Values in Cairo1 Run
5 participants