gossamer icon indicating copy to clipboard operation
gossamer copied to clipboard

Implement parachain inherents

Open kishansagathiya opened this issue 3 years ago • 2 comments

Changes

  • Implements parachn0 inherent

Tests

go test -tags integration github.com/ChainSafe/gossamer

Issues

Fixes #2426

Primary Reviewer

@timwu20

kishansagathiya avatar May 23 '22 14:05 kishansagathiya

blocked on https://github.com/ChainSafe/gossamer/issues/2634

kishansagathiya avatar Jul 06 '22 14:07 kishansagathiya

@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/).

kishansagathiya avatar Sep 22 '22 08:09 kishansagathiya

@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

kishansagathiya avatar Sep 27 '22 06:09 kishansagathiya

@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

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?

qdm12 avatar Sep 28 '22 11:09 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 data unexported. 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?

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.

timwu20 avatar Sep 29 '22 16:09 timwu20

:tada: This PR is included in version 0.7.0 :tada:

The release is available on GitHub release

Your semantic-release bot :package::rocket:

github-actions[bot] avatar Nov 23 '22 18:11 github-actions[bot]