Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(coverage): refactor coverage analysis #8025

Merged
merged 1 commit into from
Jun 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 2 additions & 0 deletions Cargo.lock

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

5 changes: 3 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -82,17 +82,17 @@ scrypt.opt-level = 3
[profile.local]
inherits = "dev"
opt-level = 1
debug-assertions = false
strip = "debuginfo"
panic = "abort"
codegen-units = 16

# Like release, but with full debug symbols and with stack unwinds. Useful for e.g. `perf`.
[profile.debug-fast]
inherits = "release"
inherits = "local"
debug = true
strip = "none"
panic = "unwind"
incremental = false

# Optimized release profile.
[profile.release]
Expand Down Expand Up @@ -216,6 +216,7 @@ num-format = "0.4.4"
yansi = { version = "1.0", features = ["detect-tty", "detect-env"] }
tempfile = "3.10"
tokio = "1"
rayon = "1"

axum = "0.7"
hyper = "1.0"
Expand Down
21 changes: 17 additions & 4 deletions crates/anvil/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,11 @@ path = "src/anvil.rs"
required-features = ["cli"]

[build-dependencies]
vergen = { workspace = true, default-features = false, features = ["build", "git", "gitcl"] }
vergen = { workspace = true, default-features = false, features = [
"build",
"git",
"gitcl",
] }

[dependencies]
# foundry internal
Expand All @@ -31,7 +35,12 @@ foundry-evm.workspace = true
# evm support
bytes = "1.4.0"
k256.workspace = true
revm = { workspace = true, features = ["std", "serde", "memory_limit", "c-kzg"] }
revm = { workspace = true, features = [
"std",
"serde",
"memory_limit",
"c-kzg",
] }
alloy-primitives = { workspace = true, features = ["serde"] }
alloy-consensus = { workspace = true, features = ["k256", "kzg"] }
alloy-contract = { workspace = true, features = ["pubsub"] }
Expand Down Expand Up @@ -78,7 +87,11 @@ rand = "0.8"
eyre.workspace = true

# cli
clap = { version = "4", features = ["derive", "env", "wrap_help"], optional = true }
clap = { version = "4", features = [
"derive",
"env",
"wrap_help",
], optional = true }
clap_complete = { version = "4", optional = true }
chrono.workspace = true
auto_impl = "1"
Expand All @@ -101,7 +114,7 @@ similar-asserts.workspace = true
tokio = { workspace = true, features = ["full"] }

[features]
default = ["cli"]
default = ["cli", "jemalloc"]
cmd = ["clap", "clap_complete", "ctrlc", "anvil-server/clap"]
cli = ["tokio/full", "cmd", "fdlimit"]
asm-keccak = ["alloy-primitives/asm-keccak"]
Expand Down
10 changes: 7 additions & 3 deletions crates/cast/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,11 @@ name = "cast"
path = "bin/main.rs"

[build-dependencies]
vergen = { workspace = true, default-features = false, features = ["build", "git", "gitcl"] }
vergen = { workspace = true, default-features = false, features = [
"build",
"git",
"gitcl",
] }

[dependencies]
# lib
Expand Down Expand Up @@ -48,7 +52,7 @@ eyre.workspace = true
futures = "0.3"
hex.workspace = true
rand.workspace = true
rayon = "1"
rayon.workspace = true
serde_json.workspace = true
serde.workspace = true

Expand Down Expand Up @@ -83,7 +87,7 @@ async-trait = "0.1"
criterion = "0.5"

[features]
default = ["rustls"]
default = ["rustls", "jemalloc"]
rustls = ["foundry-cli/rustls", "foundry-wallets/rustls"]
openssl = ["foundry-cli/openssl"]
asm-keccak = ["alloy-primitives/asm-keccak"]
Expand Down
20 changes: 16 additions & 4 deletions crates/chisel/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
[package]
name = "chisel"
authors = ["clabby <https://github.com/clabby>", "asnared <https://github.com/abigger87>"]
authors = [
"clabby <https://github.com/clabby>",
"asnared <https://github.com/abigger87>",
]
description = "Fast, utilitarian, and verbose Solidity REPL"

