Skip to content

Conversation

@nimrod-starkware
Copy link
Contributor

No description provided.

Copy link
Contributor Author

nimrod-starkware commented Jul 3, 2025

@reviewable-StarkWare
Copy link

This change is Reviewable

@nimrod-starkware nimrod-starkware force-pushed the nimrod/aliases_test/refactor_runner branch from d1698db to e3ebcf7 Compare July 3, 2025 09:14
@nimrod-starkware nimrod-starkware force-pushed the nimrod/aliases_test/allocate_and_replace branch from dd17e8f to 50b2d0e Compare July 3, 2025 09:14
@nimrod-starkware nimrod-starkware self-assigned this Jul 3, 2025
@nimrod-starkware nimrod-starkware marked this pull request as ready for review July 3, 2025 13:09
@nimrod-starkware nimrod-starkware force-pushed the nimrod/aliases_test/allocate_and_replace branch from 855329a to 2c75c44 Compare July 3, 2025 13:10
Copy link
Collaborator

@dorimedini-starkware dorimedini-starkware left a comment

Choose a reason for hiding this comment

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

Reviewed 2 of 2 files at r1, all commit messages.
Reviewable status: all files reviewed, 3 unresolved discussions (waiting on @amosStarkware)


crates/starknet_os/src/test_utils/utils.rs line 61 at r1 (raw file):

    let dict_segment_end = vm.load_data(dict_segment_start, &squashed_dict).unwrap();
    (dict_segment_start, dict_segment_end)
}

this function now actually allocates a segment and loads data into it - you should probably rename it + doc it

Suggestion:

/// Creates a squashed dict from previous and new values, and stores it in a new memory segment.
pub fn allocate_squashed_cairo_dict(
    prev_values: &HashMap<Felt, MaybeRelocatable>,
    new_values: &HashMap<Felt, MaybeRelocatable>,
    vm: &mut VirtualMachine,
) -> (Relocatable, Relocatable) {
    let squashed_dict = flatten_cairo_dict(prev_values, new_values);
    let dict_segment_start = vm.add_memory_segment();
    let dict_segment_end = vm.load_data(dict_segment_start, &squashed_dict).unwrap();
    (dict_segment_start, dict_segment_end)
}

crates/starknet_os/src/tests/aliases.rs line 439 at r1 (raw file):

            10000,
            HashMap::from([(34567, 0), (435, 0)])
        )

Suggestion:

        (
            1,
            HashMap::from([(777, 1), (8888, 1), (9999, 1)]) // No aliases.
        ),
        (
            100,
            HashMap::from([(200, 1), (777, 1), (888, 0)]) // Aliases for non-trivial diffs.
        ),
        (
            600,
            HashMap::from([(2000, 1), (3000, 1)])
        ),
        (
            800,
            HashMap::from([(700, 1), (701, 1)])
        ),
        (
            3000,
            HashMap::from([(600, 1), (2000, 1)])
        ),
        (
            10000,
            HashMap::from([(34567, 0), (435, 0)]) // No aliases (all diffs trivial).
        )

crates/starknet_os/src/tests/aliases.rs line 536 at r1 (raw file):

    .unwrap();

    // TODO(Nimrod): Complete this test to also compare the other return values.

may be hard to remember by the time you do it.
if it's already a WIP - ignore this :)

Suggestion:

// TODO(Nimrod): Complete this test to also compare the other return values (state diff and
//   state diff with aliases).

crates/starknet_os/src/tests/aliases.rs line 555 at r1 (raw file):

            "The return value doesn't match the given format.\n Got: {explicit_return_values:?}"
        );
    }

I think let..else pattern is better here, non-blocking

Suggestion:

    let [
        EndpointArg::Pointer(PointerArg::Array(aliases_storage_updates)),
        EndpointArg::Pointer(PointerArg::Array(_)),
        EndpointArg::Pointer(PointerArg::Array(_)),
    ] = explicit_return_values.as_slice() else {
        panic!(
            "The return value doesn't match the given format.\n Got: {explicit_return_values:?}"
        );
    };
    let aliases_storage_updates_as_felts: Vec<Felt> =
        aliases_storage_updates.iter().map(|f| f.get_int().unwrap()).collect();
    let actual_alias_storage = parse_squashed_cairo_dict(&aliases_storage_updates_as_felts);
    let expected_alias_storage: HashMap<Felt, Felt> = expected_alias_storage
        .into_iter()
        .map(|(key, value)| (key.into(), value.into()))
        .collect();
    assert_eq!(actual_alias_storage, expected_alias_storage);

