Skip to content

Commit 518d5d6

Browse files
authored
Merge pull request #90 from datachainlab/BELC2
BELC2
2 parents 7fdeacb + 26af143 commit 518d5d6

File tree

9 files changed

+218
-5
lines changed

9 files changed

+218
-5
lines changed

light-client/src/client.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1372,6 +1372,7 @@ mod test {
13721372
additional_header_item_count: 0,
13731373
epoch_length: 200,
13741374
max_turn_length: 9,
1375+
enable_header_msec: false,
13751376
gas_limit_bound_divider: 256,
13761377
}];
13771378
(client_state, cons_state)
@@ -1386,6 +1387,7 @@ mod test {
13861387
additional_header_item_count: 0,
13871388
epoch_length: 200,
13881389
max_turn_length: 9,
1390+
enable_header_msec: false,
13891391
gas_limit_bound_divider: 256,
13901392
}];
13911393
(client_state, cons_state)
@@ -1401,6 +1403,7 @@ mod test {
14011403
additional_header_item_count: 0,
14021404
epoch_length: 200,
14031405
max_turn_length: 9,
1406+
enable_header_msec: false,
14041407
gas_limit_bound_divider: 256,
14051408
}];
14061409
(client_state, cons_state)

light-client/src/client_state.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -325,6 +325,7 @@ mod test {
325325
additional_header_item_count: 1, // requestsHash
326326
epoch_length: 200,
327327
max_turn_length: 9,
328+
enable_header_msec: false,
328329
gas_limit_bound_divider: 256,
329330
}
330331
}

light-client/src/errors.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,8 @@ pub enum Error {
7373
MissingVanityInExtraData(BlockNumber, usize, usize),
7474
MissingSignatureInExtraData(BlockNumber, usize, usize),
7575
UnexpectedMixHash(BlockNumber, Vec<u8>),
76+
UnexpectedNotEmptyMixHash(BlockNumber, Vec<u8>),
77+
UnexpectedMilliSecondValue(BlockNumber, u64),
7678
UnexpectedUncleHash(BlockNumber),
7779
UnexpectedDifficulty(BlockNumber, u64),
7880
UnexpectedNonce(BlockNumber),
@@ -510,6 +512,12 @@ impl core::fmt::Display for Error {
510512
Error::UnexpectedEpochInfo(e1, e2) => {
511513
write!(f, "UnexpectedEpochInfo : {} {}", e1, e2)
512514
}
515+
Error::UnexpectedNotEmptyMixHash(e1, e2) => {
516+
write!(f, "UnexpectedNotEmptyMixHash : {} {:?}", e1, e2)
517+
}
518+
Error::UnexpectedMilliSecondValue(e1, e2) => {
519+
write!(f, "UnexpectedMilliSecondValue : {} {}", e1, e2)
520+
}
513521
Error::UnexpectedGasLimitDivider(e1) => {
514522
write!(f, "UnexpectedGasLimitDivider : {}", e1)
515523
}

light-client/src/fixture/mod.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ pub fn fork_spec_after_pascal() -> ForkSpec {
7575
additional_header_item_count: 1,
7676
epoch_length: 200,
7777
max_turn_length: 64,
78+
enable_header_msec: false,
7879
gas_limit_bound_divider: 256,
7980
}
8081
}
@@ -85,6 +86,7 @@ pub fn fork_spec_after_lorentz() -> ForkSpec {
8586
additional_header_item_count: 1,
8687
epoch_length: 500,
8788
max_turn_length: 64,
89+
enable_header_msec: true,
8890
gas_limit_bound_divider: 1024,
8991
}
9092
}
@@ -95,6 +97,7 @@ pub fn fork_spec_after_maxwell() -> ForkSpec {
9597
additional_header_item_count: 1,
9698
epoch_length: 1000,
9799
max_turn_length: 64,
100+
enable_header_msec: true,
98101
gas_limit_bound_divider: 1024,
99102
}
100103
}

