* Global registration of type segmenters for event decoding
* Perform type sizes check when building client
* Introduce EventTypeRegistry for global runtime type sizes
* Fmt
* Register runtime type sizes on creation of EventTypeRegistry
* Register more default dispatch types
* Add missing type sizes
* fmt
* Fix up register_type_size builder method
* Update doc comments
* Make register_default_type_sizes public
* Don't allow duplicate registered types
* Remove call to supertraits type registration, done manually in Runtime
* Fix tests and warnings
* Fix duplicate type registration
* Fmt
* review: use is_empty()
Co-authored-by: Niklas Adolfsson <niklasadolfsson1@gmail.com>
* Add panic docs
Co-authored-by: Niklas Adolfsson <niklasadolfsson1@gmail.com>
* Refactor event type decoding hand declartion
Fixes#196, #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.
* Format code
* Make rustfmt::skip an outer attribute
* Ignore the sample code
* Alias the event segmenter closure
* Copy AuthorityList from sp_finality_grandpa
* Remove the unused static event type size
* Make segmenter as a trait, resue grandpa::Public
* Wrap PhantomData in struct TypeMarker
* Update to substrate alpha.7
* Remove gas limit from contracts put code
* Rename SystemEvent::ReapedAccount to KilledAccount
* Log debug event received before attempting to decode
* Temporary registration of Balance type before #102 merged
* Show contract test errors, increase instantiate gas_limit
* Support custom clients.
* Simplify trait bounds.
* Plain and double map storage support.
* Simplify more trait bounds.
* Add proc macro.
* Add Call, Event and Store traits.
* Update proc-macros.
* Add with_system for proc-macro.
* proc-macro: test: support signature and extra fields.
* proc-macro: test: support sharing state accross steps.
* proc-macro: test: fetch state sequentially.
* Elide lifetimes.
* Add test for plain storage.
* Run rustfmt.
* WIP
* Begin converting rpc layer to use std futures and jsonrpsee
* Convert metadata to async/await
* Convert block_hash to async/await
* Convert more methods to async/await
* Remove sp_rpc
* Fix more compilation errors
* Remove connect
* Starting to convert subscription functions
* Use jsonrpsee branch from PR for public client types
* Implement subscribe events with jsonrpsee subscription
* Converting subscriptions and wait_for_block_events
* WIP converting lib methods to async
* Use shared client reference directly for rpc call
`rpc_api!` macro currently only supports RawClient (which cannot be shared).
Also supports named params only which is not currently compatible with substrate rpd which accepts only positional params.
* Use &self instead of &mut self for shared Client
* Convert submit_and_watch to async/await
* Convert more Client fns to async
* Pin some trait futures
* Add serde error
* Fix client creation
* Fix client request compiler errors
* Unify metadata errors
* Add WS handshake error variant
* Fix some more compiler errors
* Fix more compiler errors
* Convert submit_extrinsic to async
* Convert submit and submit_and_watch
* Add Send + Sync constraints
* Clone clients
* Fix EventArg conversion error
* Fix remaining warnings/errors
* Replace deny warnings with specific lints
* Infallable subscription loops
* Use jsonrpsee wss branch
* Fix example
* Start to fix up tests
* Make contracts tests compile
* Make some more tests pass
* Fix up remaining tests
* Fmt
* Use correct event storage key type
* Fix finding events
* Use master jsonrpsee
* Do not error if type sizes missing: log warn
* Split out EventsSubscriber, allow updating events decoder
* Format code
* Check missing type sizes after registration
* Add example which for submit and watching events
* Move contracts tests to contracts module
* Add test for instantiating a contract
* Fix InstantiateArgs encoding
* Ignore PhantomData primitives, they are 0
* Increase endowment and log code hash
* Update SystemEvent
* Fix codec import
* Oops
* Write buffer directly to output to avoid encoding vec
* Debug with StorageChanges encoded as hex
* Logging and format code
* Fix the module index used to create a encoded func
Same as Events, modules with no calls should be ignored when calculating
the module index.
* Update substrate
* Update jsonrpc to align with substrate
* Update to new substrate signing
* Default to MultiSignature
* Add missing event type sizes
* Rename TakeFees check to ChargeTransactionPayment
* Fix extrinsic Signature
* Ignore AuthorityList type size
* Rename srml to paint (#32)
* Introduce OpaqueEvent
* Look up event by module and variant
* Index events by module
* Get events by module
* Dynamically decode events
* Decode System events and EventRecord topics
* Use type sizes to decode raw events
* Remove unused imports
* rustfmt
* Unify error types, fix some compiler errors
* Make dynamic event decoding work
- fix compilation errors
- skip modules with no events when indexing
- preallocate vec for raw event data
* Remove printlns, replace where required with log
* Remove unused import
* Check missing type sizes
* Ignore unknown event arg type sizes
* Decode concrete System events, assumes every Runtime has the module
* Reorganise usings
* pub use some types
* Code docs
* Export Error
* Error Display impls
* Format code