Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Merged by Bors] - Shift networking configuration #4426

Closed
Show file tree
Hide file tree
Changes from 13 commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
b97fe50
Adding networking configurations into ChainSpec
armaganyildirak Jun 21, 2023
18c02d2
Finishing gossip_max_size
armaganyildirak Jun 21, 2023
3c770a7
Finishing max_request_blocks?
armaganyildirak Jun 21, 2023
e01ab7b
Finishing max_chunk_size
armaganyildirak Jun 21, 2023
e8f86cd
Finishing ttfb_timeout
armaganyildirak Jun 21, 2023
2cccf6a
Finishing resp_timeout
armaganyildirak Jun 21, 2023
72f92af
Finishing message_domain_valid_snappy
armaganyildirak Jun 21, 2023
489558c
Finishing maximum_gossip_clock_disparity?
armaganyildirak Jun 21, 2023
5e28c2e
Finishing maximum_gossip_clock_disparity
armaganyildirak Jun 21, 2023
563ce17
Finishing for the PR
armaganyildirak Jun 22, 2023
c0ac9dc
Fixing conflicts
armaganyildirak Jun 22, 2023
47d1ae7
use chain instead of calling default_spec() function
armaganyildirak Jun 22, 2023
0724ae0
use chain instead of default_spec()
armaganyildirak Jun 22, 2023
a0f3b39
Adding gossip_max_size function ChainSpec object
armaganyildirak Jun 23, 2023
816ebec
Adding ChainSpec object to other parts
armaganyildirak Jun 24, 2023
b7e009c
Adding ChainSpec object to other parts
armaganyildirak Jun 27, 2023
d3d9b8f
Add the networking constants to Config object
armaganyildirak Jun 27, 2023
7090979
Add ChainSpec object to max_rpc_size function
armaganyildirak Jun 28, 2023
eec5813
remove the needless borrows
armaganyildirak Jun 28, 2023
6ca24e9
Fixing some test errors
armaganyildirak Jun 28, 2023
8f3b9a4
Fix the other tests
armaganyildirak Jun 28, 2023
e003f20
Resolve the some reviews
armaganyildirak Jun 29, 2023
49074a3
fmt
armaganyildirak Jun 29, 2023
ba59277
change self instead of &self for removing clone and unnecessary consu…
armaganyildirak Jun 29, 2023
7ce9005
Changes after review
armaganyildirak Jul 10, 2023
323ddda
Merge branch 'sigp:stable' into shift-networking-configuration
armaganyildirak Jul 10, 2023
214a5ff
Merge branch 'unstable' into shift-networking-configuration
divagant-martian Jul 10, 2023
d478314
Merge pull request #1 from divagant-martian/shift-networking-configur…
armaganyildirak Jul 10, 2023
2c403d9
patch merge
divagant-martian Jul 10, 2023
819ff45
fmt
divagant-martian Jul 10, 2023
3a0c57b
Merge pull request #2 from divagant-martian/shift-networking-configur…
armaganyildirak Jul 10, 2023
965ca75
fixing test errors
armaganyildirak Jul 10, 2023
d4ea7ad
Add sanity check to spawn_reprocess_scheduler function
armaganyildirak Jul 11, 2023
24ef86d
fmt
armaganyildirak Jul 11, 2023
d17b3c2
Merge branch 'unstable' into shift-networking-configuration
armaganyildirak Jul 13, 2023
75fcfbf
Remove unnecessary comment
armaganyildirak Jul 17, 2023
42cf723
fix merge conflicts
armaganyildirak Jul 17, 2023
0e67472
fixes after review
armaganyildirak Jul 18, 2023
821dab2
Set ATTESTATION_SUBNET_EXTRA_BITS value to 0
armaganyildirak Jul 18, 2023
9502596
clippy
armaganyildirak Jul 18, 2023
3608b1a
Add serde default impls to `Config`
paulhauner Jul 27, 2023
82fc995
Changes after review
armaganyildirak Jul 27, 2023
7c61007
Diva's patch. Seems to add subnet prefix back also
AgeManning Aug 1, 2023
165a1c2
change after review
armaganyildirak Aug 1, 2023
a5368b0
change after review
armaganyildirak Aug 1, 2023
e9e1ff9
fix the confilicts
armaganyildirak Aug 2, 2023
7fa9a17
fmt
armaganyildirak Aug 2, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions beacon_node/beacon_chain/src/attestation_verification.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
mod batch;

