Skip to content

Comments

feat: implement in-memory storage backend#183

Merged
dhyaniarun1993 merged 21 commits intounstablefrom
meyer9/176-in-memory-storage-backend
Oct 12, 2025
Merged

feat: implement in-memory storage backend#183
dhyaniarun1993 merged 21 commits intounstablefrom
meyer9/176-in-memory-storage-backend

Conversation

@meyer9
Copy link
Collaborator

@meyer9 meyer9 commented Sep 26, 2025

Ref #176

This PR adds an in-memory storage backend and tests that work with any storage backend. We can easily add more test cases to the file to test against a future SQLite backend.

@meyer9 meyer9 force-pushed the meyer9/176-in-memory-storage-backend branch from d7fe4bc to 56afdf7 Compare September 26, 2025 17:38
@meyer9 meyer9 added the W-historical-proofs Workstream: historical-proofs label Sep 26, 2025
@meyer9 meyer9 linked an issue Sep 26, 2025 that may be closed by this pull request
@meyer9 meyer9 force-pushed the meyer9/176-in-memory-storage-backend branch 2 times, most recently from 955e4f1 to 7731223 Compare September 26, 2025 17:47
@meyer9 meyer9 marked this pull request as ready for review September 26, 2025 17:48
@meyer9 meyer9 marked this pull request as draft September 26, 2025 17:48
@meyer9 meyer9 force-pushed the meyer9/166-finalize-storage-interface branch from 3e311c7 to 5ef8999 Compare September 26, 2025 17:48
@meyer9 meyer9 force-pushed the meyer9/176-in-memory-storage-backend branch from 7731223 to a737cf2 Compare September 26, 2025 17:49
@meyer9 meyer9 marked this pull request as ready for review September 27, 2025 05:01
@meyer9 meyer9 force-pushed the meyer9/166-finalize-storage-interface branch from 5ef8999 to 84c813c Compare September 29, 2025 16:13
@meyer9 meyer9 force-pushed the meyer9/176-in-memory-storage-backend branch from a737cf2 to 1eef699 Compare September 29, 2025 16:13
@meyer9 meyer9 force-pushed the meyer9/166-finalize-storage-interface branch from 84c813c to 9ca3987 Compare October 8, 2025 15:45
@meyer9 meyer9 force-pushed the meyer9/176-in-memory-storage-backend branch from 1eef699 to 1c7a7a3 Compare October 8, 2025 15:49
@wiz-b4c72f16a4
Copy link

wiz-b4c72f16a4 bot commented Oct 8, 2025

Wiz Scan Summary

Scanner Findings
Vulnerability Finding Vulnerabilities -
Data Finding Sensitive Data -
Total -

View scan details in Wiz

To detect these findings earlier in the dev lifecycle, try using Wiz Code VS Code Extension.

