@@ -2,7 +2,7 @@ use crate::utils::AttemptResult;
22use crate :: { attempt, Aggregator , Client , ClientCommand , Devnet , MithrilInfrastructure } ;
33use mithril_common:: chain_observer:: { CardanoCliChainObserver , ChainObserver } ;
44use mithril_common:: digesters:: ImmutableFile ;
5- use mithril_common:: entities:: { Certificate , Epoch , EpochSettings , Snapshot } ;
5+ use mithril_common:: entities:: { Certificate , Epoch , EpochSettings , ProtocolParameters , Snapshot } ;
66use reqwest:: StatusCode ;
77use slog_scope:: { info, warn} ;
88use std:: error:: Error ;
@@ -41,7 +41,7 @@ impl Spec {
4141 bootstrap_genesis_certificate ( self . infrastructure . aggregator_mut ( ) ) . await ?;
4242 wait_for_epoch_settings ( & aggregator_endpoint) . await ?;
4343
44- // Wait 2 epochs before changing stake distribution, so that we use at least once original stake distribution
44+ // Wait 2 epochs before changing stake distribution, so that we use at least one original stake distribution
4545 target_epoch += 2 ;
4646 wait_for_target_epoch (
4747 self . infrastructure . chain_observer ( ) ,
@@ -51,12 +51,22 @@ impl Spec {
5151 . await ?;
5252 delegate_stakes_to_pools ( self . infrastructure . devnet ( ) ) . await ?;
5353
54- // Wait 5 epochs after stake delegation, so that we make sure that we use new stake distribution a few times
55- target_epoch += 5 ;
54+ // Wait 2 epochs before changing protocol parameters
55+ target_epoch += 2 ;
5656 wait_for_target_epoch (
5757 self . infrastructure . chain_observer ( ) ,
5858 target_epoch,
59- "epoch after which the certificate chain will be long enough to catch most common troubles" . to_string ( ) ,
59+ "epoch after which the protocol parameters will change" . to_string ( ) ,
60+ )
61+ . await ?;
62+ update_protocol_parameters ( self . infrastructure . aggregator_mut ( ) ) . await ?;
63+
64+ // Wait 4 epochs after protocol parameters update, so that we make sure that we use new protocol parameters as well as new stake distribution a few times
65+ target_epoch += 4 ;
66+ wait_for_target_epoch (
67+ self . infrastructure . chain_observer ( ) ,
68+ target_epoch,
69+ "epoch after which the certificate chain will be long enough to catch most common troubles with stake distribution and protocol parameters" . to_string ( ) ,
6070 )
6171 . await ?;
6272
@@ -177,7 +187,7 @@ async fn wait_for_target_epoch(
177187 }
178188 } ) {
179189 AttemptResult :: Ok ( _) => {
180- info ! ( "Target epoch reached !" ; "target_epoch" => ?target_epoch) ;
190+ info ! ( "Target epoch reached!" ; "target_epoch" => ?target_epoch) ;
181191 Ok ( ( ) )
182192 }
183193 AttemptResult :: Err ( error) => Err ( error) ,
@@ -194,7 +204,7 @@ async fn bootstrap_genesis_certificate(aggregator: &mut Aggregator) -> Result<()
194204
195205 info ! ( "> stopping aggregator" ) ;
196206 aggregator. stop ( ) . await ?;
197- info ! ( "> bootstrapping genesis using signers registered two epochs ago ..." ) ;
207+ info ! ( "> bootstrapping genesis using signers registered two epochs ago..." ) ;
198208 aggregator. bootstrap_genesis ( ) . await ?;
199209 info ! ( "> done, restarting aggregator" ) ;
200210 aggregator. serve ( ) ?;
@@ -210,6 +220,27 @@ async fn delegate_stakes_to_pools(devnet: &Devnet) -> Result<(), String> {
210220 Ok ( ( ) )
211221}
212222
223+ async fn update_protocol_parameters ( aggregator : & mut Aggregator ) -> Result < ( ) , String > {
224+ info ! ( "Update protocol parameters" ) ;
225+
226+ info ! ( "> stopping aggregator" ) ;
227+ aggregator. stop ( ) . await ?;
228+ let protocol_parameters_new = ProtocolParameters {
229+ k : 150 ,
230+ m : 200 ,
231+ phi_f : 0.95 ,
232+ } ;
233+ info ! (
234+ "> updating protocol parameters to {:?}..." ,
235+ protocol_parameters_new
236+ ) ;
237+ aggregator. set_protocol_parameters ( & protocol_parameters_new) ;
238+ info ! ( "> done, restarting aggregator" ) ;
239+ aggregator. serve ( ) ?;
240+
241+ Ok ( ( ) )
242+ }
243+
213244async fn assert_node_producing_snapshot ( aggregator_endpoint : & str ) -> Result < String , String > {
214245 let url = format ! ( "{}/snapshots" , aggregator_endpoint) ;
215246 info ! ( "Waiting for the aggregator to produce a snapshot" ) ;
0 commit comments