Skip to content

Commit

Permalink
minor comment updates etc
Browse files Browse the repository at this point in the history
  • Loading branch information
aschran committed Feb 25, 2024
1 parent d9d9e50 commit f5f5f45
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 14 deletions.
2 changes: 1 addition & 1 deletion crates/sui-core/src/authority/authority_per_epoch_store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2285,7 +2285,7 @@ impl AuthorityPerEpochStore {
}
}

// We always order transactins using randomness last.
// We always order transactions using randomness last.
PostConsensusTxReorder::reorder(
&mut sequenced_transactions,
self.protocol_config.consensus_transaction_ordering(),
Expand Down
2 changes: 1 addition & 1 deletion crates/sui-core/src/authority/authority_store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,7 @@ impl AuthorityStore {
TransactionKey::Digest(digest) => *digest,
_ => secondary_key_digests
.pop_front()
.expect("size of `non_digest_keys_digests` should match the number of elements in `keys` that are not of type TransactionKey::Digest")
.expect("size of `secondary_key_digests` should match the number of elements in `keys` that are not of type TransactionKey::Digest")
.unwrap_or_default(), // ok to use default here, it will return None in the lookup below
})
.collect();
Expand Down
11 changes: 6 additions & 5 deletions crates/sui-core/src/epoch/randomness.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,14 @@ const SINGLETON_KEY: u64 = 0;
// 4. Randomness generation begins.
//
// Randomness generation:
// 1. For each new round, AuthorityPerEpochStore eventually calls `generate_next_randomness`.
// 1. For each new round, AuthorityPerEpochStore eventually calls `generate_randomness`.
// 2. This kicks off a process in RandomnessEventLoop to send partial signatures for the new
// round to all other validators.
// 3. Once enough partial signautres for the round are collected, a RandomnessStateUpdate
// transaction is generated and injected into the TransactionManager.
// 4. Once the RandomnessStateUpdate transaction is seen in a certified checkpoint, the
// round is complete and we stop sending partial signatures for it.
// 4. Once the RandomnessStateUpdate transaction is seen in a certified checkpoint,
// `notify_randomness_in_checkpoint` is called to complete the round and stop sending
// partial signatures for it.
pub struct RandomnessManager {
inner: Mutex<Inner>,
}
Expand Down Expand Up @@ -291,7 +292,7 @@ impl RandomnessManager {
}

/// Adds a received dkg::Message to the randomness DKG state machine.
// TODO: change to take raw bytes and skip deserialization if a message
// TODO-DNS: change to take raw bytes and skip deserialization if a message
// was already received from the same validator.
pub async fn add_message(
&self,
Expand All @@ -302,7 +303,7 @@ impl RandomnessManager {
}

/// Adds a received dkg::Confirmation to the randomness DKG state machine.
// TODO: change to take raw bytes and skip deserialization if a message
// TODO-DNS: change to take raw bytes and skip deserialization if a message
// was already received from the same validator.
pub async fn add_confirmation(
&self,
Expand Down
2 changes: 1 addition & 1 deletion crates/sui-core/src/epoch/reconfiguration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ pub enum ReconfigCertStatus {
RejectUserCerts,

// All certs rejected, including ones received through consensus.
// But we still accept other transactions from consensus (e.g. RandomnessStateUpdate).
// But we still accept other transactions from consensus (e.g. randomness DKG).
RejectAllCerts,

// All tx rejected, including system tx.
Expand Down
13 changes: 8 additions & 5 deletions crates/sui-network/src/randomness/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -345,6 +345,8 @@ impl RandomnessEventLoop {
return;
};
if sig_bytes.len() != *expected_share_count as usize {
// No need to verify share IDs here as well, since if we receive incorrect IDs, we
// will catch it later when aggregating/verifying the partial sigs.
debug!(
"received partial sigs with wrong share count: expected {expected_share_count}, got {}",
sig_bytes.len(),
Expand Down Expand Up @@ -404,10 +406,10 @@ impl RandomnessEventLoop {
if !(self.send_tasks.contains_key(&(epoch, round))
|| self.pending_tasks.contains(&(epoch, round)))
{
// We have to wait here, because even if we have enough information from other nodes to complete
// the round, local shared object versions are not set until consensus finishes processing the
// corresponding commit. This function will be called again after maybe_start_pending_tasks
// begins this round locally.
// We have to wait here, because even if we have enough information from other nodes
// to complete the signature, local shared object versions are not set until consensus
// finishes processing the corresponding commit. This function will be called again
// after maybe_start_pending_tasks begins this round locally.
debug!("waiting to aggregate randomness partial signatures until local consensus catches up");
return;
}
Expand Down Expand Up @@ -461,6 +463,7 @@ impl RandomnessEventLoop {
warn!(
"received invalid partial signatures from possibly-Byzantine peer {peer_id}"
);
// TODO: Ignore future messages from peers sending bad signatures.
return false;
}
true
Expand Down Expand Up @@ -604,7 +607,7 @@ impl RandomnessEventLoop {
}
self.update_rounds_pending_metric();

// After starting a round we have generated our own partial sigs, check if that's
// After starting a round, we have generated our own partial sigs. Check if that's
// enough for us to aggregate already.
for (epoch, round) in rounds_to_aggregate {
self.maybe_aggregate_partial_signatures(epoch, round).await;
Expand Down
7 changes: 6 additions & 1 deletion crates/sui-types/src/crypto.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1749,6 +1749,11 @@ impl RandomnessRound {
}

pub fn signature_message(&self) -> Vec<u8> {
format!("random_beacon round {}", self.0).into()
"random_beacon round "
.as_bytes()
.iter()
.cloned()
.chain(bcs::to_bytes(&self.0).expect("serialization should not fail"))
.collect()
}
}

0 comments on commit f5f5f45

Please sign in to comment.