@meyer9 meyer9 force-pushed the meyer9/176-in-memory-storage-backend branch from 1c7a7a3 to f336fc3 Compare October 8, 2025 17:14
let mut collected_entries: Vec<(Nibbles, BranchNodeCompact)> =
if let Some(addr) = hashed_address {
// Storage trie cursor
for ((block, address, path), branch) in &storage.storage_branches {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Shouldn't we merge the changes from trie_updates for all blocks up to the specified max_block_number?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I think this should merge them all already. The BTreeMap is sorted by block number ASC, so when we collect all the entries, it will choose the latest block <= max_block_number.

Copy link
Collaborator

@dhyaniarun1993 dhyaniarun1993 Oct 9, 2025

Choose a reason for hiding this comment

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

If I understand correctly, we are storing live updates only in the trie_updates BTreeMap. We aren't saving data to storage_branches BTreeMap in the live syncing.

Hence live updates changes won't be visible to the cursor since cursor is only reading storage_branches BTreeMap

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

ah I see, that should be saved to *_branches and hashed_*. The trie_updates and post_states are just indexes from block number to the slots/trie nodes changed for pruning/reorgs.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

fixed: fa65493

Copy link
Collaborator

Choose a reason for hiding this comment

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

Thanks. Will review it.

.collect()
} else {
// Account trie cursor
for ((block, path), branch) in &storage.account_branches {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Same here

@emhane
Copy link

emhane commented Oct 9, 2025

does this pr reference any issue?

meyer9 added a commit that referenced this pull request Oct 31, 2025
Based on #183

This PR adds a backfill job that accepts a DB transaction and copies the
current state to the database. The transaction ensures we see a
consistent view of the database at the current block, even if the node
is syncing. This requires `--db.read-transaction-timeout 0`.

This currently doesn't handle interrupting the job because the state may
update while syncing and may read a different version of the database
upon restart.

---------

Co-authored-by: Arun Dhyani <dhyaniarun7@gmail.com>
Co-authored-by: Emilia Hane <elsaemiliaevahane@gmail.com>
emhane added a commit that referenced this pull request Nov 11, 2025
Ref #176 

This PR adds an in-memory storage backend and tests that work with any
storage backend. We can easily add more test cases to the file to test
against a future SQLite backend.

---------

Co-authored-by: Arun Dhyani <dhyaniarun7@gmail.com>
Co-authored-by: Emilia Hane <elsaemiliaevahane@gmail.com>
emhane added a commit that referenced this pull request Nov 11, 2025
Based on #183

This PR adds a backfill job that accepts a DB transaction and copies the
current state to the database. The transaction ensures we see a
consistent view of the database at the current block, even if the node
is syncing. This requires `--db.read-transaction-timeout 0`.

This currently doesn't handle interrupting the job because the state may
update while syncing and may read a different version of the database
upon restart.

---------

Co-authored-by: Arun Dhyani <dhyaniarun7@gmail.com>
Co-authored-by: Emilia Hane <elsaemiliaevahane@gmail.com>
meyer9 added a commit that referenced this pull request Nov 13, 2025
Ref #176 

This PR adds an in-memory storage backend and tests that work with any
storage backend. We can easily add more test cases to the file to test
against a future SQLite backend.

---------

Co-authored-by: Arun Dhyani <dhyaniarun7@gmail.com>
Co-authored-by: Emilia Hane <elsaemiliaevahane@gmail.com>
meyer9 added a commit that referenced this pull request Nov 13, 2025
Based on #183

This PR adds a backfill job that accepts a DB transaction and copies the
current state to the database. The transaction ensures we see a
consistent view of the database at the current block, even if the node
is syncing. This requires `--db.read-transaction-timeout 0`.

This currently doesn't handle interrupting the job because the state may
update while syncing and may read a different version of the database
upon restart.

---------

Co-authored-by: Arun Dhyani <dhyaniarun7@gmail.com>
Co-authored-by: Emilia Hane <elsaemiliaevahane@gmail.com>
emhane added a commit that referenced this pull request Nov 18, 2025
Ref #176 

This PR adds an in-memory storage backend and tests that work with any
storage backend. We can easily add more test cases to the file to test
against a future SQLite backend.

---------

Co-authored-by: Arun Dhyani <dhyaniarun7@gmail.com>
Co-authored-by: Emilia Hane <elsaemiliaevahane@gmail.com>
emhane added a commit that referenced this pull request Nov 18, 2025
Based on #183

This PR adds a backfill job that accepts a DB transaction and copies the
current state to the database. The transaction ensures we see a
consistent view of the database at the current block, even if the node
is syncing. This requires `--db.read-transaction-timeout 0`.

This currently doesn't handle interrupting the job because the state may
update while syncing and may read a different version of the database
upon restart.

---------

Co-authored-by: Arun Dhyani <dhyaniarun7@gmail.com>
Co-authored-by: Emilia Hane <elsaemiliaevahane@gmail.com>
emhane added a commit that referenced this pull request Nov 25, 2025
Ref #176 

This PR adds an in-memory storage backend and tests that work with any
storage backend. We can easily add more test cases to the file to test
against a future SQLite backend.

---------

Co-authored-by: Arun Dhyani <dhyaniarun7@gmail.com>
Co-authored-by: Emilia Hane <elsaemiliaevahane@gmail.com>
emhane added a commit that referenced this pull request Nov 25, 2025
Based on #183

This PR adds a backfill job that accepts a DB transaction and copies the
current state to the database. The transaction ensures we see a
consistent view of the database at the current block, even if the node
is syncing. This requires `--db.read-transaction-timeout 0`.

This currently doesn't handle interrupting the job because the state may
update while syncing and may read a different version of the database
upon restart.

---------

Co-authored-by: Arun Dhyani <dhyaniarun7@gmail.com>
Co-authored-by: Emilia Hane <elsaemiliaevahane@gmail.com>
emhane added a commit that referenced this pull request Dec 8, 2025
Ref #176 

This PR adds an in-memory storage backend and tests that work with any
storage backend. We can easily add more test cases to the file to test
against a future SQLite backend.

---------

Co-authored-by: Arun Dhyani <dhyaniarun7@gmail.com>
Co-authored-by: Emilia Hane <elsaemiliaevahane@gmail.com>
emhane added a commit that referenced this pull request Dec 8, 2025
Based on #183

This PR adds a backfill job that accepts a DB transaction and copies the
current state to the database. The transaction ensures we see a
consistent view of the database at the current block, even if the node
is syncing. This requires `--db.read-transaction-timeout 0`.

This currently doesn't handle interrupting the job because the state may
update while syncing and may read a different version of the database
upon restart.

---------

Co-authored-by: Arun Dhyani <dhyaniarun7@gmail.com>
Co-authored-by: Emilia Hane <elsaemiliaevahane@gmail.com>
emhane added a commit that referenced this pull request Dec 10, 2025
Ref #176 

This PR adds an in-memory storage backend and tests that work with any
storage backend. We can easily add more test cases to the file to test
against a future SQLite backend.

---------

Co-authored-by: Arun Dhyani <dhyaniarun7@gmail.com>
Co-authored-by: Emilia Hane <elsaemiliaevahane@gmail.com>
emhane added a commit that referenced this pull request Dec 10, 2025
Based on #183

This PR adds a backfill job that accepts a DB transaction and copies the
current state to the database. The transaction ensures we see a
consistent view of the database at the current block, even if the node
is syncing. This requires `--db.read-transaction-timeout 0`.

This currently doesn't handle interrupting the job because the state may
update while syncing and may read a different version of the database
upon restart.

---------

Co-authored-by: Arun Dhyani <dhyaniarun7@gmail.com>
Co-authored-by: Emilia Hane <elsaemiliaevahane@gmail.com>
emhane added a commit that referenced this pull request Dec 18, 2025
Ref #176 

This PR adds an in-memory storage backend and tests that work with any
storage backend. We can easily add more test cases to the file to test
against a future SQLite backend.

---------

Co-authored-by: Arun Dhyani <dhyaniarun7@gmail.com>
Co-authored-by: Emilia Hane <elsaemiliaevahane@gmail.com>
emhane added a commit that referenced this pull request Dec 18, 2025
Based on #183

This PR adds a backfill job that accepts a DB transaction and copies the
current state to the database. The transaction ensures we see a
consistent view of the database at the current block, even if the node
is syncing. This requires `--db.read-transaction-timeout 0`.

This currently doesn't handle interrupting the job because the state may
update while syncing and may read a different version of the database
upon restart.

---------

Co-authored-by: Arun Dhyani <dhyaniarun7@gmail.com>
Co-authored-by: Emilia Hane <elsaemiliaevahane@gmail.com>
emhane added a commit that referenced this pull request Dec 18, 2025
Ref #176 

This PR adds an in-memory storage backend and tests that work with any
storage backend. We can easily add more test cases to the file to test
against a future SQLite backend.

---------

Co-authored-by: Arun Dhyani <dhyaniarun7@gmail.com>
Co-authored-by: Emilia Hane <elsaemiliaevahane@gmail.com>
emhane added a commit that referenced this pull request Dec 18, 2025
Based on #183

This PR adds a backfill job that accepts a DB transaction and copies the
current state to the database. The transaction ensures we see a
consistent view of the database at the current block, even if the node
is syncing. This requires `--db.read-transaction-timeout 0`.

This currently doesn't handle interrupting the job because the state may
update while syncing and may read a different version of the database
upon restart.

---------

Co-authored-by: Arun Dhyani <dhyaniarun7@gmail.com>
Co-authored-by: Emilia Hane <elsaemiliaevahane@gmail.com>
emhane added a commit that referenced this pull request Jan 5, 2026
Ref #176 

This PR adds an in-memory storage backend and tests that work with any
storage backend. We can easily add more test cases to the file to test
against a future SQLite backend.

---------

Co-authored-by: Arun Dhyani <dhyaniarun7@gmail.com>
Co-authored-by: Emilia Hane <elsaemiliaevahane@gmail.com>
emhane added a commit that referenced this pull request Jan 5, 2026
Based on #183

This PR adds a backfill job that accepts a DB transaction and copies the
current state to the database. The transaction ensures we see a
consistent view of the database at the current block, even if the node
is syncing. This requires `--db.read-transaction-timeout 0`.

This currently doesn't handle interrupting the job because the state may
update while syncing and may read a different version of the database
upon restart.

---------

Co-authored-by: Arun Dhyani <dhyaniarun7@gmail.com>
Co-authored-by: Emilia Hane <elsaemiliaevahane@gmail.com>
emhane added a commit that referenced this pull request Jan 13, 2026
Ref #176 

This PR adds an in-memory storage backend and tests that work with any
storage backend. We can easily add more test cases to the file to test
against a future SQLite backend.

---------

Co-authored-by: Arun Dhyani <dhyaniarun7@gmail.com>
Co-authored-by: Emilia Hane <elsaemiliaevahane@gmail.com>
emhane added a commit that referenced this pull request Jan 13, 2026
Based on #183

This PR adds a backfill job that accepts a DB transaction and copies the
current state to the database. The transaction ensures we see a
consistent view of the database at the current block, even if the node
is syncing. This requires `--db.read-transaction-timeout 0`.

This currently doesn't handle interrupting the job because the state may
update while syncing and may read a different version of the database
upon restart.

---------

Co-authored-by: Arun Dhyani <dhyaniarun7@gmail.com>
Co-authored-by: Emilia Hane <elsaemiliaevahane@gmail.com>
emhane added a commit that referenced this pull request Jan 15, 2026
Ref #176 

This PR adds an in-memory storage backend and tests that work with any
storage backend. We can easily add more test cases to the file to test
against a future SQLite backend.

---------

Co-authored-by: Arun Dhyani <dhyaniarun7@gmail.com>
Co-authored-by: Emilia Hane <elsaemiliaevahane@gmail.com>
emhane added a commit that referenced this pull request Jan 15, 2026
Based on #183

This PR adds a backfill job that accepts a DB transaction and copies the
current state to the database. The transaction ensures we see a
consistent view of the database at the current block, even if the node
is syncing. This requires `--db.read-transaction-timeout 0`.

This currently doesn't handle interrupting the job because the state may
update while syncing and may read a different version of the database
upon restart.

---------

Co-authored-by: Arun Dhyani <dhyaniarun7@gmail.com>
Co-authored-by: Emilia Hane <elsaemiliaevahane@gmail.com>
emhane added a commit that referenced this pull request Jan 20, 2026
Ref #176 

This PR adds an in-memory storage backend and tests that work with any
storage backend. We can easily add more test cases to the file to test
against a future SQLite backend.

---------

Co-authored-by: Arun Dhyani <dhyaniarun7@gmail.com>
Co-authored-by: Emilia Hane <elsaemiliaevahane@gmail.com>
emhane added a commit that referenced this pull request Jan 20, 2026
Based on #183

This PR adds a backfill job that accepts a DB transaction and copies the
current state to the database. The transaction ensures we see a
consistent view of the database at the current block, even if the node
is syncing. This requires `--db.read-transaction-timeout 0`.

This currently doesn't handle interrupting the job because the state may
update while syncing and may read a different version of the database
upon restart.

---------

Co-authored-by: Arun Dhyani <dhyaniarun7@gmail.com>
Co-authored-by: Emilia Hane <elsaemiliaevahane@gmail.com>
emhane added a commit that referenced this pull request Jan 26, 2026
Ref #176 

This PR adds an in-memory storage backend and tests that work with any
storage backend. We can easily add more test cases to the file to test
against a future SQLite backend.

---------

Co-authored-by: Arun Dhyani <dhyaniarun7@gmail.com>
Co-authored-by: Emilia Hane <elsaemiliaevahane@gmail.com>
emhane added a commit that referenced this pull request Jan 26, 2026
Based on #183

This PR adds a backfill job that accepts a DB transaction and copies the
current state to the database. The transaction ensures we see a
consistent view of the database at the current block, even if the node
is syncing. This requires `--db.read-transaction-timeout 0`.

This currently doesn't handle interrupting the job because the state may
update while syncing and may read a different version of the database
upon restart.

---------

Co-authored-by: Arun Dhyani <dhyaniarun7@gmail.com>
Co-authored-by: Emilia Hane <elsaemiliaevahane@gmail.com>
emhane added a commit that referenced this pull request Jan 29, 2026
Ref #176 

This PR adds an in-memory storage backend and tests that work with any
storage backend. We can easily add more test cases to the file to test
against a future SQLite backend.

---------

Co-authored-by: Arun Dhyani <dhyaniarun7@gmail.com>
Co-authored-by: Emilia Hane <elsaemiliaevahane@gmail.com>
emhane added a commit that referenced this pull request Jan 29, 2026
Based on #183

This PR adds a backfill job that accepts a DB transaction and copies the
current state to the database. The transaction ensures we see a
consistent view of the database at the current block, even if the node
is syncing. This requires `--db.read-transaction-timeout 0`.

This currently doesn't handle interrupting the job because the state may
update while syncing and may read a different version of the database
upon restart.

---------

Co-authored-by: Arun Dhyani <dhyaniarun7@gmail.com>
Co-authored-by: Emilia Hane <elsaemiliaevahane@gmail.com>
emhane added a commit to ethereum-optimism/optimism that referenced this pull request Feb 2, 2026
Based on op-rs/op-reth#183

This PR adds a backfill job that accepts a DB transaction and copies the
current state to the database. The transaction ensures we see a
consistent view of the database at the current block, even if the node
is syncing. This requires `--db.read-transaction-timeout 0`.

This currently doesn't handle interrupting the job because the state may
update while syncing and may read a different version of the database
upon restart.

---------

Co-authored-by: Arun Dhyani <dhyaniarun7@gmail.com>
Co-authored-by: Emilia Hane <elsaemiliaevahane@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-db Area: database K-feature Kind: feature W-historical-proofs Workstream: historical-proofs

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Create in-memory storage backend for testing

3 participants