@@ -5,9 +5,8 @@ use std::{collections::HashMap, ops::Range};
5
5
use mithril_aggregator:: ServeCommandConfiguration ;
6
6
use mithril_common:: {
7
7
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 ,
11
10
} ,
12
11
temp_dir,
13
12
test_utils:: {
@@ -86,7 +85,7 @@ async fn create_certificate_follower() {
86
85
phi_f : 0.95 ,
87
86
} ;
88
87
let fixtures =
89
- EpochFixturesMapBuilder :: build_fixtures_sequence ( 1 ..10 , protocol_parameters. clone ( ) ) ;
88
+ EpochFixturesMapBuilder :: build_fixtures_sequence ( 1 ..6 , protocol_parameters. clone ( ) ) ;
90
89
let epoch_fixtures_map = EpochFixturesMapBuilder :: build_epoch_fixtures_map ( & fixtures) ;
91
90
let start_time_point = TimePoint {
92
91
epoch : Epoch ( 1 ) ,
@@ -100,11 +99,9 @@ async fn create_certificate_follower() {
100
99
let leader_configuration = ServeCommandConfiguration {
101
100
protocol_parameters : protocol_parameters. clone ( ) ,
102
101
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
+ ) ,
108
105
..ServeCommandConfiguration :: new_sample ( temp_dir ! ( ) )
109
106
} ;
110
107
let mut leader_tester =
@@ -127,6 +124,7 @@ async fn create_certificate_follower() {
127
124
"Epoch 1:
128
125
- the leader aggregator registers the first signers
129
126
- the leader aggregator can't transition from 'Idle' to 'Ready'
127
+ - the follower can't synchronise its chain with the leader aggregator
130
128
- the follower aggregator can't transition from 'Idle' to 'Ready'
131
129
"
132
130
) ;
@@ -211,7 +209,8 @@ async fn create_certificate_follower() {
211
209
"Epoch 3:
212
210
- the leader aggregator produces a new certificate
213
211
- 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'
215
214
"
216
215
) ;
217
216
let epoch_fixture = & epoch_fixtures_map[ & Epoch ( 3 ) ] ;
@@ -233,10 +232,6 @@ async fn create_certificate_follower() {
233
232
cycle ! ( leader_tester, "ready" ) ;
234
233
cycle ! ( leader_tester, "signing" ) ;
235
234
236
- comment ! ( "Follower: change the epoch after leader" ) ;
237
- follower_tester. increase_epoch ( ) . await . unwrap ( ) ;
238
- cycle_err ! ( follower_tester, "idle" ) ;
239
-
240
235
comment ! ( "Leader: register signers" ) ;
241
236
leader_tester
242
237
. register_signers ( & epoch_fixture. registering . signers_fixture ( ) )
@@ -256,27 +251,36 @@ async fn create_certificate_follower() {
256
251
comment ! ( "Leader: state machine should issue a certificate for the MithrilStakeDistribution" ) ;
257
252
cycle ! ( leader_tester, "signing" ) ;
258
253
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 ( ) ,
270
258
)
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
271
274
) ;
275
+ cycle ! ( follower_tester, "ready" ) ;
272
276
cycle_err ! ( leader_tester, "signing" ) ;
273
277
274
278
comment ! (
275
279
"Epoch 4:
276
280
- the leader aggregator produces a new certificate
277
281
- 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 "
280
284
) ;
281
285
let epoch_fixture = & epoch_fixtures_map[ & Epoch ( 4 ) ] ;
282
286
@@ -299,13 +303,8 @@ async fn create_certificate_follower() {
299
303
300
304
comment ! ( "Follower: change the epoch after leader" ) ;
301
305
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" ) ;
309
308
310
309
comment ! ( "Leader: register signers" ) ;
311
310
leader_tester
@@ -326,69 +325,19 @@ async fn create_certificate_follower() {
326
325
comment ! ( "Leader: state machine should issue a certificate for the MithrilStakeDistribution" ) ;
327
326
cycle ! ( leader_tester, "ready" ) ;
328
327
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 ( ) ,
340
332
)
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 ) ) ) ,
341
337
) ;
338
+ assert_last_certificate_eq ! ( leader_tester, leader_expected_certificate) ;
342
339
cycle ! ( leader_tester, "signing" ) ;
343
340
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
-
392
341
comment ! ( "Follower: signers send their single signature" ) ;
393
342
cycle ! ( follower_tester, "signing" ) ;
394
343
follower_tester
@@ -399,31 +348,17 @@ async fn create_certificate_follower() {
399
348
. await
400
349
. unwrap ( ) ;
401
350
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
-
416
351
comment ! ( "Follower: state machine should issue a certificate for the MithrilStakeDistribution" ) ;
417
352
cycle ! ( follower_tester, "ready" ) ;
418
353
let follower_expected_certificate = ExpectedCertificate :: new (
419
- Epoch ( 5 ) ,
354
+ Epoch ( 4 ) ,
420
355
StakeDistributionParty :: from_signers (
421
356
epoch_fixture. current_signing . unwrap ( ) . signers_with_stake ( ) ,
422
357
)
423
358
. as_slice ( ) ,
424
359
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 ) ) ) ,
427
362
) ;
428
363
assert_last_certificate_eq ! ( follower_tester, follower_expected_certificate) ;
429
364
let expected_avk = epoch_fixture
@@ -435,12 +370,12 @@ async fn create_certificate_follower() {
435
370
assert_eq ! ( expected_avk, follower_expected_certificate. avk( ) ) ;
436
371
437
372
comment ! (
438
- "Epoch 6 :
373
+ "Epoch 5 :
439
374
- the leader aggregator produces a new certificate
440
375
- the follower aggregator produces a new certificate
441
376
- the follower aggregator new certificate uses the same avk as the leader aggregator's new certificate
442
377
" ) ;
443
- let epoch_fixture = & epoch_fixtures_map[ & Epoch ( 6 ) ] ;
378
+ let epoch_fixture = & epoch_fixtures_map[ & Epoch ( 5 ) ] ;
444
379
445
380
comment ! ( "Leader: update stake distribution source" ) ;
446
381
leader_tester
@@ -493,28 +428,28 @@ async fn create_certificate_follower() {
493
428
comment ! ( "Leader: state machine should issue a certificate for the MithrilStakeDistribution" ) ;
494
429
cycle ! ( leader_tester, "ready" ) ;
495
430
let leader_expected_certificate = ExpectedCertificate :: new (
496
- Epoch ( 6 ) ,
431
+ Epoch ( 5 ) ,
497
432
StakeDistributionParty :: from_signers (
498
433
epoch_fixture. current_signing . unwrap ( ) . signers_with_stake ( ) ,
499
434
)
500
435
. as_slice ( ) ,
501
436
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 ) ) ) ,
504
439
) ;
505
440
assert_last_certificate_eq ! ( leader_tester, leader_expected_certificate) ;
506
441
507
442
comment ! ( "Follower: state machine should issue a certificate for the MithrilStakeDistribution" ) ;
508
443
cycle ! ( follower_tester, "ready" ) ;
509
444
let follower_expected_certificate = ExpectedCertificate :: new (
510
- Epoch ( 6 ) ,
445
+ Epoch ( 5 ) ,
511
446
StakeDistributionParty :: from_signers (
512
447
epoch_fixture. current_signing . unwrap ( ) . signers_with_stake ( ) ,
513
448
)
514
449
. as_slice ( ) ,
515
450
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 ) ) ) ,
518
453
) ;
519
454
assert_last_certificate_eq ! ( follower_tester, follower_expected_certificate) ;
520
455
let expected_avk = epoch_fixture
0 commit comments