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

implemented scrub for Store trait #7164

Merged
merged 1 commit into from
Jan 27, 2025
Merged

Conversation

dean-starkware
Copy link
Collaborator

No description provided.

@reviewable-StarkWare
Copy link

This change is Reviewable

@dean-starkware dean-starkware marked this pull request as ready for review January 27, 2025 11:39
Copy link
Collaborator

@orizi orizi 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 2 files at r1.
Reviewable status: 1 of 2 files reviewed, 1 unresolved discussion (waiting on @dean-starkware and @gilbens-starkware)


crates/cairo-lang-starknet/cairo_level_tests/storage_access.cairo line 413 at r1 (raw file):

    assert_eq!(state.data.a.read(), 1);
    starknet::SyscallResultTrait::unwrap_syscall(starknet::Store::<u8>::scrub(0, a_address, 0));
    assert_eq!(state.data.a.read(), 0);

make all the info manually dirty - and than make sure only that element size is 0ed out.

Code quote:

    let mut state = test_contract::contract_state_for_testing();
    state.data.a.write(1);
    let a_address = state.data.a.__storage_pointer_address__;
    assert_eq!(state.data.a.read(), 1);
    starknet::SyscallResultTrait::unwrap_syscall(starknet::Store::<u8>::scrub(0, a_address, 0));
    assert_eq!(state.data.a.read(), 0);

@dean-starkware dean-starkware force-pushed the dean/scrub_storable_storage branch from 51a97db to 20aa93f Compare January 27, 2025 13:07
Copy link
Collaborator Author

@dean-starkware dean-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: 1 of 2 files reviewed, 1 unresolved discussion (waiting on @gilbens-starkware and @orizi)


crates/cairo-lang-starknet/cairo_level_tests/storage_access.cairo line 413 at r1 (raw file):

Previously, orizi wrote…

make all the info manually dirty - and than make sure only that element size is 0ed out.

Done.

Copy link
Collaborator

@orizi orizi left a comment

Choose a reason for hiding this comment

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

Reviewed all commit messages.
Reviewable status: 1 of 2 files reviewed, 1 unresolved discussion (waiting on @dean-starkware and @gilbens-starkware)


crates/cairo-lang-starknet/cairo_level_tests/storage_access.cairo line 423 at r2 (raw file):

        ),
        1,
    );

Suggestion:

    let base_address = starknet::storage_access::storage_base_address_from_felt252(
        selector!("data"),
    );
    for i in 0..=255 {
        starknet::Store::write_at_offset(0, base_address, i, 1).unwrap();
    }
    
    let mut state = test_contract::contract_state_for_testing();
    starknet::Store::<[felt252; 23]>::scrub(0, a_address, 3).unwrap();
    for i in 0..3 {
        assert!(starknet::Store::read_at_offset(0, base_address, i).unwrap() == 0);
    }
    for i in 3..(3+23) {
        assert!(starknet::Store::read_at_offset(0, base_address, i).unwrap() == 1);
    }
    for i in (3+23)..=255 {
        assert!(starknet::Store::read_at_offset(0, base_address, i).unwrap() == 0);
    }

@dean-starkware dean-starkware force-pushed the dean/scrub_storable_storage branch from 20aa93f to fec386a Compare January 27, 2025 14:32
Copy link
Collaborator Author

@dean-starkware dean-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: 1 of 2 files reviewed, 1 unresolved discussion (waiting on @gilbens-starkware and @orizi)


crates/cairo-lang-starknet/cairo_level_tests/storage_access.cairo line 423 at r2 (raw file):

        ),
        1,
    );

Done.

Copy link
Collaborator

@orizi orizi left a comment

Choose a reason for hiding this comment

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

Reviewed all commit messages.
Reviewable status: 1 of 2 files reviewed, 1 unresolved discussion (waiting on @dean-starkware and @gilbens-starkware)


crates/cairo-lang-starknet/cairo_level_tests/storage_access.cairo line 446 at r3 (raw file):

        }
        i += 1;
    };

why not?

Suggestion:

    let base_address = starknet::storage_access::storage_base_address_from_felt252(
        selector!("data"),
    );

    for i in 0..=255 {
        starknet::Store::<u8>::write_at_offset(0, base_address, i, 1).unwrap();
    };

    starknet::Store::<[felt252; 11]>::scrub(0, base_address, 7).unwrap();
    for i in 0..7 {
        assert_eq!(starknet::Store::<u8>::read_at_offset(0, base_address, i).unwrap(), 1);
    };
    for i in 7..18 {
        assert_eq!(starknet::Store::<u8>::read_at_offset(0, base_address, i).unwrap(), 0);
    };
    for i in 18..=255 {
        assert_eq!(starknet::Store::<u8>::read_at_offset(0, base_address, i).unwrap(), 1);
    };

Copy link
Collaborator Author

@dean-starkware dean-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: 1 of 2 files reviewed, 1 unresolved discussion (waiting on @gilbens-starkware and @orizi)


crates/cairo-lang-starknet/cairo_level_tests/storage_access.cairo line 446 at r3 (raw file):

Previously, orizi wrote…

why not?

It doesn't work (both the for loop and the <[felt252; 11]>.

Copy link
Collaborator

@orizi orizi 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: 1 of 2 files reviewed, 1 unresolved discussion (waiting on @dean-starkware and @gilbens-starkware)


crates/cairo-lang-starknet/cairo_level_tests/storage_access.cairo line 446 at r3 (raw file):

Previously, dean-starkware wrote…

It doesn't work (both the for loop and the <[felt252; 11]>.

so use a (felt252, felt252, felt252) - and the for s should work.

@dean-starkware dean-starkware force-pushed the dean/scrub_storable_storage branch from fec386a to 4058567 Compare January 27, 2025 15:50
Copy link
Collaborator Author

@dean-starkware dean-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: 1 of 2 files reviewed, 1 unresolved discussion (waiting on @gilbens-starkware and @orizi)


crates/cairo-lang-starknet/cairo_level_tests/storage_access.cairo line 446 at r3 (raw file):

Previously, orizi wrote…

so use a (felt252, felt252, felt252) - and the for s should work.

Done.

Copy link
Collaborator

@orizi orizi left a comment

Choose a reason for hiding this comment

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

:lgtm:

Reviewed all commit messages.
Reviewable status: 1 of 2 files reviewed, all discussions resolved (waiting on @gilbens-starkware)

@dean-starkware dean-starkware force-pushed the dean/scrub_storable_storage branch from 4058567 to 7ca7bbe Compare January 27, 2025 15:57
Copy link
Contributor

@gilbens-starkware gilbens-starkware left a comment

Choose a reason for hiding this comment

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

:lgtm:

Reviewed 1 of 2 files at r1, 1 of 1 files at r5, all commit messages.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on @dean-starkware)

@dean-starkware dean-starkware added this pull request to the merge queue Jan 27, 2025
Merged via the queue into main with commit ad32a91 Jan 27, 2025
48 checks passed
@orizi orizi deleted the dean/scrub_storable_storage branch January 29, 2025 16:22
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.

4 participants