Skip to content

Commit 7414243

Browse files
committed
add todo for is_parent_block_full
1 parent 08c158b commit 7414243

File tree

3 files changed

+33
-17
lines changed

3 files changed

+33
-17
lines changed

consensus/state_processing/src/per_block_processing.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -522,7 +522,8 @@ pub fn compute_timestamp_at_slot<E: EthSpec>(
522522

523523
/// Compute the next batch of withdrawals which should be included in a block.
524524
///
525-
/// https://ethereum.github.io/consensus-specs/specs/_features/eip7732/beacon-chain/#modified-get_expected_withdrawals
525+
/// https://ethereum.github.io/consensus-specs/specs/gloas/beacon-chain/#modified-get_expected_withdrawals
526+
#[allow(clippy::type_complexity)]
526527
pub fn get_expected_withdrawals<E: EthSpec>(
527528
state: &BeaconState<E>,
528529
spec: &ChainSpec,
@@ -540,7 +541,7 @@ pub fn get_expected_withdrawals<E: EthSpec>(
540541
let mut processed_builder_withdrawals_count = 0;
541542
for withdrawal in builder_pending_withdrawals {
542543
if withdrawal.withdrawable_epoch > epoch
543-
|| withdrawals.len() + 1 == E::max_withdrawals_per_payload()
544+
|| withdrawals.len().safe_add(1)? == E::max_withdrawals_per_payload()
544545
{
545546
break;
546547
}

consensus/state_processing/src/per_block_processing/process_withdrawals.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,20 @@ pub mod capella {
110110
}
111111
pub mod gloas {
112112
use super::*;
113+
114+
// TODO(EIP-7732): Add comprehensive tests for Gloas `process_withdrawals`:
115+
// - Test builder_pending_withdrawals processing and removal
116+
// - Test is_builder_payment_withdrawable conditions (slashed vs unslashed builders)
117+
// - Test latest_withdrawals_root computation
118+
// - Test interaction with is_parent_block_full()
119+
// - Test partial withdrawals processing
120+
// Similar to Capella version, these will be tested via:
121+
// 1. EF consensus-spec tests in `testing/ef_tests/src/cases/operations.rs`
122+
// (see WithdrawalsPayload handler, lines ~390-430)
123+
// 2. Integration tests via full block processing
124+
// Once Gloas blocks can be properly constructed, add test cases to EF test suite.
125+
// These tests would currently fail due to incomplete Gloas block structure as mentioned here, so we will implement them after block and payload processing is in a good state.
126+
// https://github.com/sigp/lighthouse/pull/8273
113127
/// Apply withdrawals to the state.
114128
pub fn process_withdrawals<E: EthSpec>(
115129
state: &mut BeaconState<E>,

consensus/types/src/beacon_state.rs

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -760,21 +760,6 @@ impl<E: EthSpec> BeaconState<E> {
760760
}
761761
}
762762

763-
/// Return true if the parent block was full (both beacon block and execution payload were present).
764-
pub fn is_parent_block_full(&self) -> bool {
765-
match self {
766-
BeaconState::Base(_) | BeaconState::Altair(_) => false,
767-
BeaconState::Bellatrix(_)
768-
| BeaconState::Capella(_)
769-
| BeaconState::Deneb(_)
770-
| BeaconState::Electra(_)
771-
| BeaconState::Fulu(_) => true,
772-
BeaconState::Gloas(state) => {
773-
state.latest_execution_payload_bid.block_hash == state.latest_block_hash
774-
}
775-
}
776-
}
777-
778763
/// Returns the `tree_hash_root` of the state.
779764
pub fn canonical_root(&mut self) -> Result<Hash256, Error> {
780765
self.update_tree_hash_cache()
@@ -2219,6 +2204,22 @@ impl<E: EthSpec> BeaconState<E> {
22192204
}
22202205
}
22212206

2207+
/// Return true if the parent block was full (both beacon block and execution payload were present).
2208+
pub fn is_parent_block_full(&self) -> bool {
2209+
match self {
2210+
BeaconState::Base(_) | BeaconState::Altair(_) => false,
2211+
// TODO(EIP-7732): check the implications of this when we get to forkchoice modifications
2212+
BeaconState::Bellatrix(_)
2213+
| BeaconState::Capella(_)
2214+
| BeaconState::Deneb(_)
2215+
| BeaconState::Electra(_)
2216+
| BeaconState::Fulu(_) => true,
2217+
BeaconState::Gloas(state) => {
2218+
state.latest_execution_payload_bid.block_hash == state.latest_block_hash
2219+
}
2220+
}
2221+
}
2222+
22222223
/// Get the committee cache for some `slot`.
22232224
///
22242225
/// Return an error if the cache for the slot's epoch is not initialized.

0 commit comments

Comments
 (0)