@@ -2,7 +2,7 @@ use crate::utils::AttemptResult;
2
2
use crate :: { attempt, Aggregator , Client , ClientCommand , Devnet , MithrilInfrastructure } ;
3
3
use mithril_common:: chain_observer:: { CardanoCliChainObserver , ChainObserver } ;
4
4
use mithril_common:: digesters:: ImmutableFile ;
5
- use mithril_common:: entities:: { Certificate , Epoch , EpochSettings , Snapshot } ;
5
+ use mithril_common:: entities:: { Certificate , Epoch , EpochSettings , ProtocolParameters , Snapshot } ;
6
6
use reqwest:: StatusCode ;
7
7
use slog_scope:: { info, warn} ;
8
8
use std:: error:: Error ;
@@ -41,7 +41,7 @@ impl Spec {
41
41
bootstrap_genesis_certificate ( self . infrastructure . aggregator_mut ( ) ) . await ?;
42
42
wait_for_epoch_settings ( & aggregator_endpoint) . await ?;
43
43
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
45
45
target_epoch += 2 ;
46
46
wait_for_target_epoch (
47
47
self . infrastructure . chain_observer ( ) ,
@@ -51,12 +51,22 @@ impl Spec {
51
51
. await ?;
52
52
delegate_stakes_to_pools ( self . infrastructure . devnet ( ) ) . await ?;
53
53
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 ;
56
56
wait_for_target_epoch (
57
57
self . infrastructure . chain_observer ( ) ,
58
58
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 ( ) ,
60
70
)
61
71
. await ?;
62
72
@@ -177,7 +187,7 @@ async fn wait_for_target_epoch(
177
187
}
178
188
} ) {
179
189
AttemptResult :: Ok ( _) => {
180
- info ! ( "Target epoch reached !" ; "target_epoch" => ?target_epoch) ;
190
+ info ! ( "Target epoch reached!" ; "target_epoch" => ?target_epoch) ;
181
191
Ok ( ( ) )
182
192
}
183
193
AttemptResult :: Err ( error) => Err ( error) ,
@@ -194,7 +204,7 @@ async fn bootstrap_genesis_certificate(aggregator: &mut Aggregator) -> Result<()
194
204
195
205
info ! ( "> stopping aggregator" ) ;
196
206
aggregator. stop ( ) . await ?;
197
- info ! ( "> bootstrapping genesis using signers registered two epochs ago ..." ) ;
207
+ info ! ( "> bootstrapping genesis using signers registered two epochs ago..." ) ;
198
208
aggregator. bootstrap_genesis ( ) . await ?;
199
209
info ! ( "> done, restarting aggregator" ) ;
200
210
aggregator. serve ( ) ?;
@@ -210,6 +220,27 @@ async fn delegate_stakes_to_pools(devnet: &Devnet) -> Result<(), String> {
210
220
Ok ( ( ) )
211
221
}
212
222
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
+
213
244
async fn assert_node_producing_snapshot ( aggregator_endpoint : & str ) -> Result < String , String > {
214
245
let url = format ! ( "{}/snapshots" , aggregator_endpoint) ;
215
246
info ! ( "Waiting for the aggregator to produce a snapshot" ) ;
0 commit comments