Skip to content
This repository was archived by the owner on Nov 15, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
351 changes: 175 additions & 176 deletions Cargo.lock

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ polkadot-node-core-pvf = { path = "../node/core/pvf", optional = true }
polkadot-performance-test = { path = "../node/test/performance-test", optional = true }

sp-core = { git = "https://github.com/paritytech/substrate", branch = "master" }
sp-keyring = { git = "https://github.com/paritytech/substrate", branch = "master" }
frame-benchmarking-cli = { git = "https://github.com/paritytech/substrate", branch = "master", optional = true }
try-runtime-cli = { git = "https://github.com/paritytech/substrate", branch = "master", optional = true }
sc-cli = { git = "https://github.com/paritytech/substrate", branch = "master", optional = true }
Expand Down
46 changes: 35 additions & 11 deletions cli/src/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,16 @@
// along with Polkadot. If not, see <http://www.gnu.org/licenses/>.

use crate::cli::{Cli, Subcommand};
use frame_benchmarking_cli::{BenchmarkCmd, SUBSTRATE_REFERENCE_HARDWARE};
use frame_benchmarking_cli::{BenchmarkCmd, ExtrinsicFactory, SUBSTRATE_REFERENCE_HARDWARE};
use futures::future::TryFutureExt;
use log::info;
use polkadot_client::benchmarking::{
benchmark_inherent_data, ExistentialDepositProvider, RemarkBuilder, TransferKeepAliveBuilder,
};
use sc_cli::{Role, RuntimeVersion, SubstrateCli};
use service::{self, HeaderBackend, IdentifyVariant};
use sp_core::crypto::Ss58AddressFormatRegistry;
use sp_keyring::Sr25519Keyring;
use std::net::ToSocketAddrs;

pub use crate::{error::Error, service::BlockId};
Expand Down Expand Up @@ -508,22 +512,42 @@ pub fn run() -> Result<()> {

unwrap_client!(client, cmd.run(client.clone()).map_err(Error::SubstrateCli))
}),
BenchmarkCmd::Overhead(cmd) => {
// These commands are very similar and can be handled in nearly the same way.
BenchmarkCmd::Extrinsic(_) | BenchmarkCmd::Overhead(_) => {
ensure_dev(chain_spec).map_err(Error::Other)?;
runner.sync_run(|mut config| {
use polkadot_client::benchmark_inherent_data;
let (client, _, _, _) = service::new_chain_ops(&mut config, None)?;
let wrapped = client.clone();

let header = client.header(BlockId::Number(0_u32.into())).unwrap().unwrap();
let inherent_data = benchmark_inherent_data(header)
.map_err(|e| format!("generating inherent data: {:?}", e))?;

unwrap_client!(
client,
cmd.run(config, client.clone(), inherent_data, wrapped)
.map_err(Error::SubstrateCli)
)
let remark_builder = RemarkBuilder::new(client.clone());

match cmd {
BenchmarkCmd::Extrinsic(cmd) => {
let tka_builder = TransferKeepAliveBuilder::new(
client.clone(),
Sr25519Keyring::Alice.to_account_id(),
client.existential_deposit(),
);

let ext_factory = ExtrinsicFactory(vec![
Box::new(remark_builder),
Box::new(tka_builder),
]);

unwrap_client!(
client,
cmd.run(client.clone(), inherent_data, &ext_factory)
.map_err(Error::SubstrateCli)
)
},
BenchmarkCmd::Overhead(cmd) => unwrap_client!(
client,
cmd.run(config, client.clone(), inherent_data, &remark_builder)
.map_err(Error::SubstrateCli)
),
_ => unreachable!("Ensured by the outside match; qed"),
}
})
},
BenchmarkCmd::Pallet(cmd) => {
Expand Down
Loading