From 6eb362d08d4199a2b32409f5508b78b9738f4d48 Mon Sep 17 00:00:00 2001 From: jkrvivian Date: Wed, 30 Oct 2024 21:02:18 +0800 Subject: [PATCH] refactor(iota-types): Remove ConsensusTransactionKind::RandomnessStateUpdate --- .../src/authority/authority_per_epoch_store.rs | 11 ----------- crates/iota-core/src/consensus_handler.rs | 18 ++++-------------- crates/iota-core/src/consensus_validator.rs | 3 +-- crates/iota-types/src/messages_consensus.rs | 6 ------ 4 files changed, 5 insertions(+), 33 deletions(-) diff --git a/crates/iota-core/src/authority/authority_per_epoch_store.rs b/crates/iota-core/src/authority/authority_per_epoch_store.rs index c0d016458f8..d5331c2ff8d 100644 --- a/crates/iota-core/src/authority/authority_per_epoch_store.rs +++ b/crates/iota-core/src/authority/authority_per_epoch_store.rs @@ -2383,10 +2383,6 @@ impl AuthorityPerEpochStore { return None; } } - SequencedConsensusTransactionKind::External(ConsensusTransaction { - kind: ConsensusTransactionKind::RandomnessStateUpdate(_round, _bytes), - .. - }) => {} SequencedConsensusTransactionKind::External(ConsensusTransaction { kind: ConsensusTransactionKind::RandomnessDkgMessage(authority, _bytes), .. @@ -3427,13 +3423,6 @@ impl AuthorityPerEpochStore { } Ok(ConsensusCertificateResult::ConsensusMessage) } - SequencedConsensusTransactionKind::External(ConsensusTransaction { - kind: ConsensusTransactionKind::RandomnessStateUpdate(_, _), - .. - }) => { - // These are always generated as System transactions (handled below). - panic!("process_consensus_transaction called with external RandomnessStateUpdate"); - } SequencedConsensusTransactionKind::External(ConsensusTransaction { kind: ConsensusTransactionKind::RandomnessDkgMessage(authority, bytes), .. diff --git a/crates/iota-core/src/consensus_handler.rs b/crates/iota-core/src/consensus_handler.rs index cc2119cb189..74f5b426867 100644 --- a/crates/iota-core/src/consensus_handler.rs +++ b/crates/iota-core/src/consensus_handler.rs @@ -25,7 +25,7 @@ use iota_types::{ }; use lru::LruCache; use serde::{Deserialize, Serialize}; -use tracing::{debug, error, info, instrument, trace_span, warn}; +use tracing::{debug, info, instrument, trace_span, warn}; use crate::{ authority::{ @@ -314,18 +314,9 @@ impl ConsensusHandler { .stats .inc_num_user_transactions(authority_index as usize); } - if let ConsensusTransactionKind::RandomnessStateUpdate(randomness_round, _) = - &transaction.kind - { - // These are deprecated and we should never see them. Log an error and eat - // the tx if one appears. - error!( - "BUG: saw deprecated RandomnessStateUpdate tx for commit round {round:?}, randomness round {randomness_round:?}" - ) - } else { - let transaction = SequencedConsensusTransactionKind::External(transaction); - transactions.push((serialized_transaction, transaction, authority_index)); - } + + let transaction = SequencedConsensusTransactionKind::External(transaction); + transactions.push((serialized_transaction, transaction, authority_index)); } } } @@ -541,7 +532,6 @@ pub(crate) fn classify(transaction: &ConsensusTransaction) -> &'static str { ConsensusTransactionKind::EndOfPublish(_) => "end_of_publish", ConsensusTransactionKind::CapabilityNotificationV1(_) => "capability_notification_v1", ConsensusTransactionKind::NewJWKFetched(_, _, _) => "new_jwk_fetched", - ConsensusTransactionKind::RandomnessStateUpdate(_, _) => "randomness_state_update", ConsensusTransactionKind::RandomnessDkgMessage(_, _) => "randomness_dkg_message", ConsensusTransactionKind::RandomnessDkgConfirmation(_, _) => "randomness_dkg_confirmation", } diff --git a/crates/iota-core/src/consensus_validator.rs b/crates/iota-core/src/consensus_validator.rs index 4962bb0b2f5..907b69ad85a 100644 --- a/crates/iota-core/src/consensus_validator.rs +++ b/crates/iota-core/src/consensus_validator.rs @@ -88,8 +88,7 @@ impl IotaTxValidator { ConsensusTransactionKind::EndOfPublish(_) | ConsensusTransactionKind::NewJWKFetched(_, _, _) - | ConsensusTransactionKind::CapabilityNotificationV1(_) - | ConsensusTransactionKind::RandomnessStateUpdate(_, _) => {} + | ConsensusTransactionKind::CapabilityNotificationV1(_) => {} } } diff --git a/crates/iota-types/src/messages_consensus.rs b/crates/iota-types/src/messages_consensus.rs index dd8821af98d..77323a54518 100644 --- a/crates/iota-types/src/messages_consensus.rs +++ b/crates/iota-types/src/messages_consensus.rs @@ -196,7 +196,6 @@ pub enum ConsensusTransactionKind { CapabilityNotificationV1(AuthorityCapabilitiesV1), NewJWKFetched(AuthorityName, JwkId, JWK), - RandomnessStateUpdate(u64, Vec), // deprecated // DKG is used to generate keys for use in the random beacon protocol. // `RandomnessDkgMessage` is sent out at start-of-epoch to initiate the process. // Contents are a serialized `fastcrypto_tbls::dkg::Message`. @@ -425,11 +424,6 @@ impl ConsensusTransaction { key.clone(), ))) } - ConsensusTransactionKind::RandomnessStateUpdate(_, _) => { - unreachable!( - "there should never be a RandomnessStateUpdate with SequencedConsensusTransactionKind::External" - ) - } ConsensusTransactionKind::RandomnessDkgMessage(authority, _) => { ConsensusTransactionKey::RandomnessDkgMessage(*authority) }