Remove generic E from RequestId (#6462)

* remove Ethspec from types where it's possible to do so

* remove generic E from RequestType
This commit is contained in:
João Oliveira
2024-10-17 00:05:59 +01:00
committed by GitHub
parent 83d5c521d7
commit 772929fae2
15 changed files with 69 additions and 68 deletions

View File

@@ -793,7 +793,7 @@ impl<T: BeaconChainTypes> NetworkBeaconProcessor<T> {
);
// Should not send more than max request blocks
if req.max_blobs_requested::<T::EthSpec>() > self.chain.spec.max_request_blob_sidecars {
if req.max_blobs_requested() > self.chain.spec.max_request_blob_sidecars {
return Err((
RpcErrorResponse::InvalidRequest,
"Request exceeded `MAX_REQUEST_BLOBS_SIDECARS`",
@@ -998,7 +998,7 @@ impl<T: BeaconChainTypes> NetworkBeaconProcessor<T> {
);
// Should not send more than max request data columns
if req.max_requested::<T::EthSpec>() > self.chain.spec.max_request_data_column_sidecars {
if req.max_requested() > self.chain.spec.max_request_data_column_sidecars {
return Err((
RpcErrorResponse::InvalidRequest,
"Request exceeded `MAX_REQUEST_BLOBS_SIDECARS`",

View File

@@ -30,9 +30,9 @@ use std::time::Duration;
use tokio::sync::mpsc;
use types::blob_sidecar::FixedBlobSidecarList;
use types::{
Attestation, AttesterSlashing, BlobSidecar, BlobSidecarList, Epoch, Hash256, MainnetEthSpec,
ProposerSlashing, SignedAggregateAndProof, SignedBeaconBlock, SignedVoluntaryExit, Slot,
SubnetId,
Attestation, AttesterSlashing, BlobSidecar, BlobSidecarList, Epoch, EthSpec, Hash256,
MainnetEthSpec, ProposerSlashing, SignedAggregateAndProof, SignedBeaconBlock,
SignedVoluntaryExit, Slot, SubnetId,
};
type E = MainnetEthSpec;
@@ -366,6 +366,7 @@ impl TestRig {
BlobsByRangeRequest {
start_slot: 0,
count,
max_blobs_per_block: E::max_blobs_per_block(),
},
)
.unwrap();

View File

@@ -58,7 +58,7 @@ pub enum RouterMessage<E: EthSpec> {
RPCRequestReceived {
peer_id: PeerId,
id: PeerRequestId,
request: rpc::Request<E>,
request: rpc::Request,
},
/// An RPC response has been received.
RPCResponseReceived {
@@ -193,11 +193,11 @@ impl<T: BeaconChainTypes> Router<T> {
/* RPC - Related functionality */
/// A new RPC request has been received from the network.
fn handle_rpc_request<E: EthSpec>(
fn handle_rpc_request(
&mut self,
peer_id: PeerId,
request_id: PeerRequestId,
rpc_request: rpc::Request<E>,
rpc_request: rpc::Request,
) {
if !self.network_globals.peers.read().is_connected(&peer_id) {
debug!(self.log, "Dropping request of disconnected peer"; "peer_id" => %peer_id, "request" => ?rpc_request);
@@ -824,7 +824,7 @@ impl<E: EthSpec> HandlerNetworkContext<E> {
}
/// Sends a request to the network task.
pub fn send_processor_request(&mut self, peer_id: PeerId, request: RequestType<E>) {
pub fn send_processor_request(&mut self, peer_id: PeerId, request: RequestType) {
self.inform_network(NetworkMessage::SendRequest {
peer_id,
request_id: AppRequestId::Router,

View File

@@ -62,7 +62,7 @@ pub enum NetworkMessage<E: EthSpec> {
/// Send an RPC request to the libp2p service.
SendRequest {
peer_id: PeerId,
request: RequestType<E>,
request: RequestType,
request_id: AppRequestId,
},
/// Send a successful Response to the libp2p service.

View File

@@ -415,6 +415,7 @@ impl<T: BeaconChainTypes> SyncNetworkContext<T> {
request: RequestType::BlobsByRange(BlobsByRangeRequest {
start_slot: *request.start_slot(),
count: *request.count(),
max_blobs_per_block: T::EthSpec::max_blobs_per_block(),
}),
request_id: AppRequestId::Sync(SyncRequestId::RangeBlockAndBlobs { id }),
})