Skip to content

fix(provider): skip storage changeset writes when routed to static files#21468

Merged
yongkangc merged 1 commit intomainfrom
fix/changeset-multiple-append
Jan 27, 2026
Merged

fix(provider): skip storage changeset writes when routed to static files#21468
yongkangc merged 1 commit intomainfrom
fix/changeset-multiple-append

Conversation

@yongkangc
Copy link
Member

@yongkangc yongkangc commented Jan 27, 2026

Summary

Fixed a bug where storage changesets were written twice when static file storage changesets are enabled, causing UnexpectedStaticFileBlockNumber errors.

Problem

PR #20896 added static file routing for storage changesets but forgot to add write_storage_changesets to StateWriteConfig. This caused storage changesets to be written twice:

  1. First write: via write_blocks_data → static file manager
  2. Second write: via write_statewrite_state_revertsEitherWriter::new_storage_changesets (also routed to static files)

The second write fails because block N was already written:

ProviderError(UnexpectedStaticFileBlockNumber(StorageChangeSets, 1, 2))

This manifests with persistence_threshold(0) and static file changesets enabled.

Solution

  1. Add write_storage_changesets field to StateWriteConfig
  2. Pass !sf_ctx.write_storage_changesets to the config in save_blocks
  3. Guard storage changeset writes in write_state_reverts with the config

This matches the existing pattern for write_receipts and write_account_changesets.

Closes #21467

@github-project-automation github-project-automation bot moved this to Backlog in Reth Tracker Jan 27, 2026
@yongkangc yongkangc added the C-bug An unexpected or incorrect behavior label Jan 27, 2026
@yongkangc yongkangc marked this pull request as ready for review January 27, 2026 08:02
@yongkangc yongkangc changed the title fix(provider): aggregate changesets before appending to static file fix(provider): skip storage changeset writes when routed to static files Jan 27, 2026
@yongkangc yongkangc self-assigned this Jan 27, 2026
@yongkangc yongkangc added the A-static-files Related to static files label Jan 27, 2026
@yongkangc yongkangc force-pushed the fix/changeset-multiple-append branch from 343ef3c to 2092bf7 Compare January 27, 2026 08:09
@yongkangc yongkangc force-pushed the fix/changeset-multiple-append branch from 2092bf7 to 44e7b81 Compare January 27, 2026 10:11
@yongkangc yongkangc force-pushed the fix/changeset-multiple-append branch from 44e7b81 to 00abc79 Compare January 27, 2026 10:15
@yongkangc yongkangc requested a review from joshieDo January 27, 2026 10:16
@yongkangc yongkangc force-pushed the fix/changeset-multiple-append branch from 00abc79 to 95407af Compare January 27, 2026 10:17
Comment on lines +48 to +67
rocksdb:
name: e2e-rocksdb
runs-on: depot-ubuntu-latest-4
env:
RUST_BACKTRACE: 1
timeout-minutes: 60
steps:
- uses: actions/checkout@v6
- uses: dtolnay/rust-toolchain@stable
- uses: mozilla-actions/sccache-action@v0.0.9
- uses: taiki-e/install-action@nextest
- uses: Swatinem/rust-cache@v2
with:
cache-on-failure: true
- name: Run RocksDB e2e tests
run: |
cargo nextest run \
--locked --features "edge" \
-p reth-e2e-test-utils \
-E 'binary(rocksdb)'
Copy link
Member Author

Choose a reason for hiding this comment

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

not 100% sure if we want this to run all the time, but makes sense to me

@github-project-automation github-project-automation bot moved this from Backlog to In Progress in Reth Tracker Jan 27, 2026
… to static files

When static file storage changesets are enabled, storage changesets were being written twice:
1. Once via write_blocks_data (static file manager)
2. Again via write_state_reverts (database provider via EitherWriter)

This caused 'Multiple consecutive append_many calls for same block' errors when
persistence_threshold(0) is used in E2E tests, which triggers immediate persistence.

The fix adds write_storage_changesets field to StateWriteConfig and guards the
storage changeset writes in write_state_reverts, analogous to how account changesets
and receipts already work.

Additionally, this PR fixes an unrelated bug in the static file manager where per-block
iteration over changesets caused multiple appends per block. The fix aggregates all
changesets for a block before appending.

Fixes the RocksDB E2E tests which use persistence_threshold(0).

Amp-Thread-ID: https://ampcode.com/threads/T-019bfe7a-b24a-718e-b938-b941969c8c1a
@yongkangc yongkangc force-pushed the fix/changeset-multiple-append branch from 95407af to 9077463 Compare January 27, 2026 10:24
@yongkangc yongkangc enabled auto-merge January 27, 2026 10:27
@yongkangc yongkangc added this pull request to the merge queue Jan 27, 2026
Merged via the queue into main with commit 1e73493 Jan 27, 2026
48 checks passed
@yongkangc yongkangc deleted the fix/changeset-multiple-append branch January 27, 2026 10:43
@github-project-automation github-project-automation bot moved this from In Progress to Done in Reth Tracker Jan 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-static-files Related to static files C-bug An unexpected or incorrect behavior

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

fix(static-files): write_storage_changesets calls append_storage_changeset multiple times per block

2 participants