Skip to content

Commit

Permalink
support v1
Browse files Browse the repository at this point in the history
  • Loading branch information
benr-ml committed Jun 14, 2024
1 parent b996c1f commit 4895178
Show file tree
Hide file tree
Showing 4 changed files with 300 additions and 78 deletions.
46 changes: 36 additions & 10 deletions crates/sui-core/src/authority/authority_per_epoch_store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use arc_swap::ArcSwapOption;
use enum_dispatch::enum_dispatch;
use fastcrypto::groups::bls12381;
use fastcrypto_tbls::nodes::PartyId;
use fastcrypto_tbls::{dkg, dkg_v0, dkg_v1};
use fastcrypto_tbls::{dkg, dkg_v0};
use fastcrypto_zkp::bn254::zk_login::{JwkId, OIDCProvider, JWK};
use fastcrypto_zkp::bn254::zk_login_api::ZkLoginEnv;
use futures::future::{join_all, select, Either};
Expand Down Expand Up @@ -67,7 +67,10 @@ use crate::consensus_handler::{
SequencedConsensusTransactionKind, VerifiedSequencedConsensusTransaction,
};
use crate::epoch::epoch_metrics::EpochMetrics;
use crate::epoch::randomness::{DkgStatus, RandomnessManager, RandomnessReporter};
use crate::epoch::randomness::{
DkgStatus, RandomnessManager, RandomnessReporter, VersionedProcessedMessage,
VersionedUsedProcessedMessages,
};
use crate::epoch::reconfiguration::ReconfigState;
use crate::execution_cache::ObjectCacheRead;
use crate::module_cache_metrics::ResolverMetrics;
Expand All @@ -93,6 +96,7 @@ use sui_types::message_envelope::TrustedEnvelope;
use sui_types::messages_checkpoint::{
CheckpointContents, CheckpointSequenceNumber, CheckpointSignatureMessage, CheckpointSummary,
};
use sui_types::messages_consensus::VersionedDkgMessage;
use sui_types::messages_consensus::{
check_total_jwk_size, AuthorityCapabilities, ConsensusTransaction, ConsensusTransactionKey,
ConsensusTransactionKind,
Expand Down Expand Up @@ -501,14 +505,18 @@ pub struct AuthorityEpochTables {
/// Records messages processed from other nodes. Updated when receiving a new dkg::Message
/// via consensus.
// TODO: Deprecate v0 messages once testnet is using v1
pub(crate) dkg_versioned_processed_messages: DBMap<PartyId, VersionedProcessedMessage>,
/// This table is no longer used (can be removed when DBMap supports removing tables)
#[allow(dead_code)]
pub(crate) dkg_processed_messages: DBMap<PartyId, dkg_v0::ProcessedMessage<PkG, EncG>>,
pub(crate) dkg_v1_processed_messages: DBMap<PartyId, dkg_v1::ProcessedMessage<PkG, EncG>>,

/// Records messages used to generate a DKG confirmation. Updated when enough DKG
/// messages are received to progress to the next phase.
// TODO: Deprecate v0 messages once testnet is using v1
pub(crate) dkg_versioned_used_messages: DBMap<u64, VersionedUsedProcessedMessages>,
/// This table is no longer used (can be removed when DBMap supports removing tables)
#[allow(dead_code)]
pub(crate) dkg_used_messages: DBMap<u64, dkg_v0::UsedProcessedMessages<PkG, EncG>>,
pub(crate) dkg_v1_used_messages: DBMap<u64, dkg_v1::UsedProcessedMessages<PkG, EncG>>,

/// Records confirmations received from other nodes. Updated when receiving a new
/// dkg::Confirmation via consensus.
pub(crate) dkg_confirmations: DBMap<PartyId, dkg::Confirmation<EncG>>,
Expand Down Expand Up @@ -3396,13 +3404,31 @@ impl AuthorityPerEpochStore {
"Received RandomnessDkgMessage from {:?}",
authority.concise()
);
match bcs::from_bytes(bytes) {
Ok(message) => randomness_manager.add_message(authority, message)?,
Err(e) => {
warn!(
if self.protocol_config.dkg_version() == 0 {
// old message was not an enum
match bcs::from_bytes(bytes) {
Ok(message) => {
let message = VersionedDkgMessage::V0(message);
randomness_manager.add_message(authority, message)?
}
Err(e) => {
warn!(
"Failed to deserialize RandomnessDkgMessage from {:?}: {e:?}",
authority.concise(),
);
}
}
} else {
match bcs::from_bytes(bytes) {
Ok(message) => {
randomness_manager.add_message(authority, message)?
}
Err(e) => {
warn!(
"Failed to deserialize versioned RandomnessDkgMessage from {:?}: {e:?}",
authority.concise(),
);
}
}
}
} else {
Expand Down
Loading

0 comments on commit 4895178

Please sign in to comment.