From 70bbcbe886d9f82372022673766b37b14f09f7e6 Mon Sep 17 00:00:00 2001 From: Jonathan Becker <64037729+Jon-Becker@users.noreply.github.com> Date: Wed, 12 Jul 2023 18:49:16 -0400 Subject: [PATCH 1/3] :wrench: fix: dont crash during signature resolution selection --- .gitignore | 2 + common/src/testing/benchmarks.rs | 74 +++++++++++++++++++++++++++++--- heimdall/src/decompile/mod.rs | 15 ++----- 3 files changed, 73 insertions(+), 18 deletions(-) diff --git a/.gitignore b/.gitignore index 76f7edef..eb0d41fb 100644 --- a/.gitignore +++ b/.gitignore @@ -31,3 +31,5 @@ coverage.xml false false/* */false + +*.svg diff --git a/common/src/testing/benchmarks.rs b/common/src/testing/benchmarks.rs index 6f09e0b3..06b5ea22 100644 --- a/common/src/testing/benchmarks.rs +++ b/common/src/testing/benchmarks.rs @@ -1,7 +1,6 @@ use std::{io, io::Write, thread, time::Instant}; -use crate::utils::integers::ToLocaleString; - +#[allow(dead_code)] pub fn benchmark(benchmark_name: &str, runs: usize, to_bench: fn()) { let mut time = 0usize; let mut times = Vec::with_capacity(runs); @@ -14,7 +13,7 @@ pub fn benchmark(benchmark_name: &str, runs: usize, to_bench: fn()) { for _ in 0..runs { let start_time = Instant::now(); to_bench(); - let end_time = start_time.elapsed().as_micros() as usize; + let end_time = start_time.elapsed().as_nanos() as usize; max = std::cmp::max(max, end_time); min = std::cmp::min(min, end_time); @@ -36,12 +35,75 @@ pub fn benchmark(benchmark_name: &str, runs: usize, to_bench: fn()) { let _ = io::stdout().write_all( format!( - " {}:\n {}μs ± {}μs per run ( with {} runs ).\n\n", + " {}:\n {} ± {} per run ( with {} runs ).\n\n", benchmark_name, - mean.to_locale_string(), - std_dev.to_locale_string(), + format_nanos(mean), + format_nanos(std_dev), runs ) .as_bytes(), ); } + +#[allow(dead_code)] +fn format_nanos(nanos: usize) -> String { + let mut nanos = nanos; + let mut micros = 0; + let mut millis = 0; + let mut secs = 0; + let mut mins = 0; + let mut hours = 0; + + if nanos >= 1000 { + micros = nanos / 1000; + nanos %= 1000; + } + + if micros >= 1000 { + millis = micros / 1000; + micros %= 1000; + } + + if millis >= 1000 { + secs = millis / 1000; + millis %= 1000; + } + + if secs >= 60 { + mins = secs / 60; + secs %= 60; + } + + if mins >= 60 { + hours = mins / 60; + mins %= 60; + } + + let mut result = String::new(); + + if hours > 0 { + result.push_str(&format!("{}h ", hours)); + } + + if mins > 0 { + result.push_str(&format!("{}m ", mins)); + } + + if secs > 0 { + result.push_str(&format!("{}s ", secs)); + } + + if millis > 0 { + result.push_str(&format!("{}ms ", millis)); + } + + if micros > 0 { + result.push_str(&format!("{}μs ", micros)); + } + + if nanos > 0 { + result.push_str(&format!("{}ns", nanos)); + } + + result +} diff --git a/heimdall/src/decompile/mod.rs b/heimdall/src/decompile/mod.rs index abb932cf..72c1c211 100644 --- a/heimdall/src/decompile/mod.rs +++ b/heimdall/src/decompile/mod.rs @@ -424,10 +424,7 @@ pub fn decompile(args: DecompilerArgs) { let selected_match = match matched_resolved_functions.get(selected_function_index as usize) { Some(selected_match) => selected_match, - None => { - logger.error("invalid selection."); - std::process::exit(1) - } + None => continue, }; analyzed_function.resolved_function = Some(selected_match.clone()); @@ -490,10 +487,7 @@ pub fn decompile(args: DecompilerArgs) { let selected_match = match resolved_error_selectors.get(selected_error_index as usize) { Some(selected_match) => selected_match, - None => { - logger.error("invalid selection."); - std::process::exit(1) - } + None => continue, }; resolved_counter += 1; @@ -559,10 +553,7 @@ pub fn decompile(args: DecompilerArgs) { let selected_match = match resolved_event_selectors.get(selected_event_index as usize) { Some(selected_match) => selected_match, - None => { - logger.error("invalid selection."); - std::process::exit(1) - } + None => continue, }; resolved_counter += 1; From 742b3f7d9326d2e95192326ca1d7b7d6a4500f2e Mon Sep 17 00:00:00 2001 From: Jonathan Becker <64037729+Jon-Becker@users.noreply.github.com> Date: Wed, 12 Jul 2023 18:51:27 -0400 Subject: [PATCH 2/3] =?UTF-8?q?=F0=9F=91=B7=20build:=20bump=20version=20to?= =?UTF-8?q?=200.4.8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Cargo.lock | 8 ++++---- Cargo.toml | 2 +- cache/Cargo.toml | 2 +- common/Cargo.toml | 2 +- config/Cargo.toml | 2 +- heimdall/Cargo.toml | 2 +- 6 files changed, 9 insertions(+), 9 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index e6be5ba0..f8620c01 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1593,7 +1593,7 @@ checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8" [[package]] name = "heimdall" -version = "0.4.7" +version = "0.4.8" dependencies = [ "backtrace", "clap", @@ -1618,7 +1618,7 @@ dependencies = [ [[package]] name = "heimdall-cache" -version = "0.4.7" +version = "0.4.8" dependencies = [ "bincode", "clap", @@ -1629,7 +1629,7 @@ dependencies = [ [[package]] name = "heimdall-common" -version = "0.4.7" +version = "0.4.8" dependencies = [ "async-openai", "clap", @@ -1650,7 +1650,7 @@ dependencies = [ [[package]] name = "heimdall-config" -version = "0.4.7" +version = "0.4.8" dependencies = [ "clap", "clap-verbosity-flag", diff --git a/Cargo.toml b/Cargo.toml index bb12954f..e8aa17b4 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,3 +1,3 @@ [workspace] members = ["common", "config", "heimdall"] -version = "0.4.7" +version = "0.4.8" diff --git a/cache/Cargo.toml b/cache/Cargo.toml index 2118fae6..5bb01f8e 100644 --- a/cache/Cargo.toml +++ b/cache/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "heimdall-cache" -version = "0.4.7" +version = "0.4.8" edition = "2021" license = "MIT" readme = "README.md" diff --git a/common/Cargo.toml b/common/Cargo.toml index 07dd0839..e2f7b00f 100644 --- a/common/Cargo.toml +++ b/common/Cargo.toml @@ -5,7 +5,7 @@ keywords = ["ethereum", "web3", "decompiler", "evm", "crypto"] license = "MIT" name = "heimdall-common" readme = "README.md" -version = "0.4.7" +version = "0.4.8" [dependencies] async-openai = "0.10.0" diff --git a/config/Cargo.toml b/config/Cargo.toml index 403482e2..56298041 100644 --- a/config/Cargo.toml +++ b/config/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "heimdall-config" -version = "0.4.7" +version = "0.4.8" edition = "2021" license = "MIT" readme = "README.md" diff --git a/heimdall/Cargo.toml b/heimdall/Cargo.toml index 5ebf73f3..20d1ffe5 100644 --- a/heimdall/Cargo.toml +++ b/heimdall/Cargo.toml @@ -5,7 +5,7 @@ keywords = ["ethereum", "web3", "decompiler", "evm", "crypto"] license = "MIT" name = "heimdall" readme = "README.md" -version = "0.4.7" +version = "0.4.8" [dependencies] backtrace = "0.3" From b02aa1c665e465344b90f8ddbf5ca0ede18f465f Mon Sep 17 00:00:00 2001 From: Jonathan Becker <64037729+Jon-Becker@users.noreply.github.com> Date: Wed, 12 Jul 2023 19:08:16 -0400 Subject: [PATCH 3/3] =?UTF-8?q?=F0=9F=93=A6=20deps:=20update=20deps?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Cargo.lock | 87 ++++++++++++++++++++++++++++++--------------- cache/Cargo.toml | 2 +- common/Cargo.toml | 2 +- config/Cargo.toml | 2 +- heimdall/Cargo.toml | 4 +-- 5 files changed, 63 insertions(+), 34 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index f8620c01..df36fc46 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -410,7 +410,7 @@ dependencies = [ "bitflags", "clap_derive", "clap_lex", - "indexmap", + "indexmap 1.9.3", "once_cell", "strsim", "termcolor", @@ -634,6 +634,22 @@ dependencies = [ "winapi", ] +[[package]] +name = "crossterm" +version = "0.26.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a84cda67535339806297f1b331d6dd6320470d2a0fe65381e79ee9e156dd3d13" +dependencies = [ + "bitflags", + "crossterm_winapi", + "libc", + "mio", + "parking_lot", + "signal-hook", + "signal-hook-mio", + "winapi", +] + [[package]] name = "crossterm_winapi" version = "0.9.0" @@ -914,6 +930,12 @@ dependencies = [ "zeroize", ] +[[package]] +name = "equivalent" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" + [[package]] name = "errno" version = "0.3.1" @@ -1072,7 +1094,7 @@ dependencies = [ "serde", "serde_json", "syn 2.0.18", - "toml 0.7.4", + "toml", "walkdir", ] @@ -1273,9 +1295,9 @@ dependencies = [ [[package]] name = "fancy-regex" -version = "0.10.0" +version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0678ab2d46fa5195aaf59ad034c083d351377d4af57f3e073c074d0da3e3c766" +checksum = "b95f7c0680e4142284cf8b22c14a476e87d61b004a3a0861872b32ef7ead40a2" dependencies = [ "bit-set", "regex", @@ -1563,7 +1585,7 @@ dependencies = [ "futures-sink", "futures-util", "http", - "indexmap", + "indexmap 1.9.3", "slab", "tokio", "tokio-util", @@ -1576,6 +1598,12 @@ version = "0.12.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" +[[package]] +name = "hashbrown" +version = "0.14.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2c6201b9ff9fd90a5a3bac2e56a830d0caa509576f0e503818ee82c181b3437a" + [[package]] name = "hashers" version = "1.0.1" @@ -1599,7 +1627,7 @@ dependencies = [ "clap", "clap-verbosity-flag", "colored", - "crossterm", + "crossterm 0.26.1", "dot", "ethers", "fancy-regex", @@ -1624,7 +1652,7 @@ dependencies = [ "clap", "clap-verbosity-flag", "serde", - "toml 0.5.11", + "toml", ] [[package]] @@ -1656,7 +1684,7 @@ dependencies = [ "clap-verbosity-flag", "heimdall-common", "serde", - "toml 0.5.11", + "toml", ] [[package]] @@ -1858,7 +1886,17 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bd070e393353796e801d209ad339e89596eb4c8d430d18ede6a1cced8fafbd99" dependencies = [ "autocfg", - "hashbrown", + "hashbrown 0.12.3", +] + +[[package]] +name = "indexmap" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d5477fe2230a79769d8dc68e0eabf5437907c0457a5614a9e8dddb67f65eb65d" +dependencies = [ + "equivalent", + "hashbrown 0.14.0", ] [[package]] @@ -2392,7 +2430,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4dd7d28ee937e54fe3080c91faa1c3a46c06de6252988a7f4592ba2310ef22a4" dependencies = [ "fixedbitset", - "indexmap", + "indexmap 1.9.3", ] [[package]] @@ -3092,9 +3130,9 @@ dependencies = [ [[package]] name = "serde_spanned" -version = "0.6.2" +version = "0.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "93107647184f6027e3b7dcb2e11034cf95ffa1e3a682c67951963ac69c1c007d" +checksum = "96426c9936fd7a0124915f9185ea1d20aa9445cc9821142f0a73bc9207a2e186" dependencies = [ "serde", ] @@ -3550,18 +3588,9 @@ dependencies = [ [[package]] name = "toml" -version = "0.5.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f4f7f0dd8d50a853a531c426359045b1998f04219d88799810762cd4ad314234" -dependencies = [ - "serde", -] - -[[package]] -name = "toml" -version = "0.7.4" +version = "0.7.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d6135d499e69981f9ff0ef2167955a5333c35e36f6937d382974566b3d5b94ec" +checksum = "c17e963a819c331dcacd7ab957d80bc2b9a9c1e71c804826d2f283dd65306542" dependencies = [ "serde", "serde_spanned", @@ -3571,20 +3600,20 @@ dependencies = [ [[package]] name = "toml_datetime" -version = "0.6.2" +version = "0.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5a76a9312f5ba4c2dec6b9161fdf25d87ad8a09256ccea5a556fef03c706a10f" +checksum = "7cda73e2f1397b1262d6dfdcef8aafae14d1de7748d66822d3bfeeb6d03e5e4b" dependencies = [ "serde", ] [[package]] name = "toml_edit" -version = "0.19.10" +version = "0.19.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2380d56e8670370eee6566b0bfd4265f65b3f432e8c6d85623f728d4fa31f739" +checksum = "c500344a19072298cd05a7224b3c0c629348b78692bf48466c5238656e315a78" dependencies = [ - "indexmap", + "indexmap 2.0.0", "serde", "serde_spanned", "toml_datetime", @@ -3653,7 +3682,7 @@ checksum = "ccdd26cbd674007e649a272da4475fb666d3aa0ad0531da7136db6fab0e5bad1" dependencies = [ "bitflags", "cassowary", - "crossterm", + "crossterm 0.25.0", "unicode-segmentation", "unicode-width", ] diff --git a/cache/Cargo.toml b/cache/Cargo.toml index 5bb01f8e..025308a4 100644 --- a/cache/Cargo.toml +++ b/cache/Cargo.toml @@ -11,5 +11,5 @@ keywords = ["ethereum", "web3", "decompiler", "evm", "crypto"] clap-verbosity-flag = "1.0.0" clap = { version = "3.1.18", features = ["derive"] } serde = { version = "1.0", features = ["derive"] } -toml = { version = "0.5.9" } +toml = { version = "0.7.6" } bincode = "1.3.3" diff --git a/common/Cargo.toml b/common/Cargo.toml index e2f7b00f..b9a994c6 100644 --- a/common/Cargo.toml +++ b/common/Cargo.toml @@ -14,7 +14,7 @@ clap-verbosity-flag = "1.0.0" colored = "2" crossbeam-channel = "0.5.7" ethers = "2.0.4" -fancy-regex = "0.10.0" +fancy-regex = "0.11.0" heimdall-cache = {path = "./../cache"} indicatif = "0.17.0" lazy_static = "1.4.0" diff --git a/config/Cargo.toml b/config/Cargo.toml index 56298041..20051190 100644 --- a/config/Cargo.toml +++ b/config/Cargo.toml @@ -12,4 +12,4 @@ heimdall-common = { path = "./../common" } clap-verbosity-flag = "1.0.0" clap = { version = "3.1.18", features = ["derive"] } serde = { version = "1.0", features = ["derive"] } -toml = { version = "0.5.9" } +toml = { version = "0.7.6" } diff --git a/heimdall/Cargo.toml b/heimdall/Cargo.toml index 20d1ffe5..d8bebf94 100644 --- a/heimdall/Cargo.toml +++ b/heimdall/Cargo.toml @@ -12,10 +12,10 @@ backtrace = "0.3" clap = {version = "3.1.18", features = ["derive"]} clap-verbosity-flag = "1.0.0" colored = "2" -crossterm = "0.25" +crossterm = "0.26.1" dot = "0.1.4" ethers = "2.0.4" -fancy-regex = "0.10.0" +fancy-regex = "0.11.0" heimdall-cache = {path = "./../cache"} heimdall-common = {path = "./../common"} heimdall-config = {path = "./../config"}