Skip to content

Commit

Permalink
bumped depedencies and formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
Hubert Ritzdorf committed Jan 13, 2025
1 parent 407e6bd commit cca09c0
Show file tree
Hide file tree
Showing 18 changed files with 2,346 additions and 2,043 deletions.
4,027 changes: 2,158 additions & 1,869 deletions Cargo.lock

Large diffs are not rendered by default.

54 changes: 27 additions & 27 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,53 +25,53 @@ path = "lib/lib.rs"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
actix-web = "4.7.0"
actix-web = "4.9.0"
alloy = { version = "0.6.4", features = ["full"] }
alloy-chains = { version = "0.1.47", features = ["serde"] }
alloy-dyn-abi = { version = "0.8.12", features = ["eip712"] }
alloy-json-abi = "0.8.12"
alloy-node-bindings = "0.7.0"
alloy-chains = { version = "0.1.55", features = ["serde"] }
alloy-dyn-abi = { version = "0.8.18", features = ["eip712"] }
alloy-json-abi = "0.8.18"
alloy-node-bindings = "0.7.3"
alloy-rpc-types = "0.6.4"
alloy-rpc-types-trace = "0.6.4"
alloy-signer = { version = "0.6.4", features = ["eip712"] }
alloy-signer-ledger = "0.6.4"
alloy-signer-local = "0.6.4"
async-trait = "0.1.69"
async-trait = "0.1.85"
bigint = "1"
bytes = "1.4.0"
clap = { version = "3.1.6", features = ["derive"] }
colored = "1.0.0"
console = "0.15.7"
bytes = "1.9.0"
clap = { version = "3.2.25", features = ["derive"] }
colored = "1.9.4"
console = "0.15.10"
dirs-next = "2.0.0"
dotenv = "0.15.0"
foundry-block-explorers = "0.9.0"
foundry-compilers = "0.11.6"
foundry-compilers-core = "0.12.3"
foundry-compilers-core = "0.12.9"
hex = "0.4"
indicatif = "0.17.6"
indicatif = "0.17.9"
prettytable-rs = "0.10.0"
rand = "0.8.5"
regex = "1"
reqwest = { version = "0.11", features = ["json", "blocking"] }
reth-trie = { git = "https://github.com/paradigmxyz/reth", tag = "v1.1.2"}
ruint = "1.12.3"
reth-trie = { git = "https://github.com/paradigmxyz/reth", tag = "v1.1.5"}
ruint = "1.12.4"
rustc-hex = "2.1.0"
scanf = "1.2.1"
semver = { version = "1.0.17", features = ["serde"] }
serde = { version = "1.0.144", features = ["derive"] }
serde_json = "1.0.85"
scanf = "1.2.3"
semver = { version = "1.0.24", features = ["serde"] }
serde = { version = "1.0.217", features = ["derive"] }
serde_json = "1.0.135"
sha3 = "0.10.8"
substring = "1.4.5"
tempfile = "3.6.0"
thiserror = "1.0.40"
time = "0.3.36"
tiny-keccak = { version = "2.0.0", features = ["sha3", "keccak"] }
tempfile = "3.15.0"
thiserror = "1.0.69"
time = "0.3.37"
tiny-keccak = { version = "2.0.2", features = ["sha3", "keccak"] }
tokio = { version = "1", features = ["full"] }
toml = "0.7.4"
tracing = "0.1.34"
tracing-subscriber = { version = "0.3.11", default-features = true, features = ["env-filter", "fmt"] }
toml = "0.7.8"
tracing = "0.1.41"
tracing-subscriber = { version = "0.3.19", default-features = true, features = ["env-filter", "fmt"] }
zip = "0.6.6"

[dev-dependencies]
assert_cmd = "2.0.12"
env_logger = "0.11.5"
assert_cmd = "2.0.16"
env_logger = "0.11.6"
17 changes: 12 additions & 5 deletions lib/bytecode_verification/compare_bytecodes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -268,13 +268,20 @@ impl CompareInitCode {
}

// decode constructor arguments
let decoded_args = project_info.constructor.as_ref().unwrap().abi_decode_input(&init_bytecode[compiled_init_code.len()..], true).expect("Unable to decode the constructor arguments.");
let decoded_args = project_info
.constructor
.as_ref()
.unwrap()
.abi_decode_input(&init_bytecode[compiled_init_code.len()..], true)
.expect("Unable to decode the constructor arguments.");

