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.
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 ofInherentProvider
.We can define the interface in the package
lib/babe
, also we can make it generic over the type of inherent it will return.BlockBuilder
atlib/babe/build.go
to have a set ofInherentProviders
and iterate over them passing a fresh*types.InherentData
and them encode it.timestamp
andslot
to conform withInherentProvider interface
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 }