starknet_patricia_storage: two layer storage#13990
Conversation
PR SummaryLow Risk Overview Exports the module from Reviewed by Cursor Bugbot for commit 6d22672. Bugbot is set up for automated code reviews on this repo. Configure here. |
| base.0.insert(key.clone(), val.clone()); | ||
|
|
||
| let mut layered = TwoLayerStorage::new(MapStorage::default(), &base); | ||
| assert_eq!(layered.get_mut(&key).await.unwrap(), Some(val)); |
There was a problem hiding this comment.
Test for mget_mut actually calls get_mut instead
Medium Severity
The test mget_mut_uses_immutable_base_mget_on_miss is named to verify the mget_mut method but actually calls get_mut. This means the mget_mut two-layer fallthrough logic (collecting miss indices, batching base fetches, and merging results) is never exercised by any test, leaving potential bugs in that code path undetected.
Reviewed by Cursor Bugbot for commit 2de219b. Configure here.
There was a problem hiding this comment.
That's right.
Rename this test and add tests for mget.
There was a problem hiding this comment.
Renamed the test, but this is deliberate, I can't call mut_xxx functions on base.
The functions in trie traversal require ReadOnlyStorage. I want to take an existing storage, wrap it with modifications, and then use it for traversal. To do this without consuming the storage, I need to be able to work with ref, hence I have no access to get_mut (base is ImmutableReadOnly). mget_xxx functions are a fake here. It's documented on the type.
There was a problem hiding this comment.
I'm not following. Both get_mut and mget_mut are implemented, but you're only checking the first one here.
It's not related to trie_traversal.
yoavGrs
left a comment
There was a problem hiding this comment.
@yoavGrs reviewed 2 files and all commit messages, and made 4 comments.
Reviewable status: all files reviewed, 4 unresolved discussions (waiting on ArielElp).
a discussion (no related file):
Just a reminder, what do you need this for?
crates/starknet_patricia_storage/src/two_layer_storage.rs line 25 at r1 (raw file):
pub overlay: Overlay, pub base: &'a Base, }
Suggestion:
{
overlay: Overlay,
base: &'a Base,
}crates/starknet_patricia_storage/src/two_layer_storage.rs line 69 at r1 (raw file):
} #[cfg(test)]
Move tests to a testing file.
| base.0.insert(key.clone(), val.clone()); | ||
|
|
||
| let mut layered = TwoLayerStorage::new(MapStorage::default(), &base); | ||
| assert_eq!(layered.get_mut(&key).await.unwrap(), Some(val)); |
There was a problem hiding this comment.
That's right.
Rename this test and add tests for mget.
2de219b to
d746081
Compare
ArielElp
left a comment
There was a problem hiding this comment.
@ArielElp reviewed 1 file and made 3 comments.
Reviewable status: all files reviewed, 4 unresolved discussions (waiting on yoavGrs).
crates/starknet_patricia_storage/src/two_layer_storage.rs line 69 at r1 (raw file):
Previously, yoavGrs wrote…
Move tests to a testing file.
Done.
crates/starknet_patricia_storage/src/two_layer_storage.rs line 25 at r1 (raw file):
pub overlay: Overlay, pub base: &'a Base, }
Done.
| base.0.insert(key.clone(), val.clone()); | ||
|
|
||
| let mut layered = TwoLayerStorage::new(MapStorage::default(), &base); | ||
| assert_eq!(layered.get_mut(&key).await.unwrap(), Some(val)); |
There was a problem hiding this comment.
Renamed the test, but this is deliberate, I can't call mut_xxx functions on base.
The functions in trie traversal require ReadOnlyStorage. I want to take an existing storage, wrap it with modifications, and then use it for traversal. To do this without consuming the storage, I need to be able to work with ref, hence I have no access to get_mut (base is ImmutableReadOnly). mget_xxx functions are a fake here. It's documented on the type.
d746081 to
6d22672
Compare
6d471bd to
3f8b451
Compare
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
There are 2 total unresolved issues (including 1 from previous review).
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 6d22672. Configure here.
|
|
||
| let mut layered = TwoLayerStorage::new(MapStorage::default(), &base); | ||
| assert_eq!(layered.get_mut(&key).await.unwrap(), Some(val)); | ||
| } |
There was a problem hiding this comment.
Test named mget_mut actually calls get_mut instead
Medium Severity
The test mget_mut_uses_immutable_base_get_on_miss calls layered.get_mut(&key) instead of layered.mget_mut(...). This means the mget_mut code path in TwoLayerStorage — which has distinct logic for collecting miss indices, batch-fetching from base, and merging results — has no test coverage at all. The reviewer explicitly requested mget tests be added, but the current test only exercises get_mut.
Reviewed by Cursor Bugbot for commit 6d22672. Configure here.
yoavGrs
left a comment
There was a problem hiding this comment.
@yoavGrs reviewed all commit messages, made 2 comments, and resolved 2 discussions.
Reviewable status: 1 of 3 files reviewed, 4 unresolved discussions (waiting on ArielElp).
crates/starknet_patricia_storage/src/two_layer_storage.rs line 70 at r2 (raw file):
#[cfg(test)] #[path = "two_layer_storage_test.rs"]
Move it to the top of the file.
| base.0.insert(key.clone(), val.clone()); | ||
|
|
||
| let mut layered = TwoLayerStorage::new(MapStorage::default(), &base); | ||
| assert_eq!(layered.get_mut(&key).await.unwrap(), Some(val)); |
There was a problem hiding this comment.
I'm not following. Both get_mut and mget_mut are implemented, but you're only checking the first one here.
It's not related to trie_traversal.



No description provided.