Skip to content

Conversation

@bkchr
Copy link
Member

@bkchr bkchr commented Jan 2, 2026

No description provided.

@bkchr bkchr added the T0-node This PR/Issue is related to the topic “node”. label Jan 2, 2026
@bkchr bkchr force-pushed the bkchr-statement-store-all branch from 1c63bc1 to 7e0277c Compare January 2, 2026 13:43
@alexggh alexggh requested review from AndreiEres and alexggh January 2, 2026 13:44

if !self.sync.is_major_syncing() {
if let Ok(statements) = self.statement_store.statements() {
self.send_statements_to_peer(&peer, &statements).await;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will keep this loop busy until all statements are sent, which potentially are many.

I wonder if we don't want to move this out on separate task/thread, but that could easily be a follow up.

debug_assert!(_was_in.is_none());

if !self.sync.is_major_syncing() {
if let Ok(statements) = self.statement_store.statements() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would also add a test for it.

@P1sar
Copy link

P1sar commented Jan 7, 2026

Related to #10046

@bkchr
Copy link
Member Author

bkchr commented Jan 8, 2026

/cmd prdoc --audience node_dev --bump major

@paritytech-workflow-stopper
Copy link

All GitHub workflows were cancelled due to failure one of the required jobs.
Failed workflow url: https://github.com/paritytech/polkadot-sdk/actions/runs/20830127938
Failed job name: build-rustdoc

Copy link
Contributor

@alexggh alexggh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Had a second look over the newly added changes, looks good to me!

Thank you!

@bkchr bkchr added this pull request to the merge queue Jan 9, 2026
Merged via the queue into master with commit 9426936 Jan 9, 2026
235 of 239 checks passed
@bkchr bkchr deleted the bkchr-statement-store-all branch January 9, 2026 14:02
Copy link
Contributor

@AndreiEres AndreiEres left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thank you! Left a few nits.

- audience: Node Dev
description: |
When a new node connects, we now propagate all statements in our store to them. This happens in bursts of ~1MiB messages
over time to not completley use up all resources. If multiple peers are connecting, round robin between them.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
over time to not completley use up all resources. If multiple peers are connecting, round robin between them.
over time to not completely use up all resources. If multiple peers are connecting, round robin between them.

result.push((*hash, statement));
},
FilterDecision::Abort => {
// We did not process it :)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: we can increase it after match filter

}

fn statement_hashes(&self) -> Result<Vec<Hash>> {
Ok(self.index.read().entries.keys().cloned().collect())
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need Result here?

let (statements, processed) = match self.statement_store.statements_by_hashes(
&entry.get().hashes,
&mut |_hash, encoded, _stmt| {
if accumulated_size > 0 &&
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we process Skip for oversized statements here as well?

for hash in hashes {
processed += 1;
let Some(encoded) =
self.db.get(col::STATEMENTS, hash).map_err(|e| Error::Db(e.to_string()))?
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We abandon already processed statements here, maybe we could send them?

Ok(r) => r,
Err(e) => {
log::debug!(target: LOG_TARGET, "Failed to fetch statements for initial sync: {e:?}");
entry.remove();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is no retry mechanism, so the peer has no more chance to receive smth? Maybe we can at least error! it?

const LOG_TARGET: &str = "statement-gossip";
/// Maximim time we wait for sending a notification to a peer.
const SEND_TIMEOUT: std::time::Duration = std::time::Duration::from_secs(10);
/// Interval for sending statement batches during initial sync to new peers.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: initial sync every time misleads me to startup time of the current peer

}

/// Result of finding a sendable chunk of statements.
enum ChunkResult {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: FindChunkResult?

self.pending_initial_syncs.remove(&peer_id);
return;
},
SendChunkResult::Sent(_) => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: debug_assert!(to_sent.len(), sent)?

github-merge-queue bot pushed a commit that referenced this pull request Jan 13, 2026
# Description

This follow-up PR addresses review comments from PR #10718:
- Removed unnecessary Result wrapper from statement_hashes() - method is
infallible
- Added debug assertion to validate sent count matches prepared count

## Integration

Should not affect downstream projects.
acatangiu pushed a commit to acatangiu/polkadot-sdk that referenced this pull request Jan 14, 2026
…aritytech#10718)

Co-authored-by: cmd[bot] <41898282+github-actions[bot]@users.noreply.github.com>
acatangiu pushed a commit to acatangiu/polkadot-sdk that referenced this pull request Jan 14, 2026
…ew (paritytech#10770)

# Description

This follow-up PR addresses review comments from PR paritytech#10718:
- Removed unnecessary Result wrapper from statement_hashes() - method is
infallible
- Added debug assertion to validate sent count matches prepared count

## Integration

Should not affect downstream projects.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

T0-node This PR/Issue is related to the topic “node”.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants