Skip to content

Commit

Permalink
forge verify-bytecode (#7319)
Browse files Browse the repository at this point in the history
* verify bytecode boilerplate

* wip(verify-bytecode): fetch creation code and constructor args

* nit: todo comment

* verify-bytecode: integrate build args and compile project

* nits: use env eth_rpc_url

* verify-bytecode: try_match

* createFork

* deploy contract on fork

* verify-bytecode: cmp runtime code

* constructor_args_range in bytecode

* fix: NonceTooHigh issue and append constructor_args to local_bytecode

* pretty print

* verify-bytecode: pinpoint compiler settings match

* verify-bytecode: cross check provided constructor args

* handle revm changes

* rm ethers_core as dep

* nits

* nit: is_runtime param

* remove constructor args range check

* nit

* notify user on args mismatch, use args from etherscan by default.

* fix: handle create2 deployments

* add: checks for code at address and name mismatch

* nits

* add(verify-bytecode): check for bytecode hash config details and notify accordingly

* use cache

* nits

* use verification type enum

* nits

* add(verify-bytecode): `--json` feature

* fmt nits

Co-authored-by: evalir <hi@enriqueortiz.dev>

* control flow nits

* select cache version

* nits and cleanup

* use etherscan compiler version

* smol nits

* nit

* fix(verify-bytecode): integrate alloy provider

---------

Co-authored-by: evalir <hi@enriqueortiz.dev>
  • Loading branch information
yash-atreya and Evalir authored Apr 10, 2024
1 parent d8a1625 commit 43fb17b
Show file tree
Hide file tree
Showing 6 changed files with 661 additions and 3 deletions.
3 changes: 3 additions & 0 deletions Cargo.lock

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

1 change: 1 addition & 0 deletions crates/forge/bin/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ fn main() -> Result<()> {
ForgeSubcommand::Generate(cmd) => match cmd.sub {
GenerateSubcommands::Test(cmd) => cmd.run(),
},
ForgeSubcommand::VerifyBytecode(cmd) => utils::block_on(cmd.run()),
}
}

Expand Down
6 changes: 5 additions & 1 deletion crates/forge/bin/opts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use crate::cmd::{
};
use clap::{Parser, Subcommand, ValueHint};
use forge_script::ScriptArgs;
use forge_verify::{VerifyArgs, VerifyCheckArgs};
use forge_verify::{bytecode::VerifyBytecodeArgs, VerifyArgs, VerifyCheckArgs};
use std::path::PathBuf;

const VERSION_MESSAGE: &str = concat!(
Expand Down Expand Up @@ -154,6 +154,10 @@ pub enum ForgeSubcommand {

/// Generate scaffold files.
Generate(generate::GenerateArgs),

/// Verify the deployed bytecode against its source.
#[clap(visible_alias = "vb")]
VerifyBytecode(VerifyBytecodeArgs),
}

#[cfg(test)]
Expand Down
6 changes: 4 additions & 2 deletions crates/verify/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,12 @@ foundry-config.workspace = true
foundry-cli.workspace = true
foundry-common.workspace = true
foundry-evm.workspace = true

serde_json.workspace = true
hex.workspace = true
alloy-json-abi.workspace = true
alloy-primitives.workspace = true
alloy-rpc-types.workspace = true
revm-primitives.workspace = true
serde.workspace = true
eyre.workspace = true
alloy-provider.workspace = true
Expand All @@ -34,8 +35,9 @@ futures = "0.3"
semver = "1"
regex = { version = "1", default-features = false }
once_cell = "1"
yansi = "0.5"

[dev-dependencies]
tokio = { version = "1", features = ["macros"] }
foundry-test-utils.workspace = true
tempfile = "3"
tempfile = "3"
Loading

0 comments on commit 43fb17b

Please sign in to comment.