Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
15 changes: 11 additions & 4 deletions crates/blockchain/src/store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,17 +101,24 @@ fn update_head(store: &mut Store, log_tree: bool) {
}

/// Update the safe target for attestation.
///
/// Safe target is an *availability* signal, not a durable-knowledge signal:
/// only the "new" pool is considered. Migration from "new" to "known" runs at
/// interval 4, strictly after this computation at interval 3. 3sf-mini chose
/// that ordering deliberately so safe target sees only freshly received votes
/// from the current slot and ignores what was carried over from earlier slots
/// (block-included attestations, previously migrated gossip, self-attestations).
/// Counting "known" would let a node keep advancing its safe target on stale
/// evidence even when live participation has collapsed: exactly the failure
/// mode safe target is supposed to prevent. See leanSpec PR #680.
fn update_safe_target(store: &mut Store) {
let head_state = store.get_state(&store.head()).expect("head state exists");
let num_validators = head_state.validators.len() as u64;

let min_target_score = (num_validators * 2).div_ceil(3);

let blocks = store.get_live_chain();
// Merge both attestation pools (known + new).
// At interval 3 the promotion (interval 4) hasn't run yet, so we must
// merge both pools to get a complete view for safe target computation.
let attestations = store.extract_latest_all_attestations();
let attestations = store.extract_latest_new_attestations();
let (safe_target, _weights) = ethlambda_fork_choice::compute_lmd_ghost_head(
store.latest_justified().root,
&blocks,
Expand Down
23 changes: 0 additions & 23 deletions crates/storage/src/store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -992,29 +992,6 @@ impl Store {
.extract_latest_attestations()
}

/// Extract per-validator latest attestations from both known and new payloads.
pub fn extract_latest_all_attestations(&self) -> HashMap<u64, AttestationData> {
let mut result = self
.known_payloads
.lock()
.unwrap()
.extract_latest_attestations();
for (vid, data) in self
.new_payloads
.lock()
.unwrap()
.extract_latest_attestations()
{
let should_update = result
.get(&vid)
.is_none_or(|existing| existing.slot < data.slot);
if should_update {
result.insert(vid, data);
}
}
result
}

// ============ Known Aggregated Payloads ============
//
// "Known" aggregated payloads are active in fork choice weight calculations.
Expand Down
Loading