1
1
use crate :: application_domain:: { ApplicationDomain , APPLICATION_DOMAIN_BUILDER } ;
2
2
use crate :: blob_sidecar:: BlobIdentifier ;
3
+ use crate :: data_column_sidecar:: DataColumnIdentifier ;
3
4
use crate :: * ;
4
5
use int_to_bytes:: int_to_bytes4;
5
6
use safe_arith:: { ArithError , SafeArith } ;
@@ -193,6 +194,9 @@ pub struct ChainSpec {
193
194
/*
194
195
* DAS params
195
196
*/
197
+ pub eip7594_fork_epoch : Option < Epoch > ,
198
+ pub custody_requirement : u64 ,
199
+ pub data_column_sidecar_subnet_count : u64 ,
196
200
pub number_of_columns : usize ,
197
201
198
202
/*
@@ -223,6 +227,7 @@ pub struct ChainSpec {
223
227
*/
224
228
pub max_request_blocks_deneb : u64 ,
225
229
pub max_request_blob_sidecars : u64 ,
230
+ pub max_request_data_column_sidecars : u64 ,
226
231
pub min_epochs_for_blob_sidecars_requests : u64 ,
227
232
pub blob_sidecar_subnet_count : u64 ,
228
233
@@ -234,6 +239,7 @@ pub struct ChainSpec {
234
239
pub max_blocks_by_root_request : usize ,
235
240
pub max_blocks_by_root_request_deneb : usize ,
236
241
pub max_blobs_by_root_request : usize ,
242
+ pub max_data_columns_by_root_request : usize ,
237
243
238
244
/*
239
245
* Application params
@@ -413,6 +419,13 @@ impl ChainSpec {
413
419
}
414
420
}
415
421
422
+ /// Returns true if the given epoch is greater than or equal to the `EIP7594_FORK_EPOCH`.
423
+ pub fn is_peer_das_enabled_for_epoch ( & self , block_epoch : Epoch ) -> bool {
424
+ self . eip7594_fork_epoch . map_or ( false , |eip7594_fork_epoch| {
425
+ block_epoch >= eip7594_fork_epoch
426
+ } )
427
+ }
428
+
416
429
/// Returns a full `Fork` struct for a given epoch.
417
430
pub fn fork_at_epoch ( & self , epoch : Epoch ) -> Fork {
418
431
let current_fork_name = self . fork_name_at_epoch ( epoch) ;
@@ -587,6 +600,12 @@ impl ChainSpec {
587
600
}
588
601
}
589
602
603
+ pub fn data_columns_per_subnet ( & self ) -> usize {
604
+ self . number_of_columns
605
+ . safe_div ( self . data_column_sidecar_subnet_count as usize )
606
+ . expect ( "Subnet count must be greater than 0" )
607
+ }
608
+
590
609
/// Returns a `ChainSpec` compatible with the Ethereum Foundation specification.
591
610
pub fn mainnet ( ) -> Self {
592
611
Self {
@@ -777,6 +796,12 @@ impl ChainSpec {
777
796
} )
778
797
. expect ( "calculation does not overflow" ) ,
779
798
799
+ /*
800
+ * DAS params
801
+ */
802
+ eip7594_fork_epoch : None ,
803
+ custody_requirement : 1 ,
804
+ data_column_sidecar_subnet_count : 32 ,
780
805
number_of_columns : 128 ,
781
806
782
807
/*
@@ -808,6 +833,7 @@ impl ChainSpec {
808
833
*/
809
834
max_request_blocks_deneb : default_max_request_blocks_deneb ( ) ,
810
835
max_request_blob_sidecars : default_max_request_blob_sidecars ( ) ,
836
+ max_request_data_column_sidecars : default_max_request_data_column_sidecars ( ) ,
811
837
min_epochs_for_blob_sidecars_requests : default_min_epochs_for_blob_sidecars_requests ( ) ,
812
838
blob_sidecar_subnet_count : default_blob_sidecar_subnet_count ( ) ,
813
839
@@ -817,6 +843,7 @@ impl ChainSpec {
817
843
max_blocks_by_root_request : default_max_blocks_by_root_request ( ) ,
818
844
max_blocks_by_root_request_deneb : default_max_blocks_by_root_request_deneb ( ) ,
819
845
max_blobs_by_root_request : default_max_blobs_by_root_request ( ) ,
846
+ max_data_columns_by_root_request : default_data_columns_by_root_request ( ) ,
820
847
821
848
/*
822
849
* Application specific
@@ -888,6 +915,8 @@ impl ChainSpec {
888
915
u64:: checked_pow ( 2 , 7 ) ?. checked_mul ( u64:: checked_pow ( 10 , 9 ) ?)
889
916
} )
890
917
. expect ( "calculation does not overflow" ) ,
918
+ // PeerDAS
919
+ eip7594_fork_epoch : None ,
891
920
// Other
892
921
network_id : 2 , // lighthouse testnet network id
893
922
deposit_chain_id : 5 ,
@@ -1089,8 +1118,13 @@ impl ChainSpec {
1089
1118
} )
1090
1119
. expect ( "calculation does not overflow" ) ,
1091
1120
1121
+ /*
1122
+ * DAS params
1123
+ */
1124
+ eip7594_fork_epoch : None ,
1125
+ custody_requirement : 1 ,
1126
+ data_column_sidecar_subnet_count : 32 ,
1092
1127
number_of_columns : 128 ,
1093
-
1094
1128
/*
1095
1129
* Network specific
1096
1130
*/
@@ -1120,6 +1154,7 @@ impl ChainSpec {
1120
1154
*/
1121
1155
max_request_blocks_deneb : default_max_request_blocks_deneb ( ) ,
1122
1156
max_request_blob_sidecars : default_max_request_blob_sidecars ( ) ,
1157
+ max_request_data_column_sidecars : default_max_request_data_column_sidecars ( ) ,
1123
1158
min_epochs_for_blob_sidecars_requests : 16384 ,
1124
1159
blob_sidecar_subnet_count : default_blob_sidecar_subnet_count ( ) ,
1125
1160
@@ -1129,6 +1164,7 @@ impl ChainSpec {
1129
1164
max_blocks_by_root_request : default_max_blocks_by_root_request ( ) ,
1130
1165
max_blocks_by_root_request_deneb : default_max_blocks_by_root_request_deneb ( ) ,
1131
1166
max_blobs_by_root_request : default_max_blobs_by_root_request ( ) ,
1167
+ max_data_columns_by_root_request : default_data_columns_by_root_request ( ) ,
1132
1168
1133
1169
/*
1134
1170
* Application specific
@@ -1222,6 +1258,11 @@ pub struct Config {
1222
1258
#[ serde( deserialize_with = "deserialize_fork_epoch" ) ]
1223
1259
pub electra_fork_epoch : Option < MaybeQuoted < Epoch > > ,
1224
1260
1261
+ #[ serde( default ) ]
1262
+ #[ serde( serialize_with = "serialize_fork_epoch" ) ]
1263
+ #[ serde( deserialize_with = "deserialize_fork_epoch" ) ]
1264
+ pub eip7594_fork_epoch : Option < MaybeQuoted < Epoch > > ,
1265
+
1225
1266
#[ serde( with = "serde_utils::quoted_u64" ) ]
1226
1267
seconds_per_slot : u64 ,
1227
1268
#[ serde( with = "serde_utils::quoted_u64" ) ]
@@ -1307,6 +1348,9 @@ pub struct Config {
1307
1348
#[ serde( default = "default_max_request_blob_sidecars" ) ]
1308
1349
#[ serde( with = "serde_utils::quoted_u64" ) ]
1309
1350
max_request_blob_sidecars : u64 ,
1351
+ #[ serde( default = "default_max_request_data_column_sidecars" ) ]
1352
+ #[ serde( with = "serde_utils::quoted_u64" ) ]
1353
+ max_request_data_column_sidecars : u64 ,
1310
1354
#[ serde( default = "default_min_epochs_for_blob_sidecars_requests" ) ]
1311
1355
#[ serde( with = "serde_utils::quoted_u64" ) ]
1312
1356
min_epochs_for_blob_sidecars_requests : u64 ,
@@ -1320,6 +1364,13 @@ pub struct Config {
1320
1364
#[ serde( default = "default_max_per_epoch_activation_exit_churn_limit" ) ]
1321
1365
#[ serde( with = "serde_utils::quoted_u64" ) ]
1322
1366
max_per_epoch_activation_exit_churn_limit : u64 ,
1367
+
1368
+ #[ serde( with = "serde_utils::quoted_u64" ) ]
1369
+ custody_requirement : u64 ,
1370
+ #[ serde( with = "serde_utils::quoted_u64" ) ]
1371
+ data_column_sidecar_subnet_count : u64 ,
1372
+ #[ serde( with = "serde_utils::quoted_u64" ) ]
1373
+ number_of_columns : u64 ,
1323
1374
}
1324
1375
1325
1376
fn default_bellatrix_fork_version ( ) -> [ u8 ; 4 ] {
@@ -1426,6 +1477,10 @@ const fn default_max_request_blob_sidecars() -> u64 {
1426
1477
768
1427
1478
}
1428
1479
1480
+ const fn default_max_request_data_column_sidecars ( ) -> u64 {
1481
+ 16384
1482
+ }
1483
+
1429
1484
const fn default_min_epochs_for_blob_sidecars_requests ( ) -> u64 {
1430
1485
4096
1431
1486
}
@@ -1479,6 +1534,20 @@ fn max_blobs_by_root_request_common(max_request_blob_sidecars: u64) -> usize {
1479
1534
. len ( )
1480
1535
}
1481
1536
1537
+ fn max_data_columns_by_root_request_common ( max_request_data_column_sidecars : u64 ) -> usize {
1538
+ let max_request_data_column_sidecars = max_request_data_column_sidecars as usize ;
1539
+ let empty_data_column_id = DataColumnIdentifier {
1540
+ block_root : Hash256 :: zero ( ) ,
1541
+ index : 0 ,
1542
+ } ;
1543
+ RuntimeVariableList :: from_vec (
1544
+ vec ! [ empty_data_column_id; max_request_data_column_sidecars] ,
1545
+ max_request_data_column_sidecars,
1546
+ )
1547
+ . as_ssz_bytes ( )
1548
+ . len ( )
1549
+ }
1550
+
1482
1551
fn default_max_blocks_by_root_request ( ) -> usize {
1483
1552
max_blocks_by_root_request_common ( default_max_request_blocks ( ) )
1484
1553
}
@@ -1491,6 +1560,10 @@ fn default_max_blobs_by_root_request() -> usize {
1491
1560
max_blobs_by_root_request_common ( default_max_request_blob_sidecars ( ) )
1492
1561
}
1493
1562
1563
+ fn default_data_columns_by_root_request ( ) -> usize {
1564
+ max_data_columns_by_root_request_common ( default_max_request_data_column_sidecars ( ) )
1565
+ }
1566
+
1494
1567
impl Default for Config {
1495
1568
fn default ( ) -> Self {
1496
1569
let chain_spec = MainnetEthSpec :: default_spec ( ) ;
@@ -1580,6 +1653,10 @@ impl Config {
1580
1653
. electra_fork_epoch
1581
1654
. map ( |epoch| MaybeQuoted { value : epoch } ) ,
1582
1655
1656
+ eip7594_fork_epoch : spec
1657
+ . eip7594_fork_epoch
1658
+ . map ( |epoch| MaybeQuoted { value : epoch } ) ,
1659
+
1583
1660
seconds_per_slot : spec. seconds_per_slot ,
1584
1661
seconds_per_eth1_block : spec. seconds_per_eth1_block ,
1585
1662
min_validator_withdrawability_delay : spec. min_validator_withdrawability_delay ,
@@ -1616,12 +1693,17 @@ impl Config {
1616
1693
attestation_subnet_shuffling_prefix_bits : spec. attestation_subnet_shuffling_prefix_bits ,
1617
1694
max_request_blocks_deneb : spec. max_request_blocks_deneb ,
1618
1695
max_request_blob_sidecars : spec. max_request_blob_sidecars ,
1696
+ max_request_data_column_sidecars : spec. max_request_data_column_sidecars ,
1619
1697
min_epochs_for_blob_sidecars_requests : spec. min_epochs_for_blob_sidecars_requests ,
1620
1698
blob_sidecar_subnet_count : spec. blob_sidecar_subnet_count ,
1621
1699
1622
1700
min_per_epoch_churn_limit_electra : spec. min_per_epoch_churn_limit_electra ,
1623
1701
max_per_epoch_activation_exit_churn_limit : spec
1624
1702
. max_per_epoch_activation_exit_churn_limit ,
1703
+
1704
+ custody_requirement : spec. custody_requirement ,
1705
+ data_column_sidecar_subnet_count : spec. data_column_sidecar_subnet_count ,
1706
+ number_of_columns : spec. number_of_columns as u64 ,
1625
1707
}
1626
1708
}
1627
1709
@@ -1655,6 +1737,7 @@ impl Config {
1655
1737
deneb_fork_version,
1656
1738
electra_fork_epoch,
1657
1739
electra_fork_version,
1740
+ eip7594_fork_epoch,
1658
1741
seconds_per_slot,
1659
1742
seconds_per_eth1_block,
1660
1743
min_validator_withdrawability_delay,
@@ -1687,10 +1770,15 @@ impl Config {
1687
1770
maximum_gossip_clock_disparity_millis,
1688
1771
max_request_blocks_deneb,
1689
1772
max_request_blob_sidecars,
1773
+ max_request_data_column_sidecars,
1690
1774
min_epochs_for_blob_sidecars_requests,
1691
1775
blob_sidecar_subnet_count,
1776
+
1692
1777
min_per_epoch_churn_limit_electra,
1693
1778
max_per_epoch_activation_exit_churn_limit,
1779
+ custody_requirement,
1780
+ data_column_sidecar_subnet_count,
1781
+ number_of_columns,
1694
1782
} = self ;
1695
1783
1696
1784
if preset_base != E :: spec_name ( ) . to_string ( ) . as_str ( ) {
@@ -1713,6 +1801,7 @@ impl Config {
1713
1801
deneb_fork_version,
1714
1802
electra_fork_epoch : electra_fork_epoch. map ( |q| q. value ) ,
1715
1803
electra_fork_version,
1804
+ eip7594_fork_epoch : eip7594_fork_epoch. map ( |q| q. value ) ,
1716
1805
seconds_per_slot,
1717
1806
seconds_per_eth1_block,
1718
1807
min_validator_withdrawability_delay,
@@ -1749,8 +1838,10 @@ impl Config {
1749
1838
maximum_gossip_clock_disparity_millis,
1750
1839
max_request_blocks_deneb,
1751
1840
max_request_blob_sidecars,
1841
+ max_request_data_column_sidecars,
1752
1842
min_epochs_for_blob_sidecars_requests,
1753
1843
blob_sidecar_subnet_count,
1844
+
1754
1845
min_per_epoch_churn_limit_electra,
1755
1846
max_per_epoch_activation_exit_churn_limit,
1756
1847
@@ -1760,6 +1851,13 @@ impl Config {
1760
1851
max_request_blocks_deneb,
1761
1852
) ,
1762
1853
max_blobs_by_root_request : max_blobs_by_root_request_common ( max_request_blob_sidecars) ,
1854
+ max_data_columns_by_root_request : max_data_columns_by_root_request_common (
1855
+ max_request_data_column_sidecars,
1856
+ ) ,
1857
+
1858
+ custody_requirement,
1859
+ data_column_sidecar_subnet_count,
1860
+ number_of_columns : number_of_columns as usize ,
1763
1861
1764
1862
..chain_spec. clone ( )
1765
1863
} )
@@ -2001,6 +2099,9 @@ mod yaml_tests {
2001
2099
DEPOSIT_CHAIN_ID: 1
2002
2100
DEPOSIT_NETWORK_ID: 1
2003
2101
DEPOSIT_CONTRACT_ADDRESS: 0x00000000219ab540356cBB839Cbe05303d7705Fa
2102
+ CUSTODY_REQUIREMENT: 1
2103
+ DATA_COLUMN_SIDECAR_SUBNET_COUNT: 32
2104
+ NUMBER_OF_COLUMNS: 128
2004
2105
"# ;
2005
2106
2006
2107
let chain_spec: Config = serde_yaml:: from_str ( spec) . unwrap ( ) ;
0 commit comments