@@ -9,7 +9,7 @@ use mithril_common::entities::Epoch;
99use mithril_common:: messages:: ProtocolConfigurationMessage ;
1010
1111use crate :: interface:: MithrilNetworkConfigurationProvider ;
12- use crate :: model:: { MithrilNetworkConfiguration , SignedEntityTypeConfiguration } ;
12+ use crate :: model:: { EpochConfiguration , MithrilNetworkConfiguration } ;
1313
1414/// Trait to retrieve protocol configuration
1515#[ cfg_attr( test, mockall:: automock) ]
@@ -42,41 +42,41 @@ impl MithrilNetworkConfigurationProvider for HttpMithrilNetworkConfigurationProv
4242 & self ,
4343 epoch : Epoch ,
4444 ) -> StdResult < MithrilNetworkConfiguration > {
45- let signer_retrieval_epoch =
45+ let aggregation_epoch =
4646 epoch. offset_to_signer_retrieval_epoch ( ) . with_context ( || {
47- format ! ( "MithrilNetworkConfigurationProvider could not compute signer retrieval epoch from epoch: {epoch}" )
47+ format ! ( "MithrilNetworkConfigurationProvider could not compute aggregation epoch from epoch: {epoch}" )
4848 } ) ?;
49- let signer_registration_epoch = epoch. offset_to_next_signer_retrieval_epoch ( ) . next ( ) ;
49+ let next_aggregation_epoch = epoch. offset_to_next_signer_retrieval_epoch ( ) ;
50+ let registration_epoch = epoch. offset_to_next_signer_retrieval_epoch ( ) . next ( ) ;
5051
51- let protocol_configuration = self
52+ let configuration_for_aggregation : EpochConfiguration = self
5253 . protocol_configuration_retriever
53- . retrieve_protocol_configuration ( signer_retrieval_epoch)
54- . await ?;
54+ . retrieve_protocol_configuration ( aggregation_epoch)
55+ . await ?
56+ . into ( ) ;
5557
56- let signer_registration_protocol_configuration = self
58+ let configuration_for_next_aggregation = self
5759 . protocol_configuration_retriever
58- . retrieve_protocol_configuration ( signer_registration_epoch)
59- . await ?;
60+ . retrieve_protocol_configuration ( next_aggregation_epoch)
61+ . await ?
62+ . into ( ) ;
6063
61- let enabled_signed_entity_types =
62- protocol_configuration. available_signed_entity_types . clone ( ) ;
64+ let configuration_for_registration = self
65+ . protocol_configuration_retriever
66+ . retrieve_protocol_configuration ( registration_epoch)
67+ . await ?
68+ . into ( ) ;
6369
64- let cardano_transactions = protocol_configuration
65- . cardano_transactions_signing_config
70+ configuration_for_aggregation. signed_entity_types_config . cardano_transactions . clone ( )
6671 . ok_or_else ( || {
67- anyhow ! ( format!( "Cardano transactions signing config is missing in protocol configuration for epoch {epoch}" ) )
72+ anyhow ! ( format!( "Cardano transactions signing config is missing in aggregation configuration for epoch {epoch}" ) )
6873 } ) ?;
6974
70- let signed_entity_types_config = SignedEntityTypeConfiguration {
71- cardano_transactions : Some ( cardano_transactions) ,
72- } ;
73-
7475 Ok ( MithrilNetworkConfiguration {
7576 epoch,
76- signer_registration_protocol_parameters : signer_registration_protocol_configuration
77- . protocol_parameters ,
78- enabled_signed_entity_types,
79- signed_entity_types_config,
77+ configuration_for_aggregation,
78+ configuration_for_next_aggregation,
79+ configuration_for_registration,
8080 } )
8181 }
8282}
@@ -87,7 +87,7 @@ mod tests {
8787 use std:: sync:: Arc ;
8888
8989 use mithril_common:: {
90- entities:: { BlockNumber , CardanoTransactionsSigningConfig , Epoch , ProtocolParameters } ,
90+ entities:: { Epoch , ProtocolParameters } ,
9191 messages:: ProtocolConfigurationMessage ,
9292 test:: double:: Dummy ,
9393 } ;
@@ -100,7 +100,8 @@ mod tests {
100100 } ;
101101
102102 #[ tokio:: test]
103- async fn test_get_network_configuration_retrieve_signer_protocol_parameters_from_next_epoch ( ) {
103+ async fn test_get_network_configuration_retrieve_configurations_for_aggregation_next_aggregation_and_registration ( )
104+ {
104105 let mut protocol_configuration_retriever = MockProtocolConfigurationRetriever :: new ( ) ;
105106
106107 protocol_configuration_retriever
@@ -117,58 +118,21 @@ mod tests {
117118 protocol_configuration_retriever
118119 . expect_retrieve_protocol_configuration ( )
119120 . once ( )
120- . with ( eq ( Epoch ( 43 ) ) )
121+ . with ( eq ( Epoch ( 42 ) ) )
121122 . returning ( |_| {
122123 Ok ( ProtocolConfigurationMessage {
123124 protocol_parameters : ProtocolParameters :: new ( 2000 , 200 , 0.2 ) ,
124125 ..Dummy :: dummy ( )
125126 } )
126127 } ) ;
127128
128- let mithril_configuration_provider = HttpMithrilNetworkConfigurationProvider :: new (
129- Arc :: new ( protocol_configuration_retriever) ,
130- ) ;
131-
132- let configuration = mithril_configuration_provider
133- . get_network_configuration ( Epoch ( 42 ) )
134- . await
135- . expect ( "should have configuration" ) ;
136-
137- assert_eq ! (
138- configuration. signer_registration_protocol_parameters,
139- ProtocolParameters :: new( 2000 , 200 , 0.2 )
140- ) ;
141- }
142-
143- #[ tokio:: test]
144- async fn test_get_network_configuration_retrieve_cardano_transaction_config_from_previous_epoch ( )
145- {
146- let mut protocol_configuration_retriever = MockProtocolConfigurationRetriever :: new ( ) ;
147-
148- protocol_configuration_retriever
149- . expect_retrieve_protocol_configuration ( )
150- . once ( )
151- . with ( eq ( Epoch ( 41 ) ) )
152- . returning ( |_| {
153- Ok ( ProtocolConfigurationMessage {
154- cardano_transactions_signing_config : Some ( CardanoTransactionsSigningConfig {
155- security_parameter : BlockNumber ( 111 ) ,
156- step : BlockNumber ( 222 ) ,
157- } ) ,
158- ..Dummy :: dummy ( )
159- } )
160- } ) ;
161-
162129 protocol_configuration_retriever
163130 . expect_retrieve_protocol_configuration ( )
164131 . once ( )
165132 . with ( eq ( Epoch ( 43 ) ) )
166133 . returning ( |_| {
167134 Ok ( ProtocolConfigurationMessage {
168- cardano_transactions_signing_config : Some ( CardanoTransactionsSigningConfig {
169- security_parameter : BlockNumber ( 333 ) ,
170- step : BlockNumber ( 444 ) ,
171- } ) ,
135+ protocol_parameters : ProtocolParameters :: new ( 3000 , 300 , 0.3 ) ,
172136 ..Dummy :: dummy ( )
173137 } )
174138 } ) ;
@@ -182,17 +146,9 @@ mod tests {
182146 . await
183147 . expect ( "should have configuration" ) ;
184148
185- let actual_cardano_transations = configuration
186- . signed_entity_types_config
187- . cardano_transactions
188- . expect ( "should have cardano_transactions" ) ;
189-
190149 assert_eq ! (
191- actual_cardano_transations,
192- CardanoTransactionsSigningConfig {
193- security_parameter: BlockNumber ( 111 ) ,
194- step: BlockNumber ( 222 ) ,
195- }
150+ configuration. configuration_for_registration. protocol_parameters,
151+ ProtocolParameters :: new( 3000 , 300 , 0.3 )
196152 ) ;
197153 }
198154}
0 commit comments