merge conflicts

This commit is contained in:
Eitan Seri-Levi
2025-05-27 14:56:02 -07:00
358 changed files with 11552 additions and 6768 deletions

View File

@@ -124,8 +124,7 @@ pub fn initialize_beacon_state_from_eth1<E: EthSpec>(
// Remove intermediate Deneb fork from `state.fork`.
state.fork_mut().previous_version = spec.electra_fork_version;
// TODO(electra): think about this more and determine the best way to
// do this. The spec tests will expect that the sync committees are
// The spec tests will expect that the sync committees are
// calculated using the electra value for MAX_EFFECTIVE_BALANCE when
// calling `initialize_beacon_state_from_eth1()`. But the sync committees
// are actually calcuated back in `upgrade_to_altair()`. We need to

View File

@@ -523,7 +523,7 @@ pub fn get_expected_withdrawals<E: EthSpec>(
let epoch = state.current_epoch();
let mut withdrawal_index = state.next_withdrawal_index()?;
let mut validator_index = state.next_withdrawal_validator_index()?;
let mut withdrawals = vec![];
let mut withdrawals = Vec::<Withdrawal>::with_capacity(E::max_withdrawals_per_payload());
let fork_name = state.fork_name_unchecked();
// [New in Electra:EIP7251]
@@ -538,19 +538,27 @@ pub fn get_expected_withdrawals<E: EthSpec>(
break;
}
let withdrawal_balance = state.get_balance(withdrawal.validator_index as usize)?;
let validator = state.get_validator(withdrawal.validator_index as usize)?;
let has_sufficient_effective_balance =
validator.effective_balance >= spec.min_activation_balance;
let has_excess_balance = withdrawal_balance > spec.min_activation_balance;
let total_withdrawn = withdrawals
.iter()
.filter_map(|w| {
(w.validator_index == withdrawal.validator_index).then_some(w.amount)
})
.safe_sum()?;
let balance = state
.get_balance(withdrawal.validator_index as usize)?
.safe_sub(total_withdrawn)?;
let has_excess_balance = balance > spec.min_activation_balance;
if validator.exit_epoch == spec.far_future_epoch
&& has_sufficient_effective_balance
&& has_excess_balance
{
let withdrawable_balance = std::cmp::min(
withdrawal_balance.safe_sub(spec.min_activation_balance)?,
balance.safe_sub(spec.min_activation_balance)?,
withdrawal.amount,
);
withdrawals.push(Withdrawal {

View File

@@ -63,7 +63,7 @@ pub fn verify_attestation_for_state<'ctxt, E: EthSpec>(
) -> Result<IndexedAttestationRef<'ctxt, E>> {
let data = attestation.data();
// TODO(electra) choosing a validation based on the attestation's fork
// NOTE: choosing a validation based on the attestation's fork
// rather than the state's fork makes this simple, but technically the spec
// defines this verification based on the state's fork.
match attestation {

View File

@@ -84,7 +84,7 @@ pub fn process_epoch<E: EthSpec>(
Ok(EpochProcessingSummary::Altair {
progressive_balances: current_epoch_progressive_balances,
current_epoch_total_active_balance,
participation: participation_summary,
participation: participation_summary.into(),
sync_committee,
})
}

View File

@@ -17,7 +17,7 @@ pub enum EpochProcessingSummary<E: EthSpec> {
Altair {
progressive_balances: ProgressiveBalancesCache,
current_epoch_total_active_balance: u64,
participation: ParticipationEpochSummary<E>,
participation: Box<ParticipationEpochSummary<E>>,
sync_committee: Arc<SyncCommittee<E>>,
},
}

View File

@@ -7,7 +7,7 @@ use types::{
EthSpec, Fork, PendingDeposit,
};
/// Transform a `Deneb` state into an `Electra` state.
/// Transform a `Electra` state into an `Eip7805s` state.
pub fn upgrade_to_eip7805<E: EthSpec>(
pre_state: &mut BeaconState<E>,
spec: &ChainSpec,