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

Merge transactionnal state with uncommitted changes #28

Merged

Conversation

bilboquet
Copy link
Contributor

@bilboquet bilboquet commented Apr 16, 2024

@tdelabro @antiyro
Please find this work done at Massalabs that allows to merge transactional state with uncommitted changes into bonsai storage.

  • Any uncommitted changes in the bonsai storage that conflict with the changes in the transactional state are overwritten
  • Any uncommitted changes in transactional state are propagated during merge operation, and can be merged later

Co-authored-by: Damir Vodenicarevic [email protected]
Co-authored-by: AurelienFT [email protected]
Co-authored-by: Jean-François [email protected]

@bilboquet bilboquet force-pushed the mergeable_transactional_state branch from 92bcb49 to 69f6f96 Compare April 18, 2024 08:54
Co-authored-by: Damir Vodenicarevic <[email protected]>
Co-authored-by: AurelienFT <[email protected]>
Co-authored-by: Jean-François <[email protected]>

Signed-off-by: Jean-François <[email protected]>
@bilboquet bilboquet force-pushed the mergeable_transactional_state branch from 69f6f96 to 7c65199 Compare April 18, 2024 09:10
@bilboquet bilboquet marked this pull request as ready for review April 18, 2024 09:24
@bilboquet bilboquet changed the title merge transactionnal state with uncommitted changes Merge transactionnal state with uncommitted changes Apr 18, 2024
@@ -296,7 +292,7 @@ pub struct MerkleTree<H: StarkHash> {
/// The list of nodes that should be removed from the underlying database during the next commit.
death_row: Vec<TrieKey>,
/// The list of leaves that have been modified during the current commit.
cache_leaf_modified: HashMap<Vec<u8>, InsertOrRemove<Felt>>,
pub cache_leaf_modified: HashMap<Vec<u8>, InsertOrRemove<Felt>>,
Copy link
Contributor

Choose a reason for hiding this comment

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

If you only read it for reading, maybe a getter will be better, than pub

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ok

src/lib.rs Outdated
Comment on lines 493 to 506
//self.tries.db_mut().merge() work for all test but one
//(merge_with_uncommitted_remove, it fails with RocksDB.Busy error,
//which seems to be related to use of OptimisticTransactions, but
//removing them does not solve this particular problem but causes
//others).

//Applying changes after call to merge() would imply a big refactor as
//merge take ownership of its arguments, hence changes are not
//available anymore.

//Hence the solution which is a tradeoff between the two solutions:
//1. memorize changes
//2. merge tries
//3. apply changes
Copy link
Contributor

Choose a reason for hiding this comment

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

fmt comment

Copy link
Contributor Author

Choose a reason for hiding this comment

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

will remove, the code is self-explanatory

src/lib.rs Outdated
Comment on lines 499 to 501
//Applying changes after call to merge() would imply a big refactor as
//merge take ownership of its arguments, hence changes are not
//available anymore.
Copy link
Contributor

Choose a reason for hiding this comment

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

Do you want to create an issue for this? Or is it not even worth it?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't think it worth it. And I think this whole comment is not really useful (it was for the internal review). I'm going to remove it.

@AurelienFT
Copy link
Collaborator

I'm merging this as there is a lot of perfs improvements that will come in the following days and don't want to block the process (given the fact that you already approved @tdelabro also)

@AurelienFT AurelienFT merged commit f92d341 into madara-alliance:oss Apr 22, 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