use crate::{
beacon_chain::{MAXIMUM_GOSSIP_CLOCK_DISPARITY, VALIDATOR_PUBKEY_CACHE_LOCK_TIMEOUT},
beacon_chain::VALIDATOR_PUBKEY_CACHE_LOCK_TIMEOUT,
metrics,
observed_aggregates::ObserveOutcome,
observed_attesters::Error as ObservedAttestersError,
Expand All @@ -53,7 +53,7 @@ use state_processing::{
signed_aggregate_selection_proof_signature_set, signed_aggregate_signature_set,
},
};
use std::borrow::Cow;
use std::{borrow::Cow, time::Duration};
use strum::AsRefStr;
use tree_hash::TreeHash;
use types::{
Expand Down Expand Up @@ -1035,9 +1035,9 @@ pub fn verify_propagation_slot_range<S: SlotClock, E: EthSpec>(
attestation: &Attestation<E>,
) -> Result<(), Error> {
let attestation_slot = attestation.data.slot;

let maximum_gossip_clock_disparity = Duration::from_millis(E::default_spec().maximum_gossip_clock_disparity_millis);
pawanjay176 marked this conversation as resolved.
Show resolved Hide resolved
let latest_permissible_slot = slot_clock
.now_with_future_tolerance(MAXIMUM_GOSSIP_CLOCK_DISPARITY)
.now_with_future_tolerance(maximum_gossip_clock_disparity)
.ok_or(BeaconChainError::UnableToReadSlot)?;
if attestation_slot > latest_permissible_slot {
return Err(Error::FutureSlot {
Expand All @@ -1048,7 +1048,7 @@ pub fn verify_propagation_slot_range<S: SlotClock, E: EthSpec>(

// Taking advantage of saturating subtraction on `Slot`.
let earliest_permissible_slot = slot_clock
.now_with_past_tolerance(MAXIMUM_GOSSIP_CLOCK_DISPARITY)
.now_with_past_tolerance(maximum_gossip_clock_disparity)
.ok_or(BeaconChainError::UnableToReadSlot)?
- E::slots_per_epoch();
if attestation_slot < earliest_permissible_slot {
Expand Down
5 changes: 0 additions & 5 deletions beacon_node/beacon_chain/src/beacon_chain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -206,11 +206,6 @@ pub enum OverrideForkchoiceUpdate {
AlreadyApplied,
}

/// The accepted clock drift for nodes gossiping blocks and attestations. See:
///
/// https://github.com/ethereum/eth2.0-specs/blob/v0.12.1/specs/phase0/p2p-interface.md#configuration
pub const MAXIMUM_GOSSIP_CLOCK_DISPARITY: Duration = Duration::from_millis(500);

#[derive(Debug, PartialEq)]
pub enum AttestationProcessingOutcome {
Processed,
Expand Down
4 changes: 2 additions & 2 deletions beacon_node/beacon_chain/src/block_verification.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ use crate::validator_pubkey_cache::ValidatorPubkeyCache;
use crate::{
beacon_chain::{
BeaconForkChoice, ForkChoiceError, BLOCK_PROCESSING_CACHE_LOCK_TIMEOUT,
MAXIMUM_GOSSIP_CLOCK_DISPARITY, VALIDATOR_PUBKEY_CACHE_LOCK_TIMEOUT,
VALIDATOR_PUBKEY_CACHE_LOCK_TIMEOUT,
},
metrics, BeaconChain, BeaconChainError, BeaconChainTypes,
};
Expand Down Expand Up @@ -695,7 +695,7 @@ impl<T: BeaconChainTypes> GossipVerifiedBlock<T> {
// Do not gossip or process blocks from future slots.
let present_slot_with_tolerance = chain
.slot_clock
.now_with_future_tolerance(MAXIMUM_GOSSIP_CLOCK_DISPARITY)
.now_with_future_tolerance(Duration::from_millis(T::EthSpec::default_spec().maximum_gossip_clock_disparity_millis))
pawanjay176 marked this conversation as resolved.
Show resolved Hide resolved
.ok_or(BeaconChainError::UnableToReadSlot)?;
if block.slot() > present_slot_with_tolerance {
return Err(BlockError::FutureSlot {
Expand Down
6 changes: 3 additions & 3 deletions beacon_node/beacon_chain/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,9 @@ pub mod validator_pubkey_cache;

pub use self::beacon_chain::{
AttestationProcessingOutcome, BeaconChain, BeaconChainTypes, BeaconStore, ChainSegmentResult,
ForkChoiceError, OverrideForkchoiceUpdate, ProduceBlockVerification, StateSkipConfig,
WhenSlotSkipped, INVALID_FINALIZED_MERGE_TRANSITION_BLOCK_SHUTDOWN_REASON,
INVALID_JUSTIFIED_PAYLOAD_SHUTDOWN_REASON, MAXIMUM_GOSSIP_CLOCK_DISPARITY,
ForkChoiceError, OverrideForkchoiceUpdate, ProduceBlockVerification,
StateSkipConfig, WhenSlotSkipped, INVALID_FINALIZED_MERGE_TRANSITION_BLOCK_SHUTDOWN_REASON,
INVALID_JUSTIFIED_PAYLOAD_SHUTDOWN_REASON,
};
pub use self::beacon_snapshot::BeaconSnapshot;
pub use self::chain_config::ChainConfig;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use crate::{
beacon_chain::MAXIMUM_GOSSIP_CLOCK_DISPARITY, BeaconChain, BeaconChainError, BeaconChainTypes,
BeaconChain, BeaconChainError, BeaconChainTypes,
};
use derivative::Derivative;
use slot_clock::SlotClock;
Expand Down Expand Up @@ -103,7 +103,7 @@ impl<T: BeaconChainTypes> VerifiedLightClientFinalityUpdate<T> {
// verify that enough time has passed for the block to have been propagated
match start_time {
Some(time) => {
if seen_timestamp + MAXIMUM_GOSSIP_CLOCK_DISPARITY < time + one_third_slot_duration
if seen_timestamp + Duration::from_millis(chain.spec.maximum_gossip_clock_disparity_millis) < time + one_third_slot_duration
{
return Err(Error::TooEarly);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
use crate::{
beacon_chain::MAXIMUM_GOSSIP_CLOCK_DISPARITY, BeaconChain, BeaconChainError, BeaconChainTypes,
BeaconChain, BeaconChainError, BeaconChainTypes,
};
use derivative::Derivative;
use eth2::types::Hash256;
use slot_clock::SlotClock;
use std::time::Duration;
use strum::AsRefStr;
use types::{
light_client_update::Error as LightClientUpdateError, LightClientOptimisticUpdate, Slot,
light_client_update::Error as LightClientUpdateError, LightClientOptimisticUpdate, Slot, EthSpec,
};

/// Returned when a light client optimistic update was not successfully verified. It might not have been verified for
Expand Down Expand Up @@ -103,7 +103,7 @@ impl<T: BeaconChainTypes> VerifiedLightClientOptimisticUpdate<T> {
// verify that enough time has passed for the block to have been propagated
match start_time {
Some(time) => {
if seen_timestamp + MAXIMUM_GOSSIP_CLOCK_DISPARITY < time + one_third_slot_duration
if seen_timestamp + Duration::from_millis(T::EthSpec::default_spec().maximum_gossip_clock_disparity_millis) < time + one_third_slot_duration
pawanjay176 marked this conversation as resolved.
Show resolved Hide resolved
{
return Err(Error::TooEarly);
}
Expand Down
12 changes: 6 additions & 6 deletions beacon_node/beacon_chain/src/sync_committee_verification.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@

use crate::observed_attesters::SlotSubcommitteeIndex;
use crate::{
beacon_chain::{MAXIMUM_GOSSIP_CLOCK_DISPARITY, VALIDATOR_PUBKEY_CACHE_LOCK_TIMEOUT},
beacon_chain::VALIDATOR_PUBKEY_CACHE_LOCK_TIMEOUT,
metrics,
observed_aggregates::ObserveOutcome,
BeaconChain, BeaconChainError, BeaconChainTypes,
Expand All @@ -43,7 +43,7 @@ use state_processing::signature_sets::{
sync_committee_contribution_signature_set_from_pubkeys,
sync_committee_message_set_from_pubkeys,
};
use std::borrow::Cow;
use std::{borrow::Cow, time::Duration};
use std::collections::HashMap;
use strum::AsRefStr;
use tree_hash::TreeHash;
Expand All @@ -53,7 +53,7 @@ use types::sync_committee::Error as SyncCommitteeError;
use types::{
sync_committee_contribution::Error as ContributionError, AggregateSignature, BeaconStateError,
EthSpec, Hash256, SignedContributionAndProof, Slot, SyncCommitteeContribution,
SyncCommitteeMessage, SyncSelectionProof, SyncSubnetId,
SyncCommitteeMessage, SyncSelectionProof, SyncSubnetId, MainnetEthSpec,
};

/// Returned when a sync committee contribution was not successfully verified. It might not have been verified for
Expand Down Expand Up @@ -560,9 +560,9 @@ pub fn verify_propagation_slot_range<S: SlotClock, U: SlotData>(
sync_contribution: &U,
) -> Result<(), Error> {
let message_slot = sync_contribution.get_slot();

let maximum_gossip_clock_disparity = Duration::from_millis(MainnetEthSpec::default_spec().maximum_gossip_clock_disparity_millis);
pawanjay176 marked this conversation as resolved.
Show resolved Hide resolved
let latest_permissible_slot = slot_clock
.now_with_future_tolerance(MAXIMUM_GOSSIP_CLOCK_DISPARITY)
.now_with_future_tolerance(maximum_gossip_clock_disparity)
.ok_or(BeaconChainError::UnableToReadSlot)?;
if message_slot > latest_permissible_slot {
return Err(Error::FutureSlot {
Expand All @@ -572,7 +572,7 @@ pub fn verify_propagation_slot_range<S: SlotClock, U: SlotData>(
}

let earliest_permissible_slot = slot_clock
.now_with_past_tolerance(MAXIMUM_GOSSIP_CLOCK_DISPARITY)
.now_with_past_tolerance(maximum_gossip_clock_disparity)
.ok_or(BeaconChainError::UnableToReadSlot)?;

if message_slot < earliest_permissible_slot {
Expand Down
5 changes: 3 additions & 2 deletions beacon_node/http_api/src/attester_duties.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,15 @@

use crate::state_id::StateId;
use beacon_chain::{
BeaconChain, BeaconChainError, BeaconChainTypes, MAXIMUM_GOSSIP_CLOCK_DISPARITY,
BeaconChain, BeaconChainError, BeaconChainTypes,
};
use eth2::types::{self as api_types};
use slot_clock::SlotClock;
use state_processing::state_advance::partial_state_advance;
use types::{
AttestationDuty, BeaconState, ChainSpec, CloneConfig, Epoch, EthSpec, Hash256, RelativeEpoch,
};
use std::time::Duration;

/// The struct that is returned to the requesting HTTP client.
type ApiDuties = api_types::DutiesResponse<Vec<api_types::AttesterData>>;
Expand All @@ -32,7 +33,7 @@ pub fn attester_duties<T: BeaconChainTypes>(
// will equal `current_epoch + 1`
let tolerant_current_epoch = chain
.slot_clock
.now_with_future_tolerance(MAXIMUM_GOSSIP_CLOCK_DISPARITY)
.now_with_future_tolerance(Duration::from_millis(chain.spec.maximum_gossip_clock_disparity_millis))
.ok_or_else(|| warp_utils::reject::custom_server_error("unable to read slot clock".into()))?
.epoch(T::EthSpec::slots_per_epoch());

Expand Down
6 changes: 3 additions & 3 deletions beacon_node/http_api/src/proposer_duties.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
use crate::state_id::StateId;
use beacon_chain::{
beacon_proposer_cache::{compute_proposer_duties_from_head, ensure_state_is_in_epoch},
BeaconChain, BeaconChainError, BeaconChainTypes, MAXIMUM_GOSSIP_CLOCK_DISPARITY,
BeaconChain, BeaconChainError, BeaconChainTypes,
};
use eth2::types::{self as api_types};
use safe_arith::SafeArith;
use slog::{debug, Logger};
use slot_clock::SlotClock;
use std::cmp::Ordering;
use std::{cmp::Ordering, time::Duration};
use types::{CloneConfig, Epoch, EthSpec, Hash256, Slot};

/// The struct that is returned to the requesting HTTP client.
Expand All @@ -33,7 +33,7 @@ pub fn proposer_duties<T: BeaconChainTypes>(
// will equal `current_epoch + 1`
let tolerant_current_epoch = chain
.slot_clock
.now_with_future_tolerance(MAXIMUM_GOSSIP_CLOCK_DISPARITY)
.now_with_future_tolerance(Duration::from_millis(chain.spec.maximum_gossip_clock_disparity_millis))
.ok_or_else(|| warp_utils::reject::custom_server_error("unable to read slot clock".into()))?
.epoch(T::EthSpec::slots_per_epoch());

Expand Down
5 changes: 3 additions & 2 deletions beacon_node/http_api/src/sync_committees.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use beacon_chain::sync_committee_verification::{
};
use beacon_chain::{
validator_monitor::timestamp_now, BeaconChain, BeaconChainError, BeaconChainTypes,
StateSkipConfig, MAXIMUM_GOSSIP_CLOCK_DISPARITY,
StateSkipConfig,
};
use eth2::types::{self as api_types};
use lighthouse_network::PubsubMessage;
Expand All @@ -15,6 +15,7 @@ use slog::{debug, error, warn, Logger};
use slot_clock::SlotClock;
use std::cmp::max;
use std::collections::HashMap;
use std::time::Duration;
use tokio::sync::mpsc::UnboundedSender;
use types::{
slot_data::SlotData, BeaconStateError, Epoch, EthSpec, SignedContributionAndProof,
Expand Down Expand Up @@ -85,7 +86,7 @@ fn duties_from_state_load<T: BeaconChainTypes>(
let current_epoch = chain.epoch()?;
let tolerant_current_epoch = chain
.slot_clock
.now_with_future_tolerance(MAXIMUM_GOSSIP_CLOCK_DISPARITY)
.now_with_future_tolerance(Duration::from_millis(chain.spec.maximum_gossip_clock_disparity_millis))
.ok_or(BeaconChainError::UnableToReadSlot)?
.epoch(T::EthSpec::slots_per_epoch());

Expand Down
25 changes: 8 additions & 17 deletions beacon_node/lighthouse_network/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,7 @@ use std::net::{Ipv4Addr, Ipv6Addr};
use std::path::PathBuf;
use std::sync::Arc;
use std::time::Duration;
use types::{ForkContext, ForkName};

/// The maximum transmit size of gossip messages in bytes pre-merge.
const GOSSIP_MAX_SIZE: usize = 1_048_576; // 1M
/// The maximum transmit size of gossip messages in bytes post-merge.
const GOSSIP_MAX_SIZE_POST_MERGE: usize = 10 * 1_048_576; // 10M
use types::{ForkContext, ForkName, EthSpec};

/// The cache time is set to accommodate the circulation time of an attestation.
///
Expand All @@ -38,17 +33,13 @@ const GOSSIP_MAX_SIZE_POST_MERGE: usize = 10 * 1_048_576; // 10M
/// another 500ms for "fudge factor".
pub const DUPLICATE_CACHE_TIME: Duration = Duration::from_secs(33 * 12 + 1);

// We treat uncompressed messages as invalid and never use the INVALID_SNAPPY_DOMAIN as in the
// specification. We leave it here for posterity.
// const MESSAGE_DOMAIN_INVALID_SNAPPY: [u8; 4] = [0, 0, 0, 0];
const MESSAGE_DOMAIN_VALID_SNAPPY: [u8; 4] = [1, 0, 0, 0];

/// The maximum size of gossip messages.
pub fn gossip_max_size(is_merge_enabled: bool) -> usize {
pub fn gossip_max_size<TSpec:EthSpec>(is_merge_enabled: bool) -> usize {
let gossip_max_size = TSpec::default_spec().gossip_max_size;
pawanjay176 marked this conversation as resolved.
Show resolved Hide resolved
if is_merge_enabled {
GOSSIP_MAX_SIZE_POST_MERGE
gossip_max_size
} else {
GOSSIP_MAX_SIZE
gossip_max_size / 10
}
}

Expand Down Expand Up @@ -416,7 +407,7 @@ impl From<u8> for NetworkLoad {
}

/// Return a Lighthouse specific `GossipsubConfig` where the `message_id_fn` depends on the current fork.
pub fn gossipsub_config(network_load: u8, fork_context: Arc<ForkContext>) -> GossipsubConfig {
pub fn gossipsub_config<TSpec:EthSpec>(network_load: u8, fork_context: Arc<ForkContext>) -> GossipsubConfig {
// The function used to generate a gossipsub message id
// We use the first 8 bytes of SHA256(topic, data) for content addressing
let fast_gossip_message_id = |message: &RawGossipsubMessage| {
Expand Down Expand Up @@ -454,15 +445,15 @@ pub fn gossipsub_config(network_load: u8, fork_context: Arc<ForkContext>) -> Gos
let gossip_message_id = move |message: &GossipsubMessage| {
MessageId::from(
&Sha256::digest(
prefix(MESSAGE_DOMAIN_VALID_SNAPPY, message, fork_context.clone()).as_slice(),
prefix(TSpec::default_spec().message_domain_valid_snappy, message, fork_context.clone()).as_slice(),
pawanjay176 marked this conversation as resolved.
Show resolved Hide resolved
)[..20],
)
};

let load = NetworkLoad::from(network_load);

GossipsubConfigBuilder::default()
.max_transmit_size(gossip_max_size(is_merge_enabled))
.max_transmit_size(gossip_max_size::<TSpec>(is_merge_enabled))
.heartbeat_interval(load.heartbeat_interval)
.mesh_n(load.mesh_n)
.mesh_n_low(load.mesh_n_low)
Expand Down
2 changes: 1 addition & 1 deletion beacon_node/lighthouse_network/src/rpc/codec/ssz_snappy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1399,7 +1399,7 @@ mod tests {
let mut dst = BytesMut::with_capacity(1024);

// Insert length-prefix
uvi_codec.encode(MAX_RPC_SIZE + 1, &mut dst).unwrap();
pawanjay176 marked this conversation as resolved.
Show resolved Hide resolved
uvi_codec.encode(Spec::default_spec().max_chunk_size + 1, &mut dst).unwrap();

// Insert snappy stream identifier
dst.extend_from_slice(stream_identifier);
Expand Down
4 changes: 2 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::{methods, rate_limiter::Quota, Protocol};
use super::{rate_limiter::Quota, Protocol};

use serde_derive::{Deserialize, Serialize};

Expand Down Expand Up @@ -98,7 +98,7 @@ impl RateLimiterConfig {
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(methods::MAX_REQUEST_BLOCKS, 10);
Quota::n_every(1024, 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
11 changes: 4 additions & 7 deletions beacon_node/lighthouse_network/src/rpc/handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,6 @@ use tokio::time::{sleep_until, Instant as TInstant, Sleep};
use tokio_util::time::{delay_queue, DelayQueue};
use types::{EthSpec, ForkContext};

/// The time (in seconds) before a substream that is awaiting a response from the user times out.
pub const RESPONSE_TIMEOUT: u64 = 10;

/// The number of times to retry an outbound upgrade in the case of IO errors.
const IO_ERROR_RETRIES: u8 = 3;

Expand Down Expand Up @@ -351,7 +348,7 @@ where
// new outbound request. Store the stream and tag the output.
let delay_key = self.outbound_substreams_delay.insert(
self.current_outbound_substream_id,
Duration::from_secs(RESPONSE_TIMEOUT),
Duration::from_secs(TSpec::default_spec().resp_timeout),
pawanjay176 marked this conversation as resolved.
Show resolved Hide resolved
);
let awaiting_stream = OutboundSubstreamState::RequestPendingResponse {
substream: Box::new(out),
Expand Down Expand Up @@ -402,7 +399,7 @@ where
// Store the stream and tag the output.
let delay_key = self.inbound_substreams_delay.insert(
self.current_inbound_substream_id,
Duration::from_secs(RESPONSE_TIMEOUT),
Duration::from_secs(TSpec::default_spec().resp_timeout),
);
let awaiting_stream = InboundState::Idle(substream);
self.inbound_substreams.insert(
Expand Down Expand Up @@ -714,7 +711,7 @@ where
// Each chunk is allowed RESPONSE_TIMEOUT to be sent.
if let Some(ref delay_key) = info.delay_key {
self.inbound_substreams_delay
.reset(delay_key, Duration::from_secs(RESPONSE_TIMEOUT));
.reset(delay_key, Duration::from_secs(TSpec::default_spec().resp_timeout));
}

// The stream may be currently idle. Attempt to process more
Expand Down Expand Up @@ -848,7 +845,7 @@ where
};
substream_entry.remaining_chunks = Some(remaining_chunks);
self.outbound_substreams_delay
.reset(delay_key, Duration::from_secs(RESPONSE_TIMEOUT));
.reset(delay_key, Duration::from_secs(TSpec::default_spec().resp_timeout));
}
} else {
// either this is a single response request or this response closes the
Expand Down
1 change: 0 additions & 1 deletion beacon_node/lighthouse_network/src/rpc/methods.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ 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
Loading