Skip to content

Commit a1c2e35

Browse files
authored
Merge of #6127
2 parents 256f012 + a5e0279 commit a1c2e35

File tree

11 files changed

+188
-1
lines changed

11 files changed

+188
-1
lines changed

common/eth2_network_config/built_in_network_configs/chiado/config.yaml

+4
Original file line numberDiff line numberDiff line change
@@ -137,3 +137,7 @@ MIN_EPOCHS_FOR_BLOB_SIDECARS_REQUESTS: 16384
137137
# `6`
138138
BLOB_SIDECAR_SUBNET_COUNT: 6
139139

140+
# DAS
141+
CUSTODY_REQUIREMENT: 1
142+
DATA_COLUMN_SIDECAR_SUBNET_COUNT: 32
143+
NUMBER_OF_COLUMNS: 128

common/eth2_network_config/built_in_network_configs/gnosis/config.yaml

+5
Original file line numberDiff line numberDiff line change
@@ -119,3 +119,8 @@ MAX_REQUEST_BLOB_SIDECARS: 768
119119
MIN_EPOCHS_FOR_BLOB_SIDECARS_REQUESTS: 16384
120120
# `6`
121121
BLOB_SIDECAR_SUBNET_COUNT: 6
122+
123+
# DAS
124+
CUSTODY_REQUIREMENT: 1
125+
DATA_COLUMN_SIDECAR_SUBNET_COUNT: 32
126+
NUMBER_OF_COLUMNS: 128

common/eth2_network_config/built_in_network_configs/holesky/config.yaml

+5
Original file line numberDiff line numberDiff line change
@@ -123,3 +123,8 @@ MAX_REQUEST_BLOB_SIDECARS: 768
123123
MIN_EPOCHS_FOR_BLOB_SIDECARS_REQUESTS: 4096
124124
# `6`
125125
BLOB_SIDECAR_SUBNET_COUNT: 6
126+
127+
# DAS
128+
CUSTODY_REQUIREMENT: 1
129+
DATA_COLUMN_SIDECAR_SUBNET_COUNT: 32
130+
NUMBER_OF_COLUMNS: 128

common/eth2_network_config/built_in_network_configs/mainnet/config.yaml

+7
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,8 @@ DENEB_FORK_EPOCH: 269568 # March 13, 2024, 01:55:35pm UTC
5353
# Electra
5454
ELECTRA_FORK_VERSION: 0x05000000
5555
ELECTRA_FORK_EPOCH: 18446744073709551615
56+
# PeerDAS
57+
EIP7594_FORK_EPOCH: 18446744073709551615
5658

5759

5860
# Time parameters
@@ -143,3 +145,8 @@ MAX_REQUEST_BLOB_SIDECARS: 768
143145
MIN_EPOCHS_FOR_BLOB_SIDECARS_REQUESTS: 4096
144146
# `6`
145147
BLOB_SIDECAR_SUBNET_COUNT: 6
148+
149+
# DAS
150+
CUSTODY_REQUIREMENT: 1
151+
DATA_COLUMN_SIDECAR_SUBNET_COUNT: 32
152+
NUMBER_OF_COLUMNS: 128

common/eth2_network_config/built_in_network_configs/sepolia/config.yaml

