Skip to content

fix: move check in AcctDiff::decode and use filtered len in AcctDiff::encode#160

Merged
Fraser999 merged 3 commits into
mainfrom
fraser/bugfix
Jun 18, 2026
Merged

fix: move check in AcctDiff::decode and use filtered len in AcctDiff::encode#160
Fraser999 merged 3 commits into
mainfrom
fraser/bugfix

Conversation

@Fraser999

@Fraser999 Fraser999 commented Jun 16, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes two bugs in the BundleStateIndex journal codec (src/journal/coder.rs), both affecting AcctDiff round-tripping, and adds thorough boundary-case test coverage for every decode path. Bumps the patch version to 0.34.4.

Changes

  • AcctDiff::decode length check (fb86156): the check_len! for the minimum diff size was run after the InfoOutcome had already been consumed, so it demanded a second outcome's worth of trailing bytes. Any minimum-size diff - notably an empty-storage account near the end of a buffer - was wrongly rejected with an Overrun. The check now runs up front, before decoding the outcome.
  • AcctDiff::encode slot count (69e3e4e): encode wrote storage_diff.len() (the full map size) as the slot-count prefix but only serialized is_changed() entries. An unchanged slot made the on-wire count exceed the entries actually written, so decoding read a phantom slot - a clean overrun for a standalone diff, but silent corruption of the trailing new_contracts section inside a BundleStateIndex. encode now writes the count of changed slots, matching the write-loop and serialized_size.
  • Test coverage: added boundary tests covering truncation (every strict prefix of a valid encoding must overrun), the exact AcctDiff minimum-size boundary, invalid tags for every tagged type, the unchanged-storage error, EIP-7702 / empty bytecode, empty index, and Option/Header round-trips. Both bug fixes have dedicated regression tests verified to fail before the fix and pass after.

API Breakages

None. No public signatures changed. Both fixes are confined to existing trait-method bodies. The decode fix only widens what is accepted (previously-rejected valid minimum diffs now decode), and the encode fix only changes bytes for directly-constructed diffs that violate the "no unchanged slots" invariant - output for data produced via the normal From<&BundleAccount> path is byte-identical.


🤖 Generated with Claude Code

Copy link
Copy Markdown
Contributor Author

This stack of pull requests is managed by Graphite. Learn more about stacking.

@Fraser999 Fraser999 changed the title fix bug in AcctDiff::decode fix: move check in AcctDiff::decode and use filtered len in AcctDiff::encode Jun 16, 2026
@Fraser999 Fraser999 requested review from dylanlott and prestwich June 16, 2026 14:20
@Fraser999 Fraser999 merged commit 39d3695 into main Jun 18, 2026
8 checks passed
@Fraser999 Fraser999 deleted the fraser/bugfix branch June 18, 2026 08:41
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.

2 participants