version.workspace = true
Expand All @@ -15,7 +18,11 @@ name = "chisel"
path = "bin/main.rs"

[build-dependencies]
vergen = { workspace = true, default-features = false, features = ["build", "git", "gitcl"] }
vergen = { workspace = true, default-features = false, features = [
"build",
"git",
"gitcl",
] }

[dependencies]
# forge
Expand All @@ -28,7 +35,12 @@ foundry-config.workspace = true
foundry-evm.workspace = true

alloy-dyn-abi = { workspace = true, features = ["arbitrary"] }
alloy-primitives = { workspace = true, features = ["serde", "getrandom", "arbitrary", "rlp"] }
alloy-primitives = { workspace = true, features = [
"serde",
"getrandom",
"arbitrary",
"rlp",
] }
alloy-json-abi.workspace = true
alloy-rpc-types.workspace = true

Expand Down Expand Up @@ -59,7 +71,7 @@ serial_test = "3"
tracing-subscriber.workspace = true

[features]
default = ["rustls"]
default = ["rustls", "jemalloc"]
rustls = ["reqwest/rustls-tls", "reqwest/rustls-tls-native-roots"]
openssl = ["foundry-compilers/openssl", "reqwest/default-tls"]
asm-keccak = ["alloy-primitives/asm-keccak"]
Expand Down
2 changes: 1 addition & 1 deletion crates/doc/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ eyre.workspace = true
itertools.workspace = true
mdbook = { version = "0.4", default-features = false, features = ["search"] }
once_cell = "1"
rayon = "1"
rayon.workspace = true
serde_json.workspace = true
serde.workspace = true
solang-parser.workspace = true
Expand Down
5 changes: 3 additions & 2 deletions crates/evm/core/src/decode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ use alloy_sol_types::{SolCall, SolError, SolEventInterface, SolInterface, SolVal
use foundry_common::SELECTOR_LEN;
use itertools::Itertools;
use revm::interpreter::InstructionResult;
use std::{collections::HashMap, sync::OnceLock};
use rustc_hash::FxHashMap;
use std::sync::OnceLock;

/// Decode a set of logs, only returning logs from DSTest logging events and Hardhat's `console.log`
pub fn decode_console_logs(logs: &[Log]) -> Vec<String> {
Expand All @@ -27,7 +28,7 @@ pub fn decode_console_log(log: &Log) -> Option<String> {
#[derive(Clone, Debug, Default)]
pub struct RevertDecoder {
/// The custom errors to use for decoding.
pub errors: HashMap<Selector, Vec<Error>>,
pub errors: FxHashMap<Selector, Vec<Error>>,
}

impl Default for &RevertDecoder {
Expand Down
20 changes: 20 additions & 0 deletions crates/evm/core/src/ic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,16 @@ impl PcIcMap {
Self { inner: make_map::<true>(code) }
}

/// Returns the length of the map.
pub fn len(&self) -> usize {
self.inner.len()
}

/// Returns `true` if the map is empty.
pub fn is_empty(&self) -> bool {
self.inner.is_empty()
}

/// Returns the instruction counter for the given program counter.
pub fn get(&self, pc: usize) -> Option<usize> {
self.inner.get(&pc).copied()
Expand All @@ -33,6 +43,16 @@ impl IcPcMap {
Self { inner: make_map::<false>(code) }
}

/// Returns the length of the map.
pub fn len(&self) -> usize {
self.inner.len()
}

/// Returns `true` if the map is empty.
pub fn is_empty(&self) -> bool {
self.inner.is_empty()
}

/// Returns the program counter for the given instruction counter.
pub fn get(&self, ic: usize) -> Option<usize> {
self.inner.get(&ic).copied()
Expand Down
1 change: 1 addition & 0 deletions crates/evm/coverage/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,4 @@ revm.workspace = true
semver = "1"
tracing = "0.1"
rustc-hash.workspace = true
rayon.workspace = true
Loading
Loading