Skip to content

Commit 10d84b0

Browse files
author
Naohiro Yoshida
committed
fix BELC1
Signed-off-by: Naohiro Yoshida <naohiro.yoshida@datachain.jp>
1 parent ddfd92e commit 10d84b0

File tree

10 files changed

+94
-7
lines changed

10 files changed

+94
-7
lines changed

light-client/src/client.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1369,6 +1369,7 @@ mod test {
13691369
additional_header_item_count: 0,
13701370
epoch_length: 200,
13711371
max_turn_length: 9,
1372+
gas_limit_bound_divider: 256,
13721373
}];
13731374
(client_state, cons_state)
13741375
}));
@@ -1382,6 +1383,7 @@ mod test {
13821383
additional_header_item_count: 0,
13831384
epoch_length: 200,
13841385
max_turn_length: 9,
1386+
gas_limit_bound_divider: 256,
13851387
}];
13861388
(client_state, cons_state)
13871389
}));
@@ -1396,6 +1398,7 @@ mod test {
13961398
additional_header_item_count: 0,
13971399
epoch_length: 200,
13981400
max_turn_length: 9,
1401+
gas_limit_bound_divider: 256,
13991402
}];
14001403
(client_state, cons_state)
14011404
}))

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+
gas_limit_bound_divider: 256,
328329
}
329330
}
330331

light-client/src/errors.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ pub enum Error {
8282
MissingSignerInValidator(BlockNumber, Address),
8383
UnexpectedGasDiff(BlockNumber, u64, u64),
8484
UnexpectedGasUsed(BlockNumber, u64, u64),
85+
UnexpectedGasLimitDivider(BlockNumber),
8586
UnexpectedHeaderRelation(BlockNumber, BlockNumber, Hash, Vec<u8>, u64, u64),
8687
ProofRLPError(rlp::DecoderError),
8788
InvalidProofFormatError(Vec<u8>),
@@ -506,6 +507,9 @@ impl core::fmt::Display for Error {
506507
Error::UnexpectedEpochInfo(e1, e2) => {
507508
write!(f, "UnexpectedEpochInfo : {} {}", e1, e2)
508509
}
510+
Error::UnexpectedGasLimitDivider(e1) => {
511+
write!(f, "UnexpectedGasLimitDivider : {}", e1)
512+
}
509513
}
510514
}
511515
}

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+
gas_limit_bound_divider: 256,
7879
}
7980
}
8081

@@ -84,6 +85,7 @@ pub fn fork_spec_after_lorentz() -> ForkSpec {
8485
additional_header_item_count: 1,
8586
epoch_length: 500,
8687
max_turn_length: 64,
88+
gas_limit_bound_divider: 1024,
8789
}
8890
}
8991

@@ -93,5 +95,6 @@ pub fn fork_spec_after_maxwell() -> ForkSpec {
9395
additional_header_item_count: 1,
9496
epoch_length: 1000,
9597
max_turn_length: 64,
98+
gas_limit_bound_divider: 1024,
9699
}
97100
}

light-client/src/fork_spec.rs

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ pub struct ForkSpec {
1818
pub epoch_length: u64,
1919
/// Max turn length
2020
pub max_turn_length: u64,
21+
/// Gas Limit bound diriver
22+
pub gas_limit_bound_divider: u64,
2123
}
2224

2325
impl ForkSpec {
@@ -182,6 +184,7 @@ impl TryFrom<RawForkSpec> for ForkSpec {
182184
additional_header_item_count: value.additional_header_item_count,
183185
epoch_length: value.epoch_length,
184186
max_turn_length: value.max_turn_length,
187+
gas_limit_bound_divider: value.gas_limit_bound_divider,
185188
})
186189
}
187190
}
@@ -198,6 +201,7 @@ impl From<ForkSpec> for RawForkSpec {
198201
additional_header_item_count: value.additional_header_item_count,
199202
epoch_length: value.epoch_length,
200203
max_turn_length: value.max_turn_length,
204+
gas_limit_bound_divider: value.gas_limit_bound_divider,
201205
}
202206
}
203207
}
@@ -290,12 +294,14 @@ mod test {
290294
additional_header_item_count: 1,
291295
epoch_length: 200,
292296
max_turn_length: 9,
297+
gas_limit_bound_divider: 256,
293298
},
294299
ForkSpec {
295300
height_or_timestamp: HeightOrTimestamp::Height(20),
296301
additional_header_item_count: 2,
297302
epoch_length: 200,
298303
max_turn_length: 9,
304+
gas_limit_bound_divider: 256,
299305
},
300306
];
301307
let v = find_target_fork_spec(specs, 10, 0).unwrap();
@@ -316,12 +322,14 @@ mod test {
316322
additional_header_item_count: 1,
317323
epoch_length: 200,
318324
max_turn_length: 9,
325+
gas_limit_bound_divider: 256,
319326
},
320327
ForkSpec {
321328
height_or_timestamp: HeightOrTimestamp::Time(20),
322329
additional_header_item_count: 2,
323330
epoch_length: 200,
324331
max_turn_length: 9,
332+
gas_limit_bound_divider: 256,
325333
},
326334
];
327335
let v = find_target_fork_spec(specs, 0, 10).unwrap();
@@ -342,12 +350,14 @@ mod test {
342350
additional_header_item_count: 1,
343351
epoch_length: 200,
344352
max_turn_length: 9,
353+
gas_limit_bound_divider: 256,
345354
},
346355
ForkSpec {
347356
height_or_timestamp: HeightOrTimestamp::Time(10),
348357
additional_header_item_count: 20,
349358
epoch_length: 200,
350359
max_turn_length: 9,
360+
gas_limit_bound_divider: 256,
351361
},
352362
];
353363
// After value is primary
@@ -369,12 +379,14 @@ mod test {
369379
additional_header_item_count: 1,
370380
epoch_length: 200,
371381
max_turn_length: 9,
382+
gas_limit_bound_divider: 256,
372383
},
373384
ForkSpec {
374385
height_or_timestamp: HeightOrTimestamp::Height(20),
375386
additional_header_item_count: 2,
376387
epoch_length: 200,
377388
max_turn_length: 9,
389+
gas_limit_bound_divider: 256,
378390
},
379391
];
380392
let v = find_target_fork_spec(specs, 9, 0).unwrap_err();
@@ -395,12 +407,14 @@ mod test {
395407
additional_header_item_count: 1,
396408
epoch_length: 200,
397409
max_turn_length: 9,
410+
gas_limit_bound_divider: 256,
398411
},
399412
ForkSpec {
400413
height_or_timestamp: HeightOrTimestamp::Time(20),
401414
additional_header_item_count: 2,
402415
epoch_length: 200,
403416
max_turn_length: 9,
417+
gas_limit_bound_divider: 256,
404418
},
405419
];
406420
let v = find_target_fork_spec(specs, 0, 9).unwrap_err();
@@ -421,12 +435,14 @@ mod test {
421435
additional_header_item_count: 1,
422436
epoch_length: 200,
423437
max_turn_length: 9,
438+
gas_limit_bound_divider: 256,
424439
},
425440
ForkSpec {
426441
height_or_timestamp: HeightOrTimestamp::Time(10),
427442
additional_header_item_count: 2,
428443
epoch_length: 200,
429444
max_turn_length: 9,
445+
gas_limit_bound_divider: 256,
430446
},
431447
];
432448
let v = find_target_fork_spec(specs, 9, 9).unwrap_err();
@@ -447,12 +463,14 @@ mod test {
447463
additional_header_item_count: 1,
448464
epoch_length: 200,
449465
max_turn_length: 9,
466+
gas_limit_bound_divider: 256,
450467
},
451468
ForkSpec {
452469
height_or_timestamp: HeightOrTimestamp::Height(11),
453470
additional_header_item_count: 2,
454471
epoch_length: 200,
455472
max_turn_length: 9,
473+
gas_limit_bound_divider: 256,
456474
},
457475
];
458476
verify_sorted_asc(specs).unwrap();
@@ -466,12 +484,14 @@ mod test {
466484
additional_header_item_count: 1,
467485
epoch_length: 200,
468486
max_turn_length: 9,
487+
gas_limit_bound_divider: 256,
469488
},
470489
ForkSpec {
471490
height_or_timestamp: HeightOrTimestamp::Time(11),
472491
additional_header_item_count: 2,
473492
epoch_length: 200,
474493
max_turn_length: 9,
494+
gas_limit_bound_divider: 256,
475495
},
476496
];
477497
verify_sorted_asc(specs).unwrap();
@@ -485,12 +505,14 @@ mod test {
485505
additional_header_item_count: 1,
486506
epoch_length: 200,
487507
max_turn_length: 9,
508+
gas_limit_bound_divider: 256,
488509
},
489510
ForkSpec {
490511
height_or_timestamp: HeightOrTimestamp::Height(10),
491512
additional_header_item_count: 2,
492513
epoch_length: 200,
493514
max_turn_length: 9,
515+
gas_limit_bound_divider: 256,
494516
},
495517
];
496518
let v = verify_sorted_asc(specs).unwrap_err();
@@ -508,12 +530,14 @@ mod test {
508530
additional_header_item_count: 1,
509531
epoch_length: 200,
510532
max_turn_length: 9,
533+
gas_limit_bound_divider: 256,
511534
},
512535
ForkSpec {
513536
height_or_timestamp: HeightOrTimestamp::Height(10),
514537
additional_header_item_count: 2,
515538
epoch_length: 200,
516539
max_turn_length: 9,
540+
gas_limit_bound_divider: 256,
517541
},
518542
];
519543
let v = verify_sorted_asc(specs).unwrap_err();
@@ -534,12 +558,14 @@ mod test {
534558
additional_header_item_count: 1,
535559
epoch_length: 200,
536560
max_turn_length: 9,
561+
gas_limit_bound_divider: 256,
537562
},
538563
ForkSpec {
539564
height_or_timestamp: HeightOrTimestamp::Time(10),
540565
additional_header_item_count: 2,
541566
epoch_length: 200,
542567
max_turn_length: 9,
568+
gas_limit_bound_divider: 256,
543569
},
544570
];
545571
let v = verify_sorted_asc(specs).unwrap_err();
@@ -557,12 +583,14 @@ mod test {
557583
additional_header_item_count: 1,
558584
epoch_length: 200,
559585
max_turn_length: 9,
586+
gas_limit_bound_divider: 256,
560587
},
561588
ForkSpec {
562589
height_or_timestamp: HeightOrTimestamp::Time(10),
563590
additional_header_item_count: 2,
564591
epoch_length: 200,
565592
max_turn_length: 9,
593+
gas_limit_bound_divider: 256,
566594
},
567595
];
568596
let v = verify_sorted_asc(specs).unwrap_err();
@@ -582,6 +610,7 @@ mod test {
582610
additional_header_item_count: 1,
583611
epoch_length: 500,
584612
max_turn_length: 64,
613+
gas_limit_bound_divider: 256,
585614
};
586615
match current
587616
.boundary_epochs(&fork_spec_after_pascal())
@@ -705,12 +734,14 @@ mod test {
705734
additional_header_item_count: 1,
706735
epoch_length: 200,
707736
max_turn_length: 9,
737+
gas_limit_bound_divider: 256,
708738
},
709739
ForkSpec {
710740
height_or_timestamp: HeightOrTimestamp::Height(20),
711741
additional_header_item_count: 2,
712742
epoch_length: 200,
713743
max_turn_length: 9,
744+
gas_limit_bound_divider: 256,
714745
},
715746
];
716747
let v = get_boundary_epochs(&fork_spec_after_pascal(), specs).unwrap_err();
@@ -730,12 +761,14 @@ mod test {
730761
additional_header_item_count: 1,
731762
epoch_length: 200,
732763
max_turn_length: 9,
764+
gas_limit_bound_divider: 256,
733765
},
734766
ForkSpec {
735767
height_or_timestamp: HeightOrTimestamp::Height(20),
736768
additional_header_item_count: 2,
737769
epoch_length: 500,
738770
max_turn_length: 9,
771+
gas_limit_bound_divider: 256,
739772
},
740773
];
741774
let v = get_boundary_epochs(&specs[1], specs).unwrap();

0 commit comments

Comments
 (0)