mirror of
https://github.com/sigp/lighthouse.git
synced 2026-04-17 12:58:31 +00:00
Bounded withdrawals and spec v1.3.0-alpha.2 (#3802)
This commit is contained in:
@@ -158,8 +158,9 @@ pub struct ChainSpec {
|
||||
* Capella hard fork params
|
||||
*/
|
||||
pub capella_fork_version: [u8; 4],
|
||||
/// The Capella fork epoch is optional, with `None` representing "Merge never happens".
|
||||
/// The Capella fork epoch is optional, with `None` representing "Capella never happens".
|
||||
pub capella_fork_epoch: Option<Epoch>,
|
||||
pub max_validators_per_withdrawals_sweep: u64,
|
||||
|
||||
/*
|
||||
* Eip4844 hard fork params
|
||||
@@ -634,6 +635,7 @@ impl ChainSpec {
|
||||
*/
|
||||
capella_fork_version: [0x03, 00, 00, 00],
|
||||
capella_fork_epoch: None,
|
||||
max_validators_per_withdrawals_sweep: 16384,
|
||||
|
||||
/*
|
||||
* Eip4844 hard fork params
|
||||
@@ -707,6 +709,7 @@ impl ChainSpec {
|
||||
// Capella
|
||||
capella_fork_version: [0x03, 0x00, 0x00, 0x01],
|
||||
capella_fork_epoch: None,
|
||||
max_validators_per_withdrawals_sweep: 16,
|
||||
// Eip4844
|
||||
eip4844_fork_version: [0x04, 0x00, 0x00, 0x01],
|
||||
eip4844_fork_epoch: None,
|
||||
@@ -869,6 +872,7 @@ impl ChainSpec {
|
||||
*/
|
||||
capella_fork_version: [0x03, 0x00, 0x00, 0x64],
|
||||
capella_fork_epoch: None,
|
||||
max_validators_per_withdrawals_sweep: 16384,
|
||||
|
||||
/*
|
||||
* Eip4844 hard fork params
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
use crate::{
|
||||
consts::altair, AltairPreset, BasePreset, BellatrixPreset, ChainSpec, Config, EthSpec, ForkName,
|
||||
consts::altair, AltairPreset, BasePreset, BellatrixPreset, CapellaPreset, ChainSpec, Config,
|
||||
EthSpec, ForkName,
|
||||
};
|
||||
use maplit::hashmap;
|
||||
use serde_derive::{Deserialize, Serialize};
|
||||
@@ -11,7 +12,7 @@ use superstruct::superstruct;
|
||||
///
|
||||
/// Mostly useful for the API.
|
||||
#[superstruct(
|
||||
variants(Altair, Bellatrix),
|
||||
variants(Bellatrix, Capella),
|
||||
variant_attributes(derive(Serialize, Deserialize, Debug, PartialEq, Clone))
|
||||
)]
|
||||
#[derive(Serialize, Deserialize, Debug, PartialEq, Clone)]
|
||||
@@ -24,9 +25,10 @@ pub struct ConfigAndPreset {
|
||||
pub base_preset: BasePreset,
|
||||
#[serde(flatten)]
|
||||
pub altair_preset: AltairPreset,
|
||||
#[superstruct(only(Bellatrix))]
|
||||
#[serde(flatten)]
|
||||
pub bellatrix_preset: BellatrixPreset,
|
||||
#[superstruct(only(Capella))]
|
||||
pub capella_preset: CapellaPreset,
|
||||
/// The `extra_fields` map allows us to gracefully decode fields intended for future hard forks.
|
||||
#[serde(flatten)]
|
||||
pub extra_fields: HashMap<String, Value>,
|
||||
@@ -37,14 +39,24 @@ impl ConfigAndPreset {
|
||||
let config = Config::from_chain_spec::<T>(spec);
|
||||
let base_preset = BasePreset::from_chain_spec::<T>(spec);
|
||||
let altair_preset = AltairPreset::from_chain_spec::<T>(spec);
|
||||
let bellatrix_preset = BellatrixPreset::from_chain_spec::<T>(spec);
|
||||
let extra_fields = get_extra_fields(spec);
|
||||
|
||||
if spec.bellatrix_fork_epoch.is_some()
|
||||
if spec.capella_fork_epoch.is_some()
|
||||
|| fork_name.is_none()
|
||||
|| fork_name == Some(ForkName::Merge)
|
||||
|| fork_name == Some(ForkName::Capella)
|
||||
{
|
||||
let bellatrix_preset = BellatrixPreset::from_chain_spec::<T>(spec);
|
||||
let capella_preset = CapellaPreset::from_chain_spec::<T>(spec);
|
||||
|
||||
ConfigAndPreset::Capella(ConfigAndPresetCapella {
|
||||
config,
|
||||
base_preset,
|
||||
altair_preset,
|
||||
bellatrix_preset,
|
||||
capella_preset,
|
||||
extra_fields,
|
||||
})
|
||||
} else {
|
||||
ConfigAndPreset::Bellatrix(ConfigAndPresetBellatrix {
|
||||
config,
|
||||
base_preset,
|
||||
@@ -52,13 +64,6 @@ impl ConfigAndPreset {
|
||||
bellatrix_preset,
|
||||
extra_fields,
|
||||
})
|
||||
} else {
|
||||
ConfigAndPreset::Altair(ConfigAndPresetAltair {
|
||||
config,
|
||||
base_preset,
|
||||
altair_preset,
|
||||
extra_fields,
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -131,8 +136,8 @@ mod test {
|
||||
.write(false)
|
||||
.open(tmp_file.as_ref())
|
||||
.expect("error while opening the file");
|
||||
let from: ConfigAndPresetBellatrix =
|
||||
let from: ConfigAndPresetCapella =
|
||||
serde_yaml::from_reader(reader).expect("error while deserializing");
|
||||
assert_eq!(ConfigAndPreset::Bellatrix(from), yamlconfig);
|
||||
assert_eq!(ConfigAndPreset::Capella(from), yamlconfig);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -124,7 +124,7 @@ pub use crate::bls_to_execution_change::BlsToExecutionChange;
|
||||
pub use crate::chain_spec::{ChainSpec, Config, Domain};
|
||||
pub use crate::checkpoint::Checkpoint;
|
||||
pub use crate::config_and_preset::{
|
||||
ConfigAndPreset, ConfigAndPresetAltair, ConfigAndPresetBellatrix,
|
||||
ConfigAndPreset, ConfigAndPresetBellatrix, ConfigAndPresetCapella,
|
||||
};
|
||||
pub use crate::contribution_and_proof::ContributionAndProof;
|
||||
pub use crate::deposit::{Deposit, DEPOSIT_TREE_DEPTH};
|
||||
@@ -163,7 +163,7 @@ pub use crate::payload::{
|
||||
FullPayloadCapella, FullPayloadEip4844, FullPayloadMerge, FullPayloadRef, OwnedExecPayload,
|
||||
};
|
||||
pub use crate::pending_attestation::PendingAttestation;
|
||||
pub use crate::preset::{AltairPreset, BasePreset, BellatrixPreset};
|
||||
pub use crate::preset::{AltairPreset, BasePreset, BellatrixPreset, CapellaPreset};
|
||||
pub use crate::proposer_preparation_data::ProposerPreparationData;
|
||||
pub use crate::proposer_slashing::ProposerSlashing;
|
||||
pub use crate::relative_epoch::{Error as RelativeEpochError, RelativeEpoch};
|
||||
|
||||
@@ -184,6 +184,27 @@ impl BellatrixPreset {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, PartialEq, Clone, Serialize, Deserialize)]
|
||||
#[serde(rename_all = "UPPERCASE")]
|
||||
pub struct CapellaPreset {
|
||||
#[serde(with = "eth2_serde_utils::quoted_u64")]
|
||||
pub max_bls_to_execution_changes: u64,
|
||||
#[serde(with = "eth2_serde_utils::quoted_u64")]
|
||||
pub max_withdrawals_per_payload: u64,
|
||||
#[serde(with = "eth2_serde_utils::quoted_u64")]
|
||||
pub max_validators_per_withdrawals_sweep: u64,
|
||||
}
|
||||
|
||||
impl CapellaPreset {
|
||||
pub fn from_chain_spec<T: EthSpec>(spec: &ChainSpec) -> Self {
|
||||
Self {
|
||||
max_bls_to_execution_changes: T::max_bls_to_execution_changes() as u64,
|
||||
max_withdrawals_per_payload: T::max_withdrawals_per_payload() as u64,
|
||||
max_validators_per_withdrawals_sweep: spec.max_validators_per_withdrawals_sweep,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod test {
|
||||
use super::*;
|
||||
@@ -219,6 +240,9 @@ mod test {
|
||||
|
||||
let bellatrix: BellatrixPreset = preset_from_file(&preset_name, "bellatrix.yaml");
|
||||
assert_eq!(bellatrix, BellatrixPreset::from_chain_spec::<E>(&spec));
|
||||
|
||||
let capella: CapellaPreset = preset_from_file(&preset_name, "capella.yaml");
|
||||
assert_eq!(capella, CapellaPreset::from_chain_spec::<E>(&spec));
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
||||
Reference in New Issue
Block a user