Skip to content

Commit 93593d0

Browse files
committed
refactor(signer): gate DMQ publisher behind 'future_dmq' feature
1 parent 1e1789f commit 93593d0

File tree

3 files changed

+39
-23
lines changed

3 files changed

+39
-23
lines changed

mithril-signer/Cargo.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ default = ["jemallocator"]
1414

1515
bundle_tls = ["reqwest/native-tls-vendored"]
1616
jemallocator = ["dep:tikv-jemallocator"]
17+
future_dmq = ["dep:mithril-dmq-node"]
1718

1819
[dependencies]
1920
anyhow = { workspace = true }
@@ -26,7 +27,7 @@ mithril-cardano-node-chain = { path = "../internal/cardano-node/mithril-cardano-
2627
mithril-cardano-node-internal-database = { path = "../internal/cardano-node/mithril-cardano-node-internal-database" }
2728
mithril-cli-helper = { path = "../internal/mithril-cli-helper" }
2829
mithril-common = { path = "../mithril-common", features = ["full"] }
29-
mithril-dmq-node = { path = "../internal/mithril-dmq-node" }
30+
mithril-dmq-node = { path = "../internal/mithril-dmq-node", optional = true }
3031
mithril-doc = { path = "../internal/mithril-doc" }
3132
mithril-era = { path = "../internal/mithril-era" }
3233
mithril-metric = { path = "../internal/mithril-metric" }

mithril-signer/src/dependency_injection/builder.rs

Lines changed: 35 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ use std::sync::Arc;
33
use std::time::Duration;
44

55
use anyhow::{anyhow, Context};
6-
use mithril_dmq_node::{DmqMessageBuilder, DmqPublisherPallas};
76
use slog::Logger;
87
use tokio::sync::{Mutex, RwLock};
98

@@ -20,16 +19,18 @@ use mithril_cardano_node_internal_database::{
2019
signable_builder::{CardanoDatabaseSignableBuilder, CardanoImmutableFilesFullSignableBuilder},
2120
ImmutableFileObserver, ImmutableFileSystemObserver,
2221
};
22+
use mithril_common::api_version::APIVersionProvider;
2323
use mithril_common::crypto_helper::{
2424
KesSigner, KesSignerStandard, OpCert, ProtocolPartyId, SerDeShelleyFileFormat,
2525
};
26+
#[cfg(feature = "future_dmq")]
27+
use mithril_common::messages::RegisterSignatureMessageDmq;
2628
use mithril_common::signable_builder::{
2729
CardanoStakeDistributionSignableBuilder, CardanoTransactionsSignableBuilder,
2830
MithrilSignableBuilderService, MithrilStakeDistributionSignableBuilder,
2931
SignableBuilderServiceDependencies,
3032
};
3133
use mithril_common::StdResult;
32-
use mithril_common::{api_version::APIVersionProvider, messages::RegisterSignatureMessageDmq};
3334

3435
use mithril_era::{EraChecker, EraReader};
3536
use mithril_signed_entity_lock::SignedEntityTypeLock;
@@ -40,6 +41,12 @@ use mithril_persistence::database::repository::CardanoTransactionRepository;
4041
use mithril_persistence::database::{ApplicationNodeType, SqlMigration};
4142
use mithril_persistence::sqlite::{ConnectionBuilder, SqliteConnection, SqliteConnectionPool};
4243

44+
#[cfg(feature = "future_dmq")]
45+
use mithril_dmq_node::{DmqMessageBuilder, DmqPublisherPallas};
46+
47+
use crate::dependency_injection::SignerDependencyContainer;
48+
#[cfg(feature = "future_dmq")]
49+
use crate::services::SignaturePublisherDmq;
4350
use crate::services::{
4451
AggregatorHTTPClient, CardanoTransactionsImporter,
4552
CardanoTransactionsPreloaderActivationSigner, MithrilEpochService, MithrilSingleSigner,
@@ -53,7 +60,6 @@ use crate::{
5360
database::repository::{ProtocolInitializerRepository, SignedBeaconRepository, StakePoolStore},
5461
services::SignaturePublisher,
5562
};
56-
use crate::{dependency_injection::SignerDependencyContainer, services::SignaturePublisherDmq};
5763
use crate::{
5864
Configuration, MetricsService, HTTP_REQUEST_TIMEOUT_DURATION, SQLITE_FILE,
5965
SQLITE_FILE_CARDANO_TRANSACTION,
@@ -412,27 +418,34 @@ impl<'a> DependenciesBuilder<'a> {
412418
_ => None,
413419
};
414420

415-
let cardano_network = &self.config.get_network()?;
416-
417421
let signature_publisher = {
418422
let first_publisher = SignaturePublisherRetrier::new(
419-
if let Some(dmq_node_socket_path) = &self.config.dmq_node_socket_path {
420-
let dmq_message_builder = DmqMessageBuilder::new_with_default_ttl(
421-
kes_signer
422-
.clone()
423-
.ok_or(anyhow!("A KES signer is mandatory to sign DMQ messages"))?,
424-
chain_observer.clone(),
425-
);
426-
Arc::new(SignaturePublisherDmq::new(Arc::new(DmqPublisherPallas::<
427-
RegisterSignatureMessageDmq,
428-
>::new(
429-
dmq_node_socket_path.to_owned(),
430-
*cardano_network,
431-
dmq_message_builder,
432-
self.root_logger(),
433-
)))) as Arc<dyn SignaturePublisher>
434-
} else {
435-
Arc::new(SignaturePublisherNoop) as Arc<dyn SignaturePublisher>
423+
{
424+
#[cfg(feature = "future_dmq")]
425+
let publisher = match &self.config.dmq_node_socket_path {
426+
Some(dmq_node_socket_path) => {
427+
let cardano_network = &self.config.get_network()?;
428+
let dmq_message_builder = DmqMessageBuilder::new_with_default_ttl(
429+
kes_signer.clone().ok_or(anyhow!(
430+
"A KES signer is mandatory to sign DMQ messages"
431+
))?,
432+
chain_observer.clone(),
433+
);
434+
Arc::new(SignaturePublisherDmq::new(Arc::new(DmqPublisherPallas::<
435+
RegisterSignatureMessageDmq,
436+
>::new(
437+
dmq_node_socket_path.to_owned(),
438+
*cardano_network,
439+
dmq_message_builder,
440+
self.root_logger(),
441+
)))) as Arc<dyn SignaturePublisher>
442+
}
443+
_ => Arc::new(SignaturePublisherNoop) as Arc<dyn SignaturePublisher>,
444+
};
445+
#[cfg(not(feature = "future_dmq"))]
446+
let publisher = Arc::new(SignaturePublisherNoop) as Arc<dyn SignaturePublisher>;
447+
448+
publisher
436449
},
437450
SignaturePublishRetryPolicy::never(),
438451
);

mithril-signer/src/services/signature_publisher/mod.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
mod delayer;
2+
#[cfg(feature = "future_dmq")]
23
mod dmq;
34
mod http;
45
mod interface;
56
mod noop;
67
mod retrier;
78

89
pub use delayer::*;
10+
#[cfg(feature = "future_dmq")]
911
pub use dmq::*;
1012
pub use interface::*;
1113
pub use noop::*;

0 commit comments

Comments
 (0)