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 1 commit
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
Prev Previous commit
Next Next commit
Use RuntimeString.
  • Loading branch information
seerscode committed Feb 27, 2020
commit 7412561af526ddd66bf3288f0ca6e852d933ddfd
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 5 additions & 5 deletions bin/node/runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ pub use node_primitives::{AccountId, Signature};
use node_primitives::{AccountIndex, Balance, BlockNumber, Hash, Index, Moment};
use sp_api::impl_runtime_apis;
use sp_runtime::{
Permill, Perbill, Percent, ApplyExtrinsicResult, impl_opaque_keys, generic, create_runtime_str,
Permill, Perbill, Percent, ApplyExtrinsicResult, RuntimeString,
impl_opaque_keys, generic, create_runtime_str,
};
use sp_runtime::curve::PiecewiseLinear;
use sp_runtime::transaction_validity::TransactionValidity;
Expand Down Expand Up @@ -821,18 +822,17 @@ impl_runtime_apis! {
extrinsic: Vec<u8>,
steps: Vec<u32>,
repeat: u32,
) -> Result<Vec<frame_benchmarking::BenchmarkResults>, Vec<u8>> {
use codec::Encode;
) -> Result<Vec<frame_benchmarking::BenchmarkResults>, RuntimeString> {
use frame_benchmarking::Benchmarking;

let results = match module.as_slice() {
let result = match module.as_slice() {
b"pallet-balances" | b"balances" => Balances::run_benchmark(extrinsic, steps, repeat),
b"pallet-identity" | b"identity" => Identity::run_benchmark(extrinsic, steps, repeat),
b"pallet-timestamp" | b"timestamp" => Timestamp::run_benchmark(extrinsic, steps, repeat),
_ => Err("Benchmark not found for this pallet."),
};

results.map_err(|e| e.encode())
result.map_err(|e| e.into())
}
}
}
Expand Down
3 changes: 2 additions & 1 deletion frame/benchmarking/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,10 @@ description = "Macro for benchmarking a FRAME runtime."
codec = { package = "parity-scale-codec", version = "1.1.2", default-features = false }
sp-api = { version = "2.0.0-alpha.2", path = "../../primitives/api", default-features = false }
sp-runtime-interface = { version = "2.0.0-alpha.2", path = "../../primitives/runtime-interface", default-features = false }
sp-runtime = { version = "2.0.0-alpha.2", path = "../../primitives/runtime", default-features = false }
sp-std = { version = "2.0.0-alpha.2", path = "../../primitives/std", default-features = false }
sp-io = { path = "../../primitives/io", default-features = false, version = "2.0.0-alpha.2" }

[features]
default = [ "std" ]
std = [ "sp-runtime-interface/std", "sp-api/std", "codec/std", "sp-std/std" ]
std = [ "sp-runtime-interface/std", "sp-runtime/std", "sp-api/std", "codec/std", "sp-std/std" ]
3 changes: 2 additions & 1 deletion frame/benchmarking/src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
use codec::{Encode, Decode};
use sp_std::vec::Vec;
use sp_io::hashing::blake2_256;
use sp_runtime::RuntimeString;

/// An alphabet of possible parameters to use for benchmarking.
#[derive(codec::Encode, codec::Decode, Clone, Copy, PartialEq, Debug)]
Expand All @@ -42,7 +43,7 @@ sp_api::decl_runtime_apis! {
extrinsic: Vec<u8>,
steps: Vec<u32>,
repeat: u32,
) -> Result<Vec<BenchmarkResults>, Vec<u8>>;
) -> Result<Vec<BenchmarkResults>, RuntimeString>;
}
}

Expand Down
8 changes: 2 additions & 6 deletions utils/frame/benchmarking-cli/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ impl BenchmarkCmd {
.execute(strategy.into())
.map_err(|e| format!("Error executing runtime benchmark: {:?}", e))?;

let results = <Result<Vec<BenchmarkResults>, Vec<u8>> as Decode>::decode(&mut &result[..])
let results = <Result<Vec<BenchmarkResults>, String> as Decode>::decode(&mut &result[..])
.expect("failed to decode benchmark results");

match results {
Expand Down Expand Up @@ -138,11 +138,7 @@ impl BenchmarkCmd {

eprintln!("Done.");
}
Err(error) => {
let error = <String as Decode>::decode(&mut &error[..])
.expect("failed to decode benchmark error");
eprintln!("Error: {:?}", error);
}
Err(error) => eprintln!("Error: {:?}", error),
}

Ok(())
Expand Down