@@ -73,7 +73,8 @@ use strum::IntoStaticStr;
7373use tokio:: sync:: mpsc;
7474use tracing:: { debug, error, info, trace} ;
7575use types:: {
76- BlobSidecar , DataColumnSidecar , EthSpec , ForkContext , Hash256 , SignedBeaconBlock , Slot ,
76+ BlobSidecar , DataColumnSidecar , EthSpec , ForkContext , Hash256 , SignedBeaconBlock ,
77+ SignedExecutionPayloadEnvelope , Slot ,
7778} ;
7879
7980/// The number of slots ahead of us that is allowed before requesting a long-range (batch) Sync
@@ -132,6 +133,14 @@ pub enum SyncMessage<E: EthSpec> {
132133 seen_timestamp : Duration ,
133134 } ,
134135
136+ /// A payload envelope has been received from the RPC.
137+ RpcPayloadEnvelope {
138+ sync_request_id : SyncRequestId ,
139+ peer_id : PeerId ,
140+ envelope : Option < Arc < SignedExecutionPayloadEnvelope < E > > > ,
141+ seen_timestamp : Duration ,
142+ } ,
143+
135144 /// A block with an unknown parent has been received.
136145 UnknownParentBlock ( PeerId , Arc < SignedBeaconBlock < E > > , Hash256 ) ,
137146
@@ -193,14 +202,16 @@ pub enum BlockProcessType {
193202 SingleBlock { id : Id } ,
194203 SingleBlob { id : Id } ,
195204 SingleCustodyColumn ( Id ) ,
205+ SinglePayloadEnvelope ( Id ) ,
196206}
197207
198208impl BlockProcessType {
199209 pub fn id ( & self ) -> Id {
200210 match self {
201211 BlockProcessType :: SingleBlock { id }
202212 | BlockProcessType :: SingleBlob { id }
203- | BlockProcessType :: SingleCustodyColumn ( id) => * id,
213+ | BlockProcessType :: SingleCustodyColumn ( id)
214+ | BlockProcessType :: SinglePayloadEnvelope ( id) => * id,
204215 }
205216 }
206217}
@@ -502,6 +513,9 @@ impl<T: BeaconChainTypes> SyncManager<T> {
502513 SyncRequestId :: SingleBlob { id } => {
503514 self . on_single_blob_response ( id, peer_id, RpcEvent :: RPCError ( error) )
504515 }
516+ SyncRequestId :: SinglePayloadEnvelope { id } => {
517+ self . on_single_payload_envelope_response ( id, peer_id, RpcEvent :: RPCError ( error) )
518+ }
505519 SyncRequestId :: DataColumnsByRoot ( req_id) => {
506520 self . on_data_columns_by_root_response ( req_id, peer_id, RpcEvent :: RPCError ( error) )
507521 }
@@ -848,6 +862,17 @@ impl<T: BeaconChainTypes> SyncManager<T> {
848862 } => {
849863 self . rpc_data_column_received ( sync_request_id, peer_id, data_column, seen_timestamp)
850864 }
865+ SyncMessage :: RpcPayloadEnvelope {
866+ sync_request_id,
867+ peer_id,
868+ envelope,
869+ seen_timestamp,
870+ } => self . rpc_payload_envelope_received (
871+ sync_request_id,
872+ peer_id,
873+ envelope,
874+ seen_timestamp,
875+ ) ,
851876 SyncMessage :: UnknownParentBlock ( peer_id, block, block_root) => {
852877 let block_slot = block. slot ( ) ;
853878 let parent_root = block. parent_root ( ) ;
@@ -1209,6 +1234,27 @@ impl<T: BeaconChainTypes> SyncManager<T> {
12091234 }
12101235 }
12111236
1237+ // TODO(gloas): dispatch into block_lookups once the envelope lookup state machine lands.
1238+ fn rpc_payload_envelope_received (
1239+ & mut self ,
1240+ sync_request_id : SyncRequestId ,
1241+ peer_id : PeerId ,
1242+ envelope : Option < Arc < SignedExecutionPayloadEnvelope < T :: EthSpec > > > ,
1243+ seen_timestamp : Duration ,
1244+ ) {
1245+ match sync_request_id {
1246+ SyncRequestId :: SinglePayloadEnvelope { id } => self
1247+ . on_single_payload_envelope_response (
1248+ id,
1249+ peer_id,
1250+ RpcEvent :: from_chunk ( envelope, seen_timestamp) ,
1251+ ) ,
1252+ _ => {
1253+ crit ! ( %peer_id, "bad request id for payload envelope" ) ;
1254+ }
1255+ }
1256+ }
1257+
12121258 fn rpc_data_column_received (
12131259 & mut self ,
12141260 sync_request_id : SyncRequestId ,
@@ -1237,6 +1283,22 @@ impl<T: BeaconChainTypes> SyncManager<T> {
12371283 }
12381284 }
12391285
1286+ fn on_single_payload_envelope_response (
1287+ & mut self ,
1288+ id : SingleLookupReqId ,
1289+ peer_id : PeerId ,
1290+ envelope : RpcEvent < Arc < SignedExecutionPayloadEnvelope < T :: EthSpec > > > ,
1291+ ) {
1292+ if let Some ( _resp) = self
1293+ . network
1294+ . on_single_payload_envelope_response ( id, peer_id, envelope)
1295+ {
1296+ // TODO(gloas): dispatch into
1297+ // `block_lookups.on_download_response::<PayloadEnvelopeRequestState<_>>(...)` once
1298+ // the envelope lookup state machine lands.
1299+ }
1300+ }
1301+
12401302 fn on_single_blob_response (
12411303 & mut self ,
12421304 id : SingleLookupReqId ,
0 commit comments