Skip to content

Measure pallet timeouts in relay chain blocks, not parachain blocks #233

Description

@bkontur

Problem

All timeouts, expiries, periods and intervals in the storage provider pallet (and drive-registry pallet) are measured in parachain blocks. They read `frame_system::Pallet::::block_number()` directly (17 sites in `pallet/src/`, 1 in `pallet-registry/src/lib.rs`), and the runtime constants derive from a 6s parachain block.

This is wrong: parachain block time is changing (6s -> 2s/3-cores, targeting AssetHub) and will change again. Anything denominated in parachain blocks silently rescales with it -- e.g. `48 * HOURS` becomes 16h of wall-clock once blocks are 2s.

Decision (per Robert): always use relay chain blocks for these durations, to stay independent of parachain block time.

Scope

Currently the bug is latent (6s == 6s) and bites the moment the parachain switches to 2s.

Affected config: `ChallengeTimeout`, `SettlementTimeout`, `RequestTimeout`, `DefaultCheckpointInterval`, `DefaultCheckpointGrace`, `DeregisterAnnouncementPeriod`, agreement durations/extensions, drive expiry.

Plan

  1. Add `type BlockNumberProvider: BlockNumberProvider<BlockNumber = BlockNumberFor>` to both pallet `Config`s.
  2. Replace all `frame_system::Pallet::::block_number()` reads with `T::BlockNumberProvider::current_block_number()`.
  3. Runtimes: `type BlockNumberProvider = cumulus_pallet_parachain_system::RelaychainDataProvider`.
  4. Mocks/tests: `type BlockNumberProvider = System`.
  5. Recompute the time constants from a 6s relay block, independent of parachain block time.

Notes / open questions

  • User-supplied durations (agreement `duration`, extensions) change meaning to relay blocks. Client/SDK/UI and payment-per-block math must interpret them consistently -- likely a follow-up.
  • `RelaychainDataProvider` returns the relay parent number from validation data (monotonic, but delta between consecutive parachain blocks can be >1). Verify checkpoint window math (`calculate_window`) doesn't assume +1 per parachain block.

TODO

  • check/align the design

Related: #113

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Fields

No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions