Add electra presets to beacon API (#5630)

* add presets to API

* add extra fields to config spec in beacon API

* remove unused

* add mainnet presets for gnosis and fix minimal preset default values
This commit is contained in:
realbigsean
2024-04-25 14:33:03 -04:00
committed by GitHub
parent dd340eebdc
commit 320345695d
8 changed files with 190 additions and 14 deletions

View File

@@ -850,6 +850,8 @@ impl ChainSpec {
// Electra
electra_fork_version: [0x05, 0x00, 0x00, 0x01],
electra_fork_epoch: None,
max_pending_partials_per_withdrawals_sweep: u64::checked_pow(2, 0)
.expect("pow does not overflow"),
// Other
network_id: 2, // lighthouse testnet network id
deposit_chain_id: 5,

View File

@@ -1,6 +1,6 @@
use crate::{
consts::altair, AltairPreset, BasePreset, BellatrixPreset, CapellaPreset, ChainSpec, Config,
DenebPreset, ElectraPreset, EthSpec, ForkName,
consts::altair, consts::deneb, AltairPreset, BasePreset, BellatrixPreset, CapellaPreset,
ChainSpec, Config, DenebPreset, ElectraPreset, EthSpec, ForkName,
};
use maplit::hashmap;
use serde::{Deserialize, Serialize};
@@ -100,6 +100,7 @@ pub fn get_extra_fields(spec: &ChainSpec) -> HashMap<String, Value> {
let u8_hex = |v: u8| hex_string(&v.to_le_bytes());
hashmap! {
"bls_withdrawal_prefix".to_uppercase() => u8_hex(spec.bls_withdrawal_prefix_byte),
"eth1_address_withdrawal_prefix".to_uppercase() => u8_hex(spec.eth1_address_withdrawal_prefix_byte),
"domain_beacon_proposer".to_uppercase() => u32_hex(spec.domain_beacon_proposer),
"domain_beacon_attester".to_uppercase() => u32_hex(spec.domain_beacon_attester),
"domain_randao".to_uppercase()=> u32_hex(spec.domain_randao),
@@ -119,6 +120,13 @@ pub fn get_extra_fields(spec: &ChainSpec) -> HashMap<String, Value> {
altair::SYNC_COMMITTEE_SUBNET_COUNT.to_string().into(),
"target_aggregators_per_sync_subcommittee".to_uppercase() =>
altair::TARGET_AGGREGATORS_PER_SYNC_SUBCOMMITTEE.to_string().into(),
// Deneb
"versioned_hash_version_kzg".to_uppercase() => deneb::VERSIONED_HASH_VERSION_KZG.to_string().into(),
// Electra
"compounding_withdrawal_prefix".to_uppercase() => u8_hex(spec.compounding_withdrawal_prefix_byte),
"unset_deposit_receipts_start_index".to_uppercase() => spec.unset_deposit_receipts_start_index.to_string().into(),
"full_exit_request_amount".to_uppercase() => spec.full_exit_request_amount.to_string().into(),
"domain_consolidation".to_uppercase()=> u32_hex(spec.domain_consolidation),
}
}

View File

@@ -22,3 +22,6 @@ pub mod altair {
pub mod merge {
pub const INTERVALS_PER_SLOT: u64 = 3;
}
pub mod deneb {
pub use crate::VERSIONED_HASH_VERSION_KZG;
}

View File

@@ -418,6 +418,10 @@ impl EthSpec for MinimalEthSpec {
type BytesPerBlob = U131072;
type MaxBlobCommitmentsPerBlock = U16;
type KzgCommitmentInclusionProofDepth = U9;
type PendingPartialWithdrawalsLimit = U64;
type PendingConsolidationsLimit = U64;
type MaxDepositReceiptsPerPayload = U4;
type MaxWithdrawalRequestsPerPayload = U2;
params_from_eth_spec!(MainnetEthSpec {
JustificationBitsLength,
@@ -442,13 +446,9 @@ impl EthSpec for MinimalEthSpec {
MaxBlobsPerBlock,
BytesPerFieldElement,
PendingBalanceDepositsLimit,
PendingPartialWithdrawalsLimit,
PendingConsolidationsLimit,
MaxConsolidations,
MaxDepositReceiptsPerPayload,
MaxAttesterSlashingsElectra,
MaxAttestationsElectra,
MaxWithdrawalRequestsPerPayload
MaxAttestationsElectra
});
fn default_spec() -> ChainSpec {

View File

@@ -230,13 +230,50 @@ impl DenebPreset {
#[serde(rename_all = "UPPERCASE")]
pub struct ElectraPreset {
#[serde(with = "serde_utils::quoted_u64")]
pub electra_placeholder: u64,
pub min_activation_balance: u64,
#[serde(with = "serde_utils::quoted_u64")]
pub max_effective_balance_electra: u64,
#[serde(with = "serde_utils::quoted_u64")]
pub min_slashing_penalty_quotient_electra: u64,
#[serde(with = "serde_utils::quoted_u64")]
pub whistleblower_reward_quotient_electra: u64,
#[serde(with = "serde_utils::quoted_u64")]
pub max_pending_partials_per_withdrawals_sweep: u64,
#[serde(with = "serde_utils::quoted_u64")]
pub pending_balance_deposits_limit: u64,
#[serde(with = "serde_utils::quoted_u64")]
pub pending_partial_withdrawals_limit: u64,
#[serde(with = "serde_utils::quoted_u64")]
pub pending_consolidations_limit: u64,
#[serde(with = "serde_utils::quoted_u64")]
pub max_consolidations: u64,
#[serde(with = "serde_utils::quoted_u64")]
pub max_deposit_receipts_per_payload: u64,
#[serde(with = "serde_utils::quoted_u64")]
pub max_attester_slashings_electra: u64,
#[serde(with = "serde_utils::quoted_u64")]
pub max_attestations_electra: u64,
#[serde(with = "serde_utils::quoted_u64")]
pub max_withdrawal_requests_per_payload: u64,
}
impl ElectraPreset {
pub fn from_chain_spec<E: EthSpec>(_spec: &ChainSpec) -> Self {
pub fn from_chain_spec<E: EthSpec>(spec: &ChainSpec) -> Self {
Self {
electra_placeholder: 0,
min_activation_balance: spec.min_activation_balance,
max_effective_balance_electra: spec.max_effective_balance_electra,
min_slashing_penalty_quotient_electra: spec.min_slashing_penalty_quotient_electra,
whistleblower_reward_quotient_electra: spec.whistleblower_reward_quotient_electra,
max_pending_partials_per_withdrawals_sweep: spec
.max_pending_partials_per_withdrawals_sweep,
pending_balance_deposits_limit: E::pending_balance_deposits_limit() as u64,
pending_partial_withdrawals_limit: E::pending_partial_withdrawals_limit() as u64,
pending_consolidations_limit: E::pending_consolidations_limit() as u64,
max_consolidations: E::max_consolidations() as u64,
max_deposit_receipts_per_payload: E::max_deposit_receipts_per_payload() as u64,
max_attester_slashings_electra: E::max_attester_slashings_electra() as u64,
max_attestations_electra: E::max_attestations_electra() as u64,
max_withdrawal_requests_per_payload: E::max_withdrawal_requests_per_payload() as u64,
}
}
}