mirror of
https://github.com/sigp/lighthouse.git
synced 2026-07-03 12:54:27 +00:00
merge with capella
This commit is contained in:
@@ -43,5 +43,4 @@ arbitrary-fuzz = [
|
||||
"eth2_ssz_types/arbitrary",
|
||||
"tree_hash/arbitrary",
|
||||
]
|
||||
withdrawals = ["types/withdrawals"]
|
||||
withdrawals-processing = []
|
||||
|
||||
@@ -19,6 +19,7 @@ pub use process_operations::process_operations;
|
||||
pub use verify_attestation::{
|
||||
verify_attestation_for_block_inclusion, verify_attestation_for_state,
|
||||
};
|
||||
#[cfg(feature = "withdrawals-processing")]
|
||||
pub use verify_bls_to_execution_change::verify_bls_to_execution_change;
|
||||
pub use verify_deposit::{
|
||||
get_existing_validator_index, verify_deposit_merkle_proof, verify_deposit_signature,
|
||||
@@ -35,6 +36,7 @@ pub mod signature_sets;
|
||||
pub mod tests;
|
||||
mod verify_attestation;
|
||||
mod verify_attester_slashing;
|
||||
#[cfg(feature = "withdrawals-processing")]
|
||||
mod verify_bls_to_execution_change;
|
||||
mod verify_deposit;
|
||||
mod verify_exit;
|
||||
@@ -162,7 +164,7 @@ pub fn per_block_processing<T: EthSpec, Payload: AbstractExecPayload<T>>(
|
||||
// previous block.
|
||||
if is_execution_enabled(state, block.body()) {
|
||||
let payload = block.body().execution_payload()?;
|
||||
#[cfg(all(feature = "withdrawals", feature = "withdrawals-processing"))]
|
||||
#[cfg(feature = "withdrawals-processing")]
|
||||
process_withdrawals::<T, Payload>(state, payload, spec)?;
|
||||
process_execution_payload::<T, Payload>(state, payload, spec)?;
|
||||
}
|
||||
@@ -466,8 +468,9 @@ pub fn compute_timestamp_at_slot<T: EthSpec>(
|
||||
.and_then(|since_genesis| state.genesis_time().safe_add(since_genesis))
|
||||
}
|
||||
|
||||
/// FIXME: add link to this function once the spec is stable
|
||||
#[cfg(feature = "withdrawals")]
|
||||
/// Compute the next batch of withdrawals which should be included in a block.
|
||||
///
|
||||
/// https://github.com/ethereum/consensus-specs/blob/dev/specs/capella/beacon-chain.md#new-get_expected_withdrawals
|
||||
pub fn get_expected_withdrawals<T: EthSpec>(
|
||||
state: &BeaconState<T>,
|
||||
spec: &ChainSpec,
|
||||
@@ -481,7 +484,11 @@ pub fn get_expected_withdrawals<T: EthSpec>(
|
||||
return Ok(withdrawals.into());
|
||||
}
|
||||
|
||||
for _ in 0..state.validators().len() {
|
||||
let bound = std::cmp::min(
|
||||
state.validators().len() as u64,
|
||||
spec.max_validators_per_withdrawals_sweep,
|
||||
);
|
||||
for _ in 0..bound {
|
||||
let validator = state.get_validator(validator_index as usize)?;
|
||||
let balance = *state.balances().get(validator_index as usize).ok_or(
|
||||
BeaconStateError::BalancesOutOfBounds(validator_index as usize),
|
||||
@@ -518,8 +525,8 @@ pub fn get_expected_withdrawals<T: EthSpec>(
|
||||
Ok(withdrawals.into())
|
||||
}
|
||||
|
||||
/// FIXME: add link to this function once the spec is stable
|
||||
#[cfg(feature = "withdrawals")]
|
||||
/// Apply withdrawals to the state.
|
||||
#[cfg(feature = "withdrawals-processing")]
|
||||
pub fn process_withdrawals<'payload, T: EthSpec, Payload: AbstractExecPayload<T>>(
|
||||
state: &mut BeaconState<T>,
|
||||
payload: Payload::Ref<'payload>,
|
||||
@@ -547,11 +554,26 @@ pub fn process_withdrawals<'payload, T: EthSpec, Payload: AbstractExecPayload<T>
|
||||
)?;
|
||||
}
|
||||
|
||||
// Update the next withdrawal index if this block contained withdrawals
|
||||
if let Some(latest_withdrawal) = expected_withdrawals.last() {
|
||||
*state.next_withdrawal_index_mut()? = latest_withdrawal.index.safe_add(1)?;
|
||||
let next_validator_index = latest_withdrawal
|
||||
.validator_index
|
||||
.safe_add(1)?
|
||||
|
||||
// Update the next validator index to start the next withdrawal sweep
|
||||
if expected_withdrawals.len() == T::max_withdrawals_per_payload() {
|
||||
// Next sweep starts after the latest withdrawal's validator index
|
||||
let next_validator_index = latest_withdrawal
|
||||
.validator_index
|
||||
.safe_add(1)?
|
||||
.safe_rem(state.validators().len() as u64)?;
|
||||
*state.next_withdrawal_validator_index_mut()? = next_validator_index;
|
||||
}
|
||||
}
|
||||
|
||||
// Advance sweep by the max length of the sweep if there was not a full set of withdrawals
|
||||
if expected_withdrawals.len() != T::max_withdrawals_per_payload() {
|
||||
let next_validator_index = state
|
||||
.next_withdrawal_validator_index()?
|
||||
.safe_add(spec.max_validators_per_withdrawals_sweep)?
|
||||
.safe_rem(state.validators().len() as u64)?;
|
||||
*state.next_withdrawal_validator_index_mut()? = next_validator_index;
|
||||
}
|
||||
|
||||
@@ -170,7 +170,6 @@ where
|
||||
// Deposits are not included because they can legally have invalid signatures.
|
||||
self.include_exits(block)?;
|
||||
self.include_sync_aggregate(block)?;
|
||||
#[cfg(feature = "withdrawals")]
|
||||
self.include_bls_to_execution_changes(block)?;
|
||||
|
||||
Ok(())
|
||||
@@ -345,7 +344,6 @@ where
|
||||
}
|
||||
|
||||
/// Include the signature of the block's BLS to execution changes for verification.
|
||||
#[cfg(feature = "withdrawals")]
|
||||
pub fn include_bls_to_execution_changes<Payload: AbstractExecPayload<T>>(
|
||||
&mut self,
|
||||
block: &'a SignedBeaconBlock<T, Payload>,
|
||||
|
||||
@@ -34,7 +34,7 @@ pub fn process_operations<'a, T: EthSpec, Payload: AbstractExecPayload<T>>(
|
||||
process_deposits(state, block_body.deposits(), spec)?;
|
||||
process_exits(state, block_body.voluntary_exits(), verify_signatures, spec)?;
|
||||
|
||||
#[cfg(all(feature = "withdrawals", feature = "withdrawals-processing"))]
|
||||
#[cfg(feature = "withdrawals-processing")]
|
||||
if let Ok(bls_to_execution_changes) = block_body.bls_to_execution_changes() {
|
||||
process_bls_to_execution_changes(state, bls_to_execution_changes, verify_signatures, spec)?;
|
||||
}
|
||||
@@ -295,6 +295,7 @@ pub fn process_exits<T: EthSpec>(
|
||||
///
|
||||
/// Returns `Ok(())` if the validation and state updates completed successfully. Otherwise returns
|
||||
/// an `Err` describing the invalid object or cause of failure.
|
||||
#[cfg(feature = "withdrawals-processing")]
|
||||
pub fn process_bls_to_execution_changes<T: EthSpec>(
|
||||
state: &mut BeaconState<T>,
|
||||
bls_to_execution_changes: &[SignedBlsToExecutionChange],
|
||||
|
||||
@@ -56,9 +56,7 @@ pub fn upgrade_to_capella<E: EthSpec>(
|
||||
// Execution
|
||||
latest_execution_payload_header: pre.latest_execution_payload_header.upgrade_to_capella(),
|
||||
// Withdrawals
|
||||
#[cfg(feature = "withdrawals")]
|
||||
next_withdrawal_index: 0,
|
||||
#[cfg(feature = "withdrawals")]
|
||||
next_withdrawal_validator_index: 0,
|
||||
// Caches
|
||||
total_active_balance: pre.total_active_balance,
|
||||
|
||||
@@ -9,13 +9,7 @@ pub fn upgrade_to_eip4844<E: EthSpec>(
|
||||
let epoch = pre_state.current_epoch();
|
||||
let pre = pre_state.as_capella_mut()?;
|
||||
|
||||
// FIXME(sean) This is a hack to let us participate in testnets where capella doesn't exist.
|
||||
// if we are disabling withdrawals, assume we should fork off of bellatrix.
|
||||
let previous_fork_version = if cfg!(feature = "withdrawals") {
|
||||
pre.fork.current_version
|
||||
} else {
|
||||
spec.bellatrix_fork_version
|
||||
};
|
||||
let previous_fork_version = pre.fork.current_version;
|
||||
|
||||
// Where possible, use something like `mem::take` to move fields from behind the &mut
|
||||
// reference. For other fields that don't have a good default value, use `clone`.
|
||||
@@ -64,9 +58,7 @@ pub fn upgrade_to_eip4844<E: EthSpec>(
|
||||
// Execution
|
||||
latest_execution_payload_header: pre.latest_execution_payload_header.upgrade_to_eip4844(),
|
||||
// Withdrawals
|
||||
#[cfg(feature = "withdrawals")]
|
||||
next_withdrawal_index: pre.next_withdrawal_index,
|
||||
#[cfg(feature = "withdrawals")]
|
||||
next_withdrawal_validator_index: pre.next_withdrawal_validator_index,
|
||||
// Caches
|
||||
total_active_balance: pre.total_active_balance,
|
||||
|
||||
@@ -74,4 +74,3 @@ arbitrary-fuzz = [
|
||||
"swap_or_not_shuffle/arbitrary",
|
||||
"tree_hash/arbitrary",
|
||||
]
|
||||
withdrawals = []
|
||||
|
||||
17
consensus/types/presets/gnosis/capella.yaml
Normal file
17
consensus/types/presets/gnosis/capella.yaml
Normal file
@@ -0,0 +1,17 @@
|
||||
# Mainnet preset - Capella
|
||||
|
||||
# Misc
|
||||
# Max operations per block
|
||||
# ---------------------------------------------------------------
|
||||
# 2**4 (= 16)
|
||||
MAX_BLS_TO_EXECUTION_CHANGES: 16
|
||||
|
||||
# Execution
|
||||
# ---------------------------------------------------------------
|
||||
# 2**4 (= 16) withdrawals
|
||||
MAX_WITHDRAWALS_PER_PAYLOAD: 16
|
||||
|
||||
# Withdrawals processing
|
||||
# ---------------------------------------------------------------
|
||||
# 2**14 (= 16384) validators
|
||||
MAX_VALIDATORS_PER_WITHDRAWALS_SWEEP: 16384
|
||||
@@ -9,4 +9,9 @@ MAX_BLS_TO_EXECUTION_CHANGES: 16
|
||||
# Execution
|
||||
# ---------------------------------------------------------------
|
||||
# 2**4 (= 16) withdrawals
|
||||
MAX_WITHDRAWALS_PER_PAYLOAD: 16
|
||||
MAX_WITHDRAWALS_PER_PAYLOAD: 16
|
||||
|
||||
# Withdrawals processing
|
||||
# ---------------------------------------------------------------
|
||||
# 2**14 (= 16384) validators
|
||||
MAX_VALIDATORS_PER_WITHDRAWALS_SWEEP: 16384
|
||||
|
||||
@@ -9,4 +9,9 @@ MAX_BLS_TO_EXECUTION_CHANGES: 16
|
||||
# Execution
|
||||
# ---------------------------------------------------------------
|
||||
# [customized] 2**2 (= 4)
|
||||
MAX_WITHDRAWALS_PER_PAYLOAD: 4
|
||||
MAX_WITHDRAWALS_PER_PAYLOAD: 4
|
||||
|
||||
# Withdrawals processing
|
||||
# ---------------------------------------------------------------
|
||||
# [customized] 2**4 (= 16) validators
|
||||
MAX_VALIDATORS_PER_WITHDRAWALS_SWEEP: 16
|
||||
|
||||
@@ -502,7 +502,6 @@ impl<T: EthSpec, Payload: AbstractExecPayload<T>> EmptyBlock for BeaconBlockCape
|
||||
voluntary_exits: VariableList::empty(),
|
||||
sync_aggregate: SyncAggregate::empty(),
|
||||
execution_payload: Payload::Capella::default(),
|
||||
#[cfg(feature = "withdrawals")]
|
||||
bls_to_execution_changes: VariableList::empty(),
|
||||
},
|
||||
}
|
||||
@@ -532,7 +531,6 @@ impl<T: EthSpec, Payload: AbstractExecPayload<T>> EmptyBlock for BeaconBlockEip4
|
||||
voluntary_exits: VariableList::empty(),
|
||||
sync_aggregate: SyncAggregate::empty(),
|
||||
execution_payload: Payload::Eip4844::default(),
|
||||
#[cfg(feature = "withdrawals")]
|
||||
bls_to_execution_changes: VariableList::empty(),
|
||||
blob_kzg_commitments: VariableList::empty(),
|
||||
},
|
||||
|
||||
@@ -61,7 +61,6 @@ pub struct BeaconBlockBody<T: EthSpec, Payload: AbstractExecPayload<T> = FullPay
|
||||
#[superstruct(only(Eip4844), partial_getter(rename = "execution_payload_eip4844"))]
|
||||
#[serde(flatten)]
|
||||
pub execution_payload: Payload::Eip4844,
|
||||
#[cfg(feature = "withdrawals")]
|
||||
#[superstruct(only(Capella, Eip4844))]
|
||||
pub bls_to_execution_changes:
|
||||
VariableList<SignedBlsToExecutionChange, T::MaxBlsToExecutionChanges>,
|
||||
@@ -300,7 +299,6 @@ impl<E: EthSpec> From<BeaconBlockBodyCapella<E, FullPayload<E>>>
|
||||
voluntary_exits,
|
||||
sync_aggregate,
|
||||
execution_payload: FullPayloadCapella { execution_payload },
|
||||
#[cfg(feature = "withdrawals")]
|
||||
bls_to_execution_changes,
|
||||
} = body;
|
||||
|
||||
@@ -318,7 +316,6 @@ impl<E: EthSpec> From<BeaconBlockBodyCapella<E, FullPayload<E>>>
|
||||
execution_payload: BlindedPayloadCapella {
|
||||
execution_payload_header: From::from(execution_payload.clone()),
|
||||
},
|
||||
#[cfg(feature = "withdrawals")]
|
||||
bls_to_execution_changes,
|
||||
},
|
||||
Some(execution_payload),
|
||||
@@ -344,7 +341,6 @@ impl<E: EthSpec> From<BeaconBlockBodyEip4844<E, FullPayload<E>>>
|
||||
voluntary_exits,
|
||||
sync_aggregate,
|
||||
execution_payload: FullPayloadEip4844 { execution_payload },
|
||||
#[cfg(feature = "withdrawals")]
|
||||
bls_to_execution_changes,
|
||||
blob_kzg_commitments,
|
||||
} = body;
|
||||
@@ -363,7 +359,6 @@ impl<E: EthSpec> From<BeaconBlockBodyEip4844<E, FullPayload<E>>>
|
||||
execution_payload: BlindedPayloadEip4844 {
|
||||
execution_payload_header: From::from(execution_payload.clone()),
|
||||
},
|
||||
#[cfg(feature = "withdrawals")]
|
||||
bls_to_execution_changes,
|
||||
blob_kzg_commitments,
|
||||
},
|
||||
@@ -432,7 +427,6 @@ impl<E: EthSpec> BeaconBlockBodyCapella<E, FullPayload<E>> {
|
||||
voluntary_exits,
|
||||
sync_aggregate,
|
||||
execution_payload: FullPayloadCapella { execution_payload },
|
||||
#[cfg(feature = "withdrawals")]
|
||||
bls_to_execution_changes,
|
||||
} = self;
|
||||
|
||||
@@ -449,7 +443,6 @@ impl<E: EthSpec> BeaconBlockBodyCapella<E, FullPayload<E>> {
|
||||
execution_payload: BlindedPayloadCapella {
|
||||
execution_payload_header: From::from(execution_payload.clone()),
|
||||
},
|
||||
#[cfg(feature = "withdrawals")]
|
||||
bls_to_execution_changes: bls_to_execution_changes.clone(),
|
||||
}
|
||||
}
|
||||
@@ -468,7 +461,6 @@ impl<E: EthSpec> BeaconBlockBodyEip4844<E, FullPayload<E>> {
|
||||
voluntary_exits,
|
||||
sync_aggregate,
|
||||
execution_payload: FullPayloadEip4844 { execution_payload },
|
||||
#[cfg(feature = "withdrawals")]
|
||||
bls_to_execution_changes,
|
||||
blob_kzg_commitments,
|
||||
} = self;
|
||||
@@ -486,7 +478,6 @@ impl<E: EthSpec> BeaconBlockBodyEip4844<E, FullPayload<E>> {
|
||||
execution_payload: BlindedPayloadEip4844 {
|
||||
execution_payload_header: From::from(execution_payload.clone()),
|
||||
},
|
||||
#[cfg(feature = "withdrawals")]
|
||||
bls_to_execution_changes: bls_to_execution_changes.clone(),
|
||||
blob_kzg_commitments: blob_kzg_commitments.clone(),
|
||||
}
|
||||
|
||||
@@ -297,10 +297,8 @@ where
|
||||
pub latest_execution_payload_header: ExecutionPayloadHeaderEip4844<T>,
|
||||
|
||||
// Withdrawals
|
||||
#[cfg(feature = "withdrawals")]
|
||||
#[superstruct(only(Capella, Eip4844), partial_getter(copy))]
|
||||
pub next_withdrawal_index: u64,
|
||||
#[cfg(feature = "withdrawals")]
|
||||
#[superstruct(only(Capella, Eip4844), partial_getter(copy))]
|
||||
pub next_withdrawal_validator_index: u64,
|
||||
|
||||
|
||||
@@ -336,11 +336,9 @@ impl<T: EthSpec> BeaconTreeHashCacheInner<T> {
|
||||
}
|
||||
|
||||
// Withdrawal indices (Capella and later).
|
||||
#[cfg(feature = "withdrawals")]
|
||||
if let Ok(next_withdrawal_index) = state.next_withdrawal_index() {
|
||||
hasher.write(next_withdrawal_index.tree_hash_root().as_bytes())?;
|
||||
}
|
||||
#[cfg(feature = "withdrawals")]
|
||||
if let Ok(next_withdrawal_validator_index) = state.next_withdrawal_validator_index() {
|
||||
hasher.write(next_withdrawal_validator_index.tree_hash_root().as_bytes())?;
|
||||
}
|
||||
|
||||
@@ -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,11 @@ 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))]
|
||||
#[serde(flatten)]
|
||||
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 +40,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 +65,6 @@ impl ConfigAndPreset {
|
||||
bellatrix_preset,
|
||||
extra_fields,
|
||||
})
|
||||
} else {
|
||||
ConfigAndPreset::Altair(ConfigAndPresetAltair {
|
||||
config,
|
||||
base_preset,
|
||||
altair_preset,
|
||||
extra_fields,
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -131,8 +137,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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -80,7 +80,6 @@ pub struct ExecutionPayload<T: EthSpec> {
|
||||
pub block_hash: ExecutionBlockHash,
|
||||
#[serde(with = "ssz_types::serde_utils::list_of_hex_var_list")]
|
||||
pub transactions: Transactions<T>,
|
||||
#[cfg(feature = "withdrawals")]
|
||||
#[superstruct(only(Capella, Eip4844))]
|
||||
pub withdrawals: Withdrawals<T>,
|
||||
}
|
||||
|
||||
@@ -75,7 +75,6 @@ pub struct ExecutionPayloadHeader<T: EthSpec> {
|
||||
pub block_hash: ExecutionBlockHash,
|
||||
#[superstruct(getter(copy))]
|
||||
pub transactions_root: Hash256,
|
||||
#[cfg(feature = "withdrawals")]
|
||||
#[superstruct(only(Capella, Eip4844))]
|
||||
#[superstruct(getter(copy))]
|
||||
pub withdrawals_root: Hash256,
|
||||
@@ -128,7 +127,6 @@ impl<T: EthSpec> ExecutionPayloadHeaderMerge<T> {
|
||||
base_fee_per_gas: self.base_fee_per_gas,
|
||||
block_hash: self.block_hash,
|
||||
transactions_root: self.transactions_root,
|
||||
#[cfg(feature = "withdrawals")]
|
||||
withdrawals_root: Hash256::zero(),
|
||||
}
|
||||
}
|
||||
@@ -153,7 +151,6 @@ impl<T: EthSpec> ExecutionPayloadHeaderCapella<T> {
|
||||
excess_data_gas: Uint256::zero(),
|
||||
block_hash: self.block_hash,
|
||||
transactions_root: self.transactions_root,
|
||||
#[cfg(feature = "withdrawals")]
|
||||
withdrawals_root: self.withdrawals_root,
|
||||
}
|
||||
}
|
||||
@@ -196,7 +193,6 @@ impl<T: EthSpec> From<ExecutionPayloadCapella<T>> for ExecutionPayloadHeaderCape
|
||||
base_fee_per_gas: payload.base_fee_per_gas,
|
||||
block_hash: payload.block_hash,
|
||||
transactions_root: payload.transactions.tree_hash_root(),
|
||||
#[cfg(feature = "withdrawals")]
|
||||
withdrawals_root: payload.withdrawals.tree_hash_root(),
|
||||
}
|
||||
}
|
||||
@@ -219,7 +215,6 @@ impl<T: EthSpec> From<ExecutionPayloadEip4844<T>> for ExecutionPayloadHeaderEip4
|
||||
excess_data_gas: payload.excess_data_gas,
|
||||
block_hash: payload.block_hash,
|
||||
transactions_root: payload.transactions.tree_hash_root(),
|
||||
#[cfg(feature = "withdrawals")]
|
||||
withdrawals_root: payload.withdrawals.tree_hash_root(),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -123,7 +123,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};
|
||||
@@ -160,7 +160,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};
|
||||
|
||||
@@ -37,7 +37,6 @@ pub trait ExecPayload<T: EthSpec>: Debug + Clone + PartialEq + Hash + TreeHash +
|
||||
fn gas_limit(&self) -> u64;
|
||||
fn transactions(&self) -> Option<&Transactions<T>>;
|
||||
/// fork-specific fields
|
||||
#[cfg(feature = "withdrawals")]
|
||||
fn withdrawals_root(&self) -> Result<Hash256, Error>;
|
||||
|
||||
/// Is this a default payload with 0x0 roots for transactions and withdrawals?
|
||||
@@ -241,7 +240,6 @@ impl<T: EthSpec> ExecPayload<T> for FullPayload<T> {
|
||||
})
|
||||
}
|
||||
|
||||
#[cfg(feature = "withdrawals")]
|
||||
fn withdrawals_root(&self) -> Result<Hash256, Error> {
|
||||
match self {
|
||||
FullPayload::Merge(_) => Err(Error::IncorrectStateVariant),
|
||||
@@ -343,7 +341,6 @@ impl<'b, T: EthSpec> ExecPayload<T> for FullPayloadRef<'b, T> {
|
||||
})
|
||||
}
|
||||
|
||||
#[cfg(feature = "withdrawals")]
|
||||
fn withdrawals_root(&self) -> Result<Hash256, Error> {
|
||||
match self {
|
||||
FullPayloadRef::Merge(_) => Err(Error::IncorrectStateVariant),
|
||||
@@ -523,7 +520,6 @@ impl<T: EthSpec> ExecPayload<T> for BlindedPayload<T> {
|
||||
None
|
||||
}
|
||||
|
||||
#[cfg(feature = "withdrawals")]
|
||||
fn withdrawals_root(&self) -> Result<Hash256, Error> {
|
||||
match self {
|
||||
BlindedPayload::Merge(_) => Err(Error::IncorrectStateVariant),
|
||||
@@ -614,7 +610,6 @@ impl<'b, T: EthSpec> ExecPayload<T> for BlindedPayloadRef<'b, T> {
|
||||
None
|
||||
}
|
||||
|
||||
#[cfg(feature = "withdrawals")]
|
||||
fn withdrawals_root(&self) -> Result<Hash256, Error> {
|
||||
match self {
|
||||
BlindedPayloadRef::Merge(_) => Err(Error::IncorrectStateVariant),
|
||||
@@ -712,7 +707,6 @@ macro_rules! impl_exec_payload_common {
|
||||
f(self)
|
||||
}
|
||||
|
||||
#[cfg(feature = "withdrawals")]
|
||||
fn withdrawals_root(&self) -> Result<Hash256, Error> {
|
||||
let g = $g;
|
||||
g(self)
|
||||
|
||||
@@ -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]
|
||||
|
||||
@@ -341,7 +341,6 @@ impl<E: EthSpec> SignedBeaconBlockCapella<E, BlindedPayload<E>> {
|
||||
voluntary_exits,
|
||||
sync_aggregate,
|
||||
execution_payload: BlindedPayloadCapella { .. },
|
||||
#[cfg(feature = "withdrawals")]
|
||||
bls_to_execution_changes,
|
||||
},
|
||||
},
|
||||
@@ -364,7 +363,6 @@ impl<E: EthSpec> SignedBeaconBlockCapella<E, BlindedPayload<E>> {
|
||||
voluntary_exits,
|
||||
sync_aggregate,
|
||||
execution_payload: FullPayloadCapella { execution_payload },
|
||||
#[cfg(feature = "withdrawals")]
|
||||
bls_to_execution_changes,
|
||||
},
|
||||
},
|
||||
@@ -397,7 +395,6 @@ impl<E: EthSpec> SignedBeaconBlockEip4844<E, BlindedPayload<E>> {
|
||||
voluntary_exits,
|
||||
sync_aggregate,
|
||||
execution_payload: BlindedPayloadEip4844 { .. },
|
||||
#[cfg(feature = "withdrawals")]
|
||||
bls_to_execution_changes,
|
||||
blob_kzg_commitments,
|
||||
},
|
||||
@@ -421,7 +418,6 @@ impl<E: EthSpec> SignedBeaconBlockEip4844<E, BlindedPayload<E>> {
|
||||
voluntary_exits,
|
||||
sync_aggregate,
|
||||
execution_payload: FullPayloadEip4844 { execution_payload },
|
||||
#[cfg(feature = "withdrawals")]
|
||||
bls_to_execution_changes,
|
||||
blob_kzg_commitments,
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user