Skip to content

Commit

Permalink
🔧 fix: dont crash during signature resolution selection (#116)
Browse files Browse the repository at this point in the history
  • Loading branch information
Jon-Becker authored Jul 12, 2023
2 parents c810e32 + b02aa1c commit 0e15ed2
Show file tree
Hide file tree
Showing 9 changed files with 145 additions and 61 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,5 @@ coverage.xml
false
false/*
*/false

*.svg
95 changes: 62 additions & 33 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[workspace]
members = ["common", "config", "heimdall"]
version = "0.4.7"
version = "0.4.8"
4 changes: 2 additions & 2 deletions cache/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "heimdall-cache"
version = "0.4.7"
version = "0.4.8"
edition = "2021"
license = "MIT"
readme = "README.md"
Expand All @@ -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"
4 changes: 2 additions & 2 deletions common/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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"
Expand Down
74 changes: 68 additions & 6 deletions common/src/testing/benchmarks.rs
Original file line number Diff line number Diff line change
@@ -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);
Expand All @@ -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);
Expand All @@ -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
}
4 changes: 2 additions & 2 deletions config/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "heimdall-config"
version = "0.4.7"
version = "0.4.8"
edition = "2021"
license = "MIT"
readme = "README.md"
Expand All @@ -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" }
Loading

0 comments on commit 0e15ed2

Please sign in to comment.