From 0cba0b857c249faa298f087381ec8d82f3ab4d40 Mon Sep 17 00:00:00 2001 From: Lohachov Mykhailo Date: Sat, 7 Dec 2024 20:39:21 +0900 Subject: [PATCH] fix: update porfile parsing Signed-off-by: Lohachov Mykhailo --- .config/nextest.toml | 1 - crates/iroha_core/src/sumeragi/main_loop.rs | 16 ++++++++++------ crates/iroha_wasm_builder/src/lib.rs | 13 +++---------- crates/iroha_wasm_builder/src/main.rs | 6 ++---- 4 files changed, 15 insertions(+), 21 deletions(-) diff --git a/.config/nextest.toml b/.config/nextest.toml index fade17d4e5..3589b634c7 100644 --- a/.config/nextest.toml +++ b/.config/nextest.toml @@ -2,7 +2,6 @@ retries = { backoff = "fixed", count = 3, delay = "3s" } [profile.ci] -retries = { backoff = "fixed", count = 3, delay = "3s" } fail-fast = false failure-output = "immediate-final" slow-timeout = { period = "30s", terminate-after = 4 } diff --git a/crates/iroha_core/src/sumeragi/main_loop.rs b/crates/iroha_core/src/sumeragi/main_loop.rs index a478c855b7..e5b88bfa07 100644 --- a/crates/iroha_core/src/sumeragi/main_loop.rs +++ b/crates/iroha_core/src/sumeragi/main_loop.rs @@ -262,13 +262,17 @@ impl Sumeragi { } }; - if let Some(error) = block.as_ref().errors().next() { - error!( - peer_id=%self.peer, - role=%self.role(), - ?error - ); + let mut errors = block.as_ref().errors().peekable(); + if errors.peek().is_some() { + error!("Genesis contains invalid transactions"); + for error in block.as_ref().errors() { + error!( + peer_id=%self.peer, + role=%self.role(), + ?error + ); + } continue; } diff --git a/crates/iroha_wasm_builder/src/lib.rs b/crates/iroha_wasm_builder/src/lib.rs index 71ce20d305..38fc62acb6 100644 --- a/crates/iroha_wasm_builder/src/lib.rs +++ b/crates/iroha_wasm_builder/src/lib.rs @@ -43,7 +43,7 @@ impl Profile { /// use iroha_wasm_builder::Builder; /// /// fn main() -> Result<()> { -/// let bytes = Builder::new("relative/path/to/smartcontract/", "deploy") +/// let bytes = Builder::new("relative/path/to/smartcontract/", Profile::Deploy) /// .out_dir("path/to/out/dir") // Optional: Set output directory /// .build()? // Run build /// .into_bytes()?; // Get resulting WASM bytes @@ -214,19 +214,12 @@ mod internal { pub fn build(self) -> Result { let absolute_path = self.absolute_path.clone(); - let optimize = Profile::is_optimized(self.profile); - let output = self.build_smartcontract().wrap_err_with(|| { + self.build_smartcontract().wrap_err_with(|| { format!( "Failed to build the smartcontract at path: {}", absolute_path.display() ) - })?; - - if optimize { - output.optimize() - } else { - Ok(output) - } + }) } fn build_profile(&self) -> String { diff --git a/crates/iroha_wasm_builder/src/main.rs b/crates/iroha_wasm_builder/src/main.rs index f8b6282835..3267d78017 100644 --- a/crates/iroha_wasm_builder/src/main.rs +++ b/crates/iroha_wasm_builder/src/main.rs @@ -15,7 +15,7 @@ enum Cli { #[command(flatten)] common: CommonArgs, #[arg(long, default_value = "release")] - profile: String, + profile: Profile, }, /// Build the smartcontract Build { @@ -23,7 +23,7 @@ enum Cli { common: CommonArgs, /// Build profile #[arg(long, default_value = "release")] - profile: String, + profile: Profile, /// Where to store the output WASM. If the file exists, it will be overwritten. #[arg(long)] out_file: PathBuf, @@ -42,7 +42,6 @@ fn main() -> color_eyre::Result<()> { common: CommonArgs { path }, profile, } => { - let profile: Profile = profile.parse().expect("Invalid profile provided"); let builder = Builder::new(&path, profile).show_output(); builder.check()?; } @@ -51,7 +50,6 @@ fn main() -> color_eyre::Result<()> { out_file, profile, } => { - let profile: Profile = profile.parse().expect("Invalid profile provided"); let builder = Builder::new(&path, profile).show_output(); let output = {