@@ -56,10 +56,8 @@ impl Genesis {
56
56
let upgrades: Vec < & Upgrade > = self . upgrades . values ( ) . collect ( ) ;
57
57
58
58
for upgrade in upgrades {
59
- match upgrade. upgrade_type {
60
- UpgradeType :: ChainConfig { chain_config } => {
61
- base_fee = std:: cmp:: max ( chain_config. base_fee , base_fee) ;
62
- }
59
+ if let UpgradeType :: Fee { chain_config } = upgrade. upgrade_type {
60
+ base_fee = std:: cmp:: max ( chain_config. base_fee , base_fee) ;
63
61
}
64
62
}
65
63
@@ -401,7 +399,7 @@ mod test {
401
399
}
402
400
403
401
#[ test]
404
- fn test_genesis_toml_upgrade_view_mode ( ) {
402
+ fn test_genesis_toml_fee_upgrade_view_mode ( ) {
405
403
// without optional fields
406
404
// with view settings
407
405
let toml = toml ! {
@@ -432,7 +430,9 @@ mod test {
432
430
start_proposing_view = 1
433
431
stop_proposing_view = 15
434
432
435
- [ upgrade. chain_config]
433
+ [ upgrade. fee]
434
+
435
+ [ upgrade. fee. chain_config]
436
436
chain_id = 12345
437
437
max_block_size = 30000
438
438
base_fee = 1
@@ -454,7 +454,7 @@ mod test {
454
454
start_proposing_view : 1 ,
455
455
stop_proposing_view : 15 ,
456
456
} ) ,
457
- upgrade_type : UpgradeType :: ChainConfig {
457
+ upgrade_type : UpgradeType :: Fee {
458
458
chain_config : genesis. chain_config ,
459
459
} ,
460
460
} ;
@@ -463,7 +463,7 @@ mod test {
463
463
}
464
464
465
465
#[ test]
466
- fn test_genesis_toml_upgrade_time_mode ( ) {
466
+ fn test_genesis_toml_fee_upgrade_time_mode ( ) {
467
467
// without optional fields
468
468
// with time settings
469
469
let toml = toml ! {
@@ -494,7 +494,9 @@ mod test {
494
494
start_proposing_time = "2024-01-01T00:00:00Z"
495
495
stop_proposing_time = "2024-01-02T00:00:00Z"
496
496
497
- [ upgrade. chain_config]
497
+ [ upgrade. fee]
498
+
499
+ [ upgrade. fee. chain_config]
498
500
chain_id = 12345
499
501
max_block_size = 30000
500
502
base_fee = 1
@@ -518,7 +520,7 @@ mod test {
518
520
stop_proposing_time : Timestamp :: from_string ( "2024-01-02T00:00:00Z" . to_string ( ) )
519
521
. unwrap ( ) ,
520
522
} ) ,
521
- upgrade_type : UpgradeType :: ChainConfig {
523
+ upgrade_type : UpgradeType :: Fee {
522
524
chain_config : genesis. chain_config ,
523
525
} ,
524
526
} ;
@@ -527,7 +529,7 @@ mod test {
527
529
}
528
530
529
531
#[ test]
530
- fn test_genesis_toml_upgrade_view_and_time_mode ( ) {
532
+ fn test_genesis_toml_fee_upgrade_view_and_time_mode ( ) {
531
533
// set both time and view parameters
532
534
// this should err
533
535
let toml = toml ! {
@@ -560,7 +562,9 @@ mod test {
560
562
start_proposing_time = 1
561
563
stop_proposing_time = 10
562
564
563
- [ upgrade. chain_config]
565
+ [ upgrade. fee]
566
+
567
+ [ upgrade. fee. chain_config]
564
568
chain_id = 12345
565
569
max_block_size = 30000
566
570
base_fee = 1
@@ -571,4 +575,93 @@ mod test {
571
575
572
576
toml:: from_str :: < Genesis > ( & toml) . unwrap_err ( ) ;
573
577
}
578
+
579
+ #[ test]
580
+ fn test_marketplace_upgrade_toml ( ) {
581
+ let toml = toml ! {
582
+ [ stake_table]
583
+ capacity = 10
584
+
585
+ [ chain_config]
586
+ chain_id = 12345
587
+ max_block_size = 30000
588
+ base_fee = 1
589
+ fee_recipient = "0x0000000000000000000000000000000000000000"
590
+ fee_contract = "0x0000000000000000000000000000000000000000"
591
+
592
+ [ header]
593
+ timestamp = 123456
594
+
595
+ [ accounts]
596
+ "0x23618e81E3f5cdF7f54C3d65f7FBc0aBf5B21E8f" = 100000
597
+ "0x0000000000000000000000000000000000000000" = 42
598
+
599
+ [ l1_finalized]
600
+ number = 64
601
+ timestamp = "0x123def"
602
+ hash = "0x80f5dd11f2bdda2814cb1ad94ef30a47de02cf28ad68c89e104c00c4e51bb7a5"
603
+
604
+
605
+ [ [ upgrade] ]
606
+ version = "0.3"
607
+ start_proposing_view = 1
608
+ stop_proposing_view = 10
609
+
610
+ [ upgrade. marketplace]
611
+ }
612
+ . to_string ( ) ;
613
+
614
+ toml:: from_str :: < Genesis > ( & toml) . unwrap ( ) ;
615
+ }
616
+
617
+ #[ test]
618
+ fn test_marketplace_and_fee_upgrade_toml ( ) {
619
+ let toml = toml ! {
620
+ [ stake_table]
621
+ capacity = 10
622
+
623
+ [ chain_config]
624
+ chain_id = 12345
625
+ max_block_size = 30000
626
+ base_fee = 1
627
+ fee_recipient = "0x0000000000000000000000000000000000000000"
628
+ fee_contract = "0x0000000000000000000000000000000000000000"
629
+
630
+ [ header]
631
+ timestamp = 123456
632
+
633
+ [ accounts]
634
+ "0x23618e81E3f5cdF7f54C3d65f7FBc0aBf5B21E8f" = 100000
635
+ "0x0000000000000000000000000000000000000000" = 42
636
+
637
+ [ l1_finalized]
638
+ number = 64
639
+ timestamp = "0x123def"
640
+ hash = "0x80f5dd11f2bdda2814cb1ad94ef30a47de02cf28ad68c89e104c00c4e51bb7a5"
641
+
642
+ [ [ upgrade] ]
643
+ version = "0.3"
644
+ start_proposing_view = 1
645
+ stop_proposing_view = 10
646
+
647
+ [ upgrade. marketplace]
648
+
649
+ [ [ upgrade] ]
650
+ version = "0.2"
651
+ start_proposing_view = 1
652
+ stop_proposing_view = 15
653
+
654
+ [ upgrade. fee]
655
+
656
+ [ upgrade. fee. chain_config]
657
+ chain_id = 12345
658
+ max_block_size = 30000
659
+ base_fee = 1
660
+ fee_recipient = "0x0000000000000000000000000000000000000000"
661
+ fee_contract = "0x0000000000000000000000000000000000000000"
662
+ }
663
+ . to_string ( ) ;
664
+
665
+ toml:: from_str :: < Genesis > ( & toml) . unwrap ( ) ;
666
+ }
574
667
}
0 commit comments