mirror of
https://github.com/sigp/lighthouse.git
synced 2026-04-19 05:48:31 +00:00
Light client updates by range RPC (#6383)
* enable lc update over rpc * resolve TODOs * resolve merge conflicts * move max light client updates to eth spec * Merge branch 'unstable' of https://github.com/sigp/lighthouse into light-client-updates-by-range-rpc * remove ethspec dependency * Update beacon_node/network/src/network_beacon_processor/rpc_methods.rs Co-authored-by: Michael Sproul <micsproul@gmail.com> * Update beacon_node/lighthouse_network/src/rpc/methods.rs Co-authored-by: Michael Sproul <micsproul@gmail.com>
This commit is contained in:
@@ -3,7 +3,7 @@ use std::sync::Arc;
|
||||
use libp2p::swarm::ConnectionId;
|
||||
use types::{
|
||||
BlobSidecar, DataColumnSidecar, EthSpec, Hash256, LightClientBootstrap,
|
||||
LightClientFinalityUpdate, LightClientOptimisticUpdate, SignedBeaconBlock,
|
||||
LightClientFinalityUpdate, LightClientOptimisticUpdate, LightClientUpdate, SignedBeaconBlock,
|
||||
};
|
||||
|
||||
use crate::rpc::{
|
||||
@@ -117,6 +117,8 @@ pub enum Response<E: EthSpec> {
|
||||
LightClientOptimisticUpdate(Arc<LightClientOptimisticUpdate<E>>),
|
||||
/// A response to a LightClientFinalityUpdate request.
|
||||
LightClientFinalityUpdate(Arc<LightClientFinalityUpdate<E>>),
|
||||
/// A response to a LightClientUpdatesByRange request.
|
||||
LightClientUpdatesByRange(Option<Arc<LightClientUpdate<E>>>),
|
||||
}
|
||||
|
||||
impl<E: EthSpec> std::convert::From<Response<E>> for RpcResponse<E> {
|
||||
@@ -156,6 +158,12 @@ impl<E: EthSpec> std::convert::From<Response<E>> for RpcResponse<E> {
|
||||
Response::LightClientFinalityUpdate(f) => {
|
||||
RpcResponse::Success(RpcSuccessResponse::LightClientFinalityUpdate(f))
|
||||
}
|
||||
Response::LightClientUpdatesByRange(f) => match f {
|
||||
Some(d) => RpcResponse::Success(RpcSuccessResponse::LightClientUpdatesByRange(d)),
|
||||
None => {
|
||||
RpcResponse::StreamTermination(ResponseTermination::LightClientUpdatesByRange)
|
||||
}
|
||||
},
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1579,6 +1579,17 @@ impl<E: EthSpec> Network<E> {
|
||||
request,
|
||||
})
|
||||
}
|
||||
RequestType::LightClientUpdatesByRange(_) => {
|
||||
metrics::inc_counter_vec(
|
||||
&metrics::TOTAL_RPC_REQUESTS,
|
||||
&["light_client_updates_by_range"],
|
||||
);
|
||||
Some(NetworkEvent::RequestReceived {
|
||||
peer_id,
|
||||
id: (connection_id, request.substream_id),
|
||||
request,
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
Ok(RPCReceived::Response(id, resp)) => {
|
||||
@@ -1632,6 +1643,11 @@ impl<E: EthSpec> Network<E> {
|
||||
peer_id,
|
||||
Response::LightClientFinalityUpdate(update),
|
||||
),
|
||||
RpcSuccessResponse::LightClientUpdatesByRange(update) => self.build_response(
|
||||
id,
|
||||
peer_id,
|
||||
Response::LightClientUpdatesByRange(Some(update)),
|
||||
),
|
||||
}
|
||||
}
|
||||
Ok(RPCReceived::EndOfStream(id, termination)) => {
|
||||
@@ -1642,6 +1658,9 @@ impl<E: EthSpec> Network<E> {
|
||||
ResponseTermination::BlobsByRoot => Response::BlobsByRoot(None),
|
||||
ResponseTermination::DataColumnsByRoot => Response::DataColumnsByRoot(None),
|
||||
ResponseTermination::DataColumnsByRange => Response::DataColumnsByRange(None),
|
||||
ResponseTermination::LightClientUpdatesByRange => {
|
||||
Response::LightClientUpdatesByRange(None)
|
||||
}
|
||||
};
|
||||
self.build_response(id, peer_id, response)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user