Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
f06dab8
Gossip only recent statements
AndreiEres Oct 2, 2025
eca57b4
Check if the store already has a statement before processing
AndreiEres Oct 2, 2025
7b8aeb1
Reduce notification size if too large
AndreiEres Oct 2, 2025
3e69999
Update metrics
AndreiEres Oct 2, 2025
9a5decc
Update from github-actions[bot] running command 'prdoc --audience nod…
github-actions[bot] Oct 2, 2025
baeba9f
Update PRDOC
AndreiEres Oct 2, 2025
b0607bc
Update semver
AndreiEres Oct 2, 2025
52fb0aa
Address review comments
AndreiEres Oct 3, 2025
f08c2a8
Fix types
AndreiEres Oct 3, 2025
1e3e83b
Fix up
AndreiEres Oct 3, 2025
8cdb31a
Fix up
AndreiEres Oct 6, 2025
a317299
Fix typo
AndreiEres Oct 7, 2025
50ecef4
Remove unused var
AndreiEres Oct 7, 2025
6b89e1c
Update validation queue size
AndreiEres Oct 7, 2025
a705c00
Add mocked handler for tests
AndreiEres Oct 7, 2025
8703601
Add dirty test
AndreiEres Oct 7, 2025
90c0799
Add more tests
AndreiEres Oct 7, 2025
bd3645e
Fix duplicate processing
AndreiEres Oct 7, 2025
310e05b
Add more tests
AndreiEres Oct 7, 2025
ed55be3
Add metrics for ignored statements
AndreiEres Oct 7, 2025
514ad77
Remove unused tokio
AndreiEres Oct 7, 2025
0adf169
Fix tests
AndreiEres Oct 7, 2025
6daaee0
Fix style
AndreiEres Oct 8, 2025
0012b9e
Fix skipping very large statements
AndreiEres Oct 8, 2025
dad3ecd
Limit the size of the statement for further gossiping
AndreiEres Oct 8, 2025
6407d0e
Update from github-actions[bot] running command 'prdoc --audience nod…
github-actions[bot] Oct 8, 2025
46f7462
Update pr_doc
AndreiEres Oct 8, 2025
c5c15c1
Fix docs
AndreiEres Oct 8, 2025
90ffbe7
Update the logic
AndreiEres Oct 8, 2025
6cf91c4
Update logging and metrics
AndreiEres Oct 8, 2025
6891b17
Increase notification size
AndreiEres Oct 9, 2025
f52598f
Send async notifications
AndreiEres Oct 9, 2025
5945066
Fix tests
AndreiEres Oct 9, 2025
b5b96eb
Add more logs
AndreiEres Oct 14, 2025
971fe1e
Modify metrics setting
AndreiEres Oct 14, 2025
f47af22
Handle very slow or disconnected peers
AndreiEres Oct 14, 2025
dec3b53
Merge branch 'master' into AndreiEres/fix-statement-store-gossiping
AndreiEres Oct 15, 2025
894d00e
Update substrate/client/network/statement/src/lib.rs
AndreiEres Oct 15, 2025
10a1fff
Update
AndreiEres Oct 15, 2025
b8a1c2f
Merge branch 'master' into AndreiEres/fix-statement-store-gossiping
AndreiEres Oct 16, 2025
34ce2d4
Merge branch 'AndreiEres/fix-statement-store-gossiping' into AndreiEr…
AndreiEres Oct 16, 2025
fbaa076
Fix name
AndreiEres Oct 16, 2025
a3d15d2
Fix flaky test
AndreiEres Oct 16, 2025
ac2cc30
Merge branch 'AndreiEres/fix-statement-store-gossiping' into AndreiEr…
AndreiEres Oct 16, 2025
1ce8246
Add early return
AndreiEres Oct 16, 2025
633619f
Update prdoc
AndreiEres Oct 16, 2025
7f7b1d5
Merge remote-tracking branch 'origin/master' into AndreiEres/max-stat…
AndreiEres Oct 17, 2025
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
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions prdoc/pr_9965.prdoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
title: Limit the size of the statement for further gossiping
doc:
- audience: Node Dev
description: "Limits the size of statements that are further gossiped over the network to prevent skipping oversized messages. The limit is set to match the network protocol's `MAX_STATEMENT_NOTIFICATION_SIZE` (1 MB), accounting for 1-byte vector length overhead because statements are sent as `Vec<Statement>`."
crates:
- name: sc-network-statement
bump: minor
- name: sc-statement-store
bump: minor
2 changes: 1 addition & 1 deletion substrate/client/network/statement/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ pub(crate) const PROPAGATE_TIMEOUT: time::Duration = time::Duration::from_millis
pub(crate) const MAX_KNOWN_STATEMENTS: usize = 4 * 1024 * 1024; // * 32 bytes for hash = 128 MB per peer

