Implement parachain inherents
Changes
- Implements
parachn0inherent
Tests
go test -tags integration github.com/ChainSafe/gossamer
Issues
Fixes #2426
Primary Reviewer
@timwu20
blocked on https://github.com/ChainSafe/gossamer/issues/2634
@timwu20
https://github.com/ChainSafe/gossamer/pull/2851 against this branch after doing a little more investigation. I noticed that the encoding differed when using InherentsData.SetInt64Inherent vs the same InherentData struct from substrate. I ended up revising the receiver functions to a more generic SetInherent function which accepts interface{} and fixes the encoding. I added some tests to ensure the encodings are the same. Maybe we can constrain the values using generics and the new interface constraints for types that we know that the scale package will support.
I already have a a PR for that (https://github.com/ChainSafe/gossamer/pull/2815/).
@timwu20 When you try to scale encode a struct, its private (not exported) field can be read by our scale package. I observed this with InherentsData struct which has data unexported. With that in mind, does it make sense to keep things exported in parachain inherents struct?
@qdm12
@timwu20 When you try to scale encode a struct, its private (not exported) field can be read by our scale package. I observed this with InherentsData struct which has
dataunexported. With that in mind, does it make sense to keep things exported in parachain inherents struct?@qdm12
That's interesting. Most Go codecs usually don't have access to unexported fields, should we do the same thing @timwu20 ? Or is there a use case where we need access to unexported fields?
@timwu20 When you try to scale encode a struct, its private (not exported) field can be read by our scale package. I observed this with InherentsData struct which has
dataunexported. With that in mind, does it make sense to keep things exported in parachain inherents struct? @qdm12That's interesting. Most Go codecs usually don't have access to unexported fields, should we do the same thing @timwu20 ? Or is there a use case where we need access to unexported fields?
That's how they implemented InherentData in substrate. They manually encode it, and the trait ensures that the type that you are using can be scale encoded.
:tada: This PR is included in version 0.7.0 :tada:
The release is available on GitHub release
Your semantic-release bot :package::rocket: