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
6 changes: 6 additions & 0 deletions beacon_node/beacon_chain/src/beacon_chain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5895,6 +5895,12 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
.contains_block(root)
}

// TODO(gloas): implement this once issue #8956 is resolved
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is resolved now. We can use canonical head snapshot to check this

pub fn envelope_is_known_to_fork_choice(&self, root: &Hash256) -> bool {
// for now just check the database
self.store.payload_envelope_exists(root).unwrap_or(false)
}

/// Determines the beacon proposer for the next slot. If that proposer is registered in the
/// `execution_layer`, provide the `execution_layer` with the necessary information to produce
/// `PayloadAttributes` for future calls to fork choice.
Expand Down
2 changes: 2 additions & 0 deletions beacon_node/lighthouse_network/src/service/api_types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ pub enum SyncRequestId {
SingleBlock { id: SingleLookupReqId },
/// Request searching for a set of blobs given a hash.
SingleBlob { id: SingleLookupReqId },
/// Request searching for a payload envelope given a hash.
SinglePayloadEnvelope { id: SingleLookupReqId },
/// Request searching for a set of data columns given a hash and list of column indices.
DataColumnsByRoot(DataColumnsByRootRequestId),
/// Blocks by range request
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3666,6 +3666,13 @@ impl<T: BeaconChainTypes> NetworkBeaconProcessor<T> {
"Processing payload attestation message"
);

// Trigger lookup sync by beacon block root. Treat payload attestations as unknown block
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

would this also act as a trigger for the payload itself depending on the value of payload_present?
can be done in a future PR too

// root signals (same as attestation-style lookup trigger).
self.send_sync_message(SyncMessage::UnknownBlockHashFromAttestation(
peer_id,
payload_attestation_message.data.beacon_block_root,
));

// For now, ignore all payload attestation messages since verification is not implemented
self.propagate_validation_result(message_id, peer_id, MessageAcceptance::Ignore);
}
Expand Down
50 changes: 45 additions & 5 deletions beacon_node/network/src/router.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,10 @@ use std::sync::Arc;
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> {
Expand Down Expand Up @@ -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 sync manager requests them.
Response::PayloadEnvelopesByRange(_) => {
debug!("Requesting envelopes by range not supported yet");
}
// Light client responses should not be received
Response::LightClientBootstrap(_)
Expand Down Expand Up @@ -795,6 +801,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 {
sync_request_id,
peer_id,
envelope,
seen_timestamp: self.chain.slot_clock.now_duration().unwrap_or_default(),
});
}

fn handle_beacon_processor_send_result(
&mut self,
result: Result<(), crate::network_beacon_processor::Error<T::EthSpec>>,
Expand Down
217 changes: 0 additions & 217 deletions beacon_node/network/src/sync/block_lookups/common.rs

This file was deleted.

Loading
Loading