Skip to content

starknet_committer,starknet_patricia: add serde errors#10810

Merged
ArielElp merged 1 commit intomain-v0.14.1-committerfrom
ariel/add_serde_errors
Dec 24, 2025
Merged

starknet_committer,starknet_patricia: add serde errors#10810
ArielElp merged 1 commit intomain-v0.14.1-committerfrom
ariel/add_serde_errors

Conversation

@ArielElp
Copy link
Contributor

No description provided.

@reviewable-StarkWare
Copy link

This change is Reviewable

Copy link
Contributor Author

ArielElp commented Dec 15, 2025

This stack of pull requests is managed by Graphite. Learn more about stacking.

@ArielElp ArielElp marked this pull request as ready for review December 15, 2025 16:38
@ArielElp ArielElp force-pushed the ariel/add_serde_errors branch from e917ea7 to e744065 Compare December 16, 2025 07:01
@ArielElp ArielElp force-pushed the ariel/abstract_fetch_nodes branch from 7f7a8cf to 6c95b0d Compare December 16, 2025 09:12
@ArielElp ArielElp force-pushed the ariel/add_serde_errors branch from e744065 to 6325858 Compare December 16, 2025 09:12
@ArielElp ArielElp force-pushed the ariel/abstract_fetch_nodes branch from 6c95b0d to b7d1875 Compare December 16, 2025 09:39
@ArielElp ArielElp force-pushed the ariel/add_serde_errors branch from 6325858 to 4d84969 Compare December 16, 2025 09:39
@ArielElp ArielElp force-pushed the ariel/abstract_fetch_nodes branch from b7d1875 to 83edb06 Compare December 16, 2025 10:02
@ArielElp ArielElp force-pushed the ariel/add_serde_errors branch from 4d84969 to 680fc59 Compare December 16, 2025 10:02
@ArielElp ArielElp force-pushed the ariel/abstract_fetch_nodes branch from 83edb06 to b2df561 Compare December 16, 2025 10:18
@ArielElp ArielElp force-pushed the ariel/add_serde_errors branch 2 times, most recently from 20b5056 to 342ad97 Compare December 16, 2025 11:07
@ArielElp ArielElp force-pushed the ariel/abstract_fetch_nodes branch from b2df561 to 231a9b8 Compare December 16, 2025 11:07
Copy link
Contributor

@yoavGrs yoavGrs left a comment

Choose a reason for hiding this comment

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

@yoavGrs reviewed 13 of 13 files at r1, all commit messages.
Reviewable status: all files reviewed, 3 unresolved discussions (waiting on @ArielElp and @nimrod-starkware)


crates/starknet_patricia_storage/src/errors.rs line 15 at r1 (raw file):

#[derive(thiserror::Error, Debug)]
pub enum SerializationError {

Consider define (and use)

pub type SerializationResult<T> = Result<T, SerializationError>;

crates/starknet_patricia_storage/src/errors.rs line 19 at r1 (raw file):

    JsonSerializeError(#[from] serde_json::Error),
    #[error(transparent)]
    FeltSerializeError(#[from] std::io::Error),

Why determine that any transparent IO error is on felts?

Suggestion:

IOSerializeError(#[from] std::io::Error),

crates/starknet_committer_cli/src/commands.rs line 363 at r1 (raw file):

            .expect("Failed to commit the given block.");
        time_measurement.start_measurement(Action::Write);
        let n_new_facts = facts_db.write(&filled_forest).await.unwrap();

Suggestion:

.except("message...");

Copy link
Contributor Author

@ArielElp ArielElp left a comment

Choose a reason for hiding this comment

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

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


crates/starknet_committer/src/db/facts_db/db.rs line 205 at r4 (raw file):

Previously, dorimedini-starkware wrote…

doesn't this work? less changes
(collect can collect a Result<_, _> from an iterator over Results)

Doesn't work as-is since flat_map gives you an iterator over HashMap here, and not an iterator over (k,v) pairs.

Chat suggested this:

        filled_forest
        .storage_tries
        .values()
        .map(|tree| tree.serialize(&EmptyKeyContext))
        .chain(std::iter::once(filled_forest.contracts_trie.serialize(&EmptyKeyContext)))
        .chain(std::iter::once(filled_forest.classes_trie.serialize(&EmptyKeyContext)))
        // Iterator<Item = Result<DbHashMap, SerializationError>>
        .try_fold(DbHashMap::new(), |mut acc, hm| {
            acc.extend(hm?);
            Ok(acc)
        })

Up to you


crates/starknet_patricia_storage/src/errors.rs line 21 at r4 (raw file):

Previously, dorimedini-starkware wrote…

alphabetize please

Done.


crates/starknet_patricia_storage/src/errors.rs line 21 at r4 (raw file):

Previously, dorimedini-starkware wrote…

I know the JsonSerializeError is not your fault but try to omit the Error suffix on error variants: SerializationError::IOSerialize is better than SerializationError::IOSerializeError

Done.


crates/starknet_patricia_storage/src/errors.rs line 48 at r4 (raw file):

Previously, dorimedini-starkware wrote…

while you're here: can you alphabetize this enum?

Done.


crates/starknet_patricia/src/patricia_merkle_tree/filled_tree/tree.rs line 49 at r4 (raw file):

        &self,
        key_context: &<L as HasStaticPrefix>::KeyContext,
    ) -> Result<DbHashMap, SerializationError>;

Done.


crates/starknet_patricia/src/patricia_merkle_tree/filled_tree/tree.rs line 375 at r4 (raw file):

        &self,
        key_context: &<L as HasStaticPrefix>::KeyContext,
    ) -> Result<DbHashMap, SerializationError> {

Done.


crates/starknet_patricia_storage/src/errors.rs line 48 at r4 (raw file):

    ValueError(Box<dyn std::error::Error>),
    #[error("Failed to deserialize raw felt: {0:?}")]
    FeltDeserializationError(DbValue),

Done.

Copy link
Collaborator

@dorimedini-starkware dorimedini-starkware left a comment

Choose a reason for hiding this comment

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

@dorimedini-starkware reviewed 6 files 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/db.rs line 205 at r4 (raw file):

Previously, ArielElp wrote…

Doesn't work as-is since flat_map gives you an iterator over HashMap here, and not an iterator over (k,v) pairs.

Chat suggested this:

        filled_forest
        .storage_tries
        .values()
        .map(|tree| tree.serialize(&EmptyKeyContext))
        .chain(std::iter::once(filled_forest.contracts_trie.serialize(&EmptyKeyContext)))
        .chain(std::iter::once(filled_forest.classes_trie.serialize(&EmptyKeyContext)))
        // Iterator<Item = Result<DbHashMap, SerializationError>>
        .try_fold(DbHashMap::new(), |mut acc, hm| {
            acc.extend(hm?);
            Ok(acc)
        })

Up to you

nah


crates/starknet_committer_and_os_cli/src/committer_cli/tests/python_tests.rs line 81 at r5 (raw file):

    DeserializationTestFailure(#[from] DeserializationError),
    #[error(transparent)]
    SerializationError(#[from] SerializationError),

not-making-it-worse > consistency

Suggestion:

    #[error(transparent)]
    Serialization(#[from] SerializationError),

@ArielElp ArielElp changed the base branch from ariel/abstract_fetch_nodes to graphite-base/10810 December 23, 2025 15:26
@ArielElp ArielElp force-pushed the graphite-base/10810 branch from 7851196 to 97e5941 Compare December 23, 2025 15:36
@ArielElp ArielElp force-pushed the ariel/add_serde_errors branch from 384f2ca to 40351f5 Compare December 23, 2025 15:37
@ArielElp ArielElp changed the base branch from graphite-base/10810 to ariel/abstract_fetch_nodes December 23, 2025 15:37
@ArielElp ArielElp force-pushed the ariel/add_serde_errors branch from 40351f5 to 3bd24d9 Compare December 23, 2025 15:42
Copy link
Contributor Author

@ArielElp ArielElp left a comment

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: 15 of 16 files reviewed, 1 unresolved discussion (waiting on @dorimedini-starkware).


crates/starknet_committer_and_os_cli/src/committer_cli/tests/python_tests.rs line 81 at r5 (raw file):

Previously, dorimedini-starkware wrote…

not-making-it-worse > consistency

Done.

Copy link
Collaborator

@dorimedini-starkware dorimedini-starkware left a comment

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 force-pushed the ariel/abstract_fetch_nodes branch from 97e5941 to a49bbd1 Compare December 24, 2025 08:50
@ArielElp ArielElp force-pushed the ariel/add_serde_errors branch from 3bd24d9 to b4c834d Compare December 24, 2025 08:50
Copy link
Collaborator

@dorimedini-starkware dorimedini-starkware left a comment

Choose a reason for hiding this comment

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

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

@ArielElp ArielElp changed the base branch from ariel/abstract_fetch_nodes to graphite-base/10810 December 24, 2025 11:37
@ArielElp ArielElp force-pushed the graphite-base/10810 branch from a49bbd1 to 8db2e84 Compare December 24, 2025 11:38
@ArielElp ArielElp force-pushed the ariel/add_serde_errors branch from b4c834d to 9a59bb0 Compare December 24, 2025 11:38
@ArielElp ArielElp changed the base branch from graphite-base/10810 to main-v0.14.1-committer December 24, 2025 11:38
@ArielElp ArielElp force-pushed the ariel/add_serde_errors branch from 9a59bb0 to c17c0aa Compare December 24, 2025 11:41
Copy link
Collaborator

@dorimedini-starkware dorimedini-starkware left a comment

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.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on @ArielElp).

@ArielElp ArielElp force-pushed the ariel/add_serde_errors branch from c17c0aa to 20db9ea Compare December 24, 2025 11:59
Copy link
Collaborator

@dorimedini-starkware dorimedini-starkware left a comment

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.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on @ArielElp).

@ArielElp ArielElp added this pull request to the merge queue Dec 24, 2025
Merged via the queue into main-v0.14.1-committer with commit fce02f2 Dec 24, 2025
13 of 15 checks passed
@github-actions github-actions bot locked and limited conversation to collaborators Dec 27, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants