mirror of
https://github.com/sigp/lighthouse.git
synced 2026-03-15 02:42:38 +00:00
Runtime rpc request sizes (#4841)
* add runtime variable list type * add configs to ChainSpec * git rid of max request blocks type * fix tests and lints * remove todos * git rid of old const usage * fix decode impl * add new config to `Config` api struct * add docs fix compilt * move methods for per-fork-spec to chainspec * get values off chain spec * fix compile * remove min by root size * add tests for runtime var list --------- Co-authored-by: Jimmy Chen <jchen.tc@gmail.com>
This commit is contained in:
@@ -13,12 +13,11 @@ use beacon_chain::{get_block_root, BeaconChainTypes};
|
||||
use lighthouse_network::rpc::methods::BlobsByRootRequest;
|
||||
use lighthouse_network::rpc::BlocksByRootRequest;
|
||||
use rand::prelude::IteratorRandom;
|
||||
use ssz_types::VariableList;
|
||||
use std::ops::IndexMut;
|
||||
use std::sync::Arc;
|
||||
use std::time::Duration;
|
||||
use types::blob_sidecar::{BlobIdentifier, FixedBlobSidecarList};
|
||||
use types::{BlobSidecar, EthSpec, Hash256, SignedBeaconBlock};
|
||||
use types::{BlobSidecar, ChainSpec, EthSpec, Hash256, SignedBeaconBlock};
|
||||
|
||||
#[derive(Debug, Copy, Clone)]
|
||||
pub enum ResponseType {
|
||||
@@ -87,11 +86,14 @@ pub trait RequestState<L: Lookup, T: BeaconChainTypes> {
|
||||
/* Request building methods */
|
||||
|
||||
/// Construct a new request.
|
||||
fn build_request(&mut self) -> Result<(PeerId, Self::RequestType), LookupRequestError> {
|
||||
fn build_request(
|
||||
&mut self,
|
||||
spec: &ChainSpec,
|
||||
) -> Result<(PeerId, Self::RequestType), LookupRequestError> {
|
||||
// Verify and construct request.
|
||||
self.too_many_attempts()?;
|
||||
let peer = self.get_peer()?;
|
||||
let request = self.new_request();
|
||||
let request = self.new_request(spec);
|
||||
Ok((peer, request))
|
||||
}
|
||||
|
||||
@@ -108,7 +110,7 @@ pub trait RequestState<L: Lookup, T: BeaconChainTypes> {
|
||||
}
|
||||
|
||||
// Construct request.
|
||||
let (peer_id, request) = self.build_request()?;
|
||||
let (peer_id, request) = self.build_request(&cx.chain.spec)?;
|
||||
|
||||
// Update request state.
|
||||
self.get_state_mut().state = State::Downloading { peer_id };
|
||||
@@ -151,7 +153,7 @@ pub trait RequestState<L: Lookup, T: BeaconChainTypes> {
|
||||
}
|
||||
|
||||
/// Initialize `Self::RequestType`.
|
||||
fn new_request(&self) -> Self::RequestType;
|
||||
fn new_request(&self, spec: &ChainSpec) -> Self::RequestType;
|
||||
|
||||
/// Send the request to the network service.
|
||||
fn make_request(
|
||||
@@ -254,8 +256,8 @@ impl<L: Lookup, T: BeaconChainTypes> RequestState<L, T> for BlockRequestState<L>
|
||||
type VerifiedResponseType = Arc<SignedBeaconBlock<T::EthSpec>>;
|
||||
type ReconstructedResponseType = RpcBlock<T::EthSpec>;
|
||||
|
||||
fn new_request(&self) -> BlocksByRootRequest {
|
||||
BlocksByRootRequest::new(VariableList::from(vec![self.requested_block_root]))
|
||||
fn new_request(&self, spec: &ChainSpec) -> BlocksByRootRequest {
|
||||
BlocksByRootRequest::new(vec![self.requested_block_root], spec)
|
||||
}
|
||||
|
||||
fn make_request(
|
||||
@@ -353,10 +355,9 @@ impl<L: Lookup, T: BeaconChainTypes> RequestState<L, T> for BlobRequestState<L,
|
||||
type VerifiedResponseType = FixedBlobSidecarList<T::EthSpec>;
|
||||
type ReconstructedResponseType = FixedBlobSidecarList<T::EthSpec>;
|
||||
|
||||
fn new_request(&self) -> BlobsByRootRequest {
|
||||
fn new_request(&self, spec: &ChainSpec) -> BlobsByRootRequest {
|
||||
let blob_id_vec: Vec<BlobIdentifier> = self.requested_ids.clone().into();
|
||||
let blob_ids = VariableList::from(blob_id_vec);
|
||||
BlobsByRootRequest { blob_ids }
|
||||
BlobsByRootRequest::new(blob_id_vec, spec)
|
||||
}
|
||||
|
||||
fn make_request(
|
||||
|
||||
Reference in New Issue
Block a user