for (arg, value) in project_info.constructor_args.iter_mut().zip(decoded_args) {
let encoded_value = value.abi_encode_packed();
let formatted_value = format!("0x{}", hex::encode(&encoded_value));

let sol_type = value.as_type().unwrap_or_else(|| panic!("Unable to find constructor argument type for {}", arg.name));

let sol_type = value.as_type().unwrap_or_else(|| {
panic!("Unable to find constructor argument type for {}", arg.name)
});

arg.value = formatted_value;
arg.type_string = sol_type.sol_type_name().to_string()
Expand Down Expand Up @@ -369,12 +376,12 @@ mod tests {

let constructor_inputs: Vec<Param> = vec![
Param::parse("address arg1").unwrap(),
Param::parse("address arg2").unwrap()
Param::parse("address arg2").unwrap(),
];

let constructor = Constructor {
inputs: constructor_inputs,
state_mutability: StateMutability::NonPayable
state_mutability: StateMutability::NonPayable,
};

let mut p = ProjectInfo {
Expand Down
49 changes: 30 additions & 19 deletions lib/bytecode_verification/parse_json.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ use std::path::PathBuf;

use alloy::json_abi::Constructor;
use clap::ValueEnum;
use serde_json::Value;
use tempfile::Builder;
use semver::Version;
use tempfile::TempDir;
use serde_json::Value;
use std::path::Path;
use std::process::Command;
use tempfile::Builder;
use tempfile::TempDir;
use tracing::{debug, info};

use crate::bytecode_verification::types::Types;
Expand All @@ -22,21 +22,16 @@ use crate::types::Immutable;
use colored::Colorize;
use std::str::FromStr;

use foundry_compilers::CompilerOutput;
use foundry_compilers::buildinfo::BuildInfo as BInfo;
use alloy::json_abi::Event;
use alloy::primitives::U256;
use foundry_compilers::artifacts::Error as CompilerError;
use foundry_compilers::artifacts::{
BytecodeHash,
BytecodeObject,
Contract as ContractArt,
DeployedBytecode,
NodeType,
Node as EAstNode,
SourceFile
BytecodeHash, BytecodeObject, Contract as ContractArt, DeployedBytecode, Node as EAstNode,
NodeType, SourceFile,
};
use foundry_compilers::buildinfo::BuildInfo as BInfo;
use foundry_compilers::solc::SolcVersionedInput;
use alloy::json_abi::Event;
use alloy::primitives::U256;
use foundry_compilers::CompilerOutput;

type BuildInfo = BInfo<SolcVersionedInput, CompilerOutput<CompilerError>>;

Expand Down Expand Up @@ -1397,9 +1392,13 @@ impl ProjectInfo {
Ok(read_dir) => {
for build_info_file in read_dir.flatten() {
let bi: BuildInfo = BuildInfo::read(&build_info_file.path())?;
if bi.output.contracts.values().flatten().any(|(name, _)| {
name == contract_name
}) {
if bi
.output
.contracts
.values()
.flatten()
.any(|(name, _)| name == contract_name)
{
build_infos.push(bi);
}
}
Expand Down Expand Up @@ -1567,8 +1566,20 @@ impl ProjectInfo {
compiled_bytecode: compiled_bytecode_str,
init_code: init_code_str,
compiler_version: build_info.solc_version.clone(),
optimization_enabled: build_info.input.input.settings.optimizer.enabled.unwrap_or(false),
optimization_runs: build_info.input.input.settings.optimizer.runs.unwrap_or_default(),
optimization_enabled: build_info
.input
.input
.settings
.optimizer
.enabled
.unwrap_or(false),
optimization_runs: build_info
.input
.input
.settings
.optimizer
.runs
.unwrap_or_default(),
cbor_metadata: build_info
.input
.input
Expand Down
2 changes: 1 addition & 1 deletion lib/bytecode_verification/verify_bytecode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ use std::fs::File;
use std::io::prelude::*;
use std::path::Path;

use colored::Colorize;
use alloy::primitives::Address;
use colored::Colorize;
use prettytable::Table;
use tracing::debug;

Expand Down
74 changes: 28 additions & 46 deletions lib/dvf/abstract_wallet.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
use async_trait::async_trait;

use alloy::signers::{Signer, Error as SignerError};
use alloy::signers::local::{PrivateKeySigner, LocalSignerError};
use alloy_signer_ledger::{LedgerSigner, LedgerError};
use alloy::primitives::{Address, PrimitiveSignature as Signature, B256, ChainId};
use alloy::consensus::SignableTransaction;
use alloy::network::TxSigner;
use alloy::dyn_abi::eip712::TypedData;
use alloy::network::TxSigner;
use alloy::primitives::{Address, ChainId, PrimitiveSignature as Signature, B256};
use alloy::signers::local::{LocalSignerError, PrivateKeySigner};
use alloy::signers::{Error as SignerError, Signer};
use alloy::sol_types::{Eip712Domain, SolStruct};
use alloy_signer_ledger::{LedgerError, LedgerSigner};

use thiserror::Error;

Expand Down Expand Up @@ -55,7 +55,6 @@ pub enum AbstractWallet {
#[cfg_attr(target_arch = "wasm32", async_trait(?Send))]
#[cfg_attr(not(target_arch = "wasm32"), async_trait)]
impl TxSigner<Signature> for AbstractWallet {

fn address(&self) -> Address {
match self {
AbstractWallet::Ledger(ledger) => Signer::address(ledger),
Expand All @@ -67,39 +66,28 @@ impl TxSigner<Signature> for AbstractWallet {
async fn sign_transaction(
&self,
tx: &mut dyn SignableTransaction<Signature>,
) -> Result<Signature, alloy::signers::Error> { //@audit how to turn a typed transaction into a signableTx?
) -> Result<Signature, alloy::signers::Error> {
//@audit how to turn a typed transaction into a signableTx?
match self {
AbstractWallet::Ledger(ledger) => ledger
.sign_transaction(tx)
.await,
AbstractWallet::LocalWallet(localwallet) => localwallet
.sign_transaction(tx)
.await,
AbstractWallet::Ledger(ledger) => ledger.sign_transaction(tx).await,
AbstractWallet::LocalWallet(localwallet) => localwallet.sign_transaction(tx).await,
}
}
}

#[cfg_attr(target_arch = "wasm32", async_trait(?Send))]
#[cfg_attr(not(target_arch = "wasm32"), async_trait)]
impl Signer for AbstractWallet {

async fn sign_hash(&self, _hash: &B256) -> Result<Signature, alloy::signers::Error> {
Err(alloy_signer::Error::UnsupportedOperation(
alloy_signer::UnsupportedSignerOperation::SignHash,
))
}

async fn sign_message(
&self,
message: &[u8],
) -> Result<Signature, alloy::signers::Error> {
async fn sign_message(&self, message: &[u8]) -> Result<Signature, alloy::signers::Error> {
match self {
AbstractWallet::Ledger(ledger) => ledger
.sign_message(message)
.await,
AbstractWallet::LocalWallet(localwallet) => localwallet
.sign_message(message)
.await,
AbstractWallet::Ledger(ledger) => ledger.sign_message(message).await,
AbstractWallet::LocalWallet(localwallet) => localwallet.sign_message(message).await,
}
}

Expand All @@ -110,27 +98,26 @@ impl Signer for AbstractWallet {
domain: &Eip712Domain,
) -> Result<Signature, alloy::signers::Error> {
match self {
AbstractWallet::Ledger(ledger) => ledger
.sign_typed_data(payload, domain)
.await,
// .map_err(AbstractError::from),
AbstractWallet::LocalWallet(localwallet) => localwallet
.sign_typed_data(payload, domain)
.await,
// .map_err(AbstractError::from),
AbstractWallet::Ledger(ledger) => ledger.sign_typed_data(payload, domain).await,
// .map_err(AbstractError::from),
AbstractWallet::LocalWallet(localwallet) => {
localwallet.sign_typed_data(payload, domain).await
}
// .map_err(AbstractError::from),
}
}

#[inline]
async fn sign_dynamic_typed_data(&self, payload: &TypedData) -> Result<Signature, alloy::signers::Error> {
async fn sign_dynamic_typed_data(
&self,
payload: &TypedData,
) -> Result<Signature, alloy::signers::Error> {
match self {
AbstractWallet::Ledger(ledger) => ledger
.sign_dynamic_typed_data(payload)
.await,
AbstractWallet::Ledger(ledger) => ledger.sign_dynamic_typed_data(payload).await,
// .map_err(AbstractError::from),
AbstractWallet::LocalWallet(localwallet) => localwallet
.sign_dynamic_typed_data(payload)
.await,
AbstractWallet::LocalWallet(localwallet) => {
localwallet.sign_dynamic_typed_data(payload).await
}
// .map_err(AbstractError::from),
}
}
Expand All @@ -154,13 +141,8 @@ impl Signer for AbstractWallet {
/// Sets the signer's chain id
fn set_chain_id(&mut self, chain_id: Option<ChainId>) {
match self {
AbstractWallet::Ledger(ledger) => {
ledger.set_chain_id(chain_id)
}
AbstractWallet::LocalWallet(localwallet) => {
localwallet.set_chain_id(chain_id)
}
AbstractWallet::Ledger(ledger) => ledger.set_chain_id(chain_id),
AbstractWallet::LocalWallet(localwallet) => localwallet.set_chain_id(chain_id),
}
}
}

11 changes: 6 additions & 5 deletions lib/dvf/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ use dirs_next::home_dir;
use alloy::primitives::Address;
use alloy_chains::NamedChain;

use alloy::signers::Signer;
use alloy::signers::local::PrivateKeySigner; //LOCALWALLET
use alloy_signer_ledger::{LedgerSigner, HDPath};
use alloy::signers::Signer;
use alloy_signer_ledger::{HDPath, LedgerSigner};

use reqwest::blocking::Client;
use serde::{Deserialize, Serialize};
Expand Down Expand Up @@ -224,9 +224,10 @@ impl DVFConfig {
),
DVFWalletType::Ledger(ledger_config) => {
let rt = tokio::runtime::Runtime::new().unwrap();
AbstractWallet::Ledger(
rt.block_on(LedgerSigner::new(ledger_config.get_hd_path(), Option::Some(chain_id)))?,
)
AbstractWallet::Ledger(rt.block_on(LedgerSigner::new(
ledger_config.get_hd_path(),
Option::Some(chain_id),
))?)
}
};
if temp_wallet.address() != signer.wallet_address {
Expand Down
2 changes: 1 addition & 1 deletion lib/dvf/mod.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
pub mod abstract_wallet;
pub mod config;
pub mod parse;
pub mod registry;
pub mod registry;
Loading

0 comments on commit cca09c0

Please sign in to comment.