Oliver Tale-Yazdi
9543d31474
[FRAME] Runtime Omni Bencher ( #3512 )
...
This MR contains two major changes and some maintenance cleanup.
## 1. Free Standing Pallet Benchmark Runner
Closes https://github.com/paritytech/polkadot-sdk/issues/3045 , depends
on your runtime exposing the `GenesisBuilderApi` (like
https://github.com/paritytech/polkadot-sdk/pull/1492 ).
Introduces a new binary crate: `frame-omni-bencher`.
It allows to directly benchmark a WASM blob - without needing a node or
chain spec.
This makes it much easier to generate pallet weights and should allow us
to remove bloaty code from the node.
It should work for all FRAME runtimes that dont use 3rd party host calls
or non `BlakeTwo256` block hashing (basically all polkadot parachains
should work).
It is 100% backwards compatible with the old CLI args, when the `v1`
compatibility command is used. This is done to allow for forwards
compatible addition of new commands.
### Example (full example in the Rust docs)
Installing the CLI:
```sh
cargo install --locked --path substrate/utils/frame/omni-bencher
frame-omni-bencher --help
```
Building the Westend runtime:
```sh
cargo build -p westend-runtime --release --features runtime-benchmarks
```
Benchmarking the runtime:
```sh
frame-omni-bencher v1 benchmark pallet --runtime target/release/wbuild/westend-runtime/westend_runtime.compact.compressed.wasm --all
```
## 2. Building the Benchmark Genesis State in the Runtime
Closes https://github.com/paritytech/polkadot-sdk/issues/2664
This adds `--runtime` and `--genesis-builder=none|runtime|spec`
arguments to the `benchmark pallet` command to make it possible to
generate the genesis storage by the runtime. This can be used with both
the node and the freestanding benchmark runners. It utilizes the new
`GenesisBuilder` RA and depends on having
https://github.com/paritytech/polkadot-sdk/pull/3412 deployed.
## 3. Simpler args for `PalletCmd::run`
You can do three things here to integrate the changes into your node:
- nothing: old code keeps working as before but emits a deprecated
warning
- delete: remove the pallet benchmarking code from your node and use the
omni-bencher instead
- patch: apply the patch below and keep using as currently. This emits a
deprecated warning at runtime, since it uses the old way to generate a
genesis state, but is the smallest change.
```patch
runner.sync_run(|config| cmd
- .run::<HashingFor<Block>, ReclaimHostFunctions>(config)
+ .run_with_spec::<HashingFor<Block>, ReclaimHostFunctions>(Some(config.chain_spec))
)
```
## 4. Maintenance Change
- `pallet-nis` get a `BenchmarkSetup` config item to prepare its
counterparty asset.
- Add percent progress print when running benchmarks.
- Dont immediately exit on benchmark error but try to run as many as
possible and print errors last.
---------
Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io >
Co-authored-by: Liam Aharon <liam.aharon@hotmail.com >
2024-04-08 16:03:56 +00:00
Oliver Tale-Yazdi
2c0993d0c0
pallet nis: remove benchmarking hack ( #13759 )
...
* pallet nis: remove benchmark hack
Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io >
* NearestPrefDown -> Down
Tested on the kitchensink and in case that
n = 10000000000000000 and d = 12000100600000000000000 it rounds the
Perquintill up (correctly) since 833326347280+47318160/60000503 should round up.
That triggers the path 'amount <= on_hold' in L736.
Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io >
---------
Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io >
2023-04-11 14:53:16 +01:00
Oliver Tale-Yazdi
dda99e9ca9
Hotfix NIS benchmark ( #13651 )
...
* Hotfix NIS rounding error
Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io >
* Also fix communal
Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io >
---------
Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io >
2023-03-20 12:34:36 +00:00
Gavin Wood
5d81f23f8f
Deprecate Currency; introduce holds and freezing into fungible traits ( #12951 )
...
* First reworking of fungibles API
* New API and docs
* More fungible::* API improvements
* New ref-counting logic for old API
* Missing files
* Fixes
* Use the new transfer logic
* Use fungibles for the dispatchables
* Use shelve/restore names
* Locking works with total balance.
* repotting and removal
* Separate Holds from Reserves
* Introduce freezes
* Missing files
* Tests for freezing
* Fix hold+freeze combo
* More tests
* Fee-free dispatchable for upgrading accounts
* Benchmarks and a few fixes
* Another test
* Docs and refactor to avoid blanket impls
* Repot
* Fit out ItemOf fully
* Add events to Balanced traits
* Introduced events into Hold traits
* Fix Assets pallet tests
* Assets benchmarks pass
* Missing files and fixes
* Fixes
* Fixes
* Benchmarks fixes
* Fix balance benchmarks
* Formatting
* Expose fungible sub modules
* Move NIS to fungible API
* Fix broken impl and add test
* Fix tests
* API for `transfer_and_hold`
* Use composite APIs
* Formatting
* Upgraded event
* Fixes
* Fixes
* Fixes
* Fixes
* Repot tests and some fixed
* Fix some bits
* Fix dust tests
* Rename `set_balance`
- `Balances::set_balance` becomes `Balances::force_set_balance`
- `Unbalanced::set_balance` becomes `Unbalances::write_balance`
* becomes
* Move dust handling to fungibles API
* Formatting
* Fixes and more refactoring
* Fixes
* Fixes
* Fixes
* Fixes
* Fixes
* Fixes
* Fixes
* Fixes
* Fixes
* Use reducible_balance for better correctness on fees
* Reducing hold to zero should remove entry.
* Add test
* Docs
* Update frame/support/src/traits/tokens/fungibles/hold.rs
Co-authored-by: Muharem Ismailov <ismailov.m.h@gmail.com >
* Update frame/support/src/traits/tokens/fungibles/regular.rs
Co-authored-by: Muharem Ismailov <ismailov.m.h@gmail.com >
* Update frame/support/src/traits/tokens/fungible/hold.rs
Co-authored-by: Muharem Ismailov <ismailov.m.h@gmail.com >
* Update frame/support/src/traits/tokens/fungible/regular.rs
Co-authored-by: Muharem Ismailov <ismailov.m.h@gmail.com >
* Docs
* Docs
* Docs
* Fix NIS benchmarks
* Doc comment
* Remove post_mutation
* Fix some tests
* Fix some grumbles
* Enumify bool args to fungible(s) functions
* Fix up assets and balances
* Formatting
* Fix contracts
* Fix tests & benchmarks build
* Typify minted boolean arg
* Typify on_hold boolean arg; renames
* Fix numerous tests
* Fix dependency issue
* Privatize dangerous API mutate_account
* Fix contracts (@alext - please check this commit)
* Remove println
* Fix tests for contracts
* Fix broken rename
* Fix broken rename
* Fix broken rename
* Docs
* Update frame/support/src/traits/tokens/fungible/hold.rs
Co-authored-by: Anthony Alaribe <anthonyalaribe@gmail.com >
* remove from_ref_time
* Update frame/executive/src/lib.rs
Co-authored-by: Anthony Alaribe <anthonyalaribe@gmail.com >
* Update frame/executive/src/lib.rs
Co-authored-by: Anthony Alaribe <anthonyalaribe@gmail.com >
* Reenable test
* Update frame/support/src/traits/tokens/fungibles/hold.rs
Co-authored-by: Anthony Alaribe <anthonyalaribe@gmail.com >
* Update frame/support/src/traits/tokens/fungible/hold.rs
Co-authored-by: Anthony Alaribe <anthonyalaribe@gmail.com >
* Update frame/support/src/traits/tokens/fungible/hold.rs
Co-authored-by: Anthony Alaribe <anthonyalaribe@gmail.com >
* Update frame/support/src/traits/tokens/fungible/hold.rs
Co-authored-by: Anthony Alaribe <anthonyalaribe@gmail.com >
* Update frame/support/src/traits/tokens/currency.rs
Co-authored-by: Anthony Alaribe <anthonyalaribe@gmail.com >
* Update frame/lottery/src/tests.rs
Co-authored-by: Anthony Alaribe <anthonyalaribe@gmail.com >
* Update frame/support/src/traits/tokens/fungible/mod.rs
Co-authored-by: Anthony Alaribe <anthonyalaribe@gmail.com >
* Update frame/support/src/traits/tokens/fungible/regular.rs
Co-authored-by: Anthony Alaribe <anthonyalaribe@gmail.com >
* Update frame/support/src/traits/tokens/fungibles/freeze.rs
Co-authored-by: Anthony Alaribe <anthonyalaribe@gmail.com >
* Update frame/support/src/traits/tokens/fungible/regular.rs
Co-authored-by: Anthony Alaribe <anthonyalaribe@gmail.com >
* Update frame/support/src/traits/tokens/fungibles/hold.rs
Co-authored-by: Anthony Alaribe <anthonyalaribe@gmail.com >
* Update frame/support/src/traits/tokens/fungibles/hold.rs
Co-authored-by: Anthony Alaribe <anthonyalaribe@gmail.com >
* Update frame/support/src/traits/tokens/fungibles/hold.rs
Co-authored-by: Anthony Alaribe <anthonyalaribe@gmail.com >
* Rename UnwantedRemoval to UnwantedAccountRemoval
* Docs
* Formatting
* Update frame/balances/src/lib.rs
Co-authored-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io >
* Update primitives/runtime/src/lib.rs
Co-authored-by: Keith Yeung <kungfukeith11@gmail.com >
* handle_raw_dust oes nothing
* Formatting
* Fixes
* Grumble
* Fixes
* Add test
* Add test
* Tests for reducible_balance
* Fixes
* Fix Salary
* Fixes
* Disable broken test
* Disable nicely
* Fixes
* Fixes
* Fixes
* Rename some events
* Fix nomination pools breakage
* Add compatibility stub for transfer tx
* Reinstate a safely compatible version of Balances set_balance
* Fixes
* Grumble
* Update frame/nis/src/lib.rs
Co-authored-by: Kian Paimani <5588131+kianenigma@users.noreply.github.com >
* ".git/.scripts/commands/bench/bench.sh" pallet dev pallet_balances
* disable flakey tests
* Update frame/balances/src/lib.rs
Co-authored-by: Kian Paimani <5588131+kianenigma@users.noreply.github.com >
* Grumbles
* Grumble
---------
Co-authored-by: Muharem Ismailov <ismailov.m.h@gmail.com >
Co-authored-by: Alexander Theißen <alex.theissen@me.com >
Co-authored-by: Anthony Alaribe <anthonyalaribe@gmail.com >
Co-authored-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io >
Co-authored-by: Keith Yeung <kungfukeith11@gmail.com >
Co-authored-by: Kian Paimani <5588131+kianenigma@users.noreply.github.com >
Co-authored-by: command-bot <>
2023-03-18 14:47:55 +00:00
Vivek Pandya
bc53b9a03a
Remove years from copyright notes. ( #13415 )
...
* Change copyright year to 2023 from 2022
* Fix incorrect update of copyright year
* Remove years from copy right header
* Fix remaining files
* Fix typo in a header and remove update-copyright.sh
2023-02-21 18:46:41 +00:00
Muharem Ismailov
3079a17c94
Benchmark's successful origin api update ( #13146 )
...
* try successful origin unimplemented by default
* error as a default impl for try_successful_origin
* remove successful_origin func of EnsureOrigin trait
* default impl -> unimplemented!()
* update EnsureOriginWithArg
* fix EnsureOriginWithArg
* prefix unused arg with underscore
* use try_successful_origin instead successful_origin, map err to Weightless
* fix tests
* remove default impl
* unwrap for indirect origin dep
* replace unwrap by expect with a message
---------
Co-authored-by: parity-processbot <>
2023-02-01 03:11:41 +01:00
Sam Johnson
c9361bed1a
migrate new benchmarking syntax from frame_support::benchmarking to frame_benchmarking::v2 ( #13235 )
...
* * re-export frame_support::benchmarking in frame_benchmarking::
* prefer use frame_benchmarking::*; in examples, etc
* switch to frame_benchmarking::v2
* completely migrate new benchmarking code out of frame_support
* fix doc links
* remove unneeded return
Co-authored-by: Bastian Köcher <git@kchr.de >
* remove another unneeded return
Co-authored-by: Bastian Köcher <git@kchr.de >
* properly export all macros in v1
* refactor existing frame_benchmarking imports to use ::v1
---------
Co-authored-by: Bastian Köcher <git@kchr.de >
2023-01-27 20:59:39 +00:00
Gavin Wood
cbcde28546
NIS should retain funds in reserve ( #12928 )
...
* Keep funds with receipt holder
* Counterpart is optional
* Use named reserves
* Tests
* Benchmarks
* Fixes
* Update frame/nis/src/lib.rs
Co-authored-by: Keith Yeung <kungfukeith11@gmail.com >
* Update frame/nis/src/lib.rs
Co-authored-by: Keith Yeung <kungfukeith11@gmail.com >
* Update frame/nis/src/lib.rs
* Update frame/nis/src/lib.rs
* Update frame/nis/src/tests.rs
* Update frame/nis/src/lib.rs
Co-authored-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io >
* Update frame/nis/src/lib.rs
Co-authored-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io >
* Update frame/nis/src/lib.rs
Co-authored-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io >
* Update frame/nis/src/lib.rs
* Update frame/nis/src/lib.rs
* Update frame/nis/src/lib.rs
* Update frame/nis/src/lib.rs
* Formatting
Co-authored-by: Keith Yeung <kungfukeith11@gmail.com >
Co-authored-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io >
2023-01-17 11:37:59 -03:00
Gavin Wood
2a0e53d11a
Non-Interactive Staking ( #12610 )
...
* Improve naming.
* More improvements to naming
* Fungible counterpart
* Shared pot instead of reserve
* Transferable receipts
* Better naming
* Use u128 for counterpart
* Partial thawing
* Docs
* Remove AdminOrigin
* Integrate into Kitchen Sink
* Thaw throttling
* Remove todo
* Docs
* Fix benchmarks
* Building
* Tests work
* New benchmarks
* Benchmarking tests
* Test new defensive_saturating_* functions
Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io >
* fmt
Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io >
* Formatting
* Update frame/nis/src/lib.rs
Co-authored-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io >
* Apply suggestions from code review
Co-authored-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io >
* Events added
* Fix kitchensink
* Update frame/nis/src/lib.rs
Co-authored-by: Xiliang Chen <xlchen1291@gmail.com >
* Review niggles
* Remove genesis build requirements
* Grumbles
* Fixes
* Fixes
* Fixes
* Update frame/nis/src/lib.rs
Co-authored-by: Kian Paimani <5588131+kianenigma@users.noreply.github.com >
* Update primitives/runtime/src/traits.rs
Co-authored-by: Kian Paimani <5588131+kianenigma@users.noreply.github.com >
* Formatting
* Fixes
* Fix node genesis config
Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io >
* Fix node chain specs
Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io >
* Use free asset ID as counterpart
Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io >
* Account for rounding errors in fund_deficit bench
Relaxes the check for the NIS account balance in the fund_deficit bench
from equality from to checking for 99.999% equality. The exact deviation
for the kitchensink runtime config is 1.24e-10 percent but could vary if
the config is changed.
Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io >
* clippy
Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io >
* fmt
Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io >
* Fix
* Rename
* Fixes
* Fixes
* Formatting
Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io >
Co-authored-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io >
Co-authored-by: Xiliang Chen <xlchen1291@gmail.com >
Co-authored-by: Kian Paimani <5588131+kianenigma@users.noreply.github.com >
2022-12-05 13:37:52 +00:00