Skip to content

Commit

Permalink
feat(pruning): Record L1 batch root hash in pruning logs (#3266)
Browse files Browse the repository at this point in the history
## What ❔

Records root hashes of the last hard-pruned L1 batch in pruning logs.

## Why ❔

This allows to check tree integrity after recovery after pruning.

## Checklist

- [x] PR title corresponds to the body of PR (we generate changelog
entries from PRs).
- [x] Tests for the changes have been added / updated.
- [x] Documentation comments have been added / updated.
- [x] Code has been formatted via `zkstack dev fmt` and `zkstack dev
lint`.
  • Loading branch information
slowli authored Nov 27, 2024
1 parent 533bfe6 commit 7b6e590
Show file tree
Hide file tree
Showing 19 changed files with 473 additions and 323 deletions.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
ALTER TABLE pruning_log
DROP COLUMN pruned_l1_batch_root_hash;
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
-- nullable for backward compatibility
ALTER TABLE pruning_log
ADD COLUMN pruned_l1_batch_root_hash BYTEA DEFAULT NULL;
4 changes: 2 additions & 2 deletions core/lib/dal/src/consensus_dal/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -301,10 +301,10 @@ impl ConsensusDal<'_, '_> {
.get_pruning_info()
.await
.context("get_pruning_info()")?;
Ok(match info.last_soft_pruned_l2_block {
Ok(match info.last_soft_pruned {
// It is guaranteed that pruning info values are set for storage recovered from
// snapshot, even if pruning was not enabled.
Some(last_pruned) => validator::BlockNumber(last_pruned.0.into()) + 1,
Some(last_pruned) => validator::BlockNumber(last_pruned.l2_block.0.into()) + 1,
// No snapshot and no pruning:
None => validator::BlockNumber(0),
})
Expand Down
Loading

0 comments on commit 7b6e590

Please sign in to comment.