diff --git a/beacon_node/beacon_chain/src/data_availability_checker.rs b/beacon_node/beacon_chain/src/data_availability_checker.rs index 0ccee82641c..7e11a163d5a 100644 --- a/beacon_node/beacon_chain/src/data_availability_checker.rs +++ b/beacon_node/beacon_chain/src/data_availability_checker.rs @@ -87,7 +87,7 @@ impl DataAvailabilityChecker { let custody_subnet_count = if import_all_data_columns { T::EthSpec::data_column_subnet_count() } else { - T::EthSpec::min_custody_requirement() + T::EthSpec::custody_requirement() }; let custody_column_count = diff --git a/beacon_node/beacon_chain/src/data_availability_checker/overflow_lru_cache.rs b/beacon_node/beacon_chain/src/data_availability_checker/overflow_lru_cache.rs index 8c7f1a77d51..759ccc9a2d5 100644 --- a/beacon_node/beacon_chain/src/data_availability_checker/overflow_lru_cache.rs +++ b/beacon_node/beacon_chain/src/data_availability_checker/overflow_lru_cache.rs @@ -63,7 +63,7 @@ pub type DataColumnsToPublish = Option>>>; pub struct PendingComponents { pub block_root: Hash256, pub verified_blobs: FixedVector>, E::MaxBlobsPerBlock>, - pub verified_data_columns: VariableList, E::DataColumnCount>, + pub verified_data_columns: VariableList, E::NumberOfColumns>, pub executed_block: Option>, } diff --git a/beacon_node/beacon_chain/src/data_column_verification.rs b/beacon_node/beacon_chain/src/data_column_verification.rs index fa43fa170eb..1ae59da6ed5 100644 --- a/beacon_node/beacon_chain/src/data_column_verification.rs +++ b/beacon_node/beacon_chain/src/data_column_verification.rs @@ -149,7 +149,7 @@ impl From for GossipDataColumnError { pub type GossipVerifiedDataColumnList = VariableList< GossipVerifiedDataColumn, - <::EthSpec as EthSpec>::DataColumnCount, + <::EthSpec as EthSpec>::NumberOfColumns, >; /// A wrapper around a `DataColumnSidecar` that indicates it has been approved for re-gossiping on @@ -243,7 +243,7 @@ impl KzgVerifiedDataColumn { } pub type CustodyDataColumnList = - VariableList, ::DataColumnCount>; + VariableList, ::NumberOfColumns>; /// Data column that we must custody #[derive(Debug, Derivative, Clone, Encode, Decode)] diff --git a/beacon_node/lighthouse_network/src/discovery/enr.rs b/beacon_node/lighthouse_network/src/discovery/enr.rs index 9235b2bfe70..d6214423212 100644 --- a/beacon_node/lighthouse_network/src/discovery/enr.rs +++ b/beacon_node/lighthouse_network/src/discovery/enr.rs @@ -69,7 +69,7 @@ impl Eth2Enr for Enr { fn custody_subnet_count(&self) -> u64 { self.get(PEERDAS_CUSTODY_SUBNET_COUNT_ENR_KEY) .and_then(|custody_bytes| u64::from_ssz_bytes(custody_bytes).ok()) - .unwrap_or(E::min_custody_requirement() as u64) + .unwrap_or(E::custody_requirement() as u64) } fn eth2(&self) -> Result { @@ -238,7 +238,7 @@ pub fn build_enr( let custody_subnet_count = if config.subscribe_all_data_column_subnets { E::data_column_subnet_count() as u64 } else { - E::min_custody_requirement() as u64 + E::custody_requirement() as u64 }; builder.add_value( diff --git a/beacon_node/lighthouse_network/src/types/globals.rs b/beacon_node/lighthouse_network/src/types/globals.rs index 263755ca6cb..fa1501cbf18 100644 --- a/beacon_node/lighthouse_network/src/types/globals.rs +++ b/beacon_node/lighthouse_network/src/types/globals.rs @@ -151,7 +151,7 @@ mod test { fn test_custody_count_default() { let log = logging::test_logger(); let default_custody_requirement_column_count = - E::number_of_columns() / E::data_column_subnet_count() * E::min_custody_requirement(); + E::number_of_columns() / E::data_column_subnet_count() * E::custody_requirement(); let globals = NetworkGlobals::::new_test_globals(vec![], &log); let any_epoch = Epoch::new(0); let columns = globals.custody_columns(any_epoch).unwrap(); diff --git a/beacon_node/network/src/sync/block_lookups/tests.rs b/beacon_node/network/src/sync/block_lookups/tests.rs index 38e74ba0d57..173ae761f65 100644 --- a/beacon_node/network/src/sync/block_lookups/tests.rs +++ b/beacon_node/network/src/sync/block_lookups/tests.rs @@ -1866,7 +1866,7 @@ fn custody_lookup_happy_path() { // Should not request blobs let id = r.expect_block_lookup_request(block.canonical_root()); r.complete_valid_block_request(id, block.into(), true); - let custody_column_count = E::min_custody_requirement() * E::data_columns_per_subnet(); + let custody_column_count = E::custody_requirement() * E::data_columns_per_subnet(); let custody_ids = r.expect_only_data_columns_by_root_requests(block_root, custody_column_count); r.complete_valid_custody_request(custody_ids, data_columns, false); r.expect_no_active_lookups(); diff --git a/consensus/types/presets/gnosis/deneb.yaml b/consensus/types/presets/gnosis/deneb.yaml index bef51470e89..d2d7d0abed3 100644 --- a/consensus/types/presets/gnosis/deneb.yaml +++ b/consensus/types/presets/gnosis/deneb.yaml @@ -12,12 +12,3 @@ MAX_BLOB_COMMITMENTS_PER_BLOCK: 4096 MAX_BLOBS_PER_BLOCK: 6 # `floorlog2(BLOB_KZG_COMMITMENTS_GINDEX) + 1 + ceillog2(MAX_BLOB_COMMITMENTS_PER_BLOCK)` = 4 + 1 + 12 = 17 KZG_COMMITMENT_INCLUSION_PROOF_DEPTH: 17 - -# EIP-7594 (temporary in Deneb for the purpose of prototyping) -# --------------------------------------------------------------- -# `uint64(2**6)` (= 64) -FIELD_ELEMENTS_PER_CELL: 64 -# uint64(floorlog2(get_generalized_index(BeaconBlockBody, 'blob_kzg_commitments')) -KZG_COMMITMENTS_INCLUSION_PROOF_DEPTH: 4 -# `uint64((FIELD_ELEMENTS_PER_BLOB * 2) // FIELD_ELEMENTS_PER_CELL)` (= 128) -NUMBER_OF_COLUMNS: 128 \ No newline at end of file diff --git a/consensus/types/presets/gnosis/eip7594.yaml b/consensus/types/presets/gnosis/eip7594.yaml new file mode 100644 index 00000000000..813febf26d5 --- /dev/null +++ b/consensus/types/presets/gnosis/eip7594.yaml @@ -0,0 +1,10 @@ +# Mainnet preset - EIP7594 + +# Misc +# --------------------------------------------------------------- +# `uint64(2**6)` (= 64) +FIELD_ELEMENTS_PER_CELL: 64 +# `uint64(2 * 4096)` (= 8192) +FIELD_ELEMENTS_PER_EXT_BLOB: 8192 +# uint64(floorlog2(get_generalized_index(BeaconBlockBody, 'blob_kzg_commitments')) +KZG_COMMITMENTS_INCLUSION_PROOF_DEPTH: 4 diff --git a/consensus/types/presets/mainnet/deneb.yaml b/consensus/types/presets/mainnet/deneb.yaml index 44bc5034294..0f56b8bdfac 100644 --- a/consensus/types/presets/mainnet/deneb.yaml +++ b/consensus/types/presets/mainnet/deneb.yaml @@ -10,12 +10,3 @@ MAX_BLOB_COMMITMENTS_PER_BLOCK: 4096 MAX_BLOBS_PER_BLOCK: 6 # `floorlog2(get_generalized_index(BeaconBlockBody, 'blob_kzg_commitments')) + 1 + ceillog2(MAX_BLOB_COMMITMENTS_PER_BLOCK)` = 4 + 1 + 12 = 17 KZG_COMMITMENT_INCLUSION_PROOF_DEPTH: 17 - -# EIP-7594 (temporary in Deneb for the purpose of prototyping) -# --------------------------------------------------------------- -# `uint64(2**6)` (= 64) -FIELD_ELEMENTS_PER_CELL: 64 -# uint64(floorlog2(get_generalized_index(BeaconBlockBody, 'blob_kzg_commitments')) -KZG_COMMITMENTS_INCLUSION_PROOF_DEPTH: 4 -# `uint64((FIELD_ELEMENTS_PER_BLOB * 2) // FIELD_ELEMENTS_PER_CELL)` (= 128) -NUMBER_OF_COLUMNS: 128 \ No newline at end of file diff --git a/consensus/types/presets/mainnet/eip7594.yaml b/consensus/types/presets/mainnet/eip7594.yaml new file mode 100644 index 00000000000..813febf26d5 --- /dev/null +++ b/consensus/types/presets/mainnet/eip7594.yaml @@ -0,0 +1,10 @@ +# Mainnet preset - EIP7594 + +# Misc +# --------------------------------------------------------------- +# `uint64(2**6)` (= 64) +FIELD_ELEMENTS_PER_CELL: 64 +# `uint64(2 * 4096)` (= 8192) +FIELD_ELEMENTS_PER_EXT_BLOB: 8192 +# uint64(floorlog2(get_generalized_index(BeaconBlockBody, 'blob_kzg_commitments')) +KZG_COMMITMENTS_INCLUSION_PROOF_DEPTH: 4 diff --git a/consensus/types/presets/minimal/deneb.yaml b/consensus/types/presets/minimal/deneb.yaml index 8bb3e0b66bd..be2b9fadfa5 100644 --- a/consensus/types/presets/minimal/deneb.yaml +++ b/consensus/types/presets/minimal/deneb.yaml @@ -10,12 +10,3 @@ MAX_BLOB_COMMITMENTS_PER_BLOCK: 16 MAX_BLOBS_PER_BLOCK: 6 # [customized] `floorlog2(BLOB_KZG_COMMITMENTS_GINDEX) + 1 + ceillog2(MAX_BLOB_COMMITMENTS_PER_BLOCK)` = 4 + 1 + 4 = 9 KZG_COMMITMENT_INCLUSION_PROOF_DEPTH: 9 - -# EIP-7594 (temporary in Deneb for the purpose of prototyping) -# --------------------------------------------------------------- -# `uint64(2**6)` (= 64) -FIELD_ELEMENTS_PER_CELL: 64 -# uint64(floorlog2(get_generalized_index(BeaconBlockBody, 'blob_kzg_commitments')) -KZG_COMMITMENTS_INCLUSION_PROOF_DEPTH: 4 -# `uint64((FIELD_ELEMENTS_PER_BLOB * 2) // FIELD_ELEMENTS_PER_CELL)` (= 128) -NUMBER_OF_COLUMNS: 128 \ No newline at end of file diff --git a/consensus/types/presets/minimal/eip7594.yaml b/consensus/types/presets/minimal/eip7594.yaml new file mode 100644 index 00000000000..847719a4210 --- /dev/null +++ b/consensus/types/presets/minimal/eip7594.yaml @@ -0,0 +1,10 @@ +# Minimal preset - EIP7594 + +# Misc +# --------------------------------------------------------------- +# `uint64(2**6)` (= 64) +FIELD_ELEMENTS_PER_CELL: 64 +# `uint64(2 * 4096)` (= 8192) +FIELD_ELEMENTS_PER_EXT_BLOB: 8192 +# uint64(floorlog2(get_generalized_index(BeaconBlockBody, 'blob_kzg_commitments')) +KZG_COMMITMENTS_INCLUSION_PROOF_DEPTH: 4 diff --git a/consensus/types/src/data_column_sidecar.rs b/consensus/types/src/data_column_sidecar.rs index 62324fdef62..c6183414c5d 100644 --- a/consensus/types/src/data_column_sidecar.rs +++ b/consensus/types/src/data_column_sidecar.rs @@ -383,9 +383,9 @@ impl From for DataColumnSidecarError { } pub type DataColumnSidecarList = - VariableList>, ::DataColumnCount>; + VariableList>, ::NumberOfColumns>; pub type FixedDataColumnSidecarList = - FixedVector>>, ::DataColumnCount>; + FixedVector>>, ::NumberOfColumns>; /// Converts a cell ssz List object to an array to be used with the kzg /// crypto library. diff --git a/consensus/types/src/eth_spec.rs b/consensus/types/src/eth_spec.rs index d6481a1ecde..157287c4836 100644 --- a/consensus/types/src/eth_spec.rs +++ b/consensus/types/src/eth_spec.rs @@ -110,17 +110,20 @@ pub trait EthSpec: type MaxBlobsPerBlock: Unsigned + Clone + Sync + Send + Debug + PartialEq + Unpin; type MaxBlobCommitmentsPerBlock: Unsigned + Clone + Sync + Send + Debug + PartialEq + Unpin; type FieldElementsPerBlob: Unsigned + Clone + Sync + Send + Debug + PartialEq; - type FieldElementsPerCell: Unsigned + Clone + Sync + Send + Debug + PartialEq; type BytesPerFieldElement: Unsigned + Clone + Sync + Send + Debug + PartialEq; type KzgCommitmentInclusionProofDepth: Unsigned + Clone + Sync + Send + Debug + PartialEq; /* * New in PeerDAS */ - type MinCustodyRequirement: Unsigned + Clone + Sync + Send + Debug + PartialEq; - type DataColumnSubnetCount: Unsigned + Clone + Sync + Send + Debug + PartialEq; - type DataColumnCount: Unsigned + Clone + Sync + Send + Debug + PartialEq; - type DataColumnsPerSubnet: Unsigned + Clone + Sync + Send + Debug + PartialEq; + type FieldElementsPerCell: Unsigned + Clone + Sync + Send + Debug + PartialEq; + type FieldElementsPerExtBlob: Unsigned + Clone + Sync + Send + Debug + PartialEq; type KzgCommitmentsInclusionProofDepth: Unsigned + Clone + Sync + Send + Debug + PartialEq; + /* + * Config values in PeerDAS + */ + type CustodyRequirement: Unsigned + Clone + Sync + Send + Debug + PartialEq; + type DataColumnSidecarSubnetCount: Unsigned + Clone + Sync + Send + Debug + PartialEq; + type NumberOfColumns: Unsigned + Clone + Sync + Send + Debug + PartialEq; /* * Derived values (set these CAREFULLY) */ @@ -149,6 +152,11 @@ pub trait EthSpec: /// Must be set to `BytesPerFieldElement * FieldElementsPerCell`. type BytesPerCell: Unsigned + Clone + Sync + Send + Debug + PartialEq; + /// Number of data columns per subnet. + /// + /// Must be set to `NumberOfColumns / DataColumnSidecarSubnetCount` + type DataColumnsPerSubnet: Unsigned + Clone + Sync + Send + Debug + PartialEq; + /* * New in Electra */ @@ -296,6 +304,11 @@ pub trait EthSpec: Self::FieldElementsPerBlob::to_usize() } + /// Returns the `FIELD_ELEMENTS_PER_EXT_BLOB` constant for this specification. + fn field_elements_per_ext_blob() -> usize { + Self::FieldElementsPerExtBlob::to_usize() + } + /// Returns the `FIELD_ELEMENTS_PER_CELL` constant for this specification. fn field_elements_per_cell() -> usize { Self::FieldElementsPerCell::to_usize() @@ -352,19 +365,19 @@ pub trait EthSpec: } fn number_of_columns() -> usize { - Self::DataColumnCount::to_usize() + Self::NumberOfColumns::to_usize() } fn data_columns_per_subnet() -> usize { Self::DataColumnsPerSubnet::to_usize() } - fn min_custody_requirement() -> usize { - Self::MinCustodyRequirement::to_usize() + fn custody_requirement() -> usize { + Self::CustodyRequirement::to_usize() } fn data_column_subnet_count() -> usize { - Self::DataColumnSubnetCount::to_usize() + Self::DataColumnSidecarSubnetCount::to_usize() } fn kzg_commitments_inclusion_proof_depth() -> usize { @@ -414,13 +427,14 @@ impl EthSpec for MainnetEthSpec { type BytesPerFieldElement = U32; type FieldElementsPerBlob = U4096; type FieldElementsPerCell = U64; + type FieldElementsPerExtBlob = U8192; type BytesPerBlob = U131072; type BytesPerCell = U2048; type KzgCommitmentInclusionProofDepth = U17; - type MinCustodyRequirement = U4; - type DataColumnSubnetCount = U64; - type DataColumnCount = U128; - type DataColumnsPerSubnet = U4; + type CustodyRequirement = U4; + type DataColumnSidecarSubnetCount = U64; + type NumberOfColumns = U128; + type DataColumnsPerSubnet = U2; type KzgCommitmentsInclusionProofDepth = U4; // inclusion of the whole list of commitments type SyncSubcommitteeSize = U128; // 512 committee size / 4 sync committee subnet count type MaxPendingAttestations = U4096; // 128 max attestations * 32 slots per epoch @@ -461,20 +475,20 @@ impl EthSpec for MinimalEthSpec { type SlotsPerEth1VotingPeriod = U32; // 4 epochs * 8 slots per epoch type MaxWithdrawalsPerPayload = U4; type FieldElementsPerBlob = U4096; - type FieldElementsPerCell = U64; type BytesPerBlob = U131072; - type BytesPerCell = U2048; type MaxBlobCommitmentsPerBlock = U16; type KzgCommitmentInclusionProofDepth = U9; type PendingPartialWithdrawalsLimit = U64; type PendingConsolidationsLimit = U64; type MaxDepositReceiptsPerPayload = U4; type MaxWithdrawalRequestsPerPayload = U2; - // DAS spec values copied from `MainnetEthSpec` - type MinCustodyRequirement = U4; - type DataColumnSubnetCount = U64; - type DataColumnCount = U128; - type DataColumnsPerSubnet = U4; + type FieldElementsPerCell = U64; + type FieldElementsPerExtBlob = U8192; + type BytesPerCell = U2048; + type CustodyRequirement = U4; + type DataColumnSidecarSubnetCount = U64; + type NumberOfColumns = U128; + type DataColumnsPerSubnet = U2; type KzgCommitmentsInclusionProofDepth = U4; params_from_eth_spec!(MainnetEthSpec { @@ -551,10 +565,8 @@ impl EthSpec for GnosisEthSpec { type MaxBlobsPerBlock = U6; type MaxBlobCommitmentsPerBlock = U4096; type FieldElementsPerBlob = U4096; - type FieldElementsPerCell = U64; type BytesPerFieldElement = U32; type BytesPerBlob = U131072; - type BytesPerCell = U2048; type KzgCommitmentInclusionProofDepth = U17; type PendingBalanceDepositsLimit = U134217728; type PendingPartialWithdrawalsLimit = U134217728; @@ -564,11 +576,13 @@ impl EthSpec for GnosisEthSpec { type MaxAttesterSlashingsElectra = U1; type MaxAttestationsElectra = U8; type MaxWithdrawalRequestsPerPayload = U16; - // DAS spec values copied from `MainnetEthSpec` - type MinCustodyRequirement = U4; - type DataColumnSubnetCount = U64; - type DataColumnCount = U128; - type DataColumnsPerSubnet = U4; + type FieldElementsPerCell = U64; + type FieldElementsPerExtBlob = U8192; + type BytesPerCell = U2048; + type CustodyRequirement = U4; + type DataColumnSidecarSubnetCount = U64; + type NumberOfColumns = U128; + type DataColumnsPerSubnet = U2; type KzgCommitmentsInclusionProofDepth = U4; fn default_spec() -> ChainSpec { diff --git a/consensus/types/src/preset.rs b/consensus/types/src/preset.rs index a0cd61e0251..b0f67beec0d 100644 --- a/consensus/types/src/preset.rs +++ b/consensus/types/src/preset.rs @@ -214,13 +214,6 @@ pub struct DenebPreset { pub max_blob_commitments_per_block: u64, #[serde(with = "serde_utils::quoted_u64")] pub field_elements_per_blob: u64, - // EIP-7594 DAS presets - to be moved to the next fork - #[serde(with = "serde_utils::quoted_u64")] - pub field_elements_per_cell: u64, - #[serde(with = "serde_utils::quoted_u64")] - pub kzg_commitments_inclusion_proof_depth: u64, - #[serde(with = "serde_utils::quoted_u64")] - pub number_of_columns: u64, } impl DenebPreset { @@ -229,10 +222,6 @@ impl DenebPreset { max_blobs_per_block: E::max_blobs_per_block() as u64, max_blob_commitments_per_block: E::max_blob_commitments_per_block() as u64, field_elements_per_blob: E::field_elements_per_blob() as u64, - field_elements_per_cell: E::field_elements_per_cell() as u64, - kzg_commitments_inclusion_proof_depth: E::kzg_commitments_inclusion_proof_depth() - as u64, - number_of_columns: E::number_of_columns() as u64, } } } @@ -289,6 +278,28 @@ impl ElectraPreset { } } +#[derive(Debug, PartialEq, Clone, Serialize, Deserialize)] +#[serde(rename_all = "UPPERCASE")] +pub struct Eip7594Preset { + #[serde(with = "serde_utils::quoted_u64")] + pub field_elements_per_cell: u64, + #[serde(with = "serde_utils::quoted_u64")] + pub field_elements_per_ext_blob: u64, + #[serde(with = "serde_utils::quoted_u64")] + pub kzg_commitments_inclusion_proof_depth: u64, +} + +impl Eip7594Preset { + pub fn from_chain_spec(_spec: &ChainSpec) -> Self { + Self { + field_elements_per_cell: E::field_elements_per_cell() as u64, + field_elements_per_ext_blob: E::field_elements_per_ext_blob() as u64, + kzg_commitments_inclusion_proof_depth: E::kzg_commitments_inclusion_proof_depth() + as u64, + } + } +} + #[cfg(test)] mod test { use super::*; @@ -333,6 +344,9 @@ mod test { let electra: ElectraPreset = preset_from_file(&preset_name, "electra.yaml"); assert_eq!(electra, ElectraPreset::from_chain_spec::(&spec)); + + let eip7594: Eip7594Preset = preset_from_file(&preset_name, "eip7594.yaml"); + assert_eq!(eip7594, Eip7594Preset::from_chain_spec::(&spec)); } #[test]