From c15c98f84bdde57b67b8ee5058155aa5a7b282cd Mon Sep 17 00:00:00 2001 From: Omar Date: Sat, 20 Jan 2024 05:11:53 +0300 Subject: [PATCH] [Misc]: Update the scrypto version used. --- Cargo.toml | 24 +++---- libraries/package-loader/build.rs | 108 +++++++++++++++++------------- tests/src/environment.rs | 4 +- 3 files changed, 75 insertions(+), 61 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index b11efb08..07682d77 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -23,19 +23,19 @@ edition = "2021" description = "The implementation of project Ignition in Scrypto for the Radix Ledger" [workspace.dependencies] -sbor = { git = "https://github.com/radixdlt/radixdlt-scrypto", rev = "9663c7c7dbcb91309b01f0b931195194b75b2718" } -scrypto = { git = "https://github.com/radixdlt/radixdlt-scrypto", rev = "9663c7c7dbcb91309b01f0b931195194b75b2718" } -transaction = { git = "https://github.com/radixdlt/radixdlt-scrypto", rev = "9663c7c7dbcb91309b01f0b931195194b75b2718" } -radix-engine = { git = "https://github.com/radixdlt/radixdlt-scrypto", rev = "9663c7c7dbcb91309b01f0b931195194b75b2718" } -radix-engine-common = { git = "https://github.com/radixdlt/radixdlt-scrypto", rev = "9663c7c7dbcb91309b01f0b931195194b75b2718" } -radix-engine-stores = { git = "https://github.com/radixdlt/radixdlt-scrypto", rev = "9663c7c7dbcb91309b01f0b931195194b75b2718" } -radix-engine-derive = { git = "https://github.com/radixdlt/radixdlt-scrypto", rev = "9663c7c7dbcb91309b01f0b931195194b75b2718" } -radix-engine-queries = { git = "https://github.com/radixdlt/radixdlt-scrypto", rev = "9663c7c7dbcb91309b01f0b931195194b75b2718" } -radix-engine-interface = { git = "https://github.com/radixdlt/radixdlt-scrypto", rev = "9663c7c7dbcb91309b01f0b931195194b75b2718" } -radix-engine-store-interface = { git = "https://github.com/radixdlt/radixdlt-scrypto", rev = "9663c7c7dbcb91309b01f0b931195194b75b2718" } +sbor = { git = "https://github.com/radixdlt/radixdlt-scrypto", rev = "ea46347402a5553d4f0a594ff003e5f455d2b5d1" } +scrypto = { git = "https://github.com/radixdlt/radixdlt-scrypto", rev = "ea46347402a5553d4f0a594ff003e5f455d2b5d1" } +transaction = { git = "https://github.com/radixdlt/radixdlt-scrypto", rev = "ea46347402a5553d4f0a594ff003e5f455d2b5d1" } +radix-engine = { git = "https://github.com/radixdlt/radixdlt-scrypto", rev = "ea46347402a5553d4f0a594ff003e5f455d2b5d1" } +radix-engine-common = { git = "https://github.com/radixdlt/radixdlt-scrypto", rev = "ea46347402a5553d4f0a594ff003e5f455d2b5d1" } +radix-engine-stores = { git = "https://github.com/radixdlt/radixdlt-scrypto", rev = "ea46347402a5553d4f0a594ff003e5f455d2b5d1" } +radix-engine-derive = { git = "https://github.com/radixdlt/radixdlt-scrypto", rev = "ea46347402a5553d4f0a594ff003e5f455d2b5d1" } +radix-engine-queries = { git = "https://github.com/radixdlt/radixdlt-scrypto", rev = "ea46347402a5553d4f0a594ff003e5f455d2b5d1" } +radix-engine-interface = { git = "https://github.com/radixdlt/radixdlt-scrypto", rev = "ea46347402a5553d4f0a594ff003e5f455d2b5d1" } +radix-engine-store-interface = { git = "https://github.com/radixdlt/radixdlt-scrypto", rev = "ea46347402a5553d4f0a594ff003e5f455d2b5d1" } -scrypto-unit = { git = "https://github.com/radixdlt/radixdlt-scrypto", rev = "9663c7c7dbcb91309b01f0b931195194b75b2718" } -scrypto-test = { git = "https://github.com/radixdlt/radixdlt-scrypto", rev = "9663c7c7dbcb91309b01f0b931195194b75b2718" } +scrypto-unit = { git = "https://github.com/radixdlt/radixdlt-scrypto", rev = "ea46347402a5553d4f0a594ff003e5f455d2b5d1" } +scrypto-test = { git = "https://github.com/radixdlt/radixdlt-scrypto", rev = "ea46347402a5553d4f0a594ff003e5f455d2b5d1" } [profile.release] opt-level = 'z' diff --git a/libraries/package-loader/build.rs b/libraries/package-loader/build.rs index 4a5d238c..6a4b4553 100644 --- a/libraries/package-loader/build.rs +++ b/libraries/package-loader/build.rs @@ -56,55 +56,70 @@ fn build_blueprints() -> Result<(), Error> { .flatten() .collect::>(); - // Building each of the packages that have been discovered. - let mut packages = HashMap::new(); - for package_name in package_names { - // Build the package - let status = Command::new("cargo") - .args([ - "build", - "--target", - "wasm32-unknown-unknown", - "--release", - "--target-dir", - builds_target_path.as_path().display().to_string().as_str(), - "--package", - package_name.as_str(), - ]) - .status()?; - if !status.success() { - return Err(Error::CompilationOfPackageFailed(package_name)); - } - - // Construct the path to the WASM file. + // Build 1: Building each of the packages with the package definition. + let status = Command::new("cargo") + .args([ + "build", + "--target", + "wasm32-unknown-unknown", + "--release", + "--target-dir", + builds_target_path.as_path().display().to_string().as_str(), + ]) + .args(package_names.iter().flat_map(|package_name| { + ["--package".to_owned(), package_name.to_owned()] + })) + .status()?; + if !status.success() { + return Err(Error::CompilationOfPackageFailed); + } + + // Read the package definition of the various packages - assume code to be + // an empty byte array for now. + let mut packages = package_names + .iter() + .map(|package_name| { + let wasm_path = builds_target_path + .join("wasm32-unknown-unknown") + .join("release") + .join(format!("{}.wasm", package_name.replace('-', "_"))); + + let package_definition = + radix_engine::utils::extract_definition(&read(wasm_path)?)?; + + Ok::<_, Error>(( + package_name.clone(), + (Vec::::new(), package_definition), + )) + }) + .collect::, _>>()?; + + // Build 2: Build without the package definition. + let status = Command::new("cargo") + .args([ + "build", + "--target", + "wasm32-unknown-unknown", + "--release", + "--target-dir", + builds_target_path.as_path().display().to_string().as_str(), + "--features", + "scrypto/no-schema", + ]) + .args(package_names.iter().flat_map(|package_name| { + ["--package".to_owned(), package_name.to_owned()] + })) + .status()?; + if !status.success() { + return Err(Error::CompilationOfPackageFailed); + } + + for package_name in package_names.iter() { let wasm_path = builds_target_path .join("wasm32-unknown-unknown") .join("release") .join(format!("{}.wasm", package_name.replace('-', "_"))); - // Extract the package definition - let package_definition = - radix_engine::utils::extract_definition(&read(&wasm_path)?)?; - - // Build a new WASM build without any of the schema information - let status = Command::new("cargo") - .args([ - "build", - "--target", - "wasm32-unknown-unknown", - "--release", - "--target-dir", - builds_target_path.as_path().display().to_string().as_str(), - "--package", - package_name.as_str(), - "--features", - "scrypto/no-schema", - ]) - .status()?; - if !status.success() { - return Err(Error::CompilationOfPackageFailed(package_name)); - } - // Optimize the WASM using wasm-opt for size wasm_opt::OptimizationOptions::new_optimize_for_size_aggressively() .add_pass(wasm_opt::Pass::StripDebug) @@ -112,10 +127,9 @@ fn build_blueprints() -> Result<(), Error> { .add_pass(wasm_opt::Pass::StripProducers) .run(&wasm_path, &wasm_path)?; - // Read the final wasm. let wasm = read(wasm_path)?; - packages.insert(package_name, (wasm, package_definition)); + packages.get_mut(package_name.as_str()).unwrap().0 = wasm; } let out_dir = @@ -137,7 +151,7 @@ pub enum Error { IoError(std::io::Error), #[cfg(feature = "build-time-blueprints")] ManifestError(cargo_toml::Error), - CompilationOfPackageFailed(String), + CompilationOfPackageFailed, #[cfg(feature = "build-time-blueprints")] ExtractSchemaError(radix_engine::utils::ExtractSchemaError), #[cfg(feature = "build-time-blueprints")] diff --git a/tests/src/environment.rs b/tests/src/environment.rs index 86d5fd3e..0e3d1c9d 100644 --- a/tests/src/environment.rs +++ b/tests/src/environment.rs @@ -16,7 +16,7 @@ use crate::prelude::*; /// that must happen after the creation of the environment. pub struct Environment { /* Test Environment */ - pub environment: TestEnvironment, + pub environment: TestEnvironment, /* Various entities */ pub resources: ResourceInformation, pub protocol: ProtocolEntities, @@ -285,7 +285,7 @@ impl Environment { fn publish_package( name: &str, - env: &mut TestEnvironment, + env: &mut TestEnvironment, ) -> Result { let (code, definition) = package_loader::PackageLoader::get(name); Package::publish(code, definition, Default::default(), env)