starknet_committer,starknet_patricia: add serde errors#10810
starknet_committer,starknet_patricia: add serde errors#10810ArielElp merged 1 commit intomain-v0.14.1-committerfrom
Conversation
e917ea7 to
e744065
Compare
7f7a8cf to
6c95b0d
Compare
e744065 to
6325858
Compare
6c95b0d to
b7d1875
Compare
6325858 to
4d84969
Compare
b7d1875 to
83edb06
Compare
4d84969 to
680fc59
Compare
83edb06 to
b2df561
Compare
20b5056 to
342ad97
Compare
b2df561 to
231a9b8
Compare
yoavGrs
left a comment
There was a problem hiding this comment.
@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...");f08a6b1 to
7851196
Compare
f51d69b to
384f2ca
Compare
ArielElp
left a comment
There was a problem hiding this comment.
@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
(collectcan collect aResult<_, _>from an iterator overResults)
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
JsonSerializeErroris not your fault but try to omit theErrorsuffix on error variants:SerializationError::IOSerializeis better thanSerializationError::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.
dorimedini-starkware
left a comment
There was a problem hiding this comment.
@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),7851196 to
97e5941
Compare
384f2ca to
40351f5
Compare
40351f5 to
3bd24d9
Compare
ArielElp
left a comment
There was a problem hiding this comment.
@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.
dorimedini-starkware
left a comment
There was a problem hiding this comment.
@dorimedini-starkware reviewed 1 file and all commit messages, and resolved 1 discussion.
Reviewable status:complete! all files reviewed, all discussions resolved (waiting on @ArielElp).
97e5941 to
a49bbd1
Compare
3bd24d9 to
b4c834d
Compare
dorimedini-starkware
left a comment
There was a problem hiding this comment.
@dorimedini-starkware reviewed 6 files and all commit messages.
Reviewable status:complete! all files reviewed, all discussions resolved (waiting on @ArielElp).
a49bbd1 to
8db2e84
Compare
b4c834d to
9a59bb0
Compare
9a59bb0 to
c17c0aa
Compare
dorimedini-starkware
left a comment
There was a problem hiding this comment.
@dorimedini-starkware reviewed 1 file and all commit messages.
Reviewable status:complete! all files reviewed, all discussions resolved (waiting on @ArielElp).
c17c0aa to
20db9ea
Compare
dorimedini-starkware
left a comment
There was a problem hiding this comment.
@dorimedini-starkware reviewed 1 file and all commit messages.
Reviewable status:complete! all files reviewed, all discussions resolved (waiting on @ArielElp).
fce02f2

No description provided.