@@ -5,9 +5,8 @@ use std::{collections::HashMap, ops::Range};
55use mithril_aggregator:: ServeCommandConfiguration ;
66use mithril_common:: {
77 entities:: {
8- BlockNumber , CardanoTransactionsSigningConfig , ChainPoint , Epoch , ProtocolParameters ,
9- SignedEntityType , SignedEntityTypeDiscriminants , SlotNumber , StakeDistributionParty ,
10- TimePoint ,
8+ BlockNumber , ChainPoint , Epoch , ProtocolParameters , SignedEntityType ,
9+ SignedEntityTypeDiscriminants , SlotNumber , StakeDistributionParty , TimePoint ,
1110 } ,
1211 temp_dir,
1312 test_utils:: {
@@ -86,7 +85,7 @@ async fn create_certificate_follower() {
8685 phi_f : 0.95 ,
8786 } ;
8887 let fixtures =
89- EpochFixturesMapBuilder :: build_fixtures_sequence ( 1 ..10 , protocol_parameters. clone ( ) ) ;
88+ EpochFixturesMapBuilder :: build_fixtures_sequence ( 1 ..6 , protocol_parameters. clone ( ) ) ;
9089 let epoch_fixtures_map = EpochFixturesMapBuilder :: build_epoch_fixtures_map ( & fixtures) ;
9190 let start_time_point = TimePoint {
9291 epoch : Epoch ( 1 ) ,
@@ -100,11 +99,9 @@ async fn create_certificate_follower() {
10099 let leader_configuration = ServeCommandConfiguration {
101100 protocol_parameters : protocol_parameters. clone ( ) ,
102101 data_stores_directory : get_test_dir ( "create_certificate_leader" ) ,
103- cardano_transactions_signing_config : CardanoTransactionsSigningConfig {
104- security_parameter : BlockNumber ( 0 ) ,
105- step : BlockNumber ( 30 ) ,
106- } ,
107- signed_entity_types : Some ( SignedEntityTypeDiscriminants :: CardanoDatabase . to_string ( ) ) ,
102+ signed_entity_types : Some (
103+ SignedEntityTypeDiscriminants :: CardanoStakeDistribution . to_string ( ) ,
104+ ) ,
108105 ..ServeCommandConfiguration :: new_sample ( temp_dir ! ( ) )
109106 } ;
110107 let mut leader_tester =
@@ -127,6 +124,7 @@ async fn create_certificate_follower() {
127124 "Epoch 1:
128125 - the leader aggregator registers the first signers
129126 - the leader aggregator can't transition from 'Idle' to 'Ready'
127+ - the follower can't synchronise its chain with the leader aggregator
130128 - the follower aggregator can't transition from 'Idle' to 'Ready'
131129 "
132130 ) ;
@@ -211,7 +209,8 @@ async fn create_certificate_follower() {
211209 "Epoch 3:
212210 - the leader aggregator produces a new certificate
213211 - the follower aggregator synchronizes signers from the leader aggregator
214- - the follower aggregator can't transition from 'Idle' to 'Ready'
212+ - the follower synchronise its chain with the leader aggregator
213+ - the follower aggregator can transition from 'Idle' to 'Ready'
215214 "
216215 ) ;
217216 let epoch_fixture = & epoch_fixtures_map[ & Epoch ( 3 ) ] ;
@@ -233,10 +232,6 @@ async fn create_certificate_follower() {
233232 cycle ! ( leader_tester, "ready" ) ;
234233 cycle ! ( leader_tester, "signing" ) ;
235234
236- comment ! ( "Follower: change the epoch after leader" ) ;
237- follower_tester. increase_epoch ( ) . await . unwrap ( ) ;
238- cycle_err ! ( follower_tester, "idle" ) ;
239-
240235 comment ! ( "Leader: register signers" ) ;
241236 leader_tester
242237 . register_signers ( & epoch_fixture. registering . signers_fixture ( ) )
@@ -256,27 +251,36 @@ async fn create_certificate_follower() {
256251 comment ! ( "Leader: state machine should issue a certificate for the MithrilStakeDistribution" ) ;
257252 cycle ! ( leader_tester, "signing" ) ;
258253
259- assert_last_certificate_eq ! (
260- leader_tester,
261- ExpectedCertificate :: new(
262- Epoch ( 3 ) ,
263- StakeDistributionParty :: from_signers(
264- epoch_fixture. current_signing. unwrap( ) . signers_with_stake( )
265- )
266- . as_slice( ) ,
267- epoch_fixture. current_signing. unwrap( ) . compute_and_encode_avk( ) ,
268- SignedEntityType :: MithrilStakeDistribution ( Epoch ( 3 ) ) ,
269- ExpectedCertificate :: genesis_identifier( Epoch ( 2 ) ) ,
254+ let expected_certificate_on_both_aggregator = ExpectedCertificate :: new (
255+ Epoch ( 3 ) ,
256+ StakeDistributionParty :: from_signers (
257+ epoch_fixture. current_signing . unwrap ( ) . signers_with_stake ( ) ,
270258 )
259+ . as_slice ( ) ,
260+ epoch_fixture. current_signing . unwrap ( ) . compute_and_encode_avk ( ) ,
261+ SignedEntityType :: MithrilStakeDistribution ( Epoch ( 3 ) ) ,
262+ ExpectedCertificate :: genesis_identifier ( Epoch ( 2 ) ) ,
263+ ) ;
264+ assert_last_certificate_eq ! ( leader_tester, expected_certificate_on_both_aggregator) ;
265+ cycle_err ! ( leader_tester, "signing" ) ;
266+
267+ comment ! (
268+ "Follower: change the epoch after leader made a certificate and synchronise certificate chain"
269+ ) ;
270+ follower_tester. increase_epoch ( ) . await . unwrap ( ) ;
271+ cycle_err ! ( follower_tester, "idle" ) ;
272+ assert_last_certificate_eq ! (
273+ follower_tester, synchronised_from_leader => expected_certificate_on_both_aggregator
271274 ) ;
275+ cycle ! ( follower_tester, "ready" ) ;
272276 cycle_err ! ( leader_tester, "signing" ) ;
273277
274278 comment ! (
275279 "Epoch 4:
276280 - the leader aggregator produces a new certificate
277281 - the follower aggregator synchronizes signers from the leader aggregator
278- - the follower aggregator bootstraps its genesis certificate
279- - the follower aggregator can't transition from 'Idle' to 'Ready' "
282+ - the follower aggregator produces a new certificate
283+ - the follower aggregator new certificate uses the same avk as the leader aggregator's new certificate "
280284 ) ;
281285 let epoch_fixture = & epoch_fixtures_map[ & Epoch ( 4 ) ] ;
282286
@@ -299,13 +303,8 @@ async fn create_certificate_follower() {
299303
300304 comment ! ( "Follower: change the epoch after leader" ) ;
301305 follower_tester. increase_epoch ( ) . await . unwrap ( ) ;
302- cycle_err ! ( follower_tester, "idle" ) ;
303-
304- comment ! ( "Follower: bootstrap the genesis certificate" ) ;
305- follower_tester
306- . register_genesis_certificate ( epoch_fixture. next_signing . unwrap ( ) )
307- . await
308- . unwrap ( ) ;
306+ cycle ! ( follower_tester, "idle" ) ;
307+ cycle ! ( follower_tester, "ready" ) ;
309308
310309 comment ! ( "Leader: register signers" ) ;
311310 leader_tester
@@ -326,69 +325,19 @@ async fn create_certificate_follower() {
326325 comment ! ( "Leader: state machine should issue a certificate for the MithrilStakeDistribution" ) ;
327326 cycle ! ( leader_tester, "ready" ) ;
328327
329- assert_last_certificate_eq ! (
330- leader_tester,
331- ExpectedCertificate :: new(
332- Epoch ( 4 ) ,
333- StakeDistributionParty :: from_signers(
334- epoch_fixture. current_signing. unwrap( ) . signers_with_stake( )
335- )
336- . as_slice( ) ,
337- epoch_fixture. current_signing. unwrap( ) . compute_and_encode_avk( ) ,
338- SignedEntityType :: MithrilStakeDistribution ( Epoch ( 4 ) ) ,
339- ExpectedCertificate :: identifier( & SignedEntityType :: MithrilStakeDistribution ( Epoch ( 3 ) ) ) ,
328+ let leader_expected_certificate = ExpectedCertificate :: new (
329+ Epoch ( 4 ) ,
330+ StakeDistributionParty :: from_signers (
331+ epoch_fixture. current_signing . unwrap ( ) . signers_with_stake ( ) ,
340332 )
333+ . as_slice ( ) ,
334+ epoch_fixture. current_signing . unwrap ( ) . compute_and_encode_avk ( ) ,
335+ SignedEntityType :: MithrilStakeDistribution ( Epoch ( 4 ) ) ,
336+ ExpectedCertificate :: identifier ( & SignedEntityType :: MithrilStakeDistribution ( Epoch ( 3 ) ) ) ,
341337 ) ;
338+ assert_last_certificate_eq ! ( leader_tester, leader_expected_certificate) ;
342339 cycle ! ( leader_tester, "signing" ) ;
343340
344- comment ! (
345- "Epoch 5:
346- - the leader aggregator produces a new certificate
347- - the follower aggregator produces a new certificate
348- - the follower aggregator new certificate uses the same avk as the leader aggregator's new certificate
349- " ) ;
350- let epoch_fixture = & epoch_fixtures_map[ & Epoch ( 5 ) ] ;
351-
352- comment ! ( "Leader: update stake distribution source" ) ;
353- leader_tester
354- . update_stake_distribution ( epoch_fixture. registering . stake_distribution ( ) )
355- . await
356- . unwrap ( ) ;
357-
358- comment ! ( "Follower: update stake distribution source" ) ;
359- follower_tester
360- . update_stake_distribution ( epoch_fixture. registering . stake_distribution ( ) )
361- . await
362- . unwrap ( ) ;
363-
364- comment ! ( "Follower: change the epoch before leader" ) ;
365- follower_tester. increase_epoch ( ) . await . unwrap ( ) ;
366- cycle ! ( follower_tester, "idle" ) ;
367-
368- comment ! ( "Leader: change the epoch" ) ;
369- leader_tester. increase_epoch ( ) . await . unwrap ( ) ;
370- cycle ! ( leader_tester, "idle" ) ;
371- cycle ! ( leader_tester, "ready" ) ;
372-
373- comment ! ( "Follower: change the epoch after leader" ) ;
374- cycle ! ( follower_tester, "ready" ) ;
375-
376- comment ! ( "Leader: register signers" ) ;
377- leader_tester
378- . register_signers ( & epoch_fixture. registering . signers_fixture ( ) )
379- . await
380- . unwrap ( ) ;
381- cycle ! ( leader_tester, "signing" ) ;
382-
383- comment ! ( "Leader: signers send their single signature" ) ;
384- leader_tester
385- . send_single_signatures (
386- SignedEntityTypeDiscriminants :: MithrilStakeDistribution ,
387- & epoch_fixture. current_signing . unwrap ( ) . signers_fixture ( ) ,
388- )
389- . await
390- . unwrap ( ) ;
391-
392341 comment ! ( "Follower: signers send their single signature" ) ;
393342 cycle ! ( follower_tester, "signing" ) ;
394343 follower_tester
@@ -399,31 +348,17 @@ async fn create_certificate_follower() {
399348 . await
400349 . unwrap ( ) ;
401350
402- comment ! ( "Leader: state machine should issue a certificate for the MithrilStakeDistribution" ) ;
403- cycle ! ( leader_tester, "ready" ) ;
404- let leader_expected_certificate = ExpectedCertificate :: new (
405- Epoch ( 5 ) ,
406- StakeDistributionParty :: from_signers (
407- epoch_fixture. current_signing . unwrap ( ) . signers_with_stake ( ) ,
408- )
409- . as_slice ( ) ,
410- epoch_fixture. current_signing . unwrap ( ) . compute_and_encode_avk ( ) ,
411- SignedEntityType :: MithrilStakeDistribution ( Epoch ( 5 ) ) ,
412- ExpectedCertificate :: identifier ( & SignedEntityType :: MithrilStakeDistribution ( Epoch ( 4 ) ) ) ,
413- ) ;
414- assert_last_certificate_eq ! ( leader_tester, leader_expected_certificate) ;
415-
416351 comment ! ( "Follower: state machine should issue a certificate for the MithrilStakeDistribution" ) ;
417352 cycle ! ( follower_tester, "ready" ) ;
418353 let follower_expected_certificate = ExpectedCertificate :: new (
419- Epoch ( 5 ) ,
354+ Epoch ( 4 ) ,
420355 StakeDistributionParty :: from_signers (
421356 epoch_fixture. current_signing . unwrap ( ) . signers_with_stake ( ) ,
422357 )
423358 . as_slice ( ) ,
424359 epoch_fixture. current_signing . unwrap ( ) . compute_and_encode_avk ( ) ,
425- SignedEntityType :: MithrilStakeDistribution ( Epoch ( 5 ) ) ,
426- ExpectedCertificate :: genesis_identifier ( Epoch ( 4 ) ) ,
360+ SignedEntityType :: MithrilStakeDistribution ( Epoch ( 4 ) ) ,
361+ ExpectedCertificate :: identifier ( & SignedEntityType :: MithrilStakeDistribution ( Epoch ( 3 ) ) ) ,
427362 ) ;
428363 assert_last_certificate_eq ! ( follower_tester, follower_expected_certificate) ;
429364 let expected_avk = epoch_fixture
@@ -435,12 +370,12 @@ async fn create_certificate_follower() {
435370 assert_eq ! ( expected_avk, follower_expected_certificate. avk( ) ) ;
436371
437372 comment ! (
438- "Epoch 6 :
373+ "Epoch 5 :
439374 - the leader aggregator produces a new certificate
440375 - the follower aggregator produces a new certificate
441376 - the follower aggregator new certificate uses the same avk as the leader aggregator's new certificate
442377 " ) ;
443- let epoch_fixture = & epoch_fixtures_map[ & Epoch ( 6 ) ] ;
378+ let epoch_fixture = & epoch_fixtures_map[ & Epoch ( 5 ) ] ;
444379
445380 comment ! ( "Leader: update stake distribution source" ) ;
446381 leader_tester
@@ -493,28 +428,28 @@ async fn create_certificate_follower() {
493428 comment ! ( "Leader: state machine should issue a certificate for the MithrilStakeDistribution" ) ;
494429 cycle ! ( leader_tester, "ready" ) ;
495430 let leader_expected_certificate = ExpectedCertificate :: new (
496- Epoch ( 6 ) ,
431+ Epoch ( 5 ) ,
497432 StakeDistributionParty :: from_signers (
498433 epoch_fixture. current_signing . unwrap ( ) . signers_with_stake ( ) ,
499434 )
500435 . as_slice ( ) ,
501436 epoch_fixture. current_signing . unwrap ( ) . compute_and_encode_avk ( ) ,
502- SignedEntityType :: MithrilStakeDistribution ( Epoch ( 6 ) ) ,
503- ExpectedCertificate :: identifier ( & SignedEntityType :: MithrilStakeDistribution ( Epoch ( 5 ) ) ) ,
437+ SignedEntityType :: MithrilStakeDistribution ( Epoch ( 5 ) ) ,
438+ ExpectedCertificate :: identifier ( & SignedEntityType :: MithrilStakeDistribution ( Epoch ( 4 ) ) ) ,
504439 ) ;
505440 assert_last_certificate_eq ! ( leader_tester, leader_expected_certificate) ;
506441
507442 comment ! ( "Follower: state machine should issue a certificate for the MithrilStakeDistribution" ) ;
508443 cycle ! ( follower_tester, "ready" ) ;
509444 let follower_expected_certificate = ExpectedCertificate :: new (
510- Epoch ( 6 ) ,
445+ Epoch ( 5 ) ,
511446 StakeDistributionParty :: from_signers (
512447 epoch_fixture. current_signing . unwrap ( ) . signers_with_stake ( ) ,
513448 )
514449 . as_slice ( ) ,
515450 epoch_fixture. current_signing . unwrap ( ) . compute_and_encode_avk ( ) ,
516- SignedEntityType :: MithrilStakeDistribution ( Epoch ( 6 ) ) ,
517- ExpectedCertificate :: identifier ( & SignedEntityType :: MithrilStakeDistribution ( Epoch ( 5 ) ) ) ,
451+ SignedEntityType :: MithrilStakeDistribution ( Epoch ( 5 ) ) ,
452+ ExpectedCertificate :: identifier ( & SignedEntityType :: MithrilStakeDistribution ( Epoch ( 4 ) ) ) ,
518453 ) ;
519454 assert_last_certificate_eq ! ( follower_tester, follower_expected_certificate) ;
520455 let expected_avk = epoch_fixture
0 commit comments