diff --git a/.github/workflows/build-frontend-canister.yml b/.github/workflows/build-frontend-canister.yml index 57a0e86e1e..3445d0cb9a 100644 --- a/.github/workflows/build-frontend-canister.yml +++ b/.github/workflows/build-frontend-canister.yml @@ -16,7 +16,7 @@ jobs: - name: Set up run: | rustup target add wasm32-unknown-unknown - cargo install --version 0.1.5 ic-wasm + cargo install --version 0.2.0 ic-wasm - name: Build frontend canister run: | ./scripts/update-frontend-canister.sh diff --git a/Cargo.lock b/Cargo.lock index 00dec02b6d..bb02af4c0d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -800,7 +800,6 @@ dependencies = [ "tokio", "url", "walkdir", - "walrus", "wasmparser 0.87.0", "which", ] @@ -1599,9 +1598,9 @@ dependencies = [ [[package]] name = "ic-types" -version = "0.4.1" +version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "82e9cac29df1f2906137c327ed24dfc398460eda054abaa6107273c11afe6384" +checksum = "0a7d9569a4c91d5c9c202c1666f799a9761bab70a2b59464ee78c45b005e47b8" dependencies = [ "crc32fast", "data-encoding", @@ -1635,14 +1634,15 @@ dependencies = [ [[package]] name = "ic-wasm" -version = "0.1.4" +version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ebed180ae82aa994a90c4477fc928379efb8d55e52e5b90c3ab1611dd4c11ab1" +checksum = "a6bcb4b8c4455f08fe0c2671fa815affbec6b3eee631f61bd9adcd287bfbc4a2" dependencies = [ "anyhow", "candid", "clap", "ic-types", + "thiserror", "walrus", ] @@ -3366,18 +3366,18 @@ checksum = "b1141d4d61095b28419e22cb0bbf02755f5e54e0526f97f1e3d1d160e60885fb" [[package]] name = "thiserror" -version = "1.0.32" +version = "1.0.35" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f5f6586b7f764adc0231f4c79be7b920e766bb2f3e51b3661cdb263828f19994" +checksum = "c53f98874615aea268107765aa1ed8f6116782501d18e53d08b471733bea6c85" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.32" +version = "1.0.35" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "12bafc5b54507e0149cdf1b145a5d80ab80a90bcd9275df43d4fff68460f6c21" +checksum = "f8b463991b4eab2d801e724172285ec4195c650e8ec79b149e6c2a8e6dd3f783" dependencies = [ "proc-macro2", "quote", diff --git a/src/dfx/Cargo.toml b/src/dfx/Cargo.toml index c4a2f66298..d325a384b7 100644 --- a/src/dfx/Cargo.toml +++ b/src/dfx/Cargo.toml @@ -45,7 +45,7 @@ humantime = "2.1.0" humantime-serde = "1.1.1" hyper-rustls = { version = "0.23.0", features = [ "webpki-roots", "http2" ] } ic-asset = { version = "0.20.0", path = "../canisters/frontend/ic-asset" } -ic-wasm = { version = "0.1.3" } +ic-wasm = "0.2.0" indicatif = "0.16.0" itertools = "0.10.3" k256 = { version = "0.11.4", features = ["pem"] } @@ -83,7 +83,6 @@ tiny-bip39 = "1.0.0" tokio = { version = "1.17.0", features = [ "fs" ] } url = "2.1.0" walkdir = "2.2.9" -walrus = "0.19.0" wasmparser = "0.87.0" which = "4.2.5" diff --git a/src/dfx/src/lib/builders/mod.rs b/src/dfx/src/lib/builders/mod.rs index da19322364..c5de37b29b 100644 --- a/src/dfx/src/lib/builders/mod.rs +++ b/src/dfx/src/lib/builders/mod.rs @@ -386,15 +386,9 @@ impl BuildConfig { fn shrink_wasm(wasm_path: impl AsRef) -> DfxResult { let wasm_path = wasm_path.as_ref(); let wasm = std::fs::read(wasm_path).context("Could not read the WASM module.")?; - let mut module_config = walrus::ModuleConfig::new(); - module_config.generate_name_section(true); - module_config.generate_producers_section(false); - let mut module = module_config - .parse(&wasm) - .context("Could not parse the WASM module.")?; - ic_wasm::shrink::shrink(&mut module); - module - .emit_wasm_file(wasm_path) + let shrinked_wasm = + ic_wasm::shrink::shrink(&wasm).context("Could not shrink the WASM module.")?; + std::fs::write(wasm_path, &shrinked_wasm) .with_context(|| format!("Could not write shrinked WASM to {:?}", wasm_path))?; Ok(()) } diff --git a/src/dfx/src/lib/wasm/metadata.rs b/src/dfx/src/lib/wasm/metadata.rs index 7281ad60be..c24c5caa52 100644 --- a/src/dfx/src/lib/wasm/metadata.rs +++ b/src/dfx/src/lib/wasm/metadata.rs @@ -8,15 +8,12 @@ use std::path::Path; #[context("Failed to add candid service metadata from {} to {}.", idl_path.to_string_lossy(), wasm_path.to_string_lossy())] pub fn add_candid_service_metadata(wasm_path: &Path, idl_path: &Path) -> DfxResult { - let mut m = walrus::ModuleConfig::new() - .parse_file(wasm_path) - .with_context(|| format!("Failed to parse file {}", wasm_path.to_string_lossy()))?; + let wasm = std::fs::read(wasm_path).context("Could not read the WASM module.")?; let idl = std::fs::read(&idl_path) .with_context(|| format!("Failed to read {}", idl_path.to_string_lossy()))?; - - add_metadata(&mut m, Kind::Public, CANDID_SERVICE, idl); - - m.emit_wasm_file(wasm_path) - .with_context(|| format!("Failed to emit wasm to {}", wasm_path.to_string_lossy()))?; + let processed_wasm = add_metadata(&wasm, Kind::Public, CANDID_SERVICE, idl) + .context("Could not add metadata to the WASM module.")?; + std::fs::write(wasm_path, &processed_wasm) + .with_context(|| format!("Could not write WASM to {:?}", wasm_path))?; Ok(()) } diff --git a/src/distributed/assetstorage.wasm.gz b/src/distributed/assetstorage.wasm.gz index 18e02b66da..904d798bf7 100755 Binary files a/src/distributed/assetstorage.wasm.gz and b/src/distributed/assetstorage.wasm.gz differ