Skip to content
Open
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
2,423 changes: 1,463 additions & 960 deletions Cargo.lock

Large diffs are not rendered by default.

22 changes: 11 additions & 11 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 = "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 }
frame-support = { version = "41.0.0", default-features = false }
frame-system = { version = "41.0.0", default-features = false }
pallet-balances = { version = "42.0.0", default-features = false }
sc-client-db = { version = "0.47.0", default-features = false }
sc-executor = { version = "0.43.0", default-features = false }
sc-executor-common = { version = "0.39.0", default-features = false }
sp-core = { version = "37.0.0", default-features = false }
sp-externalities = { version = "0.30.0", default-features = false }
sp-io = { version = "40.0.0", default-features = false }
sp-io = { version = "41.0.1", default-features = false }
sp-maybe-compressed-blob = { version = "11.0.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-runtime = { version = "42.0.0", default-features = false }
sp-runtime-interface = { version = "30.0.0", default-features = false }
sp-state-machine = { version = "0.46.0", default-features = false }
sp-std = { version = "14.0.0", default-features = false }
sp-storage = { version = "22.0.0", default-features = false }
3 changes: 3 additions & 0 deletions bencher/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ version = "0.5.0"
authors = ["Laminar Developers <hello@laminar.one>"]
edition = "2021"

[lints.rust]
unexpected_cfgs = { level = "warn", check-cfg = ['cfg(substrate_runtime)'] }

[dependencies]
paste = "^1.0"
build-helper = { version = "^0.1", optional = true }
Expand Down
5 changes: 1 addition & 4 deletions bencher/src/build_wasm/prerequisites.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,7 @@ fn create_check_toolchain_project(project_dir: &Path) {
super::write_file_if_changed(
main_rs_file,
r#"
fn main() {
println!("{}", env!("RUSTC_VERSION"));
}
fn main() {}
"#,
);
}
Expand All @@ -92,7 +90,6 @@ fn check_wasm_toolchain_installed(
let mut build_cmd = cargo_command.command();
build_cmd.args([
"build",
"--target=wasm32-unknown-unknown",
"--manifest-path",
&manifest_path,
]);
Expand Down
6 changes: 3 additions & 3 deletions bencher/src/build_wasm/wasm_project.rs
Original file line number Diff line number Diff line change
Expand Up @@ -614,7 +614,7 @@ fn build_project(
);

build_cmd
.args(["rustc", "--target=wasm32-unknown-unknown"])
.args(["rustc", "--target=wasm32v1-none"])
.arg(format!("--manifest-path={}", manifest_path.display()))
.env("RUSTFLAGS", rustflags)
// Unset the `CARGO_TARGET_DIR` to prevent a cargo deadlock (cargo locks a target dir
Expand Down Expand Up @@ -672,7 +672,7 @@ fn compact_wasm_file(
let default_out_name = get_wasm_binary_name(cargo_manifest);
let out_name = out_name.unwrap_or_else(|| default_out_name.clone());
let in_path = project
.join("target/wasm32-unknown-unknown")
.join("target/wasm32v1-none")
.join(profile.directory())
.join(format!("{default_out_name}.wasm"));

Expand Down Expand Up @@ -713,7 +713,7 @@ fn compress_wasm(wasm_binary_path: &Path, compressed_binary_out_path: &Path) ->
use sp_maybe_compressed_blob::CODE_BLOB_BOMB_LIMIT;

let data = fs::read(wasm_binary_path).expect("Failed to read WASM binary");
if let Some(compressed) = sp_maybe_compressed_blob::compress(&data, CODE_BLOB_BOMB_LIMIT) {
if let Some(compressed) = sp_maybe_compressed_blob::compress_strongly(&data, CODE_BLOB_BOMB_LIMIT) {
fs::write(compressed_binary_out_path, &compressed[..])
.expect("Failed to write WASM binary");

Expand Down
1 change: 0 additions & 1 deletion bencher/src/macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,6 @@ macro_rules! benches {


#[cfg(target_arch = "wasm32")]
#[no_mangle]
#[panic_handler]
fn panic_handler(info: &::core::panic::PanicInfo) -> ! {
let message = $crate::sp_std::alloc::format!("{}", info);
Expand Down
28 changes: 17 additions & 11 deletions bencher/src/utils.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
use sp_runtime_interface::runtime_interface;
use sp_runtime_interface::pass_by::AllocateAndReturnByCodec;
use sp_runtime_interface::pass_by::PassFatPointerAndRead;
use sp_std::vec::Vec;

#[cfg(feature = "std")]
Expand All @@ -7,14 +10,17 @@ use super::tracker::BenchTrackerExt;
#[cfg(feature = "std")]
use sp_externalities::ExternalitiesExt;

#[sp_runtime_interface::runtime_interface]
#[runtime_interface]
pub trait Bench {
fn print_error(message: Vec<u8>) {
let msg = String::from_utf8_lossy(&message);
eprintln!("{}", red_bold(&msg));
fn print_error(message: PassFatPointerAndRead<Vec<u8>>) {
#[cfg(feature = "std")]
{
let msg = String::from_utf8_lossy(&message);
eprintln!("{}", red_bold(&msg));
}
}

fn warnings(&mut self) -> Vec<u8> {
fn warnings(&mut self) -> AllocateAndReturnByCodec<Vec<u8>> {
let tracker = &***self
.extension::<BenchTrackerExt>()
.expect("No `bench_tracker` associated for the current context!");
Expand All @@ -41,11 +47,11 @@ pub trait Bench {
tracker.instant();
}

fn end_timer(&mut self) -> u128 {
fn end_timer(&mut self) -> u64 {
let tracker = &***self
.extension::<BenchTrackerExt>()
.expect("No `bench_tracker` associated for the current context!");
tracker.elapsed()
tracker.elapsed() as u64
}

fn before_block(&mut self) {
Expand All @@ -62,21 +68,21 @@ pub trait Bench {
tracker.after_block();
}

fn redundant_time(&mut self) -> u128 {
fn redundant_time(&mut self) -> u64 {
let tracker = &***self
.extension::<BenchTrackerExt>()
.expect("No `bench_tracker` associated for the current context!");
tracker.redundant_time()
tracker.redundant_time() as u64
}

fn read_written_keys(&mut self) -> Vec<u8> {
fn read_written_keys(&mut self) -> AllocateAndReturnByCodec<Vec<u8>> {
let tracker = &***self
.extension::<BenchTrackerExt>()
.expect("No `bench_tracker` associated for the current context!");
tracker.read_written_keys()
}

fn whitelist(&mut self, key: Vec<u8>, read: bool, write: bool) {
fn whitelist(&mut self, key: PassFatPointerAndRead<Vec<u8>>, read: bool, write: bool) {
let tracker = &***self
.extension::<BenchTrackerExt>()
.expect("No `bench_tracker` associated for the current context!");
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.84.1"
channel="1.88.0"
components = [ "rustfmt", "clippy" ]
targets = [ "wasm32-unknown-unknown" ]
targets = [ "wasm32v1-none" ]
profile = "minimal"
Loading