Skip to content

Commit

Permalink
chore(deps): alloy 0.3.3 (#498)
Browse files Browse the repository at this point in the history
* alloy 0.3.3

* bump Rust to 1.79

* fix Trigger CI tests

* chore: add `rust-toolchain.toml`

* wip

* wip

* wip

* wip

---------

Co-authored-by: Jon-Becker <jonathan@jbecker.dev>
  • Loading branch information
fala13 and Jon-Becker authored Sep 17, 2024
1 parent 8693cf4 commit 5517ba7
Show file tree
Hide file tree
Showing 41 changed files with 449 additions and 349 deletions.
399 changes: 242 additions & 157 deletions Cargo.lock

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ debug = true
version = "0.8.4"
edition = "2021"
license = "MIT"
rust-version = "1.75"
rust-version = "1.79"
homepage = "https://heimdall.rs"
repository = "https://github.com/Jon-Becker/heimdall-rs"
keywords = ["ethereum", "web3", "decompiler", "evm", "crypto"]
Expand Down
17 changes: 10 additions & 7 deletions crates/cache/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,8 @@ pub fn delete_cache(key: &str) -> Result<(), Error> {
#[allow(deprecated)]
pub fn read_cache<T>(key: &str) -> Result<Option<T>, Error>
where
T: 'static + DeserializeOwned, {
T: 'static + DeserializeOwned,
{
let home = home_dir().ok_or(Error::Generic(
"failed to get home directory. does your os support `std::env::home_dir()`?".to_string(),
))?;
Expand All @@ -238,8 +239,8 @@ where
.map_err(|e| Error::Generic(format!("failed to deserialize cache object: {:?}", e)))?;

// check if the cache has expired, if so, delete it and return None
if cache.expiry <
std::time::SystemTime::now()
if cache.expiry
< std::time::SystemTime::now()
.duration_since(std::time::UNIX_EPOCH)
.map_err(|e| Error::Generic(format!("failed to get current time: {:?}", e)))?
.as_secs()
Expand All @@ -266,7 +267,8 @@ where
#[allow(deprecated)]
pub fn store_cache<T>(key: &str, value: T, expiry: Option<u64>) -> Result<(), Error>
where
T: Serialize, {
T: Serialize,
{
let home = home_dir().ok_or(Error::Generic(
"failed to get home directory. does your os support `std::env::home_dir()`?".to_string(),
))?;
Expand All @@ -278,8 +280,8 @@ where
std::time::SystemTime::now()
.duration_since(std::time::UNIX_EPOCH)
.map_err(|e| Error::Generic(format!("failed to get current time: {:?}", e)))?
.as_secs() +
60 * 60 * 24 * 90,
.as_secs()
+ 60 * 60 * 24 * 90,
);

let cache = Cache { value, expiry };
Expand All @@ -304,7 +306,8 @@ pub async fn with_cache<T, F, Fut>(key: &str, func: F) -> eyre::Result<T>
where
T: 'static + Serialize + DeserializeOwned + Send + Sync,
F: FnOnce() -> Fut + Send,
Fut: std::future::Future<Output = Result<T, eyre::Report>> + Send, {
Fut: std::future::Future<Output = Result<T, eyre::Report>> + Send,
{
// Try to read from cache
match read_cache::<T>(key) {
Ok(Some(cached_value)) => {
Expand Down
2 changes: 1 addition & 1 deletion crates/cfg/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ eyre = "0.6.12"
futures = "0.3.30"
lazy_static = "1.4.0"
petgraph = "0.6.2"
alloy = { version = "0.1.3", features = ["full", "rpc-types-debug", "rpc-types-trace"] }
alloy = { version = "0.3.3", features = ["full", "rpc-types-debug", "rpc-types-trace"] }

heimdall-disassembler.workspace = true
heimdall-vm.workspace = true
4 changes: 2 additions & 2 deletions crates/cfg/src/core/graph.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@ pub fn build_cfg(
.first()
.ok_or_eyre("failed to get first operation")?
.last_instruction
.opcode ==
JUMPDEST,
.opcode
== JUMPDEST,
)?;
}

Expand Down
4 changes: 2 additions & 2 deletions crates/cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ thiserror = "1.0.50"
tracing = "0.1.40"
tracing-subscriber = "0.3.18"
eyre = "0.6.12"
alloy-json-abi = "0.7.6"
alloy = { version = "0.1.3", features = ["full", "rpc-types-debug", "rpc-types-trace"] }
alloy-json-abi = "0.8.3"
alloy = { version = "0.3.3", features = ["full", "rpc-types-debug", "rpc-types-trace"] }
async-trait = "0.1.51"

[[bin]]
Expand Down
6 changes: 3 additions & 3 deletions crates/common/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,10 @@ backoff = { version = "0.4.0", features = ["tokio"] }
thiserror = "1.0.50"
tracing = "0.1.40"
eyre = "0.6.12"
alloy-json-abi = "0.7.6"
alloy-json-abi = "0.8.3"
futures = "0.3.17"
alloy = { version = "0.1.3", features = ["full", "rpc-types-debug", "rpc-types-trace"] }
alloy = { version = "0.3.3", features = ["full", "rpc-types-debug", "rpc-types-trace"] }
bytes = "1.6.1"
alloy-dyn-abi = "0.7.7"
alloy-dyn-abi = "0.8.3"
tokio-retry = "0.3.0"
hashbrown = "0.14.5"
10 changes: 5 additions & 5 deletions crates/common/src/ether/signatures.rs
Original file line number Diff line number Diff line change
Expand Up @@ -286,18 +286,18 @@ pub fn score_signature(signature: &str, num_words: Option<usize>) -> u32 {

// prioritize signatures with less numbers
score -= (signature.split('(').next().unwrap_or("").matches(|c: char| c.is_numeric()).count()
as u32) *
3;
as u32)
* 3;

// prioritize signatures with parameters
let num_params = signature.matches(',').count() + 1;
score += num_params as u32 * 10;

// count the number of parameters in the signature, if enabled
if let Some(num_words) = num_words {
let num_dyn_params = signature.matches("bytes").count() +
signature.matches("string").count() +
signature.matches('[').count();
let num_dyn_params = signature.matches("bytes").count()
+ signature.matches("string").count()
+ signature.matches('[').count();
let num_static_params = num_params - num_dyn_params;

// reduce the score if the signature has less static parameters than there are words in the
Expand Down
28 changes: 14 additions & 14 deletions crates/common/src/ether/tokenize.rs
Original file line number Diff line number Diff line change
Expand Up @@ -130,17 +130,17 @@ pub fn tokenize(s: &str) -> Token {
let mut op = ch.to_string();
iter.next();
if let Some(&next_ch) = iter.peek() {
if (ch == '=' && (next_ch == '=' || next_ch == '>')) ||
(ch == '&' && next_ch == '&') ||
(ch == '|' && next_ch == '|') ||
(ch == '<' && next_ch == '=') ||
(ch == '>' && next_ch == '=') ||
(ch == '!' && next_ch == '=') ||
(ch == '+' && next_ch == '+') ||
(ch == '-' && next_ch == '-') ||
(ch == '*' && next_ch == '*') ||
(ch == '>' && next_ch == '>') ||
(ch == '<' && next_ch == '<')
if (ch == '=' && (next_ch == '=' || next_ch == '>'))
|| (ch == '&' && next_ch == '&')
|| (ch == '|' && next_ch == '|')
|| (ch == '<' && next_ch == '=')
|| (ch == '>' && next_ch == '=')
|| (ch == '!' && next_ch == '=')
|| (ch == '+' && next_ch == '+')
|| (ch == '-' && next_ch == '-')
|| (ch == '*' && next_ch == '*')
|| (ch == '>' && next_ch == '>')
|| (ch == '<' && next_ch == '<')
{
op.push(next_ch);
iter.next();
Expand Down Expand Up @@ -188,9 +188,9 @@ fn parse_literal(iter: &mut std::iter::Peekable<std::str::Chars>) -> String {
}

// literal validation
if literal.starts_with("0x") &&
literal.len() > 2 &&
literal[2..].chars().all(|c| c.is_ascii_hexdigit())
if literal.starts_with("0x")
&& literal.len() > 2
&& literal[2..].chars().all(|c| c.is_ascii_hexdigit())
{
return literal;
}
Expand Down
8 changes: 4 additions & 4 deletions crates/common/src/ether/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use alloy_json_abi::Param;
use serde_json::{Map, Number, Value};
use std::collections::VecDeque;

use crate::utils::{hex::ToLowerHex, strings::find_balanced_encapsulator};
use crate::utils::strings::find_balanced_encapsulator;
use eyre::Result;

#[derive(Debug, Clone, PartialEq)]
Expand Down Expand Up @@ -261,14 +261,14 @@ pub trait DynSolValueExt {
impl DynSolValueExt for DynSolValue {
fn serialize(&self) -> Value {
match self {
DynSolValue::Address(addr) => Value::String(addr.to_lower_hex()),
DynSolValue::Address(addr) => Value::String(addr.to_string()),
DynSolValue::Bool(b) => Value::Bool(*b),
DynSolValue::String(s) => Value::String(s.to_owned()),
DynSolValue::Bytes(b) => {
Value::Array(b.iter().map(|b| Value::Number(Number::from(*b))).collect())
}
DynSolValue::Uint(u, _) => Value::String(u.to_lower_hex()),
DynSolValue::Int(i, _) => Value::String(i.to_lower_hex()),
DynSolValue::Uint(u, _) => Value::String(u.to_string()),
DynSolValue::Int(i, _) => Value::String(i.to_string()),
DynSolValue::FixedBytes(b, _) => {
Value::Array(b.iter().map(|b| Value::Number(Number::from(*b))).collect())
}
Expand Down
1 change: 1 addition & 0 deletions crates/common/src/utils/io/logging.rs
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,7 @@ impl TraceFactory {
self.add("call", parent_index, instruction, vec![title, returns])
}

#[allow(clippy::too_many_arguments)]
pub fn add_call_with_extra(
&mut self,
parent_index: u32,
Expand Down
8 changes: 4 additions & 4 deletions crates/common/src/utils/io/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ pub fn display(inputs: Vec<DynSolValue>, prefix: &str) -> Vec<String> {
for input in inputs {
match input {
DynSolValue::Address(val) => {
output.push(format!("{prefix}{} {}", "address".blue(), val.to_lower_hex()))
output.push(format!("{prefix}{} {}", "address".blue(), val))
}
DynSolValue::Int(val, _) => {
output.push(format!("{prefix}{} {}", "int ".blue(), val))
Expand All @@ -28,7 +28,7 @@ pub fn display(inputs: Vec<DynSolValue>, prefix: &str) -> Vec<String> {
}
}
DynSolValue::FixedBytes(val, _) => {
output.push(format!("{prefix}{} {}", "bytes ".blue(), val.to_lower_hex()));
output.push(format!("{prefix}{} {}", "bytes ".blue(), val));
}
DynSolValue::Bytes(val) => {
// chunk val into 32-byte chunks
Expand Down Expand Up @@ -85,14 +85,14 @@ pub trait Parameterize {
impl Parameterize for DynSolValue {
fn parameterize(&self) -> String {
match self {
DynSolValue::Address(val) => format!("address: {}", val.to_lower_hex()),
DynSolValue::Address(val) => format!("address: {}", val),
DynSolValue::Int(val, _) => format!("int: {}", val),
DynSolValue::Uint(val, _) => format!("uint: {}", val),
DynSolValue::String(val) => format!("string: {}", val),
DynSolValue::Bool(val) => format!("bool: {}", val),
DynSolValue::Bytes(val) => format!("bytes: 0x{}", val.to_lower_hex()),
DynSolValue::FixedBytes(val, size) => {
format!("bytes{}: 0x{}", size, &val.to_lower_hex()[(64 - size * 2) + 2..])
format!("bytes{}: 0x{}", size, &val.to_string()[(64 - size * 2) + 2..])
}
DynSolValue::Array(val) => {
// get type of array
Expand Down
4 changes: 2 additions & 2 deletions crates/common/src/utils/strings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -330,8 +330,8 @@ pub fn tokenize(s: &str) -> Vec<String> {
// Check if current character and last character form a compound operator (like "==",
// ">=", "&&", "||")
if let Some(last) = last_char {
if compound_operator_first_chars.contains(&last) &&
(c == '=' || c == '&' || c == '|')
if compound_operator_first_chars.contains(&last)
&& (c == '=' || c == '&' || c == '|')
{
// Remove the last character as a single token
tokens.pop();
Expand Down
3 changes: 2 additions & 1 deletion crates/common/src/utils/sync.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/// Take in a non-async function and await it. This functions should be blocking.
pub fn blocking_await<F, T>(f: F) -> T
where
F: FnOnce() -> T, {
F: FnOnce() -> T,
{
tokio::task::block_in_place(f)
}
42 changes: 21 additions & 21 deletions crates/common/src/utils/version.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,46 +93,46 @@ impl Display for Version {
impl Version {
/// greater than
pub fn gt(&self, other: &Version) -> bool {
self.major > other.major ||
(self.major == other.major && self.minor > other.minor) ||
(self.major == other.major && self.minor == other.minor && self.patch > other.patch)
self.major > other.major
|| (self.major == other.major && self.minor > other.minor)
|| (self.major == other.major && self.minor == other.minor && self.patch > other.patch)
}

/// greater than or equal to
pub fn gte(&self, other: &Version) -> bool {
self.major > other.major ||
(self.major == other.major && self.minor > other.minor) ||
(self.major == other.major && self.minor == other.minor && self.patch >= other.patch)
self.major > other.major
|| (self.major == other.major && self.minor > other.minor)
|| (self.major == other.major && self.minor == other.minor && self.patch >= other.patch)
}

/// less than
pub fn lt(&self, other: &Version) -> bool {
self.major < other.major ||
(self.major == other.major && self.minor < other.minor) ||
(self.major == other.major && self.minor == other.minor && self.patch < other.patch)
self.major < other.major
|| (self.major == other.major && self.minor < other.minor)
|| (self.major == other.major && self.minor == other.minor && self.patch < other.patch)
}

/// less than or equal to
pub fn lte(&self, other: &Version) -> bool {
self.major < other.major ||
(self.major == other.major && self.minor < other.minor) ||
(self.major == other.major && self.minor == other.minor && self.patch <= other.patch)
self.major < other.major
|| (self.major == other.major && self.minor < other.minor)
|| (self.major == other.major && self.minor == other.minor && self.patch <= other.patch)
}

/// equal to
#[allow(clippy::should_implement_trait)]
pub fn eq(&self, other: &Version) -> bool {
self.major == other.major &&
self.minor == other.minor &&
self.patch == other.patch &&
self.channel == other.channel
self.major == other.major
&& self.minor == other.minor
&& self.patch == other.patch
&& self.channel == other.channel
}

/// not equal to
pub fn ne(&self, other: &Version) -> bool {
self.major != other.major ||
self.minor != other.minor ||
self.patch != other.patch ||
self.channel != other.channel
self.major != other.major
|| self.minor != other.minor
|| self.patch != other.patch
|| self.channel != other.channel
}

/// if the version is a nightly version
Expand Down
6 changes: 3 additions & 3 deletions crates/decode/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ derive_builder = "0.12.0"
tracing = "0.1.40"
eyre = "0.6.12"
heimdall-vm.workspace = true
alloy-dyn-abi = "0.7.7"
alloy-json-abi = "0.7.6"
alloy = { version = "0.1.3", features = ["full", "rpc-types-debug", "rpc-types-trace"] }
alloy-dyn-abi = "0.8.3"
alloy-json-abi = "0.8.3"
alloy = { version = "0.3.3", features = ["full", "rpc-types-debug", "rpc-types-trace"] }
serde_json = "1.0"
hashbrown = "0.14.5"
Loading

0 comments on commit 5517ba7

Please sign in to comment.