Commit Graph

76 Commits

Author SHA1 Message Date
Guillaume Thiolliere 6dfad0921b Add pallet attribute macro to declare pallets (#6877)
* rename system Config to system Trait.

command used:
```
find frame/ bin/ test-utils/ utils/ -name *.rs -exec sed -i 's/system::Trait>::/system::Config>::/g' {} \;
find frame/ bin/ test-utils/ utils/ -name *.rs -exec sed -i 's/impl frame_system::Trait for /impl frame_system::Config for /g' {} \;
find frame/ bin/ test-utils/ utils/ -name *.rs -exec sed -i 's/impl system::Trait for /impl system::Config for /g' {} \;
```
plus some manual ones especially for frame-support tests and frame-system

* make construct_runtime handle Pallet and Module

pallets can now be implemented on struct named Pallet or Module, both
definition are valid.
This is because next macro will generate only Pallet placeholder.

* introduce pallet attribute macro

currently just with tests, frame_system and other example hasn't been
upgraded

* allow to print some upgrade helper from decl_storage

* Improved error msg, typo.

Co-authored-by: Shawn Tabrizi <shawntabrizi@gmail.com>

* Improved error msg, typo.

Co-authored-by: Shawn Tabrizi <shawntabrizi@gmail.com>

* Improved error message on unexpected attributes + ui test

* add test for transactional

* various typo

* some tips when spans are lost

* allow pallet to depend on other pallet instances

* make event type metadata consistent with call and constant

* error messages

* ignore doc example

* fix pallet upgrade template

* fixup

* fix doc

* fix indentation

* Apply suggestions code formatting

Co-authored-by: Kian Paimani <5588131+kianenigma@users.noreply.github.com>

* some renames + fix compilation

* remove unsupported genesis config type alias

* merge fixup

* fix ui tests

* additional doc

* implement StorageInstance with new syntax

* fix line width

* fix doc: because pallet doc goes below reexport doc

* Update frame/support/procedural/src/pallet/parse/event.rs

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

* Update frame/system/src/lib.rs

Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com>

* Update frame/support/test/tests/pallet_ui.rs

Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com>

* improve doc as suggested

* revert construct_runtime Pallet part.

This revert the changes on construct_runtime. Now construct_runtime is
unchanged and instead pallet macro create a type alias
`type Module<..> = Pallet<..>` to be used by construct_runtime

* refactor with less intricated code

* fix ui test with new image

* fix ui tests

* add minor tests

Co-authored-by: Shawn Tabrizi <shawntabrizi@gmail.com>
Co-authored-by: Kian Paimani <5588131+kianenigma@users.noreply.github.com>
Co-authored-by: Andrew Jones <ascjones@gmail.com>
Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com>
2020-12-24 11:33:40 +00:00
Guillaume Thiolliere 1cbfc9257f Rename pallet trait Trait to Config (#7599)
* rename Trait to Config

* add test asserting using Trait is still valid.

* fix ui tests
2020-11-30 14:34:54 +00:00
Roman Borschel b4ee48ee18 Upgrade to libp2p-0.31. (#7606)
* Upgrade to libp2p-0.31.

* Address line width.

* Add generous incoming connection limit.

* Remove old noise configuration.
2020-11-27 14:29:18 +00:00
Bastian Köcher e1b56f8dd3 Make sure pallet versions are set at genesis (#7451)
* Make sure pallet versions are set at genesis

This pr ensures that pallet versions are also set at genesis. It does
this by hooking into the runtime `GenesisConfig` which means that it
will only work when the storage is setup using this genesis config. So,
the version will not be set in pallet local tests. However, I think this
isn't such a problem. The genesis config will call `on_genesis` on all
pallets. This function comes from the new trait `OnGenesis`. Currently
the user is not able to provide any custom implementation of this trait.

Besides that it also implements `Clone` and `Copy` for the pallet
version struct.

This pr also moves the macro for generating the runtime genesis config
to `frame-support` as most of the other FRAME related macros.

* Reduce line width

* Update frame/support/src/traits.rs

Co-authored-by: Alexander Popiak <alexander.popiak@parity.io>

Co-authored-by: Alexander Popiak <alexander.popiak@parity.io>
2020-10-29 20:20:08 +01:00
Bastian Köcher ed1d0fa815 Implements pallet versioning (#7208)
* Start

* Make macro work

* Rename `ModuleToIndex` to `PalletRuntimeSetup`

Besides the renaming it also adds support getting the name of a pallet
as configured in the runtime.

* Rename it to `PalletInfo`

* Remove accidentally added files

* Some work

* Make everything compile

* Adds a test and fixes some bugs

* Implement ordering for `PalletVersion`

* Apply suggestions from code review

* Review feedback

* Update frame/support/src/dispatch.rs

Co-authored-by: Guillaume Thiolliere <gui.thiolliere@gmail.com>

* Update frame/support/src/dispatch.rs

Co-authored-by: Guillaume Thiolliere <gui.thiolliere@gmail.com>

* Fix compilation

* Fix test

* Fix doc test

Co-authored-by: Alexander Popiak <alexander.popiak@parity.io>
Co-authored-by: Guillaume Thiolliere <gui.thiolliere@gmail.com>
2020-10-21 19:05:52 +02:00
Guillaume Thiolliere 7ca9baf9b6 Derive no bound macros (to be also used in pallet macro) (#7280)
* derive no bound macros

* explicit different variant for partialeq

* fix ui for 1.47

* Apply suggestions from code review

Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com>

* move test to frame-support-test

* renames, code organization and remove expect as suggested

* better doc

* remove DebugStripped introduce RuntimeDebugNoBound

* rename

* fix test

* fix ui test

* fix line width

* Update frame/support/src/lib.rs

Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com>

* Update frame/support/procedural/src/clone_no_bound.rs

Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com>

* Apply suggestions from code review

Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com>

* fix confusing dead code

Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com>
2020-10-19 09:11:51 +00:00
Xiliang Chen 5172777c7d handle returns correctly for transactional (#7301) 2020-10-12 12:00:19 +02:00
Xiliang Chen 806dc9a659 Implements require_transactional (#7261)
* Implements require_transactional

* support wasm

* only enable for debug build

* remove wasm support and add feature flag

* Apply suggestions from code review

Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com>

* only use check for debug_assertions

* update per review

* update docs

* Apply suggestions from code review

Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com>

* remove duplicated tests

* fix test

Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com>
2020-10-12 09:46:15 +02:00
Guillaume Thiolliere a31637def8 Fix executive test (#7243)
* fix executive test

* add unallowed unsigned test

* better to have also unsigned pre_dispatch check tested
2020-10-01 12:40:45 +00:00
Benjamin Kampmann ecdc94420e Releasing 2.0 – two dot 😮 (#7182)
Tagging the release of substrate 2.0


[ci: skip-checks]
2020-09-22 19:47:38 +02:00
Guillaume Thiolliere 98951b33a9 Allow pallet in construct_runtime to have fixed index (#6969)
* implement index for pallet + some tests

* add test and doc

* remove deprecated and document behavior

* update internal doc

* Apply suggestions from code review

Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com>

* address review

* use index for all module, break construct_runtime

* fix line length

* implement migration helper funciton in scheduler

* fix start at index 0

* Update frame/scheduler/src/lib.rs

Co-authored-by: Shawn Tabrizi <shawntabrizi@gmail.com>

* Update frame/support/procedural/src/lib.rs

Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com>

* bump frame-metadata crate

* factorize

* avoid some unwrap and remove nightly join

* Update frame/support/src/event.rs

Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com>

* fix test

* add test and improve error message

* factorize test

* keep iterator, and use slice instead of vec

* refactor to avoid to have expects

* small refactor

* Test something

* Make sure we update the `Cargo.lock`

* Apply suggestions from code review

Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com>

* return 2 error

* Apply suggestions from code review

Co-authored-by: Alexander Popiak <alexander.popiak@parity.io>

* Update frame/scheduler/src/lib.rs

Co-authored-by: Kian Paimani <5588131+kianenigma@users.noreply.github.com>

* fix typo

* Revert "fix typo"

This reverts commit f2de8f2db34e8ac72bc9c34437c60dca3fa4ac22.

* Revert "Update frame/scheduler/src/lib.rs"

This reverts commit 6feb4605c6f784b64591e229de7a6fec6dbffb4b.

Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com>
Co-authored-by: Shawn Tabrizi <shawntabrizi@gmail.com>
Co-authored-by: Bastian Köcher <git@kchr.de>
Co-authored-by: Alexander Popiak <alexander.popiak@parity.io>
Co-authored-by: Kian Paimani <5588131+kianenigma@users.noreply.github.com>
2020-09-22 14:54:03 +00:00
Bastian Köcher 86594727d9 Rename ModuleToIndex to PalletRuntimeSetup (#7148)
* Rename `ModuleToIndex` to `PalletRuntimeSetup`

Besides the renaming it also adds support getting the name of a pallet
as configured in the runtime.

* Rename it to `PalletInfo`

* Remove accidentally added files
2020-09-22 13:39:56 +00:00
Bastian Köcher bdd79c93ba Make transactional attribute less scope dependent (#7112)
* Make `transactional` attribute less scope dependent

The old implementation expected that `frame-support` wasn't imported
under a different name. Besides that the pr removes some whitespaces.

* Update frame/support/procedural/src/lib.rs

Co-authored-by: Guillaume Thiolliere <gui.thiolliere@gmail.com>
2020-09-16 00:03:50 +02:00
Benjamin Kampmann 2416aa7999 prepping for releasing rc6 (#6922)
* Bump version

* update test-utils crates to be ready for publishing

* adding changelog

* Adding automaticly generated READMEs

* fixing versions

* another version mishap
2020-08-20 17:04:42 +02:00
Bastian Köcher f58e950415 Import IterableStorage* traits by decl_storage! (#6907)
Import `IterableStorageMap` and `IterableStorageDoubleMap` automatically
by `decl_storage!` as the other storage traits.
2020-08-18 07:36:58 +00:00
Shaopeng Wang a531c5b762 Implement 'transactional' annotation for runtime functions. (#6763)
* Implement 'transactional' annotation for runtime functions.

* Allow function attributes for dispatchable calls in decl_module.

* decl_module docs: add transactional function example.

* decl_module docs: add function attributes notes.

* Fix license header.
2020-08-12 09:21:36 +00:00
Guillaume Thiolliere 8a37f60844 Remove generation of instance trait by decl_storage. (#6812)
* remove generation of instance trait, no breaking change

* doc

* doc

* Update frame/support/src/traits.rs

Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com>

* Update frame/support/procedural/src/storage/instance_trait.rs

Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com>
2020-08-05 11:37:01 +00:00
pscott 046fda914a Improve overall performance (#6699)
* Improve overall performance

* Clean up code

Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com>

* Remove needless ::

Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com>

* Remove needless ::

Co-authored-by: Kian Paimani <5588131+kianenigma@users.noreply.github.com>

Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com>
Co-authored-by: Kian Paimani <5588131+kianenigma@users.noreply.github.com>
2020-07-21 14:46:49 +02:00
Benjamin Kampmann 629a801b6a Fixup cargo unleash (#6689)
* Bumping to rc5

* Revert "Bumping to rc5"

This reverts commit 5a63a8230e5a12db1b4ce4ac62e4967c52291da7.

* Bumping for rc5, correctly this time
2020-07-21 10:26:47 +00:00
Shaopeng Wang a6702b7121 decl_module! macro: use 'frame_system' instead of system as default ident (#6500)
* Use frame_system as default ident.

* Remove unused 'frame_system' to 'system' renaming.

* Fix construct_runtime_ui tests.

* Rename system to frame_system in sudo/utility pallet test.

* Bump runtime impl_version.

* Update formatting.
2020-07-07 23:06:21 +00:00
Shawn Tabrizi fe79b24692 Derive RuntimeDebug for Runtime (#6581) 2020-07-06 10:51:01 +00:00
Bastian Köcher ad2e832289 Don't require module name in inherents (#6576)
* Start

* Cleanup `construct_runtime!`

* Add tests

* Fix after merge

* Update the docs
2020-07-06 10:29:17 +00:00
Benjamin Kampmann f6ebd5f87d Releasing rc4 – Rhinoceros (#6515)
Co-authored-by: Martin Pugh <pugh@s3kr.it>
2020-06-25 23:18:43 +02:00
Guillaume Thiolliere 622dff9ca7 Impl integrity test for runtime (#6356)
* impl integrity test for runtime

* Update frame/support/src/traits.rs

Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com>

* Update frame/support/procedural/src/construct_runtime/mod.rs

Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com>

* use thread local

* update doc

* Apply suggestions from code review

Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com>
Co-authored-by: Gavin Wood <gavin@parity.io>
2020-06-16 13:10:10 +02:00
Benjamin Kampmann 881072e590 Intent to release rc3 (#6290) 2020-06-08 23:29:52 +02:00
Benjamin Kampmann b64f55089d Releasing rc2 (#6136) 2020-05-26 14:32:23 +02:00
Benjamin Kampmann fb32ac8c51 Tagging as rc1 2020-05-25 18:30:48 +02:00
thiolliere 4644be3c90 Make decl_storage generated code respect clippy (#6065)
* fix clippy for code generated by decl_storage

* use as_ref
2020-05-18 18:43:18 +02:00
Benjamin Kampmann 7c565085e9 resetting to -dev (#6050) 2020-05-16 19:03:04 +02:00
Benjamin Kampmann d7463d348f Releasing Alpha.8 (#6048) 2020-05-15 21:56:56 +02:00
Benjamin Kampmann be8c96adec Relax substrate licensing scheme (#5947) 2020-05-15 13:21:56 +02:00
Dan Forbes 848803aba2 Fix docs (#5928)
* Fix docs

* Update frame/support/src/dispatch.rs

Prettier link

Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com>

* Update primitives/runtime/src/traits.rs

Prettier link

Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com>

Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com>
2020-05-06 23:22:35 +02:00
Benjamin Kampmann 3860999ea3 post release dev reset (#5911) 2020-05-05 22:08:31 +01:00
Benjamin Kampmann 45886bd197 Release of Alpha.7 (#5904) 2020-05-05 20:50:46 +02:00
Bastian Köcher 20f211a624 Require fn token in decl_storage get (#5717)
* Require `fn` token in `decl_storage` `get`

The `fn` token was already for quite some time as an optional parameter.
It was introduced to make these functions better findable. This pr makes
the `fn` token required.

* Remove `GetterNoFnkeyword`
2020-04-21 16:58:57 +02:00
Benjamin Kampmann 3426d662f7 Switch pre-release version to dev (#5637) 2020-04-15 13:18:08 +02:00
Benjamin Kampmann 51f9bb3c0e Prepping release of alpha.6 (#5629)
* bumping version

* cargo update

* adding changelog
2020-04-14 21:41:49 +02:00
pscott 408455f8bc Build for only one target for docs.rs (#5427)
* Add docs.rs metadata to all cargo.toml files

* Remove docs.rs metada in substrate's cargo.toml
2020-03-30 09:46:30 +02:00
thiolliere 2138004fc8 Hide metadata function for in decl_event, and add doc for GenesisConfig (#5431)
* hide metadata function for non generic event

* add doc for decl_storage
2020-03-27 21:40:12 +01:00
Tomasz Drwięga 04ccb179e9 Pass transaction source to validate_transaction (#5366)
* WiP

* Support source in the runtime API.

* Finish implementation in txpool.

* Fix warning.

* Fix tests.

* Apply suggestions from code review

Co-Authored-By: Kian Paimani <5588131+kianenigma@users.noreply.github.com>
Co-Authored-By: Nikolay Volf <nikvolf@gmail.com>

* Extra changes.

* Fix test and benches.

* fix test

* Fix test & benches again.

* Fix tests.

* Update bumpalo

* Fix doc test.

* Fix doctest.

* Fix doctest.

Co-authored-by: Kian Paimani <5588131+kianenigma@users.noreply.github.com>
Co-authored-by: Nikolay Volf <nikvolf@gmail.com>
2020-03-25 14:09:23 +01:00
Benjamin Kampmann ba06d5ef64 Releasing 2.0.0-alpha.5 (#5340)
* bump pre-version

* Changelog alpha.4->alpha.5

* repo + homepage to sp-consensus-vrf

* Add default rocksdb feature to `frame-benchmarking-cli` (#5367)

* Add default rocksdb feature

* Update Cargo.toml

Co-authored-by: Shawn Tabrizi <shawntabrizi@gmail.com>
2020-03-24 15:08:02 +01:00
Benjamin Kampmann 25e25a83b9 Releasing 2.0.0-alpha.4 (#5279)
* Version bump

* Split generate_changelog.sh into separate script

Can be run in the format `generate_changelog.sh $previous_version $version`.

* remove early exit from publish_draft_release.sh

* adding changelog

* ci: change last_github_release to also find pre-releases

Co-authored-by: Martin Pugh <pugh@s3kr.it>
2020-03-18 14:37:21 +01:00
Gavin Wood af9083f53b Refactor away from opaque hashes (#5226)
* System.BlockHash

* Fix hash

* Introduce K/V iteration in all _concat maps

Also move across:
- System.Account (blake2_128_concat)
- Balances.Locks (twox_64_concat)
- ElectionsPhragmen.VotesOf (twox_64_concat)
- ElectionsPhragmen.StakeOf (twox_64_concat)
- Identity.IdentityOf (twox_64_concat)
- Identity.SubsOf (twox_64_concat)
- Society.Payouts (twox_64_concat)
- Session.NextKeys (twox_64_concat)
- Identity.SuperOf (blake2_128_concat)
- Session.KeyOwner (blake2_128_concat)
- Society.SuspendedCandidates (twox_64_concat)
- Society.SuspendedMembers (twox_64_concat)
- Society.Vouching (twox_64_concat)
- Society.Strikes (twox_64_concat)
- System.EventTopics
- Balances.Account

* Build fixes

* Ensure migration happens in correct order

* Staking.*

* Vesting.* Offences.*

* Democracy.*

* Babe.* Collective.*

* Grandpa.*

* Assets.* Benchmark.* Contracts.* Elections.* Asset.* Nicks.*

Also introduce real account list

* ImOnline.*

* Treasury.*

* Recovery.*

* Final bits.

* Docs

* Fix one test

* Fix test

* All passing except the UI tests

* Remove linked_map part 1

* Remove linked_map

* Some iterator utils for double maps.

* Remove old migrations

* Introduce tombstone for LinkedMap type

* Migration for genesis hash

* Fix build

* Fix hash

* Rename Map is_linked -> unused, keeping backwards compat (#5256)

* Update frame/balances/src/lib.rs

Co-Authored-By: Shawn Tabrizi <shawntabrizi@gmail.com>

* Update frame/elections/src/lib.rs

Co-Authored-By: Shawn Tabrizi <shawntabrizi@gmail.com>

* Remove old migration code.

* Update frame/system/src/lib.rs

Co-Authored-By: Shawn Tabrizi <shawntabrizi@gmail.com>

* Update bin/node/runtime/src/lib.rs

Co-Authored-By: Shawn Tabrizi <shawntabrizi@gmail.com>

* Fix hash

* fix session migration

* Fix watning

Co-authored-by: Jaco Greeff <jacogr@gmail.com>
Co-authored-by: Shawn Tabrizi <shawntabrizi@gmail.com>
Co-authored-by: Robert Habermeier <rphmeier@gmail.com>
2020-03-16 23:19:53 +01:00
Kian Paimani 7e2cd0edee Remove unused imports and extern crate (#5245) 2020-03-14 12:48:47 +01:00
Gavin Wood bbaf96e047 Revert quote fixed version and upgrade failure (#5152)
* Revert "use fixed quote (#5135)"

This reverts commit 8bf855b09d.

* Upgrade failure version

* Update frame/staking/reward-curve/Cargo.toml

Co-Authored-By: André Silva <andre.beat@gmail.com>

* Ahh I'm dumb

Co-authored-by: Gavin Wood <github@gavwood.com>
Co-authored-by: André Silva <andre.beat@gmail.com>
2020-03-05 22:14:55 +01:00
Gavin Wood 8bf855b09d use fixed quote (#5135) 2020-03-05 10:29:38 +01:00
Benjamin Kampmann 25d1b7878a prepping for Alpha.3 (#5080)
* Bump to alpha.3

* update gitlab-ci
2020-02-27 22:06:08 +01:00
Benjamin Kampmann d6aa8e954c set missing metadata fields, prepping alpha.2 (#5067)
* setting first batch of descriptions

* fix what I just broke

* next batch

* and pallets, too

* last batch

* set cargo.lock

* keep'em dev-deps

* bump version to alpha.2
2020-02-27 00:22:44 +01:00
Benjamin Kampmann e2776f42f9 prepare version to alpha.1 (#5055)
bump version to -alpha.1
2020-02-25 21:44:23 +01:00
Benjamin Kampmann c412c6230e Cargo.toml fixups for the release (#4975)
* setting versions to development pre-release

fixing version in dependencies

* unset already released wasm-builder

* do not publish test crates

* adding licenses

* setting homepage metadata

* set repository url
2020-02-21 17:07:00 +01:00