Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

create inherent provider interface #4242

Open
EclesioMeloJunior opened this issue Oct 11, 2024 · 0 comments
Open

create inherent provider interface #4242

EclesioMeloJunior opened this issue Oct 11, 2024 · 0 comments
Labels
C-complex Complex changes across multiple modules. Possibly will require additional research. S-babe issues related to block production functionality.

Comments

@EclesioMeloJunior
Copy link
Member

EclesioMeloJunior commented Oct 11, 2024

Description

Here is the part that connects BABE with Provisioner subsystem. Currently, Gossamer does not have a specific struct for inherents, we only define inherents at the moment of block building.

To have a better separation of responsibility we can define an interface InherentProvider and the block builder can have a set of InherentProvider.

We can define the interface in the packagelib/babe, also we can make it generic over the type of inherent it will return.

type InherentProvider interface {
    // Provide will add the data to `out`
    Provide(out *types.InherentData) T
}

type TimestampInherentProvider struct {}
// slot inherent provider might need timestamp as depedency provider
type SlotInherentProvider struct {}
// needs the overseer and state as depedencies
type ParachainsInherentProvider struct {}
  • Change the BlockBuilder at lib/babe/build.go to have a set of InherentProviders and iterate over them passing a fresh *types.InherentData and them encode it.
  • Changes might be needed to make timestamp and slot to conform with InherentProvider interface
  • Given that we now when a slot ends (slot start + duration) set up a timeout timer to avoid going beyond the block producer time slot.
endAt := slot.start + slot.duration
remainingTime := time.NewTimer(end_at - time.Now())

go create_inherent_data()

select {
case id := <- inherentDataCh:
   // happy path, we got the inherents in time
case remainingTime.C:
   // timeout! inherents not provided in time
}

Reference

https://github.com/paritytech/polkadot-sdk/blob/c0b734336a68b6f48ac70a9b9507d8ddb9fed57e/polkadot/node/service/src/lib.rs#L1245
https://github.com/paritytech/polkadot-sdk/blob/c0b734336a68b6f48ac70a9b9507d8ddb9fed57e/substrate/client/consensus/slots/src/lib.rs#L250

@EclesioMeloJunior EclesioMeloJunior added C-complex Complex changes across multiple modules. Possibly will require additional research. S-babe issues related to block production functionality. labels Oct 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-complex Complex changes across multiple modules. Possibly will require additional research. S-babe issues related to block production functionality.
Projects
None yet
Development

No branches or pull requests

1 participant