From e76dcff8145822f1d4176897c0bb26281eb89018 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bastian=20K=C3=B6cher?= Date: Wed, 28 Jun 2023 09:49:45 +0200 Subject: [PATCH 1/4] frame-benchmarking-cli: Remove native dispatch requirement No need for this, we can just use the `WasmExecutor` directly. --- Cargo.lock | 1 + utils/frame/benchmarking-cli/Cargo.toml | 1 + .../benchmarking-cli/src/pallet/command.rs | 21 ++++++++----------- 3 files changed, 11 insertions(+), 12 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index d3c376952b7be..4f415ae0868a3 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2600,6 +2600,7 @@ dependencies = [ "sp-database", "sp-externalities", "sp-inherents", + "sp-io", "sp-keystore", "sp-runtime", "sp-state-machine", diff --git a/utils/frame/benchmarking-cli/Cargo.toml b/utils/frame/benchmarking-cli/Cargo.toml index 899ba955b2f58..3d4d25475a212 100644 --- a/utils/frame/benchmarking-cli/Cargo.toml +++ b/utils/frame/benchmarking-cli/Cargo.toml @@ -51,6 +51,7 @@ sp-runtime = { version = "24.0.0", path = "../../../primitives/runtime" } sp-state-machine = { version = "0.28.0", path = "../../../primitives/state-machine" } sp-storage = { version = "13.0.0", path = "../../../primitives/storage" } sp-trie = { version = "22.0.0", path = "../../../primitives/trie" } +sp-io = { version = "23.0.0", path = "../../../primitives/io" } gethostname = "0.2.3" [features] diff --git a/utils/frame/benchmarking-cli/src/pallet/command.rs b/utils/frame/benchmarking-cli/src/pallet/command.rs index 702ec27561dcc..599f1c25af5fc 100644 --- a/utils/frame/benchmarking-cli/src/pallet/command.rs +++ b/utils/frame/benchmarking-cli/src/pallet/command.rs @@ -27,8 +27,8 @@ use sc_cli::{ execution_method_from_cli, CliConfiguration, ExecutionStrategy, Result, SharedParams, }; use sc_client_db::BenchmarkingState; -use sc_executor::{NativeElseWasmExecutor, WasmExecutor}; -use sc_service::{Configuration, NativeExecutionDispatch}; +use sc_executor::WasmExecutor; +use sc_service::Configuration; use serde::Serialize; use sp_core::{ offchain::{ @@ -143,11 +143,10 @@ not created by a node that was compiled with the flag"; impl PalletCmd { /// Runs the command and benchmarks the chain. - pub fn run(&self, config: Configuration) -> Result<()> + pub fn run(&self, config: Configuration) -> Result<()> where BB: BlockT + Debug, <<::Header as HeaderT>::Number as std::str::FromStr>::Err: std::fmt::Debug, - ExecDispatch: NativeExecutionDispatch + 'static, { if let Some(output_path) = &self.output { if !output_path.is_dir() && output_path.file_name().is_none() { @@ -182,7 +181,7 @@ impl PalletCmd { } let spec = config.chain_spec; - let strategy = self.execution.unwrap_or(ExecutionStrategy::Native); + let strategy = self.execution.unwrap_or(ExecutionStrategy::Wasm); let pallet = self.pallet.clone().unwrap_or_default(); let pallet = pallet.as_bytes(); let extrinsic = self.extrinsic.clone().unwrap_or_default(); @@ -212,13 +211,11 @@ impl PalletCmd { let method = execution_method_from_cli(self.wasm_method, self.wasmtime_instantiation_strategy); - let executor = NativeElseWasmExecutor::::new_with_wasm_executor( - WasmExecutor::builder() - .with_execution_method(method) - .with_max_runtime_instances(2) - .with_runtime_cache_size(2) - .build(), - ); + let executor = WasmExecutor::::builder() + .with_execution_method(method) + .with_max_runtime_instances(2) + .with_runtime_cache_size(2) + .build(); let extensions = || -> Extensions { let mut extensions = Extensions::default(); From a5ccf41ecdddb86fc757b305e95682bc0cabe449 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bastian=20K=C3=B6cher?= Date: Wed, 28 Jun 2023 10:24:03 +0200 Subject: [PATCH 2/4] Fixes --- bin/node-template/node/src/command.rs | 2 +- bin/node/cli/src/command.rs | 2 +- client/consensus/babe/src/lib.rs | 8 ++-- client/consensus/beefy/src/worker.rs | 8 ++-- .../src/protocol/notifications/behaviour.rs | 24 +++++----- client/network/src/service/traits.rs | 4 +- client/rpc-spec-v2/src/chain_head/event.rs | 8 ++-- frame/benchmarking/src/lib.rs | 23 +++++---- frame/contracts/src/schedule.rs | 29 ++++++----- frame/im-online/src/lib.rs | 2 +- frame/recovery/src/lib.rs | 48 +++++++++---------- frame/support/src/lib.rs | 16 +++---- primitives/npos-elections/src/balancing.rs | 2 +- primitives/runtime/src/offchain/http.rs | 8 ++-- primitives/staking/src/offence.rs | 16 +++---- utils/wasm-builder/src/builder.rs | 4 +- 16 files changed, 97 insertions(+), 107 deletions(-) diff --git a/bin/node-template/node/src/command.rs b/bin/node-template/node/src/command.rs index e121db820f2a3..e8d766dedee00 100644 --- a/bin/node-template/node/src/command.rs +++ b/bin/node-template/node/src/command.rs @@ -124,7 +124,7 @@ pub fn run() -> sc_cli::Result<()> { ) } - cmd.run::(config) + cmd.run::(config) }, BenchmarkCmd::Block(cmd) => { let PartialComponents { client, .. } = service::new_partial(&config)?; diff --git a/bin/node/cli/src/command.rs b/bin/node/cli/src/command.rs index b38b25d8fb3ad..dd123aae7dae0 100644 --- a/bin/node/cli/src/command.rs +++ b/bin/node/cli/src/command.rs @@ -117,7 +117,7 @@ pub fn run() -> Result<()> { ) } - cmd.run::(config) + cmd.run::(config) }, BenchmarkCmd::Block(cmd) => { // ensure that we keep the task manager alive diff --git a/client/consensus/babe/src/lib.rs b/client/consensus/babe/src/lib.rs index 219b52294952a..64ff00bb58c35 100644 --- a/client/consensus/babe/src/lib.rs +++ b/client/consensus/babe/src/lib.rs @@ -1152,10 +1152,10 @@ where // Verification for imported blocks is skipped in two cases: // 1. When importing blocks below the last finalized block during network initial // synchronization. - // 2. When importing whole state we don't calculate epoch descriptor, but rather - // read it from the state after import. We also skip all verifications - // because there's no parent state and we trust the sync module to verify - // that the state is correct and finalized. + // 2. When importing whole state we don't calculate epoch descriptor, but rather read it + // from the state after import. We also skip all verifications because there's no + // parent state and we trust the sync module to verify that the state is correct and + // finalized. return Ok(block) } diff --git a/client/consensus/beefy/src/worker.rs b/client/consensus/beefy/src/worker.rs index cbf58e56b2cdf..91b00ddb2cef0 100644 --- a/client/consensus/beefy/src/worker.rs +++ b/client/consensus/beefy/src/worker.rs @@ -78,11 +78,11 @@ pub(crate) struct VoterOracle { /// /// There are three voter states coresponding to three queue states: /// 1. voter uninitialized: queue empty, - /// 2. up-to-date - all mandatory blocks leading up to current GRANDPA finalized: - /// queue has ONE element, the 'current session' where `mandatory_done == true`, + /// 2. up-to-date - all mandatory blocks leading up to current GRANDPA finalized: queue has ONE + /// element, the 'current session' where `mandatory_done == true`, /// 3. lagging behind GRANDPA: queue has [1, N] elements, where all `mandatory_done == false`. - /// In this state, everytime a session gets its mandatory block BEEFY finalized, it's - /// popped off the queue, eventually getting to state `2. up-to-date`. + /// In this state, everytime a session gets its mandatory block BEEFY finalized, it's popped + /// off the queue, eventually getting to state `2. up-to-date`. sessions: VecDeque>, /// Min delta in block numbers between two blocks, BEEFY should vote on. min_block_delta: u32, diff --git a/client/network/src/protocol/notifications/behaviour.rs b/client/network/src/protocol/notifications/behaviour.rs index 42233288afe08..1659626cae4c8 100644 --- a/client/network/src/protocol/notifications/behaviour.rs +++ b/client/network/src/protocol/notifications/behaviour.rs @@ -84,19 +84,17 @@ use std::{ /// the API of this behaviour and towards the peerset manager is aggregated in /// the following way: /// -/// 1. The enabled/disabled status is the same across all connections, as -/// decided by the peerset manager. -/// 2. `send_packet` and `write_notification` always send all data over -/// the same connection to preserve the ordering provided by the transport, -/// as long as that connection is open. If it closes, a second open -/// connection may take over, if one exists, but that case should be no -/// different than a single connection failing and being re-established -/// in terms of potential reordering and dropped messages. Messages can -/// be received on any connection. -/// 3. The behaviour reports `NotificationsOut::CustomProtocolOpen` when the -/// first connection reports `NotifsHandlerOut::OpenResultOk`. -/// 4. The behaviour reports `NotificationsOut::CustomProtocolClosed` when the -/// last connection reports `NotifsHandlerOut::ClosedResult`. +/// 1. The enabled/disabled status is the same across all connections, as decided by the peerset +/// manager. +/// 2. `send_packet` and `write_notification` always send all data over the same connection to +/// preserve the ordering provided by the transport, as long as that connection is open. If it +/// closes, a second open connection may take over, if one exists, but that case should be no +/// different than a single connection failing and being re-established in terms of potential +/// reordering and dropped messages. Messages can be received on any connection. +/// 3. The behaviour reports `NotificationsOut::CustomProtocolOpen` when the first connection +/// reports `NotifsHandlerOut::OpenResultOk`. +/// 4. The behaviour reports `NotificationsOut::CustomProtocolClosed` when the last connection +/// reports `NotifsHandlerOut::ClosedResult`. /// /// In this way, the number of actual established connections to the peer is /// an implementation detail of this behaviour. Note that, in practice and at diff --git a/client/network/src/service/traits.rs b/client/network/src/service/traits.rs index 97680a9eb73b7..bebf5a5713c45 100644 --- a/client/network/src/service/traits.rs +++ b/client/network/src/service/traits.rs @@ -402,9 +402,9 @@ pub trait NetworkNotification { /// a receiver. With a `NotificationSender` at hand, sending a notification is done in two /// steps: /// - /// 1. [`NotificationSender::ready`] is used to wait for the sender to become ready + /// 1. [`NotificationSender::ready`] is used to wait for the sender to become ready /// for another notification, yielding a [`NotificationSenderReady`] token. - /// 2. [`NotificationSenderReady::send`] enqueues the notification for sending. This operation + /// 2. [`NotificationSenderReady::send`] enqueues the notification for sending. This operation /// can only fail if the underlying notification substream or connection has suddenly closed. /// /// An error is returned by [`NotificationSenderReady::send`] if there exists no open diff --git a/client/rpc-spec-v2/src/chain_head/event.rs b/client/rpc-spec-v2/src/chain_head/event.rs index d0d4d1d43ac03..3c970729d6ab1 100644 --- a/client/rpc-spec-v2/src/chain_head/event.rs +++ b/client/rpc-spec-v2/src/chain_head/event.rs @@ -192,12 +192,10 @@ pub struct Finalized { /// The event generated by the `follow` method. /// /// The events are generated in the following order: -/// 1. Initialized - generated only once to signal the -/// latest finalized block +/// 1. Initialized - generated only once to signal the latest finalized block /// 2. NewBlock - a new block was added. -/// 3. BestBlockChanged - indicate that the best block -/// is now the one from this event. The block was -/// announced priorly with the `NewBlock` event. +/// 3. BestBlockChanged - indicate that the best block is now the one from this event. The block was +/// announced priorly with the `NewBlock` event. /// 4. Finalized - State the finalized and pruned blocks. #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] #[serde(rename_all = "camelCase")] diff --git a/frame/benchmarking/src/lib.rs b/frame/benchmarking/src/lib.rs index b11e164fe8e44..e5ec61d622e95 100644 --- a/frame/benchmarking/src/lib.rs +++ b/frame/benchmarking/src/lib.rs @@ -246,22 +246,21 @@ pub use v1::*; /// of impls and structs required by the benchmarking engine. Additionally, a benchmark /// function is also generated that resembles the function definition you provide, with a few /// modifications: -/// 1. The function name is transformed from i.e. `original_name` to `_original_name` so as not -/// to collide with the struct `original_name` that is created for some of the benchmarking -/// engine impls. -/// 2. Appropriate `T: Config` and `I` (if this is an instance benchmark) generics are added to -/// the function automatically during expansion, so you should not add these manually on -/// your function definition (but you may make use of `T` and `I` anywhere within your -/// benchmark function, in any of the three sections (setup, call, verification). +/// 1. The function name is transformed from i.e. `original_name` to `_original_name` so as not to +/// collide with the struct `original_name` that is created for some of the benchmarking engine +/// impls. +/// 2. Appropriate `T: Config` and `I` (if this is an instance benchmark) generics are added to the +/// function automatically during expansion, so you should not add these manually on your +/// function definition (but you may make use of `T` and `I` anywhere within your benchmark +/// function, in any of the three sections (setup, call, verification). /// 3. Arguments such as `u: Linear<10, 100>` are converted to `u: u32` to make the function /// directly callable. -/// 4. A `verify: bool` param is added as the last argument. Specifying `true` will result in -/// the verification section of your function executing, while a value of `false` will skip +/// 4. A `verify: bool` param is added as the last argument. Specifying `true` will result in the +/// verification section of your function executing, while a value of `false` will skip /// verification. /// 5. If you specify a return type on the function definition, it must conform to the [rules -/// below](#support-for-result-benchmarkerror-and-the--operator), and the last statement of -/// the function definition must resolve to something compatible with `Result<(), -/// BenchmarkError>`. +/// below](#support-for-result-benchmarkerror-and-the--operator), and the last statement of the +/// function definition must resolve to something compatible with `Result<(), BenchmarkError>`. /// /// The reason we generate an actual function as part of the expansion is to allow the compiler /// to enforce several constraints that would otherwise be difficult to enforce and to reduce diff --git a/frame/contracts/src/schedule.rs b/frame/contracts/src/schedule.rs index c6eedb155d6a4..94307811b8689 100644 --- a/frame/contracts/src/schedule.rs +++ b/frame/contracts/src/schedule.rs @@ -145,21 +145,20 @@ impl Limits { /// There there is one field for each wasm instruction that describes the weight to /// execute one instruction of that name. There are a few exceptions: /// -/// 1. If there is a i64 and a i32 variant of an instruction we use the weight -/// of the former for both. -/// 2. The following instructions are free of charge because they merely structure the -/// wasm module and cannot be spammed without making the module invalid (and rejected): -/// End, Unreachable, Return, Else -/// 3. The following instructions cannot be benchmarked because they are removed by any -/// real world execution engine as a preprocessing step and therefore don't yield a -/// meaningful benchmark result. However, in contrast to the instructions mentioned -/// in 2. they can be spammed. We price them with the same weight as the "default" -/// instruction (i64.const): Block, Loop, Nop -/// 4. We price both i64.const and drop as InstructionWeights.i64const / 2. The reason -/// for that is that we cannot benchmark either of them on its own but we need their -/// individual values to derive (by subtraction) the weight of all other instructions -/// that use them as supporting instructions. Supporting means mainly pushing arguments -/// and dropping return values in order to maintain a valid module. +/// 1. If there is a i64 and a i32 variant of an instruction we use the weight of the former for +/// both. +/// 2. The following instructions are free of charge because they merely structure the wasm module +/// and cannot be spammed without making the module invalid (and rejected): End, Unreachable, +/// Return, Else +/// 3. The following instructions cannot be benchmarked because they are removed by any real world +/// execution engine as a preprocessing step and therefore don't yield a meaningful benchmark +/// result. However, in contrast to the instructions mentioned in 2. they can be spammed. We +/// price them with the same weight as the "default" instruction (i64.const): Block, Loop, Nop +/// 4. We price both i64.const and drop as InstructionWeights.i64const / 2. The reason for that is +/// that we cannot benchmark either of them on its own but we need their individual values to +/// derive (by subtraction) the weight of all other instructions that use them as supporting +/// instructions. Supporting means mainly pushing arguments and dropping return values in order +/// to maintain a valid module. #[cfg_attr(feature = "std", derive(Serialize, Deserialize))] #[derive(Clone, Encode, Decode, PartialEq, Eq, ScheduleDebug, TypeInfo)] #[scale_info(skip_type_params(T))] diff --git a/frame/im-online/src/lib.rs b/frame/im-online/src/lib.rs index 1f9557a427293..e1adbc062424f 100644 --- a/frame/im-online/src/lib.rs +++ b/frame/im-online/src/lib.rs @@ -656,7 +656,7 @@ impl Pallet { // // At index `idx`: // 1. A (ImOnline) public key to be used by a validator at index `idx` to send im-online - // heartbeats. + // heartbeats. let authorities = Keys::::get(); // local keystore diff --git a/frame/recovery/src/lib.rs b/frame/recovery/src/lib.rs index d66b5725fd4f7..8f70ebfe5ec67 100644 --- a/frame/recovery/src/lib.rs +++ b/frame/recovery/src/lib.rs @@ -48,34 +48,30 @@ //! ### Recovery Life Cycle //! //! The intended life cycle of a successful recovery takes the following steps: -//! 1. The account owner calls `create_recovery` to set up a recovery configuration -//! for their account. -//! 2. At some later time, the account owner loses access to their account and wants -//! to recover it. Likely, they will need to create a new account and fund it with -//! enough balance to support the transaction fees and the deposit for the -//! recovery process. -//! 3. Using this new account, they call `initiate_recovery`. -//! 4. Then the account owner would contact their configured friends to vouch for -//! the recovery attempt. The account owner would provide their old account id -//! and the new account id, and friends would call `vouch_recovery` with those -//! parameters. -//! 5. Once a threshold number of friends have vouched for the recovery attempt, -//! the account owner needs to wait until the delay period has passed, starting -//! when they initiated the recovery process. -//! 6. Now the account owner is able to call `claim_recovery`, which subsequently -//! allows them to call `as_recovered` and directly make calls on-behalf-of the lost +//! 1. The account owner calls `create_recovery` to set up a recovery configuration for their //! account. -//! 7. Using the now recovered account, the account owner can call `close_recovery` -//! on the recovery process they opened, reclaiming the recovery deposit they -//! placed. +//! 2. At some later time, the account owner loses access to their account and wants to recover it. +//! Likely, they will need to create a new account and fund it with enough balance to support the +//! transaction fees and the deposit for the recovery process. +//! 3. Using this new account, they call `initiate_recovery`. +//! 4. Then the account owner would contact their configured friends to vouch for the recovery +//! attempt. The account owner would provide their old account id and the new account id, and +//! friends would call `vouch_recovery` with those parameters. +//! 5. Once a threshold number of friends have vouched for the recovery attempt, the account owner +//! needs to wait until the delay period has passed, starting when they initiated the recovery +//! process. +//! 6. Now the account owner is able to call `claim_recovery`, which subsequently allows them to +//! call `as_recovered` and directly make calls on-behalf-of the lost account. +//! 7. Using the now recovered account, the account owner can call `close_recovery` on the recovery +//! process they opened, reclaiming the recovery deposit they placed. //! 8. Then the account owner should then call `remove_recovery` to remove the recovery -//! configuration on the recovered account and reclaim the recovery configuration -//! deposit they placed. -//! 9. Using `as_recovered`, the account owner is able to call any other pallets -//! to clean up their state and reclaim any reserved or locked funds. They -//! can then transfer all funds from the recovered account to the new account. -//! 10. When the recovered account becomes reaped (i.e. its free and reserved -//! balance drops to zero), the final recovery link is removed. +//! configuration on the recovered account and reclaim the recovery configuration deposit they +//! placed. +//! 9. Using `as_recovered`, the account owner is able to call any other pallets to clean up their +//! state and reclaim any reserved or locked funds. They can then transfer all funds from the +//! recovered account to the new account. +//! 10. When the recovered account becomes reaped (i.e. its free and reserved balance drops to +//! zero), the final recovery link is removed. //! //! ### Malicious Recovery Attempts //! diff --git a/frame/support/src/lib.rs b/frame/support/src/lib.rs index fe8ede54bac57..01eec8d2ef79f 100644 --- a/frame/support/src/lib.rs +++ b/frame/support/src/lib.rs @@ -2708,13 +2708,13 @@ pub mod pallet_prelude { /// - query the metadata using the `state_getMetadata` RPC and curl, or use `subsee -p /// > meta.json` /// 2. Generate the template upgrade for the pallet provided by `decl_storage` with the -/// environment variable `PRINT_PALLET_UPGRADE`: `PRINT_PALLET_UPGRADE=1 cargo check -p -/// my_pallet`. This template can be used as it contains all information for storages, -/// genesis config and genesis build. +/// environment variable `PRINT_PALLET_UPGRADE`: `PRINT_PALLET_UPGRADE=1 cargo check -p +/// my_pallet`. This template can be used as it contains all information for storages, +/// genesis config and genesis build. /// 3. Reorganize the pallet to have the trait `Config`, `decl_*` macros, -/// [`ValidateUnsigned`](`pallet_prelude::ValidateUnsigned`), -/// [`ProvideInherent`](`pallet_prelude::ProvideInherent`), and Origin` all together in one -/// file. Suggested order: +/// [`ValidateUnsigned`](`pallet_prelude::ValidateUnsigned`), +/// [`ProvideInherent`](`pallet_prelude::ProvideInherent`), and Origin` all together in one +/// file. Suggested order: /// * `Config`, /// * `decl_module`, /// * `decl_event`, @@ -2774,8 +2774,8 @@ pub mod pallet_prelude { /// 8. **migrate error**: rewrite it with attribute /// [`#[pallet::error]`](#error-palleterror-optional). /// 9. **migrate storage**: `decl_storage` provide an upgrade template (see 3.). All storages, -/// genesis config, genesis build and default implementation of genesis config can be -/// taken from it directly. +/// genesis config, genesis build and default implementation of genesis config can be taken +/// from it directly. /// /// Otherwise here is the manual process: /// diff --git a/primitives/npos-elections/src/balancing.rs b/primitives/npos-elections/src/balancing.rs index 234326ee94dd2..90dbe7eb71478 100644 --- a/primitives/npos-elections/src/balancing.rs +++ b/primitives/npos-elections/src/balancing.rs @@ -19,7 +19,7 @@ //! //! Given a committee `A` and an edge weight vector `w`, a balanced solution is one that //! -//! 1. it maximizes the sum of member supports, i.e `Argmax { sum(support(c)) }`. for all `c` in +//! 1. it maximizes the sum of member supports, i.e `Argmax { sum(support(c)) }`. for all `c` in //! `A`. //! 2. it minimizes the sum of supports squared, i.e `Argmin { sum(support(c).pow(2)) }` for all `c` //! in `A`. diff --git a/primitives/runtime/src/offchain/http.rs b/primitives/runtime/src/offchain/http.rs index 25e5c1007d5da..bacc0073825bb 100644 --- a/primitives/runtime/src/offchain/http.rs +++ b/primitives/runtime/src/offchain/http.rs @@ -343,10 +343,10 @@ impl Response { /// A buffered byte iterator over response body. /// /// Note that reading the body may return `None` in following cases: -/// 1. Either the deadline you've set is reached (check via `#error`; -/// In such case you can resume the reader by setting a new deadline) -/// 2. Or because of IOError. In such case the reader is not resumable and will keep -/// returning `None`. +/// 1. Either the deadline you've set is reached (check via `#error`; In such case you can resume +/// the reader by setting a new deadline) +/// 2. Or because of IOError. In such case the reader is not resumable and will keep returning +/// `None`. /// 3. The body has been returned. The reader will keep returning `None`. #[derive(Clone)] pub struct ResponseBody { diff --git a/primitives/staking/src/offence.rs b/primitives/staking/src/offence.rs index 6694c9055d4ff..8013166374e06 100644 --- a/primitives/staking/src/offence.rs +++ b/primitives/staking/src/offence.rs @@ -220,16 +220,16 @@ pub struct OffenceDetails { /// for a typical usage scenario: /// /// 1. An offence is detected and an evidence is submitted on-chain via the -/// [`OffenceReportSystem::publish_evidence`] method. This will construct -/// and submit an extrinsic transaction containing the offence evidence. +/// [`OffenceReportSystem::publish_evidence`] method. This will construct and submit an extrinsic +/// transaction containing the offence evidence. /// -/// 2. If the extrinsic is unsigned then the transaction receiver may want to -/// perform some preliminary checks before further processing. This is a good -/// place to call the [`OffenceReportSystem::check_evidence`] method. +/// 2. If the extrinsic is unsigned then the transaction receiver may want to perform some +/// preliminary checks before further processing. This is a good place to call the +/// [`OffenceReportSystem::check_evidence`] method. /// -/// 3. Finally the report extrinsic is executed on-chain. This is where the user -/// calls the [`OffenceReportSystem::process_evidence`] to consume the offence -/// report and enact any required action. +/// 3. Finally the report extrinsic is executed on-chain. This is where the user calls the +/// [`OffenceReportSystem::process_evidence`] to consume the offence report and enact any +/// required action. pub trait OffenceReportSystem { /// Longevity, in blocks, for the evidence report validity. /// diff --git a/utils/wasm-builder/src/builder.rs b/utils/wasm-builder/src/builder.rs index d0bed8d22a036..208b56077669e 100644 --- a/utils/wasm-builder/src/builder.rs +++ b/utils/wasm-builder/src/builder.rs @@ -80,8 +80,8 @@ impl WasmBuilderSelectProject { /// /// 1. Call [`WasmBuilder::new`] to create a new builder. /// 2. Select the project to build using the methods of [`WasmBuilderSelectProject`]. -/// 3. Set additional `RUST_FLAGS` or a different name for the file containing the WASM code -/// using methods of [`WasmBuilder`]. +/// 3. Set additional `RUST_FLAGS` or a different name for the file containing the WASM code using +/// methods of [`WasmBuilder`]. /// 4. Build the WASM binary using [`Self::build`]. pub struct WasmBuilder { /// Flags that should be appended to `RUST_FLAGS` env variable. From c002485594ba511a4d01950f979fc9c5eff89598 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bastian=20K=C3=B6cher?= Date: Wed, 28 Jun 2023 12:30:13 +0200 Subject: [PATCH 3/4] Pass benchmarking host functions --- utils/frame/benchmarking-cli/src/pallet/command.rs | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/utils/frame/benchmarking-cli/src/pallet/command.rs b/utils/frame/benchmarking-cli/src/pallet/command.rs index 599f1c25af5fc..a2548a4fa890b 100644 --- a/utils/frame/benchmarking-cli/src/pallet/command.rs +++ b/utils/frame/benchmarking-cli/src/pallet/command.rs @@ -211,11 +211,14 @@ impl PalletCmd { let method = execution_method_from_cli(self.wasm_method, self.wasmtime_instantiation_strategy); - let executor = WasmExecutor::::builder() - .with_execution_method(method) - .with_max_runtime_instances(2) - .with_runtime_cache_size(2) - .build(); + let executor = WasmExecutor::<( + sp_io::SubstrateHostFunctions, + frame_benchmarking::benchmarking::HostFunctions, + )>::builder() + .with_execution_method(method) + .with_max_runtime_instances(2) + .with_runtime_cache_size(2) + .build(); let extensions = || -> Extensions { let mut extensions = Extensions::default(); From 649791a4380cf08c94c67296090e5385d85aea48 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bastian=20K=C3=B6cher?= Date: Wed, 28 Jun 2023 16:53:02 +0200 Subject: [PATCH 4/4] Ensure we can pass custom host functions --- Cargo.lock | 2 ++ bin/node-template/node/src/command.rs | 2 +- bin/node/cli/Cargo.toml | 1 + bin/node/cli/src/command.rs | 2 +- utils/frame/benchmarking-cli/Cargo.toml | 1 + utils/frame/benchmarking-cli/src/pallet/command.rs | 4 +++- 6 files changed, 9 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 4f415ae0868a3..0e737bfb57af3 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2606,6 +2606,7 @@ dependencies = [ "sp-state-machine", "sp-storage", "sp-trie", + "sp-wasm-interface", "thiserror", "thousands", ] @@ -5354,6 +5355,7 @@ dependencies = [ "sp-keyring", "sp-keystore", "sp-runtime", + "sp-statement-store", "sp-timestamp", "sp-tracing", "sp-transaction-storage-proof", diff --git a/bin/node-template/node/src/command.rs b/bin/node-template/node/src/command.rs index e8d766dedee00..6ea0f0b750ea6 100644 --- a/bin/node-template/node/src/command.rs +++ b/bin/node-template/node/src/command.rs @@ -124,7 +124,7 @@ pub fn run() -> sc_cli::Result<()> { ) } - cmd.run::(config) + cmd.run::(config) }, BenchmarkCmd::Block(cmd) => { let PartialComponents { client, .. } = service::new_partial(&config)?; diff --git a/bin/node/cli/Cargo.toml b/bin/node/cli/Cargo.toml index 9e682ce114eb0..d6566dec8a783 100644 --- a/bin/node/cli/Cargo.toml +++ b/bin/node/cli/Cargo.toml @@ -58,6 +58,7 @@ sp-keystore = { version = "0.27.0", path = "../../../primitives/keystore" } sp-consensus = { version = "0.10.0-dev", path = "../../../primitives/consensus/common" } sp-transaction-storage-proof = { version = "4.0.0-dev", path = "../../../primitives/transaction-storage-proof" } sp-io = { path = "../../../primitives/io" } +sp-statement-store = { path = "../../../primitives/statement-store" } # client dependencies sc-client-api = { version = "4.0.0-dev", path = "../../../client/api" } diff --git a/bin/node/cli/src/command.rs b/bin/node/cli/src/command.rs index dd123aae7dae0..941b9031fb123 100644 --- a/bin/node/cli/src/command.rs +++ b/bin/node/cli/src/command.rs @@ -117,7 +117,7 @@ pub fn run() -> Result<()> { ) } - cmd.run::(config) + cmd.run::(config) }, BenchmarkCmd::Block(cmd) => { // ensure that we keep the task manager alive diff --git a/utils/frame/benchmarking-cli/Cargo.toml b/utils/frame/benchmarking-cli/Cargo.toml index 3d4d25475a212..d960068a01bd4 100644 --- a/utils/frame/benchmarking-cli/Cargo.toml +++ b/utils/frame/benchmarking-cli/Cargo.toml @@ -52,6 +52,7 @@ sp-state-machine = { version = "0.28.0", path = "../../../primitives/state-machi sp-storage = { version = "13.0.0", path = "../../../primitives/storage" } sp-trie = { version = "22.0.0", path = "../../../primitives/trie" } sp-io = { version = "23.0.0", path = "../../../primitives/io" } +sp-wasm-interface = { version = "14.0.0", path = "../../../primitives/wasm-interface" } gethostname = "0.2.3" [features] diff --git a/utils/frame/benchmarking-cli/src/pallet/command.rs b/utils/frame/benchmarking-cli/src/pallet/command.rs index a2548a4fa890b..7f587d9c7fa6a 100644 --- a/utils/frame/benchmarking-cli/src/pallet/command.rs +++ b/utils/frame/benchmarking-cli/src/pallet/command.rs @@ -143,10 +143,11 @@ not created by a node that was compiled with the flag"; impl PalletCmd { /// Runs the command and benchmarks the chain. - pub fn run(&self, config: Configuration) -> Result<()> + pub fn run(&self, config: Configuration) -> Result<()> where BB: BlockT + Debug, <<::Header as HeaderT>::Number as std::str::FromStr>::Err: std::fmt::Debug, + ExtraHostFunctions: sp_wasm_interface::HostFunctions, { if let Some(output_path) = &self.output { if !output_path.is_dir() && output_path.file_name().is_none() { @@ -214,6 +215,7 @@ impl PalletCmd { let executor = WasmExecutor::<( sp_io::SubstrateHostFunctions, frame_benchmarking::benchmarking::HostFunctions, + ExtraHostFunctions, )>::builder() .with_execution_method(method) .with_max_runtime_instances(2)