From ccf52e34c2ae063e429b807d3689da0866fc2293 Mon Sep 17 00:00:00 2001 From: eskimor Date: Sat, 4 Apr 2026 14:33:44 +0200 Subject: [PATCH 01/14] Use compressed runtimes & log errors. --- cumulus/test/runtime/build.rs | 4 ++ .../zombienet-sdk-helpers/src/lib.rs | 37 +++++++++++++++++++ .../elastic_scaling/upgrade_to_3_cores.rs | 11 ++---- ...chain_runtime_upgrade_slot_duration_18s.rs | 10 ++--- .../tests/zombie_ci/runtime_upgrade.rs | 17 ++++----- 5 files changed, 57 insertions(+), 22 deletions(-) diff --git a/cumulus/test/runtime/build.rs b/cumulus/test/runtime/build.rs index 4c1298575f816..edae88cfd6963 100644 --- a/cumulus/test/runtime/build.rs +++ b/cumulus/test/runtime/build.rs @@ -23,6 +23,10 @@ fn main() { .import_memory() .build(); + // Force compaction for runtime upgrade binaries so that WASM_BINARY is compact even in + // debug builds. Without this the bloaty binary may exceed `max_code_size` (3 MiB). + std::env::set_var("WASM_BUILD_TYPE", "release"); + WasmBuilder::init_with_defaults() .enable_feature("increment-spec-version") .set_file_name("wasm_binary_spec_version_incremented.rs") diff --git a/cumulus/zombienet/zombienet-sdk-helpers/src/lib.rs b/cumulus/zombienet/zombienet-sdk-helpers/src/lib.rs index 87efc802782e6..b5d4b24d86912 100644 --- a/cumulus/zombienet/zombienet-sdk-helpers/src/lib.rs +++ b/cumulus/zombienet/zombienet-sdk-helpers/src/lib.rs @@ -569,6 +569,43 @@ pub fn create_runtime_upgrade_call(wasm: &[u8]) -> DynamicPayload { ) } +/// Submit a runtime upgrade via sudo and verify it was scheduled. +/// +/// This submits a `Sudo::sudo_unchecked_weight(System::set_code(wasm))` extrinsic, +/// waits for finalization, then checks the `Sudid` event to verify the inner dispatch +/// succeeded. Returns the hash of the finalized block containing the upgrade extrinsic. +pub async fn submit_sudo_runtime_upgrade>( + client: &OnlineClient, + wasm: &[u8], + signer: &S, +) -> Result { + log::info!("Submitting sudo runtime upgrade, wasm size: {} bytes", wasm.len()); + let call = create_runtime_upgrade_call(wasm); + let block_hash = + submit_extrinsic_and_wait_for_finalization_success(client, &call, signer).await?; + + // Verify the inner sudo dispatch succeeded by checking the Sudid event. + // sudo_unchecked_weight always returns Ok at the extrinsic level, even if the + // inner call fails — the actual result is only in the Sudid event. + let block = client.blocks().at(block_hash).await?; + let events = block.events().await?; + let sudid_results: Vec> = + find_event_and_decode_fields(&events, "Sudo", "Sudid")?; + + match sudid_results.first() { + Some(Ok(())) => + log::info!("Sudo runtime upgrade dispatched successfully in block {block_hash:?}"), + Some(Err(e)) => + return Err(anyhow!( + "Sudo runtime upgrade inner dispatch failed in block {block_hash:?}: {e:?}" + )), + None => + return Err(anyhow!("Sudid event not found in block {block_hash:?}")), + } + + Ok(block_hash) +} + /// Wait until a runtime upgrade has happened. /// /// This checks all finalized blocks until it finds a block that sets the diff --git a/cumulus/zombienet/zombienet-sdk/tests/zombie_ci/elastic_scaling/upgrade_to_3_cores.rs b/cumulus/zombienet/zombienet-sdk/tests/zombie_ci/elastic_scaling/upgrade_to_3_cores.rs index e7cc473f924ac..8f7ab38dab99e 100644 --- a/cumulus/zombienet/zombienet-sdk/tests/zombie_ci/elastic_scaling/upgrade_to_3_cores.rs +++ b/cumulus/zombienet/zombienet-sdk/tests/zombie_ci/elastic_scaling/upgrade_to_3_cores.rs @@ -7,12 +7,11 @@ use serde_json::json; use crate::utils::initialize_network; use cumulus_test_runtime::{ - elastic_scaling::WASM_BINARY_BLOATY as WASM_ELASTIC_SCALING, - elastic_scaling_12s_slot::WASM_BINARY_BLOATY as WASM_ELASTIC_SCALING_12S_SLOT, + elastic_scaling::WASM_BINARY as WASM_ELASTIC_SCALING, + elastic_scaling_12s_slot::WASM_BINARY as WASM_ELASTIC_SCALING_12S_SLOT, }; use cumulus_zombienet_sdk_helpers::{ - assert_para_throughput, assign_cores, create_runtime_upgrade_call, - submit_extrinsic_and_wait_for_finalization_success, wait_for_runtime_upgrade, + assert_para_throughput, assign_cores, submit_sudo_runtime_upgrade, wait_for_runtime_upgrade, }; use polkadot_primitives::Id as ParaId; use rstest::rstest; @@ -71,9 +70,7 @@ async fn elastic_scaling_upgrade_to_3_cores( }; log::info!("Performing runtime upgrade"); - let call = create_runtime_upgrade_call(wasm); - submit_extrinsic_and_wait_for_finalization_success(&collator0_client, &call, &dev::alice()) - .await?; + submit_sudo_runtime_upgrade(&collator0_client, wasm, &dev::alice()).await?; let collator1 = network.get_node("collator1")?; let collator1_client: OnlineClient = collator1.wait_client().await?; diff --git a/cumulus/zombienet/zombienet-sdk/tests/zombie_ci/parachain_runtime_upgrade_slot_duration_18s.rs b/cumulus/zombienet/zombienet-sdk/tests/zombie_ci/parachain_runtime_upgrade_slot_duration_18s.rs index 673a204a0417c..079e8fffbdf62 100644 --- a/cumulus/zombienet/zombienet-sdk/tests/zombie_ci/parachain_runtime_upgrade_slot_duration_18s.rs +++ b/cumulus/zombienet/zombienet-sdk/tests/zombie_ci/parachain_runtime_upgrade_slot_duration_18s.rs @@ -8,10 +8,10 @@ use crate::utils::initialize_network; use anyhow::anyhow; -use cumulus_test_runtime::slot_duration_18s::WASM_BINARY_BLOATY as WASM_WITH_SLOT_DURATION_18S; +use cumulus_test_runtime::slot_duration_18s::WASM_BINARY as WASM_WITH_SLOT_DURATION_18S; use cumulus_zombienet_sdk_helpers::{ - assert_blocks_are_being_finalized, assert_para_throughput, create_runtime_upgrade_call, - submit_extrinsic_and_wait_for_finalization_success, wait_for_runtime_upgrade, + assert_blocks_are_being_finalized, assert_para_throughput, submit_sudo_runtime_upgrade, + wait_for_runtime_upgrade, }; use futures::StreamExt; use polkadot_primitives::Id as ParaId; @@ -45,9 +45,7 @@ async fn parachain_runtime_upgrade_slot_duration_18s() -> Result<(), anyhow::Err let initial_slot_duration = get_slot_duration(&collator_client).await?; log::info!("Performing runtime upgrade for parachain {}", PARA_ID); - let call = create_runtime_upgrade_call(wasm); - submit_extrinsic_and_wait_for_finalization_success(&collator_client, &call, &dev::alice()) - .await?; + submit_sudo_runtime_upgrade(&collator_client, wasm, &dev::alice()).await?; let block_hash_of_upgrade = wait_for_runtime_upgrade(&collator_client).await?; diff --git a/cumulus/zombienet/zombienet-sdk/tests/zombie_ci/runtime_upgrade.rs b/cumulus/zombienet/zombienet-sdk/tests/zombie_ci/runtime_upgrade.rs index 14c0703e457d1..d206fd9beb01c 100644 --- a/cumulus/zombienet/zombienet-sdk/tests/zombie_ci/runtime_upgrade.rs +++ b/cumulus/zombienet/zombienet-sdk/tests/zombie_ci/runtime_upgrade.rs @@ -3,11 +3,8 @@ use crate::utils::initialize_network; use anyhow::anyhow; -use cumulus_test_runtime::wasm_spec_version_incremented::WASM_BINARY_BLOATY as WASM_RUNTIME_UPGRADE; -use cumulus_zombienet_sdk_helpers::{ - create_runtime_upgrade_call, submit_extrinsic_and_wait_for_finalization_success, - wait_for_runtime_upgrade, -}; +use cumulus_test_runtime::wasm_spec_version_incremented::WASM_BINARY as WASM_RUNTIME_UPGRADE; +use cumulus_zombienet_sdk_helpers::{submit_sudo_runtime_upgrade, wait_for_runtime_upgrade}; use zombienet_sdk::{ subxt::{OnlineClient, PolkadotConfig}, subxt_signer::sr25519::dev, @@ -36,10 +33,12 @@ async fn runtime_upgrade() -> Result<(), anyhow::Error> { log::info!("Current runtime spec version {current_spec_version}"); log::info!("Performing runtime upgrade"); - - let call = create_runtime_upgrade_call(WASM_RUNTIME_UPGRADE.expect("Wasm runtime not build")); - submit_extrinsic_and_wait_for_finalization_success(&charlie_client, &call, &dev::alice()) - .await?; + submit_sudo_runtime_upgrade( + &charlie_client, + WASM_RUNTIME_UPGRADE.expect("Wasm runtime not built"), + &dev::alice(), + ) + .await?; let dave = network.get_node("dave")?; let dave_client: OnlineClient = dave.wait_client().await?; From 73028f9502aaac40563cda909c0c728302eeebf9 Mon Sep 17 00:00:00 2001 From: eskimor Date: Sat, 4 Apr 2026 21:01:37 +0200 Subject: [PATCH 02/14] Add prdoc --- prdoc/pr_11641.prdoc | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 prdoc/pr_11641.prdoc diff --git a/prdoc/pr_11641.prdoc b/prdoc/pr_11641.prdoc new file mode 100644 index 0000000000000..284c251e040d0 --- /dev/null +++ b/prdoc/pr_11641.prdoc @@ -0,0 +1,16 @@ +title: 'Use compressed runtimes & log errors in parachain runtime upgrades' +doc: +- audience: Node Dev + description: |- + Add `submit_sudo_runtime_upgrade` helper to `cumulus-zombienet-sdk-helpers` + that submits a sudo runtime upgrade, waits for finalization, and verifies + the inner dispatch succeeded via the `Sudid` event. Zombienet upgrade tests + now use this helper and consume the compact (`WASM_BINARY`) runtime instead + of `WASM_BINARY_BLOATY`, avoiding `max_code_size` overflows in debug builds. +crates: +- name: cumulus-zombienet-sdk-helpers + bump: minor +- name: cumulus-test-runtime + bump: patch +- name: cumulus-zombienet-sdk-tests + bump: none From 9abb3211bbb4cafe395cfe8f9606a98429c34700 Mon Sep 17 00:00:00 2001 From: eskimor Date: Sat, 4 Apr 2026 21:27:47 +0200 Subject: [PATCH 03/14] Remove env var hack --- cumulus/test/runtime/build.rs | 4 ---- 1 file changed, 4 deletions(-) diff --git a/cumulus/test/runtime/build.rs b/cumulus/test/runtime/build.rs index edae88cfd6963..4c1298575f816 100644 --- a/cumulus/test/runtime/build.rs +++ b/cumulus/test/runtime/build.rs @@ -23,10 +23,6 @@ fn main() { .import_memory() .build(); - // Force compaction for runtime upgrade binaries so that WASM_BINARY is compact even in - // debug builds. Without this the bloaty binary may exceed `max_code_size` (3 MiB). - std::env::set_var("WASM_BUILD_TYPE", "release"); - WasmBuilder::init_with_defaults() .enable_feature("increment-spec-version") .set_file_name("wasm_binary_spec_version_incremented.rs") From a69c384680111e9dbfb81897c230a8f0789305df Mon Sep 17 00:00:00 2001 From: eskimor Date: Sat, 4 Apr 2026 21:28:56 +0200 Subject: [PATCH 04/14] Fix prdoc --- prdoc/pr_11641.prdoc | 2 -- 1 file changed, 2 deletions(-) diff --git a/prdoc/pr_11641.prdoc b/prdoc/pr_11641.prdoc index 284c251e040d0..872611eca02b0 100644 --- a/prdoc/pr_11641.prdoc +++ b/prdoc/pr_11641.prdoc @@ -10,7 +10,5 @@ doc: crates: - name: cumulus-zombienet-sdk-helpers bump: minor -- name: cumulus-test-runtime - bump: patch - name: cumulus-zombienet-sdk-tests bump: none From c1b48895409f6174304872c4ecf5582a98e07b40 Mon Sep 17 00:00:00 2001 From: "cmd[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Sat, 4 Apr 2026 19:37:17 +0000 Subject: [PATCH 05/14] Update from github-actions[bot] running command 'fmt' --- cumulus/zombienet/zombienet-sdk-helpers/src/lib.rs | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/cumulus/zombienet/zombienet-sdk-helpers/src/lib.rs b/cumulus/zombienet/zombienet-sdk-helpers/src/lib.rs index b5d4b24d86912..6d82b16d81d08 100644 --- a/cumulus/zombienet/zombienet-sdk-helpers/src/lib.rs +++ b/cumulus/zombienet/zombienet-sdk-helpers/src/lib.rs @@ -593,14 +593,15 @@ pub async fn submit_sudo_runtime_upgrade>( find_event_and_decode_fields(&events, "Sudo", "Sudid")?; match sudid_results.first() { - Some(Ok(())) => - log::info!("Sudo runtime upgrade dispatched successfully in block {block_hash:?}"), - Some(Err(e)) => + Some(Ok(())) => { + log::info!("Sudo runtime upgrade dispatched successfully in block {block_hash:?}") + }, + Some(Err(e)) => { return Err(anyhow!( "Sudo runtime upgrade inner dispatch failed in block {block_hash:?}: {e:?}" - )), - None => - return Err(anyhow!("Sudid event not found in block {block_hash:?}")), + )) + }, + None => return Err(anyhow!("Sudid event not found in block {block_hash:?}")), } Ok(block_hash) From 6c5ba25cacd1db327855e504980eeb463aa18779 Mon Sep 17 00:00:00 2001 From: eskimor Date: Sat, 4 Apr 2026 22:09:02 +0200 Subject: [PATCH 06/14] Better error messages --- .../zombienet-sdk-helpers/src/lib.rs | 34 +++++++++++++++---- 1 file changed, 27 insertions(+), 7 deletions(-) diff --git a/cumulus/zombienet/zombienet-sdk-helpers/src/lib.rs b/cumulus/zombienet/zombienet-sdk-helpers/src/lib.rs index 6d82b16d81d08..c4ce8005e163b 100644 --- a/cumulus/zombienet/zombienet-sdk-helpers/src/lib.rs +++ b/cumulus/zombienet/zombienet-sdk-helpers/src/lib.rs @@ -19,6 +19,7 @@ use zombienet_sdk::subxt::{ dynamic::Value, events::Events, ext::scale_value::value, + metadata::Metadata, tx::{signer::Signer, DynamicPayload, TxStatus}, utils::H256, OnlineClient, PolkadotConfig, @@ -29,6 +30,26 @@ use zombienet_sdk::subxt::{ const WAIT_MAX_BLOCKS_FOR_SESSION: u32 = 50; /// Find an event in subxt `Events` and attempt to decode the fields of the event. +/// Format a `sp_runtime::DispatchError` using runtime metadata for human-readable output. +/// +/// For module errors this resolves the pallet index and error index to their names +/// (e.g. `ParachainSystem::TooBig`) instead of showing raw bytes. +fn format_dispatch_error(err: &sp_runtime::DispatchError, metadata: &Metadata) -> String { + match err { + sp_runtime::DispatchError::Module(module_err) => { + let pallet = metadata.pallet_by_index(module_err.index); + let pallet_name = + pallet.as_ref().map(|p| p.name()).unwrap_or("UnknownPallet"); + let error_name = pallet + .and_then(|p| p.error_variant_by_index(module_err.error[0])) + .map(|v| v.name.as_str()) + .unwrap_or("UnknownError"); + format!("{pallet_name}::{error_name}") + }, + other => format!("{other:?}"), + } +} + fn find_event_and_decode_fields( events: &Events, pallet: &str, @@ -593,14 +614,13 @@ pub async fn submit_sudo_runtime_upgrade>( find_event_and_decode_fields(&events, "Sudo", "Sudid")?; match sudid_results.first() { - Some(Ok(())) => { - log::info!("Sudo runtime upgrade dispatched successfully in block {block_hash:?}") - }, - Some(Err(e)) => { + Some(Ok(())) => + log::info!("Sudo runtime upgrade dispatched successfully in block {block_hash:?}"), + Some(Err(e)) => return Err(anyhow!( - "Sudo runtime upgrade inner dispatch failed in block {block_hash:?}: {e:?}" - )) - }, + "Sudo runtime upgrade inner dispatch failed in block {block_hash:?}: {}", + format_dispatch_error(e, &client.metadata()), + )), None => return Err(anyhow!("Sudid event not found in block {block_hash:?}")), } From f73474ef642b58aeeabeba3870627fcd3b8e5aef Mon Sep 17 00:00:00 2001 From: eskimor Date: Sat, 4 Apr 2026 22:11:54 +0200 Subject: [PATCH 07/14] fmt --- cumulus/zombienet/zombienet-sdk-helpers/src/lib.rs | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/cumulus/zombienet/zombienet-sdk-helpers/src/lib.rs b/cumulus/zombienet/zombienet-sdk-helpers/src/lib.rs index c4ce8005e163b..15be4bcc9354a 100644 --- a/cumulus/zombienet/zombienet-sdk-helpers/src/lib.rs +++ b/cumulus/zombienet/zombienet-sdk-helpers/src/lib.rs @@ -38,8 +38,7 @@ fn format_dispatch_error(err: &sp_runtime::DispatchError, metadata: &Metadata) - match err { sp_runtime::DispatchError::Module(module_err) => { let pallet = metadata.pallet_by_index(module_err.index); - let pallet_name = - pallet.as_ref().map(|p| p.name()).unwrap_or("UnknownPallet"); + let pallet_name = pallet.as_ref().map(|p| p.name()).unwrap_or("UnknownPallet"); let error_name = pallet .and_then(|p| p.error_variant_by_index(module_err.error[0])) .map(|v| v.name.as_str()) @@ -614,13 +613,15 @@ pub async fn submit_sudo_runtime_upgrade>( find_event_and_decode_fields(&events, "Sudo", "Sudid")?; match sudid_results.first() { - Some(Ok(())) => - log::info!("Sudo runtime upgrade dispatched successfully in block {block_hash:?}"), - Some(Err(e)) => + Some(Ok(())) => { + log::info!("Sudo runtime upgrade dispatched successfully in block {block_hash:?}") + }, + Some(Err(e)) => { return Err(anyhow!( "Sudo runtime upgrade inner dispatch failed in block {block_hash:?}: {}", format_dispatch_error(e, &client.metadata()), - )), + )) + }, None => return Err(anyhow!("Sudid event not found in block {block_hash:?}")), } From 33928a58176f012f7b9a660f1cf6928c8231025b Mon Sep 17 00:00:00 2001 From: eskimor Date: Sat, 4 Apr 2026 22:14:54 +0200 Subject: [PATCH 08/14] Docs --- cumulus/zombienet/zombienet-sdk-helpers/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cumulus/zombienet/zombienet-sdk-helpers/src/lib.rs b/cumulus/zombienet/zombienet-sdk-helpers/src/lib.rs index 15be4bcc9354a..0d9555dd4aa76 100644 --- a/cumulus/zombienet/zombienet-sdk-helpers/src/lib.rs +++ b/cumulus/zombienet/zombienet-sdk-helpers/src/lib.rs @@ -29,7 +29,6 @@ use zombienet_sdk::subxt::{ // If it does not arrive for whatever reason, we should not wait forever. const WAIT_MAX_BLOCKS_FOR_SESSION: u32 = 50; -/// Find an event in subxt `Events` and attempt to decode the fields of the event. /// Format a `sp_runtime::DispatchError` using runtime metadata for human-readable output. /// /// For module errors this resolves the pallet index and error index to their names @@ -49,6 +48,7 @@ fn format_dispatch_error(err: &sp_runtime::DispatchError, metadata: &Metadata) - } } +/// Find an event in subxt `Events` and attempt to decode the fields of the event. fn find_event_and_decode_fields( events: &Events, pallet: &str, From 9b701357884d38b8df9153fa274c5e3813885170 Mon Sep 17 00:00:00 2001 From: eskimor Date: Sat, 4 Apr 2026 23:11:20 +0200 Subject: [PATCH 09/14] Cleaned up fix + prdoc --- prdoc/pr_11641.prdoc | 21 +++++++++++++------ .../utils/wasm-builder/src/wasm_project.rs | 19 ++++++----------- 2 files changed, 21 insertions(+), 19 deletions(-) diff --git a/prdoc/pr_11641.prdoc b/prdoc/pr_11641.prdoc index 872611eca02b0..9ea8d40b8025a 100644 --- a/prdoc/pr_11641.prdoc +++ b/prdoc/pr_11641.prdoc @@ -1,13 +1,22 @@ -title: 'Use compressed runtimes & log errors in parachain runtime upgrades' +title: 'Fix runtime upgrade zombienet tests exceeding max_code_size' doc: +- audience: Runtime Dev + description: |- + The wasm-builder's compaction and compression decision now uses the actual + blob build profile rather than the outer cargo profile. Since debug builds + already compile WASM blobs with the Release profile, they now also get + compacted and compressed, producing a properly sized `WASM_BINARY`. + Previously `WASM_BINARY` in debug builds was identical to `WASM_BINARY_BLOATY`. - audience: Node Dev description: |- - Add `submit_sudo_runtime_upgrade` helper to `cumulus-zombienet-sdk-helpers` - that submits a sudo runtime upgrade, waits for finalization, and verifies - the inner dispatch succeeded via the `Sudid` event. Zombienet upgrade tests - now use this helper and consume the compact (`WASM_BINARY`) runtime instead - of `WASM_BINARY_BLOATY`, avoiding `max_code_size` overflows in debug builds. + Zombienet runtime upgrade tests now use compact (`WASM_BINARY`) runtimes + instead of `WASM_BINARY_BLOATY`, which had grown beyond the relay chain's + `max_code_size` limit. A new `submit_sudo_runtime_upgrade` helper verifies + that the inner sudo dispatch succeeded and renders any dispatch errors using + runtime metadata (e.g. `ParachainSystem::TooBig` instead of raw byte indices). crates: +- name: substrate-wasm-builder + bump: patch - name: cumulus-zombienet-sdk-helpers bump: minor - name: cumulus-zombienet-sdk-tests diff --git a/substrate/utils/wasm-builder/src/wasm_project.rs b/substrate/utils/wasm-builder/src/wasm_project.rs index 7c1de82f1f990..cdc8086d987d3 100644 --- a/substrate/utils/wasm-builder/src/wasm_project.rs +++ b/substrate/utils/wasm-builder/src/wasm_project.rs @@ -284,7 +284,7 @@ fn maybe_compact_and_compress_wasm( build_config: &BuildConfiguration, bloaty_changed: bool, ) -> (Option, WasmBinaryBloaty, bool) { - let needs_compact = build_config.outer_build_profile.wants_compact(); + let needs_compact = build_config.blob_build_profile.wants_compact(); let compact_path = blob_paths.compact(); let compressed_path = blob_paths.compact_compressed(); let compact_or_compressed_exists = compact_path.exists() || compressed_path.exists(); @@ -810,9 +810,7 @@ impl Profile { /// The build configuration for this build. #[derive(Debug)] struct BuildConfiguration { - /// The profile that is used to build the outer project. - pub outer_build_profile: Profile, - /// The profile to use to build the runtime blob. + /// The profile to use to build the runtime blob and decide whether to compact/compress. pub blob_build_profile: Profile, } @@ -828,9 +826,7 @@ impl BuildConfiguration { /// When not overridden by a env variable we always default to building wasm with the `Release` /// profile even when the main build uses the debug build. This is because wasm built with the /// `Debug` profile is too slow for normal development activities and almost never intended. - /// - /// When cargo is building in `--profile dev`, user likely intends to compile fast, so we don't - /// bother producing compact or compressed blobs. + /// Compaction and compression are also decided by this profile. /// /// # Note /// @@ -860,8 +856,8 @@ impl BuildConfiguration { .to_string(); (name, false) }; - let outer_build_profile = Profile::iter().find(|p| p.directory() == name); - let blob_build_profile = match (outer_build_profile.clone(), overridden) { + let detected_profile = Profile::iter().find(|p| p.directory() == name); + let blob_build_profile = match (detected_profile, overridden) { // When not overridden by a env variable we default to using the `Release` profile // for the wasm build even when the main build uses the debug build. This // is because the `Debug` profile is too slow for normal development activities. @@ -889,10 +885,7 @@ impl BuildConfiguration { process::exit(1); }, }; - BuildConfiguration { - outer_build_profile: outer_build_profile.unwrap_or(Profile::Release), - blob_build_profile, - } + BuildConfiguration { blob_build_profile } } } From da55577d623cbcd38f871ab23d7d6b3ac567c8ae Mon Sep 17 00:00:00 2001 From: eskimor Date: Sat, 4 Apr 2026 23:50:06 +0200 Subject: [PATCH 10/14] Add debug output --- .../utils/wasm-builder/src/wasm_project.rs | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/substrate/utils/wasm-builder/src/wasm_project.rs b/substrate/utils/wasm-builder/src/wasm_project.rs index cdc8086d987d3..50ec18329377a 100644 --- a/substrate/utils/wasm-builder/src/wasm_project.rs +++ b/substrate/utils/wasm-builder/src/wasm_project.rs @@ -290,6 +290,17 @@ fn maybe_compact_and_compress_wasm( let compact_or_compressed_exists = compact_path.exists() || compressed_path.exists(); let should_regenerate = bloaty_changed || (needs_compact && !compact_or_compressed_exists); + build_helper::warning!( + "Compaction decision: blob_profile={:?}, needs_compact={}, bloaty_changed={}, \ + compact_exists={}, compressed_exists={}, should_regenerate={}", + build_config.blob_build_profile, + needs_compact, + bloaty_changed, + compact_path.exists(), + compressed_path.exists(), + should_regenerate, + ); + if !should_regenerate { let final_blob = if compressed_path.exists() { Some(WasmBinary(compressed_path)) @@ -327,6 +338,13 @@ fn maybe_compact_and_compress_wasm( ensure_runtime_version_wasm_section_exists(bloaty_blob_binary.bloaty_path()); } + build_helper::warning!( + "Compaction result: compact={}, compressed={}, bloaty_size={}", + compact_blob_path.as_ref().map(|p| format!("{}", p.wasm_binary_path().display())).unwrap_or("None".into()), + compact_compressed_blob_path.as_ref().map(|p| format!("{}", p.wasm_binary_path().display())).unwrap_or("None".into()), + fs::metadata(bloaty_blob_binary.bloaty_path()).map(|m| m.len()).unwrap_or(0), + ); + let final_blob_binary = compact_compressed_blob_path.or(compact_blob_path); final_blob_binary From 1d609e10e123bcd680df8662997870c63b4feb99 Mon Sep 17 00:00:00 2001 From: eskimor Date: Sun, 5 Apr 2026 09:58:33 +0200 Subject: [PATCH 11/14] Fmt --- substrate/utils/wasm-builder/src/wasm_project.rs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/substrate/utils/wasm-builder/src/wasm_project.rs b/substrate/utils/wasm-builder/src/wasm_project.rs index 50ec18329377a..46ced7f73aee4 100644 --- a/substrate/utils/wasm-builder/src/wasm_project.rs +++ b/substrate/utils/wasm-builder/src/wasm_project.rs @@ -340,8 +340,14 @@ fn maybe_compact_and_compress_wasm( build_helper::warning!( "Compaction result: compact={}, compressed={}, bloaty_size={}", - compact_blob_path.as_ref().map(|p| format!("{}", p.wasm_binary_path().display())).unwrap_or("None".into()), - compact_compressed_blob_path.as_ref().map(|p| format!("{}", p.wasm_binary_path().display())).unwrap_or("None".into()), + compact_blob_path + .as_ref() + .map(|p| format!("{}", p.wasm_binary_path().display())) + .unwrap_or("None".into()), + compact_compressed_blob_path + .as_ref() + .map(|p| format!("{}", p.wasm_binary_path().display())) + .unwrap_or("None".into()), fs::metadata(bloaty_blob_binary.bloaty_path()).map(|m| m.len()).unwrap_or(0), ); From b876268c4df28e0ae5d6b733b890bbe331a60634 Mon Sep 17 00:00:00 2001 From: eskimor Date: Sun, 5 Apr 2026 10:13:10 +0200 Subject: [PATCH 12/14] Debug --- substrate/utils/wasm-builder/src/builder.rs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/substrate/utils/wasm-builder/src/builder.rs b/substrate/utils/wasm-builder/src/builder.rs index 988182d5ffe2b..f40d74341dc70 100644 --- a/substrate/utils/wasm-builder/src/builder.rs +++ b/substrate/utils/wasm-builder/src/builder.rs @@ -373,9 +373,16 @@ fn build_project( let (wasm_binary, wasm_binary_bloaty) = if let Some(wasm_binary) = wasm_binary { (wasm_binary.wasm_binary_path_escaped(), bloaty.bloaty_path_escaped()) } else { + build_helper::warning!("No compact/compressed blob available, WASM_BINARY will use bloaty"); (bloaty.bloaty_path_escaped(), bloaty.bloaty_path_escaped()) }; + build_helper::warning!( + "Generated WASM_BINARY path: {}, file: {}", + wasm_binary, + file_name.display(), + ); + crate::write_file_if_changed( file_name, format!( From f204125a94209451e75d0f97c21a14207011ddc9 Mon Sep 17 00:00:00 2001 From: eskimor Date: Sun, 5 Apr 2026 10:53:18 +0200 Subject: [PATCH 13/14] More debug + rule out caching --- cumulus/test/runtime/src/lib.rs | 1 + substrate/utils/wasm-builder/src/builder.rs | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/cumulus/test/runtime/src/lib.rs b/cumulus/test/runtime/src/lib.rs index 3852bd16e5544..3c80ef986bbc8 100644 --- a/cumulus/test/runtime/src/lib.rs +++ b/cumulus/test/runtime/src/lib.rs @@ -1,5 +1,6 @@ // Copyright (C) Parity Technologies (UK) Ltd. // This file is part of Cumulus. +// Force recompilation to pick up compressed WASM binaries. // Cumulus is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by diff --git a/substrate/utils/wasm-builder/src/builder.rs b/substrate/utils/wasm-builder/src/builder.rs index f40d74341dc70..3fd2df85614ef 100644 --- a/substrate/utils/wasm-builder/src/builder.rs +++ b/substrate/utils/wasm-builder/src/builder.rs @@ -377,9 +377,11 @@ fn build_project( (bloaty.bloaty_path_escaped(), bloaty.bloaty_path_escaped()) }; + let wasm_binary_size = std::fs::metadata(std::path::Path::new(&wasm_binary)).map(|m| m.len()).unwrap_or(0); build_helper::warning!( - "Generated WASM_BINARY path: {}, file: {}", + "Generated WASM_BINARY path: {} (size: {} bytes), file: {}", wasm_binary, + wasm_binary_size, file_name.display(), ); From a790900448602f9c61fe7373fda6c4106c1cac27 Mon Sep 17 00:00:00 2001 From: eskimor Date: Sun, 5 Apr 2026 11:32:29 +0200 Subject: [PATCH 14/14] Remove debugging output --- cumulus/test/runtime/src/lib.rs | 3 +-- substrate/utils/wasm-builder/src/builder.rs | 9 ------- .../utils/wasm-builder/src/wasm_project.rs | 24 ------------------- 3 files changed, 1 insertion(+), 35 deletions(-) diff --git a/cumulus/test/runtime/src/lib.rs b/cumulus/test/runtime/src/lib.rs index 3c80ef986bbc8..89b64359a542b 100644 --- a/cumulus/test/runtime/src/lib.rs +++ b/cumulus/test/runtime/src/lib.rs @@ -1,6 +1,5 @@ // Copyright (C) Parity Technologies (UK) Ltd. // This file is part of Cumulus. -// Force recompilation to pick up compressed WASM binaries. // Cumulus is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by @@ -19,7 +18,7 @@ // `construct_runtime!` does a lot of recursion and requires us to increase the limit to 256. #![recursion_limit = "256"] -// Make the WASM binary available. +// Make the WASM binaries available. #[cfg(feature = "std")] include!(concat!(env!("OUT_DIR"), "/wasm_binary.rs")); diff --git a/substrate/utils/wasm-builder/src/builder.rs b/substrate/utils/wasm-builder/src/builder.rs index 3fd2df85614ef..988182d5ffe2b 100644 --- a/substrate/utils/wasm-builder/src/builder.rs +++ b/substrate/utils/wasm-builder/src/builder.rs @@ -373,18 +373,9 @@ fn build_project( let (wasm_binary, wasm_binary_bloaty) = if let Some(wasm_binary) = wasm_binary { (wasm_binary.wasm_binary_path_escaped(), bloaty.bloaty_path_escaped()) } else { - build_helper::warning!("No compact/compressed blob available, WASM_BINARY will use bloaty"); (bloaty.bloaty_path_escaped(), bloaty.bloaty_path_escaped()) }; - let wasm_binary_size = std::fs::metadata(std::path::Path::new(&wasm_binary)).map(|m| m.len()).unwrap_or(0); - build_helper::warning!( - "Generated WASM_BINARY path: {} (size: {} bytes), file: {}", - wasm_binary, - wasm_binary_size, - file_name.display(), - ); - crate::write_file_if_changed( file_name, format!( diff --git a/substrate/utils/wasm-builder/src/wasm_project.rs b/substrate/utils/wasm-builder/src/wasm_project.rs index 46ced7f73aee4..cdc8086d987d3 100644 --- a/substrate/utils/wasm-builder/src/wasm_project.rs +++ b/substrate/utils/wasm-builder/src/wasm_project.rs @@ -290,17 +290,6 @@ fn maybe_compact_and_compress_wasm( let compact_or_compressed_exists = compact_path.exists() || compressed_path.exists(); let should_regenerate = bloaty_changed || (needs_compact && !compact_or_compressed_exists); - build_helper::warning!( - "Compaction decision: blob_profile={:?}, needs_compact={}, bloaty_changed={}, \ - compact_exists={}, compressed_exists={}, should_regenerate={}", - build_config.blob_build_profile, - needs_compact, - bloaty_changed, - compact_path.exists(), - compressed_path.exists(), - should_regenerate, - ); - if !should_regenerate { let final_blob = if compressed_path.exists() { Some(WasmBinary(compressed_path)) @@ -338,19 +327,6 @@ fn maybe_compact_and_compress_wasm( ensure_runtime_version_wasm_section_exists(bloaty_blob_binary.bloaty_path()); } - build_helper::warning!( - "Compaction result: compact={}, compressed={}, bloaty_size={}", - compact_blob_path - .as_ref() - .map(|p| format!("{}", p.wasm_binary_path().display())) - .unwrap_or("None".into()), - compact_compressed_blob_path - .as_ref() - .map(|p| format!("{}", p.wasm_binary_path().display())) - .unwrap_or("None".into()), - fs::metadata(bloaty_blob_binary.bloaty_path()).map(|m| m.len()).unwrap_or(0), - ); - let final_blob_binary = compact_compressed_blob_path.or(compact_blob_path); final_blob_binary