adjust constant to spec values and names

This commit is contained in:
Diva M 2023-03-06 17:32:40 -05:00
parent 39d4f0a1f3
commit bf40acd9df
No known key found for this signature in database
GPG Key ID: 1BAE5E01126680FE
4 changed files with 12 additions and 8 deletions

View File

@ -80,7 +80,7 @@ impl OutboundRateLimiterConfig {
Quota::n_every(methods::MAX_REQUEST_BLOCKS, 10);
pub const DEFAULT_BLOCKS_BY_ROOT_QUOTA: Quota = Quota::n_every(128, 10);
pub const DEFAULT_BLOBS_BY_RANGE_QUOTA: Quota =
Quota::n_every(methods::MAX_REQUEST_BLOBS_SIDECARS, 10);
Quota::n_every(methods::MAX_REQUEST_BLOB_SIDECARS, 10);
pub const DEFAULT_BLOBS_BY_ROOT_QUOTA: Quota = Quota::n_every(128, 10);
}

View File

@ -5,7 +5,7 @@ use regex::bytes::Regex;
use serde::Serialize;
use ssz_derive::{Decode, Encode};
use ssz_types::{
typenum::{U1024, U256},
typenum::{U1024, U256, U512},
VariableList,
};
use std::ops::Deref;
@ -26,8 +26,12 @@ pub const MAX_REQUEST_BLOCKS: u64 = 1024;
pub type MaxErrorLen = U256;
pub const MAX_ERROR_LEN: u64 = 256;
pub type MaxRequestBlobsSidecars = U1024;
pub const MAX_REQUEST_BLOBS_SIDECARS: u64 = 1024;
// TODO: this is calculated as MAX_REQUEST_BLOCKS_DENEB * MAX_BLOBS_PER_BLOCK and
// MAX_BLOBS_PER_BLOCK comes from the spec.
// MAX_REQUEST_BLOCKS_DENEB = 128
// MAX_BLOBS_PER_BLOCK = 4
pub type MaxRequestBlobSidecars = U512;
pub const MAX_REQUEST_BLOB_SIDECARS: u64 = 512;
/// Wrapper over SSZ List to represent error message in rpc responses.
#[derive(Debug, Clone)]

View File

@ -24,7 +24,7 @@ pub(crate) use handler::HandlerErr;
pub(crate) use methods::{MetaData, MetaDataV1, MetaDataV2, Ping, RPCCodedResponse, RPCResponse};
pub(crate) use protocol::{InboundRequest, RPCProtocol};
use crate::rpc::methods::MAX_REQUEST_BLOBS_SIDECARS;
use crate::rpc::methods::MAX_REQUEST_BLOB_SIDECARS;
pub use handler::SubstreamId;
pub use methods::{
BlocksByRangeRequest, BlocksByRootRequest, GoodbyeReason, LightClientBootstrapRequest,
@ -148,7 +148,7 @@ impl<Id: ReqId, TSpec: EthSpec> RPC<Id, TSpec> {
.n_every(Protocol::BlobsByRoot, 128, Duration::from_secs(10))
.n_every(
Protocol::BlobsByRange,
MAX_REQUEST_BLOBS_SIDECARS,
MAX_REQUEST_BLOB_SIDECARS,
Duration::from_secs(10),
)
.build()

View File

@ -5,7 +5,7 @@ use crate::sync::SyncMessage;
use beacon_chain::{BeaconChainError, BeaconChainTypes, HistoricalBlockError, WhenSlotSkipped};
use itertools::process_results;
use lighthouse_network::rpc::methods::{
BlobsByRangeRequest, BlobsByRootRequest, MAX_REQUEST_BLOBS_SIDECARS,
BlobsByRangeRequest, BlobsByRootRequest, MAX_REQUEST_BLOB_SIDECARS,
};
use lighthouse_network::rpc::StatusMessage;
use lighthouse_network::rpc::*;
@ -669,7 +669,7 @@ impl<T: BeaconChainTypes> Worker<T> {
);
// Should not send more than max request blocks
if req.count > MAX_REQUEST_BLOBS_SIDECARS {
if req.count > MAX_REQUEST_BLOB_SIDECARS {
return self.send_error_response(
peer_id,
RPCResponseErrorCode::InvalidRequest,