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): ✨ BonsaiStorage logs are no longer stored in db #82

Merged
merged 3 commits into from
Apr 29, 2024

Conversation

Trantorian1
Copy link
Collaborator

@Trantorian1 Trantorian1 commented Apr 28, 2024

Pull Request type

  • Bugfix

What is the current behavior?

Bonsai lib logs currently take up a cumulative 93.1% of the database space, with the bonsai lib as a whole being responsible for 98.8% of database usage.

image

What is the new behavior?

Removed reliance on Bonsai lib: BonsaiStorage is no longer used to store contract storage in a revertible way. Instead, we use our own custom solution to handle that (kudos to @jbcaron for comming up with this). This has resulted in a 13.3x reduction in storage space. Note that this still introduces a temporary duplication of storage, with contract key/value being stored both in the Bonsai lib and our custom storage.

image

ℹ️ Note that the Bonsai lib is still responsible for 51.6% of the storage in Deoxys.

Does this introduce a breaking change?

Yes. Due to changes in the database, any node currently running will have to re-start synchronizing from the block 0.

Other information

Some of the code for inserting contract storage into the db might seem messy. Keep in mind I will be making another pr tomorrow rewriting all rocksdb storage access to make better use write batches and multiget.

@Trantorian1 Trantorian1 added the bug Report an issue or unexpected behavior label Apr 28, 2024
@@ -206,6 +208,7 @@ impl Column {
Column::ContractClassData => "contract_class_data",
Column::ContractData => "contract_data",
Column::ContractClassHashes => "contract_class_hashes",
Column::ContractStorage => "contrac_storage",
Copy link
Member

Choose a reason for hiding this comment

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

"contract"

Copy link
Member

@jbcaron jbcaron left a comment

Choose a reason for hiding this comment

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

Cf comment

.collect();

let mut batch = WriteBatchWithTransaction::<true>::default();
for (key, mut history, value) in izip!(keys, histories?, values) {
Copy link
Member

Choose a reason for hiding this comment

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

return the error before
histories?

@antiyro antiyro merged commit a3dc79c into madara-alliance:main Apr 29, 2024
7 checks passed
@Trantorian1 Trantorian1 deleted the contract_storage branch April 29, 2024 09:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Report an issue or unexpected behavior
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants