@@ -2,6 +2,7 @@ use crate::application_domain::{ApplicationDomain, APPLICATION_DOMAIN_BUILDER};
2
2
use crate :: blob_sidecar:: BlobIdentifier ;
3
3
use crate :: data_column_sidecar:: DataColumnsByRootIdentifier ;
4
4
use crate :: * ;
5
+ use derivative:: Derivative ;
5
6
use ethereum_hashing:: hash;
6
7
use int_to_bytes:: int_to_bytes4;
7
8
use safe_arith:: { ArithError , SafeArith } ;
@@ -1472,8 +1473,17 @@ pub struct BlobParameters {
1472
1473
// A wrapper around a vector of BlobParameters to ensure that the vector is reverse
1473
1474
// sorted by epoch.
1474
1475
#[ cfg_attr( feature = "arbitrary" , derive( arbitrary:: Arbitrary ) ) ]
1475
- #[ derive( Debug , PartialEq , Clone ) ]
1476
- pub struct BlobSchedule ( Vec < BlobParameters > ) ;
1476
+ #[ derive( Debug , Derivative , Clone ) ]
1477
+ #[ derivative( PartialEq ) ]
1478
+ pub struct BlobSchedule {
1479
+ schedule : Vec < BlobParameters > ,
1480
+ // This is a hack to prevent the blob schedule being serialized on the /eth/v1/config/spec
1481
+ // endpoint prior to the Fulu fork being scheduled.
1482
+ //
1483
+ // We can remove this once Fulu is live on mainnet.
1484
+ #[ derivative( PartialEq = "ignore" ) ]
1485
+ skip_serializing : bool ,
1486
+ }
1477
1487
1478
1488
impl < ' de > Deserialize < ' de > for BlobSchedule {
1479
1489
fn deserialize < D > ( deserializer : D ) -> Result < Self , D :: Error >
@@ -1489,30 +1499,48 @@ impl BlobSchedule {
1489
1499
pub fn new ( mut vec : Vec < BlobParameters > ) -> Self {
1490
1500
// reverse sort by epoch
1491
1501
vec. sort_by ( |a, b| b. epoch . cmp ( & a. epoch ) ) ;
1492
- Self ( vec)
1502
+ Self {
1503
+ schedule : vec,
1504
+ skip_serializing : false ,
1505
+ }
1493
1506
}
1494
1507
1495
1508
pub fn is_empty ( & self ) -> bool {
1496
- self . 0 . is_empty ( )
1509
+ self . schedule . is_empty ( )
1510
+ }
1511
+
1512
+ pub fn skip_serializing ( & self ) -> bool {
1513
+ self . skip_serializing
1514
+ }
1515
+
1516
+ pub fn set_skip_serializing ( & mut self ) {
1517
+ self . skip_serializing = true ;
1497
1518
}
1498
1519
1499
1520
pub fn max_blobs_for_epoch ( & self , epoch : Epoch ) -> Option < u64 > {
1500
- self . 0
1521
+ self . schedule
1501
1522
. iter ( )
1502
1523
. find ( |entry| epoch >= entry. epoch )
1503
1524
. map ( |entry| entry. max_blobs_per_block )
1504
1525
}
1505
1526
1506
1527
pub fn blob_parameters_for_epoch ( & self , epoch : Epoch ) -> Option < BlobParameters > {
1507
- self . 0 . iter ( ) . find ( |entry| epoch >= entry. epoch ) . cloned ( )
1528
+ self . schedule
1529
+ . iter ( )
1530
+ . find ( |entry| epoch >= entry. epoch )
1531
+ . cloned ( )
1508
1532
}
1509
1533
1510
1534
pub const fn default ( ) -> Self {
1511
- Self ( vec ! [ ] )
1535
+ // TODO(EIP-7892): think about what the default should be
1536
+ Self {
1537
+ schedule : vec ! [ ] ,
1538
+ skip_serializing : false ,
1539
+ }
1512
1540
}
1513
1541
1514
1542
pub fn as_vec ( & self ) -> & Vec < BlobParameters > {
1515
- & self . 0
1543
+ & self . schedule
1516
1544
}
1517
1545
}
1518
1546
@@ -1521,7 +1549,7 @@ impl Serialize for BlobSchedule {
1521
1549
where
1522
1550
S : Serializer ,
1523
1551
{
1524
- let mut schedule = self . 0 . clone ( ) ;
1552
+ let mut schedule = self . schedule . clone ( ) ;
1525
1553
// reversing the list to get an ascending order
1526
1554
schedule. reverse ( ) ;
1527
1555
schedule. serialize ( serializer)
@@ -1533,7 +1561,7 @@ impl<'a> IntoIterator for &'a BlobSchedule {
1533
1561
type IntoIter = std:: slice:: Iter < ' a , BlobParameters > ;
1534
1562
1535
1563
fn into_iter ( self ) -> Self :: IntoIter {
1536
- self . 0 . iter ( )
1564
+ self . schedule . iter ( )
1537
1565
}
1538
1566
}
1539
1567
@@ -1542,7 +1570,7 @@ impl IntoIterator for BlobSchedule {
1542
1570
type IntoIter = std:: vec:: IntoIter < BlobParameters > ;
1543
1571
1544
1572
fn into_iter ( self ) -> Self :: IntoIter {
1545
- self . 0 . into_iter ( )
1573
+ self . schedule . into_iter ( )
1546
1574
}
1547
1575
}
1548
1576
@@ -1747,8 +1775,8 @@ pub struct Config {
1747
1775
#[ serde( with = "serde_utils::quoted_u64" ) ]
1748
1776
custody_requirement : u64 ,
1749
1777
#[ serde( default = "BlobSchedule::default" ) ]
1750
- #[ serde( skip_serializing_if = "BlobSchedule::is_empty " ) ]
1751
- blob_schedule : BlobSchedule ,
1778
+ #[ serde( skip_serializing_if = "BlobSchedule::skip_serializing " ) ]
1779
+ pub blob_schedule : BlobSchedule ,
1752
1780
#[ serde( default = "default_validator_custody_requirement" ) ]
1753
1781
#[ serde( with = "serde_utils::quoted_u64" ) ]
1754
1782
validator_custody_requirement : u64 ,
0 commit comments