Skip to content

fix(hot): avoid panic when bytecode_hash is None during revert writes#44

Merged
rswanson merged 3 commits intomainfrom
fix/bytecode-hash-expect-panic
Apr 3, 2026
Merged

fix(hot): avoid panic when bytecode_hash is None during revert writes#44
rswanson merged 3 commits intomainfrom
fix/bytecode-hash-expect-panic

Conversation

@rswanson
Copy link
Copy Markdown
Member

@rswanson rswanson commented Apr 3, 2026

Summary

  • Fixes a panic in write_plain_revert_sorted and write_changeset_account where .expect("info has bytecode; hash must exist") crashes when an AccountInfo has code = Some(...) but code_hash == KECCAK256_EMPTY
  • Account::from(AccountInfo) correctly sets bytecode_hash = None for empty code hashes, but the downstream .expect() didn't account for this
  • Replaced both .expect() calls with if let Some(code_hash) — empty-code bytecode doesn't need to be stored anyway

Context

Observed in production on signet-sidecar running signet-hot 0.6.8:

thread 'main' panicked at signet-hot-0.6.8/src/db/inconsistent.rs:243:55

Test plan

  • cargo fmt --check passes
  • cargo clippy -p signet-hot passes
  • cargo test -p signet-hot — all 107 tests pass

🤖 Generated with Claude Code

Account::from(AccountInfo) sets bytecode_hash to None when code_hash
equals KECCAK256_EMPTY. However, the AccountInfo can still have
code = Some(...) in this case. The .expect() on bytecode_hash then
panics because it assumes code presence implies a non-empty hash.

Replace the .expect() with an if-let that skips storing bytecode when
the hash is None (i.e. empty code), fixing the panic in both
write_plain_revert_sorted and write_changeset_account.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@prestwich
Copy link
Copy Markdown
Member

use a an option combinator on the initial binding instead of nesting if let bindings

rswanson and others added 2 commits April 3, 2026 12:40
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@rswanson rswanson requested a review from prestwich April 3, 2026 16:41
@rswanson rswanson enabled auto-merge (squash) April 3, 2026 16:41
@rswanson rswanson merged commit 97c46ef into main Apr 3, 2026
6 checks passed
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