Merge branch 'unstable' of https://github.com/sigp/lighthouse into gloas-range-sync

This commit is contained in:
Eitan Seri-Levi
2026-05-04 14:58:16 +03:00
24 changed files with 856 additions and 80 deletions

View File

@@ -252,11 +252,11 @@ fn make_signed_preferences(
) -> Arc<SignedProposerPreferences> {
Arc::new(SignedProposerPreferences {
message: ProposerPreferences {
dependent_root: Hash256::ZERO,
proposal_slot,
validator_index,
fee_recipient,
gas_limit,
..ProposerPreferences::default()
},
signature: Signature::empty(),
})

View File

@@ -154,7 +154,9 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
#[cfg(test)]
mod tests {
use types::{Address, BeaconState, EthSpec, MinimalEthSpec, ProposerPreferences, Slot};
use types::{
Address, BeaconState, EthSpec, Hash256, MinimalEthSpec, ProposerPreferences, Slot,
};
use super::verify_preferences_consistency;
use crate::proposer_preferences_verification::ProposerPreferencesError;
@@ -163,7 +165,7 @@ mod tests {
fn make_preferences(proposal_slot: Slot, validator_index: u64) -> ProposerPreferences {
ProposerPreferences {
dependent_root: types::Hash256::ZERO,
dependent_root: Hash256::ZERO,
proposal_slot,
validator_index,
fee_recipient: Address::ZERO,

View File

@@ -70,20 +70,24 @@ mod tests {
use std::sync::Arc;
use bls::Signature;
use types::{Address, ProposerPreferences, SignedProposerPreferences, Slot};
use types::{Address, Hash256, ProposerPreferences, SignedProposerPreferences, Slot};
use super::GossipVerifiedProposerPreferenceCache;
use crate::proposer_preferences_verification::gossip_verified_proposer_preferences::GossipVerifiedProposerPreferences;
fn make_gossip_verified(slot: Slot, validator_index: u64) -> GossipVerifiedProposerPreferences {
fn make_gossip_verified(
slot: Slot,
validator_index: u64,
dependent_root: Hash256,
) -> GossipVerifiedProposerPreferences {
GossipVerifiedProposerPreferences {
signed_preferences: Arc::new(SignedProposerPreferences {
message: ProposerPreferences {
dependent_root,
proposal_slot: slot,
validator_index,
fee_recipient: Address::ZERO,
gas_limit: 30_000_000,
..ProposerPreferences::default()
},
signature: Signature::empty(),
}),
@@ -93,9 +97,10 @@ mod tests {
#[test]
fn prune_removes_old_retains_current() {
let cache = GossipVerifiedProposerPreferenceCache::default();
let root = Hash256::ZERO;
for slot in [1, 2, 3, 7, 8, 9, 10] {
let verified = make_gossip_verified(Slot::new(slot), slot);
let verified = make_gossip_verified(Slot::new(slot), slot, root);
cache.insert_seen_validator(&verified);
cache.insert_preferences(verified);
}
@@ -104,11 +109,26 @@ mod tests {
for slot in [1, 2, 3, 7] {
assert!(cache.get_preferences(&Slot::new(slot)).is_none());
assert!(!cache.get_seen_validator(&Slot::new(slot), types::Hash256::ZERO, slot));
assert!(!cache.get_seen_validator(&Slot::new(slot), root, slot));
}
for slot in [8, 9, 10] {
assert!(cache.get_preferences(&Slot::new(slot)).is_some());
assert!(cache.get_seen_validator(&Slot::new(slot), types::Hash256::ZERO, slot));
assert!(cache.get_seen_validator(&Slot::new(slot), root, slot));
}
}
#[test]
fn different_dependent_roots_not_deduped() {
let cache = GossipVerifiedProposerPreferenceCache::default();
let slot = Slot::new(5);
let root_a = Hash256::repeat_byte(0xaa);
let root_b = Hash256::repeat_byte(0xbb);
let validator_index = 42;
let verified_a = make_gossip_verified(slot, validator_index, root_a);
cache.insert_seen_validator(&verified_a);
assert!(cache.get_seen_validator(&slot, root_a, validator_index));
assert!(!cache.get_seen_validator(&slot, root_b, validator_index));
}
}

View File

@@ -127,11 +127,11 @@ fn make_signed_preferences(
) -> Arc<SignedProposerPreferences> {
Arc::new(SignedProposerPreferences {
message: ProposerPreferences {
dependent_root: Hash256::ZERO,
proposal_slot,
validator_index,
fee_recipient: Address::ZERO,
gas_limit: 30_000_000,
..ProposerPreferences::default()
},
signature: Signature::empty(),
})
@@ -231,11 +231,10 @@ fn correct_proposer_bad_signature() {
result,
Err(ProposerPreferencesError::BadSignature)
));
assert!(!ctx.preferences_cache.get_seen_validator(
&slot,
types::Hash256::ZERO,
actual_proposer
));
assert!(
!ctx.preferences_cache
.get_seen_validator(&slot, Hash256::ZERO, actual_proposer)
);
assert!(ctx.preferences_cache.get_preferences(&slot).is_none());
}