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: remove the debugger feature #668

Merged
merged 1 commit into from
Sep 17, 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
3 changes: 0 additions & 3 deletions Cargo.lock

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

4 changes: 0 additions & 4 deletions crates/edr_napi/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -387,8 +387,6 @@ export interface SolidityTestRunnerConfigArgs {
fsPermissions?: Array<PathPermission>
/** Whether to collect traces. Defaults to false. */
trace?: boolean
/** Whether to collect debug info. Defaults to false. */
debug?: boolean
/** Whether to support the `testFail` prefix. Defaults to false. */
testFail?: boolean
/** Address labels for traces. Defaults to none. */
Expand Down Expand Up @@ -701,8 +699,6 @@ export interface StandardTestKind {
}
/** See [forge::result::TestKind::Fuzz] */
export interface FuzzTestKind {
/** See [forge::result::TestKind::Fuzz] */
readonly firstCase: FuzzCase
/** See [forge::result::TestKind::Fuzz] */
readonly runs: bigint
/** See [forge::result::TestKind::Fuzz] */
Expand Down
5 changes: 0 additions & 5 deletions crates/edr_napi/src/solidity_tests/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@ pub struct SolidityTestRunnerConfigArgs {
pub fs_permissions: Option<Vec<PathPermission>>,
/// Whether to collect traces. Defaults to false.
pub trace: Option<bool>,
/// Whether to collect debug info. Defaults to false.
pub debug: Option<bool>,
/// Whether to support the `testFail` prefix. Defaults to false.
pub test_fail: Option<bool>,
/// Address labels for traces. Defaults to none.
Expand Down Expand Up @@ -114,7 +112,6 @@ impl Debug for SolidityTestRunnerConfigArgs {
.field("project_root", &self.project_root)
.field("fs_permissions", &self.fs_permissions)
.field("trace", &self.trace)
.field("debug", &self.debug)
.field("ffi", &self.ffi)
.field("sender", &self.sender.as_ref().map(hex::encode))
.field("tx_origin", &self.tx_origin.as_ref().map(hex::encode))
Expand Down Expand Up @@ -151,7 +148,6 @@ impl TryFrom<SolidityTestRunnerConfigArgs> for SolidityTestRunnerConfig {
project_root,
fs_permissions,
trace,
debug,
test_fail,
labels,
isolate,
Expand Down Expand Up @@ -285,7 +281,6 @@ impl TryFrom<SolidityTestRunnerConfigArgs> for SolidityTestRunnerConfig {

Ok(SolidityTestRunnerConfig {
project_root: project_root.into(),
debug: debug.unwrap_or_default(),
trace: trace.unwrap_or_default(),
// TODO
coverage: false,
Expand Down
9 changes: 0 additions & 9 deletions crates/edr_napi/src/solidity_tests/test_results.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,16 +94,10 @@ impl From<(String, forge::result::TestResult)> for TestResult {
consumed_gas: BigInt::from(gas_consumed),
}),
forge::result::TestKind::Fuzz {
first_case,
runs,
mean_gas,
median_gas,
} => Either3::B(FuzzTestKind {
first_case: FuzzCase {
calldata: Buffer::from(first_case.calldata.as_ref()),
gas: BigInt::from(first_case.gas),
stipend: BigInt::from(first_case.stipend),
},
// usize as u64 is always safe
runs: BigInt::from(runs as u64),
mean_gas: BigInt::from(mean_gas),
Expand Down Expand Up @@ -160,9 +154,6 @@ pub struct StandardTestKind {
#[napi(object)]
#[derive(Debug, Clone)]
pub struct FuzzTestKind {
/// See [forge::result::TestKind::Fuzz]
#[napi(readonly)]
pub first_case: FuzzCase,
/// See [forge::result::TestKind::Fuzz]
#[napi(readonly)]
pub runs: BigInt,
Expand Down
40 changes: 0 additions & 40 deletions crates/foundry/cheatcodes/assets/cheatcodes.json
Original file line number Diff line number Diff line change
Expand Up @@ -3011,46 +3011,6 @@
"status": "stable",
"safety": "unsafe"
},
{
"func": {
"id": "breakpoint_0",
"description": "Writes a breakpoint to jump to in the debugger.",
"declaration": "function breakpoint(string calldata char) external;",
"visibility": "external",
"mutability": "",
"signature": "breakpoint(string)",
"selector": "0xf0259e92",
"selectorBytes": [
240,
37,
158,
146
]
},
"group": "testing",
"status": "stable",
"safety": "safe"
},
{
"func": {
"id": "breakpoint_1",
"description": "Writes a conditional breakpoint to jump to in the debugger.",
"declaration": "function breakpoint(string calldata char, bool value) external;",
"visibility": "external",
"mutability": "",
"signature": "breakpoint(string,bool)",
"selector": "0xf7d39a8d",
"selectorBytes": [
247,
211,
154,
141
]
},
"group": "testing",
"status": "stable",
"safety": "safe"
},
{
"func": {
"id": "chainId",
Expand Down
8 changes: 0 additions & 8 deletions crates/foundry/cheatcodes/spec/src/vm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -672,14 +672,6 @@ interface Vm {
#[cheatcode(group = Testing, safety = Safe)]
function assume(bool condition) external pure;

/// Writes a breakpoint to jump to in the debugger.
#[cheatcode(group = Testing, safety = Safe)]
function breakpoint(string calldata char) external;

/// Writes a conditional breakpoint to jump to in the debugger.
#[cheatcode(group = Testing, safety = Safe)]
function breakpoint(string calldata char, bool value) external;

/// Returns the RPC url for the given alias.
#[cheatcode(group = Testing, safety = Safe)]
function rpcUrl(string calldata rpcAlias) external view returns (string memory json);
Expand Down
5 changes: 1 addition & 4 deletions crates/foundry/cheatcodes/src/inspector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use std::{
use alloy_primitives::{Address, Bytes, Log, B256, U256};
use alloy_rpc_types::request::TransactionRequest;
use alloy_sol_types::{SolInterface, SolValue};
use foundry_common::{evm::Breakpoints, SELECTOR_LEN};
use foundry_common::SELECTOR_LEN;
use foundry_evm_core::{
abi::Vm::stopExpectSafeMemoryCall,
backend::{DatabaseExt, RevertDiagnostic},
Expand Down Expand Up @@ -207,9 +207,6 @@ pub struct Cheatcodes {

/// The current program counter.
pub pc: usize,
/// Breakpoints supplied by the `breakpoint` cheatcode.
/// `char -> (address, pc)`
pub breakpoints: Breakpoints,
}

impl Cheatcodes {
Expand Down
40 changes: 1 addition & 39 deletions crates/foundry/cheatcodes/src/test.rs
Original file line number Diff line number Diff line change
@@ -1,15 +1,11 @@
//! Implementations of [`Testing`](crate::Group::Testing) cheatcodes.

use alloy_primitives::Address;
use alloy_sol_types::SolValue;
use foundry_evm_core::constants::{MAGIC_ASSUME, MAGIC_SKIP};

use crate::{
Cheatcode, Cheatcodes, CheatsCtxt, DatabaseExt, Error, Result,
Vm::{
assumeCall, breakpoint_0Call, breakpoint_1Call, rpcUrlCall, rpcUrlStructsCall, rpcUrlsCall,
skipCall, sleepCall,
},
Vm::{assumeCall, rpcUrlCall, rpcUrlStructsCall, rpcUrlsCall, skipCall, sleepCall},
};

pub(crate) mod assert;
Expand All @@ -26,20 +22,6 @@ impl Cheatcode for assumeCall {
}
}

impl Cheatcode for breakpoint_0Call {
fn apply_full<DB: DatabaseExt>(&self, ccx: &mut CheatsCtxt<DB>) -> Result {
let Self { char } = self;
breakpoint(ccx.state, &ccx.caller, char, true)
}
}

impl Cheatcode for breakpoint_1Call {
fn apply_full<DB: DatabaseExt>(&self, ccx: &mut CheatsCtxt<DB>) -> Result {
let Self { char, value } = self;
breakpoint(ccx.state, &ccx.caller, char, *value)
}
}

impl Cheatcode for rpcUrlCall {
fn apply(&self, state: &mut Cheatcodes) -> Result {
let Self { rpcAlias } = self;
Expand Down Expand Up @@ -87,23 +69,3 @@ impl Cheatcode for skipCall {
}
}
}

/// Adds or removes the given breakpoint to the state.
fn breakpoint(state: &mut Cheatcodes, caller: &Address, s: &str, add: bool) -> Result {
let mut chars = s.chars();
let (Some(point), None) = (chars.next(), chars.next()) else {
bail!("breakpoints must be exactly one character");
};
ensure!(
point.is_alphabetic(),
"only alphabetic characters are accepted as breakpoints"
);

if add {
state.breakpoints.insert(point, (*caller, state.pc));
} else {
state.breakpoints.remove(&point);
}

Ok(Vec::default())
}
1 change: 0 additions & 1 deletion crates/foundry/common/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ tracing.workspace = true
url = "2"
walkdir = "2"
yansi.workspace = true
rustc-hash.workspace = true

[dev-dependencies]
foundry-macros.workspace = true
Expand Down
6 changes: 0 additions & 6 deletions crates/foundry/common/src/evm.rs

This file was deleted.

1 change: 0 additions & 1 deletion crates/foundry/common/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ pub mod constants;
pub mod contracts;
pub mod ens;
pub mod errors;
pub mod evm;
pub mod fmt;
pub mod fs;
pub mod provider;
Expand Down
1 change: 0 additions & 1 deletion crates/foundry/evm/core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ revm = { workspace = true, features = [
] }
revm-inspectors.workspace = true

arrayvec.workspace = true
auto_impl = "1"
derive_more.workspace = true
eyre = "0.6"
Expand Down
Loading
Loading