diff --git a/internal/mithril-doc/src/lib.rs b/internal/mithril-doc/src/lib.rs index b3f700f93f3..d4d9231b910 100644 --- a/internal/mithril-doc/src/lib.rs +++ b/internal/mithril-doc/src/lib.rs @@ -104,6 +104,14 @@ impl StructDoc { }; result } + + /// Get a field by its name. + pub fn get_field(&self, name: &str) -> &FieldDoc { + let mut fields = self.data.iter().filter(|f| f.parameter == name); + + assert_eq!(1, fields.clone().count()); + fields.next().unwrap() + } } /// Extractor for struct without Default trait. diff --git a/internal/mithril-doc/src/test_doc_macro.rs b/internal/mithril-doc/src/test_doc_macro.rs index 9d8023f61a4..b4c6b8493f8 100644 --- a/internal/mithril-doc/src/test_doc_macro.rs +++ b/internal/mithril-doc/src/test_doc_macro.rs @@ -1,6 +1,6 @@ #[cfg(test)] mod tests { - use crate::{Documenter, DocumenterDefault, FieldDoc, StructDoc}; + use crate::{Documenter, DocumenterDefault, StructDoc}; use config::{Map, Source, Value, ValueKind}; #[allow(dead_code)] @@ -41,18 +41,10 @@ mod tests { } } - // TODO May be part of StructDoc. - pub fn get_field<'a>(struct_doc: &'a StructDoc, name: &str) -> &'a FieldDoc { - let mut fields = struct_doc.data.iter().filter(|f| f.parameter == name); - - assert_eq!(1, fields.clone().count()); - fields.next().unwrap() - } - #[test] fn test_extract_struct_of_default_configuration() { let doc = MyDefaultConfiguration::extract(); - let field = get_field(&doc, "environment"); + let field = doc.get_field("environment"); assert_eq!("environment", field.parameter); assert_eq!("ENVIRONMENT", field.environment_variable.as_ref().unwrap()); @@ -63,7 +55,7 @@ mod tests { #[test] fn test_extract_struct_of_configuration() { let doc = MyConfiguration::extract(); - let field = get_field(&doc, "environment"); + let field = doc.get_field("environment"); assert_eq!("environment", field.parameter); assert_eq!("ENVIRONMENT", field.environment_variable.as_ref().unwrap()); @@ -75,12 +67,12 @@ mod tests { fn test_extract_example_of_configuration() { { let doc_with_example = MyConfiguration::extract(); - let field = get_field(&doc_with_example, "environment"); + let field = doc_with_example.get_field("environment"); assert_eq!(Some("dev".to_string()), field.example); } { let doc_without_example = MyDefaultConfiguration::extract(); - let field = get_field(&doc_without_example, "environment"); + let field = doc_without_example.get_field("environment"); assert_eq!(None, field.example); } } diff --git a/mithril-aggregator/src/file_uploaders/local_snapshot_uploader.rs b/mithril-aggregator/src/file_uploaders/local_snapshot_uploader.rs index 1aaf9d9206f..b53928b5266 100644 --- a/mithril-aggregator/src/file_uploaders/local_snapshot_uploader.rs +++ b/mithril-aggregator/src/file_uploaders/local_snapshot_uploader.rs @@ -10,7 +10,6 @@ use mithril_common::StdResult; use crate::file_uploaders::{url_sanitizer::sanitize_url_path, FileUploader, FileUri}; use crate::tools; -// TODO: This specific local uploader will be removed. // It's only used by the legacy snapshot that uploads the entire Cardano database. /// LocalSnapshotUploader is a file uploader working using local files pub struct LocalSnapshotUploader { diff --git a/mithril-aggregator/src/http_server/routes/artifact_routes/snapshot.rs b/mithril-aggregator/src/http_server/routes/artifact_routes/snapshot.rs index 55b7538bfd6..1851c8e31b5 100644 --- a/mithril-aggregator/src/http_server/routes/artifact_routes/snapshot.rs +++ b/mithril-aggregator/src/http_server/routes/artifact_routes/snapshot.rs @@ -1,7 +1,5 @@ use crate::http_server::routes::middlewares; use crate::http_server::routes::router::RouterState; -use crate::http_server::SERVER_BASE_PATH; -use warp::hyper::Uri; use warp::Filter; pub fn routes( @@ -11,8 +9,6 @@ pub fn routes( .or(artifact_cardano_full_immutable_snapshot_by_id(router_state)) .or(serve_snapshots_dir(router_state)) .or(snapshot_download(router_state)) - .or(artifact_cardano_full_immutable_snapshots_legacy()) - .or(artifact_cardano_full_immutable_snapshot_by_id_legacy()) } /// GET /artifact/snapshots @@ -67,34 +63,6 @@ fn serve_snapshots_dir( .and_then(handlers::ensure_downloaded_file_is_a_snapshot) } -/// GET /snapshots -// TODO: This legacy route should be removed when this code is released with a new distribution -fn artifact_cardano_full_immutable_snapshots_legacy( -) -> impl Filter + Clone { - warp::path!("snapshots").map(|| { - warp::redirect( - format!("/{SERVER_BASE_PATH}/artifact/snapshots") - .as_str() - .parse::() - .unwrap(), - ) - }) -} - -/// GET /snapshot/digest -// TODO: This legacy route should be removed when this code is released with a new distribution -fn artifact_cardano_full_immutable_snapshot_by_id_legacy( -) -> impl Filter + Clone { - warp::path!("snapshot" / String).map(|digest| { - warp::redirect( - format!("/{SERVER_BASE_PATH}/artifact/snapshot/{digest}") - .as_str() - .parse::() - .unwrap(), - ) - }) -} - mod handlers { use crate::http_server::routes::reply; use crate::http_server::SERVER_BASE_PATH; diff --git a/mithril-common/src/crypto_helper/cardano/key_certification.rs b/mithril-common/src/crypto_helper/cardano/key_certification.rs index 4afddcec245..f8f18bc51ae 100644 --- a/mithril-common/src/crypto_helper/cardano/key_certification.rs +++ b/mithril-common/src/crypto_helper/cardano/key_certification.rs @@ -43,7 +43,8 @@ pub type KESPeriod = u32; #[derive(Error, Debug)] pub enum ProtocolRegistrationErrorWrapper { /// Error raised when a party id is needed but not provided - // TODO: Should be removed once the signer certification is fully deployed + /// + /// Used only for testing when SPO pool id is not certified #[error("missing party id")] PartyIdMissing, @@ -246,9 +247,9 @@ impl KeyRegWrapper { /// Mithril key (with its corresponding Proof of Possession). pub fn register( &mut self, - party_id: Option, // TODO: Parameter should be removed once the signer certification is fully deployed - opcert: Option, // TODO: Option should be removed once the signer certification is fully deployed - kes_sig: Option, // TODO: Option should be removed once the signer certification is fully deployed + party_id: Option, // Used for only for testing when SPO pool id is not certified + opcert: Option, // Used for only for testing when SPO pool id is not certified + kes_sig: Option, // Used for only for testing when SPO pool id is not certified kes_period: Option, pk: ProtocolSignerVerificationKey, ) -> Result { diff --git a/mithril-common/src/entities/signer.rs b/mithril-common/src/entities/signer.rs index 30d2e66329f..3a1bd54145e 100644 --- a/mithril-common/src/entities/signer.rs +++ b/mithril-common/src/entities/signer.rs @@ -14,19 +14,22 @@ use sha2::{Digest, Sha256}; #[derive(Clone, Eq, Serialize, Deserialize)] pub struct Signer { /// The unique identifier of the signer - // TODO: Should be removed once the signer certification is fully deployed + /// + /// Used only for testing when SPO pool id is not certified pub party_id: PartyId, /// The public key used to authenticate signer signature pub verification_key: ProtocolSignerVerificationKey, /// The encoded signer 'Mithril verification key' signature (signed by the Cardano node KES secret key) - // TODO: Option should be removed once the signer certification is fully deployed + /// + /// None is used only for testing when SPO pool id is not certified #[serde(skip_serializing_if = "Option::is_none")] pub verification_key_signature: Option, /// The encoded operational certificate of stake pool operator attached to the signer node - // TODO: Option should be removed once the signer certification is fully deployed + /// + /// None is used only for testing when SPO pool id is not certified #[serde(skip_serializing_if = "Option::is_none")] pub operational_certificate: Option, @@ -136,19 +139,22 @@ impl From for Signer { #[derive(Clone, Eq, Serialize, Deserialize)] pub struct SignerWithStake { /// The unique identifier of the signer - // TODO: Should be removed once the signer certification is fully deployed + /// + /// Used only for testing when SPO pool id is not certified pub party_id: PartyId, /// The public key used to authenticate signer signature pub verification_key: ProtocolSignerVerificationKey, /// The encoded signer 'Mithril verification key' signature (signed by the Cardano node KES secret key) - // TODO: Option should be removed once the signer certification is fully deployed + /// + /// None is used only for testing when SPO pool id is not certified #[serde(skip_serializing_if = "Option::is_none")] pub verification_key_signature: Option, /// The encoded operational certificate of stake pool operator attached to the signer node - // TODO: Option should be removed once the signer certification is fully deployed + /// + /// None is used only for testing when SPO pool id is not certified #[serde(skip_serializing_if = "Option::is_none")] pub operational_certificate: Option, diff --git a/mithril-common/src/entities/single_signatures.rs b/mithril-common/src/entities/single_signatures.rs index a136604b5dd..781efd1025a 100644 --- a/mithril-common/src/entities/single_signatures.rs +++ b/mithril-common/src/entities/single_signatures.rs @@ -65,8 +65,6 @@ impl SingleSignatures { cfg_test_tools! { impl SingleSignatures { /// Create a fake [SingleSignatures] with valid cryptographic data for testing purposes. - // TODO: this method is slow due to the fixture creation, we should either make - // the fixture faster or find a faster alternative. pub fn fake, TMessage: Into>(party_id: TPartyId, message: TMessage) -> Self { use crate::entities::{ProtocolParameters}; use crate::test_utils::{MithrilFixtureBuilder, StakeDistributionGenerationMethod}; diff --git a/mithril-common/src/messages/message_parts/signer.rs b/mithril-common/src/messages/message_parts/signer.rs index 300cb0b063f..d7b5133b0ab 100644 --- a/mithril-common/src/messages/message_parts/signer.rs +++ b/mithril-common/src/messages/message_parts/signer.rs @@ -16,7 +16,8 @@ use std::fmt::{Debug, Formatter}; #[derive(Clone, PartialEq, Eq, Default, Serialize, Deserialize)] pub struct SignerWithStakeMessagePart { /// The unique identifier of the signer - // TODO: Should be removed once the signer certification is fully deployed + /// + /// Used only for testing when SPO pool id is not certified pub party_id: PartyId, /// The public key used to authenticate signer signature @@ -24,15 +25,15 @@ pub struct SignerWithStakeMessagePart { /// The encoded signer 'Mithril verification key' signature (signed by the /// Cardano node KES secret key). - // TODO: Option should be removed once the signer certification is fully - // deployed. + /// + /// None is used only for testing when SPO pool id is not certified #[serde(skip_serializing_if = "Option::is_none")] pub verification_key_signature: Option, /// The encoded operational certificate of stake pool operator attached to /// the signer node. - // TODO: Option should be removed once the signer certification is fully - // deployed. + /// + /// None is used only for testing when SPO pool id is not certified #[serde(skip_serializing_if = "Option::is_none")] pub operational_certificate: Option, @@ -161,7 +162,8 @@ impl Debug for SignerMessagePart { #[derive(Clone, PartialEq, Eq, Default, Serialize, Deserialize)] pub struct SignerMessagePart { /// The unique identifier of the signer - // TODO: Should be removed once the signer certification is fully deployed + /// + /// Used only for testing when SPO pool id is not certified pub party_id: PartyId, /// The public key used to authenticate signer signature @@ -169,15 +171,15 @@ pub struct SignerMessagePart { /// The encoded signer 'Mithril verification key' signature (signed by the /// Cardano node KES secret key). - // TODO: Option should be removed once the signer certification is fully - // deployed. + /// + /// None is used only for testing when SPO pool id is not certified #[serde(skip_serializing_if = "Option::is_none")] pub verification_key_signature: Option, /// The encoded operational certificate of stake pool operator attached to /// the signer node. - // TODO: Option should be removed once the signer certification is fully - // deployed. + /// + /// None is used only for testing when SPO pool id is not certified #[serde(skip_serializing_if = "Option::is_none")] pub operational_certificate: Option, diff --git a/mithril-common/src/messages/register_signer.rs b/mithril-common/src/messages/register_signer.rs index 0fcabf2b774..9bc706d65f2 100644 --- a/mithril-common/src/messages/register_signer.rs +++ b/mithril-common/src/messages/register_signer.rs @@ -13,7 +13,8 @@ pub struct RegisterSignerMessage { pub epoch: Epoch, /// The unique identifier of the signer - // TODO: Should be removed once the signer certification is fully deployed + /// + /// Used only for testing when SPO pool id is not certified pub party_id: PartyId, /// The public key used to authenticate signer signature @@ -21,15 +22,15 @@ pub struct RegisterSignerMessage { /// The encoded signer 'Mithril verification key' signature (signed by the /// Cardano node KES secret key). - // TODO: Option should be removed once the signer certification is fully - // deployed. + /// + /// None is used only for testing when SPO pool id is not certified #[serde(skip_serializing_if = "Option::is_none")] pub verification_key_signature: Option, /// The encoded operational certificate of stake pool operator attached to /// the signer node. - // TODO: Option should be removed once the signer certification is fully - // deployed. + /// + /// None is used only for testing when SPO pool id is not certified #[serde(skip_serializing_if = "Option::is_none")] pub operational_certificate: Option, diff --git a/mithril-relay/src/relay/passive.rs b/mithril-relay/src/relay/passive.rs index a3990b62f2f..3fcd41af80b 100644 --- a/mithril-relay/src/relay/passive.rs +++ b/mithril-relay/src/relay/passive.rs @@ -7,8 +7,7 @@ use slog::{debug, info, Logger}; /// A passive relay pub struct PassiveRelay { /// Relay peer - // TODO: should be private - pub peer: Peer, + peer: Peer, logger: Logger, } @@ -24,13 +23,9 @@ impl PassiveRelay { }) } - /// Convert event to broadcast message - /// TODO: should be removed - pub fn convert_peer_event_to_message( - &mut self, - event: PeerEvent, - ) -> StdResult> { - self.peer.convert_peer_event_to_message(event) + /// Get the peer of the passive relay + pub fn peer_mut(&mut self) -> &mut Peer { + &mut self.peer } /// Tick the passive relay diff --git a/mithril-relay/tests/register_signer_signature.rs b/mithril-relay/tests/register_signer_signature.rs index 99cf362537e..958fde0b1ca 100644 --- a/mithril-relay/tests/register_signer_signature.rs +++ b/mithril-relay/tests/register_signer_signature.rs @@ -54,7 +54,7 @@ async fn should_receive_registrations_from_signers_when_subscribed_to_pubsub() { .await .expect("P2P client start failed"); p2p_client1 - .peer + .peer_mut() .dial(relay_peer_address.clone()) .expect("P2P client dial to the relay should not fail"); @@ -62,7 +62,7 @@ async fn should_receive_registrations_from_signers_when_subscribed_to_pubsub() { .await .expect("P2P client start failed"); p2p_client2 - .peer + .peer_mut() .dial(relay_peer_address.clone()) .expect("P2P client dial to the relay should not fail"); @@ -138,7 +138,7 @@ async fn should_receive_registrations_from_signers_when_subscribed_to_pubsub() { loop { tokio::select! { event = p2p_client1.tick_peer() => { - if let Ok(Some(BroadcastMessage::RegisterSigner(signer_message_received))) = p2p_client1.convert_peer_event_to_message(event.unwrap().unwrap()) + if let Ok(Some(BroadcastMessage::RegisterSigner(signer_message_received))) = p2p_client1.peer_mut().convert_peer_event_to_message(event.unwrap().unwrap()) { info!("Test: client1 consumed signer registration"; "message" => #?signer_message_received); assert_eq!(signer_message_sent, signer_message_received); @@ -146,7 +146,7 @@ async fn should_receive_registrations_from_signers_when_subscribed_to_pubsub() { } } event = p2p_client2.tick_peer() => { - if let Ok(Some(BroadcastMessage::RegisterSigner(signer_message_received))) = p2p_client2.convert_peer_event_to_message(event.unwrap().unwrap()) + if let Ok(Some(BroadcastMessage::RegisterSigner(signer_message_received))) = p2p_client2.peer_mut().convert_peer_event_to_message(event.unwrap().unwrap()) { info!("Test: client2 consumed signer registration"; "message" => #?signer_message_received); assert_eq!(signer_message_sent, signer_message_received); @@ -183,7 +183,7 @@ async fn should_receive_registrations_from_signers_when_subscribed_to_pubsub() { loop { tokio::select! { event = p2p_client1.tick_peer() => { - if let Ok(Some(BroadcastMessage::RegisterSignature(signature_message_received))) = p2p_client1.convert_peer_event_to_message(event.unwrap().unwrap()) + if let Ok(Some(BroadcastMessage::RegisterSignature(signature_message_received))) = p2p_client1.peer_mut().convert_peer_event_to_message(event.unwrap().unwrap()) { info!("Test: client1 consumed signature"; "message" => #?signature_message_received); assert_eq!(signature_message_sent, signature_message_received); @@ -191,7 +191,7 @@ async fn should_receive_registrations_from_signers_when_subscribed_to_pubsub() { } } event = p2p_client2.tick_peer() => { - if let Ok(Some(BroadcastMessage::RegisterSignature(signature_message_received))) = p2p_client2.convert_peer_event_to_message(event.unwrap().unwrap()) + if let Ok(Some(BroadcastMessage::RegisterSignature(signature_message_received))) = p2p_client2.peer_mut().convert_peer_event_to_message(event.unwrap().unwrap()) { info!("Test: client2 consumed signature"; "message" => #?signature_message_received); assert_eq!(signature_message_sent, signature_message_received); diff --git a/mithril-signer/src/configuration.rs b/mithril-signer/src/configuration.rs index e9af4a4b25e..47fe3040e54 100644 --- a/mithril-signer/src/configuration.rs +++ b/mithril-signer/src/configuration.rs @@ -52,7 +52,8 @@ pub struct Configuration { pub relay_endpoint: Option, /// Party Id - // TODO: Field should be removed once the signer certification is fully deployed + /// + /// Used only for testing when SPO pool id is not certified #[example = "`pool1pxaqe80sqpde7902er5kf6v0c7y0sv6d5g676766v2h829fvs3x`"] pub party_id: Option, diff --git a/mithril-test-lab/mithril-devnet/configuration/byron/configuration.yaml b/mithril-test-lab/mithril-devnet/configuration/byron/configuration.yaml index d1c096eac26..24457485fbb 100644 --- a/mithril-test-lab/mithril-devnet/configuration/byron/configuration.yaml +++ b/mithril-test-lab/mithril-devnet/configuration/byron/configuration.yaml @@ -3,7 +3,6 @@ ############### Cardano Byron Node Configuration ######### ########################################################## - ##### Locations ##### GenesisFile: genesis.json @@ -16,7 +15,7 @@ MaxConcurrencyBulkSync: 1 # The maximum number of used peers when fetching newly forged blocks. MaxConcurrencyDeadline: 2 -#TODO: These parameters cannot yet be used in the config file, only on the CLI: +# These parameters cannot yet be used in the config file, only on the CLI: #DatabasePath: db/ #Topology: configuration/mainnet-topology.json #Port 7776 @@ -31,7 +30,6 @@ Protocol: RealPBFT # The mainnet does not include the network magic into addresses. Testnets do. RequiresNetworkMagic: RequiresNoMagic - ##### Update system parameters ##### # This protocol version number gets used by block producing nodes as part @@ -130,9 +128,8 @@ defaultScribes: # in the setupScribes above for specific scribes. rotation: rpLogLimitBytes: 5000000 - rpKeepFilesNum: 3 - rpMaxAgeHours: 24 - + rpKeepFilesNum: 3 + rpMaxAgeHours: 24 ##### Coarse grained logging control ##### @@ -198,7 +195,7 @@ TraceIpSubscription: True TraceLocalRootPeers: True # Trace public root peers -TracePublicRootPeers: True +TracePublicRootPeers: True # Trace peer selection TracePeerSelection: True @@ -249,7 +246,6 @@ TraceTxOutbound: False # Trace TxSubmission protocol messages. TraceTxSubmissionProtocol: False - ##### Fine grained logging control ##### # It is also possible to have more fine grained control over filtering of @@ -258,7 +254,6 @@ TraceTxSubmissionProtocol: False # much more precise control. options: - # This routes metrics matching specific names to particular backends. # This overrides the 'defaultBackends' listed above. And note that it is # an override and not an extension so anything matched here will not diff --git a/mithril-test-lab/mithril-devnet/mkfiles/mkfiles-docker.sh b/mithril-test-lab/mithril-devnet/mkfiles/mkfiles-docker.sh index 2bec6725e4c..a61ebf06e08 100644 --- a/mithril-test-lab/mithril-devnet/mkfiles/mkfiles-docker.sh +++ b/mithril-test-lab/mithril-devnet/mkfiles/mkfiles-docker.sh @@ -229,7 +229,6 @@ EOF EOF else # 50% of signers without key certification (legacy) - # TODO: Should be removed once the signer certification is fully deployed cat >> ${NODE}/info.json < Spec<'a> { assertions::assert_node_producing_cardano_database_digests_map(&aggregator_endpoint) .await?; - - // TODO: uncomment when the client can verify Cardano database snapshots - //let mut client = self.infrastructure.build_client()?; - //assertions::assert_client_can_verify_cardano_database_snapshot(&mut client, &digest).await?; } // Verify that Cardano transactions artifacts are produced and signed correctly diff --git a/mithril-test-lab/mithril-end-to-end/src/mithril/infrastructure.rs b/mithril-test-lab/mithril-end-to-end/src/mithril/infrastructure.rs index 4e42d300e81..b551a7aec21 100644 --- a/mithril-test-lab/mithril-end-to-end/src/mithril/infrastructure.rs +++ b/mithril-test-lab/mithril-end-to-end/src/mithril/infrastructure.rs @@ -259,7 +259,6 @@ impl MithrilInfrastructure { for (index, pool_node) in pool_nodes.iter().enumerate() { // 50% of signers with key certification if allow unverified signer registration // Or 100% of signers otherwise - // TODO: Should be removed once the signer certification is fully deployed let enable_certification = index % 2 == 0 || cfg!(not(feature = "allow_skip_signer_certification")); let aggregator_endpoint = if config.use_p2p_network_mode {