Skip to content
Snippets Groups Projects
Commit e0b3c5cb authored by Robert Klotzner's avatar Robert Klotzner Committed by GitHub
Browse files

Better size limits. (#3572)


* Better size limits.

* Remove reference to private repo.

* Update node/network/protocol/src/request_response/mod.rs

Fix statement response size.

Co-authored-by: default avatarAndronik Ordian <write@reusable.software>

Co-authored-by: default avatarAndronik Ordian <write@reusable.software>
parent 6e5a572c
No related merge requests found
......@@ -102,6 +102,19 @@ const STATEMENTS_TIMEOUT: Duration = Duration::from_secs(1);
/// to have 3 slow nodes connected, to delay transfer for others by `STATEMENTS_TIMEOUT`.
pub const MAX_PARALLEL_STATEMENT_REQUESTS: u32 = 3;
/// Response size limit for responses of POV like data.
///
/// This is larger than `MAX_POV_SIZE` to account for protocol overhead and for additional data in
/// `CollationFetching` or `AvailableDataFetching` for example. We try to err on larger limits here
/// as a too large limit only allows an attacker to waste our bandwidth some more, a too low limit
/// might have more severe effects.
const POV_RESPONSE_SIZE: u64 = MAX_POV_SIZE as u64 + 10_000;
/// Maximum response sizes for `StatementFetching`.
///
/// This is `MAX_CODE_SIZE` plus some additional space for protocol overhead.
const STATEMENT_RESPONSE_SIZE: u64 = MAX_CODE_SIZE as u64 + 10_000;
impl Protocol {
/// Get a configuration for a given Request response protocol.
///
......@@ -114,7 +127,7 @@ impl Protocol {
Protocol::ChunkFetching => RequestResponseConfig {
name: p_name,
max_request_size: 1_000,
max_response_size: MAX_POV_SIZE as u64 / 10,
max_response_size: POV_RESPONSE_SIZE as u64 / 10,
// We are connected to all validators:
request_timeout: DEFAULT_REQUEST_TIMEOUT_CONNECTED,
inbound_queue: Some(tx),
......@@ -122,7 +135,7 @@ impl Protocol {
Protocol::CollationFetching => RequestResponseConfig {
name: p_name,
max_request_size: 1_000,
max_response_size: MAX_POV_SIZE as u64 + 1000,
max_response_size: POV_RESPONSE_SIZE,
// Taken from initial implementation in collator protocol:
request_timeout: POV_REQUEST_TIMEOUT_CONNECTED,
inbound_queue: Some(tx),
......@@ -130,7 +143,7 @@ impl Protocol {
Protocol::PoVFetching => RequestResponseConfig {
name: p_name,
max_request_size: 1_000,
max_response_size: MAX_POV_SIZE as u64,
max_response_size: POV_RESPONSE_SIZE,
request_timeout: POV_REQUEST_TIMEOUT_CONNECTED,
inbound_queue: Some(tx),
},
......@@ -138,7 +151,7 @@ impl Protocol {
name: p_name,
max_request_size: 1_000,
// Available data size is dominated by the PoV size.
max_response_size: MAX_POV_SIZE as u64 + 1000,
max_response_size: POV_RESPONSE_SIZE,
request_timeout: POV_REQUEST_TIMEOUT_CONNECTED,
inbound_queue: Some(tx),
},
......@@ -146,8 +159,7 @@ impl Protocol {
name: p_name,
max_request_size: 1_000,
// Available data size is dominated code size.
// + 1000 to account for protocol overhead (should be way less).
max_response_size: MAX_CODE_SIZE as u64 + 1000,
max_response_size: STATEMENT_RESPONSE_SIZE,
// We need statement fetching to be fast and will try our best at the responding
// side to answer requests within that timeout, assuming a bandwidth of 500Mbit/s
// - which is the recommended minimum bandwidth for nodes on Kusama as of April
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment