mirror of
https://github.com/sigp/lighthouse.git
synced 2026-03-21 05:44:44 +00:00
Fixed a ton of state_processing stuff (#3642)
FIXME's: * consensus/fork_choice/src/fork_choice.rs * consensus/state_processing/src/per_epoch_processing/capella.rs * consensus/types/src/execution_payload_header.rs TODO's: * consensus/state_processing/src/per_epoch_processing/capella/partial_withdrawals.rs * consensus/state_processing/src/per_epoch_processing/capella/full_withdrawals.rs
This commit is contained in:
@@ -2,7 +2,9 @@ use super::per_block_processing::{
|
||||
errors::BlockProcessingError, process_operations::process_deposit,
|
||||
};
|
||||
use crate::common::DepositDataTree;
|
||||
use crate::upgrade::{upgrade_to_altair, upgrade_to_bellatrix};
|
||||
use crate::upgrade::{
|
||||
upgrade_to_altair, upgrade_to_bellatrix, upgrade_to_capella, upgrade_to_eip4844,
|
||||
};
|
||||
use safe_arith::{ArithError, SafeArith};
|
||||
use tree_hash::TreeHash;
|
||||
use types::DEPOSIT_TREE_DEPTH;
|
||||
@@ -61,6 +63,7 @@ pub fn initialize_beacon_state_from_eth1<T: EthSpec>(
|
||||
.bellatrix_fork_epoch
|
||||
.map_or(false, |fork_epoch| fork_epoch == T::genesis_epoch())
|
||||
{
|
||||
// this will set state.latest_execution_payload_header = ExecutionPayloadHeaderMerge::default()
|
||||
upgrade_to_bellatrix(&mut state, spec)?;
|
||||
|
||||
// Remove intermediate Altair fork from `state.fork`.
|
||||
@@ -68,8 +71,43 @@ pub fn initialize_beacon_state_from_eth1<T: EthSpec>(
|
||||
|
||||
// Override latest execution payload header.
|
||||
// See https://github.com/ethereum/consensus-specs/blob/v1.1.0/specs/bellatrix/beacon-chain.md#testing
|
||||
*state.latest_execution_payload_header_mut()? =
|
||||
execution_payload_header.unwrap_or_default();
|
||||
if let Some(ExecutionPayloadHeader::Merge(ref header)) = execution_payload_header {
|
||||
*state.latest_execution_payload_header_merge_mut()? = header.clone();
|
||||
}
|
||||
}
|
||||
|
||||
// Upgrade to capella if configured from genesis
|
||||
if spec
|
||||
.capella_fork_epoch
|
||||
.map_or(false, |fork_epoch| fork_epoch == T::genesis_epoch())
|
||||
{
|
||||
upgrade_to_capella(&mut state, spec)?;
|
||||
|
||||
// Remove intermediate Bellatrix fork from `state.fork`.
|
||||
state.fork_mut().previous_version = spec.capella_fork_version;
|
||||
|
||||
// Override latest execution payload header.
|
||||
// See https://github.com/ethereum/consensus-specs/blob/dev/specs/capella/beacon-chain.md#testing
|
||||
if let Some(ExecutionPayloadHeader::Capella(ref header)) = execution_payload_header {
|
||||
*state.latest_execution_payload_header_capella_mut()? = header.clone();
|
||||
}
|
||||
}
|
||||
|
||||
// Upgrade to eip4844 if configured from genesis
|
||||
if spec
|
||||
.eip4844_fork_epoch
|
||||
.map_or(false, |fork_epoch| fork_epoch == T::genesis_epoch())
|
||||
{
|
||||
upgrade_to_eip4844(&mut state, spec)?;
|
||||
|
||||
// Remove intermediate Capella fork from `state.fork`.
|
||||
state.fork_mut().previous_version = spec.eip4844_fork_version;
|
||||
|
||||
// Override latest execution payload header.
|
||||
// See https://github.com/ethereum/consensus-specs/blob/dev/specs/eip4844/beacon-chain.md#testing
|
||||
if let Some(ExecutionPayloadHeader::Eip4844(header)) = execution_payload_header {
|
||||
*state.latest_execution_payload_header_eip4844_mut()? = header;
|
||||
}
|
||||
}
|
||||
|
||||
// Now that we have our validators, initialize the caches (including the committees)
|
||||
|
||||
Reference in New Issue
Block a user