From bf40acd9dfb2aedc140777260db5d1bda3e13f7b Mon Sep 17 00:00:00 2001 From: Diva M Date: Mon, 6 Mar 2023 17:32:40 -0500 Subject: [PATCH] adjust constant to spec values and names --- beacon_node/lighthouse_network/src/rpc/config.rs | 2 +- beacon_node/lighthouse_network/src/rpc/methods.rs | 10 +++++++--- beacon_node/lighthouse_network/src/rpc/mod.rs | 4 ++-- .../network/src/beacon_processor/worker/rpc_methods.rs | 4 ++-- 4 files changed, 12 insertions(+), 8 deletions(-) diff --git a/beacon_node/lighthouse_network/src/rpc/config.rs b/beacon_node/lighthouse_network/src/rpc/config.rs index 7d88dbaff7..cdee1d495a 100644 --- a/beacon_node/lighthouse_network/src/rpc/config.rs +++ b/beacon_node/lighthouse_network/src/rpc/config.rs @@ -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); } diff --git a/beacon_node/lighthouse_network/src/rpc/methods.rs b/beacon_node/lighthouse_network/src/rpc/methods.rs index 088cf90fa9..2ee4cc9798 100644 --- a/beacon_node/lighthouse_network/src/rpc/methods.rs +++ b/beacon_node/lighthouse_network/src/rpc/methods.rs @@ -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)] diff --git a/beacon_node/lighthouse_network/src/rpc/mod.rs b/beacon_node/lighthouse_network/src/rpc/mod.rs index 8727f7df76..f2abb8821a 100644 --- a/beacon_node/lighthouse_network/src/rpc/mod.rs +++ b/beacon_node/lighthouse_network/src/rpc/mod.rs @@ -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 RPC { .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() diff --git a/beacon_node/network/src/beacon_processor/worker/rpc_methods.rs b/beacon_node/network/src/beacon_processor/worker/rpc_methods.rs index cefb1c77e1..ad0595ea05 100644 --- a/beacon_node/network/src/beacon_processor/worker/rpc_methods.rs +++ b/beacon_node/network/src/beacon_processor/worker/rpc_methods.rs @@ -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 Worker { ); // 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,