2

Substrate's Aura implementation has an InherentDataProvider that includes the Aura slot number into the runtime. However, it seems that this code is not consistently used throughout the ecosystem.

For example, In the Substrate Node Template, it is included. But in the Parachain Template, it is Not included.

I think I once read Andre Silva writing deep in a PR discussion that this inherent was no longer necessary or would become unnecessary at some point. But I can't seem to find that now.

So my question is, When is it necessary or advisable in include the aura slot inherent?

1 Answer 1

2

When using Aura as a standalone chain the slot worker is used to drive block production. The slot worker requires that the InherentDataProvider includes the slot number (https://github.com/paritytech/polkadot-sdk/tree/8297d08cca75eab01356af8142672e608cc52e1e/substrate/client/consensus/slots/src/lib.rs https://github.com/paritytech/polkadot-sdk/blob/8297d08cca75eab01356af8142672e608cc52e1e/substrate/client/consensus/slots/src/lib.rs#L470-L474). When using Aura as a parachain the block production is driven by the relay chain, and hence the slot worker is not used, and by extension the InherentDataProvider doesn't need to include the block number. This is validated by the compiler, i.e. if you try to use Aura in a standalone chain without providing a slot in the InherentDataProvider you'll get a compile error.

The runtime doesn't need this inherent at all, the slot number is extracted from the predigest instead.

2
  • Makes sense thank you. DQ: Why doesn't the slot worker also extract the slot from the pre-digest? And remove the inherent entirely? Commented Nov 21, 2023 at 17:02
  • 1
    The slot worker needs to create the digest, since it's responsible for creating the block, and hence it needs to calculate the current slot. It could do this without relying on InherentDataProvider though (i.e. just calculate the slot itself), but this way it can guarantee that whatever slot number it computes, it will be consistent with the timestamp in the timestamp inherent (e.g. there could be timing issues/delays that make things go out-of-sync).
    – André
    Commented Nov 21, 2023 at 17:07

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.