Skip to content

Commit

Permalink
Diva's patch. Seems to add subnet prefix back also
Browse files Browse the repository at this point in the history
  • Loading branch information
AgeManning committed Aug 1, 2023
1 parent 82fc995 commit 7c61007
Show file tree
Hide file tree
Showing 12 changed files with 16 additions and 33 deletions.
5 changes: 3 additions & 2 deletions beacon_node/lighthouse_network/src/rpc/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};

Expand Down Expand Up @@ -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);
}
Expand Down
1 change: 1 addition & 0 deletions beacon_node/lighthouse_network/src/rpc/methods.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion beacon_node/lighthouse_network/src/rpc/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down
4 changes: 2 additions & 2 deletions beacon_node/lighthouse_network/src/rpc/protocol.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down Expand Up @@ -90,7 +90,7 @@ lazy_static! {
pub static ref BLOCKS_BY_ROOT_REQUEST_MAX: usize =
VariableList::<Hash256, MaxRequestBlocks>::from(vec![
Hash256::zero();
MainnetEthSpec::default_spec().max_request_blocks
MAX_REQUEST_BLOCKS
as usize
])
.as_ssz_bytes()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -297,9 +297,8 @@ impl<T: BeaconChainTypes> NetworkBeaconProcessor<T> {
);

// 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
Expand Down
3 changes: 2 additions & 1 deletion beacon_node/network/src/sync/manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down Expand Up @@ -188,7 +189,7 @@ pub fn spawn<T: BeaconChainTypes>(
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"
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
ATTESTATION_SUBNET_PREFIX_BITS: 6
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
ATTESTATION_SUBNET_PREFIX_BITS: 6
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
ATTESTATION_SUBNET_PREFIX_BITS: 6
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
ATTESTATION_SUBNET_PREFIX_BITS: 6
14 changes: 0 additions & 14 deletions consensus/types/src/chain_spec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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(),
Expand Down Expand Up @@ -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(),
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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
}
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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);
Expand Down
3 changes: 1 addition & 2 deletions lighthouse/environment/tests/testnet_dir/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
ATTESTATION_SUBNET_PREFIX_BITS: 6

0 comments on commit 7c61007

Please sign in to comment.