Skip to content

Commit

Permalink
Continue deduping system tx on end-of-epoch (MystenLabs#15216)
Browse files Browse the repository at this point in the history
## Description 

Fixes simtest failures on epoch change.
  • Loading branch information
aschran authored Dec 6, 2023
1 parent 6f3c4e8 commit dc09959
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 12 deletions.
25 changes: 14 additions & 11 deletions crates/sui-core/src/authority/authority_per_epoch_store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,8 @@ pub enum ConsensusCertificateResult {
Defered(DeferralKey),
/// Everything else, e.g. AuthorityCapabilities, CheckpointSignatures, etc.
ConsensusMessage,
/// A system message in consensus was ignored (e.g. because of end of epoch).
IgnoredSystem,
}

#[derive(Serialize, Deserialize, Clone, Debug, Default, PartialEq, Eq)]
Expand Down Expand Up @@ -2320,7 +2322,8 @@ impl AuthorityPerEpochStore {
.push(tx.clone());
}
ConsensusCertificateResult::ConsensusMessage => notifications.push(key.clone()),
// Note: ignored transactions must not be recorded as processed. Otherwise
ConsensusCertificateResult::IgnoredSystem => (),
// Note: ignored external transactions must not be recorded as processed. Otherwise
// they may not get reverted after restart during epoch change.
ConsensusCertificateResult::Ignored => ignored = true,
}
Expand Down Expand Up @@ -2580,15 +2583,6 @@ impl AuthorityPerEpochStore {
panic!("process_consensus_transaction called with external RandomnessStateUpdate");
}
SequencedConsensusTransactionKind::System(system_transaction) => {
if let TransactionKind::RandomnessStateUpdate(rsu) =
&system_transaction.data().intent_message().value.kind()
{
batch.insert_batch(
&self.tables.randomness_rounds_written,
[(RandomnessRound(rsu.randomness_round), ())],
)?;
}

if !self
.get_reconfig_state_read_lock_guard()
.should_accept_consensus_certs()
Expand All @@ -2597,7 +2591,16 @@ impl AuthorityPerEpochStore {
"Ignoring system transaction {:?} because of end of epoch",
system_transaction.digest()
);
return Ok(ConsensusCertificateResult::Ignored);
return Ok(ConsensusCertificateResult::IgnoredSystem);
}

if let TransactionKind::RandomnessStateUpdate(rsu) =
&system_transaction.data().intent_message().value.kind()
{
batch.insert_batch(
&self.tables.randomness_rounds_written,
[(RandomnessRound(rsu.randomness_round), ())],
)?;
}

// If needed we can support owned object system transactions as well...
Expand Down
5 changes: 4 additions & 1 deletion crates/sui-core/src/consensus_handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -604,7 +604,10 @@ impl<T, C> ConsensusHandler<T, C> {
.randomness_obj_initial_shared_version()
.expect("randomness state obj must exist"),
);
debug!("created randomness state update transaction: {transaction:?}");
debug!(
"created randomness state update transaction: {:?}",
transaction.digest()
);
VerifiedExecutableTransaction::new_system(transaction, self.epoch())
}

Expand Down

0 comments on commit dc09959

Please sign in to comment.