starknet_committer: define StarknetForestProofs serde#13994
Conversation
2092a49 to
f0e3f55
Compare
19be0db to
7768006
Compare
6d8fca8 to
f34a751
Compare
88273cc to
482d5eb
Compare
f34a751 to
540e432
Compare
482d5eb to
8149407
Compare
48f73db to
40a2552
Compare
PR SummaryMedium Risk Overview
Reviewed by Cursor Bugbot for commit 7b294f1. Bugbot is set up for automated code reviews on this repo. Configure here. |
ArielElp
left a comment
There was a problem hiding this comment.
@ArielElp made 1 comment.
Reviewable status: 0 of 5 files reviewed, 1 unresolved discussion (waiting on yoavGrs).
a discussion (no related file):
Previously, yoavGrs wrote…
For each object, test that
deser(ser(object)) == object.
Done.
26ed95b to
e4503a6
Compare
0ac92db to
111d357
Compare
e4503a6 to
31307c5
Compare
111d357 to
063f6b4
Compare
31307c5 to
f3ae5b0
Compare
063f6b4 to
e9e5c4e
Compare
yoavGrs
left a comment
There was a problem hiding this comment.
@yoavGrs reviewed 5 files and all commit messages, made 6 comments, and resolved 1 discussion.
Reviewable status: all files reviewed, 6 unresolved discussions (waiting on ArielElp).
crates/starknet_committer/src/patricia_merkle_tree/starknet_forest_proofs_serialization_test.rs line 128 at r2 (raw file):
} #[template]
Why do you need the template?
crates/starknet_committer/src/patricia_merkle_tree/types.rs line 97 at r2 (raw file):
/// 3. Contract trie leaves — `Vec<(ContractAddress, (Nonce, HashOutput, ClassHash))>`, sorted /// by contract address. /// 4. Storage trie inner nodes — `Vec<(ContractAddress, Vec<(HashOutput, encoded_preimage)>)>`,
?
Suggestion:
triescrates/starknet_committer/src/patricia_merkle_tree/types.rs line 113 at r2 (raw file):
.leaves .iter() .map(|(addr, s)| (*addr, (s.nonce, s.storage_root_hash, s.class_hash)))
Full names, please
Suggestion:
addr, state)crates/starknet_committer/src/patricia_merkle_tree/types.rs line 120 at r2 (raw file):
for (addr, m) in &self.contracts_trie_storage_proofs { storage.push((*addr, sorted_encoded_preimage_map(m)?)); }
In Rust, it's idiomatic to create a vector by iter().map().collect().
Code quote:
let mut storage: Vec<(ContractAddress, Vec<(HashOutput, Vec<u8>)>)> = Vec::new();
for (addr, m) in &self.contracts_trie_storage_proofs {
storage.push((*addr, sorted_encoded_preimage_map(m)?));
}crates/starknet_committer/src/patricia_merkle_tree/types.rs line 167 at r2 (raw file):
{ return Err(DeserializationError::KeyDuplicate(format!( "duplicate storage trie witness key {addr:?}"
Suggestion:
addresscrates/starknet_committer/src/patricia_merkle_tree/types.rs line 270 at r2 (raw file):
) -> Result<Vec<(HashOutput, Vec<u8>)>, SerializationError> { let mut v = Vec::with_capacity(m.len()); for (h, p) in m {
Give full names, please
Suggestion:
for (hash, preimage) in m
ArielElp
left a comment
There was a problem hiding this comment.
@ArielElp made 6 comments.
Reviewable status: all files reviewed, 6 unresolved discussions (waiting on yoavGrs).
crates/starknet_committer/src/patricia_merkle_tree/starknet_forest_proofs_serialization_test.rs line 128 at r2 (raw file):
Previously, yoavGrs wrote…
Why do you need the template?
Removed
crates/starknet_committer/src/patricia_merkle_tree/types.rs line 97 at r2 (raw file):
Previously, yoavGrs wrote…
?
Done.
crates/starknet_committer/src/patricia_merkle_tree/types.rs line 113 at r2 (raw file):
Previously, yoavGrs wrote…
Full names, please
Done.
crates/starknet_committer/src/patricia_merkle_tree/types.rs line 120 at r2 (raw file):
Previously, yoavGrs wrote…
In Rust, it's idiomatic to create a vector by
iter().map().collect().
Done.
crates/starknet_committer/src/patricia_merkle_tree/types.rs line 270 at r2 (raw file):
Previously, yoavGrs wrote…
Give full names, please
Done.
crates/starknet_committer/src/patricia_merkle_tree/types.rs line 167 at r2 (raw file):
{ return Err(DeserializationError::KeyDuplicate(format!( "duplicate storage trie witness key {addr:?}"
Done.
e9e5c4e to
bfe1119
Compare
yoavGrs
left a comment
There was a problem hiding this comment.
@yoavGrs reviewed 2 files and all commit messages, and resolved 6 discussions.
Reviewable status:complete! all files reviewed, all discussions resolved (waiting on ArielElp).
bfe1119 to
f0b03b9
Compare
f3ae5b0 to
959f1cf
Compare
f0b03b9 to
cfe6585
Compare
959f1cf to
7f4f979
Compare
cfe6585 to
8e92e61
Compare
7f4f979 to
22efed7
Compare
8e92e61 to
fcb80de
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/src/patricia_merkle_tree/starknet_forest_proofs_serialization_test.rs line 52 at r5 (raw file):
class_hash: ClassHash(Felt::from(class_hash)), } }
can you ask claude if similar test utils exist in the patricia/committer crates? seems like duplication to me, I vaguely recall similar stuff
Code quote:
fn binary_preimage(node_hash: u128, left: u128, right: u128) -> (HashOutput, Preimage) {
(
HashOutput(Felt::from(node_hash)),
Preimage::Binary(BinaryData {
left_data: HashOutput(Felt::from(left)),
right_data: HashOutput(Felt::from(right)),
}),
)
}
fn edge_preimage(node_hash: u128, bottom: u128, path: u128, length: u8) -> (HashOutput, Preimage) {
(
HashOutput(Felt::from(node_hash)),
Preimage::Edge(EdgeData {
bottom_data: HashOutput(Felt::from(bottom)),
path_to_bottom: PathToBottom::new(
EdgePath(U256::from(path)),
EdgePathLength::new(length).unwrap(),
)
.unwrap(),
}),
)
}
fn contract_state(nonce: u128, storage_root: u128, class_hash: u128) -> ContractState {
ContractState {
nonce: Nonce(Felt::from(nonce)),
storage_root_hash: HashOutput(Felt::from(storage_root)),
class_hash: ClassHash(Felt::from(class_hash)),
}
}crates/starknet_committer/src/patricia_merkle_tree/types.rs at r5 (raw file):
can you move the additions here to a separate module gated by os_input?
there shouldn't be a problem, adding another impl block.
I ask because of all the gated-imports - generally a sign that a new module is a good choice
crates/starknet_committer/src/patricia_merkle_tree/types.rs line 78 at r5 (raw file):
} impl StarknetForestProofs {
why are the (de)serialize functions here needed?
we already have serde logic for facts layout, or at least we have deserialization logic for facts layout. this logic is used by the py-side ambassador to encode commitment infos for OS runs. can't you reuse it?
crates/starknet_committer/src/patricia_merkle_tree/types.rs line 88 at r5 (raw file):
} /// Bincode payload for the OS-input witness KV (structured proofs, round-trips with
KV?
Code quote:
KVa6fd9aa to
c39b0f2
Compare
ArielElp
left a comment
There was a problem hiding this comment.
@ArielElp made 4 comments.
Reviewable status: 3 of 6 files reviewed, 4 unresolved discussions (waiting on dorimedini-starkware and yoavGrs).
crates/starknet_committer/src/patricia_merkle_tree/starknet_forest_proofs_serialization_test.rs line 52 at r5 (raw file):
Previously, dorimedini-starkware wrote…
can you ask claude if similar test utils exist in the patricia/committer crates? seems like duplication to me, I vaguely recall similar stuff
Doesn't look like it, existing tests also explicitly construct ContractState and I don't see (or Cursor) something for Preimage
crates/starknet_committer/src/patricia_merkle_tree/types.rs line 78 at r5 (raw file):
Previously, dorimedini-starkware wrote…
why are the (de)serialize functions here needed?
we already have serde logic for facts layout, or at least we have deserialization logic for facts layout. this logic is used by the py-side ambassador to encode commitment infos for OS runs. can't you reuse it?
For the OsBlockInput constructed in tests we use deserialization of CommitmentInfo, which is a bit more raw compared to StarknetForestProofs.
I kept the structure of StarknetForestProofs, but now reusing the existing encoding/decoding of Preimage, so most of the new code is gone.
crates/starknet_committer/src/patricia_merkle_tree/types.rs line 88 at r5 (raw file):
Previously, dorimedini-starkware wrote…
KV?
AI for the key value preimage map, changed to OS input witnesses
crates/starknet_committer/src/patricia_merkle_tree/types.rs at r5 (raw file):
Previously, dorimedini-starkware wrote…
can you move the additions here to a separate module gated by
os_input?
there shouldn't be a problem, adding anotherimplblock.
I ask because of all the gated-imports - generally a sign that a new module is a good choice
Done.
11d186a to
c9ac657
Compare
c39b0f2 to
a5cc604
Compare
a5cc604 to
7b294f1
Compare
c9ac657 to
5a5ff22
Compare

No description provided.