fix: use hashed_keys for extracting storage logs from db#4606
Open
sanekmelnikov wants to merge 3 commits intomainfrom
Open
fix: use hashed_keys for extracting storage logs from db#4606sanekmelnikov wants to merge 3 commits intomainfrom
sanekmelnikov wants to merge 3 commits intomainfrom
Conversation
perekopskiy
reviewed
Jan 12, 2026
Comment on lines
+829
to
+832
| if let Some(&(initial_write_batch_for_key, leaf_index)) = | ||
| l1_batches_for_initial_writes.get(&hashed_key) | ||
| { | ||
| if initial_write_batch_for_key <= l1_batch_number { |
Contributor
There was a problem hiding this comment.
nit: I'd assert! that these 2 ifs are entered for each protective read
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What ❔
When recovering lost storage logs using compressed state diffs from L1, only the
hashed_keyis available. As a result, the backfilled postgres data instorage_logswon't have theaddressandkeyfields.The current logic causes tree recovery to fail here, as the query expects these fields to be present.
(Note that
tree_writesfield inl1_batchesisn't available in this case as well - it can't be recovered because it is decoded usingaddressandkey)This PR replaces
get_touched_slots_for_executed_l1_batchwith get_touched_slots_for_l1_batch to usehashed_keyinstead.To ensure the order of writes is preserved, we sort values by
leaf_index.Why ❔
To enable L1 recovery
Is this a breaking change?
Checklist
zkstack dev fmtandzkstack dev lint.