From e16991821b3d65ddb55870211f73b1d75c3ba7a5 Mon Sep 17 00:00:00 2001 From: zerosnacks Date: Mon, 9 Dec 2024 14:06:56 +0100 Subject: [PATCH 1/3] enforce stricter command compatibility mode for forge test --- crates/forge/bin/cmd/test/mod.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/crates/forge/bin/cmd/test/mod.rs b/crates/forge/bin/cmd/test/mod.rs index c55eb520ae25..85f75a19be2d 100644 --- a/crates/forge/bin/cmd/test/mod.rs +++ b/crates/forge/bin/cmd/test/mod.rs @@ -79,7 +79,7 @@ pub struct TestArgs { /// /// If the matching test is a fuzz test, then it will open the debugger on the first failure /// case. If the fuzz test does not fail, it will open the debugger on the last fuzz case. - #[arg(long, value_name = "DEPRECATED_TEST_FUNCTION_REGEX")] + #[arg(long, conflicts_with_all = ["flamegraph", "flamechart", "decode_internal", "rerun"], value_name = "DEPRECATED_TEST_FUNCTION_REGEX")] debug: Option>, /// Generate a flamegraph for a single test. Implies `--decode-internal`. @@ -123,7 +123,7 @@ pub struct TestArgs { allow_failure: bool, /// Output test results as JUnit XML report. - #[arg(long, conflicts_with_all = ["quiet", "json", "gas_report"], help_heading = "Display options")] + #[arg(long, conflicts_with_all = ["quiet", "json", "gas_report", "summary", "list", "show_progress"], help_heading = "Display options")] pub junit: bool, /// Stop running tests after the first failure. @@ -135,7 +135,7 @@ pub struct TestArgs { etherscan_api_key: Option, /// List tests instead of running them. - #[arg(long, short, help_heading = "Display options")] + #[arg(long, short, conflicts_with_all = ["show_progress", "decode_internal", "summary"], help_heading = "Display options")] list: bool, /// Set seed used to generate randomness during your fuzz runs. @@ -154,7 +154,7 @@ pub struct TestArgs { pub fuzz_input_file: Option, /// Show test execution progress. - #[arg(long)] + #[arg(long, conflicts_with_all = ["quiet", "json"], help_heading = "Display options")] pub show_progress: bool, #[command(flatten)] From 49e43f77e32f05308570ed8c23c69f00203f0a0f Mon Sep 17 00:00:00 2001 From: zerosnacks Date: Tue, 10 Dec 2024 12:27:11 +0100 Subject: [PATCH 2/3] add conflicting cases for anvil --- crates/anvil/src/cmd.rs | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/crates/anvil/src/cmd.rs b/crates/anvil/src/cmd.rs index 7b009a592813..beece04c878e 100644 --- a/crates/anvil/src/cmd.rs +++ b/crates/anvil/src/cmd.rs @@ -8,7 +8,7 @@ use alloy_genesis::Genesis; use alloy_primitives::{utils::Unit, B256, U256}; use alloy_signer_local::coins_bip39::{English, Mnemonic}; use anvil_server::ServerConfig; -use clap::Parser; +use clap::{ArgGroup, Parser}; use core::fmt; use foundry_common::shell; use foundry_config::{Chain, Config, FigmentProviders}; @@ -30,6 +30,7 @@ use std::{ use tokio::time::{Instant, Interval}; #[derive(Clone, Debug, Parser)] +#[command(group = ArgGroup::new("mnemonic_options").multiple(false))] pub struct NodeArgs { /// Port number to listen on. #[arg(long, short, default_value = "8545", value_name = "NUM")] @@ -49,14 +50,14 @@ pub struct NodeArgs { /// BIP39 mnemonic phrase used for generating accounts. /// Cannot be used if `mnemonic_random` or `mnemonic_seed` are used. - #[arg(long, short, conflicts_with_all = &["mnemonic_seed", "mnemonic_random"])] + #[arg(long, short, conflicts_with_all = &["mnemonic_seed", "mnemonic_random"], group = "mnemonic_options")] pub mnemonic: Option, /// Automatically generates a BIP39 mnemonic phrase, and derives accounts from it. /// Cannot be used with other `mnemonic` options. /// You can specify the number of words you want in the mnemonic. /// [default: 12] - #[arg(long, conflicts_with_all = &["mnemonic", "mnemonic_seed"], default_missing_value = "12", num_args(0..=1))] + #[arg(long, default_missing_value = "12", num_args(0..=1), group = "mnemonic_options")] pub mnemonic_random: Option, /// Generates a BIP39 mnemonic phrase from a given seed @@ -64,18 +65,18 @@ pub struct NodeArgs { /// /// CAREFUL: This is NOT SAFE and should only be used for testing. /// Never use the private keys generated in production. - #[arg(long = "mnemonic-seed-unsafe", conflicts_with_all = &["mnemonic", "mnemonic_random"])] + #[arg(long = "mnemonic-seed-unsafe", group = "mnemonic_options")] pub mnemonic_seed: Option, /// Sets the derivation path of the child key to be derived. /// /// [default: m/44'/60'/0'/0/] - #[arg(long)] + #[arg(long, requires = "mnemonic_options")] pub derivation_path: Option, /// The EVM hardfork to use. /// - /// Choose the hardfork by name, e.g. `shanghai`, `paris`, `london`, etc... + /// Choose the hardfork by name, e.g. `cancun`, `shanghai`, `paris`, `london`, etc... /// [default: latest] #[arg(long)] pub hardfork: Option, @@ -177,7 +178,7 @@ pub struct NodeArgs { /// Max number of states to persist on disk. /// /// Note that `prune_history` will overwrite `max_persisted_states` to 0. - #[arg(long)] + #[arg(long, conflicts_with = "prune_history")] pub max_persisted_states: Option, /// Number of blocks with transactions to keep in memory. From 48d5cf21534dbcec862b767640b66ae8e5ba8b96 Mon Sep 17 00:00:00 2001 From: zerosnacks Date: Tue, 10 Dec 2024 14:19:10 +0100 Subject: [PATCH 3/3] revert anvil changes, derivation_path is not exclusive to mnemonics --- crates/anvil/src/cmd.rs | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/crates/anvil/src/cmd.rs b/crates/anvil/src/cmd.rs index beece04c878e..19e9193f908b 100644 --- a/crates/anvil/src/cmd.rs +++ b/crates/anvil/src/cmd.rs @@ -8,7 +8,7 @@ use alloy_genesis::Genesis; use alloy_primitives::{utils::Unit, B256, U256}; use alloy_signer_local::coins_bip39::{English, Mnemonic}; use anvil_server::ServerConfig; -use clap::{ArgGroup, Parser}; +use clap::Parser; use core::fmt; use foundry_common::shell; use foundry_config::{Chain, Config, FigmentProviders}; @@ -30,7 +30,6 @@ use std::{ use tokio::time::{Instant, Interval}; #[derive(Clone, Debug, Parser)] -#[command(group = ArgGroup::new("mnemonic_options").multiple(false))] pub struct NodeArgs { /// Port number to listen on. #[arg(long, short, default_value = "8545", value_name = "NUM")] @@ -50,14 +49,14 @@ pub struct NodeArgs { /// BIP39 mnemonic phrase used for generating accounts. /// Cannot be used if `mnemonic_random` or `mnemonic_seed` are used. - #[arg(long, short, conflicts_with_all = &["mnemonic_seed", "mnemonic_random"], group = "mnemonic_options")] + #[arg(long, short, conflicts_with_all = &["mnemonic_seed", "mnemonic_random"])] pub mnemonic: Option, /// Automatically generates a BIP39 mnemonic phrase, and derives accounts from it. /// Cannot be used with other `mnemonic` options. /// You can specify the number of words you want in the mnemonic. /// [default: 12] - #[arg(long, default_missing_value = "12", num_args(0..=1), group = "mnemonic_options")] + #[arg(long, conflicts_with_all = &["mnemonic", "mnemonic_seed"], default_missing_value = "12", num_args(0..=1))] pub mnemonic_random: Option, /// Generates a BIP39 mnemonic phrase from a given seed @@ -65,13 +64,13 @@ pub struct NodeArgs { /// /// CAREFUL: This is NOT SAFE and should only be used for testing. /// Never use the private keys generated in production. - #[arg(long = "mnemonic-seed-unsafe", group = "mnemonic_options")] + #[arg(long = "mnemonic-seed-unsafe", conflicts_with_all = &["mnemonic", "mnemonic_random"])] pub mnemonic_seed: Option, /// Sets the derivation path of the child key to be derived. /// /// [default: m/44'/60'/0'/0/] - #[arg(long, requires = "mnemonic_options")] + #[arg(long)] pub derivation_path: Option, /// The EVM hardfork to use.