mirror of
https://github.com/sigp/lighthouse.git
synced 2026-03-06 10:11:44 +00:00
Remove generic Id param from RequestId (#6032)
* rename RequestId's for better context, and move them to lighthouse_network crate. * remove unrequired generic AppReqId from RequestID
This commit is contained in:
@@ -13,7 +13,6 @@ use types::{
|
||||
};
|
||||
|
||||
type E = MinimalEthSpec;
|
||||
type ReqId = usize;
|
||||
|
||||
use tempfile::Builder as TempBuilder;
|
||||
|
||||
@@ -44,14 +43,14 @@ pub fn fork_context(fork_name: ForkName) -> ForkContext {
|
||||
}
|
||||
|
||||
pub struct Libp2pInstance(
|
||||
LibP2PService<ReqId, E>,
|
||||
LibP2PService<E>,
|
||||
#[allow(dead_code)]
|
||||
// This field is managed for lifetime purposes may not be used directly, hence the `#[allow(dead_code)]` attribute.
|
||||
async_channel::Sender<()>,
|
||||
);
|
||||
|
||||
impl std::ops::Deref for Libp2pInstance {
|
||||
type Target = LibP2PService<ReqId, E>;
|
||||
type Target = LibP2PService<E>;
|
||||
fn deref(&self) -> &Self::Target {
|
||||
&self.0
|
||||
}
|
||||
@@ -125,7 +124,7 @@ pub async fn build_libp2p_instance(
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
pub fn get_enr(node: &LibP2PService<ReqId, E>) -> Enr {
|
||||
pub fn get_enr(node: &LibP2PService<E>) -> Enr {
|
||||
node.local_enr()
|
||||
}
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@ mod common;
|
||||
|
||||
use common::Protocol;
|
||||
use lighthouse_network::rpc::methods::*;
|
||||
use lighthouse_network::service::api_types::AppRequestId;
|
||||
use lighthouse_network::{rpc::max_rpc_size, NetworkEvent, ReportSource, Request, Response};
|
||||
use slog::{debug, warn, Level};
|
||||
use ssz::Encode;
|
||||
@@ -99,12 +100,12 @@ fn test_tcp_status_rpc() {
|
||||
// Send a STATUS message
|
||||
debug!(log, "Sending RPC");
|
||||
sender
|
||||
.send_request(peer_id, 10, rpc_request.clone())
|
||||
.send_request(peer_id, AppRequestId::Router, rpc_request.clone())
|
||||
.unwrap();
|
||||
}
|
||||
NetworkEvent::ResponseReceived {
|
||||
peer_id: _,
|
||||
id: 10,
|
||||
id: AppRequestId::Router,
|
||||
response,
|
||||
} => {
|
||||
// Should receive the RPC response
|
||||
@@ -196,7 +197,6 @@ fn test_tcp_blocks_by_range_chunked_rpc() {
|
||||
|
||||
// keep count of the number of messages received
|
||||
let mut messages_received = 0;
|
||||
let request_id = messages_to_send as usize;
|
||||
// build the sender future
|
||||
let sender_future = async {
|
||||
loop {
|
||||
@@ -205,7 +205,7 @@ fn test_tcp_blocks_by_range_chunked_rpc() {
|
||||
// Send a STATUS message
|
||||
debug!(log, "Sending RPC");
|
||||
sender
|
||||
.send_request(peer_id, request_id, rpc_request.clone())
|
||||
.send_request(peer_id, AppRequestId::Router, rpc_request.clone())
|
||||
.unwrap();
|
||||
}
|
||||
NetworkEvent::ResponseReceived {
|
||||
@@ -323,7 +323,6 @@ fn test_blobs_by_range_chunked_rpc() {
|
||||
|
||||
// keep count of the number of messages received
|
||||
let mut messages_received = 0;
|
||||
let request_id = messages_to_send as usize;
|
||||
// build the sender future
|
||||
let sender_future = async {
|
||||
loop {
|
||||
@@ -332,7 +331,7 @@ fn test_blobs_by_range_chunked_rpc() {
|
||||
// Send a STATUS message
|
||||
debug!(log, "Sending RPC");
|
||||
sender
|
||||
.send_request(peer_id, request_id, rpc_request.clone())
|
||||
.send_request(peer_id, AppRequestId::Router, rpc_request.clone())
|
||||
.unwrap();
|
||||
}
|
||||
NetworkEvent::ResponseReceived {
|
||||
@@ -433,7 +432,6 @@ fn test_tcp_blocks_by_range_over_limit() {
|
||||
let rpc_response_bellatrix_large =
|
||||
Response::BlocksByRange(Some(Arc::new(signed_full_block)));
|
||||
|
||||
let request_id = messages_to_send as usize;
|
||||
// build the sender future
|
||||
let sender_future = async {
|
||||
loop {
|
||||
@@ -442,12 +440,12 @@ fn test_tcp_blocks_by_range_over_limit() {
|
||||
// Send a STATUS message
|
||||
debug!(log, "Sending RPC");
|
||||
sender
|
||||
.send_request(peer_id, request_id, rpc_request.clone())
|
||||
.send_request(peer_id, AppRequestId::Router, rpc_request.clone())
|
||||
.unwrap();
|
||||
}
|
||||
// The request will fail because the sender will refuse to send anything > MAX_RPC_SIZE
|
||||
NetworkEvent::RPCFailed { id, .. } => {
|
||||
assert_eq!(id, request_id);
|
||||
assert!(matches!(id, AppRequestId::Router));
|
||||
return;
|
||||
}
|
||||
_ => {} // Ignore other behaviour events
|
||||
@@ -528,7 +526,6 @@ fn test_tcp_blocks_by_range_chunked_rpc_terminates_correctly() {
|
||||
|
||||
// keep count of the number of messages received
|
||||
let mut messages_received: u64 = 0;
|
||||
let request_id = messages_to_send as usize;
|
||||
// build the sender future
|
||||
let sender_future = async {
|
||||
loop {
|
||||
@@ -537,7 +534,7 @@ fn test_tcp_blocks_by_range_chunked_rpc_terminates_correctly() {
|
||||
// Send a STATUS message
|
||||
debug!(log, "Sending RPC");
|
||||
sender
|
||||
.send_request(peer_id, request_id, rpc_request.clone())
|
||||
.send_request(peer_id, AppRequestId::Router, rpc_request.clone())
|
||||
.unwrap();
|
||||
}
|
||||
NetworkEvent::ResponseReceived {
|
||||
@@ -668,12 +665,12 @@ fn test_tcp_blocks_by_range_single_empty_rpc() {
|
||||
// Send a STATUS message
|
||||
debug!(log, "Sending RPC");
|
||||
sender
|
||||
.send_request(peer_id, 10, rpc_request.clone())
|
||||
.send_request(peer_id, AppRequestId::Router, rpc_request.clone())
|
||||
.unwrap();
|
||||
}
|
||||
NetworkEvent::ResponseReceived {
|
||||
peer_id: _,
|
||||
id: 10,
|
||||
id: AppRequestId::Router,
|
||||
response,
|
||||
} => match response {
|
||||
Response::BlocksByRange(Some(_)) => {
|
||||
@@ -793,12 +790,12 @@ fn test_tcp_blocks_by_root_chunked_rpc() {
|
||||
// Send a STATUS message
|
||||
debug!(log, "Sending RPC");
|
||||
sender
|
||||
.send_request(peer_id, 6, rpc_request.clone())
|
||||
.send_request(peer_id, AppRequestId::Router, rpc_request.clone())
|
||||
.unwrap();
|
||||
}
|
||||
NetworkEvent::ResponseReceived {
|
||||
peer_id: _,
|
||||
id: 6,
|
||||
id: AppRequestId::Router,
|
||||
response,
|
||||
} => match response {
|
||||
Response::BlocksByRoot(Some(_)) => {
|
||||
@@ -926,12 +923,12 @@ fn test_tcp_blocks_by_root_chunked_rpc_terminates_correctly() {
|
||||
// Send a STATUS message
|
||||
debug!(log, "Sending RPC");
|
||||
sender
|
||||
.send_request(peer_id, 10, rpc_request.clone())
|
||||
.send_request(peer_id, AppRequestId::Router, rpc_request.clone())
|
||||
.unwrap();
|
||||
}
|
||||
NetworkEvent::ResponseReceived {
|
||||
peer_id: _,
|
||||
id: 10,
|
||||
id: AppRequestId::Router,
|
||||
response,
|
||||
} => {
|
||||
debug!(log, "Sender received a response");
|
||||
|
||||
Reference in New Issue
Block a user