Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(BonsaiStorage): added new methods for retrieving key-value pairs and change id for BonsaiStorage #25

Merged
merged 6 commits into from
Apr 12, 2024

Conversation

Trantorian1
Copy link
Contributor

@Trantorian1 Trantorian1 commented Apr 5, 2024

Pull Request type

  • Feature

What is the current behavior?

This Pr aims to add functionality around key-value and change id retrieval for BonsaiStrorage.

What is the new behavior?

  • get_keys now ignores empty keys and skips the size byte after the identifier. Note that this introduces issues with the handling of HashMapDb as pertains to HashMapDB does not differenciate between leaf and branch nodes #26. Given that this is an error related to the structure and not this methods directly, I believe this update is still pertinent as it makes key retrieval more intuitive for the end user.
  • get_key_value_pairs has been added which works pretty much as the name indicates, with the same drawbacks as stated above for get_keys wihth HashMapDb.
  • get_latest_id has been added which returns the latest id committed to a db, or None if no commit has occurred. This is mainly useful for creating transactional_state based on the latest commit to the db.

ℹ️ Note that unit tests have also been added for get_keys

Does this introduce a breaking change?

Yes. get_keys will no longer:

  1. return empty keys.
  2. return the size byte in a key.

In practice though, this just means the function should now be easier to use.

Trantorian added 4 commits April 4, 2024 02:03
Also updated `get_keys` to filter out non-leaf nodes + remove the length byte at index 0 when returning
keys.

> Please note that this currently poses problems with the implementation of `HashMapDb`, due to it not
differenciating leaf nodes from branch nodes. This will have to be fixed at a later date.
@tdelabro
Copy link
Contributor

tdelabro commented Apr 9, 2024

Note that this introduces issues with the handling of HashMapDb, due to it not currently differentiating between leaf and branch nodes.

Can you create an issue with full context? And a proposal of fix?

src/trie/merkle_tree.rs Outdated Show resolved Hide resolved
src/trie/merkle_tree.rs Outdated Show resolved Hide resolved
src/trie/merkle_tree.rs Outdated Show resolved Hide resolved
src/trie/merkle_tree.rs Show resolved Hide resolved
@tdelabro tdelabro merged commit 6efb672 into madara-alliance:oss Apr 12, 2024
6 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.

3 participants