Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Hello,
This PR addresses the review suggestions you sent us, it contains all the changes we made following the review. However, there are some suggestions that we did not apply and we'll explain why here :
For the
serialize
method ofId
(renamed toto_bytes
now) it’s impossible to return a slice of the object because the byte representation will be created inside the function. We could use a slice as a parameter and have the same behaviour as this crate : https://docs.rs/integer-encoding/latest/integer_encoding/trait.FixedInt.html#tymethod.encode_fixed but we don’t think it’s more suitable for our usage. Open to suggestions.For the errors we applied the changes you asked and we now use error types from DB/Felt conversion/Node decoding however we still have errors that hold a String for custom errors and for errors that need a context to be understandable.
Your idea to use
serde
for the serialization of the changes is great but we think that it's too big of a machinery. The reasons are :serde
etc is uselessFor the TrieKey (which we have renamed to
KeyOwned
) we can’t use a slice with lifetime because we are saving a collection of these types in the structure of the trie (MerkleTree
) but we are creating these objects when setting a new key in the trie or removing one. These objects don't live more than the tree because they are created when we manipulate it and so we can’t use a reference to store them in the trie.pub(super)
on the typePath
prevents us to make the comparison in the tests https://github.com/keep-starknet-strange/bonsai-trie/blob/4ae6caeb59429cee8efd51ebf821569b26caa91e/src/tests/proof.rs#L107The
#[test]
attribute already makes the function available only in test mode : https://doc.rust-lang.org/stable/reference/attributes/testing.html#the-test-attributeFor the proposition of decoding directly in the key_value db we think it breaks the separation of concern and the simplicity of this structure
KeyValueDB
that is very straightforward for DB interactions. Moreover yourT::decode()
would lead to have a new trait implemented for all the values we want to decode which will lead to complexity and less usability of theKeyValueDB
structure.“I see no reason why you cannot get rid of this and insert directly in self.storage_nodes” https://github.com/keep-starknet-strange/bonsai-trie/blob/87525315abac9611430c5f3c8db922f1d8e0e42f/src/trie/merkle_tree.rs#L464 It’s not possible because we already have a mutual borrow and so we would have two