Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
5ce9b3b
added WIP changes
Nov 25, 2024
407e6bd
Refactoring: Fully Migrate to Alloy (#48)
Uniblake Jan 13, 2025
cca09c0
bumped depedencies and formatting
ritzdorf Jan 13, 2025
0360e11
Calling forge inspect with "--json"
ritzdorf Jan 13, 2025
ee8a251
make clippy happy
ritzdorf Jan 13, 2025
e5b5a0a
support more than mainnet
ritzdorf Jan 13, 2025
7f5d60a
refactor: change etherscan url
markus-cs Jan 15, 2025
bfbcde9
Revert "refactor: change etherscan url"
markus-cs Jan 16, 2025
f1069e5
Some minor Refactoring (#50)
ritzdorf Jan 30, 2025
fd93f7e
disabled storage proof check and fixed argument handling
Mar 19, 2025
eaa83ad
fmt + clippy
Mar 19, 2025
19de193
made version in solc input optional
Mar 19, 2025
2856698
fmt + clippy
Mar 19, 2025
b354e51
temporarily enable debugging for failing ci tests
Mar 20, 2025
0d49f56
fmt + clippy
Mar 20, 2025
4c8ac6c
undo previous step
Mar 20, 2025
8ba5621
temporarily log blockscout requests
Mar 20, 2025
634a63b
temporarily log blockscout responses
Mar 20, 2025
b3ca44f
fmt + clippy
Mar 20, 2025
cad853e
revert
Mar 20, 2025
fe0b984
updated blockscout cache
Mar 20, 2025
e17502e
updated web3 test case to work with cache
Mar 20, 2025
689f9e4
updated cache
Mar 20, 2025
94232e6
try failing test in verbose mode
Mar 20, 2025
6a3a4e8
updated frax repo
Mar 21, 2025
6f3d571
provide canonical URL for deployment_validation repo
Jan 29, 2025
8a57dfc
added some hotfixes
Mar 18, 2025
4232ad2
some more fixes
Mar 19, 2025
aa61f2e
fixed remaining merge conflict
Mar 21, 2025
e9e51a0
updated package version
Mar 21, 2025
d22f44a
fixed merge bug
Mar 21, 2025
c7529ab
fixed default config path handling
Mar 21, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5,685 changes: 3,700 additions & 1,985 deletions Cargo.lock

Large diffs are not rendered by default.

84 changes: 46 additions & 38 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "dv"
version = "0.9.0"
version = "0.9.1"
edition = "2021"

[[bin]]
Expand All @@ -22,48 +22,56 @@ path = "src/cached_proxy.rs"
[lib]
name = "dvf_libs"
path = "lib/lib.rs"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
tracing = "0.1.34"
tracing-subscriber = { version = "0.3.11", default-features = true, features = ["env-filter", "fmt"]}
reqwest = { version = "0.11", features = ["json", "blocking"] }
tokio = { version = "1", features = ["full"] }
serde = { version = "1.0.144", features = ["derive"] }
serde_json = "1.0.85"
substring = "1.4.5"
clap = { version = "3.1.6", features = ["derive"]}
colored = "1.0.0"
actix-web = "4.9.0"
alloy = { version = "0.9.2", features = ["full"] }
alloy-chains = { version = "0.1.55", features = ["serde"] }
alloy-dyn-abi = { version = "0.8.19", features = ["eip712"] }
alloy-json-abi = "0.8.19"
alloy-node-bindings = "0.9.2"
alloy-rpc-types = "0.9.2"
alloy-rpc-types-trace = "0.9.2"
alloy-signer = { version = "0.9.2", features = ["eip712"] }
alloy-signer-ledger = "0.9.2"
alloy-signer-local = "0.9.2"
async-trait = "0.1.85"
bigint = "4"
bytes = "1.9.0"
clap = { version = "4.5.26", features = ["derive", "cargo"] }
colored = "3.0.0"
console = "0.15.10"
dirs-next = "2.0.0"
dotenv = "0.15.0"
foundry-block-explorers = "0.9.0"
foundry-compilers = "0.12.9"
foundry-compilers-core = "0.12.9"
hex = "0.4"
indicatif = "0.17.9"
prettytable-rs = "0.10.0"
rand = "0.8.5"
regex = "1"
bigint = "1"
tiny-keccak = { version = "2.0.0", features = ["sha3", "keccak"] }
hex = "0.4"
ethers = { version = "2.0.8", features = ["solc"] }
ethers-contract = "2.0.8"
ethers-core = { version = "2.0.8" }
ethers-etherscan = { version = "2.0.8" }
ethers-providers = "2.0.8"
ethers-signers = {version = "2.0.8", features = ["ledger", "yubi", "yubihsm"]}
ethers-solc = "2.0.8"
semver = { version = "1.0.17", features = ["serde"] }
toml = "0.7.4"
dirs-next = "2.0.0"
zip = "0.6.6"
tempfile = "3.6.0"
bytes = "1.4.0"
async-trait = "0.1.69"
thiserror = "1.0.40"
sha3 = "0.10.8"
reqwest = { version = "0.12", features = ["json", "blocking"] }
reth-trie = { git = "https://github.com/paradigmxyz/reth", tag = "v1.1.5"}
ruint = "1.12.4"
rustc-hex = "2.1.0"
indicatif = "0.17.6"
console = "0.15.7"
actix-web = "4.7.0"
scanf = "1.2.1"
dotenv = "0.15.0"
time = "0.3.36"
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.15.0"
thiserror = "2.0.11"
time = "0.3.37"
tiny-keccak = { version = "2.0.2", features = ["sha3", "keccak"] }
tokio = { version = "1", features = ["full"] }
toml = "0.8.19"
tracing = "0.1.41"
tracing-subscriber = { version = "0.3.19", default-features = true, features = ["env-filter", "fmt"] }
zip = "2.2.2"

[dev-dependencies]
assert_cmd = "2.0.12"
env_logger = "0.11.5"
assert_cmd = "2.0.16"
env_logger = "0.11.6"
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ NodeJS is only required if you are running `dv` in a Hardhat project. Foundry is
To install `dv`, clone this repository and build:

```
git clone TODO: add repo URI
git clone https://github.com/ChainSecurity/deployment_validation
cd deployment-validation
cargo install --path .
```
Expand All @@ -117,7 +117,7 @@ Depending on your system's configuration, this command might have to be adapted.
To run `dv` with the pre-configured Docker image, clone this repository and run:

```
git clone TODO: add repo URI
git clone https://github.com/ChainSecurity/deployment_validation
cd deployment-validation
docker build -t dv .
```
Expand Down
2 changes: 1 addition & 1 deletion examples/frxETH-public
Submodule frxETH-public updated 1 files
+3 −0 foundry.toml
64 changes: 40 additions & 24 deletions lib/bytecode_verification/compare_bytecodes.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use ethers::abi;
use ethers::solc::artifacts::BytecodeHash;
use alloy::dyn_abi::JsonAbiExt;
use foundry_compilers::artifacts::BytecodeHash;
use tracing::{debug, info};

use crate::bytecode_verification::parse_json::ProjectInfo;
Expand Down Expand Up @@ -166,7 +166,10 @@ impl CompareBytecode {
if factory_mode {
let mut other_bytecodes: Vec<Vec<u8>> = vec![];
for other_bytecode in &project_info.other_bytecodes {
other_bytecodes.push(hex::decode(other_bytecode.trim_start_matches("0x")).unwrap());
// TODO: bytecode may contain placehodlers for linked libraries (e.g., "__$a8edeab004e053fbdc8344e3d53a225696$__"). handle this
if let Ok(hex_bytecode) = hex::decode(other_bytecode.trim_start_matches("0x")) {
other_bytecodes.push(hex_bytecode);
}
}
ignore_subcontracts_metadata(
&other_bytecodes,
Expand Down Expand Up @@ -246,7 +249,9 @@ impl CompareInitCode {
if factory_mode {
let mut other_bytecodes: Vec<Vec<u8>> = vec![];
for other_bytecode in &project_info.other_bytecodes {
other_bytecodes.push(hex::decode(other_bytecode.trim_start_matches("0x")).unwrap());
if let Ok(hex_bytecode) = hex::decode(other_bytecode.trim_start_matches("0x")) {
other_bytecodes.push(hex_bytecode);
}
}
ignore_subcontracts_metadata(
&other_bytecodes,
Expand All @@ -263,28 +268,28 @@ impl CompareInitCode {
return Self::no_match();
}

if project_info.constructor_args.is_empty() {
if project_info.constructor.is_none() {
return CompareInitCode { matched: true };
}

// decode constructor arguments
let argument_types: Vec<_> = project_info
.constructor_args
.iter()
.map(|arg| arg.kind.clone())
.collect();
let decoded_args = abi::decode(&argument_types, &init_bytecode[compiled_init_code.len()..])
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.");

if decoded_args.len() != project_info.constructor_args.len() {
return Self::no_match();
}

for (arg, value) in project_info.constructor_args.iter_mut().zip(decoded_args) {
let encoded_value = abi::encode_packed(&[value]).unwrap();
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)
});

arg.value = formatted_value;
arg.type_string = sol_type.sol_type_name().to_string()
}

// Byte offset -> Relevant
Expand All @@ -295,7 +300,7 @@ impl CompareInitCode {
#[cfg(test)]
mod tests {
use crate::types::ConstructorArg;
use ethers::abi::ParamType;
use alloy::json_abi::{Constructor, Param, StateMutability};
use semver::Version;
use std::collections::HashMap;

Expand All @@ -314,6 +319,7 @@ mod tests {
cbor_metadata: None,
immutables: Vec::<Immutable>::new(),
constructor_args: Vec::<ConstructorArg>::new(),
constructor: None,
events: vec![],
other_bytecodes: vec![],
types: HashMap::new(),
Expand All @@ -337,6 +343,7 @@ mod tests {
cbor_metadata: None,
immutables: Vec::<Immutable>::new(),
constructor_args: Vec::<ConstructorArg>::new(),
constructor: None,
events: vec![],
other_bytecodes: vec![],
types: HashMap::new(),
Expand All @@ -362,18 +369,26 @@ mod tests {
let constructor_args = vec![
ConstructorArg {
name: "arg1".to_string(),
kind: ParamType::Address,
value: "value1".to_string(),
type_string: "type1".to_string(),
value: "1".to_string(),
type_string: "address".to_string(),
},
ConstructorArg {
name: "arg1".to_string(),
kind: ParamType::Address,
value: "value1".to_string(),
type_string: "type1".to_string(),
name: "arg2".to_string(),
value: "2".to_string(),
type_string: "address".to_string(),
},
];

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

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

let mut p = ProjectInfo {
compiled_bytecode,
init_code: compiled_init_code,
Expand All @@ -383,6 +398,7 @@ mod tests {
cbor_metadata: None,
immutables: vec![],
constructor_args,
constructor: Some(constructor),
events: vec![],
other_bytecodes: vec![],
types: HashMap::new(),
Expand Down
Loading
Loading