Skip to content
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
1,571 changes: 934 additions & 637 deletions Cargo.lock

Large diffs are not rendered by default.

26 changes: 13 additions & 13 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,18 @@ resolver = "2"
split-debuginfo = "unpacked"

[workspace.dependencies]
frame-support = { version = "37.0.0", default-features = false }
frame-system = { version = "37.0.0", default-features = false }
pallet-balances = { version = "38.0.0", default-features = false }
sc-client-db = { version = "0.44.0", default-features = false }
sc-executor = { version = "0.40.0", default-features = false }
sc-executor-common = { version = "0.35.0", default-features = false }
sp-core = { version = "34.0.0", default-features = false }
sp-externalities = { version = "0.29.0", default-features = false }
sp-io = { version = "38.0.0", default-features = false }
frame-support = { version = "40.1.0", default-features = false }
frame-system = { version = "40.1.0", default-features = false }
pallet-balances = { version = "41.1.0", default-features = false }
sc-client-db = { version = "0.46.0", default-features = false }
sc-executor = { version = "0.42.0", default-features = false }
sc-executor-common = { version = "0.38.0", default-features = false }
sp-core = { version = "36.1.0", default-features = false }
sp-externalities = { version = "0.30.0", default-features = false }
sp-io = { version = "40.0.0", default-features = false }
sp-maybe-compressed-blob = { version = "11.0.0", default-features = false }
sp-runtime = { version = "39.0.0", default-features = false }
sp-runtime-interface = { version = "28.0.0", default-features = false }
sp-state-machine = { version = "0.43.0", default-features = false }
sp-runtime = { version = "41.1.0", default-features = false }
sp-runtime-interface = { version = "29.0.1", default-features = false }
sp-state-machine = { version = "0.45.0", default-features = false }
sp-std = { version = "14.0.0", default-features = false }
sp-storage = { version = "21.0.0", default-features = false }
sp-storage = { version = "22.0.0", default-features = false }
2 changes: 1 addition & 1 deletion bencher/src/build_wasm/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ pub fn build() -> std::io::Result<Vec<u8>> {
let cargo_cmd = match prerequisites::check() {
Ok(cmd) => cmd,
Err(err_msg) => {
eprintln!("{}", err_msg);
eprintln!("{err_msg}");
std::process::exit(1);
},
};
Expand Down
27 changes: 13 additions & 14 deletions bencher/src/build_wasm/wasm_project.rs
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@ fn create_project_cargo_toml(
}

let mut package = Table::new();
package.insert("name".into(), format!("{}-wasm", crate_name).into());
package.insert("name".into(), format!("{crate_name}-wasm").into());
package.insert("version".into(), "1.0.0".into());
package.insert("edition".into(), "2021".into());

Expand Down Expand Up @@ -366,8 +366,7 @@ fn find_package_by_manifest_path<'a>(
if let Some(pkg) = pkgs_by_name.first() {
if pkgs_by_name.len() > 1 {
panic!(
"Found multiple packages matching the name {pkg_name} ({manifest_path:?}): {:?}",
pkgs_by_name
"Found multiple packages matching the name {pkg_name} ({manifest_path:?}): {pkgs_by_name:?}"
);
}
pkg
Expand Down Expand Up @@ -403,7 +402,7 @@ fn project_enabled_features(
// features already being present in nightly, we need this code to make
// runtimes compile with all the possible rustc versions.
if v.len() == 1
&& v.first().map_or(false, |v| *v == format!("dep:{}", f))
&& v.first().is_some_and(|v| *v == format!("dep:{f}"))
&& std_enabled.as_ref().map(|e| e.iter().any(|ef| ef == *f)).unwrap_or(false)
{
return false;
Expand All @@ -413,7 +412,7 @@ fn project_enabled_features(
// we need to check if the feature is enabled by checking the env variable.
*f != "std"
&& *f != "default"
&& env::var(format!("CARGO_FEATURE_{}", feature_env))
&& env::var(format!("CARGO_FEATURE_{feature_env}"))
.map(|v| v == "1")
.unwrap_or_default()
})
Expand Down Expand Up @@ -596,7 +595,7 @@ impl Profile {

/// Check environment whether we should build without network
fn offline_build() -> bool {
env::var(OFFLINE).map_or(false, |v| v == "true")
env::var(OFFLINE).is_ok_and(|v| v == "true")
}

/// Build the project to create the WASM binary.
Expand Down Expand Up @@ -675,10 +674,10 @@ fn compact_wasm_file(
let in_path = project
.join("target/wasm32-unknown-unknown")
.join(profile.directory())
.join(format!("{}.wasm", default_out_name));
.join(format!("{default_out_name}.wasm"));

let (wasm_compact_path, wasm_compact_compressed_path) = if profile.wants_compact() {
let wasm_compact_path = project.join(format!("{}.compact.wasm", out_name,));
let wasm_compact_path = project.join(format!("{out_name}.compact.wasm"));
wasm_opt::OptimizationOptions::new_opt_level_0()
.mvp_features_only()
.debug_info(true)
Expand All @@ -687,7 +686,7 @@ fn compact_wasm_file(
.expect("Failed to compact generated WASM binary.");

let wasm_compact_compressed_path =
project.join(format!("{}.compact.compressed.wasm", out_name));
project.join(format!("{out_name}.compact.compressed.wasm"));
if compress_wasm(&wasm_compact_path, &wasm_compact_compressed_path) {
(
Some(WasmBinary(wasm_compact_path)),
Expand All @@ -700,7 +699,7 @@ fn compact_wasm_file(
(None, None)
};

let bloaty_path = project.join(format!("{}.wasm", out_name));
let bloaty_path = project.join(format!("{out_name}.wasm"));
fs::copy(in_path, &bloaty_path).expect("Copying the bloaty file to the project dir.");

(
Expand Down Expand Up @@ -746,21 +745,21 @@ impl<'a> From<&'a cargo_metadata::Package> for DeduplicatePackage<'a> {
}
}

impl<'a> Hash for DeduplicatePackage<'a> {
impl Hash for DeduplicatePackage<'_> {
fn hash<H: Hasher>(&self, state: &mut H) {
self.identifier.hash(state);
}
}

impl<'a> PartialEq for DeduplicatePackage<'a> {
impl PartialEq for DeduplicatePackage<'_> {
fn eq(&self, other: &Self) -> bool {
self.identifier == other.identifier
}
}

impl<'a> Eq for DeduplicatePackage<'a> {}
impl Eq for DeduplicatePackage<'_> {}

impl<'a> Deref for DeduplicatePackage<'a> {
impl Deref for DeduplicatePackage<'_> {
type Target = cargo_metadata::Package;

fn deref(&self) -> &Self::Target {
Expand Down
2 changes: 1 addition & 1 deletion bencher/src/handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -152,5 +152,5 @@ pub fn save_output_json(data: Vec<BenchData>, storage_infos: Vec<StorageMetadata
writer.write_all(b"\n").unwrap();
writer.flush().unwrap();

println!("\nOutput JSON file:\n{}", json_path);
println!("\nOutput JSON file:\n{json_path}");
}
2 changes: 1 addition & 1 deletion bencher/src/macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
/// ```
///
/// Create a file `benches/module_benches.rs` must be the same as bench name.
/// ```.ignore
/// ```ignore
/// # run benches
/// wasm_bencher::main!();
/// # or, run benches with storage info, required by `wasm-bencher` to generate output json
Expand Down
2 changes: 2 additions & 0 deletions bencher/test/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#![allow(clippy::useless_conversion)]

#![cfg_attr(not(feature = "std"), no_std)]

pub mod benches;
Expand Down
4 changes: 2 additions & 2 deletions rust-toolchain.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[toolchain]
channel="1.77.0"
channel="1.84.1"
components = [ "rustfmt", "clippy" ]
targets = [ "wasm32-unknown-unknown" ]
profile = "minimal"
profile = "minimal"
4 changes: 2 additions & 2 deletions weight-gen/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -187,12 +187,12 @@ fn main() {
.render_template_to_write(&template, &hbs_data, &mut output_file)
.expect("Unable to render template");
println!();
println!("Weights file `{}` was generated.", path);
println!("Weights file `{path}` was generated.");
} else {
let template_string = handlebars
.render_template(&template, &hbs_data)
.expect("Unable to render template");

println!("{}", template_string);
println!("{template_string}");
}
}
36 changes: 18 additions & 18 deletions weight-meter/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
//! `weight_meter::weight` attribute, and only when running benchmarks.
//!
//! 2. Create benchmarks using wasm_bencher and generate the weights with weight_gen
//! After running the benchmarks and the weights have been generated then we can
//! replace
//! After running the benchmarks and the weights have been generated then we can
//! replace
//! ```ignore
//! #[weight_meter::weight(0)]
//! ```
Expand All @@ -25,22 +25,22 @@
//! ```
//!
//! 3. Use WeightMeter on your calls by adding macro
//! `#[weight_meter::start(weight)]` or `#[weight_meter::start]` if
//! starts with zero and at the end use `weight_meter::used_weight()` to
//! get used weight. ```ignore
//! #[pallet::call]
//! impl<T: Config> Pallet<T> {
//! #[pallet::weight(T::WeightInfo::do_something())]
//! #[weight_meter::start(ModuleWeights::<T>::do_something())]
//! pub fn do_something(origin: OriginFor<T>, something: u32) ->
//! DispatchResultWithPostInfo {
//! let who = ensure_signed(origin)?;
//! Self::inner_do_something(something);
//! // Emit an event.
//! Self::deposit_event(Event::SomethingStored(something, who));
//! Ok(PostDispatchInfo::from(Some(weight_meter::used_weight())))
//! }
//! }
//! `#[weight_meter::start(weight)]` or `#[weight_meter::start]` if
//! starts with zero and at the end use `weight_meter::used_weight()` to
//! get used weight. ```ignore
//! #[pallet::call]
//! impl<T: Config> Pallet<T> {
//! #[pallet::weight(T::WeightInfo::do_something())]
//! #[weight_meter::start(ModuleWeights::<T>::do_something())]
//! pub fn do_something(origin: OriginFor<T>, something: u32) ->
//! DispatchResultWithPostInfo {
//! let who = ensure_signed(origin)?;
//! Self::inner_do_something(something);
//! // Emit an event.
//! Self::deposit_event(Event::SomethingStored(something, who));
//! Ok(PostDispatchInfo::from(Some(weight_meter::used_weight())))
//! }
//! }
//! ```

type Weight = u64;
Expand Down
4 changes: 4 additions & 0 deletions weight-meter/src/mock.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#![allow(clippy::useless_conversion)]

#[frame_support::pallet]
pub mod test_module {
use frame_support::{dispatch::DispatchResultWithPostInfo, pallet_prelude::*, weights::Weight};
Expand Down Expand Up @@ -162,6 +164,7 @@ impl pallet_balances::Config for Runtime {
type FreezeIdentifier = ();
type MaxFreezes = ();
type WeightInfo = ();
type DoneSlashHandler = ();
}

impl test_module::Config for Runtime {}
Expand All @@ -184,6 +187,7 @@ impl ExtBuilder {

pallet_balances::GenesisConfig::<Runtime> {
balances: vec![(100, 100_000)],
..Default::default()
}
.assimilate_storage(&mut t)
.unwrap();
Expand Down