Skip to content

Commit 7b5be8b

Browse files
authored
Remove ttfb_timeout and resp_timeout (#7925)
`TTFB_TIMEOUT` was deprecated in ethereum/consensus-specs#3767. Remove `ttfb_timeout` from `InboundUpgrade` and other related structs. (Update) Also removed `resp_timeout` and also removed the `NetworkParams` struct since its fields are no longer used. #7925 (comment)
1 parent a9db852 commit 7b5be8b

File tree

6 files changed

+13
-64
lines changed

6 files changed

+13
-64
lines changed

Cargo.lock

Lines changed: 0 additions & 11 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

beacon_node/lighthouse_network/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@ superstruct = { workspace = true }
4545
task_executor = { workspace = true }
4646
tiny-keccak = "2"
4747
tokio = { workspace = true }
48-
tokio-io-timeout = "1"
4948
tokio-util = { workspace = true }
5049
tracing = { workspace = true }
5150
tracing-subscriber = { workspace = true }

beacon_node/lighthouse_network/src/rpc/handler.rs

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,9 @@ const SHUTDOWN_TIMEOUT_SECS: u64 = 15;
3939
/// Maximum number of simultaneous inbound substreams we keep for this peer.
4040
const MAX_INBOUND_SUBSTREAMS: usize = 32;
4141

42+
/// Timeout that will be used for inbound and outbound responses.
43+
const RESP_TIMEOUT: Duration = Duration::from_secs(10);
44+
4245
/// Identifier of inbound and outbound substreams from the handler's perspective.
4346
#[derive(Debug, Clone, Copy, Hash, Eq, PartialEq)]
4447
pub struct SubstreamId(usize);
@@ -140,9 +143,6 @@ where
140143

141144
/// Waker, to be sure the handler gets polled when needed.
142145
waker: Option<std::task::Waker>,
143-
144-
/// Timeout that will be used for inbound and outbound responses.
145-
resp_timeout: Duration,
146146
}
147147

148148
enum HandlerState {
@@ -224,7 +224,6 @@ where
224224
pub fn new(
225225
listen_protocol: SubstreamProtocol<RPCProtocol<E>, ()>,
226226
fork_context: Arc<ForkContext>,
227-
resp_timeout: Duration,
228227
peer_id: PeerId,
229228
connection_id: ConnectionId,
230229
) -> Self {
@@ -246,7 +245,6 @@ where
246245
outbound_io_error_retries: 0,
247246
fork_context,
248247
waker: None,
249-
resp_timeout,
250248
}
251249
}
252250

@@ -542,8 +540,7 @@ where
542540
// If this substream has not ended, we reset the timer.
543541
// Each chunk is allowed RESPONSE_TIMEOUT to be sent.
544542
if let Some(ref delay_key) = info.delay_key {
545-
self.inbound_substreams_delay
546-
.reset(delay_key, self.resp_timeout);
543+
self.inbound_substreams_delay.reset(delay_key, RESP_TIMEOUT);
547544
}
548545

549546
// The stream may be currently idle. Attempt to process more
@@ -712,7 +709,7 @@ where
712709
};
713710
substream_entry.max_remaining_chunks = Some(max_remaining_chunks);
714711
self.outbound_substreams_delay
715-
.reset(delay_key, self.resp_timeout);
712+
.reset(delay_key, RESP_TIMEOUT);
716713
}
717714
}
718715

@@ -960,7 +957,7 @@ where
960957
// Store the stream and tag the output.
961958
let delay_key = self
962959
.inbound_substreams_delay
963-
.insert(self.current_inbound_substream_id, self.resp_timeout);
960+
.insert(self.current_inbound_substream_id, RESP_TIMEOUT);
964961
let awaiting_stream = InboundState::Idle(substream);
965962
self.inbound_substreams.insert(
966963
self.current_inbound_substream_id,
@@ -1036,7 +1033,7 @@ where
10361033
// new outbound request. Store the stream and tag the output.
10371034
let delay_key = self
10381035
.outbound_substreams_delay
1039-
.insert(self.current_outbound_substream_id, self.resp_timeout);
1036+
.insert(self.current_outbound_substream_id, RESP_TIMEOUT);
10401037
let awaiting_stream = OutboundSubstreamState::RequestPendingResponse {
10411038
substream: Box::new(substream),
10421039
request,

beacon_node/lighthouse_network/src/rpc/mod.rs

Lines changed: 2 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ use std::collections::HashMap;
1616
use std::marker::PhantomData;
1717
use std::sync::Arc;
1818
use std::task::{Context, Poll};
19-
use std::time::Duration;
2019
use tracing::{debug, trace};
2120
use types::{EthSpec, ForkContext};
2221

@@ -143,12 +142,6 @@ pub struct RPCMessage<Id, E: EthSpec> {
143142

144143
type BehaviourAction<Id, E> = ToSwarm<RPCMessage<Id, E>, RPCSend<Id, E>>;
145144

146-
pub struct NetworkParams {
147-
pub max_payload_size: usize,
148-
pub ttfb_timeout: Duration,
149-
pub resp_timeout: Duration,
150-
}
151-
152145
/// Implements the libp2p `NetworkBehaviour` trait and therefore manages network-level
153146
/// logic.
154147
pub struct RPC<Id: ReqId, E: EthSpec> {
@@ -162,8 +155,6 @@ pub struct RPC<Id: ReqId, E: EthSpec> {
162155
events: Vec<BehaviourAction<Id, E>>,
163156
fork_context: Arc<ForkContext>,
164157
enable_light_client_server: bool,
165-
/// Networking constant values
166-
network_params: NetworkParams,
167158
/// A sequential counter indicating when data gets modified.
168159
seq_number: u64,
169160
}
@@ -174,7 +165,6 @@ impl<Id: ReqId, E: EthSpec> RPC<Id, E> {
174165
enable_light_client_server: bool,
175166
inbound_rate_limiter_config: Option<InboundRateLimiterConfig>,
176167
outbound_rate_limiter_config: Option<OutboundRateLimiterConfig>,
177-
network_params: NetworkParams,
178168
seq_number: u64,
179169
) -> Self {
180170
let response_limiter = inbound_rate_limiter_config.map(|config| {
@@ -194,7 +184,6 @@ impl<Id: ReqId, E: EthSpec> RPC<Id, E> {
194184
events: Vec::new(),
195185
fork_context,
196186
enable_light_client_server,
197-
network_params,
198187
seq_number,
199188
}
200189
}
@@ -331,18 +320,11 @@ where
331320
max_rpc_size: self.fork_context.spec.max_payload_size as usize,
332321
enable_light_client_server: self.enable_light_client_server,
333322
phantom: PhantomData,
334-
ttfb_timeout: self.network_params.ttfb_timeout,
335323
},
336324
(),
337325
);
338326

339-
let handler = RPCHandler::new(
340-
protocol,
341-
self.fork_context.clone(),
342-
self.network_params.resp_timeout,
343-
peer_id,
344-
connection_id,
345-
);
327+
let handler = RPCHandler::new(protocol, self.fork_context.clone(), peer_id, connection_id);
346328

347329
Ok(handler)
348330
}
@@ -361,18 +343,11 @@ where
361343
max_rpc_size: self.fork_context.spec.max_payload_size as usize,
362344
enable_light_client_server: self.enable_light_client_server,
363345
phantom: PhantomData,
364-
ttfb_timeout: self.network_params.ttfb_timeout,
365346
},
366347
(),
367348
);
368349

369-
let handler = RPCHandler::new(
370-
protocol,
371-
self.fork_context.clone(),
372-
self.network_params.resp_timeout,
373-
peer_id,
374-
connection_id,
375-
);
350+
let handler = RPCHandler::new(protocol, self.fork_context.clone(), peer_id, connection_id);
376351

377352
Ok(handler)
378353
}

