Skip to content

Commit 86d5c5b

Browse files
authored
feat(forge): introduce network custom features, sunset Odyssey (#11675)
* feat(forge): add precompiles crate * Nit - NetowrkPrecompiles * Consolidate networks * Remove anvil odyssey * Consolidate forge networks * More reuse * Broader netwroks scope than precompiles * Remove odyssey * Add comment re optimism skipped from forge config
1 parent d4a7898 commit 86d5c5b

File tree

38 files changed

+312
-498
lines changed

38 files changed

+312
-498
lines changed

Cargo.lock

Lines changed: 15 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,7 @@ foundry-evm = { path = "crates/evm/evm" }
198198
foundry-evm-abi = { path = "crates/evm/abi" }
199199
foundry-evm-core = { path = "crates/evm/core" }
200200
foundry-evm-coverage = { path = "crates/evm/coverage" }
201+
foundry-evm-networks = { path = "crates/evm/networks" }
201202
foundry-evm-fuzz = { path = "crates/evm/fuzz" }
202203
foundry-evm-traces = { path = "crates/evm/traces" }
203204
foundry-macros = { path = "crates/macros" }

crates/anvil/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ foundry-common.workspace = true
2828
foundry-config.workspace = true
2929
foundry-evm.workspace = true
3030
foundry-evm-core.workspace = true
31+
foundry-evm-networks.workspace = true
3132

3233
# alloy
3334
alloy-evm = { workspace = true, features = ["call-util"] }

crates/anvil/core/src/eth/mod.rs

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -680,14 +680,6 @@ pub enum EthRequest {
680680
#[serde(rename = "wallet_getCapabilities", with = "empty_params")]
681681
WalletGetCapabilities(()),
682682

683-
/// Wallet send_tx
684-
#[serde(
685-
rename = "wallet_sendTransaction",
686-
alias = "odyssey_sendTransaction",
687-
with = "sequence"
688-
)]
689-
WalletSendTransaction(Box<WithOtherFields<TransactionRequest>>),
690-
691683
/// Add an address to the delegation capability of the wallet
692684
#[serde(rename = "anvil_addCapability", with = "sequence")]
693685
AnvilAddCapability(Address),

