Skip to content

Conversation

@WilliamNwoke
Copy link
Contributor

Resolves #19077

Replaced the intermediate collection with a streaming iterator (WipedStorageIter) that processes wiped entries directly from the database cursor.

@WilliamNwoke
Copy link
Contributor Author

Please review @yongkangc @mattsse

Copy link
Member

@yongkangc yongkangc left a comment

Choose a reason for hiding this comment

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

Think we could simplify this without the abstraction

ref:

fn write_storage_trie_changesets<'a>(
cc @mediocregopher would be great to get ur thoughts as well :)

Comment on lines 12 to 26
pub struct WipedStorageIter<'a, C> {
cursor: &'a mut C,
address: alloy_primitives::Address,
is_first: bool,
has_more: bool,
}

impl<'a, C> WipedStorageIter<'a, C>
where
C: DbCursorRO<PlainStorageState> + DbDupCursorRO<PlainStorageState>,
{
/// Create a new iterator for wiped storage entries at the given address.
pub fn new(
cursor: &'a mut C,
address: alloy_primitives::Address,
Copy link
Member

Choose a reason for hiding this comment

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

could we do it in a simpler way where we don't need this abstraction?

this abstraction seems to make it more complicated

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Simplified and reverted!

@github-project-automation github-project-automation bot moved this from Backlog to In Progress in Reth Tracker Oct 20, 2025
@yongkangc yongkangc requested a review from Copilot October 21, 2025 00:49
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR optimizes the collection of wiped storage entries by replacing an intermediate Vec allocation with a streaming iterator that processes entries directly from the database cursor.

Key Changes:

  • Introduces WipedStorageIter for lazy iteration over wiped storage entries
  • Refactors storage revert writing to use the new iterator instead of collecting into a Vec

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.

File Description
crates/storage/provider/src/changesets_utils/wiped_storage.rs New file implementing WipedStorageIter for streaming wiped storage entries
crates/storage/provider/src/changesets_utils/mod.rs Exports the new WipedStorageIter type
crates/storage/provider/src/providers/database/provider.rs Replaces Vec collection with WipedStorageIter in storage revert writing

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: In Progress

Development

Successfully merging this pull request may close these issues.

perf(storage): optimize wiped storage entry collection to avoid unnecessary Vec allocation

3 participants