Skip to content

Conversation

@meyer9
Copy link
Collaborator

@meyer9 meyer9 commented Oct 14, 2025

This PR separates storage and account cursors which makes sense because these two cursors may have very different seek/next implementations. In the case of in-memory, a single cursor impl can still handle both, but for MDBX, it makes sense to implement separate cursors.

Closes #236

Copilot AI review requested due to automatic review settings October 14, 2025 20:40
Copy link

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 separates the storage and account cursors into distinct APIs to allow for specialized implementations in different storage backends like MDBX while maintaining compatibility with in-memory implementations.

  • Replaces single trie_cursor method with separate account_trie_cursor and storage_trie_cursor methods
  • Updates trait definitions to include separate cursor types for storage and account tries
  • Migrates all test code to use the new cursor-specific methods

Reviewed Changes

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

Show a summary per file
File Description
crates/optimism/trie/src/api.rs Defines separate cursor types and methods for storage/account tries
crates/optimism/trie/src/in_memory.rs Implements new cursor methods for in-memory storage
crates/optimism/trie/src/db/store.rs Updates MDBX implementation with separate cursor methods
crates/optimism/trie/tests/in_memory.rs Updates all test calls to use specific cursor methods
crates/optimism/trie/src/backfill.rs Updates backfill operations to use new cursor methods

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

@emhane
Copy link
Member

emhane commented Oct 15, 2025

also pr description is missing which issue it references/closes

@meyer9
Copy link
Collaborator Author

meyer9 commented Oct 15, 2025

fix for this upstream: paradigmxyz#19043

Actually decided to just import optimism primitives here with serde-bincode-compat.

@wiz-b4c72f16a4
Copy link

wiz-b4c72f16a4 bot commented Oct 15, 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.

Comment on lines +22 to +24
# for ethereum types, `serde-bincode-compat` is added by `reth-storage-api`, however this does not work with `op` until
# `reth-storage-api` is updated to support `op`, so we add it here.
reth-optimism-primitives = { workspace = true, features = ["reth-codec", "serde-bincode-compat", "serde"] }
Copy link
Member

Choose a reason for hiding this comment

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

hopefully this is solved in #242 so that we don't have to mess with the manifests outside of the optimism directory for this op feature

@emhane emhane added this pull request to the merge queue Oct 15, 2025
Merged via the queue into unstable with commit 040a33b Oct 15, 2025
40 checks passed
@emhane emhane deleted the meyer9/split-storage-account-cursor branch October 15, 2025 17:47
github-merge-queue bot pushed a commit that referenced this pull request Oct 15, 2025
Based on #229 

Adds tests to ensure that storing TrieUpdates that include deletions
actually deletes the nodes at that block height, and that updates take
precedence over deletions (same as `write_trie_updates` in Reth).

Closes #238
emhane added a commit that referenced this pull request Oct 17, 2025
Ref #241

- Fixes comment from deps fix in
#229 (fix correct but comment
misleading)
- `serde-bincode-compat` is a feature which must be enabled when the
`bincode` dependency is used. Asides for dev-deps, this only happens in
`reth-stages`. `reth-exex` runs in `reth-stages`. In this wokrstream we
use the `TrieUpdate` in exex. `serde-bincode-compat` is already
implemented for `TrieUpdates` in `reth-trie-common`, this PR simply
makes that feature accessible via `reth-trie` and in turn
`reth-optimism-trie`, in order to enable it in `reth-optimism-exex`.
emhane pushed a commit that referenced this pull request Oct 20, 2025
This PR separates storage and account cursors which makes sense because
these two cursors may have very different seek/next implementations. In
the case of in-memory, a single cursor impl can still handle both, but
for MDBX, it makes sense to implement separate cursors.

Closes #236

---------

Co-authored-by: Arun Dhyani <[email protected]>
emhane pushed a commit that referenced this pull request Oct 20, 2025
Based on #229 

Adds tests to ensure that storing TrieUpdates that include deletions
actually deletes the nodes at that block height, and that updates take
precedence over deletions (same as `write_trie_updates` in Reth).

Closes #238
emhane added a commit that referenced this pull request Oct 20, 2025
Ref #241

- Fixes comment from deps fix in
#229 (fix correct but comment
misleading)
- `serde-bincode-compat` is a feature which must be enabled when the
`bincode` dependency is used. Asides for dev-deps, this only happens in
`reth-stages`. `reth-exex` runs in `reth-stages`. In this wokrstream we
use the `TrieUpdate` in exex. `serde-bincode-compat` is already
implemented for `TrieUpdates` in `reth-trie-common`, this PR simply
makes that feature accessible via `reth-trie` and in turn
`reth-optimism-trie`, in order to enable it in `reth-optimism-exex`.
meyer9 added a commit that referenced this pull request Oct 31, 2025
This PR separates storage and account cursors which makes sense because
these two cursors may have very different seek/next implementations. In
the case of in-memory, a single cursor impl can still handle both, but
for MDBX, it makes sense to implement separate cursors.

Closes #236

---------

Co-authored-by: Arun Dhyani <[email protected]>
meyer9 added a commit that referenced this pull request Oct 31, 2025
Based on #229 

Adds tests to ensure that storing TrieUpdates that include deletions
actually deletes the nodes at that block height, and that updates take
precedence over deletions (same as `write_trie_updates` in Reth).

Closes #238
meyer9 pushed a commit that referenced this pull request Oct 31, 2025
Ref #241