light-client/src/fork_spec.rs

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ pub struct ForkSpec {
2828
pub epoch_length: u64,
2929
/// Max turn length
3030
pub max_turn_length: u64,
31+
/// true: header has msec in mix_digest
32+
pub enable_header_msec: bool,
3133
/// Gas Limit bound diriver
3234
pub gas_limit_bound_divider: u64,
3335
}
@@ -203,6 +205,7 @@ impl TryFrom<RawForkSpec> for ForkSpec {
203205
additional_header_item_count: value.additional_header_item_count,
204206
epoch_length: value.epoch_length,
205207
max_turn_length: value.max_turn_length,
208+
enable_header_msec: value.enable_header_msec,
206209
gas_limit_bound_divider: value.gas_limit_bound_divider,
207210
})
208211
}
@@ -220,6 +223,7 @@ impl From<ForkSpec> for RawForkSpec {
220223
additional_header_item_count: value.additional_header_item_count,
221224
epoch_length: value.epoch_length,
222225
max_turn_length: value.max_turn_length,
226+
enable_header_msec: value.enable_header_msec,
223227
gas_limit_bound_divider: value.gas_limit_bound_divider,
224228
}
225229
}
@@ -312,13 +316,15 @@ mod test {
312316
additional_header_item_count: 1,
313317
epoch_length: 200,
314318
max_turn_length: 9,
319+
enable_header_msec: false,
315320
gas_limit_bound_divider: 256,
316321
},
317322
ForkSpec {
318323
height_or_timestamp: HeightOrTimestamp::Height(20),
319324
additional_header_item_count: 2,
320325
epoch_length: 200,
321326
max_turn_length: 9,
327+
enable_header_msec: true,
322328
gas_limit_bound_divider: 256,
323329
},
324330
];
@@ -340,13 +346,15 @@ mod test {
340346
additional_header_item_count: 1,
341347
epoch_length: 200,
342348
max_turn_length: 9,
349+
enable_header_msec: false,
343350
gas_limit_bound_divider: 256,
344351
},
345352
ForkSpec {
346353
height_or_timestamp: HeightOrTimestamp::Time(20),
347354
additional_header_item_count: 2,
348355
epoch_length: 200,
349356
max_turn_length: 9,
357+
enable_header_msec: false,
350358
gas_limit_bound_divider: 256,
351359
},
352360
];
@@ -368,13 +376,15 @@ mod test {
368376
additional_header_item_count: 1,
369377
epoch_length: 200,
370378
max_turn_length: 9,
379+
enable_header_msec: false,
371380
gas_limit_bound_divider: 256,
372381
},
373382
ForkSpec {
374383
height_or_timestamp: HeightOrTimestamp::Time(10),
375384
additional_header_item_count: 20,
376385
epoch_length: 200,
377386
max_turn_length: 9,
387+
enable_header_msec: false,
378388
gas_limit_bound_divider: 256,
379389
},
380390
];
@@ -397,13 +407,15 @@ mod test {
397407
additional_header_item_count: 1,
398408
epoch_length: 200,
399409
max_turn_length: 9,
410+
enable_header_msec: false,
400411
gas_limit_bound_divider: 256,
401412
},
402413
ForkSpec {
403414
height_or_timestamp: HeightOrTimestamp::Height(20),
404415
additional_header_item_count: 2,
405416
epoch_length: 200,
406417
max_turn_length: 9,
418+
enable_header_msec: false,
407419
gas_limit_bound_divider: 256,
408420
},
409421
];
@@ -425,13 +437,15 @@ mod test {
425437
additional_header_item_count: 1,
426438
epoch_length: 200,
427439
max_turn_length: 9,
440+
enable_header_msec: false,
428441
gas_limit_bound_divider: 256,
429442
},
430443
ForkSpec {
431444
height_or_timestamp: HeightOrTimestamp::Time(20),
432445
additional_header_item_count: 2,
433446
epoch_length: 200,
434447
max_turn_length: 9,
448+
enable_header_msec: false,
435449
gas_limit_bound_divider: 256,
436450
},
437451
];
@@ -453,13 +467,15 @@ mod test {
453467
additional_header_item_count: 1,
454468
epoch_length: 200,
455469
max_turn_length: 9,
470+
enable_header_msec: false,
456471
gas_limit_bound_divider: 256,
457472
},
458473
ForkSpec {
459474
height_or_timestamp: HeightOrTimestamp::Time(10),
460475
additional_header_item_count: 2,
461476
epoch_length: 200,
462477
max_turn_length: 9,
478+
enable_header_msec: false,
463479
gas_limit_bound_divider: 256,
464480
},
465481
];
@@ -481,13 +497,15 @@ mod test {
481497
additional_header_item_count: 1,
482498
epoch_length: 200,
483499
max_turn_length: 9,
500+
enable_header_msec: false,
484501
gas_limit_bound_divider: 256,
485502
},
486503
ForkSpec {
487504
height_or_timestamp: HeightOrTimestamp::Height(11),
488505
additional_header_item_count: 2,
489506
epoch_length: 200,
490507
max_turn_length: 9,
508+
enable_header_msec: false,
491509
gas_limit_bound_divider: 256,
492510
},
493511
];
@@ -502,13 +520,15 @@ mod test {
502520
additional_header_item_count: 1,
503521
epoch_length: 200,
504522
max_turn_length: 9,
523+
enable_header_msec: false,
505524
gas_limit_bound_divider: 256,
506525
},
507526
ForkSpec {
508527
height_or_timestamp: HeightOrTimestamp::Time(11),
509528
additional_header_item_count: 2,
510529
epoch_length: 200,
511530
max_turn_length: 9,
531+
enable_header_msec: false,
512532
gas_limit_bound_divider: 256,
513533
},
514534
];
@@ -523,13 +543,15 @@ mod test {
523543
additional_header_item_count: 1,
524544
epoch_length: 200,
525545
max_turn_length: 9,
546+
enable_header_msec: false,
526547
gas_limit_bound_divider: 256,
527548
},
528549
ForkSpec {
529550
height_or_timestamp: HeightOrTimestamp::Height(10),
530551
additional_header_item_count: 2,
531552
epoch_length: 200,
532553
max_turn_length: 9,
554+
enable_header_msec: false,
533555
gas_limit_bound_divider: 256,
534556
},
535557
];
@@ -548,13 +570,15 @@ mod test {
548570
additional_header_item_count: 1,
549571
epoch_length: 200,
550572
max_turn_length: 9,
573+
enable_header_msec: false,
551574
gas_limit_bound_divider: 256,
552575
},
553576
ForkSpec {
554577
height_or_timestamp: HeightOrTimestamp::Height(10),
555578
additional_header_item_count: 2,
556579
epoch_length: 200,
557580
max_turn_length: 9,
581+
enable_header_msec: false,
558582
gas_limit_bound_divider: 256,
559583
},
560584
];
@@ -576,13 +600,15 @@ mod test {
576600
additional_header_item_count: 1,
577601
epoch_length: 200,
578602
max_turn_length: 9,
603+
enable_header_msec: false,
579604
gas_limit_bound_divider: 256,
580605
},
581606
ForkSpec {
582607
height_or_timestamp: HeightOrTimestamp::Time(10),
583608
additional_header_item_count: 2,
584609
epoch_length: 200,
585610
max_turn_length: 9,
611+
enable_header_msec: false,
586612
gas_limit_bound_divider: 256,
587613
},
588614
];
@@ -601,13 +627,15 @@ mod test {
601627
additional_header_item_count: 1,
602628
epoch_length: 200,
603629
max_turn_length: 9,
630+
enable_header_msec: false,
604631
gas_limit_bound_divider: 256,
605632
},
606633
ForkSpec {
607634
height_or_timestamp: HeightOrTimestamp::Time(10),
608635
additional_header_item_count: 2,
609636
epoch_length: 200,
610637
max_turn_length: 9,
638+
enable_header_msec: false,
611639
gas_limit_bound_divider: 256,
612640
},
613641
];
@@ -628,6 +656,7 @@ mod test {
628656
additional_header_item_count: 1,
629657
epoch_length: 500,
630658
max_turn_length: 64,
659+
enable_header_msec: true,
631660
gas_limit_bound_divider: 256,
632661
};
633662
match current
@@ -648,6 +677,7 @@ mod test {
648677
additional_header_item_count: 1,
649678
epoch_length: 0,
650679
max_turn_length: 64,
680+
enable_header_msec: false,
651681
gas_limit_bound_divider: 256,
652682
};
653683
match current
@@ -669,6 +699,7 @@ mod test {
669699
additional_header_item_count: 1,
670700
epoch_length: 0,
671701
max_turn_length: 64,
702+
enable_header_msec: false,
672703
gas_limit_bound_divider: 256,
673704
};
674705
match fork_spec_after_pascal()
@@ -794,13 +825,15 @@ mod test {
794825
additional_header_item_count: 1,
795826
epoch_length: 200,
796827
max_turn_length: 9,
828+
enable_header_msec: false,
797829
gas_limit_bound_divider: 256,
798830
},
799831
ForkSpec {
800832
height_or_timestamp: HeightOrTimestamp::Height(20),
801833
additional_header_item_count: 2,
802834
epoch_length: 200,
803835
max_turn_length: 9,
836+
enable_header_msec: false,
804837
gas_limit_bound_divider: 256,
805838
},
806839
];
@@ -821,13 +854,15 @@ mod test {
821854
additional_header_item_count: 1,
822855
epoch_length: 200,
823856
max_turn_length: 9,
857+
enable_header_msec: false,
824858
gas_limit_bound_divider: 256,
825859
},
826860
ForkSpec {
827861
height_or_timestamp: HeightOrTimestamp::Height(20),
828862
additional_header_item_count: 2,
829863
epoch_length: 500,
830864
max_turn_length: 9,
865+
enable_header_msec: false,
831866
gas_limit_bound_divider: 256,
832867
},
833868
];

0 commit comments

Comments
 (0)