Skip to content
This repository was archived by the owner on Nov 15, 2023. It is now read-only.

Commit 444bc4f

Browse files
authored
frame-benchmarking-cli: Remove native dispatch requirement (#14474)
* frame-benchmarking-cli: Remove native dispatch requirement No need for this, we can just use the `WasmExecutor` directly. * Fixes * Pass benchmarking host functions * Ensure we can pass custom host functions
1 parent a95c9b3 commit 444bc4f

File tree

20 files changed

+117
-119
lines changed

20 files changed

+117
-119
lines changed

Cargo.lock

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

bin/node-template/node/src/command.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ pub fn run() -> sc_cli::Result<()> {
124124
)
125125
}
126126

127-
cmd.run::<Block, service::ExecutorDispatch>(config)
127+
cmd.run::<Block, ()>(config)
128128
},
129129
BenchmarkCmd::Block(cmd) => {
130130
let PartialComponents { client, .. } = service::new_partial(&config)?;

bin/node/cli/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ sp-keystore = { version = "0.27.0", path = "../../../primitives/keystore" }
5858
sp-consensus = { version = "0.10.0-dev", path = "../../../primitives/consensus/common" }
5959
sp-transaction-storage-proof = { version = "4.0.0-dev", path = "../../../primitives/transaction-storage-proof" }
6060
sp-io = { path = "../../../primitives/io" }
61+
sp-statement-store = { path = "../../../primitives/statement-store" }
6162

6263
# client dependencies
6364
sc-client-api = { version = "4.0.0-dev", path = "../../../client/api" }

bin/node/cli/src/command.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ pub fn run() -> Result<()> {
117117
)
118118
}
119119

120-
cmd.run::<Block, ExecutorDispatch>(config)
120+
cmd.run::<Block, sp_statement_store::runtime_api::HostFunctions>(config)
121121
},
122122
BenchmarkCmd::Block(cmd) => {
123123
// ensure that we keep the task manager alive

client/consensus/babe/src/lib.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1152,10 +1152,10 @@ where
11521152
// Verification for imported blocks is skipped in two cases:
11531153
// 1. When importing blocks below the last finalized block during network initial
11541154
// synchronization.
1155-
// 2. When importing whole state we don't calculate epoch descriptor, but rather
1156-
// read it from the state after import. We also skip all verifications
1157-
// because there's no parent state and we trust the sync module to verify
1158-
// that the state is correct and finalized.
1155+
// 2. When importing whole state we don't calculate epoch descriptor, but rather read it
1156+
// from the state after import. We also skip all verifications because there's no
1157+
// parent state and we trust the sync module to verify that the state is correct and
1158+
// finalized.
11591159
return Ok(block)
11601160
}
11611161

