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(storage): ✨ Bonsai storage refactor and rpc call support #28

Merged
merged 16 commits into from
Apr 4, 2024

Conversation

Trantorian1
Copy link
Collaborator

@Trantorian1 Trantorian1 commented Mar 27, 2024

Pull Request type

  • Feature

What is the current behavior?

Bonsai storage is handled separately from Substrate storage and does not interact with the runtime. Moreover, the manual use of bonsai storage in cases such as commitments/lib.rs is not type-safe and is error prone, especially when the amount of type-juggling and manual, often repetitive hash computation.

Other issues further arise when considering a situation with many parallel accesses to the db, which is typical in our use case. This PR aims to introduce some of the boilerplate necessary for minimizing storage locks during block sync by working of BonsaiDb transactional state. Since this is still a work in progress in upstream dependencies, parts of the code relevant to this issue have been commented out, with a more naive 'lock-on-use' approach being currently used.

What is the new behavior?

  • Created a new StoraHandler abstraction for handling bonsai storage in a type-safe way by providing a single source of mutation for the bonsai storage and handling type conversions and hashing for interfacing with the bonsai lib.
  • Set up the boilerplate for writing changes though BonsaiDb transactional state and state merges.
  • Updated rpc methods which rely on bonsai storage to use StorageHandler.
  • Merged duplicate types in crates/runtime/src/types.rs and crates/primitives/types.

Does this introduce a breaking change?

No.

Other information

Looking for feedback on the implementation of StorageHandler.

Trantorian added 5 commits March 25, 2024 09:02
`StorageHandler` is a type-safe storage abstraction with exclusif access to the
backend bonsai storage, allowing for a centralized point of mutation of the
database without the error-prone nature of manually querying the bonsai dbs.
This should reduce blocking time on reading threads for RPC calls. Currently
this applies to `read` and `root` methods on storage handlers.
@Trantorian1 Trantorian1 added the enhancement New feature or request label Mar 27, 2024
@Trantorian1 Trantorian1 self-assigned this Mar 27, 2024
@antiyro antiyro marked this pull request as ready for review March 28, 2024 10:38
@cchudant cchudant mentioned this pull request Mar 29, 2024
Trantorian added 3 commits April 3, 2024 09:13
This includes `Messaging` and `SierraContractClasses`. Note that `L1Handler` is
also set to be removed in the near future and has been marked as deprecated.
@Tbelleng Tbelleng self-requested a review April 4, 2024 14:16
Copy link
Contributor

@Tbelleng Tbelleng left a comment

Choose a reason for hiding this comment

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

Seems good to me, Lfgg well done 🤝

@antiyro antiyro merged commit f5956af into madara-alliance:main Apr 4, 2024
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants