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

0 commit comments

Comments
 (0)