1
+ use crate :: mithril:: relay_signer:: RelaySignerConfiguration ;
2
+ use crate :: {
3
+ assertions, Aggregator , AggregatorConfig , Client , Devnet , PoolNode , RelayAggregator ,
4
+ RelayPassive , RelaySigner , Signer , DEVNET_MAGIC_ID ,
5
+ } ;
1
6
use mithril_common:: chain_observer:: { ChainObserver , PallasChainObserver } ;
2
7
use mithril_common:: entities:: { Epoch , PartyId , ProtocolParameters } ;
3
8
use mithril_common:: { CardanoNetwork , StdResult } ;
9
+ use mithril_relay:: SignerRelayMode ;
4
10
use slog_scope:: info;
5
11
use std:: fs;
6
12
use std:: path:: PathBuf ;
7
13
use std:: sync:: Arc ;
8
14
use tokio:: sync:: RwLock ;
9
15
10
- use crate :: {
11
- assertions, Aggregator , AggregatorConfig , Client , Devnet , PoolNode , RelayAggregator ,
12
- RelayPassive , RelaySigner , Signer , DEVNET_MAGIC_ID ,
13
- } ;
14
-
15
16
use super :: signer:: SignerConfig ;
16
17
17
18
pub struct MithrilInfrastructureConfig {
@@ -29,7 +30,9 @@ pub struct MithrilInfrastructureConfig {
29
30
pub mithril_era_reader_adapter : String ,
30
31
pub signed_entity_types : Vec < String > ,
31
32
pub run_only_mode : bool ,
32
- pub use_p2p_network_mode : bool ,
33
+ pub use_relays : bool ,
34
+ pub relay_signer_registration_mode : SignerRelayMode ,
35
+ pub relay_signature_registration_mode : SignerRelayMode ,
33
36
pub use_p2p_passive_relays : bool ,
34
37
pub use_era_specific_work_dir : bool ,
35
38
}
@@ -64,6 +67,8 @@ impl MithrilInfrastructure {
64
67
. iter ( )
65
68
. map ( |s| s. party_id ( ) )
66
69
. collect :: < StdResult < Vec < PartyId > > > ( ) ?;
70
+ let relay_signer_registration_mode = & config. relay_signer_registration_mode ;
71
+ let relay_signature_registration_mode = & config. relay_signature_registration_mode ;
67
72
68
73
let aggregators =
69
74
Self :: start_aggregators ( config, aggregator_cardano_nodes, chain_observer_type) . await ?;
@@ -73,8 +78,13 @@ impl MithrilInfrastructure {
73
78
. collect :: < Vec < _ > > ( ) ;
74
79
let master_aggregator_endpoint = aggregator_endpoints[ 0 ] . to_owned ( ) ;
75
80
76
- let ( relay_aggregators, relay_signers, relay_passives) =
77
- Self :: start_relays ( config, & aggregator_endpoints, & signer_party_ids) ?;
81
+ let ( relay_aggregators, relay_signers, relay_passives) = Self :: start_relays (
82
+ config,
83
+ & aggregator_endpoints,
84
+ & signer_party_ids,
85
+ relay_signer_registration_mode. to_owned ( ) ,
86
+ relay_signature_registration_mode. to_owned ( ) ,
87
+ ) ?;
78
88
79
89
let signers = Self :: start_signers (
80
90
config,
@@ -219,8 +229,10 @@ impl MithrilInfrastructure {
219
229
config : & MithrilInfrastructureConfig ,
220
230
aggregator_endpoints : & [ String ] ,
221
231
signers_party_ids : & [ PartyId ] ,
232
+ relay_signer_registration_mode : SignerRelayMode ,
233
+ relay_signature_registration_mode : SignerRelayMode ,
222
234
) -> StdResult < ( Vec < RelayAggregator > , Vec < RelaySigner > , Vec < RelayPassive > ) > {
223
- if !config. use_p2p_network_mode {
235
+ if !config. use_relays {
224
236
return Ok ( ( vec ! [ ] , vec ! [ ] , vec ! [ ] ) ) ;
225
237
}
226
238
@@ -249,15 +261,17 @@ impl MithrilInfrastructure {
249
261
}
250
262
251
263
for ( index, party_id) in signers_party_ids. iter ( ) . enumerate ( ) {
252
- let mut relay_signer = RelaySigner :: new (
253
- config. server_port + index as u64 + 200 ,
254
- config. server_port + index as u64 + 300 ,
255
- bootstrap_peer_addr. clone ( ) ,
256
- master_aggregator_endpoint,
257
- party_id. clone ( ) ,
258
- & config. work_dir ,
259
- & config. bin_dir ,
260
- ) ?;
264
+ let mut relay_signer = RelaySigner :: new ( & RelaySignerConfiguration {
265
+ listen_port : config. server_port + index as u64 + 200 ,
266
+ server_port : config. server_port + index as u64 + 300 ,
267
+ dial_to : bootstrap_peer_addr. clone ( ) ,
268
+ relay_signer_registration_mode : relay_signer_registration_mode. clone ( ) ,
269
+ relay_signature_registration_mode : relay_signature_registration_mode. clone ( ) ,
270
+ aggregator_endpoint : master_aggregator_endpoint,
271
+ party_id : party_id. clone ( ) ,
272
+ work_dir : & config. work_dir ,
273
+ bin_dir : & config. bin_dir ,
274
+ } ) ?;
261
275
relay_signer. start ( ) ?;
262
276
263
277
relay_signers. push ( relay_signer) ;
@@ -308,7 +322,7 @@ impl MithrilInfrastructure {
308
322
// Or 100% of signers otherwise
309
323
let enable_certification =
310
324
index % 2 == 0 || cfg ! ( not( feature = "allow_skip_signer_certification" ) ) ;
311
- let aggregator_endpoint = if config. use_p2p_network_mode {
325
+ let aggregator_endpoint = if config. use_relays {
312
326
relay_signers[ index] . endpoint ( )
313
327
} else {
314
328
master_aggregator_endpoint. clone ( )
0 commit comments