mirror of
https://github.com/sigp/lighthouse.git
synced 2026-03-18 20:32:45 +00:00
Electra: Add Preset, Constants, & Config (#5606)
* Electra: Add Presets, Constants, & Config
This commit is contained in:
@@ -25,6 +25,7 @@ pub enum Domain {
|
||||
SyncCommittee,
|
||||
ContributionAndProof,
|
||||
SyncCommitteeSelectionProof,
|
||||
Consolidation,
|
||||
ApplicationMask(ApplicationDomain),
|
||||
}
|
||||
|
||||
@@ -76,6 +77,7 @@ pub struct ChainSpec {
|
||||
pub genesis_fork_version: [u8; 4],
|
||||
pub bls_withdrawal_prefix_byte: u8,
|
||||
pub eth1_address_withdrawal_prefix_byte: u8,
|
||||
pub compounding_withdrawal_prefix_byte: u8,
|
||||
|
||||
/*
|
||||
* Time parameters
|
||||
@@ -108,6 +110,7 @@ pub struct ChainSpec {
|
||||
pub(crate) domain_voluntary_exit: u32,
|
||||
pub(crate) domain_selection_proof: u32,
|
||||
pub(crate) domain_aggregate_and_proof: u32,
|
||||
pub(crate) domain_consolidation: u32,
|
||||
|
||||
/*
|
||||
* Fork choice
|
||||
@@ -177,6 +180,15 @@ pub struct ChainSpec {
|
||||
pub electra_fork_version: [u8; 4],
|
||||
/// The Electra fork epoch is optional, with `None` representing "Electra never happens".
|
||||
pub electra_fork_epoch: Option<Epoch>,
|
||||
pub unset_deposit_receipts_start_index: u64,
|
||||
pub full_exit_request_amount: u64,
|
||||
pub min_activation_balance: u64,
|
||||
pub max_effective_balance_electra: u64,
|
||||
pub min_slashing_penalty_quotient_electra: u64,
|
||||
pub whistleblower_reward_quotient_electra: u64,
|
||||
pub max_pending_partials_per_withdrawals_sweep: u64,
|
||||
pub min_per_epoch_churn_limit_electra: u64,
|
||||
pub max_per_epoch_activation_exit_churn_limit: u64,
|
||||
|
||||
/*
|
||||
* Networking
|
||||
@@ -364,7 +376,9 @@ impl ChainSpec {
|
||||
state: &BeaconState<E>,
|
||||
) -> u64 {
|
||||
let fork_name = state.fork_name_unchecked();
|
||||
if fork_name >= ForkName::Merge {
|
||||
if fork_name >= ForkName::Electra {
|
||||
self.min_slashing_penalty_quotient_electra
|
||||
} else if fork_name >= ForkName::Merge {
|
||||
self.min_slashing_penalty_quotient_bellatrix
|
||||
} else if fork_name >= ForkName::Altair {
|
||||
self.min_slashing_penalty_quotient_altair
|
||||
@@ -418,6 +432,7 @@ impl ChainSpec {
|
||||
Domain::SyncCommitteeSelectionProof => self.domain_sync_committee_selection_proof,
|
||||
Domain::ApplicationMask(application_domain) => application_domain.get_domain_constant(),
|
||||
Domain::BlsToExecutionChange => self.domain_bls_to_execution_change,
|
||||
Domain::Consolidation => self.domain_consolidation,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -602,6 +617,7 @@ impl ChainSpec {
|
||||
genesis_fork_version: [0; 4],
|
||||
bls_withdrawal_prefix_byte: 0x00,
|
||||
eth1_address_withdrawal_prefix_byte: 0x01,
|
||||
compounding_withdrawal_prefix_byte: 0x02,
|
||||
|
||||
/*
|
||||
* Time parameters
|
||||
@@ -635,6 +651,7 @@ impl ChainSpec {
|
||||
domain_voluntary_exit: 4,
|
||||
domain_selection_proof: 5,
|
||||
domain_aggregate_and_proof: 6,
|
||||
domain_consolidation: 0x0B,
|
||||
|
||||
/*
|
||||
* Fork choice
|
||||
@@ -709,6 +726,30 @@ impl ChainSpec {
|
||||
*/
|
||||
electra_fork_version: [0x05, 00, 00, 00],
|
||||
electra_fork_epoch: None,
|
||||
unset_deposit_receipts_start_index: u64::MAX,
|
||||
full_exit_request_amount: 0,
|
||||
min_activation_balance: option_wrapper(|| {
|
||||
u64::checked_pow(2, 5)?.checked_mul(u64::checked_pow(10, 9)?)
|
||||
})
|
||||
.expect("calculation does not overflow"),
|
||||
max_effective_balance_electra: option_wrapper(|| {
|
||||
u64::checked_pow(2, 11)?.checked_mul(u64::checked_pow(10, 9)?)
|
||||
})
|
||||
.expect("calculation does not overflow"),
|
||||
min_slashing_penalty_quotient_electra: u64::checked_pow(2, 12)
|
||||
.expect("pow does not overflow"),
|
||||
whistleblower_reward_quotient_electra: u64::checked_pow(2, 12)
|
||||
.expect("pow does not overflow"),
|
||||
max_pending_partials_per_withdrawals_sweep: u64::checked_pow(2, 3)
|
||||
.expect("pow does not overflow"),
|
||||
min_per_epoch_churn_limit_electra: option_wrapper(|| {
|
||||
u64::checked_pow(2, 7)?.checked_mul(u64::checked_pow(10, 9)?)
|
||||
})
|
||||
.expect("calculation does not overflow"),
|
||||
max_per_epoch_activation_exit_churn_limit: option_wrapper(|| {
|
||||
u64::checked_pow(2, 8)?.checked_mul(u64::checked_pow(10, 9)?)
|
||||
})
|
||||
.expect("calculation does not overflow"),
|
||||
|
||||
/*
|
||||
* Network specific
|
||||
@@ -874,6 +915,7 @@ impl ChainSpec {
|
||||
genesis_fork_version: [0x00, 0x00, 0x00, 0x64],
|
||||
bls_withdrawal_prefix_byte: 0x00,
|
||||
eth1_address_withdrawal_prefix_byte: 0x01,
|
||||
compounding_withdrawal_prefix_byte: 0x02,
|
||||
|
||||
/*
|
||||
* Time parameters
|
||||
@@ -907,6 +949,7 @@ impl ChainSpec {
|
||||
domain_voluntary_exit: 4,
|
||||
domain_selection_proof: 5,
|
||||
domain_aggregate_and_proof: 6,
|
||||
domain_consolidation: 0x0B,
|
||||
|
||||
/*
|
||||
* Fork choice
|
||||
@@ -983,6 +1026,30 @@ impl ChainSpec {
|
||||
*/
|
||||
electra_fork_version: [0x05, 0x00, 0x00, 0x64],
|
||||
electra_fork_epoch: None,
|
||||
unset_deposit_receipts_start_index: u64::MAX,
|
||||
full_exit_request_amount: 0,
|
||||
min_activation_balance: option_wrapper(|| {
|
||||
u64::checked_pow(2, 5)?.checked_mul(u64::checked_pow(10, 9)?)
|
||||
})
|
||||
.expect("calculation does not overflow"),
|
||||
max_effective_balance_electra: option_wrapper(|| {
|
||||
u64::checked_pow(2, 11)?.checked_mul(u64::checked_pow(10, 9)?)
|
||||
})
|
||||
.expect("calculation does not overflow"),
|
||||
min_slashing_penalty_quotient_electra: u64::checked_pow(2, 12)
|
||||
.expect("pow does not overflow"),
|
||||
whistleblower_reward_quotient_electra: u64::checked_pow(2, 12)
|
||||
.expect("pow does not overflow"),
|
||||
max_pending_partials_per_withdrawals_sweep: u64::checked_pow(2, 3)
|
||||
.expect("pow does not overflow"),
|
||||
min_per_epoch_churn_limit_electra: option_wrapper(|| {
|
||||
u64::checked_pow(2, 7)?.checked_mul(u64::checked_pow(10, 9)?)
|
||||
})
|
||||
.expect("calculation does not overflow"),
|
||||
max_per_epoch_activation_exit_churn_limit: option_wrapper(|| {
|
||||
u64::checked_pow(2, 8)?.checked_mul(u64::checked_pow(10, 9)?)
|
||||
})
|
||||
.expect("calculation does not overflow"),
|
||||
|
||||
/*
|
||||
* Network specific
|
||||
@@ -1206,6 +1273,13 @@ pub struct Config {
|
||||
#[serde(default = "default_blob_sidecar_subnet_count")]
|
||||
#[serde(with = "serde_utils::quoted_u64")]
|
||||
blob_sidecar_subnet_count: u64,
|
||||
|
||||
#[serde(default = "default_min_per_epoch_churn_limit_electra")]
|
||||
#[serde(with = "serde_utils::quoted_u64")]
|
||||
min_per_epoch_churn_limit_electra: u64,
|
||||
#[serde(default = "default_max_per_epoch_activation_exit_churn_limit")]
|
||||
#[serde(with = "serde_utils::quoted_u64")]
|
||||
max_per_epoch_activation_exit_churn_limit: u64,
|
||||
}
|
||||
|
||||
fn default_bellatrix_fork_version() -> [u8; 4] {
|
||||
@@ -1320,6 +1394,14 @@ const fn default_blob_sidecar_subnet_count() -> u64 {
|
||||
6
|
||||
}
|
||||
|
||||
const fn default_min_per_epoch_churn_limit_electra() -> u64 {
|
||||
128_000_000_000
|
||||
}
|
||||
|
||||
const fn default_max_per_epoch_activation_exit_churn_limit() -> u64 {
|
||||
256_000_000_000
|
||||
}
|
||||
|
||||
const fn default_epochs_per_subnet_subscription() -> u64 {
|
||||
256
|
||||
}
|
||||
@@ -1496,6 +1578,10 @@ impl Config {
|
||||
max_request_blob_sidecars: spec.max_request_blob_sidecars,
|
||||
min_epochs_for_blob_sidecars_requests: spec.min_epochs_for_blob_sidecars_requests,
|
||||
blob_sidecar_subnet_count: spec.blob_sidecar_subnet_count,
|
||||
|
||||
min_per_epoch_churn_limit_electra: spec.min_per_epoch_churn_limit_electra,
|
||||
max_per_epoch_activation_exit_churn_limit: spec
|
||||
.max_per_epoch_activation_exit_churn_limit,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1563,6 +1649,8 @@ impl Config {
|
||||
max_request_blob_sidecars,
|
||||
min_epochs_for_blob_sidecars_requests,
|
||||
blob_sidecar_subnet_count,
|
||||
min_per_epoch_churn_limit_electra,
|
||||
max_per_epoch_activation_exit_churn_limit,
|
||||
} = self;
|
||||
|
||||
if preset_base != E::spec_name().to_string().as_str() {
|
||||
@@ -1623,6 +1711,8 @@ impl Config {
|
||||
max_request_blob_sidecars,
|
||||
min_epochs_for_blob_sidecars_requests,
|
||||
blob_sidecar_subnet_count,
|
||||
min_per_epoch_churn_limit_electra,
|
||||
max_per_epoch_activation_exit_churn_limit,
|
||||
|
||||
// We need to re-derive any values that might have changed in the config.
|
||||
max_blocks_by_root_request: max_blocks_by_root_request_common(max_request_blocks),
|
||||
@@ -1695,6 +1785,7 @@ mod tests {
|
||||
&spec,
|
||||
);
|
||||
test_domain(Domain::SyncCommittee, spec.domain_sync_committee, &spec);
|
||||
test_domain(Domain::Consolidation, spec.domain_consolidation, &spec);
|
||||
|
||||
// The builder domain index is zero
|
||||
let builder_domain_pre_mask = [0; 4];
|
||||
|
||||
@@ -3,8 +3,9 @@ use crate::*;
|
||||
use safe_arith::SafeArith;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use ssz_types::typenum::{
|
||||
bit::B0, UInt, U0, U1024, U1048576, U1073741824, U1099511627776, U128, U131072, U16, U16777216,
|
||||
U2, U2048, U256, U32, U4, U4096, U512, U6, U625, U64, U65536, U8, U8192,
|
||||
bit::B0, UInt, U0, U1, U1024, U1048576, U1073741824, U1099511627776, U128, U131072, U134217728,
|
||||
U16, U16777216, U2, U2048, U256, U262144, U32, U4, U4096, U512, U6, U625, U64, U65536, U8,
|
||||
U8192,
|
||||
};
|
||||
use ssz_types::typenum::{U17, U9};
|
||||
use std::fmt::{self, Debug};
|
||||
@@ -137,7 +138,14 @@ pub trait EthSpec:
|
||||
/*
|
||||
* New in Electra
|
||||
*/
|
||||
type ElectraPlaceholder: Unsigned + Clone + Sync + Send + Debug + PartialEq;
|
||||
type PendingBalanceDepositsLimit: Unsigned + Clone + Sync + Send + Debug + PartialEq;
|
||||
type PendingPartialWithdrawalsLimit: Unsigned + Clone + Sync + Send + Debug + PartialEq;
|
||||
type PendingConsolidationsLimit: Unsigned + Clone + Sync + Send + Debug + PartialEq;
|
||||
type MaxConsolidations: Unsigned + Clone + Sync + Send + Debug + PartialEq;
|
||||
type MaxDepositReceiptsPerPayload: Unsigned + Clone + Sync + Send + Debug + PartialEq;
|
||||
type MaxAttesterSlashingsElectra: Unsigned + Clone + Sync + Send + Debug + PartialEq;
|
||||
type MaxAttestationsElectra: Unsigned + Clone + Sync + Send + Debug + PartialEq;
|
||||
type MaxWithdrawalRequestsPerPayload: Unsigned + Clone + Sync + Send + Debug + PartialEq;
|
||||
|
||||
fn default_spec() -> ChainSpec;
|
||||
|
||||
@@ -284,8 +292,44 @@ pub trait EthSpec:
|
||||
Self::KzgCommitmentInclusionProofDepth::to_usize()
|
||||
}
|
||||
|
||||
fn electra_placeholder() -> usize {
|
||||
Self::ElectraPlaceholder::to_usize()
|
||||
/// Returns the `PENDING_BALANCE_DEPOSITS_LIMIT` constant for this specification.
|
||||
fn pending_balance_deposits_limit() -> usize {
|
||||
Self::PendingBalanceDepositsLimit::to_usize()
|
||||
}
|
||||
|
||||
/// Returns the `PENDING_PARTIAL_WITHDRAWALS_LIMIT` constant for this specification.
|
||||
fn pending_partial_withdrawals_limit() -> usize {
|
||||
Self::PendingPartialWithdrawalsLimit::to_usize()
|
||||
}
|
||||
|
||||
/// Returns the `PENDING_CONSOLIDATIONS_LIMIT` constant for this specification.
|
||||
fn pending_consolidations_limit() -> usize {
|
||||
Self::PendingConsolidationsLimit::to_usize()
|
||||
}
|
||||
|
||||
/// Returns the `MAX_CONSOLIDATIONS` constant for this specification.
|
||||
fn max_consolidations() -> usize {
|
||||
Self::MaxConsolidations::to_usize()
|
||||
}
|
||||
|
||||
/// Returns the `MAX_DEPOSIT_RECEIPTS_PER_PAYLOAD` constant for this specification.
|
||||
fn max_deposit_receipts_per_payload() -> usize {
|
||||
Self::MaxDepositReceiptsPerPayload::to_usize()
|
||||
}
|
||||
|
||||
/// Returns the `MAX_ATTESTER_SLASHINGS_ELECTRA` constant for this specification.
|
||||
fn max_attester_slashings_electra() -> usize {
|
||||
Self::MaxAttesterSlashingsElectra::to_usize()
|
||||
}
|
||||
|
||||
/// Returns the `MAX_ATTESTATIONS_ELECTRA` constant for this specification.
|
||||
fn max_attestations_electra() -> usize {
|
||||
Self::MaxAttestationsElectra::to_usize()
|
||||
}
|
||||
|
||||
/// Returns the `MAX_WITHDRAWAL_REQUESTS_PER_PAYLOAD` constant for this specification.
|
||||
fn max_withdrawal_requests_per_payload() -> usize {
|
||||
Self::MaxWithdrawalRequestsPerPayload::to_usize()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -337,7 +381,14 @@ impl EthSpec for MainnetEthSpec {
|
||||
type SlotsPerEth1VotingPeriod = U2048; // 64 epochs * 32 slots per epoch
|
||||
type MaxBlsToExecutionChanges = U16;
|
||||
type MaxWithdrawalsPerPayload = U16;
|
||||
type ElectraPlaceholder = U16;
|
||||
type PendingBalanceDepositsLimit = U134217728;
|
||||
type PendingPartialWithdrawalsLimit = U134217728;
|
||||
type PendingConsolidationsLimit = U262144;
|
||||
type MaxConsolidations = U1;
|
||||
type MaxDepositReceiptsPerPayload = U8192;
|
||||
type MaxAttesterSlashingsElectra = U1;
|
||||
type MaxAttestationsElectra = U8;
|
||||
type MaxWithdrawalRequestsPerPayload = U16;
|
||||
|
||||
fn default_spec() -> ChainSpec {
|
||||
ChainSpec::mainnet()
|
||||
@@ -390,7 +441,14 @@ impl EthSpec for MinimalEthSpec {
|
||||
MaxBlsToExecutionChanges,
|
||||
MaxBlobsPerBlock,
|
||||
BytesPerFieldElement,
|
||||
ElectraPlaceholder
|
||||
PendingBalanceDepositsLimit,
|
||||
PendingPartialWithdrawalsLimit,
|
||||
PendingConsolidationsLimit,
|
||||
MaxConsolidations,
|
||||
MaxDepositReceiptsPerPayload,
|
||||
MaxAttesterSlashingsElectra,
|
||||
MaxAttestationsElectra,
|
||||
MaxWithdrawalRequestsPerPayload
|
||||
});
|
||||
|
||||
fn default_spec() -> ChainSpec {
|
||||
@@ -442,7 +500,14 @@ impl EthSpec for GnosisEthSpec {
|
||||
type BytesPerFieldElement = U32;
|
||||
type BytesPerBlob = U131072;
|
||||
type KzgCommitmentInclusionProofDepth = U17;
|
||||
type ElectraPlaceholder = U16;
|
||||
type PendingBalanceDepositsLimit = U134217728;
|
||||
type PendingPartialWithdrawalsLimit = U134217728;
|
||||
type PendingConsolidationsLimit = U262144;
|
||||
type MaxConsolidations = U1;
|
||||
type MaxDepositReceiptsPerPayload = U8192;
|
||||
type MaxAttesterSlashingsElectra = U1;
|
||||
type MaxAttestationsElectra = U8;
|
||||
type MaxWithdrawalRequestsPerPayload = U16;
|
||||
|
||||
fn default_spec() -> ChainSpec {
|
||||
ChainSpec::gnosis()
|
||||
|
||||
Reference in New Issue
Block a user