mirror of
https://github.com/sigp/lighthouse.git
synced 2026-07-01 20:04:41 +00:00
Spec v1.7.0-alpha.6 and Gloas genesis (#9190)
Co-Authored-By: Josh King <josh@sigmaprime.io> Co-Authored-By: Jimmy Chen <jchen.tc@gmail.com> Co-Authored-By: Michael Sproul <michael@sigmaprime.io>
This commit is contained in:
@@ -5023,11 +5023,8 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
|
||||
}
|
||||
.ok_or(Error::MissingExecutionPayloadEnvelope(parent_block_root))?;
|
||||
|
||||
let parent_bid = advanced_state.latest_execution_payload_bid()?.clone();
|
||||
|
||||
apply_parent_execution_payload(
|
||||
&mut advanced_state,
|
||||
&parent_bid,
|
||||
&envelope.message.execution_requests,
|
||||
&self.spec,
|
||||
)
|
||||
|
||||
@@ -623,11 +623,13 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
|
||||
// For trustless building, the builder will provide the envelope separately.
|
||||
if let Some(payload_data) = payload_data {
|
||||
let beacon_block_root = block.tree_hash_root();
|
||||
let parent_beacon_block_root = block.parent_root();
|
||||
let execution_payload_envelope = ExecutionPayloadEnvelope {
|
||||
payload: payload_data.payload,
|
||||
execution_requests: payload_data.execution_requests,
|
||||
builder_index: payload_data.builder_index,
|
||||
beacon_block_root,
|
||||
parent_beacon_block_root,
|
||||
};
|
||||
|
||||
let signed_envelope = SignedExecutionPayloadEnvelope {
|
||||
@@ -854,7 +856,6 @@ fn get_execution_payload_gloas<T: BeaconChainTypes>(
|
||||
let mut withdrawals_state = state.clone();
|
||||
apply_parent_execution_payload(
|
||||
&mut withdrawals_state,
|
||||
parent_bid,
|
||||
&envelope.message.execution_requests,
|
||||
spec,
|
||||
)?;
|
||||
|
||||
@@ -256,6 +256,7 @@ fn make_signed_preferences(
|
||||
validator_index,
|
||||
fee_recipient,
|
||||
gas_limit,
|
||||
..ProposerPreferences::default()
|
||||
},
|
||||
signature: Signature::empty(),
|
||||
})
|
||||
|
||||
@@ -72,6 +72,7 @@ fn build_chain(
|
||||
execution_requests: Default::default(),
|
||||
builder_index: 0,
|
||||
beacon_block_root: block_root,
|
||||
parent_beacon_block_root: Hash256::ZERO,
|
||||
},
|
||||
signature: Signature::empty(),
|
||||
})
|
||||
|
||||
@@ -339,6 +339,7 @@ mod tests {
|
||||
execution_requests: ExecutionRequests::default(),
|
||||
builder_index,
|
||||
beacon_block_root: Hash256::ZERO,
|
||||
parent_beacon_block_root: Hash256::ZERO,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -87,7 +87,7 @@ impl<T: BeaconChainTypes> PayloadNotifier<T> {
|
||||
Ok(NewPayloadRequest::Gloas(NewPayloadRequestGloas {
|
||||
execution_payload: &envelope.message.payload,
|
||||
versioned_hashes,
|
||||
parent_beacon_block_root: block.message().parent_root(),
|
||||
parent_beacon_block_root: envelope.message.parent_beacon_block_root,
|
||||
execution_requests: &envelope.message.execution_requests,
|
||||
}))
|
||||
}
|
||||
|
||||
@@ -105,6 +105,7 @@ mod tests {
|
||||
execution_requests: ExecutionRequests::default(),
|
||||
builder_index: 0,
|
||||
beacon_block_root: Hash256::ZERO,
|
||||
parent_beacon_block_root: Hash256::ZERO,
|
||||
},
|
||||
blobs: None,
|
||||
}
|
||||
|
||||
@@ -64,6 +64,7 @@ impl GossipVerifiedProposerPreferences {
|
||||
ctx: &GossipVerificationContext<'_, T>,
|
||||
) -> Result<Self, ProposerPreferencesError> {
|
||||
let proposal_slot = signed_preferences.message.proposal_slot;
|
||||
let checkpoint_root = signed_preferences.message.checkpoint_root;
|
||||
let validator_index = signed_preferences.message.validator_index;
|
||||
let cached_head = ctx.canonical_head.cached_head();
|
||||
let current_slot = ctx
|
||||
@@ -74,7 +75,7 @@ impl GossipVerifiedProposerPreferences {
|
||||
|
||||
if ctx
|
||||
.gossip_verified_proposer_preferences_cache
|
||||
.get_seen_validator(&proposal_slot, validator_index)
|
||||
.get_seen_validator(&proposal_slot, checkpoint_root, validator_index)
|
||||
{
|
||||
return Err(ProposerPreferencesError::AlreadySeen {
|
||||
validator_index,
|
||||
@@ -162,6 +163,7 @@ mod tests {
|
||||
|
||||
fn make_preferences(proposal_slot: Slot, validator_index: u64) -> ProposerPreferences {
|
||||
ProposerPreferences {
|
||||
checkpoint_root: types::Hash256::ZERO,
|
||||
proposal_slot,
|
||||
validator_index,
|
||||
fee_recipient: Address::ZERO,
|
||||
|
||||
@@ -5,11 +5,11 @@ use std::{
|
||||
|
||||
use crate::proposer_preferences_verification::gossip_verified_proposer_preferences::GossipVerifiedProposerPreferences;
|
||||
use parking_lot::RwLock;
|
||||
use types::{SignedProposerPreferences, Slot};
|
||||
use types::{Hash256, SignedProposerPreferences, Slot};
|
||||
|
||||
pub struct GossipVerifiedProposerPreferenceCache {
|
||||
preferences: RwLock<BTreeMap<Slot, GossipVerifiedProposerPreferences>>,
|
||||
seen: RwLock<BTreeMap<Slot, HashSet<u64>>>,
|
||||
seen: RwLock<BTreeMap<Slot, HashSet<(Hash256, u64)>>>,
|
||||
}
|
||||
|
||||
impl Default for GossipVerifiedProposerPreferenceCache {
|
||||
@@ -34,21 +34,27 @@ impl GossipVerifiedProposerPreferenceCache {
|
||||
self.preferences.write().insert(slot, preferences);
|
||||
}
|
||||
|
||||
pub fn get_seen_validator(&self, slot: &Slot, validator_index: u64) -> bool {
|
||||
pub fn get_seen_validator(
|
||||
&self,
|
||||
slot: &Slot,
|
||||
checkpoint_root: Hash256,
|
||||
validator_index: u64,
|
||||
) -> bool {
|
||||
self.seen
|
||||
.read()
|
||||
.get(slot)
|
||||
.is_some_and(|seen| seen.contains(&validator_index))
|
||||
.is_some_and(|seen| seen.contains(&(checkpoint_root, validator_index)))
|
||||
}
|
||||
|
||||
pub fn insert_seen_validator(&self, preferences: &GossipVerifiedProposerPreferences) {
|
||||
let slot = preferences.signed_preferences.message.proposal_slot;
|
||||
let checkpoint_root = preferences.signed_preferences.message.checkpoint_root;
|
||||
let validator_index = preferences.signed_preferences.message.validator_index;
|
||||
self.seen
|
||||
.write()
|
||||
.entry(slot)
|
||||
.or_default()
|
||||
.insert(validator_index);
|
||||
.insert((checkpoint_root, validator_index));
|
||||
}
|
||||
|
||||
pub fn prune(&self, current_slot: Slot) {
|
||||
@@ -77,6 +83,7 @@ mod tests {
|
||||
validator_index,
|
||||
fee_recipient: Address::ZERO,
|
||||
gas_limit: 30_000_000,
|
||||
..ProposerPreferences::default()
|
||||
},
|
||||
signature: Signature::empty(),
|
||||
}),
|
||||
@@ -97,11 +104,11 @@ 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), slot));
|
||||
assert!(!cache.get_seen_validator(&Slot::new(slot), types::Hash256::ZERO, slot));
|
||||
}
|
||||
for slot in [8, 9, 10] {
|
||||
assert!(cache.get_preferences(&Slot::new(slot)).is_some());
|
||||
assert!(cache.get_seen_validator(&Slot::new(slot), slot));
|
||||
assert!(cache.get_seen_validator(&Slot::new(slot), types::Hash256::ZERO, slot));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -131,6 +131,7 @@ fn make_signed_preferences(
|
||||
validator_index,
|
||||
fee_recipient: Address::ZERO,
|
||||
gas_limit: 30_000_000,
|
||||
..ProposerPreferences::default()
|
||||
},
|
||||
signature: Signature::empty(),
|
||||
})
|
||||
@@ -230,10 +231,11 @@ fn correct_proposer_bad_signature() {
|
||||
result,
|
||||
Err(ProposerPreferencesError::BadSignature)
|
||||
));
|
||||
assert!(
|
||||
!ctx.preferences_cache
|
||||
.get_seen_validator(&slot, actual_proposer)
|
||||
);
|
||||
assert!(!ctx.preferences_cache.get_seen_validator(
|
||||
&slot,
|
||||
types::Hash256::ZERO,
|
||||
actual_proposer
|
||||
));
|
||||
assert!(ctx.preferences_cache.get_preferences(&slot).is_none());
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user