3

I noticed that the OnTimestampSet differs in the parachains and solo chains. This config must be set in the solo chain as Aura or Babe. But in parachain, () is okay.

In Cumulus:

impl pallet_timestamp::Config for Runtime {
    /// A timestamp: milliseconds since the unix epoch.
    type Moment = u64;
    type OnTimestampSet = ();   // here
    type MinimumPeriod = MinimumPeriod;
    type WeightInfo = ();
}

In substrate-node-template:

impl pallet_timestamp::Config for Runtime {
    /// A timestamp: milliseconds since the unix epoch.
    type Moment = u64;
    type OnTimestampSet = Aura;  // here
    type MinimumPeriod = ConstU64<{ SLOT_DURATION / 2 }>;
    type WeightInfo = ();
}

From the docs in the pallet-timestamp:

/// Set the current time.
///
/// This call should be invoked exactly once per block. It will panic at the finalization
/// phase, if this call hasn't been invoked by that time.
///
/// The timestamp should be greater than the previous one by the amount specified by
/// `MinimumPeriod`.
///
pub fn set(origin: OriginFor<T>, #[pallet::compact] now: T::Moment) -> DispatchResult {...}

What make this difference?

2 Answers 2

3

What make this difference?

This was actually wrong, thank you for bringing this up. On Parachains the OnTimestampSet should be set to Aura as you pointed out.

0

It may be related to "How parachains produce block", you could get more info from polkadot wiki and the path of a parachain block.

Aura primarily provides block authoring in solo chains, but in parachains, block producer is collator.

2
  • Is that meant he collators do not need to set a timestamp when sealing a block? Sounds interesting. Nov 14, 2022 at 9:41
  • Substrate does not have the concept of "a block timestamp". You could get the timestamp of a block via timestamp.now() with block hash. Refer to here
    – Guantong
    Nov 15, 2022 at 3:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.