mirror of
https://github.com/sigp/lighthouse.git
synced 2026-05-07 00:42:42 +00:00
cleanup
This commit is contained in:
@@ -132,18 +132,21 @@ pub async fn publish_execution_payload_envelope<T: BeaconChainTypes>(
|
|||||||
};
|
};
|
||||||
|
|
||||||
let ctx = chain.gossip_verification_context();
|
let ctx = chain.gossip_verification_context();
|
||||||
let Ok(gossip_verifed_envelope) = GossipVerifiedEnvelope::new(signed_envelope, &ctx) else {
|
let gossip_verified_envelope = match GossipVerifiedEnvelope::new(signed_envelope, &ctx) {
|
||||||
warn!(%slot, %beacon_block_root, "Execution payload envelope rejected");
|
Ok(envelope) => envelope,
|
||||||
return Err(warp_utils::reject::custom_bad_request(
|
Err(e) => {
|
||||||
"execution payload envelope rejected, gossip verification".to_string(),
|
warn!(%slot, %beacon_block_root, error = ?e, "Execution payload envelope rejected");
|
||||||
));
|
return Err(warp_utils::reject::custom_bad_request(format!(
|
||||||
|
"execution payload envelope rejected: {e:?}",
|
||||||
|
)));
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// Import the envelope locally (runs state transition and notifies the EL).
|
// Import the envelope locally (runs state transition and notifies the EL).
|
||||||
chain
|
chain
|
||||||
.process_execution_payload_envelope(
|
.process_execution_payload_envelope(
|
||||||
beacon_block_root,
|
beacon_block_root,
|
||||||
gossip_verifed_envelope,
|
gossip_verified_envelope,
|
||||||
NotifyExecutionLayer::Yes,
|
NotifyExecutionLayer::Yes,
|
||||||
BlockImportSource::HttpApi,
|
BlockImportSource::HttpApi,
|
||||||
publish_fn,
|
publish_fn,
|
||||||
|
|||||||
@@ -228,6 +228,47 @@ impl<T: BeaconChainTypes> BlockLookups<T> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// A child block's parent envelope is missing. Create a child lookup (with the block component)
|
||||||
|
/// that waits for the parent envelope, and an envelope-only lookup for the parent.
|
||||||
|
///
|
||||||
|
/// Returns true if both lookups are created or already exist.
|
||||||
|
#[must_use = "only reference the new lookup if returns true"]
|
||||||
|
pub fn search_child_and_parent_envelope(
|
||||||
|
&mut self,
|
||||||
|
block_root: Hash256,
|
||||||
|
block_component: BlockComponent<T::EthSpec>,
|
||||||
|
parent_root: Hash256,
|
||||||
|
peer_id: PeerId,
|
||||||
|
cx: &mut SyncNetworkContext<T>,
|
||||||
|
) -> bool {
|
||||||
|
let envelope_lookup_exists =
|
||||||
|
self.search_parent_envelope_of_child(parent_root, &[peer_id], cx);
|
||||||
|
if envelope_lookup_exists {
|
||||||
|
// Create child lookup that waits for the parent envelope (not parent block).
|
||||||
|
// The child block itself is available, so we pass it as a component.
|
||||||
|
let child_created = self.new_current_lookup(
|
||||||
|
block_root,
|
||||||
|
Some(block_component),
|
||||||
|
None, // not awaiting parent block
|
||||||
|
&[],
|
||||||
|
cx,
|
||||||
|
);
|
||||||
|
// Set awaiting_parent_envelope on the child lookup
|
||||||
|
if child_created {
|
||||||
|
if let Some((_, lookup)) = self
|
||||||
|
.single_block_lookups
|
||||||
|
.iter_mut()
|
||||||
|
.find(|(_, l)| l.is_for_block(block_root))
|
||||||
|
{
|
||||||
|
lookup.set_awaiting_parent_envelope(parent_root);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
child_created
|
||||||
|
} else {
|
||||||
|
false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// Seach a block whose parent root is unknown.
|
/// Seach a block whose parent root is unknown.
|
||||||
///
|
///
|
||||||
/// Returns true if the lookup is created or already exists
|
/// Returns true if the lookup is created or already exists
|
||||||
@@ -815,7 +856,8 @@ impl<T: BeaconChainTypes> BlockLookups<T> {
|
|||||||
Action::ParentEnvelopeUnknown { parent_root } => {
|
Action::ParentEnvelopeUnknown { parent_root } => {
|
||||||
let peers = lookup.all_peers();
|
let peers = lookup.all_peers();
|
||||||
lookup.set_awaiting_parent_envelope(parent_root);
|
lookup.set_awaiting_parent_envelope(parent_root);
|
||||||
let envelope_lookup_exists = self.search_parent_envelope_of_child(parent_root, &peers, cx);
|
let envelope_lookup_exists =
|
||||||
|
self.search_parent_envelope_of_child(parent_root, &peers, cx);
|
||||||
if envelope_lookup_exists {
|
if envelope_lookup_exists {
|
||||||
debug!(
|
debug!(
|
||||||
id = lookup_id,
|
id = lookup_id,
|
||||||
|
|||||||
@@ -935,9 +935,9 @@ impl<T: BeaconChainTypes> SyncManager<T> {
|
|||||||
debug!(
|
debug!(
|
||||||
%block_root,
|
%block_root,
|
||||||
%parent_root,
|
%parent_root,
|
||||||
"Parent envelope not yet available, creating lookup"
|
"Parent envelope not yet available, creating envelope lookup"
|
||||||
);
|
);
|
||||||
self.handle_unknown_parent(
|
self.handle_unknown_parent_envelope(
|
||||||
peer_id,
|
peer_id,
|
||||||
block_root,
|
block_root,
|
||||||
parent_root,
|
parent_root,
|
||||||
@@ -1055,6 +1055,40 @@ impl<T: BeaconChainTypes> SyncManager<T> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Handle a block whose parent block is known but parent envelope is missing.
|
||||||
|
/// Creates an envelope-only lookup for the parent and a child lookup that waits for it.
|
||||||
|
fn handle_unknown_parent_envelope(
|
||||||
|
&mut self,
|
||||||
|
peer_id: PeerId,
|
||||||
|
block_root: Hash256,
|
||||||
|
parent_root: Hash256,
|
||||||
|
slot: Slot,
|
||||||
|
block_component: BlockComponent<T::EthSpec>,
|
||||||
|
) {
|
||||||
|
match self.should_search_for_block(Some(slot), &peer_id) {
|
||||||
|
Ok(_) => {
|
||||||
|
if self.block_lookups.search_child_and_parent_envelope(
|
||||||
|
block_root,
|
||||||
|
block_component,
|
||||||
|
parent_root,
|
||||||
|
peer_id,
|
||||||
|
&mut self.network,
|
||||||
|
) {
|
||||||
|
// Lookups created
|
||||||
|
} else {
|
||||||
|
debug!(
|
||||||
|
?block_root,
|
||||||
|
?parent_root,
|
||||||
|
"No lookup created for child and parent envelope"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Err(reason) => {
|
||||||
|
debug!(%block_root, %parent_root, reason, "Ignoring unknown parent envelope request");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fn handle_unknown_block_root(&mut self, peer_id: PeerId, block_root: Hash256) {
|
fn handle_unknown_block_root(&mut self, peer_id: PeerId, block_root: Hash256) {
|
||||||
match self.should_search_for_block(None, &peer_id) {
|
match self.should_search_for_block(None, &peer_id) {
|
||||||
Ok(_) => {
|
Ok(_) => {
|
||||||
|
|||||||
Reference in New Issue
Block a user