Skip to content

dash-spv: endgame hedging downloads a third of all blocks twice #1338

Closed

Description

@xdustinface

All paths are under dash-spv/src/ at 64be3a10b (dev).

Endgame hedging sends about a third of all block requests twice. The flow controller calls Broker::hedge (network/broker.rs:329-380) whenever the broker queue is empty (network/manager.rs, if broker.len() == 0). hedge re-sends to a second peer every block request that has been on the wire for HEDGE_AFTER (2 s). During filter-driven block download, block requests arrive in small bursts, so the queue is empty most of the time. Meanwhile peers usually hold megabytes in flight, so a block often takes more than 2 s even on a healthy peer. "Endgame" mode is therefore on for most of the sync, not only at its end.

Evidence. A fresh testnet sync on dev plus #1332 to #1334:

  • 87 endgame: hedged N block request(s) events hedged 1,045 blocks in total.
  • 1,037 of 3,204 received blocks arrived as Received unrequested block, the second copy of a block already received. That matches the hedge count almost exactly.
  • An earlier testnet run showed the same pattern: 224 of 945 blocks were duplicates.

The duplicate copies cost download bandwidth that filter and header sync need, on links where peers are already queueing.

Fix options.

  1. Hedge only the lowest pending block heights. Blocks are processed in height order, so only the lowest outstanding block holds up progress. A block that is not yet next in line gains nothing from a duplicate.
  2. Scale HEDGE_AFTER with the serving peer's queue, for example its in-flight bytes ahead of the request divided by its serving rate, instead of a fixed 2 s.
  3. Only hedge in a real endgame: no pending filter batches and only a handful of blocks left.

Option 1 is the smallest change and keeps the hedge useful for the block that is actually blocking progress.

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions