Commit Graph

140 Commits

Author SHA1 Message Date
Andrew Jones de859e7396 Add hooks to register event types for decoding (#227)
* 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>
2021-02-18 10:28:40 +00:00
Andrew Jones 2c8e5211aa Substrate 3.0 (#232)
* Update substrate deps to 3.0.0 and 0.9.0

* Update substrate wasm tools

* Fixing errors for 3.0.0 compat

* Fixing more errors for 3.0.0 compat

* Use MultiAddress for test runtime

* Fmt

* Fix node test

* Pin Funty

* Update AccountInfo struct

* Add comment about funty pin
2021-02-17 16:45:05 +00:00
Andrew Jones 51c48f223a Update license header, bye bye 2020 👋 (#231) 2021-02-11 17:17:24 +00:00
Andrew Jones 032ba029af Release v0.14.0 (#226)
* Update CHANGELOG

* Bump versions

* Update client dep versions
2021-02-08 10:51:52 +00:00
h4x3rotab f3ece6d933 Fix the wrong rpc call in query_storage_at() (#223) 2021-01-27 08:57:47 +00:00
Niklas Adolfsson 4725a33ea2 [ci]: use latest nightly (#222)
* [ci]: use latest nightly

* grumbles

* fix nit; targets -> target
2021-01-20 16:22:50 +00:00
h4x3rotab 3c46002e67 Refactor event type decoding and declaration (#221)
* 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
2021-01-20 09:41:58 +00:00
Liu-Cheng Xu 5a0201c130 Add Balances Locks (#197)
* Add Balances Locks

* Pass fmt

* Add tests for Balances Locks

In order to write this test, I just added the new staking::BondCall :).

* .

* In case you want to run multiple tests at the same time

* Return Result in integration test
2021-01-15 09:34:35 +00:00
h4x3rotab 754b184363 Add event Phase::Initialization (#215) 2021-01-14 16:51:10 +00:00
Caio c2cc7afbc1 Make type explicit (#217) 2021-01-14 16:50:16 +00:00
Andrew Jones 6175cb70b9 Upgrade dependencies, bumps substrate to 2.0.1 (#219)
* Upgrade dependencies, bumps substrate to 2.0.1

* Upgrade test-node dependencies

* Upgrade client dependencies

* Upgrade proc-macro dependencies

* Revert futures01 dependency

* Upgrade futures

* Remove redundant package specifiers
2021-01-14 16:47:01 +00:00
Caio 5595b1e82f Export extra types (#212) 2021-01-05 17:26:13 +00:00
Zeke Mostov 0a926ef4c4 Enable retrieval of constants from rutnime metadata (#207) 2020-12-17 10:23:46 +00:00
Caio 8a76bebcff Add badge to docs.rs (#203) 2020-12-14 17:26:49 +00:00
Greg Hill 80aff7eb6e register type sizes for u64 and u128 (#200)
Signed-off-by: Gregory Hill <gregorydhill@outlook.com>
2020-12-09 15:09:29 +00:00
Andrew Jones 0b3c8d4523 Remove some substrate dependencies to improve compile time (#194)
* Copy ReadProof and TransactionStatus types

* Define local app crypto types

* Fmt

* Restore logging and add comments
2020-12-03 13:20:50 +00:00
Greg Hill 27c377a9d6 propagate 'RuntimeError's to 'decode_raw_bytes' caller (#189)
Signed-off-by: Gregory Hill <gregorydhill@outlook.com>
2020-11-13 17:16:14 +00:00
Qinxuan Chen 7655caac0f Derive Clone for PairSigner (#184)
* Derive `Clone` for `PairSigner`

Signed-off-by: koushiro <koushiro.cqx@gmail.com>

* Specify the date of nightly toolchain to fix CI

Signed-off-by: koushiro <koushiro.cqx@gmail.com>
2020-10-20 10:57:27 +01:00
David fc2da6b9c7 Release v0.13 (#175)
* Upgrade to substrate 2.0.0

* WIP implement Subcommand manually (see https://github.com/paritytech/substrate/pull/6894#issuecomment-676060197)

* Add pallet-staking/std to the std feature

* Sort out the subcommand impl

* Sort out the module index (ty @ascjones)
Sort out the RefCount type (ty @dvc94ch)
Random tweaks to make test-node more similar to the vanilla node-template

* obey the fmt

* Add changelog and bump versions

* Merge #165 and update CHANGELOG

* Update test-node/runtime/src/lib.rs

Co-authored-by: Demi Marie Obenour <demiobenour@gmail.com>

* Update CHANGELOG.md

Co-authored-by: Demi Marie Obenour <demiobenour@gmail.com>

Co-authored-by: Demi Marie Obenour <demiobenour@gmail.com>
2020-10-05 10:56:27 +02:00
Demi Marie Obenour cd7bb6041b Remove unnecessary Sync requirements (#172)
This is needed for Ledgeracio, as Ledgeracio’s signer is now no longer
`Send`.
2020-09-25 08:18:26 +01:00
Andrew Jones 385d214217 Call a contract (#165)
* Revert contracts put_code test to pure code (not using the macro)

* Test contract instantiate

* Fmt

* Extract put_code and new_client functions

* Generate fresh accounts for contract tests to allow reruns without a chain purge

* Fetch and increment nonce to allow concurrent test runs

* fmt

* Failing contract call test

* Fmt and fix compilation

* Fix error message for contract call

* Fix call test

* Update contract execution event comment

* Remove redundant feature flags, now on module

* Update event data comment

* Use fetch_add

* Fmt
2020-09-24 18:21:51 +02:00
David 8e2a4f06ee Upgrade to substrate 2.0.0 (#173)
* Upgrade to substrate 2.0.0

* WIP implement Subcommand manually (see https://github.com/paritytech/substrate/pull/6894#issuecomment-676060197)

* Add pallet-staking/std to the std feature

* Sort out the subcommand impl

* Sort out the module index (ty @ascjones)
Sort out the RefCount type (ty @dvc94ch)
Random tweaks to make test-node more similar to the vanilla node-template

* obey the fmt

* cleanup

* more cleanup
2020-09-24 12:57:35 +01:00
David 56bd633706 Address review grumbles from #99 (#171)
* Address review grumbles from #99

* obey the fmt
2020-09-22 16:29:29 +01:00
Demi Obenour f9f69b8c3b Staking support (#99)
* Initial Staking API

* Add more staking types

* Reformat

* Remove dead code

* Fix missing documentation

* Reformat

* Staking: use proc macros

* Add partial session support

* Reformat

* Try to implement nomination

This currently fails with compilation errors I do not understand.

* Use the #[module] macro

This fixes a compile error

* Explain undefined method diagnostics

* Use ‘#[module]’ and implement session for Kusama

* Don’t impl ‘Staking’ for all ‘T: System’

* Add staking payout support

* Fix compilation errors and remove useless lifetimes

* Respond to code review

This fixes most of the issues found during review, with the exception of
tests.

* Make signing fallable and asynchronous

This is needed for hardware wallets, which require human confirmation to
sign transactions.  Blocking on a human to sign transactions is not a
good idea, and the signing might fail for many reasons (device
unplugged, authorization not granted, etc).

* Reformat

* Refactor as suggested by Andrew Jones (@ascjones).

* Reformat

* Refactor as suggested by Andrew Jones (@ascjones).

* Trait cleanups

* Make the `Signer` impl require Send + Sync

This is what Ledgeracio needs.

* Use the correct key for staking maps

They use the key type, not ‘PhantomData’.

* Implement set_payee call

* Switch to associated types for Staking

* Implement `set_keys`

This is needed for Ledgeracio.

* Remove impl of Signer for Box<dyn Signer + Send + Sync>

It isn’t needed, since Box implements Deref.

* Fix Polkadot and Kusama ‘SessionKey’ structs

I had failed to include the ‘Parachains’ component, which the default
Substrate runtime doesn’t have.

* Include a copy of `ValidatorId`

This avoids needing to depend on Polkadot.

* Fix syntax error in Cargo.toml

* Fix compile errors

* Add Debug impls

* Fix return type of `BondedStore`

* Use some upstream type definitions

Also add `Default` impls.

* Bump deps and fix build

* Remove last reference to Kusama feature

* Fix compilation errors

* Implement the `concat` in `twox_64_concat`

* Expose properties and per-era preferences

* Era rewards point support

I also did some refactoring.

* Expose clipped exposure

* Era reward points support

* Make `PayoutStakersCall` public

* Add in all default features for debugging

* Chill support and update to latest Substrate

* If property fetch fails, use dummy values

* Fix tests

* Fix header

* Remove some code Ledgeracio does not need

* More deletions

* Remove more code not needed for Ledgeracio

* Remove a pointless change in Cargo.toml

w.r.t. upstream.

* Remove more junk

* Revert contracts put_code test to pure code (not using the macro)

* Test contract instantiate

* Fmt

* WIP

* Add some more submission tests

* Reformat

* More tests

* Cleanup

* Hopefully fix CI

* Remove dead code

* Test chill

* Add missing docs

* Remove unnecessary use

* Revert "Remove unnecessary use"

This reverts commit bc8bc36bde581f1892ea88a778dfe0fe5bff24d7.

* Retry on temporary failures

* Ignore the staking tests on CI

* Obey the fmt

* Run CI with at most one test thread

* Implement tests for staking

* More tests

* Remove unhelpful println!

* Revert changes in contract tests

* Reformat

* Remove spurious diff

* More tests

Co-authored-by: Demi M. Obenour <demiobenour@gmail.com>
Co-authored-by: David Palm <dvdplm@gmail.com>
Co-authored-by: Andrew Jones <ascjones@gmail.com>
2020-09-21 13:15:46 -04:00
Liu-Cheng Xu 0c7454dfcd Display RawEvent data in hex (#168)
So that printing the RawEvent won't comsume more than the whole screen.
2020-09-21 10:32:41 +01:00
Liu-Cheng Xu e843bd670f Add SudoUncheckedWeightCall (#167)
* Add SudoUncheckedWeightCall

* Add test_sudo_unchecked_weight()

* Fix CI

Use nightly fmt.

* .
2020-09-21 09:22:57 +01:00
Liu-Cheng Xu ce22986a75 Add SetCodeWithoutChecksCall (#166) 2020-09-17 15:20:48 +01:00
Andrew Jones 4ed8e37ffe Fix up contracts pallet tests (#163)
* Revert contracts put_code test to pure code (not using the macro)

* Test contract instantiate

* Fmt
2020-09-15 08:32:33 +01:00
Greg Hill 2829d7d7c1 fix option decoding and add basic sanity test (#161)
Signed-off-by: Gregory Hill <gregorydhill@outlook.com>
2020-09-15 08:24:05 +01:00
David Ackerman f2cf79847a Remove visibility limiter pub (crate) from Metadata (#162)
* Remove visibility limiter `pub (crate)`

* Run fmt

* Add comments
2020-09-14 15:51:42 +01:00
Greg Hill e85d01ed08 decode option event arg (#158)
Signed-off-by: Gregory Hill <gregorydhill@outlook.com>
2020-09-07 14:58:45 +01:00
Andrew Jones af45c39fb1 Release v0.12.0 (#157)
* Bump version, update changelog

* Bump proc-macro crate

* Bump client crate
v0.12.0
2020-09-01 15:54:01 +01:00
David Craven e9c50e21d0 Only return an error if the extrinsic failed. (#156) 2020-09-01 11:15:04 +01:00
David Craven 3ea9d3b8bb Update to rc6. (#155)
* Update to rc6.

* Fix clippy warnings.
2020-08-25 09:50:14 +01:00
David Craven eac2ce3b2a Different assert. (#153) 2020-08-17 09:14:26 +01:00
Yuanchao Sun 59b9c117b7 Add a method to fetch an unhashed key, close #100 (#152)
* Add a method to fetch an unhashed key, close #100

* Return decoded value

* Refactoring
2020-08-13 21:06:30 +01:00
David Craven 9aa32ef63d Fix port number. (#151) 2020-08-13 16:04:30 +01:00
Demi Obenour 511e6f5a16 Implement the concat in twox_64_concat (#150)
Co-authored-by: Demi M. Obenour <demiobenour@gmail.com>
2020-08-10 11:05:17 +01:00
David Craven 271775bf99 Storage map iter (#148)
* Add example file

* Fmt

* Add KeyIter.

* Add iter method to store proc-macro.

* Fetch all values at once.

* Update docs.

* Run rustfmt.

Co-authored-by: Andrew Jones <ascjones@gmail.com>
2020-08-05 09:08:12 +01:00
Andrew Jones 663934ca37 Fetch paged storage keys 2020-08-03 12:40:37 +01:00
Andrew Jones d3e7bd2282 Release v0.11.0 (#145)
* Bump versions

* Update changelog

* Update PR links

* Fix changelog linebreak

* Remove explicit wabt-sys dependency

* Update changelog

* Update parity-scale-codec version
v0.11.0
2020-07-31 11:02:21 +01:00
hewigovens cb23cb24e0 Fix build error, wabt 0.9.2 is yanked (#146) 2020-07-31 08:29:48 +01:00
David Craven e6f3a82f99 Rc5 (#143)
* Update to rc6.

* Update runtime.

* Update node to rc6.

* Update client.

* Fix node.

* Add option to enable telemetry.
2020-07-27 08:53:02 +01:00
Andrew Jones cd6b8f43f1 Refactor: extract functions and types for creating extrinsics (#138)
* Extract extrinsic

* Extract extrinsic types to own module

* Fix compiler errors

* Fix warnings

* Fmt

* Pin wabt-sys to 0.7.1, it fails (on my machine) with 0.7.2

* Fix up tests

* Fmt

* Reexport RuntimeVersion
2020-07-20 09:17:19 +01:00
Amar Singh 015a819759 event subscription example (#140)
* added example

* fmt
2020-07-16 08:09:03 +01:00
David a4ba74ed72 Document the Call derive macro (#137)
* Document the `Call` derive macro

* Obey the fmt

* Update proc-macro/src/lib.rs

Co-authored-by: Andrew Jones <ascjones@gmail.com>

* Review feedback

Co-authored-by: Andrew Jones <ascjones@gmail.com>
2020-07-07 08:20:58 +01:00
David 536c54c843 Document the #[module] macro (#135)
* Document the #[module] macro

* Obey the fmt

* Review feedback

* More docs

* Tweak wording

* tweak wording

* whitespace

* Tweak docstring
2020-07-07 08:19:44 +01:00
David Craven c6350fcc11 Support authors api. (#134) 2020-07-01 15:27:14 +01:00
Andrew Jones 4265dd6a69 Release client v0.2.0 (#133)
* Bump client version

* Bump client dev dependency version

* Changelog

* Bump subxt version
2020-06-29 13:21:20 +01:00
Andrew Jones f08f316741 Release client v0.2.0 (#133)
* Bump client version

* Bump client dev dependency version

* Changelog

* Bump subxt version
2020-06-29 11:44:33 +01:00