@nimrod-starkware nimrod-starkware force-pushed the nimrod/aliases_test/refactor_runner branch from e3ebcf7 to 67903f4 Compare July 6, 2025 06:39
@nimrod-starkware nimrod-starkware force-pushed the nimrod/aliases_test/allocate_and_replace branch from 2c75c44 to 1a8e992 Compare July 6, 2025 06:39
Copy link
Contributor Author

@nimrod-starkware nimrod-starkware left a comment

Choose a reason for hiding this comment

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

Reviewable status: all files reviewed, 3 unresolved discussions (waiting on @amosStarkware and @dorimedini-starkware)


crates/starknet_os/src/test_utils/utils.rs line 61 at r1 (raw file):

Previously, dorimedini-starkware wrote…

this function now actually allocates a segment and loads data into it - you should probably rename it + doc it

Done.


crates/starknet_os/src/tests/aliases.rs line 555 at r1 (raw file):

Previously, dorimedini-starkware wrote…

I think let..else pattern is better here, non-blocking

Done.


crates/starknet_os/src/tests/aliases.rs line 439 at r1 (raw file):

            10000,
            HashMap::from([(34567, 0), (435, 0)])
        )

Done.

Copy link
Collaborator

@dorimedini-starkware dorimedini-starkware left a comment

Choose a reason for hiding this comment

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

Reviewed 2 of 2 files at r2, all commit messages.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on @amosStarkware)

@nimrod-starkware nimrod-starkware changed the base branch from nimrod/aliases_test/refactor_runner to graphite-base/7745 July 6, 2025 11:22
@nimrod-starkware nimrod-starkware force-pushed the nimrod/aliases_test/allocate_and_replace branch from 1a8e992 to 6aec9d9 Compare July 6, 2025 12:33
@nimrod-starkware nimrod-starkware changed the base branch from graphite-base/7745 to nimrod/aliases_test/refactor_runner July 6, 2025 12:33
@nimrod-starkware nimrod-starkware force-pushed the nimrod/aliases_test/allocate_and_replace branch from 6aec9d9 to 4f1831f Compare July 7, 2025 07:00
@nimrod-starkware nimrod-starkware force-pushed the nimrod/aliases_test/refactor_runner branch from 295c5e9 to 29ccbce Compare July 7, 2025 07:00
Copy link
Collaborator

@dorimedini-starkware dorimedini-starkware left a comment

Choose a reason for hiding this comment

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

Reviewed 1 of 1 files at r3, all commit messages.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on @amosStarkware)

@nimrod-starkware nimrod-starkware changed the base branch from nimrod/aliases_test/refactor_runner to graphite-base/7745 July 7, 2025 10:36
@nimrod-starkware nimrod-starkware force-pushed the nimrod/aliases_test/allocate_and_replace branch from 4f1831f to 124855c Compare July 7, 2025 15:24
@nimrod-starkware nimrod-starkware changed the base branch from graphite-base/7745 to nimrod/aliases_test/refactor_runner July 7, 2025 15:24
@nimrod-starkware nimrod-starkware force-pushed the nimrod/aliases_test/allocate_and_replace branch from 124855c to b482214 Compare July 7, 2025 16:00
@nimrod-starkware nimrod-starkware force-pushed the nimrod/aliases_test/refactor_runner branch from 6684907 to 778e7d8 Compare July 7, 2025 16:00
@nimrod-starkware nimrod-starkware changed the base branch from nimrod/aliases_test/refactor_runner to graphite-base/7745 July 8, 2025 06:10
@nimrod-starkware nimrod-starkware force-pushed the nimrod/aliases_test/allocate_and_replace branch from b482214 to 23e65b6 Compare July 8, 2025 06:11
@nimrod-starkware nimrod-starkware changed the base branch from graphite-base/7745 to main-v0.14.0 July 8, 2025 06:11
@nimrod-starkware nimrod-starkware added this pull request to the merge queue Jul 8, 2025
Merged via the queue into main-v0.14.0 with commit 6493332 Jul 8, 2025
14 of 25 checks passed
@github-actions github-actions bot locked and limited conversation to collaborators Jul 9, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants