-
Notifications
You must be signed in to change notification settings - Fork 598
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
Conversation
There was a problem hiding this 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);
51a97db
to
20aa93f
Compare
There was a problem hiding this 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.
There was a problem hiding this 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);
}
20aa93f
to
fec386a
Compare
There was a problem hiding this 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.
There was a problem hiding this 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);
};
There was a problem hiding this 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]>.
There was a problem hiding this 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.
fec386a
to
4058567
Compare
There was a problem hiding this 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 thefor
s should work.
Done.
There was a problem hiding this 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, all discussions resolved (waiting on @gilbens-starkware)
4058567
to
7ca7bbe
Compare
There was a problem hiding this 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, 1 of 1 files at r5, all commit messages.
Reviewable status:complete! all files reviewed, all discussions resolved (waiting on @dean-starkware)
No description provided.