beacon_node/lighthouse_network/src/rpc/protocol.rs

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ use std::marker::PhantomData;
1111
use std::sync::{Arc, LazyLock};
1212
use std::time::Duration;
1313
use strum::{AsRefStr, Display, EnumString, IntoStaticStr};
14-
use tokio_io_timeout::TimeoutStream;
1514
use tokio_util::{
1615
codec::Framed,
1716
compat::{Compat, FuturesAsyncReadCompatExt},
@@ -425,7 +424,6 @@ pub struct RPCProtocol<E: EthSpec> {
425424
pub max_rpc_size: usize,
426425
pub enable_light_client_server: bool,
427426
pub phantom: PhantomData<E>,
428-
pub ttfb_timeout: Duration,
429427
}
430428

431429
impl<E: EthSpec> UpgradeInfo for RPCProtocol<E> {
@@ -652,7 +650,7 @@ pub fn rpc_data_column_limits<E: EthSpec>(
652650

653651
pub type InboundOutput<TSocket, E> = (RequestType<E>, InboundFramed<TSocket, E>);
654652
pub type InboundFramed<TSocket, E> =
655-
Framed<std::pin::Pin<Box<TimeoutStream<Compat<TSocket>>>>, SSZSnappyInboundCodec<E>>;
653+
Framed<std::pin::Pin<Box<Compat<TSocket>>>, SSZSnappyInboundCodec<E>>;
656654

657655
impl<TSocket, E> InboundUpgrade<TSocket> for RPCProtocol<E>
658656
where
@@ -676,10 +674,7 @@ where
676674
),
677675
};
678676

679-
let mut timed_socket = TimeoutStream::new(socket);
680-
timed_socket.set_read_timeout(Some(self.ttfb_timeout));
681-
682-
let socket = Framed::new(Box::pin(timed_socket), codec);
677+
let socket = Framed::new(Box::pin(socket), codec);
683678

684679
// MetaData requests should be empty, return the stream
685680
match versioned_protocol {

beacon_node/lighthouse_network/src/service/mod.rs

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ use crate::peer_manager::{
1212
use crate::peer_manager::{MIN_OUTBOUND_ONLY_FACTOR, PEER_EXCESS_FACTOR, PRIORITY_PEER_EXCESS};
1313
use crate::rpc::methods::MetadataRequest;
1414
use crate::rpc::{
15-
GoodbyeReason, HandlerErr, InboundRequestId, NetworkParams, Protocol, RPC, RPCError,
16-
RPCMessage, RPCReceived, RequestType, ResponseTermination, RpcResponse, RpcSuccessResponse,
15+
GoodbyeReason, HandlerErr, InboundRequestId, Protocol, RPC, RPCError, RPCMessage, RPCReceived,
16+
RequestType, ResponseTermination, RpcResponse, RpcSuccessResponse,
1717
};
1818
use crate::types::{
1919
GossipEncoding, GossipKind, GossipTopic, SnappyTransform, Subnet, SubnetDiscovery,
@@ -367,17 +367,11 @@ impl<E: EthSpec> Network<E> {
367367
(gossipsub, update_gossipsub_scores)
368368
};
369369

370-
let network_params = NetworkParams {
371-
max_payload_size: ctx.chain_spec.max_payload_size as usize,
372-
ttfb_timeout: ctx.chain_spec.ttfb_timeout(),
373-
resp_timeout: ctx.chain_spec.resp_timeout(),
374-
};
375370
let eth2_rpc = RPC::new(
376371
ctx.fork_context.clone(),
377372
config.enable_light_client_server,
378373
config.inbound_rate_limiter_config.clone(),
379374
config.outbound_rate_limiter_config.clone(),
380-
network_params,
381375
seq_number,
382376
);
383377

0 commit comments

Comments
 (0)