From 7c61007b7c2bcdc42f23507e28ff5568ba44350e Mon Sep 17 00:00:00 2001 From: Age Manning Date: Tue, 1 Aug 2023 16:12:07 +1000 Subject: [PATCH] Diva's patch. Seems to add subnet prefix back also --- beacon_node/lighthouse_network/src/rpc/config.rs | 5 +++-- beacon_node/lighthouse_network/src/rpc/methods.rs | 1 + beacon_node/lighthouse_network/src/rpc/mod.rs | 2 +- beacon_node/lighthouse_network/src/rpc/protocol.rs | 4 ++-- .../src/network_beacon_processor/rpc_methods.rs | 5 ++--- beacon_node/network/src/sync/manager.rs | 3 ++- .../built_in_network_configs/gnosis/config.yaml | 3 +-- .../built_in_network_configs/mainnet/config.yaml | 3 +-- .../built_in_network_configs/prater/config.yaml | 3 +-- .../built_in_network_configs/sepolia/config.yaml | 3 +-- consensus/types/src/chain_spec.rs | 14 -------------- .../environment/tests/testnet_dir/config.yaml | 3 +-- 12 files changed, 16 insertions(+), 33 deletions(-) diff --git a/beacon_node/lighthouse_network/src/rpc/config.rs b/beacon_node/lighthouse_network/src/rpc/config.rs index b1e824e5e8e..a0f3acaf766 100644 --- a/beacon_node/lighthouse_network/src/rpc/config.rs +++ b/beacon_node/lighthouse_network/src/rpc/config.rs @@ -4,7 +4,7 @@ use std::{ time::Duration, }; -use super::{rate_limiter::Quota, Protocol}; +use super::{methods, rate_limiter::Quota, Protocol}; use serde_derive::{Deserialize, Serialize}; @@ -97,7 +97,8 @@ impl RateLimiterConfig { pub const DEFAULT_META_DATA_QUOTA: Quota = Quota::n_every(2, 5); pub const DEFAULT_STATUS_QUOTA: Quota = Quota::n_every(5, 15); pub const DEFAULT_GOODBYE_QUOTA: Quota = Quota::one_every(10); - pub const DEFAULT_BLOCKS_BY_RANGE_QUOTA: Quota = Quota::n_every(1024, 10); + pub const DEFAULT_BLOCKS_BY_RANGE_QUOTA: Quota = + Quota::n_every(methods::MAX_REQUEST_BLOCKS, 10); pub const DEFAULT_BLOCKS_BY_ROOT_QUOTA: Quota = Quota::n_every(128, 10); pub const DEFAULT_LIGHT_CLIENT_BOOTSTRAP_QUOTA: Quota = Quota::one_every(10); } diff --git a/beacon_node/lighthouse_network/src/rpc/methods.rs b/beacon_node/lighthouse_network/src/rpc/methods.rs index 52efc35431e..af0ba2510bf 100644 --- a/beacon_node/lighthouse_network/src/rpc/methods.rs +++ b/beacon_node/lighthouse_network/src/rpc/methods.rs @@ -20,6 +20,7 @@ use types::{ /// Maximum number of blocks in a single request. pub type MaxRequestBlocks = U1024; +pub const MAX_REQUEST_BLOCKS: u64 = 1024; /// Maximum length of error message. pub type MaxErrorLen = U256; diff --git a/beacon_node/lighthouse_network/src/rpc/mod.rs b/beacon_node/lighthouse_network/src/rpc/mod.rs index 0c266b25d65..96b1cbd5818 100644 --- a/beacon_node/lighthouse_network/src/rpc/mod.rs +++ b/beacon_node/lighthouse_network/src/rpc/mod.rs @@ -27,7 +27,7 @@ pub(crate) use protocol::{InboundRequest, RPCProtocol}; pub use handler::SubstreamId; pub use methods::{ BlocksByRangeRequest, BlocksByRootRequest, GoodbyeReason, LightClientBootstrapRequest, - MaxRequestBlocks, RPCResponseErrorCode, ResponseTermination, StatusMessage, + MaxRequestBlocks, RPCResponseErrorCode, ResponseTermination, StatusMessage, MAX_REQUEST_BLOCKS, }; pub(crate) use outbound::OutboundRequest; pub use protocol::{max_rpc_size, Protocol, RPCError}; diff --git a/beacon_node/lighthouse_network/src/rpc/protocol.rs b/beacon_node/lighthouse_network/src/rpc/protocol.rs index 6b537be0ea0..2641d55af7d 100644 --- a/beacon_node/lighthouse_network/src/rpc/protocol.rs +++ b/beacon_node/lighthouse_network/src/rpc/protocol.rs @@ -2,7 +2,7 @@ use super::methods::*; use crate::rpc::{ codec::{base::BaseInboundCodec, ssz_snappy::SSZSnappyInboundCodec, InboundCodec}, methods::{MaxErrorLen, ResponseTermination, MAX_ERROR_LEN}, - MaxRequestBlocks, + MaxRequestBlocks, MAX_REQUEST_BLOCKS, }; use futures::future::BoxFuture; use futures::prelude::{AsyncRead, AsyncWrite}; @@ -90,7 +90,7 @@ lazy_static! { pub static ref BLOCKS_BY_ROOT_REQUEST_MAX: usize = VariableList::::from(vec![ Hash256::zero(); - MainnetEthSpec::default_spec().max_request_blocks + MAX_REQUEST_BLOCKS as usize ]) .as_ssz_bytes() diff --git a/beacon_node/network/src/network_beacon_processor/rpc_methods.rs b/beacon_node/network/src/network_beacon_processor/rpc_methods.rs index ad9fe54a256..19b0a60a43e 100644 --- a/beacon_node/network/src/network_beacon_processor/rpc_methods.rs +++ b/beacon_node/network/src/network_beacon_processor/rpc_methods.rs @@ -297,9 +297,8 @@ impl NetworkBeaconProcessor { ); // Should not send more than max request blocks - let max_request_blocks = self.chain.spec.max_request_blocks; - if *req.count() > max_request_blocks { - *req.count_mut() = max_request_blocks; + if *req.count() > MAX_REQUEST_BLOCKS { + *req.count_mut() = MAX_REQUEST_BLOCKS; } let forwards_block_root_iter = match self diff --git a/beacon_node/network/src/sync/manager.rs b/beacon_node/network/src/sync/manager.rs index ae4ff295d28..72542752c51 100644 --- a/beacon_node/network/src/sync/manager.rs +++ b/beacon_node/network/src/sync/manager.rs @@ -43,6 +43,7 @@ use crate::service::NetworkMessage; use crate::status::ToStatusMessage; use beacon_chain::{BeaconChain, BeaconChainTypes, BlockError, EngineState}; use futures::StreamExt; +use lighthouse_network::rpc::methods::MAX_REQUEST_BLOCKS; use lighthouse_network::types::{NetworkGlobals, SyncState}; use lighthouse_network::SyncInfo; use lighthouse_network::{PeerAction, PeerId}; @@ -188,7 +189,7 @@ pub fn spawn( log: slog::Logger, ) { assert!( - beacon_chain.spec.max_request_blocks >= T::EthSpec::slots_per_epoch() * EPOCHS_PER_BATCH, + MAX_REQUEST_BLOCKS >= T::EthSpec::slots_per_epoch() * EPOCHS_PER_BATCH, "Max blocks that can be requested in a single batch greater than max allowed blocks in a single request" ); diff --git a/common/eth2_network_config/built_in_network_configs/gnosis/config.yaml b/common/eth2_network_config/built_in_network_configs/gnosis/config.yaml index 7cc64ad5557..8e7a9dd07a4 100644 --- a/common/eth2_network_config/built_in_network_configs/gnosis/config.yaml +++ b/common/eth2_network_config/built_in_network_configs/gnosis/config.yaml @@ -91,7 +91,6 @@ DEPOSIT_CONTRACT_ADDRESS: 0x0B98057eA310F4d31F2a452B414647007d1645d9 # --------------------------------------------------------------- SUBNETS_PER_NODE: 4 GOSSIP_MAX_SIZE: 10485760 -MAX_REQUEST_BLOCKS: 1024 MIN_EPOCHS_FOR_BLOCK_REQUESTS: 33024 MAX_CHUNK_SIZE: 10485760 TTFB_TIMEOUT: 5 @@ -100,4 +99,4 @@ MESSAGE_DOMAIN_INVALID_SNAPPY: 0x00000000 MESSAGE_DOMAIN_VALID_SNAPPY: 0x01000000 ATTESTATION_SUBNET_COUNT: 64 ATTESTATION_SUBNET_EXTRA_BITS: 0 -ATTESTATION_SUBNET_PREFIX_BITS: 6 \ No newline at end of file +ATTESTATION_SUBNET_PREFIX_BITS: 6 diff --git a/common/eth2_network_config/built_in_network_configs/mainnet/config.yaml b/common/eth2_network_config/built_in_network_configs/mainnet/config.yaml index 7333f0bc267..98984f3b7db 100644 --- a/common/eth2_network_config/built_in_network_configs/mainnet/config.yaml +++ b/common/eth2_network_config/built_in_network_configs/mainnet/config.yaml @@ -91,7 +91,6 @@ DEPOSIT_CONTRACT_ADDRESS: 0x00000000219ab540356cBB839Cbe05303d7705Fa # --------------------------------------------------------------- SUBNETS_PER_NODE: 2 GOSSIP_MAX_SIZE: 10485760 -MAX_REQUEST_BLOCKS: 1024 MIN_EPOCHS_FOR_BLOCK_REQUESTS: 33024 MAX_CHUNK_SIZE: 10485760 TTFB_TIMEOUT: 5 @@ -100,4 +99,4 @@ MESSAGE_DOMAIN_INVALID_SNAPPY: 0x00000000 MESSAGE_DOMAIN_VALID_SNAPPY: 0x01000000 ATTESTATION_SUBNET_COUNT: 64 ATTESTATION_SUBNET_EXTRA_BITS: 0 -ATTESTATION_SUBNET_PREFIX_BITS: 6 \ No newline at end of file +ATTESTATION_SUBNET_PREFIX_BITS: 6 diff --git a/common/eth2_network_config/built_in_network_configs/prater/config.yaml b/common/eth2_network_config/built_in_network_configs/prater/config.yaml index 62882c6e8ac..a0dd85fec07 100644 --- a/common/eth2_network_config/built_in_network_configs/prater/config.yaml +++ b/common/eth2_network_config/built_in_network_configs/prater/config.yaml @@ -91,7 +91,6 @@ DEPOSIT_CONTRACT_ADDRESS: 0xff50ed3d0ec03aC01D4C79aAd74928BFF48a7b2b # --------------------------------------------------------------- SUBNETS_PER_NODE: 2 GOSSIP_MAX_SIZE: 10485760 -MAX_REQUEST_BLOCKS: 1024 MIN_EPOCHS_FOR_BLOCK_REQUESTS: 33024 MAX_CHUNK_SIZE: 10485760 TTFB_TIMEOUT: 5 @@ -100,4 +99,4 @@ MESSAGE_DOMAIN_INVALID_SNAPPY: 0x00000000 MESSAGE_DOMAIN_VALID_SNAPPY: 0x01000000 ATTESTATION_SUBNET_COUNT: 64 ATTESTATION_SUBNET_EXTRA_BITS: 0 -ATTESTATION_SUBNET_PREFIX_BITS: 6 \ No newline at end of file +ATTESTATION_SUBNET_PREFIX_BITS: 6 diff --git a/common/eth2_network_config/built_in_network_configs/sepolia/config.yaml b/common/eth2_network_config/built_in_network_configs/sepolia/config.yaml index 359f10e9aea..e3674cf7df5 100644 --- a/common/eth2_network_config/built_in_network_configs/sepolia/config.yaml +++ b/common/eth2_network_config/built_in_network_configs/sepolia/config.yaml @@ -79,7 +79,6 @@ DEPOSIT_CONTRACT_ADDRESS: 0x7f02C3E3c98b133055B8B348B2Ac625669Ed295D # --------------------------------------------------------------- SUBNETS_PER_NODE: 2 GOSSIP_MAX_SIZE: 10485760 -MAX_REQUEST_BLOCKS: 1024 MIN_EPOCHS_FOR_BLOCK_REQUESTS: 33024 MAX_CHUNK_SIZE: 10485760 TTFB_TIMEOUT: 5 @@ -88,4 +87,4 @@ MESSAGE_DOMAIN_INVALID_SNAPPY: 0x00000000 MESSAGE_DOMAIN_VALID_SNAPPY: 0x01000000 ATTESTATION_SUBNET_COUNT: 64 ATTESTATION_SUBNET_EXTRA_BITS: 0 -ATTESTATION_SUBNET_PREFIX_BITS: 6 \ No newline at end of file +ATTESTATION_SUBNET_PREFIX_BITS: 6 diff --git a/consensus/types/src/chain_spec.rs b/consensus/types/src/chain_spec.rs index a7e23cb8478..a13d3116d8b 100644 --- a/consensus/types/src/chain_spec.rs +++ b/consensus/types/src/chain_spec.rs @@ -172,7 +172,6 @@ pub struct ChainSpec { pub subnets_per_node: u8, pub epochs_per_subnet_subscription: u64, pub gossip_max_size: u64, - pub max_request_blocks: u64, pub min_epochs_for_block_requests: u64, pub max_chunk_size: u64, pub ttfb_timeout: u64, @@ -634,7 +633,6 @@ impl ChainSpec { target_aggregators_per_committee: 16, epochs_per_subnet_subscription: 256, gossip_max_size: default_gossip_max_size(), - max_request_blocks: default_max_request_blocks(), min_epochs_for_block_requests: default_min_epochs_for_block_requests(), max_chunk_size: default_max_chunk_size(), ttfb_timeout: default_ttfb_timeout(), @@ -867,7 +865,6 @@ impl ChainSpec { target_aggregators_per_committee: 16, epochs_per_subnet_subscription: 256, gossip_max_size: default_gossip_max_size(), - max_request_blocks: default_max_request_blocks(), min_epochs_for_block_requests: default_min_epochs_for_block_requests(), max_chunk_size: default_max_chunk_size(), ttfb_timeout: default_ttfb_timeout(), @@ -990,9 +987,6 @@ pub struct Config { #[serde(default = "default_gossip_max_size")] #[serde(with = "serde_utils::quoted_u64")] gossip_max_size: u64, - #[serde(default = "default_max_request_blocks")] - #[serde(with = "serde_utils::quoted_u64")] - max_request_blocks: u64, #[serde(default = "default_min_epochs_for_block_requests")] #[serde(with = "serde_utils::quoted_u64")] min_epochs_for_block_requests: u64, @@ -1061,10 +1055,6 @@ const fn default_gossip_max_size() -> u64 { 10485760 } -const fn default_max_request_blocks() -> u64 { - 1024 -} - const fn default_min_epochs_for_block_requests() -> u64 { 33024 } @@ -1194,7 +1184,6 @@ impl Config { deposit_contract_address: spec.deposit_contract_address, gossip_max_size: spec.gossip_max_size, - max_request_blocks: spec.max_request_blocks, min_epochs_for_block_requests: spec.min_epochs_for_block_requests, max_chunk_size: spec.max_chunk_size, ttfb_timeout: spec.ttfb_timeout, @@ -1248,7 +1237,6 @@ impl Config { deposit_network_id, deposit_contract_address, gossip_max_size, - max_request_blocks, min_epochs_for_block_requests, max_chunk_size, ttfb_timeout, @@ -1295,7 +1283,6 @@ impl Config { terminal_block_hash_activation_epoch, safe_slots_to_import_optimistically, gossip_max_size, - max_request_blocks, min_epochs_for_block_requests, max_chunk_size, ttfb_timeout, @@ -1565,7 +1552,6 @@ mod yaml_tests { check_default!(safe_slots_to_import_optimistically); check_default!(bellatrix_fork_version); check_default!(gossip_max_size); - check_default!(max_request_blocks); check_default!(min_epochs_for_block_requests); check_default!(max_chunk_size); check_default!(ttfb_timeout); diff --git a/lighthouse/environment/tests/testnet_dir/config.yaml b/lighthouse/environment/tests/testnet_dir/config.yaml index faf63433ce0..b98145163c4 100644 --- a/lighthouse/environment/tests/testnet_dir/config.yaml +++ b/lighthouse/environment/tests/testnet_dir/config.yaml @@ -86,7 +86,6 @@ DEPOSIT_CONTRACT_ADDRESS: 0x00000000219ab540356cBB839Cbe05303d7705Fa # --------------------------------------------------------------- SUBNETS_PER_NODE: 2 GOSSIP_MAX_SIZE: 10485760 -MAX_REQUEST_BLOCKS: 1024 MIN_EPOCHS_FOR_BLOCK_REQUESTS: 33024 MAX_CHUNK_SIZE: 10485760 TTFB_TIMEOUT: 5 @@ -95,4 +94,4 @@ MESSAGE_DOMAIN_INVALID_SNAPPY: 0x00000000 MESSAGE_DOMAIN_VALID_SNAPPY: 0x01000000 ATTESTATION_SUBNET_COUNT: 64 ATTESTATION_SUBNET_EXTRA_BITS: 0 -ATTESTATION_SUBNET_PREFIX_BITS: 6 \ No newline at end of file +ATTESTATION_SUBNET_PREFIX_BITS: 6