blockifier: record pre-migration compiled class hash as initial read#14612
blockifier: record pre-migration compiled class hash as initial read#14612yoavGrs wants to merge 1 commit into
Conversation
This stack of pull requests is managed by Graphite. Learn more about stacking. |
PR SummaryMedium Risk Overview That restores correct Adds a focused unit test that checks the post-migration hash, the diff, and (with Reviewed by Cursor Bugbot for commit cdbf3ab. Bugbot is set up for automated code reviews on this repo. Configure here. |
|
Artifacts upload workflows: |
When migrating a class's compiled class hash, `set_compiled_class_hash_migration` wrote the post-migration (v2) value into the write cache without first recording the pre-block (v1) value as an initial read. Since `get_compiled_class_hash` resolves the write cache before the initial reads, the v2 write shadowed the pre-block value, so it was never captured. This made `to_state_diff` panic in `strict_subtract_mappings` (the migrated write had no matching initial read to subtract against) and left the OS without the pre-block class-trie leaf needed to replay the block. Force-read the pre-migration compiled class hash into the initial reads before applying the migration write, and add a unit test covering the fix. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
94279be to
cdbf3ab
Compare
Yoni-Starkware
left a comment
There was a problem hiding this comment.
@Yoni-Starkware made 1 comment.
Reviewable status: 0 of 2 files reviewed, 1 unresolved discussion (waiting on yoavGrs).
crates/blockifier/src/state/compiled_class_hash_migration.rs line 36 at r1 (raw file):
// Capture the pre-block (v1) hash as an initial read before the v2 write shadows it. self.get_compiled_class_hash(*class_hash)?;
Every migrated class should have triggered a call to get_compiled_class_hash before this point. See here:
sequencer/crates/blockifier/src/utils.rs
Line 126 in a5cbd53
Also, it's clear from the function API - it gets the previous compiled class hash, so not sure why this read is needed
Code quote:
// Capture the pre-block (v1) hash as an initial read before the v2 write shadows it.
self.get_compiled_class_hash(*class_hash)?;
When migrating a class's compiled class hash,
set_compiled_class_hash_migrationwrote the post-migration (v2) value into the write cache without first recording
the pre-block (v1) value as an initial read. Since
get_compiled_class_hashresolves the write cache before the initial reads, the v2 write shadowed the
pre-block value, so it was never captured. This made
to_state_diffpanic instrict_subtract_mappings(the migrated write had no matching initial read tosubtract against) and left the OS without the pre-block class-trie leaf needed to
replay the block.
Force-read the pre-migration compiled class hash into the initial reads before
applying the migration write, and add a unit test covering the fix.
Co-Authored-By: Claude Opus 4.8 (1M context) noreply@anthropic.com