Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
1490e27
perf(beacon): keep unslashed target balances incrementally for the pu…
MegaRedHand Nov 2, 2026
fd72710
perf(beacon): read each attester's validator once for the target-bala…
MegaRedHand Nov 3, 2026
654fad9
Merge main into perf/progressive-target-balances
MegaRedHand Nov 4, 2026
713e1fd
Merge main into perf/progressive-target-balances
MegaRedHand Nov 11, 2026
1c51255
Merge main into perf/progressive-target-balances
MegaRedHand Nov 18, 2026
6954009
Merge main into perf/progressive-target-balances
MegaRedHand Nov 18, 2026
8045a6b
Merge main into perf/progressive-target-balances
MegaRedHand Nov 18, 2026
b0b13b1
Merge main into perf/progressive-target-balances
MegaRedHand Nov 19, 2026
580339b
Merge main into perf/progressive-target-balances
MegaRedHand Nov 19, 2026
c03bb5e
Merge main into perf/progressive-target-balances
MegaRedHand Nov 19, 2026
ce1331c
test(beacon): decide a block's incremental target totals in one helpe…
MegaRedHand Nov 19, 2026
4271e8f
fix(beacon): add to the target-balance delta in one atomic update
MegaRedHand Nov 19, 2026
cadc844
docs(beacon): say why gloas keeps the target-balance cache key, and w…
MegaRedHand Nov 19, 2026
99aa236
Merge main into perf/progressive-target-balances
MegaRedHand Nov 20, 2026
fbff48d
perf(beacon): divide an attester's reward increments once again
MegaRedHand Nov 20, 2026
f5716b1
test(beacon): sum the unslashed attesters' balances in the delta test
MegaRedHand Nov 20, 2026
89381bd
perf(beacon): check only extended target totals against a scan in deb…
MegaRedHand Nov 20, 2026
25d700c
Merge main into perf/progressive-target-balances
pablodeymo Nov 20, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -887,9 +887,10 @@ mod tests {
assert_eq!(block.state_root, post.hash_tree_root());
}

fn skip_randao() -> BlockProcessingOptions {
fn skip_randao() -> BlockProcessingOptions<'static> {
BlockProcessingOptions {
randao: RandaoVerification::Skip,
..Default::default()
}
}

Expand Down
205 changes: 173 additions & 32 deletions crates/blockchain/state_transition/src/beacon/fork_choice.rs

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -1055,6 +1055,7 @@ mod gloas_block_production_tests {
let state = state_to_build_on();
let skip = BlockProcessingOptions {
randao: RandaoVerification::Skip,
..Default::default()
};
let produce_with = |options| {
let requests = ExecutionRequests::default();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,6 @@ pub mod participation_reference;
pub mod predicates;
pub mod shuffling;
pub mod sync_committee;
pub mod target_balances;
#[cfg(any(test, feature = "test-utils"))]
pub mod test_state;
Original file line number Diff line number Diff line change
Expand Up @@ -99,10 +99,46 @@ impl ParticipationTotals {
pub fn compute(state: &BeaconState) -> Result<Self> {
scan(state, true, |_, _, _| {})
}

/// The unslashed timely-target balances of the previous and current epoch
/// as raw sums (no one-increment floor), in one scan.
///
/// What [`crate::beacon::helpers::target_balances`] caches per block: a
/// floored total cannot be extended by a later block's additions. Fails
/// like [`Self::compute`].
pub fn compute_raw_target(state: &BeaconState) -> Result<(Gwei, Gwei)> {
let raw = scan_raw(state, true, |_, _, _| {})?;
Ok((
raw.previous_flags[constants::TIMELY_TARGET_FLAG_INDEX],
raw.current_target,
))
}
}

/// [`ParticipationTotals`] before the one-increment floor.
struct RawTotals {
total_active: Gwei,
previous_flags: [Gwei; FLAG_COUNT],
current_target: Gwei,
}

/// [`scan_raw`] with the specification's one-increment floor applied.
fn scan(
state: &BeaconState,
current_target: bool,
each: impl FnMut(usize, EpochFlags, Gwei),
) -> Result<ParticipationTotals> {
let raw = scan_raw(state, current_target, each)?;
let floor = |total: Gwei| total.max(preset::EFFECTIVE_BALANCE_INCREMENT);
Ok(ParticipationTotals {
total_active_balance: floor(raw.total_active),
previous_epoch_flags: raw.previous_flags.map(floor),
current_epoch_target: floor(raw.current_target),
})
}

/// Walks the registry once, calling `each(index, flags, effective_balance)` per
/// validator, and returns the totals.
/// validator, and returns the raw totals.
///
/// The only place the membership predicates live. `current_target` says
/// whether the current epoch's list is read at all: the specification's
Expand All @@ -112,11 +148,11 @@ impl ParticipationTotals {
/// At the genesis epoch "previous" and "current" coincide and the
/// specification reads the CURRENT list for both, so the previous epoch's
/// list aliases it there.
fn scan(
fn scan_raw(
state: &BeaconState,
current_target: bool,
mut each: impl FnMut(usize, EpochFlags, Gwei),
) -> Result<ParticipationTotals> {
) -> Result<RawTotals> {
let (previous_list, current_list, _) = state.altair_validator_lists()?;
let current_epoch = get_current_epoch(state);
let previous_epoch = get_previous_epoch(state);
Expand Down Expand Up @@ -197,11 +233,10 @@ fn scan(
return Err(error);
}

let floor = |total: Gwei| total.max(preset::EFFECTIVE_BALANCE_INCREMENT);
Ok(ParticipationTotals {
total_active_balance: floor(total_active),
previous_epoch_flags: previous_flags.map(floor),
current_epoch_target: floor(current_target_balance),
Ok(RawTotals {
total_active,
previous_flags,
current_target: current_target_balance,
})
}

Expand Down
Loading