crates/anvil/src/cmd.rs

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ use clap::Parser;
1212
use core::fmt;
1313
use foundry_common::shell;
1414
use foundry_config::{Chain, Config, FigmentProviders};
15+
use foundry_evm_networks::NetworkConfigs;
1516
use futures::FutureExt;
1617
use rand_08::{SeedableRng, rngs::StdRng};
1718
use std::{
@@ -217,7 +218,7 @@ impl NodeArgs {
217218

218219
let hardfork = match &self.hardfork {
219220
Some(hf) => {
220-
if self.evm.optimism {
221+
if self.evm.networks.optimism {
221222
Some(OpHardfork::from_str(hf)?.into())
222223
} else {
223224
Some(EthereumHardfork::from_str(hf)?.into())
@@ -277,9 +278,7 @@ impl NodeArgs {
277278
.with_init_state(self.load_state.or_else(|| self.state.and_then(|s| s.state)))
278279
.with_transaction_block_keeper(self.transaction_block_keeper)
279280
.with_max_persisted_states(self.max_persisted_states)
280-
.with_optimism(self.evm.optimism)
281-
.with_odyssey(self.evm.odyssey)
282-
.with_celo(self.evm.celo)
281+
.with_networks(self.evm.networks)
283282
.with_disable_default_create2_deployer(self.evm.disable_default_create2_deployer)
284283
.with_disable_pool_balance_checks(self.evm.disable_pool_balance_checks)
285284
.with_slots_in_an_epoch(self.slots_in_an_epoch)
@@ -593,10 +592,6 @@ pub struct AnvilEvmArgs {
593592
#[arg(long, visible_alias = "auto-unlock")]
594593
pub auto_impersonate: bool,
595594

596-
/// Run an Optimism chain
597-
#[arg(long, visible_alias = "optimism")]
598-
pub optimism: bool,
599-
600595
/// Disable the default create2 deployer
601596
#[arg(long, visible_alias = "no-create2")]
602597
pub disable_default_create2_deployer: bool,
@@ -609,13 +604,8 @@ pub struct AnvilEvmArgs {
609604
#[arg(long)]
610605
pub memory_limit: Option<u64>,
611606

612-
/// Enable Odyssey features
613-
#[arg(long, alias = "alphanet")]
614-
pub odyssey: bool,
615-
616-
/// Run a Celo chain
617-
#[arg(long)]
618-
pub celo: bool,
607+
#[command(flatten)]
608+
pub networks: NetworkConfigs,
619609
}
620610

621611
/// Resolves an alias passed as fork-url to the matching url defined in the rpc_endpoints section

crates/anvil/src/config.rs

Lines changed: 12 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ use yansi::Paint;
6666

6767
pub use foundry_common::version::SHORT_VERSION as VERSION_MESSAGE;
6868
use foundry_evm::traces::{CallTraceDecoderBuilder, identifier::SignaturesIdentifier};
69+
use foundry_evm_networks::NetworkConfigs;
6970

7071
/// Default port the rpc will open
7172
pub const NODE_PORT: u16 = 8545;
@@ -188,18 +189,14 @@ pub struct NodeConfig {
188189
pub disable_default_create2_deployer: bool,
189190
/// Disable pool balance checks
190191
pub disable_pool_balance_checks: bool,
191-
/// Enable Optimism deposit transaction
192-
pub enable_optimism: bool,
193192
/// Slots in an epoch
194193
pub slots_in_an_epoch: u64,
195194
/// The memory limit per EVM execution in bytes.
196195
pub memory_limit: Option<u64>,
197196
/// Factory used by `anvil` to extend the EVM's precompiles.
198197
pub precompile_factory: Option<Arc<dyn PrecompileFactory>>,
199-
/// Enable Odyssey features.
200-
pub odyssey: bool,
201-
/// Enable Celo features.
202-
pub celo: bool,
198+
/// Networks to enable features for.
199+
pub networks: NetworkConfigs,
203200
/// Do not print log messages.
204201
pub silent: bool,
205202
/// The path where states are cached.
@@ -491,12 +488,10 @@ impl Default for NodeConfig {
491488
transaction_block_keeper: None,
492489
disable_default_create2_deployer: false,
493490
disable_pool_balance_checks: false,
494-
enable_optimism: false,
495491
slots_in_an_epoch: 32,
496492
memory_limit: None,
497493
precompile_factory: None,
498-
odyssey: false,
499-
celo: false,
494+
networks: Default::default(),
500495
silent: false,
501496
cache_path: None,
502497
}
@@ -540,13 +535,10 @@ impl NodeConfig {
540535

541536
/// Returns the hardfork to use
542537
pub fn get_hardfork(&self) -> ChainHardfork {
543-
if self.odyssey {
544-
return ChainHardfork::Ethereum(EthereumHardfork::default());
545-
}
546538
if let Some(hardfork) = self.hardfork {
547539
return hardfork;
548540
}
549-
if self.enable_optimism {
541+
if self.networks.optimism {
550542
return OpHardfork::default().into();
551543
}
552544
EthereumHardfork::default().into()
@@ -999,7 +991,7 @@ impl NodeConfig {
999991
/// Sets whether to enable optimism support
1000992
#[must_use]
1001993
pub fn with_optimism(mut self, enable_optimism: bool) -> Self {
1002-
self.enable_optimism = enable_optimism;
994+
self.networks.optimism = enable_optimism;
1003995
self
1004996
}
1005997

@@ -1024,20 +1016,20 @@ impl NodeConfig {
10241016
self
10251017
}
10261018

1027-
/// Sets whether to enable Odyssey support
1019+
/// Enable features for provided networks.
10281020
#[must_use]
1029-
pub fn with_odyssey(mut self, odyssey: bool) -> Self {
1030-
self.odyssey = odyssey;
1021+
pub fn with_networks(mut self, networks: NetworkConfigs) -> Self {
1022+
self.networks = networks;
10311023
self
10321024
}
10331025

10341026
/// Sets whether to enable Celo support
10351027
#[must_use]
10361028
pub fn with_celo(mut self, celo: bool) -> Self {
1037-
self.celo = celo;
1029+
self.networks.celo = celo;
10381030
if celo {
10391031
// Celo requires Optimism support
1040-
self.enable_optimism = true;
1032+
self.networks.optimism = true;
10411033
}
10421034
self
10431035
}
@@ -1099,8 +1091,7 @@ impl NodeConfig {
10991091
base: TxEnv { chain_id: Some(self.get_chain_id()), ..Default::default() },
11001092
..Default::default()
11011093
},
1102-
self.enable_optimism,
1103-
self.celo,
1094+
self.networks,
11041095
);
11051096

11061097
let fees = FeeManager::new(
@@ -1163,7 +1154,6 @@ impl NodeConfig {
11631154
self.print_logs,
11641155
self.print_traces,
11651156
Arc::new(decoder_builder.build()),
1166-
self.odyssey,
11671157
self.prune_history,
11681158
self.max_persisted_states,
11691159
self.transaction_block_keeper,

0 commit comments

Comments
 (0)