-
Notifications
You must be signed in to change notification settings - Fork 490
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 basic storage array. #5974
Add basic storage array. #5974
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.
Reviewable status: 0 of 3 files reviewed, 1 unresolved discussion
a discussion (no related file):
Draft - names and doc tbd.
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: 0 of 3 files reviewed, 4 unresolved discussions (waiting on @ArielElp and @gilbens-starkware)
corelib/src/starknet/storage.cairo
line 670 at r1 (raw file):
pub trait StorageArrayTrait<T> {
doc all.
(also below)
corelib/src/starknet/storage.cairo
line 670 at r1 (raw file):
pub trait StorageArrayTrait<T> {
generate_trait?
(also below)
corelib/src/starknet/storage.cairo
line 745 at r1 (raw file):
self.as_path().append() } }
emptyline.
3bf5f89
to
24c52a7
Compare
39eaba1
to
fddae14
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: 0 of 3 files reviewed, 4 unresolved discussions (waiting on @ArielElp and @orizi)
corelib/src/starknet/storage.cairo
line 670 at r1 (raw file):
Previously, orizi wrote…
doc all.
(also below)
Done.
corelib/src/starknet/storage.cairo
line 670 at r1 (raw file):
Previously, orizi wrote…
generate_trait?
(also below)
Doesn't work, I guess because the generic arg and param are not exactly the same, I'll check it out later.
corelib/src/starknet/storage.cairo
line 745 at r1 (raw file):
Previously, orizi wrote…
emptyline.
Done.
0f7603e
to
baa2564
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 r2, all commit messages.
Reviewable status: 1 of 3 files reviewed, 2 unresolved discussions (waiting on @ArielElp and @gilbens-starkware)
a discussion (no related file):
Previously, gilbens-starkware (Gil Ben-Shachar) wrote…
Draft - names and doc tbd.
+1
corelib/src/starknet/storage.cairo
line 670 at r1 (raw file):
Previously, gilbens-starkware (Gil Ben-Shachar) wrote…
Doesn't work, I guess because the generic arg and param are not exactly the same, I'll check it out later.
you are correct.
corelib/src/starknet/storage.cairo
line 649 at r2 (raw file):
} /// A type to represent an array in storage. The length of the storage is stored in the storage
maybe should be added to its own submodule file?
(and possibly for Map
as well)
fddae14
to
6ab4502
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 3 files reviewed, 2 unresolved discussions (waiting on @ArielElp and @orizi)
corelib/src/starknet/storage.cairo
line 649 at r2 (raw file):
Previously, orizi wrote…
maybe should be added to its own submodule file?
(and possibly forMap
as well)
Done. Will do Map
in a separate pr.
6ab4502
to
35e1392
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 all commit messages.
Reviewable status: 0 of 4 files reviewed, 3 unresolved discussions (waiting on @ArielElp and @gilbens-starkware)
-- commits
line 4 at r4:
rebase
35e1392
to
02a0d68
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: 0 of 4 files reviewed, 3 unresolved discussions (waiting on @ArielElp and @orizi)
Previously, orizi wrote…
rebase
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 1 of 1 files at r5, all commit messages.
Reviewable status: 1 of 4 files reviewed, 4 unresolved discussions (waiting on @ArielElp and @gilbens-starkware)
corelib/src/starknet/storage.cairo
line 9 at r5 (raw file):
mod array; pub use array::{StorageArray, StorageArrayTrait, MutableStorageArrayTrait};
are we changing to vector?
(as the interface is different enough from our array in any case)
Code quote:
mod array;
pub use array::{StorageArray, StorageArrayTrait, MutableStorageArrayTrait};
crates/cairo-lang-starknet/cairo_level_tests/storage_access.cairo
line 84 at r5 (raw file):
#[starknet::storage_node] struct StorageArrays { array: StorageArray<u32>,
Array<T>
is equivalent toMap<u64, T>
value wise?
if so, add direct test accessing members (using contract_state_for_testing
, and direct assignment and read in one and the other)
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 4 files reviewed, 4 unresolved discussions (waiting on @ArielElp and @gilbens-starkware)
crates/cairo-lang-starknet/cairo_level_tests/storage_access.cairo
line 84 at r5 (raw file):
Previously, orizi wrote…
Array<T>
is equivalent toMap<u64, T>
value wise?
if so, add direct test accessing members (usingcontract_state_for_testing
, and direct assignment and read in one and the other)
(i know array has length as well, but ignore it for testing value location wise)
02a0d68
to
2ce5604
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 6 files reviewed, 4 unresolved discussions (waiting on @ArielElp and @orizi)
corelib/src/starknet/storage.cairo
line 9 at r5 (raw file):
Previously, orizi wrote…
are we changing to vector?
(as the interface is different enough from our array in any case)
I think that we do. Vector or Vec? And what about append?
crates/cairo-lang-starknet/cairo_level_tests/storage_access.cairo
line 84 at r5 (raw file):
Previously, orizi wrote…
(i know array has length as well, but ignore it for testing value location wise)
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 6 files reviewed, 3 unresolved discussions (waiting on @ArielElp and @gilbens-starkware)
2ce5604
to
f7e928e
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: 0 of 6 files reviewed, 3 unresolved discussions (waiting on @ArielElp and @orizi)
corelib/src/starknet/storage.cairo
line 9 at r5 (raw file):
Previously, gilbens-starkware (Gil Ben-Shachar) wrote…
I think that we do. Vector or Vec? And what about append?
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.
Reviewable status: 0 of 6 files reviewed, 2 unresolved discussions (waiting on @ArielElp and @orizi)
a discussion (no related file):
Previously, orizi wrote…
+1
Done.
f7e928e
to
3e0111c
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 3 files at r6, 3 of 5 files at r7.
Reviewable status: 3 of 6 files reviewed, 3 unresolved discussions (waiting on @ArielElp and @gilbens-starkware)
corelib/src/starknet/storage.cairo
line 9 at r5 (raw file):
Previously, gilbens-starkware (Gil Ben-Shachar) wrote…
Done
if we are going for Vec
no need for the disabguiation with Storage
prefix. - just Vec
like Map
.
for full name - user can just use starknet::storage::Vec
.
crates/cairo-lang-starknet/cairo_level_tests/collections_test.cairo
line 24 at r7 (raw file):
nested: StorageVec::<StorageVec<u32>>, } }
Suggestion:
mod contract_with_map {
use starknet::storage::Map;
#[storage]
struct Storage {
simple: Map<u64, u32>,
nested: Map<u64, Map<u64, u32>>,
}
}
#[starknet::contract]
mod contract_with_vec {
use starknet::storage::StorageVec;
#[storage]
struct Storage {
simple: StorageVec<u32>,
nested: StorageVec<StorageVec<u32>>,
}
}
crates/cairo-lang-starknet/cairo_level_tests/lib.cairo
line 29 at r7 (raw file):
mod utils; #[cfg(test)] mod collections_test;
empty line
3e0111c
to
2b34046
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: 0 of 6 files reviewed, 3 unresolved discussions (waiting on @ArielElp and @orizi)
corelib/src/starknet/storage.cairo
line 9 at r5 (raw file):
Previously, orizi wrote…
if we are going for
Vec
no need for the disabguiation withStorage
prefix. - justVec
likeMap
.for full name - user can just use
starknet::storage::Vec
.
Done.
Changed also the traits, e.g. starknet::storage::VecTrait
but not sure if it's better.
crates/cairo-lang-starknet/cairo_level_tests/collections_test.cairo
line 24 at r7 (raw file):
nested: StorageVec::<StorageVec<u32>>, } }
Done.
crates/cairo-lang-starknet/cairo_level_tests/lib.cairo
line 29 at r7 (raw file):
Previously, orizi wrote…
empty line
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 1 of 1 files at r8, 5 of 5 files at r9.
Reviewable status: all files reviewed (commit messages unreviewed), 1 unresolved discussion (waiting on @ArielElp and @gilbens-starkware)
corelib/src/starknet/storage.cairo
line 9 at r5 (raw file):
Previously, gilbens-starkware (Gil Ben-Shachar) wrote…
Done.
Changed also the traits, e.g.starknet::storage::VecTrait
but not sure if it's better.
in Map
is it MapTrait
? - if so probably revert that specifically.
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: all files reviewed, 1 unresolved discussion (waiting on @ArielElp and @gilbens-starkware)
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: all files reviewed, 1 unresolved discussion (waiting on @ArielElp and @orizi)
corelib/src/starknet/storage.cairo
line 9 at r5 (raw file):
Previously, orizi wrote…
in
Map
is itMapTrait
? - if so probably revert that specifically.
Map
have only entry
, so it is named StoragePathEntry
as the same interface can be implemented for other types, but I don't see any such type for now so maybe It should be changed?
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: all files reviewed, 2 unresolved discussions (waiting on @ArielElp and @gilbens-starkware)
corelib/src/starknet/storage/vec.cairo
line 45 at r9 (raw file):
assert!(index < vec_len, "Index out of bounds"); self.update(index) }
have get
instead - return option.
at
would probably be through the index
trait.
Code quote:
fn at(self: StoragePath<Vec<T>>, index: u64) -> StoragePath<T> {
let vec_len = self.len();
assert!(index < vec_len, "Index out of bounds");
self.update(index)
}
commit-id:2da700e2
2b34046
to
572baae
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: 3 of 6 files reviewed, 2 unresolved discussions (waiting on @ArielElp and @orizi)
corelib/src/starknet/storage/vec.cairo
line 45 at r9 (raw file):
Previously, orizi wrote…
have
get
instead - return option.
at
would probably be through theindex
trait.
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 3 of 3 files at r10, all commit messages.
Reviewable status: complete! all files reviewed, all discussions resolved (waiting on @ArielElp)
Stack:
This change is