Skip to content

warp-with-RAPI-pre-simplify

@skunert skunert tagged this 16 May 14:24
Adds the gap-sync dispatch path to `StorageChainBlockImport`, gated in
production behind the existing `should_intercept` filter for `BlockOrigin::GapSync`.
Reachable only via the test-helpers `intercept_gap_sync_for_test` override while
the sync layer's body-fetch-inside-pruning-window work is still pending.

When enabled, the wrapper for a gap-synced block:
1. Queries `TransactionStorageApi::indexed_transactions(block_number)` at the
   local `finalized_hash` (always >= the gap block by construction; that state
   has `Transactions::<T>::get(block_number)` populated by the block's own
   `on_finalize`, within retention).
2. Tail-hashes each entry against the body to split it into synthetic
   `IndexOperation::Insert` ops (store data already in body) and synthetic
   `IndexOperation::Renew` ops (data missing, must be fetched).
3. Bitswap-fetches the missing renew payloads.
4. Attaches both halves to `BlockImportParams::prefetched_indexed_transactions`
   via the widened `PrefetchedIndexedTransactions { ops, renew_payloads }`
   carrier introduced in the parent substrate PR.
5. Forwards to the inner import with `state_action = Skip` unchanged.

The backend then routes via the synthetic-ops fallback (runtime `index_ops`
empty for gap-synced blocks) and writes both store tails and renew payloads
into the TRANSACTION column exactly as if the runtime had executed.

Refactors `body_classify_renews` into `body_classify_to_ops` returning both
halves of the classification (synthetic ops + renew-fetch set);
`body_classify_renews` becomes a `#[cfg(test)]` delegate-regression target.

Tests:
- 9 new unit tests for `body_classify_to_ops` (W12): pure stores / pure renews
  / mixed / per-hashing / oversized / `u32::MAX` skip / non-RAW skip /
  out-of-range skip / delegate regression.
- 9 new integration tests for the gap-sync dispatch (W13, behind
  `test-helpers`): pure renews / pure stores no fetch / mixed split /
  state_action stays Skip / below-retention pass-through / finalized-hash
  state-context assertion / already-present filter / fetcher partial failure
  propagation / production-gate regression guard
  (`import_gap_sync_disabled_by_default_passes_through`).

Test infrastructure:
- `cumulus-client-storage-chain-sync` gains a `test-helpers` feature that
  exposes `StorageChainBlockImport::intercept_gap_sync_for_test`.
- Mock client extensions: `set_finalized_hash`, `last_indexed_transactions_state`,
  `MockNetworkRequest::call_count` (all feature-gated).
- Default-features build remains clean; W13 tests skip when `test-helpers`
  is not enabled.

Also updates the existing `attach_prefetched` and tip-block test assertions
to use the widened struct (`renew_payloads` field) instead of the bare
`Vec<(_,_)>` shape. No production behaviour change on the tip-block path.
Assets 2
Loading