Skip to content

forward epoch sync: make prepare RPC timeout longer by default and configurable #820

Description

@nekomoto911

Context

PR #819 adds batched forward epoch sync. In try_prepare_forward_epoch_sync, the prepare probe uses a hardcoded timeout:

Duration::from_millis(1_000), // with 2 retries

See aptos-core/consensus/src/block_storage/sync_manager/forward_epoch_sync.rs.

By contrast, fetch uses RPC_TIMEOUT_MSEC (5s from block_retrieval).

Problem

Cold build_forward_epoch_sync_index does O(epoch) work:

  • get_all(EpochByBlockNumber)
  • get_qc_range
  • parent walk
  • full LedgerInfoSchema scan

RCA for an epoch-50 zero-hash stuck case measured ~1.3s for a similar QC scan alone. A 1s prepare probe therefore often times out → Ok(None)legacy reverse sync (HashValue::zero()), re-entering the all-or-nothing zero-hash path that forward epoch sync is meant to avoid — especially on large epochs or loaded serving peers.

The short timeout was intentional for rolling-upgrade capability probing (old peers that cannot decode the new enum variant), but it also treats slow-but-capable peers as unavailable and silently falls back.

Recommendation

  1. Raise the default prepare timeout substantially (e.g. align with or exceed fetch / RPC_TIMEOUT_MSEC, or use a dedicated larger budget suitable for cold index build). Concrete suggestion: at least 5s, preferably 10s+, pending measurement on cold vs warm index paths.
  2. Expose it as a node-configurable parameter (e.g. under consensus / local config alongside existing sync knobs such as max_blocks_to_request), not a magic literal in the prepare call site.
  3. Optionally:
    • name the constant clearly if a code default remains
    • add metrics for prepare timeout vs success vs legacy fallback

Related

Non-goals

This issue is scoped to timeout default + configurability. Full redesign of prepare/index build is out of scope. Busy/semaphore behavior and index warm-path improvements are related but should stay separate unless briefly noted.

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