Skip to content

Commit b21cbb5

Browse files
AndreiEresgithub-actions[bot]bkchr
authored
Improve statement-store gossiping performance (paritytech#9912)
# Description Fixes gossiping and scalability issues in the statement-store networking. 1. Reduced gossiping traffic by propagating only recent statements instead of all. 2. Added an early check for statements that the node already has to skip duplicate processing. 3. Added splitting of large statement batches to stay under MAX_STATEMENT_NOTIFICATION_SIZE; oversized individual statements are skipped. 4. MAX_STATEMENT_NOTIFICATION_SIZE was updated to the commonly used 1MB, which drastically improved the gossiping speed. 5. Notifications are sent asynchronously. I don't see much difference in performance, but according to @lexnv, it's better to do: paritytech#9296. 6. Added a 10s timeout to handle very slow or disconnected peers. ## Integration Internal optimizations to the gossip protocol. No downstream changes required. Related PR: paritytech#9965 ## Things to handle in further PRs - After this PR, nodes don't send all statements to new peers anymore, only the recent ones. - After restarting, the node doesn't re-gossip statements it wasn't gossiped. - Broadcasting notifications to all peers when the first peer is slow is limited. We could instead use a FuturesUnordered. --------- Co-authored-by: cmd[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: Bastian Köcher <[email protected]>
1 parent ced629a commit b21cbb5

File tree

7 files changed

+765
-32
lines changed

7 files changed

+765
-32
lines changed

Cargo.lock

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

prdoc/pr_9912.prdoc

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
title: '[WIP] Fix statement-store gossiping'
2+
doc:
3+
- audience: Node Dev
4+
description: |-
5+
Fixes gossiping and scalability issues in the statement-store networking:
6+
reduces traffic by propagating only recent statements, skips duplicate processing,
7+
and splits large batches to stay under MAX_STATEMENT_NOTIFICATION_SIZE.
8+
crates:
9+
- name: sc-network-statement
10+
bump: minor
11+
- name: sc-statement-store
12+
bump: minor
13+
- name: sp-statement-store
14+
bump: minor

substrate/client/network/statement/Cargo.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,3 +29,7 @@ sc-network-types = { workspace = true, default-features = true }
2929
sp-consensus = { workspace = true, default-features = true }
3030
sp-runtime = { workspace = true, default-features = true }
3131
sp-statement-store = { workspace = true, default-features = true }
32+
tokio = { workspace = true }
33+
34+
[dev-dependencies]
35+
async-trait = { workspace = true }

substrate/client/network/statement/src/config.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,10 @@ use std::time;
2424
pub(crate) const PROPAGATE_TIMEOUT: time::Duration = time::Duration::from_millis(1000);
2525

2626
/// Maximum number of known statement hashes to keep for a peer.
27-
pub(crate) const MAX_KNOWN_STATEMENTS: usize = 4 * 1024 * 1024;
27+
pub(crate) const MAX_KNOWN_STATEMENTS: usize = 4 * 1024 * 1024; // * 32 bytes for hash = 128 MB per peer
2828

2929
/// Maximum allowed size for a statement notification.
30-
pub(crate) const MAX_STATEMENT_SIZE: u64 = 256 * 1024;
30+
pub(crate) const MAX_STATEMENT_NOTIFICATION_SIZE: u64 = 1024 * 1024;
3131

3232
/// Maximum number of statement validation request we keep at any moment.
3333
pub(crate) const MAX_PENDING_STATEMENTS: usize = 2 * 1024 * 1024;

0 commit comments

Comments
 (0)