+5
Original file line numberDiff line numberDiff line change
@@ -119,3 +119,8 @@ MAX_REQUEST_BLOB_SIDECARS: 768
119119
MIN_EPOCHS_FOR_BLOB_SIDECARS_REQUESTS: 4096
120120
# `6`
121121
BLOB_SIDECAR_SUBNET_COUNT: 6
122+
123+
# DAS
124+
CUSTODY_REQUIREMENT: 1
125+
DATA_COLUMN_SIDECAR_SUBNET_COUNT: 32
126+
NUMBER_OF_COLUMNS: 128
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# Mainnet preset - EIP7594
2+
3+
# Misc
4+
# ---------------------------------------------------------------
5+
# `uint64(2**6)` (= 64)
6+
FIELD_ELEMENTS_PER_CELL: 64
7+
# `uint64(2 * 4096)` (= 8192)
8+
FIELD_ELEMENTS_PER_EXT_BLOB: 8192
9+
# uint64(floorlog2(get_generalized_index(BeaconBlockBody, 'blob_kzg_commitments'))
10+
KZG_COMMITMENTS_INCLUSION_PROOF_DEPTH: 4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# Mainnet preset - EIP7594
2+
3+
# Misc
4+
# ---------------------------------------------------------------
5+
# `uint64(2**6)` (= 64)
6+
FIELD_ELEMENTS_PER_CELL: 64
7+
# `uint64(2 * 4096)` (= 8192)
8+
FIELD_ELEMENTS_PER_EXT_BLOB: 8192
9+
# uint64(floorlog2(get_generalized_index(BeaconBlockBody, 'blob_kzg_commitments'))
10+
KZG_COMMITMENTS_INCLUSION_PROOF_DEPTH: 4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# Minimal preset - EIP7594
2+
3+
# Misc
4+
# ---------------------------------------------------------------
5+
# `uint64(2**6)` (= 64)
6+
FIELD_ELEMENTS_PER_CELL: 64
7+
# `uint64(2 * 4096)` (= 8192)
8+
FIELD_ELEMENTS_PER_EXT_BLOB: 8192
9+
# uint64(floorlog2(get_generalized_index(BeaconBlockBody, 'blob_kzg_commitments'))
10+
KZG_COMMITMENTS_INCLUSION_PROOF_DEPTH: 4

consensus/types/src/chain_spec.rs

+102-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
use crate::application_domain::{ApplicationDomain, APPLICATION_DOMAIN_BUILDER};
22
use crate::blob_sidecar::BlobIdentifier;
3+
use crate::data_column_sidecar::DataColumnIdentifier;
34
use crate::*;
45
use int_to_bytes::int_to_bytes4;
56
use safe_arith::{ArithError, SafeArith};
@@ -193,6 +194,9 @@ pub struct ChainSpec {
193194
/*
194195
* DAS params
195196
*/
197+
pub eip7594_fork_epoch: Option<Epoch>,
198+
pub custody_requirement: u64,
199+
pub data_column_sidecar_subnet_count: u64,
196200
pub number_of_columns: usize,
197201

198202
/*
@@ -223,6 +227,7 @@ pub struct ChainSpec {
223227
*/
224228
pub max_request_blocks_deneb: u64,
225229
pub max_request_blob_sidecars: u64,
230+
pub max_request_data_column_sidecars: u64,
226231
pub min_epochs_for_blob_sidecars_requests: u64,
227232
pub blob_sidecar_subnet_count: u64,
228233

@@ -234,6 +239,7 @@ pub struct ChainSpec {
234239
pub max_blocks_by_root_request: usize,
235240
pub max_blocks_by_root_request_deneb: usize,
236241
pub max_blobs_by_root_request: usize,
242+
pub max_data_columns_by_root_request: usize,
237243

238244
/*
239245
* Application params
@@ -413,6 +419,13 @@ impl ChainSpec {
413419
}
414420
}
415421

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+
416429
/// Returns a full `Fork` struct for a given epoch.
417430
pub fn fork_at_epoch(&self, epoch: Epoch) -> Fork {
418431
let current_fork_name = self.fork_name_at_epoch(epoch);
@@ -587,6 +600,12 @@ impl ChainSpec {
587600
}
588601
}
589602

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+
590609
/// Returns a `ChainSpec` compatible with the Ethereum Foundation specification.
591610
pub fn mainnet() -> Self {
592611
Self {
@@ -777,6 +796,12 @@ impl ChainSpec {
777796
})
778797
.expect("calculation does not overflow"),
779798

799+
/*
800+
* DAS params
801+
*/
802+
eip7594_fork_epoch: None,
803+
custody_requirement: 1,
804+
data_column_sidecar_subnet_count: 32,
780805
number_of_columns: 128,
781806

782807
/*
@@ -808,6 +833,7 @@ impl ChainSpec {
808833
*/
809834
max_request_blocks_deneb: default_max_request_blocks_deneb(),
810835
max_request_blob_sidecars: default_max_request_blob_sidecars(),
836+
max_request_data_column_sidecars: default_max_request_data_column_sidecars(),
811837
min_epochs_for_blob_sidecars_requests: default_min_epochs_for_blob_sidecars_requests(),
812838
blob_sidecar_subnet_count: default_blob_sidecar_subnet_count(),
813839

@@ -817,6 +843,7 @@ impl ChainSpec {
817843
max_blocks_by_root_request: default_max_blocks_by_root_request(),
818844
max_blocks_by_root_request_deneb: default_max_blocks_by_root_request_deneb(),
819845
max_blobs_by_root_request: default_max_blobs_by_root_request(),
846+
max_data_columns_by_root_request: default_data_columns_by_root_request(),
820847

821848
/*
822849
* Application specific
@@ -888,6 +915,8 @@ impl ChainSpec {
888915
u64::checked_pow(2, 7)?.checked_mul(u64::checked_pow(10, 9)?)
889916
})
890917
.expect("calculation does not overflow"),
918+
// PeerDAS
919+
eip7594_fork_epoch: None,
891920
// Other
892921
network_id: 2, // lighthouse testnet network id
893922
deposit_chain_id: 5,
@@ -1089,8 +1118,13 @@ impl ChainSpec {
10891118
})
10901119
.expect("calculation does not overflow"),
10911120

1121+
/*
1122+
* DAS params
1123+
*/
1124+
eip7594_fork_epoch: None,
1125+
custody_requirement: 1,
1126+
data_column_sidecar_subnet_count: 32,
10921127
number_of_columns: 128,
1093-
10941128
/*
10951129
* Network specific
10961130
*/
@@ -1120,6 +1154,7 @@ impl ChainSpec {
11201154
*/
11211155
max_request_blocks_deneb: default_max_request_blocks_deneb(),
11221156
max_request_blob_sidecars: default_max_request_blob_sidecars(),
1157+
max_request_data_column_sidecars: default_max_request_data_column_sidecars(),
11231158
min_epochs_for_blob_sidecars_requests: 16384,
11241159
blob_sidecar_subnet_count: default_blob_sidecar_subnet_count(),
11251160

@@ -1129,6 +1164,7 @@ impl ChainSpec {
11291164
max_blocks_by_root_request: default_max_blocks_by_root_request(),
11301165
max_blocks_by_root_request_deneb: default_max_blocks_by_root_request_deneb(),
11311166
max_blobs_by_root_request: default_max_blobs_by_root_request(),
1167+
max_data_columns_by_root_request: default_data_columns_by_root_request(),
11321168

11331169
/*
11341170
* Application specific
@@ -1222,6 +1258,11 @@ pub struct Config {
12221258
#[serde(deserialize_with = "deserialize_fork_epoch")]
12231259
pub electra_fork_epoch: Option<MaybeQuoted<Epoch>>,
12241260

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+
12251266
#[serde(with = "serde_utils::quoted_u64")]
12261267
seconds_per_slot: u64,
12271268
#[serde(with = "serde_utils::quoted_u64")]
@@ -1307,6 +1348,9 @@ pub struct Config {
13071348
#[serde(default = "default_max_request_blob_sidecars")]
13081349
#[serde(with = "serde_utils::quoted_u64")]
13091350
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,
13101354
#[serde(default = "default_min_epochs_for_blob_sidecars_requests")]
13111355
#[serde(with = "serde_utils::quoted_u64")]
13121356
min_epochs_for_blob_sidecars_requests: u64,
@@ -1320,6 +1364,13 @@ pub struct Config {
13201364
#[serde(default = "default_max_per_epoch_activation_exit_churn_limit")]
13211365
#[serde(with = "serde_utils::quoted_u64")]
13221366
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,
13231374
}
13241375

13251376
fn default_bellatrix_fork_version() -> [u8; 4] {
@@ -1426,6 +1477,10 @@ const fn default_max_request_blob_sidecars() -> u64 {
14261477
768
14271478
}
14281479

1480+
const fn default_max_request_data_column_sidecars() -> u64 {
1481+
16384
1482+
}
1483+
14291484
const fn default_min_epochs_for_blob_sidecars_requests() -> u64 {
14301485
4096
14311486
}
@@ -1479,6 +1534,20 @@ fn max_blobs_by_root_request_common(max_request_blob_sidecars: u64) -> usize {
14791534
.len()
14801535
}
14811536

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+
14821551
fn default_max_blocks_by_root_request() -> usize {
14831552
max_blocks_by_root_request_common(default_max_request_blocks())
14841553
}
@@ -1491,6 +1560,10 @@ fn default_max_blobs_by_root_request() -> usize {
14911560
max_blobs_by_root_request_common(default_max_request_blob_sidecars())
14921561
}
14931562

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+
14941567
impl Default for Config {
14951568
fn default() -> Self {
14961569
let chain_spec = MainnetEthSpec::default_spec();
@@ -1580,6 +1653,10 @@ impl Config {
15801653
.electra_fork_epoch
15811654
.map(|epoch| MaybeQuoted { value: epoch }),
15821655

1656+
eip7594_fork_epoch: spec
1657+
.eip7594_fork_epoch
1658+
.map(|epoch| MaybeQuoted { value: epoch }),
1659+
15831660
seconds_per_slot: spec.seconds_per_slot,
15841661
seconds_per_eth1_block: spec.seconds_per_eth1_block,
15851662
min_validator_withdrawability_delay: spec.min_validator_withdrawability_delay,
@@ -1616,12 +1693,17 @@ impl Config {
16161693
attestation_subnet_shuffling_prefix_bits: spec.attestation_subnet_shuffling_prefix_bits,
16171694
max_request_blocks_deneb: spec.max_request_blocks_deneb,
16181695
max_request_blob_sidecars: spec.max_request_blob_sidecars,
1696+
max_request_data_column_sidecars: spec.max_request_data_column_sidecars,
16191697
min_epochs_for_blob_sidecars_requests: spec.min_epochs_for_blob_sidecars_requests,
16201698
blob_sidecar_subnet_count: spec.blob_sidecar_subnet_count,
16211699

16221700
min_per_epoch_churn_limit_electra: spec.min_per_epoch_churn_limit_electra,
16231701
max_per_epoch_activation_exit_churn_limit: spec
16241702
.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,
16251707
}
16261708
}
16271709

@@ -1655,6 +1737,7 @@ impl Config {
16551737
deneb_fork_version,
16561738
electra_fork_epoch,
16571739
electra_fork_version,
1740+
eip7594_fork_epoch,
16581741
seconds_per_slot,
16591742
seconds_per_eth1_block,
16601743
min_validator_withdrawability_delay,
@@ -1687,10 +1770,15 @@ impl Config {
16871770
maximum_gossip_clock_disparity_millis,
16881771
max_request_blocks_deneb,
16891772
max_request_blob_sidecars,
1773+
max_request_data_column_sidecars,
16901774
min_epochs_for_blob_sidecars_requests,
16911775
blob_sidecar_subnet_count,
1776+
16921777
min_per_epoch_churn_limit_electra,
16931778
max_per_epoch_activation_exit_churn_limit,
1779+
custody_requirement,
1780+
data_column_sidecar_subnet_count,
1781+
number_of_columns,
16941782
} = self;
16951783

16961784
if preset_base != E::spec_name().to_string().as_str() {
@@ -1713,6 +1801,7 @@ impl Config {
17131801
deneb_fork_version,
17141802
electra_fork_epoch: electra_fork_epoch.map(|q| q.value),
17151803
electra_fork_version,
1804+
eip7594_fork_epoch: eip7594_fork_epoch.map(|q| q.value),
17161805
seconds_per_slot,
17171806
seconds_per_eth1_block,
17181807
min_validator_withdrawability_delay,
@@ -1749,8 +1838,10 @@ impl Config {
17491838
maximum_gossip_clock_disparity_millis,
17501839
max_request_blocks_deneb,
17511840
max_request_blob_sidecars,
1841+
max_request_data_column_sidecars,
17521842
min_epochs_for_blob_sidecars_requests,
17531843
blob_sidecar_subnet_count,
1844+
17541845
min_per_epoch_churn_limit_electra,
17551846
max_per_epoch_activation_exit_churn_limit,
17561847

@@ -1760,6 +1851,13 @@ impl Config {
17601851
max_request_blocks_deneb,
17611852
),
17621853
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,
17631861

17641862
..chain_spec.clone()
17651863
})
@@ -2001,6 +2099,9 @@ mod yaml_tests {
20012099
DEPOSIT_CHAIN_ID: 1
20022100
DEPOSIT_NETWORK_ID: 1
20032101
DEPOSIT_CONTRACT_ADDRESS: 0x00000000219ab540356cBB839Cbe05303d7705Fa
2102+
CUSTODY_REQUIREMENT: 1
2103+
DATA_COLUMN_SIDECAR_SUBNET_COUNT: 32
2104+
NUMBER_OF_COLUMNS: 128
20042105
"#;
20052106

20062107
let chain_spec: Config = serde_yaml::from_str(spec).unwrap();

0 commit comments

Comments
 (0)