Refactor event type decoding and declaration#221
Merged
ascjones merged 9 commits intoparitytech:masterfrom Jan 20, 2021
Merged
Conversation
Fixes paritytech#196, paritytech#181, #28 ## Dyanmic sized types Before this change, the event decoder assume all the event types have fixed sizes. Some counterexamples are: Hashes, AuthorityList. In this change, instead of decoding by skipping the fixed-length bytes, we introduce `type_segmenter` registry which decodes the raw event bytes with the actual scale codec. So variable length types can be handled correctly. ## New attribute for pallet type definition In the past, trait associated type is the only way to add types to the EventsDecoder implementation of a pallet. But in reality it's common that the events in a pallet references some types not defined in the trait associated types. Some examples are: `IdentificationTuple` and `SessionIndex` in Session pallet. In this change, we introduce more attributes to add the types: ```rust #[module] trait Pallet: System { #![event_type(SomeType)] #![event_alias(TypeNameAlias = SomeType)] #![event_alias(SomeOtherAlias = TypeWithAssociatedTypes<T>)] } ``` ## Tested Compile with `nightly-2020-10-01`; smoke test to sync a full Phala bockchain.
7806f6f to
22f0855
Compare
|
Any updates? |
ascjones
suggested changes
Jan 18, 2021
Contributor
ascjones
left a comment
There was a problem hiding this comment.
In general this looks good, just a few nits.
ascjones
reviewed
Jan 19, 2021
ed58a55 to
fbd3e2f
Compare
Contributor
Author
|
The CI failed at "pure virtual method called". I believe it's a flaky test. It looks like due to the test full node not being properly killed: openethereum/parity-ethereum#6213 |
Contributor
Yeah that happens fairly frequently unfortunately, see #178. |
ascjones
reviewed
Jan 19, 2021
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #196, fixes #181, fixes #28
Dynamic sized types
Before this change, the event decoder assume all the event types have fixed sizes. Some counterexamples are: Hashes, AuthorityList.
In this change, instead of decoding by skipping the fixed-length bytes, we introduce
type_segmenterregistry which decodes the raw event bytes with the actual scale codec. So variable length types can be handled correctly.New attribute for pallet type definition
In the past, trait associated type is the only way to add types to the EventsDecoder implementation of a pallet. But in reality it's common that the events in a pallet references some types not defined in the trait associated types. Some examples are:
IdentificationTupleandSessionIndexin Session pallet.In this change, we introduce more attributes to add the types:
Tested
Compile with
nightly-2020-10-01; smoke test to sync a fullPhala bockchain.