@@ -71,12 +71,21 @@ pub enum Protocol {
7171/// When decreasing this value, take into account that the very first request might need to open a
7272/// connection, which can be slow. If this causes problems, we should ensure connectivity via peer
7373/// sets.
74+ #[ allow( dead_code) ]
7475const DEFAULT_REQUEST_TIMEOUT : Duration = Duration :: from_secs ( 3 ) ;
7576
7677/// Request timeout where we can assume the connection is already open (e.g. we have peers in a
7778/// peer set as well).
7879const DEFAULT_REQUEST_TIMEOUT_CONNECTED : Duration = Duration :: from_secs ( 1 ) ;
7980
81+ /// Minimum bandwidth we expect for validators - 500Mbit/s is the recommendation, so approximately
82+ /// 50Meg bytes per second:
83+ const MIN_BANDWIDTH_BYTES : u64 = 50 * 1024 * 1024 ;
84+ /// Timeout for PoV like data, 2 times what it should take, assuming we can fully utilize the
85+ /// bandwidth. This amounts to two seconds right now.
86+ const POV_REQUEST_TIMEOUT_CONNECTED : Duration =
87+ Duration :: from_millis ( 2 * 1000 * ( MAX_COMPRESSED_POV_SIZE as u64 ) / MIN_BANDWIDTH_BYTES ) ;
88+
8089impl Protocol {
8190 /// Get a configuration for a given Request response protocol.
8291 ///
@@ -98,30 +107,31 @@ impl Protocol {
98107 name : p_name,
99108 max_request_size : 10_000 ,
100109 max_response_size : 10_000_000 ,
101- request_timeout : DEFAULT_REQUEST_TIMEOUT ,
110+ // We are connected to all validators:
111+ request_timeout : DEFAULT_REQUEST_TIMEOUT_CONNECTED ,
102112 inbound_queue : Some ( tx) ,
103113 } ,
104114 Protocol :: CollationFetching => RequestResponseConfig {
105115 name : p_name,
106116 max_request_size : 10_000 ,
107117 max_response_size : MAX_COMPRESSED_POV_SIZE as u64 ,
108118 // Taken from initial implementation in collator protocol:
109- request_timeout : DEFAULT_REQUEST_TIMEOUT_CONNECTED ,
119+ request_timeout : POV_REQUEST_TIMEOUT_CONNECTED ,
110120 inbound_queue : Some ( tx) ,
111121 } ,
112122 Protocol :: PoVFetching => RequestResponseConfig {
113123 name : p_name,
114124 max_request_size : 1_000 ,
115125 max_response_size : MAX_COMPRESSED_POV_SIZE as u64 ,
116- request_timeout : DEFAULT_REQUEST_TIMEOUT_CONNECTED ,
126+ request_timeout : POV_REQUEST_TIMEOUT_CONNECTED ,
117127 inbound_queue : Some ( tx) ,
118128 } ,
119129 Protocol :: AvailableDataFetching => RequestResponseConfig {
120130 name : p_name,
121131 max_request_size : 1_000 ,
122132 // Available data size is dominated by the PoV size.
123133 max_response_size : MAX_COMPRESSED_POV_SIZE as u64 ,
124- request_timeout : DEFAULT_REQUEST_TIMEOUT ,
134+ request_timeout : POV_REQUEST_TIMEOUT_CONNECTED ,
125135 inbound_queue : Some ( tx) ,
126136 } ,
127137 } ;
0 commit comments