* implement max_values + storages info
* some formatting + doc
* sudo sanity check
* timestamp
* assets (not working)
* fix assets
* impl for proxy
* update balances
* rename StoragesInfo -> PalletStorageInfo
* merge both StorageInfoTrait and PalletStorageInfo
I think it is more future proof. In the future some storage could make
use of multiple prefix. Like one to store how much value has been
inserted, etc...
* Update frame/support/procedural/src/storage/parse.rs
Co-authored-by: Peter Goodspeed-Niklaus <coriolinus@users.noreply.github.com>
* Update frame/support/procedural/src/storage/storage_struct.rs
Co-authored-by: Peter Goodspeed-Niklaus <coriolinus@users.noreply.github.com>
* Fix max_size using hasher information
hasher now expose `max_len` which allows to computes their maximum len.
For hasher without concatenation, it is the size of the hash part,
for hasher with concatenation, it is the size of the hash part + max
encoded len of the key.
* fix tests
* fix ui tests
* Move `MaxBoundedLen` into its own crate (#8814)
* move MaxEncodedLen into its own crate
* remove MaxEncodedLen impl from frame-support
* add to assets and balances
* try more fixes
* fix compile
Co-authored-by: Shawn Tabrizi <shawntabrizi@gmail.com>
* nits
* fix compile
* line width
* fix max-values-macro merge
* Add some derive, needed for test and other purpose
* use weak bounded vec in some cases
* Update lib.rs
* move max-encoded-len crate
* fix
* remove app crypto for now
* width
* Revert "remove app crypto for now"
This reverts commit 73623e9933d50648e0e7fe90b6171a8e45d7f5a2.
* unused variable
* more unused variables
* more fixes
* Add #[max_encoded_len_crate(...)] helper attribute
The purpose of this attribute is to reduce the surface area of
max_encoded_len changes. Crates deriving `MaxEncodedLen` do not
need to add it to `Cargo.toml`; they can instead just do
```rust
\#[derive(Encode, MaxEncodedLen)]
\#[max_encoded_len_crate(frame_support::max_encoded_len)]
struct Example;
```
* fix a ui test
* use #[max_encoded_len_crate(...)] helper in app_crypto
* remove max_encoded_len import where not necessary
* update lockfile
* fix ui test
* ui
* newline
* fix merge
* try fix ui again
* Update max-encoded-len/derive/src/lib.rs
Co-authored-by: Peter Goodspeed-Niklaus <coriolinus@users.noreply.github.com>
* extract generate_crate_access_2018
* Update lib.rs
* compiler isnt smart enough
Co-authored-by: thiolliere <gui.thiolliere@gmail.com>
Co-authored-by: Peter Goodspeed-Niklaus <coriolinus@users.noreply.github.com>
Co-authored-by: Peter Goodspeed-Niklaus <peter.r.goodspeedniklaus@gmail.com>
* Make #[pallet::hooks] optional
* Make #[pallet::call] optional
* Remove unused imports
* Update UI test expectations
* Update UI test expectations
* Remove unnecessary HooksDef::empty method
* Remove unnecessary CallDef::empty method
* Clarify what would happen when no call or hooks are specified in a pallet
* implement max_values + storages info
* some formatting + doc
* rename StoragesInfo -> PalletStorageInfo
* merge both StorageInfoTrait and PalletStorageInfo
I think it is more future proof. In the future some storage could make
use of multiple prefix. Like one to store how much value has been
inserted, etc...
* Update frame/support/procedural/src/storage/parse.rs
Co-authored-by: Peter Goodspeed-Niklaus <coriolinus@users.noreply.github.com>
* Update frame/support/procedural/src/storage/storage_struct.rs
Co-authored-by: Peter Goodspeed-Niklaus <coriolinus@users.noreply.github.com>
* Fix max_size using hasher information
hasher now expose `max_len` which allows to computes their maximum len.
For hasher without concatenation, it is the size of the hash part,
for hasher with concatenation, it is the size of the hash part + max
encoded len of the key.
* fix tests
* fix ui tests
Co-authored-by: Peter Goodspeed-Niklaus <coriolinus@users.noreply.github.com>
* Implement StorageNMap
* Change copyright date to 2021
* Rewrite keys to use impl_for_tuples instead of recursion
* Implement prefix iteration on StorageNMap
* Implement EncodeLike for key arguments
* Rename KeyGenerator::Arg to KeyGenerator::KArg
* Support StorageNMap in decl_storage and #[pallet::storage] macros
* Use StorageNMap in assets pallet
* Support migrate_keys in StorageNMap
* Reduce line characters on select files
* Refactor crate imports in decl_storage macros
* Some more line char reductions and doc comment update
* Update UI test expectations
* Revert whitespace changes to untouched files
* Generate Key struct instead of a 1-tuple when only 1 pair of key and hasher is provided
* Revert formatting changes to unrelated files
* Introduce KeyGeneratorInner
* Add tests for StorageNMap in FRAMEv2 pallet macro
* Small fixes to unit tests for StorageNMap
* Bump runtime metadata version
* Remove unused import
* Update tests to use runtime metadata v13
* Introduce and use EncodeLikeTuple as a trait bound for KArg
* Add some rustdocs
* Revert usage of StorageNMap in assets pallet
* Make use of ext::PunctuatedTrailing
* Add rustdoc for final_hash
* Fix StorageNMap proc macro expansions for single key cases
* Create associated const in KeyGenerator for hasher metadata
* Refactor code according to comments from Basti
* Add module docs for generator/nmap.rs
* Re-export storage::Key as NMapKey in pallet prelude
* Seal the EncodeLikeTuple trait
* Extract sealing code out of key.rs
Co-authored-by: Shawn Tabrizi <shawntabrizi@gmail.com>
* requiring users to maintain an unchecked invariant is unsafe
* relax trait restrictions on BoundedVec<T, S>
A normal `Vec<T>` can do many things without any particular trait
bounds on `T`. This commit relaxes the bounds on `BoundedVec<T, S>`
to give it similar capabilities.
* Lol
* Yeah
* Moare
* adaasda
* Convert AURA to new pallet macro
* AURA: Switch to `CurrentSlot` instead of `LastTimestamp`
This switches AURA to use `CurrentSlot` instead of `LastTimestamp`.
* Add missing file
* Update frame/aura/src/migrations.rs
Co-authored-by: André Silva <123550+andresilva@users.noreply.github.com>
* Remove the runtime side provide inherent code
* Use correct weight
* Add TODO
* Remove the Inherent from AURA
* 🤦
* Remove unused stuff
* Update primitives authorship
* Fix babe inherent data provider
* Fix consensus-uncles
* Fix BABE
* Do some further changes to authorship primitives... :D
* More work
* Make it compile the happy path
* Make it async!
* Take hash
* More stuff
* Hacks
* Revert "Hacks"
This reverts commit cfffad88668cfdebf632a59c4fbfada001ef8251.
* Fix
* Make `execute_block` return the final block header
* Move Aura digest stuff
* Make it possible to disable equivocation checking
* Fix fix fix
* Some refactorings
* Comment
* Fixes fixes fixes
* More cleanups
* Some love
* Better love
* Make slot duration being exposed as `Duration` to the outside
* Some slot info love
* Add `build_aura_worker` utility function
* Copy copy copy
* Some stuff
* Start fixing pow
* Fix pow
* Remove some bounds
* More work
* Make grandpa work
* Make slots use `async_trait`
* Introduce `SharedData`
* Add test and fix bugs
* Switch to `SharedData`
* Make grandpa tests working
* More Babe work
* Make grandpa work
* Introduce `SharedData`
* Add test and fix bugs
* Switch to `SharedData`
* Make grandpa tests working
* More Babe work
* Make it async
* Fix fix
* Use `async_trait` in sc-consensus-slots
This makes the code a little bit easier to read and also expresses that
there can always only be one call at a time to `on_slot`.
* Make grandpa tests compile
* More Babe tests work
* Fix network test
* Start fixing service test
* Finish service-test
* Fix sc-consensus-aura
* Fix fix fix
* More fixes
* Make everything compile *yeah*
* Make manual-seal compile
* More fixes
* Start fixing Aura
* Fix Aura tests
* Fix Babe tests
* Make everything compile
* Move code around and switch to async_trait
* Fix Babe
* Docs docs docs
* Move to FRAME
* Fix fix fix
* Make everything compile
* Last cleanups
* Fix integration test
* Change slot usage of the timestamp
* We really need to switch to `impl-trait-for-tuples`
* Update primitives/inherents/src/lib.rs
Co-authored-by: André Silva <123550+andresilva@users.noreply.github.com>
* Update primitives/inherents/src/lib.rs
Co-authored-by: André Silva <123550+andresilva@users.noreply.github.com>
* Update primitives/inherents/src/lib.rs
Co-authored-by: André Silva <123550+andresilva@users.noreply.github.com>
* Some extra logging
* Remove dbg!
* Update primitives/consensus/common/src/import_queue/basic_queue.rs
Co-authored-by: André Silva <123550+andresilva@users.noreply.github.com>
Co-authored-by: André Silva <123550+andresilva@users.noreply.github.com>
* generate accessor to PalletInfo information on pallet placeholder
* remove unused
* use trait, and add tests
* less verbose doc
* add PalletInfoAccess to prelude for ease usage
* prototype for shawn
* Clean and document it
* Add more docs
* Move imports
* Some changes for easier compat.
* revert exmaple pallet
* rename
* BoundedVec for AccountLocks (#8580)
* Example with balances
* Fix tests
* Make it indexable
* fix
* Fix tests
* fix test
* Fix collective as well
* Fix test
* Update frame/support/src/storage/mod.rs
Co-authored-by: Peter Goodspeed-Niklaus <coriolinus@users.noreply.github.com>
* Repot and add for value
* Add for map and double map
* Final touches.
* Update frame/support/src/storage/bounded_vec.rs
Co-authored-by: Guillaume Thiolliere <gui.thiolliere@gmail.com>
* Add a few more tests
* Add import
Co-authored-by: Peter Goodspeed-Niklaus <coriolinus@users.noreply.github.com>
Co-authored-by: Guillaume Thiolliere <gui.thiolliere@gmail.com>
* Init `RuntimeLogger` automatically for each runtime api call
This pr change the runtime api in such a way to always and automatically
enable the `RuntimeLogger`. This enables the user to use `log` or
`tracing` from inside the runtime to create log messages. As logging
introduces some extra code and especially increases the size of the wasm
blob. It is advised to disable all logging completely with
`sp-api/disable-logging` when doing the wasm builds for the on-chain
wasm runtime.
Besides these changes, the pr also brings most of the logging found in
frame to the same format "runtime::*".
* Update frame/im-online/src/lib.rs
Co-authored-by: Guillaume Thiolliere <gui.thiolliere@gmail.com>
* Update test-utils/runtime/Cargo.toml
* Fix test
* Don't use tracing in the runtime, as we don't support it :D
* Fixes
Co-authored-by: Guillaume Thiolliere <gui.thiolliere@gmail.com>
* A clean new attempt
* Checkpoint to move remote.
* A lot of dependency wiring to make it feature gated.
* bad macro, bad macro.
* Undo the DB mess.
* Update frame/support/src/traits.rs
Co-authored-by: Alexander Popiak <alexander.popiak@parity.io>
* Apply suggestions from code review
Co-authored-by: Alexander Popiak <alexander.popiak@parity.io>
* unbreak the build
* Better logging and ids for migrations
* Fix doc.
* Test
* Update frame/try-runtime/src/lib.rs
Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com>
* Update utils/frame/try-runtime/cli/Cargo.toml
Co-authored-by: Shawn Tabrizi <shawntabrizi@gmail.com>
* Update frame/try-runtime/Cargo.toml
Co-authored-by: Shawn Tabrizi <shawntabrizi@gmail.com>
* Address most review grumbles.
* Fix build
* Add some comments
* Remove allowing one pallet at a time.
* Rework the PR
* nit
* Slightly better error handling.
* Remove files
* Update utils/frame/remote-externalities/src/lib.rs
Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com>
* Update frame/support/src/dispatch.rs
* Update frame/support/src/dispatch.rs
* Fix test
* Make extension trait.
* Bring back try-runtime/std
* remove bincode
* Remove warning
* Change test features
Co-authored-by: Alexander Popiak <alexander.popiak@parity.io>
Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com>
Co-authored-by: Shawn Tabrizi <shawntabrizi@gmail.com>
* Prep: move things around to suggested order
* Compiles, tests pass
* cleanup
* cleanup 2
* Fix dead doc-links
* Add back documentation for storage items
* Switch benchmarks to use `Event` rather than `RawEvent`.
* Update frame/assets/src/lib.rs
Co-authored-by: Guillaume Thiolliere <gui.thiolliere@gmail.com>
* reviwe feedback
* Obey line length checks
Co-authored-by: Guillaume Thiolliere <gui.thiolliere@gmail.com>
* Fix weight syntax in comments
* Mention to add `IsType` bound
* Link to subsee
* Fix link
* Update frame/support/procedural/src/pallet/parse/call.rs
Co-authored-by: David <dvdplm@gmail.com>
* Apply review suggestion from @dvdplm, make StorageInstance doc link
* fix ui test
Co-authored-by: David <dvdplm@gmail.com>
Co-authored-by: thiolliere <gui.thiolliere@gmail.com>
* Don't mutate storage when account is dead and should stay dead
* cargo run --release --features=runtime-benchmarks --manifest-path=bin/node/cli/Cargo.toml -- benchmark --chain=dev --steps=50 --repeat=20 --pallet=pallet_balances --extrinsic=* --execution=wasm --wasm-execution=compiled --heap-pages=4096 --output=./frame/balances/src/weights.rs --template=./.maintain/frame-weight-template.hbs
* more concrete storage noop
Co-authored-by: Parity Benchmarking Bot <admin@parity.io>
* improve error message on where clause on pallet error
* Revert "improve error message on where clause on pallet error"
This reverts commit 5a3cc38976813fccef3357833553ce30f5b988ea.
* Revert "Revert "improve error message on where clause on pallet error""
This reverts commit e3b3fca6bc4fa89816f80dbcb82dc4536a9b2549.
* 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>
* 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>
* 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>
* Move `IsSubType` and write some docs for the trait
This moves the `IsSubType` trait from dispatch.rs to traits.rs. It also
adds docs to make the trait better understandable.
* Update frame/support/src/traits.rs
Co-authored-by: Shawn Tabrizi <shawntabrizi@gmail.com>
Co-authored-by: Shawn Tabrizi <shawntabrizi@gmail.com>
* 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>