/// Maximum allowed size for a statement notification.
pub(crate) const MAX_STATEMENT_NOTIFICATION_SIZE: u64 = 1024 * 1024;
pub const MAX_STATEMENT_NOTIFICATION_SIZE: u64 = 1024 * 1024;

/// Maximum number of statement validation request we keep at any moment.
pub(crate) const MAX_PENDING_STATEMENTS: usize = 2 * 1024 * 1024;
1 change: 1 addition & 0 deletions substrate/client/statement-store/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ parking_lot = { workspace = true, default-features = true }
prometheus-endpoint = { workspace = true, default-features = true }
sc-client-api = { workspace = true, default-features = true }
sc-keystore = { workspace = true, default-features = true }
sc-network-statement = { workspace = true, default-features = true }
sp-api = { workspace = true, default-features = true }
sp-blockchain = { workspace = true, default-features = true }
sp-core = { workspace = true, default-features = true }
Expand Down
39 changes: 39 additions & 0 deletions substrate/client/statement-store/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,10 @@ pub const DEFAULT_MAX_TOTAL_STATEMENTS: usize = 4 * 1024 * 1024; // ~4 million
/// The maximum amount of data the statement store can hold, regardless of the number of
/// statements from which the data originates.
pub const DEFAULT_MAX_TOTAL_SIZE: usize = 2 * 1024 * 1024 * 1024; // 2GiB
/// The maximum size of a single statement in bytes.
/// Accounts for the 1-byte vector length prefix when statements are gossiped as `Vec<Statement>`.
pub const MAX_STATEMENT_SIZE: usize =
sc_network_statement::config::MAX_STATEMENT_NOTIFICATION_SIZE as usize - 1;

const MAINTENANCE_PERIOD: std::time::Duration = std::time::Duration::from_secs(30);

Expand Down Expand Up @@ -890,6 +894,18 @@ impl StatementStore for Store {
/// Submit a statement to the store. Validates the statement and returns validation result.
fn submit(&self, statement: Statement, source: StatementSource) -> SubmitResult {
let hash = statement.hash();
let encoded_size = statement.encoded_size();
if encoded_size > MAX_STATEMENT_SIZE {
log::debug!(
target: LOG_TARGET,
"Statement is too big for propogation: {:?} ({}/{} bytes)",
HexDisplay::from(&hash),
statement.encoded_size(),
MAX_STATEMENT_SIZE
);
return SubmitResult::Ignored
}

match self.index.read().query(&hash) {
IndexQuery::Expired =>
if !source.can_be_resubmitted() {
Expand Down Expand Up @@ -1079,6 +1095,7 @@ mod tests {
Some(a) if a == account(2) => (2, 1000),
Some(a) if a == account(3) => (3, 1000),
Some(a) if a == account(4) => (4, 1000),
Some(a) if a == account(42) => (42, 42 * crate::MAX_STATEMENT_SIZE as u32),
_ => (2, 2000),
};
Ok(ValidStatement{ max_count, max_size })
Expand Down Expand Up @@ -1385,6 +1402,28 @@ mod tests {
assert_eq!(expected_statements, statements);
}

#[test]
fn max_statement_size_for_gossiping() {
let (store, _temp) = test_store();
store.index.write().options.max_total_size = 42 * crate::MAX_STATEMENT_SIZE;

assert_eq!(
store.submit(
statement(42, 1, Some(1), crate::MAX_STATEMENT_SIZE - 500),
StatementSource::Local
),
SubmitResult::New(NetworkPriority::High)
);

assert_eq!(
store.submit(
statement(42, 2, Some(1), 2 * crate::MAX_STATEMENT_SIZE),
StatementSource::Local
),
SubmitResult::Ignored
);
}

#[test]
fn expired_statements_are_purged() {
use super::DEFAULT_PURGE_AFTER_SEC;
Expand Down
Loading