Skip to content

Conversation

@alexggh
Copy link
Contributor

@alexggh alexggh commented Jan 30, 2026

Problems

High-Level Changes

  • Introduce on_statements workers that handle decoding, hashing, and deduplication off the main loop. A configurable number of workers (num_submission_workers) process incoming statement notifications in parallel.
  • Keep statement validation workers, the already existed and they handle statement store submission/validation, allowing cryptographic verification to happen concurrently.
  • Non-blocking peer sends: Replace sequential awaits on send_async_notification with a FuturesUnordered collection (pending_sends) that queues send futures and polls them from the main loop.

statement_network_architecture

New Flows

Statement Reception:

   Network notification → main loop queues OnStatementsRequest
         → on_statements worker decodes & deduplicates
         → worker sends aggregated ReputationChange back to main loop
         → queues (hash, statement) for validation
         → submission worker validates via statement_store.submit()
         → sends WorkerEvent::StatementResult back to main loop
         → main loop updates peer reputation

Statement Propagation:

    propagate_timeout fires → main loop gets recent statements
         → encodes chunks per peer → creates send futures with timeout
         → pushes to pending_sends (FuturesUnordered)
         → main loop polls pending_sends with highest priority
         → handle_send_result processes completions

Shared State:

The minimal downside is that there is a shared state for this workers, but benchmarks shows updating the shared state is fast and does not contain the bulk of the time

  • PeersState: peer known_statements (RwLock)
  • PendingState: pending statement→peers map for deduplication (RwLock)

TODO

  • Evaluate performance on real world scenarios in versi
  • More testing that the minimal one provided.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants