diff --git a/Cargo.lock b/Cargo.lock index 89d1c6bb2a..081a9edd8b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3879,6 +3879,7 @@ dependencies = [ "eyre", "owo-colors 4.1.0", "path-absolutize", + "serde", "serde_json", "sha256", "spinoff", diff --git a/crates/iroha_core/src/sumeragi/main_loop.rs b/crates/iroha_core/src/sumeragi/main_loop.rs index 4ec1ceb020..a0f51104cf 100644 --- a/crates/iroha_core/src/sumeragi/main_loop.rs +++ b/crates/iroha_core/src/sumeragi/main_loop.rs @@ -263,13 +263,12 @@ impl Sumeragi { }; if block.as_ref().errors().next().is_some() { - error!("Genesis contains invalid transactions"); - for error in block.as_ref().errors() { error!( peer_id=%self.peer, role=%self.role(), - ?error + ?error, + "Invalid transaction in genesis" ); } continue; diff --git a/crates/iroha_test_network/src/lib.rs b/crates/iroha_test_network/src/lib.rs index 107920ca55..7d76bbab85 100644 --- a/crates/iroha_test_network/src/lib.rs +++ b/crates/iroha_test_network/src/lib.rs @@ -339,15 +339,6 @@ impl NetworkBuilder { commit_time = SumeragiParameters::default().commit_time(); } - // Unoptimized profile requires additional resources. - // if cfg!(debug_assertions) { - // extra_isi.push(InstructionBox::SetParameter(SetParameter::new( - // Parameter::Executor(SmartContractParameter::Fuel( - // std::num::NonZeroU64::new(80000000).expect("Fuel must be positive."), - // )), - // ))); - // } - let genesis = config::genesis( [ InstructionBox::SetParameter(SetParameter::new(Parameter::Sumeragi( diff --git a/crates/iroha_test_samples/src/lib.rs b/crates/iroha_test_samples/src/lib.rs index 9884762c53..8513db7f4d 100644 --- a/crates/iroha_test_samples/src/lib.rs +++ b/crates/iroha_test_samples/src/lib.rs @@ -10,6 +10,7 @@ use std::{ use iroha_crypto::KeyPair; use iroha_data_model::prelude::{AccountId, WasmSmartContract}; use iroha_wasm_builder::Profile; +use serde::Deserialize; /// Generate [`AccountId`](iroha_data_model::account::AccountId) in the given `domain`. /// @@ -130,6 +131,11 @@ pub fn load_sample_wasm(name: impl AsRef) -> WasmSmartContract { } } +#[derive(Deserialize)] +struct WasmBuildConfiguration { + profile: Profile, +} + /// Load WASM smart contract build profile /// /// WASMs must be pre-built with the `build_wasm.sh` script @@ -150,15 +156,9 @@ pub fn load_wasm_build_profile() -> Profile { panic!("could not read WASM build profile"); } Ok(content) => { - let parsed: toml::Value = - toml::from_str(content.as_str()).expect("must parse config file"); - let profile_str = parsed - .get("profile") - .and_then(toml::Value::as_str) - .expect("profile must be present in config"); - profile_str - .parse() - .unwrap_or_else(|_| panic!("unrecognized profile {profile_str}")) + let WasmBuildConfiguration { profile } = toml::from_str(content.as_str()) + .expect("a valid config must be written by `build_wasm.sh`"); + profile } } } diff --git a/crates/iroha_wasm_builder/Cargo.toml b/crates/iroha_wasm_builder/Cargo.toml index d8864507d5..9f0b14af89 100644 --- a/crates/iroha_wasm_builder/Cargo.toml +++ b/crates/iroha_wasm_builder/Cargo.toml @@ -14,6 +14,7 @@ workspace = true [dependencies] eyre = { workspace = true } serde_json = { workspace = true, features = ["std"] } +serde = { workspace = true, features = ["std"] } sha256 = "1.5.0" path-absolutize = { workspace = true } strum = { workspace = true, features = ["derive", "std"] } diff --git a/crates/iroha_wasm_builder/src/lib.rs b/crates/iroha_wasm_builder/src/lib.rs index f72b31756e..d21d8cbd47 100644 --- a/crates/iroha_wasm_builder/src/lib.rs +++ b/crates/iroha_wasm_builder/src/lib.rs @@ -12,12 +12,24 @@ use std::{ use eyre::{bail, eyre, Context as _, Result}; use path_absolutize::Absolutize; +use serde::{Deserialize, Serialize}; /// Current toolchain used to build smartcontracts const TOOLCHAIN: &str = "+nightly-2024-09-09"; /// Build profile for smartcontracts -#[derive(Debug, Copy, Clone, Eq, PartialEq, strum::Display, strum::EnumString, Default)] +#[derive( + Debug, + Copy, + Clone, + Eq, + PartialEq, + strum::Display, + strum::EnumString, + Default, + Serialize, + Deserialize, +)] #[strum(serialize_all = "snake_case")] pub enum Profile { /// Applies release optimization