Skip to content

starknet_patricia_storage: move is_gatherable to ReadOnlyStorage#14280

Merged
ArielElp merged 1 commit into
mainfrom
ariel/move_as_gatherable_to_read_only_storage
Jun 7, 2026
Merged

starknet_patricia_storage: move is_gatherable to ReadOnlyStorage#14280
ArielElp merged 1 commit into
mainfrom
ariel/move_as_gatherable_to_read_only_storage

Conversation

@ArielElp

@ArielElp ArielElp commented Jun 1, 2026

Copy link
Copy Markdown
Contributor

No description provided.

@reviewable-StarkWare

Copy link
Copy Markdown

This change is Reviewable

@cursor

cursor Bot commented Jun 1, 2026

Copy link
Copy Markdown

PR Summary

Low Risk
Trait-only relocation with unchanged gather semantics; limited to Patricia storage trait wiring and impl blocks.

Overview
Moves as_gatherable_storage from Storage to ReadOnlyStorage, so callers that only hold a mutable read-only view (e.g. overlay wrappers, concurrent trie reads) can probe GatherableStorage without requiring write-capable storage.

Each backend and wrapper now implements the hook on ReadOnlyStorage: real backends still return Some(self); ReadsCollectorStorage, TwoLayerStorage, and short-key wrappers return None with documented rationale. CachedStorage’s ReadOnlyStorage impl picks up the same 'static bound already used for GatherableStorage.

Reviewed by Cursor Bugbot for commit 22fbbee. Bugbot is set up for automated code reviews on this repo. Configure here.

@ArielElp ArielElp requested a review from yoavGrs June 1, 2026 12:39
@ArielElp ArielElp force-pushed the ariel/switch_to_blockifier_accessed_keys branch from a5ac682 to 320dff3 Compare June 2, 2026 11:57
@ArielElp ArielElp force-pushed the ariel/move_as_gatherable_to_read_only_storage branch from 17d61f2 to 4d43ae3 Compare June 2, 2026 11:57
@ArielElp ArielElp force-pushed the ariel/switch_to_blockifier_accessed_keys branch from 320dff3 to e126a94 Compare June 2, 2026 12:08
@ArielElp ArielElp force-pushed the ariel/move_as_gatherable_to_read_only_storage branch 2 times, most recently from 831d5cf to 6b3eb36 Compare June 2, 2026 13:54
@ArielElp ArielElp force-pushed the ariel/switch_to_blockifier_accessed_keys branch from e126a94 to 50bbdd5 Compare June 2, 2026 13:54
@ArielElp ArielElp force-pushed the ariel/move_as_gatherable_to_read_only_storage branch 2 times, most recently from a3f03fc to 5b37897 Compare June 2, 2026 17:21
@ArielElp ArielElp force-pushed the ariel/switch_to_blockifier_accessed_keys branch from 1741bec to 263e820 Compare June 2, 2026 17:21
@ArielElp ArielElp force-pushed the ariel/move_as_gatherable_to_read_only_storage branch from 5b37897 to 48b3a2f Compare June 3, 2026 11:07
@ArielElp ArielElp force-pushed the ariel/switch_to_blockifier_accessed_keys branch 2 times, most recently from 2534a7d to c698d25 Compare June 3, 2026 13:14
@ArielElp ArielElp force-pushed the ariel/move_as_gatherable_to_read_only_storage branch from 48b3a2f to 75e57b6 Compare June 3, 2026 13:14
@ArielElp ArielElp force-pushed the ariel/switch_to_blockifier_accessed_keys branch from c698d25 to b9f4b32 Compare June 3, 2026 15:17
@ArielElp ArielElp force-pushed the ariel/move_as_gatherable_to_read_only_storage branch from 75e57b6 to 9114559 Compare June 3, 2026 15:17
@ArielElp ArielElp force-pushed the ariel/switch_to_blockifier_accessed_keys branch from b9f4b32 to ad400eb Compare June 3, 2026 15:52
@ArielElp ArielElp force-pushed the ariel/move_as_gatherable_to_read_only_storage branch from 9114559 to 5326f1b Compare June 3, 2026 15:52
@ArielElp ArielElp changed the base branch from ariel/switch_to_blockifier_accessed_keys to graphite-base/14280 June 4, 2026 08:15

@yoavGrs yoavGrs left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@yoavGrs reviewed 8 files and all commit messages, and made 1 comment.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on ArielElp).


crates/starknet_patricia_storage/src/map_storage.rs line 305 at r1 (raw file):

}

// TODO(Nimrod): Find a way to share the implementation with `ImmutableReadOnlyStorage`.

Mark as done?

Code quote:

// TODO(Nimrod): Find a way to share the implementation with `ImmutableReadOnlyStorage`.

@ArielElp ArielElp left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ArielElp made 1 comment.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on yoavGrs).


crates/starknet_patricia_storage/src/map_storage.rs line 305 at r1 (raw file):

Previously, yoavGrs wrote…

Mark as done?

I don't think it's related to the change. This one is about attempting to use the logic of ImmutableReadOnlyStorage's get in get_mut so that it looks something like:

  1. immutable get
  2. update cache

@ArielElp ArielElp force-pushed the ariel/move_as_gatherable_to_read_only_storage branch from 5326f1b to e1d16c6 Compare June 7, 2026 07:57
@ArielElp ArielElp force-pushed the graphite-base/14280 branch from ad400eb to 0d7ef4c Compare June 7, 2026 07:57

@yoavGrs yoavGrs left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@yoavGrs resolved 1 discussion.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on ArielElp).

