ChainSafe / gossamer

🕸️ Go Implementation of the Polkadot Host
https://chainsafe.github.io/gossamer
GNU Lesser General Public License v3.0
433 stars 117 forks source link

Investigate on Async Backing #4231

Open axaysagathiya opened 1 month ago

axaysagathiya commented 1 month ago

Issue summary

Other information and links

Acceptance criteria's (Outcomes)

@axaysagathiya please check how we put the AC in Elastic Scaling issue and add them here @kishansagathiya

axaysagathiya commented 1 month ago

Notes from async backing video by polkadot blockchain academy

in legacy backing, (Collation generation + backing) and (availability and inclusion), they require one to finish before the other can start. They can't run in parallel.

a parachain produce a block whenever relaychain block has included a previous candidate from that parachain.

after a parachain candidate block gets enough supporting votes, relay chain block author selects one candidate of each parachain to be included in a relay chain. and they get included directly to the relay chain. but...

In Async backing, instead of back the candidate on chain, we cache these candidates in a storage structure in the relay chain client. and later these cached candidates are then used for the availability and inclusion steps.

The Async backing optimistic collator assumptions

  1. The best existing parablock the collator aware of will eventually be included in the relay chain
  2. There won't be a chain reversion impacting that best parablock.

The worst case here the parablock we assumed will be included, doesn't get included. may be we have remake a few blocks. But this assumptions gives us mmuch more than what they could take away.

Async backing advantages

Screenshot from 2024-10-07 14-33-34

Synchrounous backing diagram

Screenshot from 2024-10-07 14-42-14

Asynchrounous backing diagram

Screenshot from 2024-10-07 15-28-18

Unincluded Segment: it stores the parachain block which are not yet included into the relaychain block. unincluded segments live in the runtimes of parachain collators.

The core functionality that asynchronous backing brings is the ability to build on these unincluded segments of block ancestors rather than building only on ancestors included in the relay chain state.

axaysagathiya commented 1 month ago

Notes from Async backing Wiki

In Synchronous backing,

parablock generation is tightly coupled to the relay chain's progression:

In Async Backing.

Two parameters of asynchronous backing can be controlled by Governance:

parachain block Gets 2 second execution time, which was 0.5 seconds in synchronous backing.

The 2-second execution time is thus a limiter, not a system limitation. If parablock generation takes >2 seconds, the unincluded segment will shrink (less unincluded parablocks), while if it takes < 2 seconds, the segment will grow (more unincluded parablocks that will need to be backed and included). Such flexibility from the parachain side will be possible when, on the relay chain side, there will be elastic scaling (i.e., agile core usage and coretime allocation).

What is prospective Parachain in async backing?

Keep track of parablocks that have been submitted to backers but have yet to be included.

A parablock stops being a prospective parablock when it is included on chain. At that point prospective parachains does not have to care about it anymore. Alternatively, a parablock's relay parent can get too old before that parablock is included, in which case prospective parachains can throw away the candidate.

axaysagathiya commented 1 month ago

Prospective parachain

we can now build prospective parachains – that is, trees of potential (but likely) future parachain blocks. This is the subsystem responsible for doing so.

other subsystems such as Backing rely on Prospective Parachains, e.g. for determining if a candidate can be seconded.

Prospective Parachains is primarily an implementation of fragment trees.

Messages we send from backing to prospective parachain subsystem

ProspectiveParachainsMessage::IntroduceCandidate

ProspectiveParachainsMessage::CandidateSeconded

ProspectiveParachainsMessage::CandidateBacked

ProspectiveParachainsMessage::GetHypotheticalFrontier

ProspectiveParachainsMessage::GetTreeMembership

ProspectiveParachainsMessage::GetMinimumRelayParents

axaysagathiya commented 1 month ago

Subsystems affected by Async backing support

Implemented v1 in Gossamer and need to update

Not implemented in Gossamer: