kaspanet / rusty-kaspa

Kaspa full-node and related libraries in the Rust programming language. This is a stable version at the initial rollout phases.
ISC License
376 stars 119 forks source link

Optimize P2P block processing latency -- Broadcast blocks after Body Processor #295

Closed coderofstuff closed 8 months ago

coderofstuff commented 8 months ago

Changes:

  1. Refactor validate_and_insert_block to return two futures - Added in b134d61

    • one future resolves when body processor is complete
    • the other future resolves when virtual state processor is complete

    The second future is used by all original callers, making the current implementation behave the same as before.

  2. Change BodyProcessorMessage to VirtualStateProcessorMessage when passing the block from body-processor to virtual-processor - Added in af066c5

  3. Add conditions/checks to see if we can broadcast

  4. Actually broadcast the block after Body Processor

michaelsutton commented 8 months ago

The main aim of this PR is to minimize peer to peer latency of block processing by sharing a block with peers ASAP. Tests and benchmarks have shown that this is especially important with higher BPS network configurations.