You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat(en): Resume incomplete snapshot in snapshot creator in more cases (#2886)
## What ❔
Resumes an incomplete snapshot in the snapshot creator if the creator
config doesn't specify an L1 batch.
## Why ❔
This effectively reverts the relevant changes from
#2256. It makes the
snapshot creator resilient by default without additional setup, at the
cost of parallel creator jobs working incorrectly (unless they all
specify L1 batches).
## 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] Code has been formatted via `zk fmt` and `zk lint`.
"Requested a snapshot for L1 batch #{l1_batch_number} that doesn't exist in Postgres (latest L1 batch: {sealed_l1_batch_number})"
298
300
);
299
-
l1_batch_number
301
+
302
+
let existing_snapshot = master_conn
303
+
.snapshots_dal()
304
+
.get_snapshot_metadata(l1_batch_number)
305
+
.await?;
306
+
(l1_batch_number, existing_snapshot)
300
307
}else{
301
308
// We subtract 1 so that after restore, EN node has at least one L1 batch to fetch.
302
309
anyhow::ensure!(
303
310
sealed_l1_batch_number != L1BatchNumber(0),
304
311
"Cannot create snapshot when only the genesis L1 batch is present in Postgres"
305
312
);
306
-
sealed_l1_batch_number - 1
307
-
};
313
+
let requested_l1_batch_number = sealed_l1_batch_number - 1;
308
314
309
-
let existing_snapshot = master_conn
310
-
.snapshots_dal()
311
-
.get_snapshot_metadata(requested_l1_batch_number)
312
-
.await?;
315
+
// Continue creating a pending snapshot if it exists, even if it doesn't correspond to the latest L1 batch.
316
+
// OTOH, a completed snapshot does not matter, unless it corresponds to `requested_l1_batch_number` (in which case it doesn't need to be created again).
0 commit comments