mirror of
https://github.com/sigp/lighthouse.git
synced 2026-03-14 10:22:38 +00:00
Implement data columns by network boilerplate (#6224)
* Implement data columns by network boilerplate * Use correct quota values * Address PR review * Update currently_supported * Merge remote-tracking branch 'sigp/unstable' into peerdas-network-boilerplate * PR reviews * Fix data column rpc request not being sent due to incorrect limits set. (#6000)
This commit is contained in:
@@ -2,11 +2,13 @@ use std::sync::Arc;
|
||||
|
||||
use libp2p::swarm::ConnectionId;
|
||||
use types::{
|
||||
BlobSidecar, EthSpec, LightClientBootstrap, LightClientFinalityUpdate,
|
||||
BlobSidecar, DataColumnSidecar, EthSpec, LightClientBootstrap, LightClientFinalityUpdate,
|
||||
LightClientOptimisticUpdate, SignedBeaconBlock,
|
||||
};
|
||||
|
||||
use crate::rpc::methods::{BlobsByRangeRequest, BlobsByRootRequest};
|
||||
use crate::rpc::methods::{
|
||||
BlobsByRangeRequest, BlobsByRootRequest, DataColumnsByRangeRequest, DataColumnsByRootRequest,
|
||||
};
|
||||
use crate::rpc::{
|
||||
methods::{
|
||||
BlocksByRangeRequest, BlocksByRootRequest, LightClientBootstrapRequest,
|
||||
@@ -27,6 +29,11 @@ pub struct SingleLookupReqId {
|
||||
pub req_id: Id,
|
||||
}
|
||||
|
||||
/// Request ID for data_columns_by_root requests. Block lookup do not issue this requests directly.
|
||||
/// Wrapping this particular req_id, ensures not mixing this requests with a custody req_id.
|
||||
#[derive(Debug, Hash, PartialEq, Eq, Clone, Copy)]
|
||||
pub struct DataColumnsByRootRequestId(pub Id);
|
||||
|
||||
/// Id of rpc requests sent by sync to the network.
|
||||
#[derive(Debug, Hash, PartialEq, Eq, Clone, Copy)]
|
||||
pub enum SyncRequestId {
|
||||
@@ -34,6 +41,8 @@ pub enum SyncRequestId {
|
||||
SingleBlock { id: SingleLookupReqId },
|
||||
/// Request searching for a set of blobs given a hash.
|
||||
SingleBlob { id: SingleLookupReqId },
|
||||
/// Request searching for a set of data columns given a hash and list of column indices.
|
||||
DataColumnsByRoot(DataColumnsByRootRequestId, SingleLookupReqId),
|
||||
/// Range request that is composed by both a block range request and a blob range request.
|
||||
RangeBlockAndBlobs { id: Id },
|
||||
}
|
||||
@@ -75,6 +84,10 @@ pub enum Request {
|
||||
LightClientFinalityUpdate,
|
||||
/// A request blobs root request.
|
||||
BlobsByRoot(BlobsByRootRequest),
|
||||
/// A request data columns root request.
|
||||
DataColumnsByRoot(DataColumnsByRootRequest),
|
||||
/// A request data columns by range request.
|
||||
DataColumnsByRange(DataColumnsByRangeRequest),
|
||||
}
|
||||
|
||||
impl<E: EthSpec> std::convert::From<Request> for OutboundRequest<E> {
|
||||
@@ -104,6 +117,8 @@ impl<E: EthSpec> std::convert::From<Request> for OutboundRequest<E> {
|
||||
}
|
||||
Request::BlobsByRange(r) => OutboundRequest::BlobsByRange(r),
|
||||
Request::BlobsByRoot(r) => OutboundRequest::BlobsByRoot(r),
|
||||
Request::DataColumnsByRoot(r) => OutboundRequest::DataColumnsByRoot(r),
|
||||
Request::DataColumnsByRange(r) => OutboundRequest::DataColumnsByRange(r),
|
||||
Request::Status(s) => OutboundRequest::Status(s),
|
||||
}
|
||||
}
|
||||
@@ -123,10 +138,14 @@ pub enum Response<E: EthSpec> {
|
||||
BlocksByRange(Option<Arc<SignedBeaconBlock<E>>>),
|
||||
/// A response to a get BLOBS_BY_RANGE request. A None response signals the end of the batch.
|
||||
BlobsByRange(Option<Arc<BlobSidecar<E>>>),
|
||||
/// A response to a get DATA_COLUMN_SIDECARS_BY_Range request.
|
||||
DataColumnsByRange(Option<Arc<DataColumnSidecar<E>>>),
|
||||
/// A response to a get BLOCKS_BY_ROOT request.
|
||||
BlocksByRoot(Option<Arc<SignedBeaconBlock<E>>>),
|
||||
/// A response to a get BLOBS_BY_ROOT request.
|
||||
BlobsByRoot(Option<Arc<BlobSidecar<E>>>),
|
||||
/// A response to a get DATA_COLUMN_SIDECARS_BY_ROOT request.
|
||||
DataColumnsByRoot(Option<Arc<DataColumnSidecar<E>>>),
|
||||
/// A response to a LightClientUpdate request.
|
||||
LightClientBootstrap(Arc<LightClientBootstrap<E>>),
|
||||
/// A response to a LightClientOptimisticUpdate request.
|
||||
@@ -154,6 +173,16 @@ impl<E: EthSpec> std::convert::From<Response<E>> for RPCCodedResponse<E> {
|
||||
Some(b) => RPCCodedResponse::Success(RPCResponse::BlobsByRange(b)),
|
||||
None => RPCCodedResponse::StreamTermination(ResponseTermination::BlobsByRange),
|
||||
},
|
||||
Response::DataColumnsByRoot(r) => match r {
|
||||
Some(d) => RPCCodedResponse::Success(RPCResponse::DataColumnsByRoot(d)),
|
||||
None => RPCCodedResponse::StreamTermination(ResponseTermination::DataColumnsByRoot),
|
||||
},
|
||||
Response::DataColumnsByRange(r) => match r {
|
||||
Some(d) => RPCCodedResponse::Success(RPCResponse::DataColumnsByRange(d)),
|
||||
None => {
|
||||
RPCCodedResponse::StreamTermination(ResponseTermination::DataColumnsByRange)
|
||||
}
|
||||
},
|
||||
Response::Status(s) => RPCCodedResponse::Success(RPCResponse::Status(s)),
|
||||
Response::LightClientBootstrap(b) => {
|
||||
RPCCodedResponse::Success(RPCResponse::LightClientBootstrap(b))
|
||||
|
||||
@@ -1204,6 +1204,12 @@ impl<E: EthSpec> Network<E> {
|
||||
Request::BlobsByRoot { .. } => {
|
||||
metrics::inc_counter_vec(&metrics::TOTAL_RPC_REQUESTS, &["blobs_by_root"])
|
||||
}
|
||||
Request::DataColumnsByRoot { .. } => {
|
||||
metrics::inc_counter_vec(&metrics::TOTAL_RPC_REQUESTS, &["data_columns_by_root"])
|
||||
}
|
||||
Request::DataColumnsByRange { .. } => {
|
||||
metrics::inc_counter_vec(&metrics::TOTAL_RPC_REQUESTS, &["data_columns_by_range"])
|
||||
}
|
||||
}
|
||||
NetworkEvent::RequestReceived {
|
||||
peer_id,
|
||||
@@ -1523,6 +1529,22 @@ impl<E: EthSpec> Network<E> {
|
||||
self.build_request(peer_request_id, peer_id, Request::BlobsByRoot(req));
|
||||
Some(event)
|
||||
}
|
||||
InboundRequest::DataColumnsByRoot(req) => {
|
||||
let event = self.build_request(
|
||||
peer_request_id,
|
||||
peer_id,
|
||||
Request::DataColumnsByRoot(req),
|
||||
);
|
||||
Some(event)
|
||||
}
|
||||
InboundRequest::DataColumnsByRange(req) => {
|
||||
let event = self.build_request(
|
||||
peer_request_id,
|
||||
peer_id,
|
||||
Request::DataColumnsByRange(req),
|
||||
);
|
||||
Some(event)
|
||||
}
|
||||
InboundRequest::LightClientBootstrap(req) => {
|
||||
let event = self.build_request(
|
||||
peer_request_id,
|
||||
@@ -1580,6 +1602,12 @@ impl<E: EthSpec> Network<E> {
|
||||
RPCResponse::BlobsByRoot(resp) => {
|
||||
self.build_response(id, peer_id, Response::BlobsByRoot(Some(resp)))
|
||||
}
|
||||
RPCResponse::DataColumnsByRoot(resp) => {
|
||||
self.build_response(id, peer_id, Response::DataColumnsByRoot(Some(resp)))
|
||||
}
|
||||
RPCResponse::DataColumnsByRange(resp) => {
|
||||
self.build_response(id, peer_id, Response::DataColumnsByRange(Some(resp)))
|
||||
}
|
||||
// Should never be reached
|
||||
RPCResponse::LightClientBootstrap(bootstrap) => {
|
||||
self.build_response(id, peer_id, Response::LightClientBootstrap(bootstrap))
|
||||
@@ -1602,6 +1630,8 @@ impl<E: EthSpec> Network<E> {
|
||||
ResponseTermination::BlocksByRoot => Response::BlocksByRoot(None),
|
||||
ResponseTermination::BlobsByRange => Response::BlobsByRange(None),
|
||||
ResponseTermination::BlobsByRoot => Response::BlobsByRoot(None),
|
||||
ResponseTermination::DataColumnsByRoot => Response::DataColumnsByRoot(None),
|
||||
ResponseTermination::DataColumnsByRange => Response::DataColumnsByRange(None),
|
||||
};
|
||||
self.build_response(id, peer_id, response)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user