starknet_committer: compute and store accessed keys digest#13993
starknet_committer: compute and store accessed keys digest#13993ArielElp wants to merge 1 commit into
Conversation
68fbdbc to
b0885bd
Compare
35ba931 to
19be0db
Compare
b0885bd to
b925279
Compare
19be0db to
7768006
Compare
PR SummaryLow Risk Overview That function builds a canonical, length-prefixed byte encoding of a Reviewed by Cursor Bugbot for commit 5a5ff22. Bugbot is set up for automated code reviews on this repo. Configure here. |
yoavGrs
left a comment
There was a problem hiding this comment.
@yoavGrs reviewed 2 files and all commit messages, and made 1 comment.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on ArielElp).
crates/starknet_committer/src/db/serde_db_utils.rs line 60 at r1 (raw file):
) -> [u8; 32] { let mut class_hashes: Vec<ClassHash> = class_hashes.iter().copied().collect(); class_hashes.sort();
In the previous PR you sort it. Define a "sorted" struct?
Code quote:
class_hashes.sort();7768006 to
88273cc
Compare
13ea978 to
d58523d
Compare
88273cc to
482d5eb
Compare
6ee8f1d to
0efaf0c
Compare
40dd29b to
26ed95b
Compare
ArielElp
left a comment
There was a problem hiding this comment.
@ArielElp partially reviewed 2 files and made 2 comments.
Reviewable status: 0 of 3 files reviewed, 2 unresolved discussions (waiting on yoavGrs).
crates/starknet_committer/src/db/serde_db_utils.rs line 39 at r2 (raw file):
Previously, yoavGrs wrote…
Document the structure of the payload
Done.
crates/starknet_committer/src/db/serde_db_utils.rs line 72 at r2 (raw file):
Previously, yoavGrs wrote…
Avoid using
as.
Done.
yoavGrs
left a comment
There was a problem hiding this comment.
@yoavGrs reviewed 2 files and all commit messages, made 1 comment, and resolved 2 discussions.
Reviewable status: 2 of 3 files reviewed, all discussions resolved (waiting on ArielElp).
26ed95b to
e4503a6
Compare
b757ad2 to
70039f0
Compare
31307c5 to
f3ae5b0
Compare
70039f0 to
c579a4b
Compare
f3ae5b0 to
959f1cf
Compare
869a81f to
96c5bcb
Compare
959f1cf to
7f4f979
Compare
dorimedini-starkware
left a comment
There was a problem hiding this comment.
@dorimedini-starkware reviewed 3 files and all commit messages, and made 4 comments.
Reviewable status: all files reviewed, 4 unresolved discussions (waiting on ArielElp).
crates/starknet_committer/Cargo.toml line 15 at r4 (raw file):
[dependencies] blake2 = { workspace = true, optional = true } digest = { workspace = true, optional = true }
excuse me ser we sort dependencies here
Code quote:
blake2 = { workspace = true, optional = true }
digest = { workspace = true, optional = true }crates/starknet_committer/src/db/serde_db_utils.rs line 47 at r4 (raw file):
/// (already sorted within the contract). #[cfg(feature = "os_input")] pub fn accessed_keys_digest(sorted: &SortedLeavesRequest<'_>) -> [u8; 32] {
consider making this a method of SortedLeavesRequest
Code quote:
pub fn accessed_keys_digest(sorted: &SortedLeavesRequest<'_>) -> [u8; 32] {crates/starknet_committer/src/db/serde_db_utils.rs line 63 at r4 (raw file):
let mut contract_indices: Vec<NodeIndex> = sorted.storage_sorted.keys().copied().collect(); contract_indices.sort_unstable();
unstable? why?
also, why do you need to sort at all? isn't that what SortedLeavesRequest is for?
if it's because of the HashMap field, consider using a BTreeMap field to get well-defined key order in the struct itself
Code quote:
contract_indices.sort_unstable();crates/starknet_committer/src/db/serde_db_utils.rs line 81 at r4 (raw file):
#[cfg(feature = "os_input")] fn encode_usize(n: usize) -> [u8; 4] { u32::try_from(n).expect("accessed leaf count exceeds u32::MAX").to_be_bytes()
mmmmmm why not u64? and return [u8; 8]? it doesn't matter much, and we won't have to answer the question "will we ever read 4B leaves"?
Code quote:
u32::try_from(n).expect("accessed leaf count exceeds u32::MAX").to_be_bytes()96c5bcb to
2e17706
Compare
7f4f979 to
22efed7
Compare
ArielElp
left a comment
There was a problem hiding this comment.
@ArielElp reviewed all commit messages and made 4 comments.
Reviewable status: all files reviewed, 4 unresolved discussions (waiting on dorimedini-starkware).
crates/starknet_committer/Cargo.toml line 15 at r4 (raw file):
Previously, dorimedini-starkware wrote…
excuse me ser we sort dependencies here
Done.
crates/starknet_committer/src/db/serde_db_utils.rs line 47 at r4 (raw file):
Previously, dorimedini-starkware wrote…
consider making this a method of SortedLeavesRequest
IMO given that it's db-serialization related, it's slightly better placed here, but won't insist if you prefer moving.
crates/starknet_committer/src/db/serde_db_utils.rs line 63 at r4 (raw file):
Previously, dorimedini-starkware wrote…
unstable? why?
also, why do you need to sort at all? isn't that what SortedLeavesRequest is for?
if it's because of the HashMap field, consider using a BTreeMap field to get well-defined key order in the struct itself
AI decision, it's supposed to be marginally faster, and you know there are no duplications here (it's the keys from a HashMap).
crates/starknet_committer/src/db/serde_db_utils.rs line 81 at r4 (raw file):
Previously, dorimedini-starkware wrote…
mmmmmm why not u64? and return
[u8; 8]? it doesn't matter much, and we won't have to answer the question "will we ever read 4B leaves"?
Done.
22efed7 to
093fc19
Compare
dorimedini-starkware
left a comment
There was a problem hiding this comment.
@dorimedini-starkware reviewed 2 files and all commit messages, made 1 comment, and resolved 3 discussions.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on ArielElp).
crates/starknet_committer/src/db/serde_db_utils.rs line 63 at r4 (raw file):
Previously, ArielElp wrote…
AI decision, it's supposed to be marginally faster, and you know there are no duplications here (it's the keys from a HashMap).
but with a HashMap, order is not well defined, and you could get different digests for the same input. right?
ArielElp
left a comment
There was a problem hiding this comment.
@ArielElp made 1 comment.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on dorimedini-starkware).
crates/starknet_committer/src/db/serde_db_utils.rs line 63 at r4 (raw file):
Previously, dorimedini-starkware wrote…
but with a HashMap, order is not well defined, and you could get different digests for the same input. right?
Hence the sort, sort unstable is just about ordering of equal elements
2e17706 to
300a545
Compare
11d186a to
c9ac657
Compare
300a545 to
c381bc4
Compare
c9ac657 to
5a5ff22
Compare
c381bc4 to
1b083d2
Compare

No description provided.