@@ -3,6 +3,7 @@ use std::sync::Arc;
3
3
use std:: time:: Duration ;
4
4
5
5
use anyhow:: { anyhow, Context } ;
6
+ use mithril_dmq_node:: { DmqMessageBuilder , DmqPublisherPallas } ;
6
7
use slog:: Logger ;
7
8
use tokio:: sync:: { Mutex , RwLock } ;
8
9
@@ -19,14 +20,16 @@ use mithril_cardano_node_internal_database::{
19
20
signable_builder:: { CardanoDatabaseSignableBuilder , CardanoImmutableFilesFullSignableBuilder } ,
20
21
ImmutableFileObserver , ImmutableFileSystemObserver ,
21
22
} ;
22
- use mithril_common:: api_version:: APIVersionProvider ;
23
- use mithril_common:: crypto_helper:: { OpCert , ProtocolPartyId , SerDeShelleyFileFormat } ;
23
+ use mithril_common:: crypto_helper:: {
24
+ KesSigner , KesSignerStandard , OpCert , ProtocolPartyId , SerDeShelleyFileFormat ,
25
+ } ;
24
26
use mithril_common:: signable_builder:: {
25
27
CardanoStakeDistributionSignableBuilder , CardanoTransactionsSignableBuilder ,
26
28
MithrilSignableBuilderService , MithrilStakeDistributionSignableBuilder ,
27
29
SignableBuilderServiceDependencies ,
28
30
} ;
29
31
use mithril_common:: StdResult ;
32
+ use mithril_common:: { api_version:: APIVersionProvider , messages:: RegisterSignatureMessageDmq } ;
30
33
31
34
use mithril_era:: { EraChecker , EraReader } ;
32
35
use mithril_signed_entity_lock:: SignedEntityTypeLock ;
@@ -37,10 +40,6 @@ use mithril_persistence::database::repository::CardanoTransactionRepository;
37
40
use mithril_persistence:: database:: { ApplicationNodeType , SqlMigration } ;
38
41
use mithril_persistence:: sqlite:: { ConnectionBuilder , SqliteConnection , SqliteConnectionPool } ;
39
42
40
- use crate :: database:: repository:: {
41
- ProtocolInitializerRepository , SignedBeaconRepository , StakePoolStore ,
42
- } ;
43
- use crate :: dependency_injection:: SignerDependencyContainer ;
44
43
use crate :: services:: {
45
44
AggregatorHTTPClient , CardanoTransactionsImporter ,
46
45
CardanoTransactionsPreloaderActivationSigner , MithrilEpochService , MithrilSingleSigner ,
@@ -50,6 +49,11 @@ use crate::services::{
50
49
TransactionsImporterWithPruner , TransactionsImporterWithVacuum ,
51
50
} ;
52
51
use crate :: store:: MKTreeStoreSqlite ;
52
+ use crate :: {
53
+ database:: repository:: { ProtocolInitializerRepository , SignedBeaconRepository , StakePoolStore } ,
54
+ services:: SignaturePublisher ,
55
+ } ;
56
+ use crate :: { dependency_injection:: SignerDependencyContainer , services:: SignaturePublisherDmq } ;
53
57
use crate :: {
54
58
Configuration , MetricsService , HTTP_REQUEST_TIMEOUT_DURATION , SQLITE_FILE ,
55
59
SQLITE_FILE_CARDANO_TRANSACTION ,
@@ -390,10 +394,46 @@ impl<'a> DependenciesBuilder<'a> {
390
394
self . root_logger ( ) ,
391
395
) ) ;
392
396
397
+ let kes_signer = match (
398
+ & self . config . kes_secret_key_path ,
399
+ & self . config . operational_certificate_path ,
400
+ ) {
401
+ ( Some ( kes_secret_key_path) , Some ( operational_certificate_path) ) => {
402
+ Some ( Arc :: new ( KesSignerStandard :: new (
403
+ kes_secret_key_path. clone ( ) ,
404
+ operational_certificate_path. clone ( ) ,
405
+ ) ) as Arc < dyn KesSigner > )
406
+ }
407
+ ( Some ( _) , None ) | ( None , Some ( _) ) => {
408
+ return Err ( anyhow ! (
409
+ "kes_secret_key and operational_certificate are both mandatory" . to_string( ) ,
410
+ ) )
411
+ }
412
+ _ => None ,
413
+ } ;
414
+
415
+ let cardano_network = & self . config . get_network ( ) ?;
416
+
393
417
let signature_publisher = {
394
- // Temporary no-op publisher before a DMQ-based implementation is available.
395
418
let first_publisher = SignaturePublisherRetrier :: new (
396
- Arc :: new ( SignaturePublisherNoop { } ) ,
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 >
436
+ } ,
397
437
SignaturePublishRetryPolicy :: never ( ) ,
398
438
) ;
399
439
@@ -442,6 +482,7 @@ impl<'a> DependenciesBuilder<'a> {
442
482
upkeep_service,
443
483
epoch_service,
444
484
certifier,
485
+ kes_signer,
445
486
} ;
446
487
447
488
Ok ( services)
0 commit comments