mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-12 07:41:08 +00:00
Try-runtime Revamp and Facelift (#12537)
* fix online/offline confusion * unified cache file * multi-threaded babyyy * checkpoint for niklas * compiles * all tests pass with --test-threads 1 * child-tree scrape is also multi-threaded now. * better thread splitting * some suggestions (#12532) * some suggestions * tokio multithread * move unused dependencies * snapshot command * fix rem * a bit of cleanup * support optional checks * fix * OCW command migrated to wasm-only, as an example * state-version management fully in remote-ext * almost everything move to wasm executor, some CLI flags reduced * follow-chain works as well * Master.into() * everything builds now * concurrent insertion and download for remote builds * minor fix * fix a bug * checkpoint * some updates * fmt * review comments * fmt * fix * fmt * update * fmt * rename * fix the damn UI tests * fmt * remoe the thread abstraction for the time being * cleanup * fix CI * fmt * fix * fix a few more things * tweak log levels * better error handling * address grumbles: use futures::mpsc * review comments * fmt * Apply suggestions from code review Co-authored-by: Bastian Köcher <git@kchr.de> * Update utils/frame/try-runtime/cli/src/lib.rs Co-authored-by: Bastian Köcher <git@kchr.de> * better api version stuff * some doc update * a whole lot of docs * fmt * fix all docs * fmt * rpc rebase: Try-runtime Revamp and Facelift (#12921) * Introduce sensible weight constants (#12868) * Introduce sensible weight constants * cargo fmt * Remove unused import * Add missing import * ".git/.scripts/bench-bot.sh" pallet dev pallet_lottery Co-authored-by: command-bot <> * Checkout to the branch HEAD explicitly in `build-linux-substrate` (#12876) * cli: Improve pruning documentation (#12819) * cli: Improve pruning documentation Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * cli: Keep `finalized` notation and remove `canonical` one * cli: Fix cargo doc * cli: `PruningModeClap` IR enum Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * cli: Convert PruningModeClap into pruning modes Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * cli: Use `PruningModeClap` Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * cli: Rename to `DatabasePruningMode` Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * cli: Implement `FromStr` instead of `clap::ValueEnum` Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * Update client/cli/src/params/pruning_params.rs Co-authored-by: Bastian Köcher <git@kchr.de> * Fix clippy Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * cli: Add option documentation back Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * Apply suggestions from code review Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> Co-authored-by: Bastian Köcher <git@kchr.de> * Revert "Move LockableCurrency trait to fungibles::Lockable and deprecate LockableCurrency (#12798)" (#12882) This reverts commit9a014d1ecd. * Don't indefinitely block on shutting down Tokio (#12885) * Don't indefinitely on shutting down Tokio Now we wait in maximum 60 seconds before we shutdown the node. Tasks are may be leaked and leading to some data corruption. * Drink less :thinking_face: * General Message Queue Pallet (#12485) * The message queue * Make fully generic * Refactor * Docs * Refactor * Use iter not slice * Per-origin queues * Multi-queue processing * Introduce MaxReady * Remove MaxReady in favour of ready ring * Cleanups * ReadyRing and tests * Stale page reaping * from_components -> from_parts Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Move WeightCounter to sp_weights Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Add MockedWeightInfo Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Deploy to kitchensink Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Use WeightCounter Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Small fixes and logging Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Add service_page Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Typo Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Move service_page below service_queue Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Add service_message Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Use correct weight function Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Overweight execution * Refactor * Missing file * Fix WeightCounter usage in scheduler Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Fix peek_index Take into account that decoding from a mutable slice modifies it. Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Add tests and bench service_page_item Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Add debug_info Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Add no-progress check to service_queues Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Add more benches Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Bound from_message and try_append_message Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Add PageReaped event Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Rename BookStateOf and BookStateFor Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Update tests and remove logging Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Remove redundant per-message origins; add footprint() and sweep_queue() * Move testing stuff to mock.rs Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Add integration test Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Fix no-progress check Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Fix debug_info Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Fixup merge and tests Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Fix footprint tracking * Introduce * Formatting * OverweightEnqueued event, auto-servicing config item * Update tests and benchmarks Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Clippy Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Add tests Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Provide change handler * Add missing BookStateFor::insert and call QueueChangeHandler Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Docs Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Update benchmarks and weights Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * More tests... Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Use weight metering functions Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * weightInfo::process_message_payload is gone Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Add defensive_saturating_accrue Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Rename WeightCounter to WeightMeter Ctr+Shift+H should do the trick. Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Test on_initialize Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Add module docs Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Remove origin from MaxMessageLen The message origin is not encoded into the heap and does therefore not influence the max message length anymore. Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Add BoundedVec::as_slice Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Test Page::{from_message, try_append_message} Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Fixup docs Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Docs * Do nothing in sweep_queue if the queue does not exist ... otherwise it inserts default values into the storage. Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Test ring (un)knitting Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Upgrade stress-test Change the test to not assume that all queued messages will be processed in the next block but split it over multiple. Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * More tests... Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Beauty fixes Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * clippy Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Rename BoundedVec::as_slice to as_bounded_slice Conflicts with deref().as_slice() otherwise. Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Fix imports Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Remove ReadyRing struct Was used for testing only. Instead use 'fn assert_ring' which also check the service head and backlinks. Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Beauty fixes Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Fix stale page watermark Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Cleanup Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Fix test feature and clippy Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * QueueChanged handler is called correctly Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Update benches Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Abstract testing functions Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * More tests Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Cleanup 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> * Simplify tests Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Make stuff compile Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Extend overweight execution benchmark Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Remove TODOs Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Test service queue with faulty MessageProcessor Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * fmt Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Update pallet ui tests to 1.65 Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * More docs Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Review doc fixes Co-authored-by: Robert Klotzner <eskimor@users.noreply.github.com> Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Add weight_limit to extrinsic weight of execute_overweight * Correctly return unused weight * Return actual weight consumed in do_execute_overweight * Review fixes Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Set version 7.0.0-dev Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Make it compile Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Switch message_size to u64 Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Switch message_count to u64 Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Fix benchmarks Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Make CI green Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Docs * Update tests Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * ".git/.scripts/bench-bot.sh" pallet dev pallet_message_queue * Dont mention README.md in the Cargo.toml Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Remove reference to readme 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: parity-processbot <> Co-authored-by: Robert Klotzner <eskimor@users.noreply.github.com> Co-authored-by: Keith Yeung <kungfukeith11@gmail.com> * zombienet timings adjusted (#12890) * zombinet tests: add some timeout to allow net spin-up Sometimes tests are failing at first try, as the pods were not up yet. Adding timeout should allow the network to spin up properly. * initial timeout increased to 30s * Move import queue out of `sc-network` (#12764) * Move import queue out of `sc-network` Add supplementary asynchronous API for the import queue which means it can be run as an independent task and communicated with through the `ImportQueueService`. This commit removes removes block and justification imports from `sc-network` and provides `ChainSync` with a handle to import queue so it can import blocks and justifications. Polling of the import queue is moved complete out of `sc-network` and `sc_consensus::Link` is implemented for `ChainSyncInterfaceHandled` so the import queue can still influence the syncing process. * Fix tests * Apply review comments * Apply suggestions from code review Co-authored-by: Bastian Köcher <git@kchr.de> * Update client/network/sync/src/lib.rs Co-authored-by: Bastian Köcher <git@kchr.de> Co-authored-by: Bastian Köcher <git@kchr.de> * Trace response payload in default `jsonrpsee` middleware (#12886) * Trace result in default `jsonrpsee` middleware * `rpc_metrics::extra` Co-authored-by: Bastian Köcher <git@kchr.de> Co-authored-by: Bastian Köcher <git@kchr.de> * Ensure that we inform all tasks to stop before starting the 60 seconds shutdown (#12897) * Ensure that we inform all tasks to stop before starting the 60 seconds shutdown The change of waiting in maximum 60 seconds for the node to shutdown actually introduced a bug. We were actually waiting always 60 seconds as we didn't informed our tasks to shutdown. The solution to this problem is to drop the task manager as this will then inform all tasks to end. It also adds tests to ensure that the behaviors work as expected. (This should already have been done in the first pr! :() * ".git/.scripts/fmt.sh" 1 Co-authored-by: command-bot <> * Safe desired targets call (#12826) * checked call for desired targets * fix compile * fmt * fix tests * cleaner with and_then * Fix typo (#12900) * ValidateUnsigned: Improve docs. (#12870) * ValidateUnsigned: Improve docs. * Review comments * rpc server with HTTP/WS on the same socket (#12663) * jsonrpsee v0.16 add backwards compatibility run old http server on http only * cargo fmt * update jsonrpsee 0.16.1 * less verbose cors log * fix nit in log: WS -> HTTP * revert needless changes in Cargo.lock * remove unused features in tower * fix nits; add client-core feature * jsonrpsee v0.16.2 * `pallet-message-queue`: Fix license (#12895) * Fix license Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Add mock doc Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Use explicit call indices (#12891) * frame-system: explicit call index Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Use explicit call indices Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * pallet-template: explicit call index Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * DNM: Temporarily require call_index Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Revert "DNM: Temporarily require call_index" This reverts commit c4934e312e12af72ca05a8029d7da753a9c99346. Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Pin canonincalized block (#12902) * Remove implicit approval chilling upon slash. (#12420) * don't read slashing spans when taking election snapshot * update cargo.toml * bring back remote test * fix merge stuff * fix npos-voters function sig * remove as much redundant diff as you can * Update frame/staking/src/pallet/mod.rs Co-authored-by: Andronik <write@reusable.software> * fix * Update frame/staking/src/pallet/impls.rs * update lock * fix all tests * review comments * fmt * fix offence bench * clippy * ".git/.scripts/bench-bot.sh" pallet dev pallet_staking Co-authored-by: Andronik <write@reusable.software> Co-authored-by: Ankan <ankan.anurag@gmail.com> Co-authored-by: command-bot <> * bounties calls docs fix (#12909) Co-authored-by: parity-processbot <> * pallet-contracts migration pre-upgrade fix for v8 (#12905) * Only run pre-v8 migration check for versions older than 8 * Logix fix * use custom environment for publishing crates (#12912) * [contracts] Add debug buffer limit + enforcement (#12845) * Add debug buffer limit + enforcement Add debug buffer limit + enforcement * use BoundedVec for the debug buffer * revert schedule (debug buf len limit not needed anymore) * return DispatchError * addressed review comments * frame/remote-externalities: Fix clippy Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * frame/rpc: Add previous export Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * Fixup some wrong dependencies (#12899) * Fixup some wrong dependencies Dev dependencies should not appear in the feature list. If features are required, they should be directly enabled for the `dev-dependency`. * More fixups * Fix fix * Remove deprecated feature * Make all work properly and nice!! * FMT * Fix formatting * add numerator and denominator to Rational128 Debug impl and increase precision of float representation (#12914) * Fix state-db pinning (#12927) * Pin all canonicalized blocks * Added a test * Docs * [ci] add job switcher (#12922) Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> Co-authored-by: Keith Yeung <kungfukeith11@gmail.com> Co-authored-by: Vlad <vladimir@parity.io> Co-authored-by: Bastian Köcher <git@kchr.de> Co-authored-by: Anthony Alaribe <anthonyalaribe@gmail.com> Co-authored-by: Gavin Wood <gavin@parity.io> Co-authored-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> Co-authored-by: Robert Klotzner <eskimor@users.noreply.github.com> Co-authored-by: Michal Kucharczyk <1728078+michalkucharczyk@users.noreply.github.com> Co-authored-by: Aaro Altonen <48052676+altonen@users.noreply.github.com> Co-authored-by: tgmichel <telmo@purestake.com> Co-authored-by: Ankan <10196091+Ank4n@users.noreply.github.com> Co-authored-by: Luke Schoen <ltfschoen@users.noreply.github.com> Co-authored-by: Niklas Adolfsson <niklasadolfsson1@gmail.com> Co-authored-by: Arkadiy Paronyan <arkady.paronyan@gmail.com> Co-authored-by: Kian Paimani <5588131+kianenigma@users.noreply.github.com> Co-authored-by: Andronik <write@reusable.software> Co-authored-by: Ankan <ankan.anurag@gmail.com> Co-authored-by: Muharem Ismailov <ismailov.m.h@gmail.com> Co-authored-by: Dino Pačandi <3002868+Dinonard@users.noreply.github.com> Co-authored-by: João Paulo Silva de Souza <77391175+joao-paulo-parity@users.noreply.github.com> Co-authored-by: Sasha Gryaznov <hi@agryaznov.com> Co-authored-by: Alexander Popiak <alexander.popiak@parity.io> Co-authored-by: Alexander Samusev <41779041+alvicsam@users.noreply.github.com> * Revert "rpc rebase: Try-runtime Revamp and Facelift (#12921)" This reverts commit 4ce770a9cb8daf1401529bda7d974b8c703f6b3e. * Lexnv/kiz revamp try runtime stuff (#12932) * Introduce sensible weight constants (#12868) * Introduce sensible weight constants * cargo fmt * Remove unused import * Add missing import * ".git/.scripts/bench-bot.sh" pallet dev pallet_lottery Co-authored-by: command-bot <> * Checkout to the branch HEAD explicitly in `build-linux-substrate` (#12876) * cli: Improve pruning documentation (#12819) * cli: Improve pruning documentation Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * cli: Keep `finalized` notation and remove `canonical` one * cli: Fix cargo doc * cli: `PruningModeClap` IR enum Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * cli: Convert PruningModeClap into pruning modes Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * cli: Use `PruningModeClap` Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * cli: Rename to `DatabasePruningMode` Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * cli: Implement `FromStr` instead of `clap::ValueEnum` Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * Update client/cli/src/params/pruning_params.rs Co-authored-by: Bastian Köcher <git@kchr.de> * Fix clippy Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * cli: Add option documentation back Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * Apply suggestions from code review Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> Co-authored-by: Bastian Köcher <git@kchr.de> * Revert "Move LockableCurrency trait to fungibles::Lockable and deprecate LockableCurrency (#12798)" (#12882) This reverts commit9a014d1ecd. * Don't indefinitely block on shutting down Tokio (#12885) * Don't indefinitely on shutting down Tokio Now we wait in maximum 60 seconds before we shutdown the node. Tasks are may be leaked and leading to some data corruption. * Drink less :thinking_face: * General Message Queue Pallet (#12485) * The message queue * Make fully generic * Refactor * Docs * Refactor * Use iter not slice * Per-origin queues * Multi-queue processing * Introduce MaxReady * Remove MaxReady in favour of ready ring * Cleanups * ReadyRing and tests * Stale page reaping * from_components -> from_parts Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Move WeightCounter to sp_weights Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Add MockedWeightInfo Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Deploy to kitchensink Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Use WeightCounter Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Small fixes and logging Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Add service_page Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Typo Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Move service_page below service_queue Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Add service_message Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Use correct weight function Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Overweight execution * Refactor * Missing file * Fix WeightCounter usage in scheduler Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Fix peek_index Take into account that decoding from a mutable slice modifies it. Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Add tests and bench service_page_item Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Add debug_info Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Add no-progress check to service_queues Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Add more benches Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Bound from_message and try_append_message Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Add PageReaped event Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Rename BookStateOf and BookStateFor Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Update tests and remove logging Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Remove redundant per-message origins; add footprint() and sweep_queue() * Move testing stuff to mock.rs Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Add integration test Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Fix no-progress check Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Fix debug_info Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Fixup merge and tests Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Fix footprint tracking * Introduce * Formatting * OverweightEnqueued event, auto-servicing config item * Update tests and benchmarks Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Clippy Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Add tests Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Provide change handler * Add missing BookStateFor::insert and call QueueChangeHandler Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Docs Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Update benchmarks and weights Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * More tests... Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Use weight metering functions Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * weightInfo::process_message_payload is gone Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Add defensive_saturating_accrue Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Rename WeightCounter to WeightMeter Ctr+Shift+H should do the trick. Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Test on_initialize Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Add module docs Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Remove origin from MaxMessageLen The message origin is not encoded into the heap and does therefore not influence the max message length anymore. Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Add BoundedVec::as_slice Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Test Page::{from_message, try_append_message} Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Fixup docs Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Docs * Do nothing in sweep_queue if the queue does not exist ... otherwise it inserts default values into the storage. Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Test ring (un)knitting Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Upgrade stress-test Change the test to not assume that all queued messages will be processed in the next block but split it over multiple. Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * More tests... Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Beauty fixes Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * clippy Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Rename BoundedVec::as_slice to as_bounded_slice Conflicts with deref().as_slice() otherwise. Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Fix imports Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Remove ReadyRing struct Was used for testing only. Instead use 'fn assert_ring' which also check the service head and backlinks. Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Beauty fixes Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Fix stale page watermark Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Cleanup Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Fix test feature and clippy Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * QueueChanged handler is called correctly Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Update benches Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Abstract testing functions Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * More tests Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Cleanup 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> * Simplify tests Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Make stuff compile Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Extend overweight execution benchmark Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Remove TODOs Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Test service queue with faulty MessageProcessor Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * fmt Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Update pallet ui tests to 1.65 Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * More docs Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Review doc fixes Co-authored-by: Robert Klotzner <eskimor@users.noreply.github.com> Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Add weight_limit to extrinsic weight of execute_overweight * Correctly return unused weight * Return actual weight consumed in do_execute_overweight * Review fixes Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Set version 7.0.0-dev Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Make it compile Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Switch message_size to u64 Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Switch message_count to u64 Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Fix benchmarks Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Make CI green Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Docs * Update tests Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * ".git/.scripts/bench-bot.sh" pallet dev pallet_message_queue * Dont mention README.md in the Cargo.toml Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Remove reference to readme 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: parity-processbot <> Co-authored-by: Robert Klotzner <eskimor@users.noreply.github.com> Co-authored-by: Keith Yeung <kungfukeith11@gmail.com> * zombienet timings adjusted (#12890) * zombinet tests: add some timeout to allow net spin-up Sometimes tests are failing at first try, as the pods were not up yet. Adding timeout should allow the network to spin up properly. * initial timeout increased to 30s * Move import queue out of `sc-network` (#12764) * Move import queue out of `sc-network` Add supplementary asynchronous API for the import queue which means it can be run as an independent task and communicated with through the `ImportQueueService`. This commit removes removes block and justification imports from `sc-network` and provides `ChainSync` with a handle to import queue so it can import blocks and justifications. Polling of the import queue is moved complete out of `sc-network` and `sc_consensus::Link` is implemented for `ChainSyncInterfaceHandled` so the import queue can still influence the syncing process. * Fix tests * Apply review comments * Apply suggestions from code review Co-authored-by: Bastian Köcher <git@kchr.de> * Update client/network/sync/src/lib.rs Co-authored-by: Bastian Köcher <git@kchr.de> Co-authored-by: Bastian Köcher <git@kchr.de> * Trace response payload in default `jsonrpsee` middleware (#12886) * Trace result in default `jsonrpsee` middleware * `rpc_metrics::extra` Co-authored-by: Bastian Köcher <git@kchr.de> Co-authored-by: Bastian Köcher <git@kchr.de> * Ensure that we inform all tasks to stop before starting the 60 seconds shutdown (#12897) * Ensure that we inform all tasks to stop before starting the 60 seconds shutdown The change of waiting in maximum 60 seconds for the node to shutdown actually introduced a bug. We were actually waiting always 60 seconds as we didn't informed our tasks to shutdown. The solution to this problem is to drop the task manager as this will then inform all tasks to end. It also adds tests to ensure that the behaviors work as expected. (This should already have been done in the first pr! :() * ".git/.scripts/fmt.sh" 1 Co-authored-by: command-bot <> * Safe desired targets call (#12826) * checked call for desired targets * fix compile * fmt * fix tests * cleaner with and_then * Fix typo (#12900) * ValidateUnsigned: Improve docs. (#12870) * ValidateUnsigned: Improve docs. * Review comments * rpc server with HTTP/WS on the same socket (#12663) * jsonrpsee v0.16 add backwards compatibility run old http server on http only * cargo fmt * update jsonrpsee 0.16.1 * less verbose cors log * fix nit in log: WS -> HTTP * revert needless changes in Cargo.lock * remove unused features in tower * fix nits; add client-core feature * jsonrpsee v0.16.2 * `pallet-message-queue`: Fix license (#12895) * Fix license Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Add mock doc Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Use explicit call indices (#12891) * frame-system: explicit call index Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Use explicit call indices Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * pallet-template: explicit call index Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * DNM: Temporarily require call_index Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Revert "DNM: Temporarily require call_index" This reverts commit c4934e312e12af72ca05a8029d7da753a9c99346. Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Pin canonincalized block (#12902) * Remove implicit approval chilling upon slash. (#12420) * don't read slashing spans when taking election snapshot * update cargo.toml * bring back remote test * fix merge stuff * fix npos-voters function sig * remove as much redundant diff as you can * Update frame/staking/src/pallet/mod.rs Co-authored-by: Andronik <write@reusable.software> * fix * Update frame/staking/src/pallet/impls.rs * update lock * fix all tests * review comments * fmt * fix offence bench * clippy * ".git/.scripts/bench-bot.sh" pallet dev pallet_staking Co-authored-by: Andronik <write@reusable.software> Co-authored-by: Ankan <ankan.anurag@gmail.com> Co-authored-by: command-bot <> * bounties calls docs fix (#12909) Co-authored-by: parity-processbot <> * pallet-contracts migration pre-upgrade fix for v8 (#12905) * Only run pre-v8 migration check for versions older than 8 * Logix fix * use custom environment for publishing crates (#12912) * [contracts] Add debug buffer limit + enforcement (#12845) * Add debug buffer limit + enforcement Add debug buffer limit + enforcement * use BoundedVec for the debug buffer * revert schedule (debug buf len limit not needed anymore) * return DispatchError * addressed review comments * frame/remote-externalities: Fix clippy Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * frame/rpc: Add previous export Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * Fixup some wrong dependencies (#12899) * Fixup some wrong dependencies Dev dependencies should not appear in the feature list. If features are required, they should be directly enabled for the `dev-dependency`. * More fixups * Fix fix * Remove deprecated feature * Make all work properly and nice!! * FMT * Fix formatting * add numerator and denominator to Rational128 Debug impl and increase precision of float representation (#12914) * Fix state-db pinning (#12927) * Pin all canonicalized blocks * Added a test * Docs * [ci] add job switcher (#12922) * Use LOG_TARGET in consensus related crates (#12875) * Use shared LOG_TARGET in consensus related crates * Rename target from "afg" to "grandpa" Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> Co-authored-by: Keith Yeung <kungfukeith11@gmail.com> Co-authored-by: Vlad <vladimir@parity.io> Co-authored-by: Alexandru Vasile <60601340+lexnv@users.noreply.github.com> Co-authored-by: Bastian Köcher <git@kchr.de> Co-authored-by: Anthony Alaribe <anthonyalaribe@gmail.com> Co-authored-by: Gavin Wood <gavin@parity.io> Co-authored-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> Co-authored-by: Robert Klotzner <eskimor@users.noreply.github.com> Co-authored-by: Michal Kucharczyk <1728078+michalkucharczyk@users.noreply.github.com> Co-authored-by: Aaro Altonen <48052676+altonen@users.noreply.github.com> Co-authored-by: tgmichel <telmo@purestake.com> Co-authored-by: Ankan <10196091+Ank4n@users.noreply.github.com> Co-authored-by: Luke Schoen <ltfschoen@users.noreply.github.com> Co-authored-by: Niklas Adolfsson <niklasadolfsson1@gmail.com> Co-authored-by: Arkadiy Paronyan <arkady.paronyan@gmail.com> Co-authored-by: Andronik <write@reusable.software> Co-authored-by: Ankan <ankan.anurag@gmail.com> Co-authored-by: Muharem Ismailov <ismailov.m.h@gmail.com> Co-authored-by: Dino Pačandi <3002868+Dinonard@users.noreply.github.com> Co-authored-by: João Paulo Silva de Souza <77391175+joao-paulo-parity@users.noreply.github.com> Co-authored-by: Sasha Gryaznov <hi@agryaznov.com> Co-authored-by: Alexandru Vasile <alexandru.vasile@parity.io> Co-authored-by: Alexander Popiak <alexander.popiak@parity.io> Co-authored-by: Alexander Samusev <41779041+alvicsam@users.noreply.github.com> Co-authored-by: Davide Galassi <davxy@datawok.net> * Revert "Lexnv/kiz revamp try runtime stuff (#12932)" This reverts commit 378cfb26d984bcde467781f07ef8ddb6998212cb. * fmt * update * fix publish Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> Co-authored-by: Niklas Adolfsson <niklasadolfsson1@gmail.com> Co-authored-by: Bastian Köcher <git@kchr.de> Co-authored-by: Alexandru Vasile <60601340+lexnv@users.noreply.github.com> Co-authored-by: Keith Yeung <kungfukeith11@gmail.com> Co-authored-by: Vlad <vladimir@parity.io> Co-authored-by: Anthony Alaribe <anthonyalaribe@gmail.com> Co-authored-by: Gavin Wood <gavin@parity.io> Co-authored-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> Co-authored-by: Robert Klotzner <eskimor@users.noreply.github.com> Co-authored-by: Michal Kucharczyk <1728078+michalkucharczyk@users.noreply.github.com> Co-authored-by: Aaro Altonen <48052676+altonen@users.noreply.github.com> Co-authored-by: tgmichel <telmo@purestake.com> Co-authored-by: Ankan <10196091+Ank4n@users.noreply.github.com> Co-authored-by: Luke Schoen <ltfschoen@users.noreply.github.com> Co-authored-by: Arkadiy Paronyan <arkady.paronyan@gmail.com> Co-authored-by: Andronik <write@reusable.software> Co-authored-by: Ankan <ankan.anurag@gmail.com> Co-authored-by: Muharem Ismailov <ismailov.m.h@gmail.com> Co-authored-by: Dino Pačandi <3002868+Dinonard@users.noreply.github.com> Co-authored-by: João Paulo Silva de Souza <77391175+joao-paulo-parity@users.noreply.github.com> Co-authored-by: Sasha Gryaznov <hi@agryaznov.com> Co-authored-by: Alexander Popiak <alexander.popiak@parity.io> Co-authored-by: Alexander Samusev <41779041+alvicsam@users.noreply.github.com> Co-authored-by: Alexandru Vasile <alexandru.vasile@parity.io> Co-authored-by: Davide Galassi <davxy@datawok.net>
This commit is contained in:
Generated
+65
-14
@@ -269,9 +269,9 @@ checksum = "e91831deabf0d6d7ec49552e489aed63b7456a7a3c46cff62adad428110b0af0"
|
||||
|
||||
[[package]]
|
||||
name = "async-trait"
|
||||
version = "0.1.58"
|
||||
version = "0.1.59"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1e805d94e6b5001b651426cf4cd446b1ab5f319d27bab5c644f61de0a804360c"
|
||||
checksum = "31e6e93155431f3931513b243d371981bb2770112b370c82745a1d19d2f99364"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
@@ -2031,6 +2031,7 @@ version = "0.10.0-dev"
|
||||
dependencies = [
|
||||
"env_logger",
|
||||
"frame-support",
|
||||
"futures",
|
||||
"log",
|
||||
"pallet-elections-phragmen",
|
||||
"parity-scale-codec",
|
||||
@@ -2042,6 +2043,7 @@ dependencies = [
|
||||
"sp-version",
|
||||
"substrate-rpc-client",
|
||||
"tokio",
|
||||
"tracing-subscriber 0.3.16",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -2874,9 +2876,9 @@ checksum = "879d54834c8c76457ef4293a689b2a8c59b076067ad77b15efafbb05f92a592b"
|
||||
|
||||
[[package]]
|
||||
name = "itertools"
|
||||
version = "0.10.3"
|
||||
version = "0.10.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a9a9d19fa1e79b6215ff29b9d6880b706147f16e9b1dbb1e4e5947b5b02bc5e3"
|
||||
checksum = "b0fd2260e829bddf4cb6ea802289de2f86d6a7a690192fbe91b3f46e0f2c8473"
|
||||
dependencies = [
|
||||
"either",
|
||||
]
|
||||
@@ -3788,6 +3790,15 @@ dependencies = [
|
||||
"regex-automata",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "matchers"
|
||||
version = "0.1.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8263075bb86c5a1b1427b5ae862e8889656f126e9f77c484496e8b47cf5c5558"
|
||||
dependencies = [
|
||||
"regex-automata",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "matches"
|
||||
version = "0.1.8"
|
||||
@@ -4271,6 +4282,7 @@ dependencies = [
|
||||
"sp-core",
|
||||
"sp-finality-grandpa",
|
||||
"sp-inherents",
|
||||
"sp-io",
|
||||
"sp-keyring",
|
||||
"sp-keystore",
|
||||
"sp-runtime",
|
||||
@@ -4427,6 +4439,7 @@ dependencies = [
|
||||
"sp-core",
|
||||
"sp-finality-grandpa",
|
||||
"sp-inherents",
|
||||
"sp-io",
|
||||
"sp-keyring",
|
||||
"sp-runtime",
|
||||
"sp-timestamp",
|
||||
@@ -4529,6 +4542,16 @@ version = "0.3.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "61807f77802ff30975e01f4f071c8ba10c022052f98b3294119f3e615d13e5be"
|
||||
|
||||
[[package]]
|
||||
name = "nu-ansi-term"
|
||||
version = "0.46.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "77a8165726e8236064dbb45459242600304b42a5ea24ee2948e18e023bf7ba84"
|
||||
dependencies = [
|
||||
"overload",
|
||||
"winapi",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "num-bigint"
|
||||
version = "0.4.3"
|
||||
@@ -4667,6 +4690,12 @@ dependencies = [
|
||||
"winapi",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "overload"
|
||||
version = "0.1.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b15813163c1d831bf4a13c3610c05c0d03b39feb07f7e09fa234dac9b15aaf39"
|
||||
|
||||
[[package]]
|
||||
name = "pallet-alliance"
|
||||
version = "4.0.0-dev"
|
||||
@@ -7585,7 +7614,7 @@ dependencies = [
|
||||
"substrate-test-runtime",
|
||||
"tempfile",
|
||||
"tracing",
|
||||
"tracing-subscriber",
|
||||
"tracing-subscriber 0.2.25",
|
||||
"wasmi 0.13.0",
|
||||
"wat",
|
||||
]
|
||||
@@ -8337,7 +8366,7 @@ dependencies = [
|
||||
"thiserror",
|
||||
"tracing",
|
||||
"tracing-log",
|
||||
"tracing-subscriber",
|
||||
"tracing-subscriber 0.2.25",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -8705,9 +8734,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "sharded-slab"
|
||||
version = "0.1.1"
|
||||
version = "0.1.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "79c719719ee05df97490f80a45acfc99e5a30ce98a1e4fb67aee422745ae14e3"
|
||||
checksum = "900fba806f70c630b0a382d0d825e17a0f19fcd059a2ade1ff237bcddf446b31"
|
||||
dependencies = [
|
||||
"lazy_static",
|
||||
]
|
||||
@@ -8763,9 +8792,9 @@ checksum = "03b634d87b960ab1a38c4fe143b508576f075e7c978bfad18217645ebfdfa2ec"
|
||||
|
||||
[[package]]
|
||||
name = "smallvec"
|
||||
version = "1.8.0"
|
||||
version = "1.10.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f2dd574626839106c320a323308629dcb1acfc96e32a8cba364ddc61ac23ee83"
|
||||
checksum = "a507befe795404456341dfab10cef66ead4c041f62b8b11bbb92bffe5d0953e0"
|
||||
|
||||
[[package]]
|
||||
name = "snap"
|
||||
@@ -9555,7 +9584,7 @@ dependencies = [
|
||||
"sp-std",
|
||||
"tracing",
|
||||
"tracing-core",
|
||||
"tracing-subscriber",
|
||||
"tracing-subscriber 0.2.25",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -10431,9 +10460,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "tracing-core"
|
||||
version = "0.1.28"
|
||||
version = "0.1.30"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7b7358be39f2f274f322d2aaed611acc57f382e8eb1e5b48cb9ae30933495ce7"
|
||||
checksum = "24eb03ba0eab1fd845050058ce5e616558e8f8d8fca633e6b163fe25c797213a"
|
||||
dependencies = [
|
||||
"once_cell",
|
||||
"valuable",
|
||||
@@ -10479,7 +10508,7 @@ dependencies = [
|
||||
"ansi_term",
|
||||
"chrono",
|
||||
"lazy_static",
|
||||
"matchers",
|
||||
"matchers 0.0.1",
|
||||
"parking_lot 0.11.2",
|
||||
"regex",
|
||||
"serde",
|
||||
@@ -10493,6 +10522,24 @@ dependencies = [
|
||||
"tracing-serde",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "tracing-subscriber"
|
||||
version = "0.3.16"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a6176eae26dd70d0c919749377897b54a9276bd7061339665dd68777926b5a70"
|
||||
dependencies = [
|
||||
"matchers 0.1.0",
|
||||
"nu-ansi-term",
|
||||
"once_cell",
|
||||
"regex",
|
||||
"sharded-slab",
|
||||
"smallvec",
|
||||
"thread_local",
|
||||
"tracing",
|
||||
"tracing-core",
|
||||
"tracing-log",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "treeline"
|
||||
version = "0.1.0"
|
||||
@@ -10605,6 +10652,7 @@ dependencies = [
|
||||
"clap 4.0.11",
|
||||
"frame-remote-externalities",
|
||||
"frame-try-runtime",
|
||||
"hex",
|
||||
"log",
|
||||
"parity-scale-codec",
|
||||
"sc-chain-spec",
|
||||
@@ -10612,10 +10660,13 @@ dependencies = [
|
||||
"sc-executor",
|
||||
"sc-service",
|
||||
"serde",
|
||||
"sp-api",
|
||||
"sp-core",
|
||||
"sp-debug-derive",
|
||||
"sp-externalities",
|
||||
"sp-io",
|
||||
"sp-keystore",
|
||||
"sp-rpc",
|
||||
"sp-runtime",
|
||||
"sp-state-machine",
|
||||
"sp-version",
|
||||
|
||||
@@ -36,6 +36,7 @@ sc-finality-grandpa = { version = "0.10.0-dev", path = "../../../client/finality
|
||||
sp-finality-grandpa = { version = "4.0.0-dev", path = "../../../primitives/finality-grandpa" }
|
||||
sc-client-api = { version = "4.0.0-dev", path = "../../../client/api" }
|
||||
sp-runtime = { version = "7.0.0", path = "../../../primitives/runtime" }
|
||||
sp-io = { version = "7.0.0", path = "../../../primitives/io" }
|
||||
sp-timestamp = { version = "4.0.0-dev", path = "../../../primitives/timestamp" }
|
||||
sp-inherents = { version = "4.0.0-dev", path = "../../../primitives/inherents" }
|
||||
sp-keyring = { version = "7.0.0", path = "../../../primitives/keyring" }
|
||||
|
||||
@@ -174,6 +174,8 @@ pub fn run() -> sc_cli::Result<()> {
|
||||
},
|
||||
#[cfg(feature = "try-runtime")]
|
||||
Some(Subcommand::TryRuntime(cmd)) => {
|
||||
use crate::service::ExecutorDispatch;
|
||||
use sc_executor::{sp_wasm_interface::ExtendedHostFunctions, NativeExecutionDispatch};
|
||||
let runner = cli.create_runner(cmd)?;
|
||||
runner.async_run(|config| {
|
||||
// we don't need any of the components of new_partial, just a runtime, or a task
|
||||
@@ -182,7 +184,13 @@ pub fn run() -> sc_cli::Result<()> {
|
||||
let task_manager =
|
||||
sc_service::TaskManager::new(config.tokio_handle.clone(), registry)
|
||||
.map_err(|e| sc_cli::Error::Service(sc_service::Error::Prometheus(e)))?;
|
||||
Ok((cmd.run::<Block, service::ExecutorDispatch>(config), task_manager))
|
||||
Ok((
|
||||
cmd.run::<Block, ExtendedHostFunctions<
|
||||
sp_io::SubstrateHostFunctions,
|
||||
<ExecutorDispatch as NativeExecutionDispatch>::ExtendHostFunctions,
|
||||
>>(),
|
||||
task_manager,
|
||||
))
|
||||
})
|
||||
},
|
||||
#[cfg(not(feature = "try-runtime"))]
|
||||
|
||||
@@ -539,22 +539,23 @@ impl_runtime_apis! {
|
||||
|
||||
#[cfg(feature = "try-runtime")]
|
||||
impl frame_try_runtime::TryRuntime<Block> for Runtime {
|
||||
fn on_runtime_upgrade() -> (Weight, Weight) {
|
||||
fn on_runtime_upgrade(checks: bool) -> (Weight, Weight) {
|
||||
// NOTE: intentional unwrap: we don't want to propagate the error backwards, and want to
|
||||
// have a backtrace here. If any of the pre/post migration checks fail, we shall stop
|
||||
// right here and right now.
|
||||
let weight = Executive::try_runtime_upgrade().unwrap();
|
||||
let weight = Executive::try_runtime_upgrade(checks).unwrap();
|
||||
(weight, BlockWeights::get().max_block)
|
||||
}
|
||||
|
||||
fn execute_block(
|
||||
block: Block,
|
||||
state_root_check: bool,
|
||||
signature_check: bool,
|
||||
select: frame_try_runtime::TryStateSelect
|
||||
) -> Weight {
|
||||
// NOTE: intentional unwrap: we don't want to propagate the error backwards, and want to
|
||||
// have a backtrace here.
|
||||
Executive::try_execute_block(block, state_root_check, select).expect("execute-block failed")
|
||||
Executive::try_execute_block(block, state_root_check, signature_check, select).expect("execute-block failed")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -59,6 +59,7 @@ sp-keystore = { version = "0.13.0", path = "../../../primitives/keystore" }
|
||||
sp-consensus = { version = "0.10.0-dev", path = "../../../primitives/consensus/common" }
|
||||
sp-transaction-pool = { version = "4.0.0-dev", path = "../../../primitives/transaction-pool" }
|
||||
sp-transaction-storage-proof = { version = "4.0.0-dev", path = "../../../primitives/transaction-storage-proof" }
|
||||
sp-io = { path = "../../../primitives/io" }
|
||||
|
||||
# client dependencies
|
||||
sc-client-api = { version = "4.0.0-dev", path = "../../../client/api" }
|
||||
|
||||
@@ -227,6 +227,7 @@ pub fn run() -> Result<()> {
|
||||
},
|
||||
#[cfg(feature = "try-runtime")]
|
||||
Some(Subcommand::TryRuntime(cmd)) => {
|
||||
use sc_executor::{sp_wasm_interface::ExtendedHostFunctions, NativeExecutionDispatch};
|
||||
let runner = cli.create_runner(cmd)?;
|
||||
runner.async_run(|config| {
|
||||
// we don't need any of the components of new_partial, just a runtime, or a task
|
||||
@@ -236,7 +237,13 @@ pub fn run() -> Result<()> {
|
||||
sc_service::TaskManager::new(config.tokio_handle.clone(), registry)
|
||||
.map_err(|e| sc_cli::Error::Service(sc_service::Error::Prometheus(e)))?;
|
||||
|
||||
Ok((cmd.run::<Block, ExecutorDispatch>(config), task_manager))
|
||||
Ok((
|
||||
cmd.run::<Block, ExtendedHostFunctions<
|
||||
sp_io::SubstrateHostFunctions,
|
||||
<ExecutorDispatch as NativeExecutionDispatch>::ExtendHostFunctions,
|
||||
>>(),
|
||||
task_manager,
|
||||
))
|
||||
})
|
||||
},
|
||||
#[cfg(not(feature = "try-runtime"))]
|
||||
|
||||
@@ -2158,29 +2158,23 @@ impl_runtime_apis! {
|
||||
|
||||
#[cfg(feature = "try-runtime")]
|
||||
impl frame_try_runtime::TryRuntime<Block> for Runtime {
|
||||
fn on_runtime_upgrade() -> (Weight, Weight) {
|
||||
fn on_runtime_upgrade(checks: bool) -> (Weight, Weight) {
|
||||
// NOTE: intentional unwrap: we don't want to propagate the error backwards, and want to
|
||||
// have a backtrace here. If any of the pre/post migration checks fail, we shall stop
|
||||
// right here and right now.
|
||||
let weight = Executive::try_runtime_upgrade().unwrap();
|
||||
let weight = Executive::try_runtime_upgrade(checks).unwrap();
|
||||
(weight, RuntimeBlockWeights::get().max_block)
|
||||
}
|
||||
|
||||
fn execute_block(
|
||||
block: Block,
|
||||
state_root_check: bool,
|
||||
signature_check: bool,
|
||||
select: frame_try_runtime::TryStateSelect
|
||||
) -> Weight {
|
||||
log::info!(
|
||||
target: "node-runtime",
|
||||
"try-runtime: executing block {:?} / root checks: {:?} / try-state-select: {:?}",
|
||||
block.header.hash(),
|
||||
state_root_check,
|
||||
select,
|
||||
);
|
||||
// NOTE: intentional unwrap: we don't want to propagate the error backwards, and want to
|
||||
// have a backtrace here.
|
||||
Executive::try_execute_block(block, state_root_check, select).unwrap()
|
||||
Executive::try_execute_block(block, state_root_check, signature_check, select).unwrap()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -30,7 +30,7 @@ pub async fn execute<Runtime, Block>(
|
||||
ws_url: String,
|
||||
) where
|
||||
Runtime: RuntimeT<pallet_bags_list::Instance1>,
|
||||
Block: BlockT,
|
||||
Block: BlockT + DeserializeOwned,
|
||||
Block::Header: DeserializeOwned,
|
||||
{
|
||||
let mut ext = Builder::<Block>::new()
|
||||
|
||||
@@ -25,7 +25,7 @@ use sp_runtime::{traits::Block as BlockT, DeserializeOwned};
|
||||
pub async fn execute<Runtime, Block>(voter_limit: Option<usize>, currency_unit: u64, ws_url: String)
|
||||
where
|
||||
Runtime: crate::RuntimeT<pallet_bags_list::Instance1>,
|
||||
Block: BlockT,
|
||||
Block: BlockT + DeserializeOwned,
|
||||
Block::Header: DeserializeOwned,
|
||||
{
|
||||
use frame_support::storage::generator::StorageMap;
|
||||
@@ -38,14 +38,18 @@ where
|
||||
pallets: vec![pallet_bags_list::Pallet::<Runtime, pallet_bags_list::Instance1>::name()
|
||||
.to_string()],
|
||||
at: None,
|
||||
hashed_prefixes: vec![
|
||||
<pallet_staking::Bonded<Runtime>>::prefix_hash(),
|
||||
<pallet_staking::Ledger<Runtime>>::prefix_hash(),
|
||||
<pallet_staking::Validators<Runtime>>::map_storage_final_prefix(),
|
||||
<pallet_staking::Nominators<Runtime>>::map_storage_final_prefix(),
|
||||
],
|
||||
hashed_keys: vec![
|
||||
<pallet_staking::Validators<Runtime>>::counter_storage_final_key().to_vec(),
|
||||
<pallet_staking::Nominators<Runtime>>::counter_storage_final_key().to_vec(),
|
||||
],
|
||||
..Default::default()
|
||||
}))
|
||||
.inject_hashed_prefix(&<pallet_staking::Bonded<Runtime>>::prefix_hash())
|
||||
.inject_hashed_prefix(&<pallet_staking::Ledger<Runtime>>::prefix_hash())
|
||||
.inject_hashed_prefix(&<pallet_staking::Validators<Runtime>>::map_storage_final_prefix())
|
||||
.inject_hashed_prefix(&<pallet_staking::Nominators<Runtime>>::map_storage_final_prefix())
|
||||
.inject_hashed_key(&<pallet_staking::Validators<Runtime>>::counter_storage_final_key())
|
||||
.inject_hashed_key(&<pallet_staking::Nominators<Runtime>>::counter_storage_final_key())
|
||||
.build()
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
@@ -31,7 +31,7 @@ pub async fn execute<Runtime, Block>(
|
||||
ws_url: String,
|
||||
) where
|
||||
Runtime: crate::RuntimeT<pallet_bags_list::Instance1>,
|
||||
Block: BlockT,
|
||||
Block: BlockT + DeserializeOwned,
|
||||
Block::Header: DeserializeOwned,
|
||||
{
|
||||
let mut ext = Builder::<Block>::new()
|
||||
@@ -39,10 +39,12 @@ pub async fn execute<Runtime, Block>(
|
||||
transport: ws_url.to_string().into(),
|
||||
pallets: vec![pallet_bags_list::Pallet::<Runtime, pallet_bags_list::Instance1>::name()
|
||||
.to_string()],
|
||||
hashed_prefixes: vec![
|
||||
<pallet_staking::Bonded<Runtime>>::prefix_hash(),
|
||||
<pallet_staking::Ledger<Runtime>>::prefix_hash(),
|
||||
],
|
||||
..Default::default()
|
||||
}))
|
||||
.inject_hashed_prefix(&<pallet_staking::Bonded<Runtime>>::prefix_hash())
|
||||
.inject_hashed_prefix(&<pallet_staking::Ledger<Runtime>>::prefix_hash())
|
||||
.build()
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
@@ -49,4 +49,4 @@ std = [
|
||||
"sp-std/std",
|
||||
"sp-tracing/std",
|
||||
]
|
||||
try-runtime = ["frame-support/try-runtime", "frame-try-runtime/try-runtime" ]
|
||||
try-runtime = ["frame-support/try-runtime", "frame-try-runtime/try-runtime", "sp-runtime/try-runtime"]
|
||||
|
||||
@@ -227,27 +227,71 @@ where
|
||||
{
|
||||
/// Execute given block, but don't as strict is the normal block execution.
|
||||
///
|
||||
/// Some consensus related checks such as the state root check can be switched off via
|
||||
/// `try_state_root`. Some additional non-consensus checks can be additionally enabled via
|
||||
/// `try_state`.
|
||||
/// Some checks can be disabled via:
|
||||
///
|
||||
/// - `state_root_check`
|
||||
/// - `signature_check`
|
||||
///
|
||||
/// Should only be used for testing ONLY.
|
||||
pub fn try_execute_block(
|
||||
block: Block,
|
||||
try_state_root: bool,
|
||||
state_root_check: bool,
|
||||
signature_check: bool,
|
||||
select: frame_try_runtime::TryStateSelect,
|
||||
) -> Result<frame_support::weights::Weight, &'static str> {
|
||||
use frame_support::traits::TryState;
|
||||
) -> Result<Weight, &'static str> {
|
||||
frame_support::log::info!(
|
||||
target: "frame::executive",
|
||||
"try-runtime: executing block #{:?} / state root check: {:?} / signature check: {:?} / try-state-select: {:?}",
|
||||
block.header().number(),
|
||||
state_root_check,
|
||||
signature_check,
|
||||
select,
|
||||
);
|
||||
|
||||
Self::initialize_block(block.header());
|
||||
Self::initial_checks(&block);
|
||||
|
||||
let (header, extrinsics) = block.deconstruct();
|
||||
|
||||
Self::execute_extrinsics_with_book_keeping(extrinsics, *header.number());
|
||||
let try_apply_extrinsic = |uxt: Block::Extrinsic| -> ApplyExtrinsicResult {
|
||||
sp_io::init_tracing();
|
||||
let encoded = uxt.encode();
|
||||
let encoded_len = encoded.len();
|
||||
|
||||
// run the try-state checks of all pallets.
|
||||
<AllPalletsWithSystem as TryState<System::BlockNumber>>::try_state(
|
||||
// skip signature verification.
|
||||
let xt = if signature_check {
|
||||
uxt.check(&Default::default())
|
||||
} else {
|
||||
uxt.unchecked_into_checked_i_know_what_i_am_doing(&Default::default())
|
||||
}?;
|
||||
<frame_system::Pallet<System>>::note_extrinsic(encoded);
|
||||
|
||||
let dispatch_info = xt.get_dispatch_info();
|
||||
let r = Applyable::apply::<UnsignedValidator>(xt, &dispatch_info, encoded_len)?;
|
||||
|
||||
<frame_system::Pallet<System>>::note_applied_extrinsic(&r, dispatch_info);
|
||||
|
||||
Ok(r.map(|_| ()).map_err(|e| e.error))
|
||||
};
|
||||
|
||||
for e in extrinsics {
|
||||
if let Err(err) = try_apply_extrinsic(e.clone()) {
|
||||
frame_support::log::error!(
|
||||
target: "runtime::executive", "executing transaction {:?} failed due to {:?}. Aborting the rest of the block execution.",
|
||||
e,
|
||||
err,
|
||||
);
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
// post-extrinsics book-keeping
|
||||
<frame_system::Pallet<System>>::note_finished_extrinsics();
|
||||
Self::idle_and_finalize_hook(*header.number());
|
||||
|
||||
// run the try-state checks of all pallets, ensuring they don't alter any state.
|
||||
let _guard = frame_support::StorageNoopGuard::default();
|
||||
<AllPalletsWithSystem as frame_support::traits::TryState<System::BlockNumber>>::try_state(
|
||||
*header.number(),
|
||||
select,
|
||||
)
|
||||
@@ -255,6 +299,7 @@ where
|
||||
frame_support::log::error!(target: "runtime::executive", "failure: {:?}", e);
|
||||
e
|
||||
})?;
|
||||
drop(_guard);
|
||||
|
||||
// do some of the checks that would normally happen in `final_checks`, but perhaps skip
|
||||
// the state root check.
|
||||
@@ -266,7 +311,7 @@ where
|
||||
assert!(header_item == computed_item, "Digest item must match that calculated.");
|
||||
}
|
||||
|
||||
if try_state_root {
|
||||
if state_root_check {
|
||||
let storage_root = new_header.state_root();
|
||||
header.state_root().check_equal(storage_root);
|
||||
assert!(
|
||||
@@ -286,9 +331,30 @@ where
|
||||
|
||||
/// Execute all `OnRuntimeUpgrade` of this runtime, including the pre and post migration checks.
|
||||
///
|
||||
/// This should only be used for testing.
|
||||
pub fn try_runtime_upgrade() -> Result<frame_support::weights::Weight, &'static str> {
|
||||
let weight = Self::execute_on_runtime_upgrade();
|
||||
/// Runs the try-state code both before and after the migration function if `checks` is set to
|
||||
/// `true`. Also, if set to `true`, it runs the `pre_upgrade` and `post_upgrade` hooks.
|
||||
pub fn try_runtime_upgrade(checks: bool) -> Result<Weight, &'static str> {
|
||||
if checks {
|
||||
let _guard = frame_support::StorageNoopGuard::default();
|
||||
<AllPalletsWithSystem as frame_support::traits::TryState<System::BlockNumber>>::try_state(
|
||||
frame_system::Pallet::<System>::block_number(),
|
||||
frame_try_runtime::TryStateSelect::All,
|
||||
)?;
|
||||
}
|
||||
|
||||
let weight =
|
||||
<(COnRuntimeUpgrade, AllPalletsWithSystem) as OnRuntimeUpgrade>::try_on_runtime_upgrade(
|
||||
checks,
|
||||
)?;
|
||||
|
||||
if checks {
|
||||
let _guard = frame_support::StorageNoopGuard::default();
|
||||
<AllPalletsWithSystem as frame_support::traits::TryState<System::BlockNumber>>::try_state(
|
||||
frame_system::Pallet::<System>::block_number(),
|
||||
frame_try_runtime::TryStateSelect::All,
|
||||
)?;
|
||||
}
|
||||
|
||||
Ok(weight)
|
||||
}
|
||||
}
|
||||
@@ -314,7 +380,7 @@ where
|
||||
UnsignedValidator: ValidateUnsigned<Call = CallOf<Block::Extrinsic, Context>>,
|
||||
{
|
||||
/// Execute all `OnRuntimeUpgrade` of this runtime, and return the aggregate weight.
|
||||
pub fn execute_on_runtime_upgrade() -> frame_support::weights::Weight {
|
||||
pub fn execute_on_runtime_upgrade() -> Weight {
|
||||
<(COnRuntimeUpgrade, AllPalletsWithSystem) as OnRuntimeUpgrade>::on_runtime_upgrade()
|
||||
}
|
||||
|
||||
|
||||
@@ -62,7 +62,6 @@ std = [
|
||||
"sp-runtime/std",
|
||||
"sp-staking/std",
|
||||
"pallet-session/std",
|
||||
"pallet-bags-list/std",
|
||||
"frame-system/std",
|
||||
"pallet-authorship/std",
|
||||
"sp-application-crypto/std",
|
||||
|
||||
@@ -1636,9 +1636,9 @@ impl<T: Config> Pallet<T> {
|
||||
ensure!(
|
||||
T::VoterList::iter()
|
||||
.all(|x| <Nominators<T>>::contains_key(&x) || <Validators<T>>::contains_key(&x)),
|
||||
"VoterList contains non-nominators"
|
||||
"VoterList contains non-staker"
|
||||
);
|
||||
T::VoterList::try_state()?;
|
||||
|
||||
Self::check_nominators()?;
|
||||
Self::check_exposures()?;
|
||||
Self::check_ledgers()?;
|
||||
@@ -1651,7 +1651,10 @@ impl<T: Config> Pallet<T> {
|
||||
Nominators::<T>::count() + Validators::<T>::count(),
|
||||
"wrong external count"
|
||||
);
|
||||
|
||||
ensure!(
|
||||
<T as Config>::TargetList::count() == Validators::<T>::count(),
|
||||
"wrong external count"
|
||||
);
|
||||
ensure!(
|
||||
ValidatorCount::<T>::get() <=
|
||||
<T::ElectionProvider as frame_election_provider_support::ElectionProviderBase>::MaxWinners::get(),
|
||||
@@ -1692,7 +1695,7 @@ impl<T: Config> Pallet<T> {
|
||||
<Nominators<T>>::iter()
|
||||
.filter_map(
|
||||
|(nominator, nomination)| {
|
||||
if nomination.submitted_in > era {
|
||||
if nomination.submitted_in < era {
|
||||
Some(nominator)
|
||||
} else {
|
||||
None
|
||||
|
||||
@@ -1619,7 +1619,10 @@ pub(crate) mod remote_tests {
|
||||
use frame_system::Pallet as System;
|
||||
use remote_externalities::Mode;
|
||||
use sp_core::H256;
|
||||
use sp_runtime::traits::{Block as BlockT, HashFor, Header as _, One, Zero};
|
||||
use sp_runtime::{
|
||||
traits::{Block as BlockT, HashFor, Header as _, One, Zero},
|
||||
DeserializeOwned,
|
||||
};
|
||||
use thousands::Separable;
|
||||
|
||||
#[allow(dead_code)]
|
||||
@@ -1648,12 +1651,12 @@ pub(crate) mod remote_tests {
|
||||
pub(crate) async fn run_with_limits<Runtime, Block>(limits: MigrationLimits, mode: Mode<Block>)
|
||||
where
|
||||
Runtime: crate::Config<Hash = H256>,
|
||||
Block: BlockT<Hash = H256>,
|
||||
Block: BlockT<Hash = H256> + DeserializeOwned,
|
||||
Block::Header: serde::de::DeserializeOwned,
|
||||
{
|
||||
let mut ext = remote_externalities::Builder::<Block>::new()
|
||||
.mode(mode)
|
||||
.state_version(sp_core::storage::StateVersion::V0)
|
||||
.overwrite_state_version(sp_core::storage::StateVersion::V0)
|
||||
.build()
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
@@ -50,7 +50,7 @@ pub fn expand_hooks(def: &mut Def) -> proc_macro2::TokenStream {
|
||||
} else {
|
||||
// default.
|
||||
quote::quote! {
|
||||
#frame_support::log::info!(
|
||||
#frame_support::log::debug!(
|
||||
target: #frame_support::LOG_TARGET,
|
||||
"✅ no migration for {}",
|
||||
pallet_name,
|
||||
|
||||
@@ -2188,7 +2188,7 @@ macro_rules! decl_module {
|
||||
$system::Config
|
||||
>::PalletInfo as $crate::traits::PalletInfo>::name::<Self>().unwrap_or("<unknown pallet name>");
|
||||
|
||||
$crate::log::info!(
|
||||
$crate::log::debug!(
|
||||
target: $crate::LOG_TARGET,
|
||||
"✅ no migration for {}",
|
||||
pallet_name,
|
||||
|
||||
@@ -22,9 +22,6 @@ use impl_trait_for_tuples::impl_for_tuples;
|
||||
use sp_runtime::traits::AtLeast32BitUnsigned;
|
||||
use sp_std::prelude::*;
|
||||
|
||||
#[cfg(all(feature = "try-runtime", test))]
|
||||
use codec::{Decode, Encode};
|
||||
|
||||
/// The block initialization trait.
|
||||
///
|
||||
/// Implementing this lets you express what should happen for your pallet when the block is
|
||||
@@ -136,6 +133,29 @@ pub trait OnRuntimeUpgrade {
|
||||
Weight::zero()
|
||||
}
|
||||
|
||||
/// Same as `on_runtime_upgrade`, but perform the optional `pre_upgrade` and `post_upgrade` as
|
||||
/// well.
|
||||
#[cfg(feature = "try-runtime")]
|
||||
fn try_on_runtime_upgrade(checks: bool) -> Result<Weight, &'static str> {
|
||||
let maybe_state = if checks {
|
||||
let _guard = frame_support::StorageNoopGuard::default();
|
||||
let state = Self::pre_upgrade()?;
|
||||
Some(state)
|
||||
} else {
|
||||
None
|
||||
};
|
||||
|
||||
let weight = Self::on_runtime_upgrade();
|
||||
|
||||
if let Some(state) = maybe_state {
|
||||
let _guard = frame_support::StorageNoopGuard::default();
|
||||
// we want to panic if any checks fail right here right now.
|
||||
Self::post_upgrade(state)?
|
||||
}
|
||||
|
||||
Ok(weight)
|
||||
}
|
||||
|
||||
/// Execute some pre-checks prior to a runtime upgrade.
|
||||
///
|
||||
/// Return a `Vec<u8>` that can contain arbitrary encoded data (usually some pre-upgrade state),
|
||||
@@ -143,6 +163,9 @@ pub trait OnRuntimeUpgrade {
|
||||
/// should be returned if there is no such need.
|
||||
///
|
||||
/// This hook is never meant to be executed on-chain but is meant to be used by testing tools.
|
||||
///
|
||||
/// This hook must not write to any state, as it would make the main `on_runtime_upgrade` path
|
||||
/// inaccurate.
|
||||
#[cfg(feature = "try-runtime")]
|
||||
fn pre_upgrade() -> Result<Vec<u8>, &'static str> {
|
||||
Ok(Vec::new())
|
||||
@@ -155,6 +178,9 @@ pub trait OnRuntimeUpgrade {
|
||||
/// be passed in, in such case `post_upgrade` should ignore it.
|
||||
///
|
||||
/// This hook is never meant to be executed on-chain but is meant to be used by testing tools.
|
||||
///
|
||||
/// This hook must not write to any state, as it would make the main `on_runtime_upgrade` path
|
||||
/// inaccurate.
|
||||
#[cfg(feature = "try-runtime")]
|
||||
fn post_upgrade(_state: Vec<u8>) -> Result<(), &'static str> {
|
||||
Ok(())
|
||||
@@ -165,7 +191,6 @@ pub trait OnRuntimeUpgrade {
|
||||
#[cfg_attr(all(feature = "tuples-96", not(feature = "tuples-128")), impl_for_tuples(96))]
|
||||
#[cfg_attr(feature = "tuples-128", impl_for_tuples(128))]
|
||||
impl OnRuntimeUpgrade for Tuple {
|
||||
#[cfg(not(feature = "try-runtime"))]
|
||||
fn on_runtime_upgrade() -> Weight {
|
||||
let mut weight = Weight::zero();
|
||||
for_tuples!( #( weight = weight.saturating_add(Tuple::on_runtime_upgrade()); )* );
|
||||
@@ -176,40 +201,10 @@ impl OnRuntimeUpgrade for Tuple {
|
||||
/// We are executing pre- and post-checks sequentially in order to be able to test several
|
||||
/// consecutive migrations for the same pallet without errors. Therefore pre and post upgrade
|
||||
/// hooks for tuples are a noop.
|
||||
fn on_runtime_upgrade() -> Weight {
|
||||
use scale_info::prelude::format;
|
||||
|
||||
fn try_on_runtime_upgrade(checks: bool) -> Result<Weight, &'static str> {
|
||||
let mut weight = Weight::zero();
|
||||
// migration index in the tuple, start with 1 for better readability
|
||||
let mut i = 1;
|
||||
for_tuples!( #(
|
||||
let _guard = frame_support::StorageNoopGuard::default();
|
||||
// we want to panic if any checks fail right here right now.
|
||||
let state = Tuple::pre_upgrade().expect(&format!("PreUpgrade failed for migration #{}", i));
|
||||
drop(_guard);
|
||||
|
||||
weight = weight.saturating_add(Tuple::on_runtime_upgrade());
|
||||
|
||||
let _guard = frame_support::StorageNoopGuard::default();
|
||||
// we want to panic if any checks fail right here right now.
|
||||
Tuple::post_upgrade(state).expect(&format!("PostUpgrade failed for migration #{}", i));
|
||||
drop(_guard);
|
||||
|
||||
i += 1;
|
||||
)* );
|
||||
weight
|
||||
}
|
||||
|
||||
#[cfg(feature = "try-runtime")]
|
||||
/// noop
|
||||
fn pre_upgrade() -> Result<Vec<u8>, &'static str> {
|
||||
Ok(Vec::new())
|
||||
}
|
||||
|
||||
#[cfg(feature = "try-runtime")]
|
||||
/// noop
|
||||
fn post_upgrade(_state: Vec<u8>) -> Result<(), &'static str> {
|
||||
Ok(())
|
||||
for_tuples!( #( weight = weight.saturating_add(Tuple::try_on_runtime_upgrade(checks)?); )* );
|
||||
Ok(weight)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -274,6 +269,8 @@ pub trait Hooks<BlockNumber> {
|
||||
///
|
||||
/// It should focus on certain checks to ensure that the state is sensible. This is never
|
||||
/// executed in a consensus code-path, therefore it can consume as much weight as it needs.
|
||||
///
|
||||
/// This hook should not alter any storage.
|
||||
#[cfg(feature = "try-runtime")]
|
||||
fn try_state(_n: BlockNumber) -> Result<(), &'static str> {
|
||||
Ok(())
|
||||
@@ -440,110 +437,4 @@ mod tests {
|
||||
ON_IDLE_INVOCATION_ORDER.clear();
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "try-runtime")]
|
||||
#[test]
|
||||
#[allow(dead_code)]
|
||||
fn on_runtime_upgrade_tuple() {
|
||||
use frame_support::parameter_types;
|
||||
use sp_io::TestExternalities;
|
||||
|
||||
struct Test1;
|
||||
struct Test2;
|
||||
struct Test3;
|
||||
|
||||
parameter_types! {
|
||||
static Test1Assertions: u8 = 0;
|
||||
static Test2Assertions: u8 = 0;
|
||||
static Test3Assertions: u8 = 0;
|
||||
static EnableSequentialTest: bool = false;
|
||||
static SequentialAssertions: u8 = 0;
|
||||
}
|
||||
|
||||
impl OnRuntimeUpgrade for Test1 {
|
||||
fn pre_upgrade() -> Result<Vec<u8>, &'static str> {
|
||||
Ok("Test1".encode())
|
||||
}
|
||||
fn post_upgrade(state: Vec<u8>) -> Result<(), &'static str> {
|
||||
let s: String = Decode::decode(&mut state.as_slice()).unwrap();
|
||||
Test1Assertions::mutate(|val| *val += 1);
|
||||
if EnableSequentialTest::get() {
|
||||
SequentialAssertions::mutate(|val| *val += 1);
|
||||
}
|
||||
assert_eq!(s, "Test1");
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
impl OnRuntimeUpgrade for Test2 {
|
||||
fn pre_upgrade() -> Result<Vec<u8>, &'static str> {
|
||||
Ok(100u32.encode())
|
||||
}
|
||||
fn post_upgrade(state: Vec<u8>) -> Result<(), &'static str> {
|
||||
let s: u32 = Decode::decode(&mut state.as_slice()).unwrap();
|
||||
Test2Assertions::mutate(|val| *val += 1);
|
||||
if EnableSequentialTest::get() {
|
||||
assert_eq!(SequentialAssertions::get(), 1);
|
||||
SequentialAssertions::mutate(|val| *val += 1);
|
||||
}
|
||||
assert_eq!(s, 100);
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
impl OnRuntimeUpgrade for Test3 {
|
||||
fn pre_upgrade() -> Result<Vec<u8>, &'static str> {
|
||||
Ok(true.encode())
|
||||
}
|
||||
fn post_upgrade(state: Vec<u8>) -> Result<(), &'static str> {
|
||||
let s: bool = Decode::decode(&mut state.as_slice()).unwrap();
|
||||
Test3Assertions::mutate(|val| *val += 1);
|
||||
if EnableSequentialTest::get() {
|
||||
assert_eq!(SequentialAssertions::get(), 2);
|
||||
SequentialAssertions::mutate(|val| *val += 1);
|
||||
}
|
||||
assert_eq!(s, true);
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
TestExternalities::default().execute_with(|| {
|
||||
type TestEmpty = ();
|
||||
let origin_state = <TestEmpty as OnRuntimeUpgrade>::pre_upgrade().unwrap();
|
||||
assert!(origin_state.is_empty());
|
||||
<TestEmpty as OnRuntimeUpgrade>::post_upgrade(origin_state).unwrap();
|
||||
|
||||
type Test1Tuple = (Test1,);
|
||||
let origin_state = <Test1Tuple as OnRuntimeUpgrade>::pre_upgrade().unwrap();
|
||||
assert!(origin_state.is_empty());
|
||||
<Test1Tuple as OnRuntimeUpgrade>::post_upgrade(origin_state).unwrap();
|
||||
assert_eq!(Test1Assertions::get(), 0);
|
||||
<Test1Tuple as OnRuntimeUpgrade>::on_runtime_upgrade();
|
||||
assert_eq!(Test1Assertions::take(), 1);
|
||||
|
||||
type Test321 = (Test3, Test2, Test1);
|
||||
<Test321 as OnRuntimeUpgrade>::on_runtime_upgrade();
|
||||
assert_eq!(Test1Assertions::take(), 1);
|
||||
assert_eq!(Test2Assertions::take(), 1);
|
||||
assert_eq!(Test3Assertions::take(), 1);
|
||||
|
||||
// enable sequential tests
|
||||
EnableSequentialTest::mutate(|val| *val = true);
|
||||
|
||||
type Test123 = (Test1, Test2, Test3);
|
||||
<Test123 as OnRuntimeUpgrade>::on_runtime_upgrade();
|
||||
assert_eq!(Test1Assertions::take(), 1);
|
||||
assert_eq!(Test2Assertions::take(), 1);
|
||||
assert_eq!(Test3Assertions::take(), 1);
|
||||
|
||||
// reset assertions
|
||||
SequentialAssertions::take();
|
||||
|
||||
type TestNested123 = (Test1, (Test2, Test3));
|
||||
<TestNested123 as OnRuntimeUpgrade>::on_runtime_upgrade();
|
||||
assert_eq!(Test1Assertions::take(), 1);
|
||||
assert_eq!(Test2Assertions::take(), 1);
|
||||
assert_eq!(Test3Assertions::take(), 1);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -85,6 +85,8 @@ impl sp_std::str::FromStr for Select {
|
||||
///
|
||||
/// Usually, these checks should check all of the invariants that are expected to be held on all of
|
||||
/// the storage items of your pallet.
|
||||
///
|
||||
/// This hook should not alter any storage.
|
||||
pub trait TryState<BlockNumber> {
|
||||
/// Execute the state checks.
|
||||
fn try_state(_: BlockNumber, _: Select) -> Result<(), &'static str>;
|
||||
|
||||
+2
-2
@@ -28,7 +28,7 @@ error[E0277]: the trait bound `Bar: EncodeLike` is not satisfied
|
||||
<&[(T,)] as EncodeLike<BinaryHeap<LikeT>>>
|
||||
<&[(T,)] as EncodeLike<LinkedList<LikeT>>>
|
||||
<&[T] as EncodeLike<Vec<U>>>
|
||||
and 279 others
|
||||
and 280 others
|
||||
= note: required for `Bar` to implement `FullEncode`
|
||||
= note: required for `Bar` to implement `FullCodec`
|
||||
= note: required for `frame_support::pallet_prelude::StorageValue<_GeneratedPrefixForStorageFoo<T>, Bar>` to implement `PartialStorageInfoTrait`
|
||||
@@ -103,7 +103,7 @@ error[E0277]: the trait bound `Bar: EncodeLike` is not satisfied
|
||||
<&[(T,)] as EncodeLike<BinaryHeap<LikeT>>>
|
||||
<&[(T,)] as EncodeLike<LinkedList<LikeT>>>
|
||||
<&[T] as EncodeLike<Vec<U>>>
|
||||
and 279 others
|
||||
and 280 others
|
||||
= note: required for `Bar` to implement `FullEncode`
|
||||
= note: required for `Bar` to implement `FullCodec`
|
||||
= note: required for `frame_support::pallet_prelude::StorageValue<_GeneratedPrefixForStorageFoo<T>, Bar>` to implement `StorageEntryMetadataBuilder`
|
||||
|
||||
+2
-2
@@ -28,7 +28,7 @@ error[E0277]: the trait bound `Bar: EncodeLike` is not satisfied
|
||||
<&[(T,)] as EncodeLike<BinaryHeap<LikeT>>>
|
||||
<&[(T,)] as EncodeLike<LinkedList<LikeT>>>
|
||||
<&[T] as EncodeLike<Vec<U>>>
|
||||
and 279 others
|
||||
and 280 others
|
||||
= note: required for `Bar` to implement `FullEncode`
|
||||
= note: required for `Bar` to implement `FullCodec`
|
||||
= note: required for `frame_support::pallet_prelude::StorageValue<_GeneratedPrefixForStorageFoo<T>, Bar>` to implement `PartialStorageInfoTrait`
|
||||
@@ -103,7 +103,7 @@ error[E0277]: the trait bound `Bar: EncodeLike` is not satisfied
|
||||
<&[(T,)] as EncodeLike<BinaryHeap<LikeT>>>
|
||||
<&[(T,)] as EncodeLike<LinkedList<LikeT>>>
|
||||
<&[T] as EncodeLike<Vec<U>>>
|
||||
and 279 others
|
||||
and 280 others
|
||||
= note: required for `Bar` to implement `FullEncode`
|
||||
= note: required for `Bar` to implement `FullCodec`
|
||||
= note: required for `frame_support::pallet_prelude::StorageValue<_GeneratedPrefixForStorageFoo<T>, Bar>` to implement `StorageEntryMetadataBuilder`
|
||||
|
||||
@@ -33,12 +33,21 @@ sp_api::decl_runtime_apis! {
|
||||
///
|
||||
/// Returns the consumed weight of the migration in case of a successful one, combined with
|
||||
/// the total allowed block weight of the runtime.
|
||||
fn on_runtime_upgrade() -> (Weight, Weight);
|
||||
|
||||
/// Execute the given block, but don't check that its state root matches that of yours.
|
||||
///
|
||||
/// This is only sensible where the incoming block is from a different network, yet it has
|
||||
/// the same block format as the runtime implementing this API.
|
||||
fn execute_block(block: Block, state_root_check: bool, try_state: TryStateSelect) -> Weight;
|
||||
/// If `checks` is `true`, `pre_migrate` and `post_migrate` of each migration and
|
||||
/// `try_state` of all pallets will be executed. Else, no. If checks are executed, the PoV
|
||||
/// tracking is likely inaccurate.
|
||||
fn on_runtime_upgrade(checks: bool) -> (Weight, Weight);
|
||||
|
||||
/// Execute the given block, but optionally disable state-root and signature checks.
|
||||
///
|
||||
/// Optionally, a number of `try_state` hooks can also be executed after the block
|
||||
/// execution.
|
||||
fn execute_block(
|
||||
block: Block,
|
||||
state_root_check: bool,
|
||||
signature_check: bool,
|
||||
try_state: TryStateSelect,
|
||||
) -> Weight;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -41,6 +41,7 @@ substrate-test-runtime-client = { version = "2.0.0", path = "../../test-utils/ru
|
||||
|
||||
[features]
|
||||
runtime-benchmarks = []
|
||||
try-runtime = []
|
||||
default = ["std"]
|
||||
std = [
|
||||
"codec/std",
|
||||
|
||||
@@ -149,6 +149,22 @@ where
|
||||
None => CheckedExtrinsic { signed: None, function: self.function },
|
||||
})
|
||||
}
|
||||
|
||||
#[cfg(feature = "try-runtime")]
|
||||
fn unchecked_into_checked_i_know_what_i_am_doing(
|
||||
self,
|
||||
lookup: &Lookup,
|
||||
) -> Result<Self::Checked, TransactionValidityError> {
|
||||
Ok(match self.signature {
|
||||
Some((signed, _, extra)) => {
|
||||
let signed = lookup.lookup(signed)?;
|
||||
let raw_payload = SignedPayload::new(self.function, extra)?;
|
||||
let (function, extra, _) = raw_payload.deconstruct();
|
||||
CheckedExtrinsic { signed: Some((signed, extra)), function }
|
||||
},
|
||||
None => CheckedExtrinsic { signed: None, function: self.function },
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
impl<Address, Call, Signature, Extra> ExtrinsicMetadata
|
||||
|
||||
@@ -326,6 +326,14 @@ impl<Call: Codec + Sync + Send, Context, Extra> Checkable<Context> for TestXt<Ca
|
||||
fn check(self, _: &Context) -> Result<Self::Checked, TransactionValidityError> {
|
||||
Ok(self)
|
||||
}
|
||||
|
||||
#[cfg(feature = "try-runtime")]
|
||||
fn unchecked_into_checked_i_know_what_i_am_doing(
|
||||
self,
|
||||
_: &Context,
|
||||
) -> Result<Self::Checked, TransactionValidityError> {
|
||||
unreachable!()
|
||||
}
|
||||
}
|
||||
|
||||
impl<Call: Codec + Sync + Send, Extra> traits::Extrinsic for TestXt<Call, Extra> {
|
||||
|
||||
@@ -990,6 +990,20 @@ pub trait Checkable<Context>: Sized {
|
||||
|
||||
/// Check self, given an instance of Context.
|
||||
fn check(self, c: &Context) -> Result<Self::Checked, TransactionValidityError>;
|
||||
|
||||
/// Blindly check self.
|
||||
///
|
||||
/// ## WARNING
|
||||
///
|
||||
/// DO NOT USE IN PRODUCTION. This is only meant to be used in testing environments. A runtime
|
||||
/// compiled with `try-runtime` should never be in production. Moreover, the name of this
|
||||
/// function is deliberately chosen to prevent developers from ever calling it in consensus
|
||||
/// code-paths.
|
||||
#[cfg(feature = "try-runtime")]
|
||||
fn unchecked_into_checked_i_know_what_i_am_doing(
|
||||
self,
|
||||
c: &Context,
|
||||
) -> Result<Self::Checked, TransactionValidityError>;
|
||||
}
|
||||
|
||||
/// A "checkable" piece of information, used by the standard Substrate Executive in order to
|
||||
@@ -1011,6 +1025,14 @@ impl<T: BlindCheckable, Context> Checkable<Context> for T {
|
||||
fn check(self, _c: &Context) -> Result<Self::Checked, TransactionValidityError> {
|
||||
BlindCheckable::check(self)
|
||||
}
|
||||
|
||||
#[cfg(feature = "try-runtime")]
|
||||
fn unchecked_into_checked_i_know_what_i_am_doing(
|
||||
self,
|
||||
_: &Context,
|
||||
) -> Result<Self::Checked, TransactionValidityError> {
|
||||
unreachable!();
|
||||
}
|
||||
}
|
||||
|
||||
/// A lazy call (module function and argument values) that can be executed via its `dispatch`
|
||||
|
||||
@@ -407,6 +407,7 @@ impl ChildTrieParentKeyId {
|
||||
/// V0 and V1 uses a same trie implementation, but V1 will write external value node in the trie for
|
||||
/// value with size at least `TRIE_VALUE_NODE_THRESHOLD`.
|
||||
#[derive(Debug, Clone, Copy, Eq, PartialEq)]
|
||||
#[cfg_attr(feature = "std", derive(Encode, Decode))]
|
||||
pub enum StateVersion {
|
||||
/// Old state version, no value nodes.
|
||||
V0 = 0,
|
||||
|
||||
@@ -22,12 +22,14 @@ sp-core = { version = "7.0.0", path = "../../../primitives/core" }
|
||||
sp-io = { version = "7.0.0", path = "../../../primitives/io" }
|
||||
sp-runtime = { version = "7.0.0", path = "../../../primitives/runtime" }
|
||||
sp-version = { version = "5.0.0", path = "../../../primitives/version" }
|
||||
tokio = { version = "1.22.0", features = ["macros", "rt-multi-thread"] }
|
||||
substrate-rpc-client = { path = "../rpc/client" }
|
||||
futures = "0.3"
|
||||
|
||||
[dev-dependencies]
|
||||
tokio = { version = "1.22.0", features = ["macros", "rt-multi-thread"] }
|
||||
frame-support = { version = "4.0.0-dev", path = "../../../frame/support" }
|
||||
pallet-elections-phragmen = { version = "5.0.0-dev", path = "../../../frame/elections-phragmen" }
|
||||
tracing-subscriber = { version = "0.3.16", features = ["env-filter"] }
|
||||
|
||||
[features]
|
||||
remote-test = ["frame-support"]
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
Binary file not shown.
Binary file not shown.
@@ -46,6 +46,7 @@ pub use jsonrpsee::{
|
||||
core::{
|
||||
client::{ClientT, Subscription, SubscriptionClientT},
|
||||
params::BatchRequestBuilder,
|
||||
Error, RpcResult,
|
||||
},
|
||||
rpc_params,
|
||||
ws_client::{WsClient, WsClientBuilder},
|
||||
|
||||
@@ -12,11 +12,6 @@ description = "Cli command runtime testing and dry-running"
|
||||
targets = ["x86_64-unknown-linux-gnu"]
|
||||
|
||||
[dependencies]
|
||||
clap = { version = "4.0.9", features = ["derive"] }
|
||||
log = "0.4.17"
|
||||
parity-scale-codec = "3.0.0"
|
||||
serde = "1.0.136"
|
||||
zstd = { version = "0.11.2", default-features = false }
|
||||
remote-externalities = { version = "0.10.0-dev", path = "../../remote-externalities", package = "frame-remote-externalities" }
|
||||
sc-chain-spec = { version = "4.0.0-dev", path = "../../../../client/chain-spec" }
|
||||
sc-cli = { version = "0.10.0-dev", path = "../../../../client/cli" }
|
||||
@@ -27,16 +22,27 @@ sp-externalities = { version = "0.13.0", path = "../../../../primitives/external
|
||||
sp-io = { version = "7.0.0", path = "../../../../primitives/io" }
|
||||
sp-keystore = { version = "0.13.0", path = "../../../../primitives/keystore" }
|
||||
sp-runtime = { version = "7.0.0", path = "../../../../primitives/runtime" }
|
||||
sp-rpc = { version = "6.0.0", path = "../../../../primitives/rpc" }
|
||||
sp-state-machine = { version = "0.13.0", path = "../../../../primitives/state-machine" }
|
||||
sp-version = { version = "5.0.0", path = "../../../../primitives/version" }
|
||||
sp-debug-derive = { path = "../../../../primitives/debug-derive" }
|
||||
sp-api = { path = "../../../../primitives/api" }
|
||||
sp-weights = { version = "4.0.0", path = "../../../../primitives/weights" }
|
||||
frame-try-runtime = { optional = true, path = "../../../../frame/try-runtime" }
|
||||
substrate-rpc-client = { path = "../../rpc/client" }
|
||||
|
||||
parity-scale-codec = "3.0.0"
|
||||
hex = "0.4.3"
|
||||
clap = { version = "4.0.9", features = ["derive"] }
|
||||
log = "0.4.17"
|
||||
serde = "1.0.136"
|
||||
zstd = { version = "0.11.2", default-features = false }
|
||||
|
||||
[dev-dependencies]
|
||||
tokio = "1.22.0"
|
||||
|
||||
[features]
|
||||
try-runtime = [
|
||||
"sp-debug-derive/force-debug",
|
||||
"frame-try-runtime/try-runtime",
|
||||
]
|
||||
|
||||
@@ -0,0 +1,78 @@
|
||||
// This file is part of Substrate.
|
||||
|
||||
// Copyright (C) 2022 Parity Technologies (UK) Ltd.
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
use crate::{build_executor, LiveState, SharedParams, State, LOG_TARGET};
|
||||
use sc_executor::sp_wasm_interface::HostFunctions;
|
||||
use sp_runtime::traits::{Block as BlockT, NumberFor};
|
||||
use std::{fmt::Debug, str::FromStr};
|
||||
use substrate_rpc_client::{ws_client, StateApi};
|
||||
|
||||
/// Configurations of the [`crate::Command::CreateSnapshot`].
|
||||
#[derive(Debug, Clone, clap::Parser)]
|
||||
pub struct CreateSnapshotCmd {
|
||||
/// The source of the snapshot. Must be a remote node.
|
||||
#[clap(flatten)]
|
||||
pub from: LiveState,
|
||||
|
||||
/// The snapshot path to write to.
|
||||
///
|
||||
/// If not provided `<spec-name>-<spec-version>@<block-hash>.snap` will be used.
|
||||
pub snapshot_path: Option<String>,
|
||||
}
|
||||
|
||||
/// inner command for `Command::CreateSnapshot`.
|
||||
pub(crate) async fn create_snapshot<Block, HostFns>(
|
||||
shared: SharedParams,
|
||||
command: CreateSnapshotCmd,
|
||||
) -> sc_cli::Result<()>
|
||||
where
|
||||
Block: BlockT + serde::de::DeserializeOwned,
|
||||
Block::Hash: FromStr + serde::de::DeserializeOwned,
|
||||
Block::Header: serde::de::DeserializeOwned,
|
||||
<Block::Hash as FromStr>::Err: Debug,
|
||||
NumberFor<Block>: FromStr,
|
||||
<NumberFor<Block> as FromStr>::Err: Debug,
|
||||
HostFns: HostFunctions,
|
||||
{
|
||||
let snapshot_path = command.snapshot_path;
|
||||
if !matches!(shared.runtime, crate::Runtime::Existing) {
|
||||
return Err("creating a snapshot is only possible with --runtime existing.".into())
|
||||
}
|
||||
|
||||
let path = match snapshot_path {
|
||||
Some(path) => path,
|
||||
None => {
|
||||
let rpc = ws_client(&command.from.uri).await.unwrap();
|
||||
let remote_spec = StateApi::<Block::Hash>::runtime_version(&rpc, None).await.unwrap();
|
||||
let path_str = format!(
|
||||
"{}-{}@{}.snap",
|
||||
remote_spec.spec_name.to_lowercase(),
|
||||
remote_spec.spec_version,
|
||||
command.from.at.clone().unwrap_or("latest".to_owned())
|
||||
);
|
||||
log::info!(target: LOG_TARGET, "snapshot path not provided (-s), using '{}'", path_str);
|
||||
path_str.into()
|
||||
},
|
||||
};
|
||||
|
||||
let executor = build_executor::<HostFns>(&shared);
|
||||
let _ = State::Live(command.from)
|
||||
.into_ext::<Block, HostFns>(&shared, &executor, Some(path.into()))
|
||||
.await?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
@@ -16,30 +16,25 @@
|
||||
// limitations under the License.
|
||||
|
||||
use crate::{
|
||||
build_executor, ensure_matching_spec, extract_code, full_extensions, hash_of, local_spec,
|
||||
state_machine_call_with_proof, SharedParams, State, LOG_TARGET,
|
||||
build_executor, full_extensions, rpc_err_handler, state_machine_call_with_proof, LiveState,
|
||||
SharedParams, State, LOG_TARGET,
|
||||
};
|
||||
use parity_scale_codec::Encode;
|
||||
use sc_service::{Configuration, NativeExecutionDispatch};
|
||||
use sp_core::storage::well_known_keys;
|
||||
use sp_runtime::traits::{Block as BlockT, Header as HeaderT, NumberFor};
|
||||
use sc_executor::sp_wasm_interface::HostFunctions;
|
||||
use sp_rpc::{list::ListOrValue, number::NumberOrHex};
|
||||
use sp_runtime::{
|
||||
generic::SignedBlock,
|
||||
traits::{Block as BlockT, Header as HeaderT, NumberFor},
|
||||
};
|
||||
use std::{fmt::Debug, str::FromStr};
|
||||
use substrate_rpc_client::{ws_client, ChainApi};
|
||||
|
||||
/// Configurations of the [`Command::ExecuteBlock`].
|
||||
/// Configurations of the [`crate::Command::ExecuteBlock`].
|
||||
///
|
||||
/// This will always call into `TryRuntime_execute_block`, which can optionally skip the state-root
|
||||
/// check (useful for trying a unreleased runtime), and can execute runtime sanity checks as well.
|
||||
#[derive(Debug, Clone, clap::Parser)]
|
||||
pub struct ExecuteBlockCmd {
|
||||
/// Overwrite the wasm code in state or not.
|
||||
#[arg(long)]
|
||||
overwrite_wasm_code: bool,
|
||||
|
||||
/// If set the state root check is disabled.
|
||||
#[arg(long)]
|
||||
no_state_root_check: bool,
|
||||
|
||||
/// Which try-state targets to execute when running this command.
|
||||
///
|
||||
/// Expected values:
|
||||
@@ -49,69 +44,28 @@ pub struct ExecuteBlockCmd {
|
||||
/// `Staking, System`).
|
||||
/// - `rr-[x]` where `[x]` is a number. Then, the given number of pallets are checked in a
|
||||
/// round-robin fashion.
|
||||
#[arg(long, default_value = "none")]
|
||||
try_state: frame_try_runtime::TryStateSelect,
|
||||
|
||||
/// The block hash at which to fetch the block.
|
||||
///
|
||||
/// If the `live` state type is being used, then this can be omitted, and is equal to whatever
|
||||
/// the `state::at` is. Only use this (with care) when combined with a snapshot.
|
||||
#[arg(
|
||||
long,
|
||||
value_parser = crate::parse::hash
|
||||
)]
|
||||
block_at: Option<String>,
|
||||
#[arg(long, default_value = "all")]
|
||||
pub try_state: frame_try_runtime::TryStateSelect,
|
||||
|
||||
/// The ws uri from which to fetch the block.
|
||||
///
|
||||
/// If the `live` state type is being used, then this can be omitted, and is equal to whatever
|
||||
/// the `state::uri` is. Only use this (with care) when combined with a snapshot.
|
||||
/// This will always fetch the next block of whatever `state` is referring to, because this is
|
||||
/// the only sensible combination. In other words, if you have the state of block `n`, you
|
||||
/// should execute block `n+1` on top of it.
|
||||
///
|
||||
/// If `state` is `Live`, this can be ignored and the same uri is used for both.
|
||||
#[arg(
|
||||
long,
|
||||
value_parser = crate::parse::url
|
||||
)]
|
||||
block_ws_uri: Option<String>,
|
||||
pub block_ws_uri: Option<String>,
|
||||
|
||||
/// The state type to use.
|
||||
///
|
||||
/// For this command only, if the `live` is used, then state of the parent block is fetched.
|
||||
///
|
||||
/// If `block_at` is provided, then the [`State::Live::at`] is being ignored.
|
||||
#[command(subcommand)]
|
||||
state: State,
|
||||
pub state: State,
|
||||
}
|
||||
|
||||
impl ExecuteBlockCmd {
|
||||
async fn block_at<Block: BlockT>(&self, ws_uri: String) -> sc_cli::Result<Block::Hash>
|
||||
where
|
||||
Block::Hash: FromStr + serde::de::DeserializeOwned,
|
||||
<Block::Hash as FromStr>::Err: Debug,
|
||||
Block::Header: serde::de::DeserializeOwned,
|
||||
{
|
||||
let rpc = ws_client(&ws_uri).await?;
|
||||
|
||||
match (&self.block_at, &self.state) {
|
||||
(Some(block_at), State::Snap { .. }) => hash_of::<Block>(block_at),
|
||||
(Some(block_at), State::Live { .. }) => {
|
||||
log::warn!(target: LOG_TARGET, "--block-at is provided while state type is live. the `Live::at` will be ignored");
|
||||
hash_of::<Block>(block_at)
|
||||
},
|
||||
(None, State::Live { at: None, .. }) => {
|
||||
log::warn!(
|
||||
target: LOG_TARGET,
|
||||
"No --block-at or --at provided, using the latest finalized block instead"
|
||||
);
|
||||
ChainApi::<(), Block::Hash, Block::Header, ()>::finalized_head(&rpc)
|
||||
.await
|
||||
.map_err(|e| e.to_string().into())
|
||||
},
|
||||
(None, State::Live { at: Some(at), .. }) => hash_of::<Block>(at),
|
||||
_ => {
|
||||
panic!("either `--block-at` must be provided, or state must be `live with a proper `--at``");
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
fn block_ws_uri<Block: BlockT>(&self) -> String
|
||||
where
|
||||
Block::Hash: FromStr,
|
||||
@@ -123,7 +77,7 @@ impl ExecuteBlockCmd {
|
||||
log::error!(target: LOG_TARGET, "--block-uri is provided while state type is live, Are you sure you know what you are doing?");
|
||||
block_ws_uri.to_owned()
|
||||
},
|
||||
(None, State::Live { uri, .. }) => uri.clone(),
|
||||
(None, State::Live(LiveState { uri, .. })) => uri.clone(),
|
||||
(None, State::Snap { .. }) => {
|
||||
panic!("either `--block-uri` must be provided, or state must be `live`");
|
||||
},
|
||||
@@ -131,10 +85,9 @@ impl ExecuteBlockCmd {
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) async fn execute_block<Block, ExecDispatch>(
|
||||
pub(crate) async fn execute_block<Block, HostFns>(
|
||||
shared: SharedParams,
|
||||
command: ExecuteBlockCmd,
|
||||
config: Configuration,
|
||||
) -> sc_cli::Result<()>
|
||||
where
|
||||
Block: BlockT + serde::de::DeserializeOwned,
|
||||
@@ -142,79 +95,77 @@ where
|
||||
<Block::Hash as FromStr>::Err: Debug,
|
||||
Block::Hash: serde::de::DeserializeOwned,
|
||||
Block::Header: serde::de::DeserializeOwned,
|
||||
NumberFor<Block>: FromStr,
|
||||
<NumberFor<Block> as FromStr>::Err: Debug,
|
||||
ExecDispatch: NativeExecutionDispatch + 'static,
|
||||
<NumberFor<Block> as TryInto<u64>>::Error: Debug,
|
||||
HostFns: HostFunctions,
|
||||
{
|
||||
let executor = build_executor::<ExecDispatch>(&shared, &config);
|
||||
let execution = shared.execution;
|
||||
let executor = build_executor::<HostFns>(&shared);
|
||||
let ext = command.state.into_ext::<Block, HostFns>(&shared, &executor, None).await?;
|
||||
|
||||
// get the block number associated with this block.
|
||||
let block_ws_uri = command.block_ws_uri::<Block>();
|
||||
let block_at = command.block_at::<Block>(block_ws_uri.clone()).await?;
|
||||
let rpc = ws_client(&block_ws_uri).await?;
|
||||
let block: Block = ChainApi::<(), Block::Hash, Block::Header, _>::block(&rpc, Some(block_at))
|
||||
.await
|
||||
.unwrap()
|
||||
.unwrap();
|
||||
let parent_hash = block.header().parent_hash();
|
||||
log::info!(
|
||||
target: LOG_TARGET,
|
||||
"fetched block #{:?} from {:?}, parent_hash to fetch the state {:?}",
|
||||
block.header().number(),
|
||||
block_ws_uri,
|
||||
parent_hash
|
||||
);
|
||||
let next_hash = next_hash_of::<Block>(&rpc, ext.block_hash).await?;
|
||||
|
||||
let ext = {
|
||||
let builder = command
|
||||
.state
|
||||
.builder::<Block>()?
|
||||
// make sure the state is being build with the parent hash, if it is online.
|
||||
.overwrite_online_at(parent_hash.to_owned())
|
||||
.state_version(shared.state_version);
|
||||
log::info!(target: LOG_TARGET, "fetching next block: {:?} ", next_hash);
|
||||
|
||||
let builder = if command.overwrite_wasm_code {
|
||||
log::info!(
|
||||
target: LOG_TARGET,
|
||||
"replacing the in-storage :code: with the local code from {}'s chain_spec (your local repo)",
|
||||
config.chain_spec.name(),
|
||||
);
|
||||
let (code_key, code) = extract_code(&config.chain_spec)?;
|
||||
builder.inject_hashed_key_value(&[(code_key, code)])
|
||||
} else {
|
||||
builder.inject_hashed_key(well_known_keys::CODE)
|
||||
};
|
||||
|
||||
builder.build().await?
|
||||
};
|
||||
let block = ChainApi::<(), Block::Hash, Block::Header, SignedBlock<Block>>::block(
|
||||
&rpc,
|
||||
Some(next_hash),
|
||||
)
|
||||
.await
|
||||
.map_err(rpc_err_handler)?
|
||||
.expect("header exists, block should also exist; qed")
|
||||
.block;
|
||||
|
||||
// A digest item gets added when the runtime is processing the block, so we need to pop
|
||||
// the last one to be consistent with what a gossiped block would contain.
|
||||
let (mut header, extrinsics) = block.deconstruct();
|
||||
header.digest_mut().pop();
|
||||
let block = Block::new(header, extrinsics);
|
||||
let payload = (block.clone(), !command.no_state_root_check, command.try_state).encode();
|
||||
|
||||
let (expected_spec_name, expected_spec_version, _) =
|
||||
local_spec::<Block, ExecDispatch>(&ext, &executor);
|
||||
ensure_matching_spec::<Block>(
|
||||
block_ws_uri.clone(),
|
||||
expected_spec_name,
|
||||
expected_spec_version,
|
||||
shared.no_spec_check_panic,
|
||||
)
|
||||
.await;
|
||||
// for now, hardcoded for the sake of simplicity. We might customize them one day.
|
||||
let state_root_check = false;
|
||||
let signature_check = false;
|
||||
let payload = (block.clone(), state_root_check, signature_check, command.try_state).encode();
|
||||
|
||||
let _ = state_machine_call_with_proof::<Block, ExecDispatch>(
|
||||
let _ = state_machine_call_with_proof::<Block, HostFns>(
|
||||
&ext,
|
||||
&executor,
|
||||
execution,
|
||||
"TryRuntime_execute_block",
|
||||
&payload,
|
||||
full_extensions(),
|
||||
)?;
|
||||
|
||||
log::info!(target: LOG_TARGET, "Core_execute_block executed without errors.");
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub(crate) async fn next_hash_of<Block: BlockT>(
|
||||
rpc: &substrate_rpc_client::WsClient,
|
||||
hash: Block::Hash,
|
||||
) -> sc_cli::Result<Block::Hash>
|
||||
where
|
||||
Block: BlockT + serde::de::DeserializeOwned,
|
||||
Block::Header: serde::de::DeserializeOwned,
|
||||
{
|
||||
let number = ChainApi::<(), Block::Hash, Block::Header, ()>::header(rpc, Some(hash))
|
||||
.await
|
||||
.map_err(rpc_err_handler)
|
||||
.and_then(|maybe_header| maybe_header.ok_or("header_not_found").map(|h| *h.number()))?;
|
||||
|
||||
let next = number + sp_runtime::traits::One::one();
|
||||
|
||||
let next_hash = match ChainApi::<(), Block::Hash, Block::Header, ()>::block_hash(
|
||||
rpc,
|
||||
Some(ListOrValue::Value(NumberOrHex::Number(
|
||||
next.try_into().map_err(|_| "failed to convert number to block number")?,
|
||||
))),
|
||||
)
|
||||
.await
|
||||
.map_err(rpc_err_handler)?
|
||||
{
|
||||
ListOrValue::Value(t) => t.expect("value passed in; value comes out; qed"),
|
||||
_ => unreachable!(),
|
||||
};
|
||||
|
||||
Ok(next_hash)
|
||||
}
|
||||
|
||||
@@ -16,32 +16,33 @@
|
||||
// limitations under the License.
|
||||
|
||||
use crate::{
|
||||
build_executor, ensure_matching_spec, extract_code, full_extensions, local_spec, parse,
|
||||
state_machine_call_with_proof, SharedParams, LOG_TARGET,
|
||||
build_executor, full_extensions, parse, rpc_err_handler, state_machine_call_with_proof,
|
||||
LiveState, SharedParams, State, LOG_TARGET,
|
||||
};
|
||||
use parity_scale_codec::{Decode, Encode};
|
||||
use remote_externalities::{Builder, Mode, OnlineConfig};
|
||||
use sc_executor::NativeExecutionDispatch;
|
||||
use sc_service::Configuration;
|
||||
use sc_executor::sp_wasm_interface::HostFunctions;
|
||||
use serde::{de::DeserializeOwned, Serialize};
|
||||
use sp_core::H256;
|
||||
use sp_runtime::traits::{Block as BlockT, Header as HeaderT, NumberFor};
|
||||
use sp_runtime::{
|
||||
generic::SignedBlock,
|
||||
traits::{Block as BlockT, Header as HeaderT, NumberFor},
|
||||
};
|
||||
use std::{fmt::Debug, str::FromStr};
|
||||
use substrate_rpc_client::{ws_client, ChainApi, FinalizedHeaders, Subscription, WsClient};
|
||||
|
||||
const SUB: &str = "chain_subscribeFinalizedHeads";
|
||||
const UN_SUB: &str = "chain_unsubscribeFinalizedHeads";
|
||||
|
||||
/// Configurations of the [`Command::FollowChain`].
|
||||
/// Configurations of the [`crate::Command::FollowChain`].
|
||||
#[derive(Debug, Clone, clap::Parser)]
|
||||
pub struct FollowChainCmd {
|
||||
/// The url to connect to.
|
||||
#[arg(short, long, value_parser = parse::url)]
|
||||
uri: String,
|
||||
pub uri: String,
|
||||
|
||||
/// If set, then the state root check is enabled.
|
||||
#[arg(long)]
|
||||
state_root_check: bool,
|
||||
pub state_root_check: bool,
|
||||
|
||||
/// Which try-state targets to execute when running this command.
|
||||
///
|
||||
@@ -52,12 +53,12 @@ pub struct FollowChainCmd {
|
||||
/// `Staking, System`).
|
||||
/// - `rr-[x]` where `[x]` is a number. Then, the given number of pallets are checked in a
|
||||
/// round-robin fashion.
|
||||
#[arg(long, default_value = "none")]
|
||||
try_state: frame_try_runtime::TryStateSelect,
|
||||
#[arg(long, default_value = "all")]
|
||||
pub try_state: frame_try_runtime::TryStateSelect,
|
||||
|
||||
/// If present, a single connection to a node will be kept and reused for fetching blocks.
|
||||
#[arg(long)]
|
||||
keep_connection: bool,
|
||||
pub keep_connection: bool,
|
||||
}
|
||||
|
||||
/// Start listening for with `SUB` at `url`.
|
||||
@@ -77,10 +78,9 @@ async fn start_subscribing<Header: DeserializeOwned + Serialize + Send + Sync +
|
||||
Ok((client, sub))
|
||||
}
|
||||
|
||||
pub(crate) async fn follow_chain<Block, ExecDispatch>(
|
||||
pub(crate) async fn follow_chain<Block, HostFns>(
|
||||
shared: SharedParams,
|
||||
command: FollowChainCmd,
|
||||
config: Configuration,
|
||||
) -> sc_cli::Result<()>
|
||||
where
|
||||
Block: BlockT<Hash = H256> + DeserializeOwned,
|
||||
@@ -89,26 +89,35 @@ where
|
||||
<Block::Hash as FromStr>::Err: Debug,
|
||||
NumberFor<Block>: FromStr,
|
||||
<NumberFor<Block> as FromStr>::Err: Debug,
|
||||
ExecDispatch: NativeExecutionDispatch + 'static,
|
||||
HostFns: HostFunctions,
|
||||
{
|
||||
let mut maybe_state_ext = None;
|
||||
let (rpc, subscription) = start_subscribing::<Block::Header>(&command.uri).await?;
|
||||
|
||||
let (code_key, code) = extract_code(&config.chain_spec)?;
|
||||
let executor = build_executor::<ExecDispatch>(&shared, &config);
|
||||
let execution = shared.execution;
|
||||
|
||||
let mut finalized_headers: FinalizedHeaders<Block, _, _> =
|
||||
FinalizedHeaders::new(&rpc, subscription);
|
||||
|
||||
let mut maybe_state_ext = None;
|
||||
let executor = build_executor::<HostFns>(&shared);
|
||||
|
||||
while let Some(header) = finalized_headers.next().await {
|
||||
let hash = header.hash();
|
||||
let number = header.number();
|
||||
|
||||
let block: Block = ChainApi::<(), Block::Hash, Block::Header, _>::block(&rpc, Some(hash))
|
||||
.await
|
||||
.unwrap()
|
||||
.unwrap();
|
||||
let block =
|
||||
ChainApi::<(), Block::Hash, Block::Header, SignedBlock<Block>>::block(&rpc, Some(hash))
|
||||
.await
|
||||
.or_else(|e| {
|
||||
if matches!(e, substrate_rpc_client::Error::ParseError(_)) {
|
||||
log::error!(
|
||||
"failed to parse the block format of remote against the local \
|
||||
codebase. The block format has changed, and follow-chain cannot run in \
|
||||
this case. Try running this command in a branch of your codebase that has \
|
||||
the same block format as the remote chain. For now, we replace the block with an empty one"
|
||||
);
|
||||
}
|
||||
Err(rpc_err_handler(e))
|
||||
})?
|
||||
.expect("if header exists, block should also exist.")
|
||||
.block;
|
||||
|
||||
log::debug!(
|
||||
target: LOG_TARGET,
|
||||
@@ -120,49 +129,40 @@ where
|
||||
|
||||
// create an ext at the state of this block, whatever is the first subscription event.
|
||||
if maybe_state_ext.is_none() {
|
||||
let builder = Builder::<Block>::new()
|
||||
.mode(Mode::Online(OnlineConfig {
|
||||
transport: command.uri.clone().into(),
|
||||
at: Some(*header.parent_hash()),
|
||||
..Default::default()
|
||||
}))
|
||||
.state_version(shared.state_version);
|
||||
|
||||
let new_ext = builder
|
||||
.inject_hashed_key_value(&[(code_key.clone(), code.clone())])
|
||||
.build()
|
||||
.await?;
|
||||
log::info!(
|
||||
target: LOG_TARGET,
|
||||
"initialized state externalities at {:?}, storage root {:?}",
|
||||
number,
|
||||
new_ext.as_backend().root()
|
||||
);
|
||||
|
||||
let (expected_spec_name, expected_spec_version, spec_state_version) =
|
||||
local_spec::<Block, ExecDispatch>(&new_ext, &executor);
|
||||
ensure_matching_spec::<Block>(
|
||||
command.uri.clone(),
|
||||
expected_spec_name,
|
||||
expected_spec_version,
|
||||
shared.no_spec_check_panic,
|
||||
)
|
||||
.await;
|
||||
|
||||
maybe_state_ext = Some((new_ext, spec_state_version));
|
||||
let state = State::Live(LiveState {
|
||||
uri: command.uri.clone(),
|
||||
// a bit dodgy, we have to un-parse the has to a string again and re-parse it
|
||||
// inside.
|
||||
at: Some(hex::encode(header.parent_hash().encode())),
|
||||
pallet: vec![],
|
||||
child_tree: true,
|
||||
});
|
||||
let ext = state.into_ext::<Block, HostFns>(&shared, &executor, None).await?;
|
||||
maybe_state_ext = Some(ext);
|
||||
}
|
||||
|
||||
let (state_ext, spec_state_version) =
|
||||
let state_ext =
|
||||
maybe_state_ext.as_mut().expect("state_ext either existed or was just created");
|
||||
|
||||
let (mut changes, encoded_result) = state_machine_call_with_proof::<Block, ExecDispatch>(
|
||||
let result = state_machine_call_with_proof::<Block, HostFns>(
|
||||
state_ext,
|
||||
&executor,
|
||||
execution,
|
||||
"TryRuntime_execute_block",
|
||||
(block, command.state_root_check, command.try_state.clone()).encode().as_ref(),
|
||||
full_extensions(),
|
||||
)?;
|
||||
);
|
||||
|
||||
if let Err(why) = result {
|
||||
log::error!(
|
||||
target: LOG_TARGET,
|
||||
"failed to execute block {:?} due to {:?}",
|
||||
number,
|
||||
why
|
||||
);
|
||||
continue
|
||||
}
|
||||
|
||||
let (mut changes, encoded_result) = result.expect("checked to be Ok; qed");
|
||||
|
||||
let consumed_weight = <sp_weights::Weight as Decode>::decode(&mut &*encoded_result)
|
||||
.map_err(|e| format!("failed to decode weight: {:?}", e))?;
|
||||
@@ -171,13 +171,13 @@ where
|
||||
.drain_storage_changes(
|
||||
&state_ext.backend,
|
||||
&mut Default::default(),
|
||||
// Note that in case a block contains a runtime upgrade,
|
||||
// state version could potentially be incorrect here,
|
||||
// this is very niche and would only result in unaligned
|
||||
// roots, so this use case is ignored for now.
|
||||
*spec_state_version,
|
||||
// Note that in case a block contains a runtime upgrade, state version could
|
||||
// potentially be incorrect here, this is very niche and would only result in
|
||||
// unaligned roots, so this use case is ignored for now.
|
||||
state_ext.state_version,
|
||||
)
|
||||
.unwrap();
|
||||
|
||||
state_ext.backend.apply_transaction(
|
||||
storage_changes.transaction_storage_root,
|
||||
storage_changes.transaction,
|
||||
|
||||
@@ -15,7 +15,8 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
pub(crate) mod execute_block;
|
||||
pub(crate) mod follow_chain;
|
||||
pub(crate) mod offchain_worker;
|
||||
pub(crate) mod on_runtime_upgrade;
|
||||
pub mod create_snapshot;
|
||||
pub mod execute_block;
|
||||
pub mod follow_chain;
|
||||
pub mod offchain_worker;
|
||||
pub mod on_runtime_upgrade;
|
||||
|
||||
@@ -16,34 +16,18 @@
|
||||
// limitations under the License.
|
||||
|
||||
use crate::{
|
||||
build_executor, ensure_matching_spec, extract_code, full_extensions, hash_of, local_spec,
|
||||
parse, state_machine_call, SharedParams, State, LOG_TARGET,
|
||||
build_executor, commands::execute_block::next_hash_of, full_extensions, parse, rpc_err_handler,
|
||||
state_machine_call, LiveState, SharedParams, State, LOG_TARGET,
|
||||
};
|
||||
use parity_scale_codec::Encode;
|
||||
use sc_executor::NativeExecutionDispatch;
|
||||
use sc_service::Configuration;
|
||||
use sp_core::storage::well_known_keys;
|
||||
use sp_runtime::traits::{Block as BlockT, Header, NumberFor};
|
||||
use sc_executor::sp_wasm_interface::HostFunctions;
|
||||
use sp_runtime::traits::{Block as BlockT, NumberFor};
|
||||
use std::{fmt::Debug, str::FromStr};
|
||||
use substrate_rpc_client::{ws_client, ChainApi};
|
||||
|
||||
/// Configurations of the [`Command::OffchainWorker`].
|
||||
/// Configurations of the [`crate::Command::OffchainWorker`].
|
||||
#[derive(Debug, Clone, clap::Parser)]
|
||||
pub struct OffchainWorkerCmd {
|
||||
/// Overwrite the wasm code in state or not.
|
||||
#[arg(long)]
|
||||
overwrite_wasm_code: bool,
|
||||
|
||||
/// The block hash at which to fetch the header.
|
||||
///
|
||||
/// If the `live` state type is being used, then this can be omitted, and is equal to whatever
|
||||
/// the `state::at` is. Only use this (with care) when combined with a snapshot.
|
||||
#[arg(
|
||||
long,
|
||||
value_parser = parse::hash
|
||||
)]
|
||||
header_at: Option<String>,
|
||||
|
||||
/// The ws uri from which to fetch the header.
|
||||
///
|
||||
/// If the `live` state type is being used, then this can be omitted, and is equal to whatever
|
||||
@@ -52,7 +36,7 @@ pub struct OffchainWorkerCmd {
|
||||
long,
|
||||
value_parser = parse::url
|
||||
)]
|
||||
header_ws_uri: Option<String>,
|
||||
pub header_ws_uri: Option<String>,
|
||||
|
||||
/// The state type to use.
|
||||
#[command(subcommand)]
|
||||
@@ -60,24 +44,6 @@ pub struct OffchainWorkerCmd {
|
||||
}
|
||||
|
||||
impl OffchainWorkerCmd {
|
||||
fn header_at<Block: BlockT>(&self) -> sc_cli::Result<Block::Hash>
|
||||
where
|
||||
Block::Hash: FromStr,
|
||||
<Block::Hash as FromStr>::Err: Debug,
|
||||
{
|
||||
match (&self.header_at, &self.state) {
|
||||
(Some(header_at), State::Snap { .. }) => hash_of::<Block>(header_at),
|
||||
(Some(header_at), State::Live { .. }) => {
|
||||
log::error!(target: LOG_TARGET, "--header-at is provided while state type is live, this will most likely lead to a nonsensical result.");
|
||||
hash_of::<Block>(header_at)
|
||||
},
|
||||
(None, State::Live { at: Some(at), .. }) => hash_of::<Block>(at),
|
||||
_ => {
|
||||
panic!("either `--header-at` must be provided, or state must be `live` with a proper `--at`");
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
fn header_ws_uri<Block: BlockT>(&self) -> String
|
||||
where
|
||||
Block::Hash: FromStr,
|
||||
@@ -89,7 +55,7 @@ impl OffchainWorkerCmd {
|
||||
log::error!(target: LOG_TARGET, "--header-uri is provided while state type is live, this will most likely lead to a nonsensical result.");
|
||||
header_ws_uri.to_owned()
|
||||
},
|
||||
(None, State::Live { uri, .. }) => uri.clone(),
|
||||
(None, State::Live(LiveState { uri, .. })) => uri.clone(),
|
||||
(None, State::Snap { .. }) => {
|
||||
panic!("either `--header-uri` must be provided, or state must be `live`");
|
||||
},
|
||||
@@ -97,76 +63,42 @@ impl OffchainWorkerCmd {
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) async fn offchain_worker<Block, ExecDispatch>(
|
||||
pub(crate) async fn offchain_worker<Block, HostFns>(
|
||||
shared: SharedParams,
|
||||
command: OffchainWorkerCmd,
|
||||
config: Configuration,
|
||||
) -> sc_cli::Result<()>
|
||||
where
|
||||
Block: BlockT + serde::de::DeserializeOwned,
|
||||
Block::Hash: FromStr,
|
||||
Block::Header: serde::de::DeserializeOwned,
|
||||
Block::Hash: FromStr,
|
||||
<Block::Hash as FromStr>::Err: Debug,
|
||||
NumberFor<Block>: FromStr,
|
||||
<NumberFor<Block> as FromStr>::Err: Debug,
|
||||
ExecDispatch: NativeExecutionDispatch + 'static,
|
||||
HostFns: HostFunctions,
|
||||
{
|
||||
let executor = build_executor(&shared, &config);
|
||||
let execution = shared.execution;
|
||||
let executor = build_executor(&shared);
|
||||
// we first build the externalities with the remote code.
|
||||
let ext = command.state.into_ext::<Block, HostFns>(&shared, &executor, None).await?;
|
||||
|
||||
let header_at = command.header_at::<Block>()?;
|
||||
let header_ws_uri = command.header_ws_uri::<Block>();
|
||||
|
||||
let rpc = ws_client(&header_ws_uri).await?;
|
||||
let header = ChainApi::<(), Block::Hash, Block::Header, ()>::header(&rpc, Some(header_at))
|
||||
let next_hash = next_hash_of::<Block>(&rpc, ext.block_hash).await?;
|
||||
log::info!(target: LOG_TARGET, "fetching next header: {:?} ", next_hash);
|
||||
|
||||
let header = ChainApi::<(), Block::Hash, Block::Header, ()>::header(&rpc, Some(next_hash))
|
||||
.await
|
||||
.unwrap()
|
||||
.unwrap();
|
||||
log::info!(
|
||||
target: LOG_TARGET,
|
||||
"fetched header from {:?}, block number: {:?}",
|
||||
header_ws_uri,
|
||||
header.number()
|
||||
);
|
||||
.map_err(rpc_err_handler)
|
||||
.map(|maybe_header| maybe_header.ok_or("Header does not exist"))??;
|
||||
let payload = header.encode();
|
||||
|
||||
let ext = {
|
||||
let builder = command.state.builder::<Block>()?.state_version(shared.state_version);
|
||||
|
||||
let builder = if command.overwrite_wasm_code {
|
||||
log::info!(
|
||||
target: LOG_TARGET,
|
||||
"replacing the in-storage :code: with the local code from {}'s chain_spec (your local repo)",
|
||||
config.chain_spec.name(),
|
||||
);
|
||||
let (code_key, code) = extract_code(&config.chain_spec)?;
|
||||
builder.inject_hashed_key_value(&[(code_key, code)])
|
||||
} else {
|
||||
builder.inject_hashed_key(well_known_keys::CODE)
|
||||
};
|
||||
|
||||
builder.build().await?
|
||||
};
|
||||
|
||||
let (expected_spec_name, expected_spec_version, _) =
|
||||
local_spec::<Block, ExecDispatch>(&ext, &executor);
|
||||
ensure_matching_spec::<Block>(
|
||||
header_ws_uri,
|
||||
expected_spec_name,
|
||||
expected_spec_version,
|
||||
shared.no_spec_check_panic,
|
||||
)
|
||||
.await;
|
||||
|
||||
let _ = state_machine_call::<Block, ExecDispatch>(
|
||||
let _ = state_machine_call::<Block, HostFns>(
|
||||
&ext,
|
||||
&executor,
|
||||
execution,
|
||||
"OffchainWorkerApi_offchain_worker",
|
||||
header.encode().as_ref(),
|
||||
&payload,
|
||||
full_extensions(),
|
||||
)?;
|
||||
|
||||
log::info!(target: LOG_TARGET, "OffchainWorkerApi_offchain_worker executed without errors.");
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -15,31 +15,31 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
use std::{fmt::Debug, str::FromStr};
|
||||
|
||||
use parity_scale_codec::Decode;
|
||||
use sc_executor::NativeExecutionDispatch;
|
||||
use sc_service::Configuration;
|
||||
use crate::{build_executor, state_machine_call_with_proof, SharedParams, State, LOG_TARGET};
|
||||
use parity_scale_codec::{Decode, Encode};
|
||||
use sc_executor::sp_wasm_interface::HostFunctions;
|
||||
use sp_runtime::traits::{Block as BlockT, NumberFor};
|
||||
use sp_weights::Weight;
|
||||
use std::{fmt::Debug, str::FromStr};
|
||||
|
||||
use crate::{
|
||||
build_executor, ensure_matching_spec, extract_code, local_spec, state_machine_call_with_proof,
|
||||
SharedParams, State, LOG_TARGET,
|
||||
};
|
||||
|
||||
/// Configurations of the [`Command::OnRuntimeUpgrade`].
|
||||
/// Configurations of the [`crate::Command::OnRuntimeUpgrade`].
|
||||
#[derive(Debug, Clone, clap::Parser)]
|
||||
pub struct OnRuntimeUpgradeCmd {
|
||||
/// The state type to use.
|
||||
#[command(subcommand)]
|
||||
pub state: State,
|
||||
|
||||
/// Execute `try_state`, `pre_upgrade` and `post_upgrade` checks as well.
|
||||
///
|
||||
/// This will perform more checks, but it will also makes the reported PoV/Weight be
|
||||
/// inaccurate.
|
||||
#[clap(long)]
|
||||
pub checks: bool,
|
||||
}
|
||||
|
||||
pub(crate) async fn on_runtime_upgrade<Block, ExecDispatch>(
|
||||
pub(crate) async fn on_runtime_upgrade<Block, HostFns>(
|
||||
shared: SharedParams,
|
||||
command: OnRuntimeUpgradeCmd,
|
||||
config: Configuration,
|
||||
) -> sc_cli::Result<()>
|
||||
where
|
||||
Block: BlockT + serde::de::DeserializeOwned,
|
||||
@@ -48,40 +48,22 @@ where
|
||||
Block::Header: serde::de::DeserializeOwned,
|
||||
NumberFor<Block>: FromStr,
|
||||
<NumberFor<Block> as FromStr>::Err: Debug,
|
||||
ExecDispatch: NativeExecutionDispatch + 'static,
|
||||
HostFns: HostFunctions,
|
||||
{
|
||||
let executor = build_executor(&shared, &config);
|
||||
let execution = shared.execution;
|
||||
let executor = build_executor(&shared);
|
||||
let ext = command.state.into_ext::<Block, HostFns>(&shared, &executor, None).await?;
|
||||
|
||||
let ext = {
|
||||
let builder = command.state.builder::<Block>()?.state_version(shared.state_version);
|
||||
let (code_key, code) = extract_code(&config.chain_spec)?;
|
||||
builder.inject_hashed_key_value(&[(code_key, code)]).build().await?
|
||||
};
|
||||
|
||||
if let Some(uri) = command.state.live_uri() {
|
||||
let (expected_spec_name, expected_spec_version, _) =
|
||||
local_spec::<Block, ExecDispatch>(&ext, &executor);
|
||||
ensure_matching_spec::<Block>(
|
||||
uri,
|
||||
expected_spec_name,
|
||||
expected_spec_version,
|
||||
shared.no_spec_check_panic,
|
||||
)
|
||||
.await;
|
||||
}
|
||||
|
||||
let (_, encoded_result) = state_machine_call_with_proof::<Block, ExecDispatch>(
|
||||
let (_, encoded_result) = state_machine_call_with_proof::<Block, HostFns>(
|
||||
&ext,
|
||||
&executor,
|
||||
execution,
|
||||
"TryRuntime_on_runtime_upgrade",
|
||||
&[],
|
||||
command.checks.encode().as_ref(),
|
||||
Default::default(), // we don't really need any extensions here.
|
||||
)?;
|
||||
|
||||
let (weight, total_weight) = <(Weight, Weight) as Decode>::decode(&mut &*encoded_result)
|
||||
.map_err(|e| format!("failed to decode weight: {:?}", e))?;
|
||||
|
||||
log::info!(
|
||||
target: LOG_TARGET,
|
||||
"TryRuntime_on_runtime_upgrade executed without errors. Consumed weight = ({} ps, {} byte), total weight = ({} ps, {} byte) ({:.2} %, {:.2} %).",
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user