Skip to content
This repository was archived by the owner on Nov 15, 2023. It is now read-only.
This repository was archived by the owner on Nov 15, 2023. It is now read-only.

Prepare block authoring for asynchronous backing #2267

@bkchr

Description

@bkchr

Block authoring for Parachains currently works in the following way:

  1. A new relay chain block is imported.
  2. The collation generation subsystem checks if the core associated to the parachain is free and if yes, continues.
  3. Collation generation calls our collator callback to generate a PoV.
  4. Authoring logic determines if the current node should build a PoV.
  5. Build new PoV and give it back to collation generation.

With asynchronous backing this will be more complicated as block production isn't bound to importing a relay chain block anymore. Parachains will build new blocks in fixed time frames at standalone chains are doing this, e.g. every 6 seconds. To support this we will need separate the logic that determines when to build a block from the logic that determines on which relay chain block to build.

For determining on when to build a new block we can reuse the slots logic from Substrate. We will let it run with the requested slot duration of the Parachain. Then we will implement a custom SlotWorker. Every this slot worker is triggered we will need to trigger some logic to determine the next relay chain block to build on top of. This logic should be generic and should support the asynchronous/synchronous backing. It will return the relay chain block in which context the block should be build on and the parachain block to build on top of.

For synchronous backing we will check the best relay chain block to check if the core of our parachain is free. Relative simple and easy. The advantage of this logic is that we will not have Parachain forks anymore as we are building only on one relay chain block and also very likely on the block that the network is seeing as its best block (assuming all blocks of the same height already propagated through the network). However, as currently we start with the block production directly after importing the relay chain block, we will may start block production later which could make it more complicated to include big PoVs into the relay chain as there is less time to send them to the validators. The parachain slot should be calculated based on the timestamp and this should be calculated using relay_chain_slot * slot_duration.

For asynchronous backing we will be more free to choose the block to build on as we can also build on older relay chain blocks as well. We will probably need some kind of runtime api for the Parachain to check if we want to build on a given relay chain block. So, for example to reject building too many parachain blocks on the same relay chain block. The parachain slot should be calculated based on the timestamp and this should be calculating using relay_chain_slot * slot_duration + parachain_slot_duration * unincluded_segment_len.

Metadata

Metadata

Assignees

No one assigned

    Labels

    I7-refactorCode needs refactoring.

    Type

    No type
    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