Skip to content

Commit

Permalink
[checkpoints] Insert genesis transactions in the checkpoint builder i…
Browse files Browse the repository at this point in the history
…ndex (MystenLabs#7338)

This is needed so that CheckpointBuilder does not attempt to include
genesis transaction in the future checkpoints.
  • Loading branch information
andll authored Jan 12, 2023
1 parent b817895 commit d7fc9b0
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 2 deletions.
13 changes: 13 additions & 0 deletions crates/sui-core/src/authority/authority_per_epoch_store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1288,6 +1288,19 @@ impl AuthorityPerEpochStore {
batch.write()
}

/// Register genesis transaction in builder DB so that it does not include transaction
/// in future checkpoints
pub fn put_genesis_transaction_in_builder_digest_to_checkpoint(
&self,
digest: TransactionDigest,
sequence: CheckpointSequenceNumber,
) -> SuiResult<()> {
Ok(self
.tables
.builder_digest_to_checkpoint
.insert(&digest, &sequence)?)
}

pub fn builder_included_transaction_in_checkpoint(
&self,
digest: &TransactionDigest,
Expand Down
13 changes: 13 additions & 0 deletions crates/sui-core/src/checkpoints/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,20 @@ impl CheckpointStore {
&self,
checkpoint: VerifiedCheckpoint,
contents: CheckpointContents,
epoch_store: &AuthorityPerEpochStore,
) {
for transaction in contents.iter() {
debug!(
"Manually inserting genesis transaction in checkpoint DB: {:?}",
transaction.transaction
);
epoch_store
.put_genesis_transaction_in_builder_digest_to_checkpoint(
transaction.transaction,
checkpoint.sequence_number(),
)
.unwrap();
}
self.insert_verified_checkpoint(checkpoint.clone()).unwrap();
self.insert_checkpoint_contents(contents).unwrap();
self.update_highest_synced_checkpoint(&checkpoint).unwrap();
Expand Down
7 changes: 5 additions & 2 deletions crates/sui-node/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -159,8 +159,11 @@ impl SuiNode {
);

let checkpoint_store = CheckpointStore::new(&config.db_path().join("checkpoints"));
checkpoint_store
.insert_genesis_checkpoint(genesis.checkpoint(), genesis.checkpoint_contents().clone());
checkpoint_store.insert_genesis_checkpoint(
genesis.checkpoint(),
genesis.checkpoint_contents().clone(),
&epoch_store,
);
let state_sync_store = RocksDbStore::new(
store.clone(),
committee_store.clone(),
Expand Down

0 comments on commit d7fc9b0

Please sign in to comment.