mirror of
https://github.com/sigp/lighthouse.git
synced 2026-05-31 13:17:09 +00:00
resolve merge conflicts
This commit is contained in:
@@ -183,9 +183,19 @@ pub fn initialize_beacon_state_from_eth1<E: EthSpec>(
|
||||
// Remove intermediate Fulu fork from `state.fork`.
|
||||
state.fork_mut().previous_version = spec.gloas_fork_version;
|
||||
|
||||
// Override latest execution payload header.
|
||||
// Here's where we *would* clone the header but there is no header here so..
|
||||
// TODO(EIP7732): check this
|
||||
// The genesis block's bid must have block_hash = 0x00 per spec (empty payload).
|
||||
// Retain the EL genesis hash in latest_block_hash and parent_block_hash so the
|
||||
// first post-genesis proposer can build on the correct EL head.
|
||||
let el_genesis_hash = state.latest_execution_payload_bid()?.block_hash;
|
||||
let bid = state.latest_execution_payload_bid_mut()?;
|
||||
bid.parent_block_hash = el_genesis_hash;
|
||||
bid.block_hash = ExecutionBlockHash::default();
|
||||
|
||||
// Update the `latest_block_header.body_root` so that it matches the body of the
|
||||
// Gloas genesis block, which embeds `state.latest_execution_payload_bid` in its
|
||||
// `signed_execution_payload_bid` field (see `genesis_block`).
|
||||
let genesis_body_root = genesis_block(&state, spec)?.body_root();
|
||||
state.latest_block_header_mut().body_root = genesis_body_root;
|
||||
}
|
||||
|
||||
// Now that we have our validators, initialize the caches (including the committees)
|
||||
@@ -197,6 +207,27 @@ pub fn initialize_beacon_state_from_eth1<E: EthSpec>(
|
||||
Ok(state)
|
||||
}
|
||||
|
||||
/// Create an unsigned genesis `BeaconBlock`.
|
||||
///
|
||||
/// Per spec, the genesis block body is empty (all default fields) except for Gloas,
|
||||
/// where `body.signed_execution_payload_bid.message` is initialised from
|
||||
/// `state.latest_execution_payload_bid` so that the first post-genesis proposer can
|
||||
/// build on the correct execution layer head.
|
||||
///
|
||||
/// `state.latest_block_header.body_root` is set from this same block's body, so the
|
||||
/// two must stay in sync.
|
||||
pub fn genesis_block<E: EthSpec>(
|
||||
state: &BeaconState<E>,
|
||||
spec: &ChainSpec,
|
||||
) -> Result<BeaconBlock<E>, BeaconStateError> {
|
||||
let mut block = BeaconBlock::empty(spec);
|
||||
if let BeaconBlock::Gloas(ref mut gloas_block) = block {
|
||||
let bid = state.latest_execution_payload_bid()?.clone();
|
||||
gloas_block.body.signed_execution_payload_bid.message = bid;
|
||||
}
|
||||
Ok(block)
|
||||
}
|
||||
|
||||
/// Determine whether a candidate genesis state is suitable for starting the chain.
|
||||
pub fn is_valid_genesis_state<E: EthSpec>(state: &BeaconState<E>, spec: &ChainSpec) -> bool {
|
||||
state
|
||||
@@ -211,7 +242,7 @@ pub fn is_valid_genesis_state<E: EthSpec>(state: &BeaconState<E>, spec: &ChainSp
|
||||
pub fn process_activations<E: EthSpec>(
|
||||
state: &mut BeaconState<E>,
|
||||
spec: &ChainSpec,
|
||||
) -> Result<(), Error> {
|
||||
) -> Result<(), BeaconStateError> {
|
||||
let (validators, balances, _) = state.validators_and_balances_and_progressive_balances_mut();
|
||||
let mut validators_iter = validators.iter_cow();
|
||||
while let Some((index, validator)) = validators_iter.next_cow() {
|
||||
@@ -219,7 +250,7 @@ pub fn process_activations<E: EthSpec>(
|
||||
let balance = balances
|
||||
.get(index)
|
||||
.copied()
|
||||
.ok_or(Error::BalancesOutOfBounds(index))?;
|
||||
.ok_or(BeaconStateError::BalancesOutOfBounds(index))?;
|
||||
validator.effective_balance = std::cmp::min(
|
||||
balance.safe_sub(balance.safe_rem(spec.effective_balance_increment)?)?,
|
||||
spec.max_effective_balance,
|
||||
|
||||
Reference in New Issue
Block a user