client/consensus/beefy/src/worker.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -78,11 +78,11 @@ pub(crate) struct VoterOracle<B: Block> {
7878
///
7979
/// There are three voter states coresponding to three queue states:
8080
/// 1. voter uninitialized: queue empty,
81-
/// 2. up-to-date - all mandatory blocks leading up to current GRANDPA finalized:
82-
/// queue has ONE element, the 'current session' where `mandatory_done == true`,
81+
/// 2. up-to-date - all mandatory blocks leading up to current GRANDPA finalized: queue has ONE
82+
/// element, the 'current session' where `mandatory_done == true`,
8383
/// 3. lagging behind GRANDPA: queue has [1, N] elements, where all `mandatory_done == false`.
84-
/// In this state, everytime a session gets its mandatory block BEEFY finalized, it's
85-
/// popped off the queue, eventually getting to state `2. up-to-date`.
84+
/// In this state, everytime a session gets its mandatory block BEEFY finalized, it's popped
85+
/// off the queue, eventually getting to state `2. up-to-date`.
8686
sessions: VecDeque<Rounds<B>>,
8787
/// Min delta in block numbers between two blocks, BEEFY should vote on.
8888
min_block_delta: u32,

client/network/src/protocol/notifications/behaviour.rs

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -84,19 +84,17 @@ use std::{
8484
/// the API of this behaviour and towards the peerset manager is aggregated in
8585
/// the following way:
8686
///
87-
/// 1. The enabled/disabled status is the same across all connections, as
88-
/// decided by the peerset manager.
89-
/// 2. `send_packet` and `write_notification` always send all data over
90-
/// the same connection to preserve the ordering provided by the transport,
91-
/// as long as that connection is open. If it closes, a second open
92-
/// connection may take over, if one exists, but that case should be no
93-
/// different than a single connection failing and being re-established
94-
/// in terms of potential reordering and dropped messages. Messages can
95-
/// be received on any connection.
96-
/// 3. The behaviour reports `NotificationsOut::CustomProtocolOpen` when the
97-
/// first connection reports `NotifsHandlerOut::OpenResultOk`.
98-
/// 4. The behaviour reports `NotificationsOut::CustomProtocolClosed` when the
99-
/// last connection reports `NotifsHandlerOut::ClosedResult`.
87+
/// 1. The enabled/disabled status is the same across all connections, as decided by the peerset
88+
/// manager.
89+
/// 2. `send_packet` and `write_notification` always send all data over the same connection to
90+
/// preserve the ordering provided by the transport, as long as that connection is open. If it
91+
/// closes, a second open connection may take over, if one exists, but that case should be no
92+
/// different than a single connection failing and being re-established in terms of potential
93+
/// reordering and dropped messages. Messages can be received on any connection.
94+
/// 3. The behaviour reports `NotificationsOut::CustomProtocolOpen` when the first connection
95+
/// reports `NotifsHandlerOut::OpenResultOk`.
96+
/// 4. The behaviour reports `NotificationsOut::CustomProtocolClosed` when the last connection
97+
/// reports `NotifsHandlerOut::ClosedResult`.
10098
///
10199
/// In this way, the number of actual established connections to the peer is
102100
/// an implementation detail of this behaviour. Note that, in practice and at

client/network/src/service/traits.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -402,9 +402,9 @@ pub trait NetworkNotification {
402402
/// a receiver. With a `NotificationSender` at hand, sending a notification is done in two
403403
/// steps:
404404
///
405-
/// 1. [`NotificationSender::ready`] is used to wait for the sender to become ready
405+
/// 1. [`NotificationSender::ready`] is used to wait for the sender to become ready
406406
/// for another notification, yielding a [`NotificationSenderReady`] token.
407-
/// 2. [`NotificationSenderReady::send`] enqueues the notification for sending. This operation
407+
/// 2. [`NotificationSenderReady::send`] enqueues the notification for sending. This operation
408408
/// can only fail if the underlying notification substream or connection has suddenly closed.
409409
///
410410
/// An error is returned by [`NotificationSenderReady::send`] if there exists no open

client/rpc-spec-v2/src/chain_head/event.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -192,12 +192,10 @@ pub struct Finalized<Hash> {
192192
/// The event generated by the `follow` method.
193193
///
194194
/// The events are generated in the following order:
195-
/// 1. Initialized - generated only once to signal the
196-
/// latest finalized block
195+
/// 1. Initialized - generated only once to signal the latest finalized block
197196
/// 2. NewBlock - a new block was added.
198-
/// 3. BestBlockChanged - indicate that the best block
199-
/// is now the one from this event. The block was
200-
/// announced priorly with the `NewBlock` event.
197+
/// 3. BestBlockChanged - indicate that the best block is now the one from this event. The block was
198+
/// announced priorly with the `NewBlock` event.
201199
/// 4. Finalized - State the finalized and pruned blocks.
202200
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
203201
#[serde(rename_all = "camelCase")]

frame/benchmarking/src/lib.rs

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -246,22 +246,21 @@ pub use v1::*;
246246
/// of impls and structs required by the benchmarking engine. Additionally, a benchmark
247247
/// function is also generated that resembles the function definition you provide, with a few
248248
/// modifications:
249-
/// 1. The function name is transformed from i.e. `original_name` to `_original_name` so as not
250-
/// to collide with the struct `original_name` that is created for some of the benchmarking
251-
/// engine impls.
252-
/// 2. Appropriate `T: Config` and `I` (if this is an instance benchmark) generics are added to
253-
/// the function automatically during expansion, so you should not add these manually on
254-
/// your function definition (but you may make use of `T` and `I` anywhere within your
255-
/// benchmark function, in any of the three sections (setup, call, verification).
249+
/// 1. The function name is transformed from i.e. `original_name` to `_original_name` so as not to
250+
/// collide with the struct `original_name` that is created for some of the benchmarking engine
251+
/// impls.
252+
/// 2. Appropriate `T: Config` and `I` (if this is an instance benchmark) generics are added to the
253+
/// function automatically during expansion, so you should not add these manually on your
254+
/// function definition (but you may make use of `T` and `I` anywhere within your benchmark
255+
/// function, in any of the three sections (setup, call, verification).
256256
/// 3. Arguments such as `u: Linear<10, 100>` are converted to `u: u32` to make the function
257257
/// directly callable.
258-
/// 4. A `verify: bool` param is added as the last argument. Specifying `true` will result in
259-
/// the verification section of your function executing, while a value of `false` will skip
258+
/// 4. A `verify: bool` param is added as the last argument. Specifying `true` will result in the
259+
/// verification section of your function executing, while a value of `false` will skip
260260
/// verification.
261261
/// 5. If you specify a return type on the function definition, it must conform to the [rules
262-
/// below](#support-for-result-benchmarkerror-and-the--operator), and the last statement of
263-
/// the function definition must resolve to something compatible with `Result<(),
264-
/// BenchmarkError>`.
262+
/// below](#support-for-result-benchmarkerror-and-the--operator), and the last statement of the
263+
/// function definition must resolve to something compatible with `Result<(), BenchmarkError>`.
265264
///
266265
/// The reason we generate an actual function as part of the expansion is to allow the compiler
267266
/// to enforce several constraints that would otherwise be difficult to enforce and to reduce

frame/contracts/src/schedule.rs

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -145,21 +145,20 @@ impl Limits {
145145
/// There there is one field for each wasm instruction that describes the weight to
146146
/// execute one instruction of that name. There are a few exceptions:
147147
///
148-
/// 1. If there is a i64 and a i32 variant of an instruction we use the weight
149-
/// of the former for both.
150-
/// 2. The following instructions are free of charge because they merely structure the
151-
/// wasm module and cannot be spammed without making the module invalid (and rejected):
152-
/// End, Unreachable, Return, Else
153-
/// 3. The following instructions cannot be benchmarked because they are removed by any
154-
/// real world execution engine as a preprocessing step and therefore don't yield a
155-
/// meaningful benchmark result. However, in contrast to the instructions mentioned
156-
/// in 2. they can be spammed. We price them with the same weight as the "default"
157-
/// instruction (i64.const): Block, Loop, Nop
158-
/// 4. We price both i64.const and drop as InstructionWeights.i64const / 2. The reason
159-
/// for that is that we cannot benchmark either of them on its own but we need their
160-
/// individual values to derive (by subtraction) the weight of all other instructions
161-
/// that use them as supporting instructions. Supporting means mainly pushing arguments
162-
/// and dropping return values in order to maintain a valid module.
148+
/// 1. If there is a i64 and a i32 variant of an instruction we use the weight of the former for
149+
/// both.
150+
/// 2. The following instructions are free of charge because they merely structure the wasm module
151+
/// and cannot be spammed without making the module invalid (and rejected): End, Unreachable,
152+
/// Return, Else
153+
/// 3. The following instructions cannot be benchmarked because they are removed by any real world
154+
/// execution engine as a preprocessing step and therefore don't yield a meaningful benchmark
155+
/// result. However, in contrast to the instructions mentioned in 2. they can be spammed. We
156+
/// price them with the same weight as the "default" instruction (i64.const): Block, Loop, Nop
157+
/// 4. We price both i64.const and drop as InstructionWeights.i64const / 2. The reason for that is
158+
/// that we cannot benchmark either of them on its own but we need their individual values to
159+
/// derive (by subtraction) the weight of all other instructions that use them as supporting
160+
/// instructions. Supporting means mainly pushing arguments and dropping return values in order
161+
/// to maintain a valid module.
163162
#[cfg_attr(feature = "std", derive(Serialize, Deserialize))]
164163
#[derive(Clone, Encode, Decode, PartialEq, Eq, ScheduleDebug, TypeInfo)]
165164
#[scale_info(skip_type_params(T))]

frame/im-online/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -656,7 +656,7 @@ impl<T: Config> Pallet<T> {
656656
//
657657
// At index `idx`:
658658
// 1. A (ImOnline) public key to be used by a validator at index `idx` to send im-online
659-
// heartbeats.
659+
// heartbeats.
660660
let authorities = Keys::<T>::get();
661661

662662
// local keystore

frame/recovery/src/lib.rs

Lines changed: 22 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -48,34 +48,30 @@
4848
//! ### Recovery Life Cycle
4949
//!
5050
//! The intended life cycle of a successful recovery takes the following steps:
51-
//! 1. The account owner calls `create_recovery` to set up a recovery configuration
52-
//! for their account.
53-
//! 2. At some later time, the account owner loses access to their account and wants
54-
//! to recover it. Likely, they will need to create a new account and fund it with
55-
//! enough balance to support the transaction fees and the deposit for the
56-
//! recovery process.
57-
//! 3. Using this new account, they call `initiate_recovery`.
58-
//! 4. Then the account owner would contact their configured friends to vouch for
59-
//! the recovery attempt. The account owner would provide their old account id
60-
//! and the new account id, and friends would call `vouch_recovery` with those
61-
//! parameters.
62-
//! 5. Once a threshold number of friends have vouched for the recovery attempt,
63-
//! the account owner needs to wait until the delay period has passed, starting
64-
//! when they initiated the recovery process.
65-
//! 6. Now the account owner is able to call `claim_recovery`, which subsequently
66-
//! allows them to call `as_recovered` and directly make calls on-behalf-of the lost
51+
//! 1. The account owner calls `create_recovery` to set up a recovery configuration for their
6752
//! account.
68-
//! 7. Using the now recovered account, the account owner can call `close_recovery`
69-
//! on the recovery process they opened, reclaiming the recovery deposit they
70-
//! placed.
53+
//! 2. At some later time, the account owner loses access to their account and wants to recover it.
54+
//! Likely, they will need to create a new account and fund it with enough balance to support the
55+
//! transaction fees and the deposit for the recovery process.
56+
//! 3. Using this new account, they call `initiate_recovery`.
57+
//! 4. Then the account owner would contact their configured friends to vouch for the recovery
58+
//! attempt. The account owner would provide their old account id and the new account id, and
59+
//! friends would call `vouch_recovery` with those parameters.
60+
//! 5. Once a threshold number of friends have vouched for the recovery attempt, the account owner
61+
//! needs to wait until the delay period has passed, starting when they initiated the recovery
62+
//! process.
63+
//! 6. Now the account owner is able to call `claim_recovery`, which subsequently allows them to
64+
//! call `as_recovered` and directly make calls on-behalf-of the lost account.
65+
//! 7. Using the now recovered account, the account owner can call `close_recovery` on the recovery
66+
//! process they opened, reclaiming the recovery deposit they placed.
7167
//! 8. Then the account owner should then call `remove_recovery` to remove the recovery
72-
//! configuration on the recovered account and reclaim the recovery configuration
73-
//! deposit they placed.
74-
//! 9. Using `as_recovered`, the account owner is able to call any other pallets
75-
//! to clean up their state and reclaim any reserved or locked funds. They
76-
//! can then transfer all funds from the recovered account to the new account.
77-
//! 10. When the recovered account becomes reaped (i.e. its free and reserved
78-
//! balance drops to zero), the final recovery link is removed.
68+
//! configuration on the recovered account and reclaim the recovery configuration deposit they
69+
//! placed.
70+
//! 9. Using `as_recovered`, the account owner is able to call any other pallets to clean up their
71+
//! state and reclaim any reserved or locked funds. They can then transfer all funds from the
72+
//! recovered account to the new account.
73+
//! 10. When the recovered account becomes reaped (i.e. its free and reserved balance drops to
74+
//! zero), the final recovery link is removed.
7975
//!
8076
//! ### Malicious Recovery Attempts
8177
//!

frame/support/src/lib.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2708,13 +2708,13 @@ pub mod pallet_prelude {
27082708
/// - query the metadata using the `state_getMetadata` RPC and curl, or use `subsee -p
27092709
/// <PALLET_NAME> > meta.json`
27102710
/// 2. Generate the template upgrade for the pallet provided by `decl_storage` with the
2711-
/// environment variable `PRINT_PALLET_UPGRADE`: `PRINT_PALLET_UPGRADE=1 cargo check -p
2712-
/// my_pallet`. This template can be used as it contains all information for storages,
2713-
/// genesis config and genesis build.
2711+
/// environment variable `PRINT_PALLET_UPGRADE`: `PRINT_PALLET_UPGRADE=1 cargo check -p
2712+
/// my_pallet`. This template can be used as it contains all information for storages,
2713+
/// genesis config and genesis build.
27142714
/// 3. Reorganize the pallet to have the trait `Config`, `decl_*` macros,
2715-
/// [`ValidateUnsigned`](`pallet_prelude::ValidateUnsigned`),
2716-
/// [`ProvideInherent`](`pallet_prelude::ProvideInherent`), and Origin` all together in one
2717-
/// file. Suggested order:
2715+
/// [`ValidateUnsigned`](`pallet_prelude::ValidateUnsigned`),
2716+
/// [`ProvideInherent`](`pallet_prelude::ProvideInherent`), and Origin` all together in one
2717+
/// file. Suggested order:
27182718
/// * `Config`,
27192719
/// * `decl_module`,
27202720
/// * `decl_event`,
@@ -2774,8 +2774,8 @@ pub mod pallet_prelude {
27742774
/// 8. **migrate error**: rewrite it with attribute
27752775
/// [`#[pallet::error]`](#error-palleterror-optional).
27762776
/// 9. **migrate storage**: `decl_storage` provide an upgrade template (see 3.). All storages,
2777-
/// genesis config, genesis build and default implementation of genesis config can be
2778-
/// taken from it directly.
2777+
/// genesis config, genesis build and default implementation of genesis config can be taken
2778+
/// from it directly.
27792779
///
27802780
/// Otherwise here is the manual process:
27812781
///

primitives/npos-elections/src/balancing.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
//!
2020
//! Given a committee `A` and an edge weight vector `w`, a balanced solution is one that
2121
//!
22-
//! 1. it maximizes the sum of member supports, i.e `Argmax { sum(support(c)) }`. for all `c` in
22+
//! 1. it maximizes the sum of member supports, i.e `Argmax { sum(support(c)) }`. for all `c` in
2323
//! `A`.
2424
//! 2. it minimizes the sum of supports squared, i.e `Argmin { sum(support(c).pow(2)) }` for all `c`
2525
//! in `A`.

primitives/runtime/src/offchain/http.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -343,10 +343,10 @@ impl Response {
343343
/// A buffered byte iterator over response body.
344344
///
345345
/// Note that reading the body may return `None` in following cases:
346-
/// 1. Either the deadline you've set is reached (check via `#error`;
347-
/// In such case you can resume the reader by setting a new deadline)
348-
/// 2. Or because of IOError. In such case the reader is not resumable and will keep
349-
/// returning `None`.
346+
/// 1. Either the deadline you've set is reached (check via `#error`; In such case you can resume
347+
/// the reader by setting a new deadline)
348+
/// 2. Or because of IOError. In such case the reader is not resumable and will keep returning
349+
/// `None`.
350350
/// 3. The body has been returned. The reader will keep returning `None`.
351351
#[derive(Clone)]
352352
pub struct ResponseBody {

0 commit comments

Comments
 (0)