Skip to content

Commit b154b6f

Browse files
authored
[tidehunter] insert genesis startup check (#24368)
## Description Adjust the insert-genesis check on startup to check the permanent table `certified_checkpoints`. The previous implementation was checking the `checkpoint_by_digest` table, whose values can be pruned by the compaction filter, resulting in resetting the highest-synced watermark and causing a panic in state sync on startup --- ## Release notes Check each box that your changes affect. If none of the boxes relate to your changes, release notes aren't required. For each box you select, include information after the relevant heading that describes the impact of your changes that a user might notice and any actions they must take to implement updates. - [ ] Protocol: - [ ] Nodes (Validators and Full nodes): - [ ] gRPC: - [ ] JSON-RPC: - [ ] GraphQL: - [ ] CLI: - [ ] Rust SDK: - [ ] Indexing Framework:
1 parent dc58dfb commit b154b6f

File tree

1 file changed

+19
-18
lines changed
  • crates/sui-core/src/checkpoints

1 file changed

+19
-18
lines changed

crates/sui-core/src/checkpoints/mod.rs

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -353,25 +353,26 @@ impl CheckpointStore {
353353
);
354354

355355
// Only insert the genesis checkpoint if the DB is empty and doesn't have it already
356-
if self
357-
.get_checkpoint_by_digest(checkpoint.digest())
358-
.unwrap()
359-
.is_none()
360-
{
361-
if epoch_store.epoch() == checkpoint.epoch {
362-
epoch_store
363-
.put_genesis_checkpoint_in_builder(checkpoint.data(), &contents)
364-
.unwrap();
365-
} else {
366-
debug!(
367-
validator_epoch =% epoch_store.epoch(),
368-
genesis_epoch =% checkpoint.epoch(),
369-
"Not inserting checkpoint builder data for genesis checkpoint",
370-
);
356+
match self.get_checkpoint_by_sequence_number(0).unwrap() {
357+
Some(existing_checkpoint) => {
358+
assert_eq!(existing_checkpoint.digest(), checkpoint.digest())
359+
}
360+
None => {
361+
if epoch_store.epoch() == checkpoint.epoch {
362+
epoch_store
363+
.put_genesis_checkpoint_in_builder(checkpoint.data(), &contents)
364+
.unwrap();
365+
} else {
366+
debug!(
367+
validator_epoch =% epoch_store.epoch(),
368+
genesis_epoch =% checkpoint.epoch(),
369+
"Not inserting checkpoint builder data for genesis checkpoint",
370+
);
371+
}
372+
self.insert_checkpoint_contents(contents).unwrap();
373+
self.insert_verified_checkpoint(&checkpoint).unwrap();
374+
self.update_highest_synced_checkpoint(&checkpoint).unwrap();
371375
}
372-
self.insert_checkpoint_contents(contents).unwrap();
373-
self.insert_verified_checkpoint(&checkpoint).unwrap();
374-
self.update_highest_synced_checkpoint(&checkpoint).unwrap();
375376
}
376377
}
377378

0 commit comments

Comments
 (0)