- Fixes comment from deps fix in
#229 (fix correct but comment
misleading)
- `serde-bincode-compat` is a feature which must be enabled when the
`bincode` dependency is used. Asides for dev-deps, this only happens in
`reth-stages`. `reth-exex` runs in `reth-stages`. In this wokrstream we
use the `TrieUpdate` in exex. `serde-bincode-compat` is already
implemented for `TrieUpdates` in `reth-trie-common`, this PR simply
makes that feature accessible via `reth-trie` and in turn
`reth-optimism-trie`, in order to enable it in `reth-optimism-exex`.
emhane pushed a commit that referenced this pull request Nov 11, 2025
This PR separates storage and account cursors which makes sense because
these two cursors may have very different seek/next implementations. In
the case of in-memory, a single cursor impl can still handle both, but
for MDBX, it makes sense to implement separate cursors.

Closes #236

---------

Co-authored-by: Arun Dhyani <[email protected]>
emhane pushed a commit that referenced this pull request Nov 11, 2025
Based on #229 

Adds tests to ensure that storing TrieUpdates that include deletions
actually deletes the nodes at that block height, and that updates take
precedence over deletions (same as `write_trie_updates` in Reth).

Closes #238
emhane added a commit that referenced this pull request Nov 11, 2025
Ref #241

- Fixes comment from deps fix in
#229 (fix correct but comment
misleading)
- `serde-bincode-compat` is a feature which must be enabled when the
`bincode` dependency is used. Asides for dev-deps, this only happens in
`reth-stages`. `reth-exex` runs in `reth-stages`. In this wokrstream we
use the `TrieUpdate` in exex. `serde-bincode-compat` is already
implemented for `TrieUpdates` in `reth-trie-common`, this PR simply
makes that feature accessible via `reth-trie` and in turn
`reth-optimism-trie`, in order to enable it in `reth-optimism-exex`.
meyer9 added a commit that referenced this pull request Nov 13, 2025
This PR separates storage and account cursors which makes sense because
these two cursors may have very different seek/next implementations. In
the case of in-memory, a single cursor impl can still handle both, but
for MDBX, it makes sense to implement separate cursors.

Closes #236

---------

Co-authored-by: Arun Dhyani <[email protected]>
meyer9 added a commit that referenced this pull request Nov 13, 2025
Based on #229 

Adds tests to ensure that storing TrieUpdates that include deletions
actually deletes the nodes at that block height, and that updates take
precedence over deletions (same as `write_trie_updates` in Reth).

Closes #238
meyer9 pushed a commit that referenced this pull request Nov 13, 2025
Ref #241

- Fixes comment from deps fix in
#229 (fix correct but comment
misleading)
- `serde-bincode-compat` is a feature which must be enabled when the
`bincode` dependency is used. Asides for dev-deps, this only happens in
`reth-stages`. `reth-exex` runs in `reth-stages`. In this wokrstream we
use the `TrieUpdate` in exex. `serde-bincode-compat` is already
implemented for `TrieUpdates` in `reth-trie-common`, this PR simply
makes that feature accessible via `reth-trie` and in turn
`reth-optimism-trie`, in order to enable it in `reth-optimism-exex`.
emhane pushed a commit that referenced this pull request Nov 18, 2025
This PR separates storage and account cursors which makes sense because
these two cursors may have very different seek/next implementations. In
the case of in-memory, a single cursor impl can still handle both, but
for MDBX, it makes sense to implement separate cursors.

Closes #236

---------

Co-authored-by: Arun Dhyani <[email protected]>
emhane pushed a commit that referenced this pull request Nov 18, 2025
Based on #229 

Adds tests to ensure that storing TrieUpdates that include deletions
actually deletes the nodes at that block height, and that updates take
precedence over deletions (same as `write_trie_updates` in Reth).

Closes #238
emhane added a commit that referenced this pull request Nov 18, 2025
Ref #241

- Fixes comment from deps fix in
#229 (fix correct but comment
misleading)
- `serde-bincode-compat` is a feature which must be enabled when the
`bincode` dependency is used. Asides for dev-deps, this only happens in
`reth-stages`. `reth-exex` runs in `reth-stages`. In this wokrstream we
use the `TrieUpdate` in exex. `serde-bincode-compat` is already
implemented for `TrieUpdates` in `reth-trie-common`, this PR simply
makes that feature accessible via `reth-trie` and in turn
`reth-optimism-trie`, in order to enable it in `reth-optimism-exex`.
emhane pushed a commit that referenced this pull request Nov 25, 2025
This PR separates storage and account cursors which makes sense because
these two cursors may have very different seek/next implementations. In
the case of in-memory, a single cursor impl can still handle both, but
for MDBX, it makes sense to implement separate cursors.

Closes #236

---------

Co-authored-by: Arun Dhyani <[email protected]>
emhane pushed a commit that referenced this pull request Nov 25, 2025
Based on #229 

Adds tests to ensure that storing TrieUpdates that include deletions
actually deletes the nodes at that block height, and that updates take
precedence over deletions (same as `write_trie_updates` in Reth).

Closes #238
emhane added a commit that referenced this pull request Nov 25, 2025
Ref #241

- Fixes comment from deps fix in
#229 (fix correct but comment
misleading)
- `serde-bincode-compat` is a feature which must be enabled when the
`bincode` dependency is used. Asides for dev-deps, this only happens in
`reth-stages`. `reth-exex` runs in `reth-stages`. In this wokrstream we
use the `TrieUpdate` in exex. `serde-bincode-compat` is already
implemented for `TrieUpdates` in `reth-trie-common`, this PR simply
makes that feature accessible via `reth-trie` and in turn
`reth-optimism-trie`, in order to enable it in `reth-optimism-exex`.
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.

Separate storage and account cursors for MDBX

5 participants