mirror of
https://github.com/sigp/lighthouse.git
synced 2026-04-29 18:53:32 +00:00
When a block comes in whose parent is unkown, queue the block for processing and lookup the parent envelope
This commit is contained in:
@@ -24,7 +24,10 @@ use std::time::{Duration, SystemTime, UNIX_EPOCH};
|
||||
use tokio::sync::mpsc;
|
||||
use tokio_stream::wrappers::UnboundedReceiverStream;
|
||||
use tracing::{debug, error, trace, warn};
|
||||
use types::{BlobSidecar, DataColumnSidecar, EthSpec, ForkContext, SignedBeaconBlock};
|
||||
use types::{
|
||||
BlobSidecar, DataColumnSidecar, EthSpec, ForkContext, SignedBeaconBlock,
|
||||
SignedExecutionPayloadEnvelope,
|
||||
};
|
||||
|
||||
/// Handles messages from the network and routes them to the appropriate service to be handled.
|
||||
pub struct Router<T: BeaconChainTypes> {
|
||||
@@ -327,10 +330,13 @@ impl<T: BeaconChainTypes> Router<T> {
|
||||
Response::DataColumnsByRange(data_column) => {
|
||||
self.on_data_columns_by_range_response(peer_id, app_request_id, data_column);
|
||||
}
|
||||
// TODO(EIP-7732): implement outgoing payload envelopes by range and root
|
||||
// responses once sync manager requests them.
|
||||
Response::PayloadEnvelopesByRoot(_) | Response::PayloadEnvelopesByRange(_) => {
|
||||
debug!("Requesting envelopes by root and by range not supported yet");
|
||||
Response::PayloadEnvelopesByRoot(envelope) => {
|
||||
self.on_payload_envelopes_by_root_response(peer_id, app_request_id, envelope);
|
||||
}
|
||||
// TODO(EIP-7732): implement outgoing payload envelopes by range responses once
|
||||
// range sync requests them.
|
||||
Response::PayloadEnvelopesByRange(_) => {
|
||||
unreachable!()
|
||||
}
|
||||
// Light client responses should not be received
|
||||
Response::LightClientBootstrap(_)
|
||||
@@ -703,6 +709,40 @@ impl<T: BeaconChainTypes> Router<T> {
|
||||
});
|
||||
}
|
||||
|
||||
/// Handle a `PayloadEnvelopesByRoot` response from the peer.
|
||||
pub fn on_payload_envelopes_by_root_response(
|
||||
&mut self,
|
||||
peer_id: PeerId,
|
||||
app_request_id: AppRequestId,
|
||||
envelope: Option<Arc<SignedExecutionPayloadEnvelope<T::EthSpec>>>,
|
||||
) {
|
||||
let sync_request_id = match app_request_id {
|
||||
AppRequestId::Sync(sync_id) => match sync_id {
|
||||
id @ SyncRequestId::SinglePayloadEnvelope { .. } => id,
|
||||
other => {
|
||||
crit!(request = ?other, "PayloadEnvelopesByRoot response on incorrect request");
|
||||
return;
|
||||
}
|
||||
},
|
||||
AppRequestId::Router => {
|
||||
crit!(%peer_id, "All PayloadEnvelopesByRoot requests belong to sync");
|
||||
return;
|
||||
}
|
||||
AppRequestId::Internal => unreachable!("Handled internally"),
|
||||
};
|
||||
|
||||
trace!(
|
||||
%peer_id,
|
||||
"Received PayloadEnvelopesByRoot Response"
|
||||
);
|
||||
self.send_to_sync(SyncMessage::RpcPayloadEnvelope {
|
||||
peer_id,
|
||||
sync_request_id,
|
||||
envelope,
|
||||
seen_timestamp: timestamp_now(),
|
||||
});
|
||||
}
|
||||
|
||||
/// Handle a `BlobsByRoot` response from the peer.
|
||||
pub fn on_blobs_by_root_response(
|
||||
&mut self,
|
||||
|
||||
Reference in New Issue
Block a user