starknet_committer: fetch patricia paths tests#13959
Conversation
61f0e7e to
b6f331e
Compare
414244d to
22604c1
Compare
PR SummaryLow Risk Overview Adds helpers to compute expected fetched leaves and to convert a Facts-layout trie into Index-layout storage via Moves the Reviewed by Cursor Bugbot for commit 4c3049b. 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 4 files and all commit messages, and made 9 comments.
Reviewable status: all files reviewed, 9 unresolved discussions (waiting on ArielElp).
crates/starknet_committer/src/db/facts_db/traversal_test.rs line 6 at r1 (raw file):
use pretty_assertions::assert_eq; use rstest::rstest; use rstest_reuse::{apply, template};
Nice :)
Code quote:
use rstest_reuse::{apply, template};crates/starknet_committer/src/db/facts_db/traversal_test.rs line 79 at r1 (raw file):
async fn convert_trie_to_index_storage( storage: &mut MapStorage,
Suggestion:
facts_storage: &mut MapStorage,crates/starknet_committer/src/db/facts_db/traversal_test.rs line 97 at r1 (raw file):
} async fn test_fetch_patricia_paths_inner_impl<Layout>(
Tests should start with a test_ prefix, not helper functions.
(I know it's not your code)
Code quote:
test_fetch_patricia_paths_inner_implcrates/starknet_committer/src/db/facts_db/traversal_test.rs line 107 at r1 (raw file):
for<'a> Layout: NodeLayout<'a, MockLeaf>, { let root_index = small_tree_index_to_full(U256::ONE, height);
It's always 1, no?
Suggestion:
let root_index = NodeIndex::ROOT;crates/starknet_committer/src/db/facts_db/traversal_test.rs line 108 at r1 (raw file):
{ let root_index = small_tree_index_to_full(U256::ONE, height); let mut leaf_indices_full = leaf_indices
Better?
Suggestion:
leaf_full_indicescrates/starknet_committer/src/db/facts_db/traversal_test.rs line 142 at r1 (raw file):
} #[template]
I'm not blocking, but I think this is one of the cases where parameterization makes it difficult to understand.
Code snippet:
Using parametrization in a test (using rstest)
can make tests harder to reason about and debug in some cases,
when the parametrization is very complicated and involves complex types.
In those cases one should consider a free-function that performs the test,
and several one-line tests that call it with different args,
rather than forcing a parameterized solution.crates/starknet_committer/src/db/facts_db/traversal_test.rs line 625 at r1 (raw file):
) { let expected_fetched_leaves = compute_expected_leaves(&storage, &leaf_indices, height); let root_index = small_tree_index_to_full(U256::ONE, height);
As above
Suggestion:
let root_index = NodeIndex::ROOT;crates/starknet_committer/src/db/facts_db/traversal_test.rs line 648 at r1 (raw file):
} fn parse_json_test_input(
Document the output.
Code quote:
parse_json_test_input(crates/starknet_committer/src/db/facts_db/traversal_test.rs line 747 at r1 (raw file):
parse_json_test_input(input_data); let expected_fetched_leaves = compute_expected_leaves(&storage, &leaf_indices, height); let root_index = small_tree_index_to_full(U256::ONE, height);
Same here.
Code quote:
small_tree_index_to_full(U256::ONE, height);22604c1 to
4c3049b
Compare
b6f331e to
22de1c4
Compare
ArielElp
left a comment
There was a problem hiding this comment.
@ArielElp made 8 comments.
Reviewable status: 3 of 4 files reviewed, 9 unresolved discussions (waiting on yoavGrs).
crates/starknet_committer/src/db/facts_db/traversal_test.rs line 97 at r1 (raw file):
Previously, yoavGrs wrote…
Tests should start with a
test_prefix, not helper functions.
(I know it's not your code)
Renamed and added some docs
crates/starknet_committer/src/db/facts_db/traversal_test.rs line 107 at r1 (raw file):
Previously, yoavGrs wrote…
It's always 1, no?
No, we're submitting small subtrees to this function
crates/starknet_committer/src/db/facts_db/traversal_test.rs line 108 at r1 (raw file):
Previously, yoavGrs wrote…
Better?
Given the new comment I think it's better as-is
crates/starknet_committer/src/db/facts_db/traversal_test.rs line 142 at r1 (raw file):
Previously, yoavGrs wrote…
I'm not blocking, but I think this is one of the cases where parameterization makes it difficult to understand.
Why though? IMO it screams template, you have your trees (worked hard to come up with the examples once), and want to test them with two storage layouts.
crates/starknet_committer/src/db/facts_db/traversal_test.rs line 625 at r1 (raw file):
Previously, yoavGrs wrote…
As above
Same
crates/starknet_committer/src/db/facts_db/traversal_test.rs line 648 at r1 (raw file):
Previously, yoavGrs wrote…
Document the output.
Done.
crates/starknet_committer/src/db/facts_db/traversal_test.rs line 747 at r1 (raw file):
Previously, yoavGrs wrote…
Same here.
Same
crates/starknet_committer/src/db/facts_db/traversal_test.rs line 79 at r1 (raw file):
async fn convert_trie_to_index_storage( storage: &mut MapStorage,
Done.
ArielElp
left a comment
There was a problem hiding this comment.
@ArielElp made 1 comment and resolved 1 discussion.
Reviewable status: 3 of 4 files reviewed, 8 unresolved discussions (waiting on yoavGrs).
crates/starknet_committer/src/db/facts_db/traversal_test.rs line 6 at r1 (raw file):
Previously, yoavGrs wrote…
Nice :)
toda!
yoavGrs
left a comment
There was a problem hiding this comment.
@yoavGrs reviewed 1 file and all commit messages, made 2 comments, and resolved 7 discussions.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on ArielElp).
crates/starknet_committer/src/db/facts_db/traversal_test.rs line 142 at r1 (raw file):
Previously, ArielElp wrote…
Why though? IMO it screams template, you have your trees (worked hard to come up with the examples once), and want to test them with two storage layouts.
The template concept fits here, sure.
My issue is with complicated Rust objects wrapped by a macro.

No description provided.