@dorimedini-starkware dorimedini-starkware left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dorimedini-starkware reviewed 8 files and all commit messages, and made 2 comments.
Reviewable status: all files reviewed, 2 unresolved discussions (waiting on ArielElp).


crates/starknet_patricia_storage/src/two_layer_storage.rs line 75 at r1 (raw file):

    fn as_gatherable_storage(&mut self) -> Option<&mut impl GatherableStorage> {
        None::<&mut NullStorage>
    }

add a docstring remarking why this type should not return Some please

Code quote:

    fn as_gatherable_storage(&mut self) -> Option<&mut impl GatherableStorage> {
        None::<&mut NullStorage>
    }

crates/starknet_patricia_storage/src/reads_collector_storage.rs line 51 at r1 (raw file):

    fn as_gatherable_storage(&mut self) -> Option<&mut impl GatherableStorage> {
        None::<&mut NullStorage>
    }

am i right?

Suggestion:

    /// This type is intended to be the gather *target*; do not spawn gatherable instances.
    fn as_gatherable_storage(&mut self) -> Option<&mut impl GatherableStorage> {
        None::<&mut NullStorage>
    }

@ArielElp ArielElp force-pushed the graphite-base/14280 branch from 0d7ef4c to 7e41fc2 Compare June 7, 2026 11:47
@ArielElp ArielElp force-pushed the ariel/move_as_gatherable_to_read_only_storage branch from e1d16c6 to cf047d5 Compare June 7, 2026 11:47
@ArielElp ArielElp changed the base branch from graphite-base/14280 to main June 7, 2026 11:47

@ArielElp ArielElp left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ArielElp made 2 comments.
Reviewable status: 7 of 8 files reviewed, 2 unresolved discussions (waiting on dorimedini-starkware and yoavGrs).


crates/starknet_patricia_storage/src/reads_collector_storage.rs line 51 at r1 (raw file):

Previously, dorimedini-starkware wrote…

am i right?

I'm not sure wdym by "the gather target". gather has a default implementation that is running tasks and collecting reads via the ReadsCollectorStorage wrapper, but there is nothing inherent in this behavior. Any storage (well, except TwoLayerStorage) can be gatherable; we only did it for types we intend to use in that way.


crates/starknet_patricia_storage/src/two_layer_storage.rs line 75 at r1 (raw file):

Previously, dorimedini-starkware wrote…

add a docstring remarking why this type should not return Some please

Done.

@dorimedini-starkware dorimedini-starkware left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dorimedini-starkware reviewed 1 file and all commit messages, made 1 comment, and resolved 1 discussion.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on ArielElp).


crates/starknet_patricia_storage/src/reads_collector_storage.rs line 51 at r1 (raw file):

Previously, ArielElp wrote…

I'm not sure wdym by "the gather target". gather has a default implementation that is running tasks and collecting reads via the ReadsCollectorStorage wrapper, but there is nothing inherent in this behavior. Any storage (well, except TwoLayerStorage) can be gatherable; we only did it for types we intend to use in that way.

we use "gatherable" storage to spawn separate storage readers which separately cache reads, so they can be collected via ReadsCollectorStorage; this is why making ReadCollectorStorage gatherable is redundant, no?

@ArielElp ArielElp left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ArielElp made 1 comment.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on dorimedini-starkware).


crates/starknet_patricia_storage/src/reads_collector_storage.rs line 51 at r1 (raw file):

Previously, dorimedini-starkware wrote…

we use "gatherable" storage to spawn separate storage readers which separately cache reads, so they can be collected via ReadsCollectorStorage; this is why making ReadCollectorStorage gatherable is redundant, no?

This is what we use it for in practice, but the notion of gatherable is "run a bunch of tasks concurrently". We don't need to do it with ReadsCollectorStorage, as it's just an implementation detail of the default gather logic, but we could do it in the future for some reason.

@dorimedini-starkware dorimedini-starkware left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dorimedini-starkware made 1 comment.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on ArielElp).


crates/starknet_patricia_storage/src/reads_collector_storage.rs line 51 at r1 (raw file):

Previously, ArielElp wrote…

This is what we use it for in practice, but the notion of gatherable is "run a bunch of tasks concurrently". We don't need to do it with ReadsCollectorStorage, as it's just an implementation detail of the default gather logic, but we could do it in the future for some reason.

it would be best to add a remark to explain why it's Null. it can be

/// It's possible to implement [GatherableStorage] on [Self] but it currently has no use case.

@ArielElp ArielElp force-pushed the ariel/move_as_gatherable_to_read_only_storage branch from cf047d5 to 22fbbee Compare June 7, 2026 12:14

@ArielElp ArielElp left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ArielElp made 1 comment.
Reviewable status: 7 of 8 files reviewed, 1 unresolved discussion (waiting on dorimedini-starkware and yoavGrs).


crates/starknet_patricia_storage/src/reads_collector_storage.rs line 51 at r1 (raw file):

Previously, dorimedini-starkware wrote…

it would be best to add a remark to explain why it's Null. it can be

/// It's possible to implement [GatherableStorage] on [Self] but it currently has no use case.

Added, WDYT?

@dorimedini-starkware dorimedini-starkware left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dorimedini-starkware reviewed 1 file and all commit messages, and resolved 1 discussion.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on ArielElp).

@ArielElp ArielElp added this pull request to the merge queue Jun 7, 2026
Merged via the queue into main with commit 92c60e9 Jun 7, 2026
21 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants