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

refactor: Use BundleBuilder instead of hashmaps #8264

Merged
merged 6 commits into from
Jun 29, 2024

Conversation

quentinv72
Copy link
Contributor

@quentinv72 quentinv72 commented May 14, 2024

Closes #4614

  • Update insert_state in crates/storage/db-common/src/init.rs to use BundleBuilder
  • Update unwind_or_peek_state in crates/storage/provider/src/providers/database/provider.rs to use BundleBuilder
  • Remove BundleStateInit, AccountRevertInit, and RevertInit.

@quentinv72 quentinv72 marked this pull request as ready for review May 14, 2024 19:53
@emhane emhane added D-good-first-issue Nice and easy! A great choice to get started C-debt Refactor of code section that is hard to understand or maintain A-db Related to the database labels May 16, 2024
Copy link
Member

@emhane emhane left a comment

Choose a reason for hiding this comment

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

lgtm, pending @rakita

@mattsse mattsse self-assigned this Jun 10, 2024
DaniPopes added a commit to paradigmxyz/revm-inspectors that referenced this pull request Jun 16, 2024
Upgrade revm version to help unblock changes needed in
paradigmxyz/reth#8264 (comment)

---------

Co-authored-by: DaniPopes <57450786+DaniPopes@users.noreply.github.com>
@quentinv72 quentinv72 mentioned this pull request Jun 16, 2024
@quentinv72
Copy link
Contributor Author

@rakita @mattsse This PR is ready for review when you get some time. Thank you.

@onbjerg onbjerg changed the title (refactor) Use BundleBuilder instead of hashmaps refactor: Use BundleBuilder instead of hashmaps Jun 16, 2024
Copy link
Collaborator

@mattsse mattsse left a comment

Choose a reason for hiding this comment

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

lgtm, this is a lot cleaner now

this is a bit delicate so I'd appreciate another review by @rkrasiuk @rakita

Comment on lines +605 to +608
if let Some(old_info) = old_info {
bundle_builder =
bundle_builder.state_original_account_info(address, into_revm_acc(old_info));
}
Copy link
Member

Choose a reason for hiding this comment

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

previous behavior: if the entry is occuppied, overwrite the original account state even if old_info is None
current behavior: only overwrite the original account state if old_info is Some

if old_info is None, original info must still be overwritten

Comment on lines +600 to +602
if let Some(new_info) = new_info {
bundle_builder =
bundle_builder.state_present_account_info(address, into_revm_acc(new_info));
Copy link
Member

Choose a reason for hiding this comment

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

same as the comment below, this leads to incorrect state for destroyed accounts

entry.insert((present_info, present_info, HashMap::new()))
if !bundle_builder.get_states().contains(&address) {
let present_info = plain_accounts_cursor.seek_exact(address)?.map(|kv| kv.1);
if let Some(present_info) = present_info {
Copy link
Member

Choose a reason for hiding this comment

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

there should be no Some check here

Comment on lines +631 to 634
let account_state = match bundle_builder.get_state_storage_mut().entry(address) {
hash_map::Entry::Occupied(entry) => entry.into_mut(),
hash_map::Entry::Vacant(entry) => entry.insert(HashMap::new()),
};
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
let account_state = match bundle_builder.get_state_storage_mut().entry(address) {
hash_map::Entry::Occupied(entry) => entry.into_mut(),
hash_map::Entry::Vacant(entry) => entry.insert(HashMap::new()),
};
let account_storage = bundle_builder.get_state_storage_mut().entry(address).or_default();

@rkrasiuk
Copy link
Member

addressing my comments probably requires some rework of BundleBuilder API. would like to see it improved as well as state/revert tracking seems unnecessarily cumbersome there

@quentinv72
Copy link
Contributor Author

Thank you all for reviewing. Unfortunately, I don't think that I'll be able to address the comments on this PR as I have some other commitments at the moment. If anyone else wants to pick this up or close the PR, then please do so.

@emhane emhane changed the base branch from main to emhane/integrate-bundle-builder June 29, 2024 08:29
@emhane emhane merged commit 09e5066 into paradigmxyz:emhane/integrate-bundle-builder Jun 29, 2024
6 of 24 checks passed
mattsse added a commit that referenced this pull request Jun 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-db Related to the database C-debt Refactor of code section that is hard to understand or maintain D-good-first-issue Nice and easy! A great choice to get started
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Integrate BundleBuilder
5 participants