From 8a0cf759ee29d1ec45b9f48ff18ae6fece46a3a8 Mon Sep 17 00:00:00 2001 From: iosh Date: Sun, 15 Dec 2024 17:18:14 +0800 Subject: [PATCH 1/4] rename json_rpc_url to url --- crates/edr_generic/tests/issue_570.rs | 2 +- crates/edr_napi/index.d.ts | 2 +- crates/edr_napi/src/config.rs | 4 ++-- crates/edr_napi/test/provider.ts | 2 +- crates/edr_optimism/tests/provider.rs | 2 +- crates/edr_provider/src/data.rs | 2 +- crates/edr_provider/src/requests/hardhat/rpc_types/config.rs | 2 +- crates/edr_provider/src/test_utils.rs | 2 +- crates/edr_provider/tests/hardhat_request_serialization.rs | 2 +- 9 files changed, 10 insertions(+), 10 deletions(-) diff --git a/crates/edr_generic/tests/issue_570.rs b/crates/edr_generic/tests/issue_570.rs index 0ad985990..bd9dffc83 100644 --- a/crates/edr_generic/tests/issue_570.rs +++ b/crates/edr_generic/tests/issue_570.rs @@ -22,7 +22,7 @@ fn get_provider() -> anyhow::Result> { let subscriber = Box::new(|_event| {}); let mut config = create_test_config_with_fork(Some(ForkConfig { - json_rpc_url: get_alchemy_url().replace("eth-mainnet", "base-sepolia"), + url: get_alchemy_url().replace("eth-mainnet", "base-sepolia"), block_number: Some(BLOCK_NUMBER), http_headers: None, })); diff --git a/crates/edr_napi/index.d.ts b/crates/edr_napi/index.d.ts index a31fa5438..a140f0b65 100644 --- a/crates/edr_napi/index.d.ts +++ b/crates/edr_napi/index.d.ts @@ -139,7 +139,7 @@ export interface ChainConfig { /** Configuration for forking a blockchain */ export interface ForkConfig { /** The URL of the JSON-RPC endpoint to fork from */ - jsonRpcUrl: string + url: string /** * The block number to fork from. If not provided, the latest safe block is * used. diff --git a/crates/edr_napi/src/config.rs b/crates/edr_napi/src/config.rs index 82b15b8bf..56135f827 100644 --- a/crates/edr_napi/src/config.rs +++ b/crates/edr_napi/src/config.rs @@ -26,7 +26,7 @@ pub struct ChainConfig { #[napi(object)] pub struct ForkConfig { /// The URL of the JSON-RPC endpoint to fork from - pub json_rpc_url: String, + pub url: String, /// The block number to fork from. If not provided, the latest safe block is /// used. pub block_number: Option, @@ -139,7 +139,7 @@ impl TryFrom for edr_provider::hardhat_rpc_types::ForkConfig { }); Ok(Self { - json_rpc_url: value.json_rpc_url, + url: value.url, block_number, http_headers, }) diff --git a/crates/edr_napi/test/provider.ts b/crates/edr_napi/test/provider.ts index e31c27cd8..63bd53342 100644 --- a/crates/edr_napi/test/provider.ts +++ b/crates/edr_napi/test/provider.ts @@ -97,7 +97,7 @@ describe("Provider", () => { GENERIC_CHAIN_TYPE, { fork: { - jsonRpcUrl: ALCHEMY_URL, + url: ALCHEMY_URL, }, ...providerConfig, }, diff --git a/crates/edr_optimism/tests/provider.rs b/crates/edr_optimism/tests/provider.rs index cbb9dc25c..ae8abbb13 100644 --- a/crates/edr_optimism/tests/provider.rs +++ b/crates/edr_optimism/tests/provider.rs @@ -47,7 +47,7 @@ async fn sepolia_call_with_remote_chain_id() -> anyhow::Result<()> { let subscriber = Box::new(|_event| {}); let mut config = create_test_config_with_fork(Some(ForkConfig { - json_rpc_url: sepolia_url(), + url: sepolia_url(), block_number: None, http_headers: None, })); diff --git a/crates/edr_provider/src/data.rs b/crates/edr_provider/src/data.rs index 1e57e5a13..7c67810d0 100644 --- a/crates/edr_provider/src/data.rs +++ b/crates/edr_provider/src/data.rs @@ -2639,7 +2639,7 @@ fn create_blockchain_and_state>( .transpose()?; let rpc_client = Arc::new(EthRpcClient::::new( - &fork_config.json_rpc_url, + &fork_config.url, config.cache_dir.clone(), http_headers.clone(), )?); diff --git a/crates/edr_provider/src/requests/hardhat/rpc_types/config.rs b/crates/edr_provider/src/requests/hardhat/rpc_types/config.rs index b6edbbcd7..10109a5c4 100644 --- a/crates/edr_provider/src/requests/hardhat/rpc_types/config.rs +++ b/crates/edr_provider/src/requests/hardhat/rpc_types/config.rs @@ -9,7 +9,7 @@ pub struct ResetProviderConfig { #[derive(Clone, Debug, PartialEq, serde::Deserialize, serde::Serialize)] #[serde(rename_all = "camelCase")] pub struct ForkConfig { - pub json_rpc_url: String, + pub url: String, pub block_number: Option, pub http_headers: Option>, } diff --git a/crates/edr_provider/src/test_utils.rs b/crates/edr_provider/src/test_utils.rs index 2e794753d..cde842948 100644 --- a/crates/edr_provider/src/test_utils.rs +++ b/crates/edr_provider/src/test_utils.rs @@ -166,7 +166,7 @@ impl> ProviderTestFixture) -> anyhow::Result { let fork = fork.map(|json_rpc_url| { ForkConfig { - json_rpc_url, + url: json_rpc_url, // Random recent block for better cache consistency block_number: Some(FORK_BLOCK_NUMBER), http_headers: None, diff --git a/crates/edr_provider/tests/hardhat_request_serialization.rs b/crates/edr_provider/tests/hardhat_request_serialization.rs index 8c3ee8f28..1e0169552 100644 --- a/crates/edr_provider/tests/hardhat_request_serialization.rs +++ b/crates/edr_provider/tests/hardhat_request_serialization.rs @@ -97,7 +97,7 @@ fn serde_hardhat_reset() { help_test_method_invocation_serde(MethodInvocation::::Reset(Some( ResetProviderConfig { forking: Some(ForkConfig { - json_rpc_url: String::from("http://whatever.com/whatever"), + url: String::from("http://whatever.com/whatever"), block_number: Some(123456), http_headers: None, }), From f48a18e03245c084d1789584be8209fad5e2d77a Mon Sep 17 00:00:00 2001 From: iosh Date: Sun, 15 Dec 2024 19:52:41 +0800 Subject: [PATCH 2/4] Move cache_dir config option to ForkConfig --- crates/edr_napi/index.d.ts | 4 ++-- crates/edr_napi/src/config.rs | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/crates/edr_napi/index.d.ts b/crates/edr_napi/index.d.ts index a140f0b65..4d8fd35c1 100644 --- a/crates/edr_napi/index.d.ts +++ b/crates/edr_napi/index.d.ts @@ -147,6 +147,8 @@ export interface ForkConfig { blockNumber?: bigint /** The HTTP headers to use when making requests to the JSON-RPC endpoint */ httpHeaders?: Array + /** The directory to cache remote JSON-RPC responses */ + cacheDir?: string } export interface HttpHeader { name: string @@ -192,8 +194,6 @@ export interface ProviderConfig { bailOnTransactionFailure: boolean /** The gas limit of each block */ blockGasLimit: bigint - /** The directory to cache remote JSON-RPC responses */ - cacheDir?: string /** The chain ID of the blockchain */ chainId: bigint /** The configuration for chains */ diff --git a/crates/edr_napi/src/config.rs b/crates/edr_napi/src/config.rs index 56135f827..17974e03e 100644 --- a/crates/edr_napi/src/config.rs +++ b/crates/edr_napi/src/config.rs @@ -32,6 +32,8 @@ pub struct ForkConfig { pub block_number: Option, /// The HTTP headers to use when making requests to the JSON-RPC endpoint pub http_headers: Option>, + /// The directory to cache remote JSON-RPC responses + pub cache_dir: Option, } #[napi(object)] @@ -91,8 +93,6 @@ pub struct ProviderConfig { pub bail_on_transaction_failure: bool, /// The gas limit of each block pub block_gas_limit: BigInt, - /// The directory to cache remote JSON-RPC responses - pub cache_dir: Option, /// The chain ID of the blockchain pub chain_id: BigInt, /// The configuration for chains @@ -256,7 +256,7 @@ impl TryFrom for edr_napi_core::provider::Config { bail_on_call_failure: value.bail_on_call_failure, bail_on_transaction_failure: value.bail_on_transaction_failure, block_gas_limit, - cache_dir: value.cache_dir, + cache_dir: value.fork.as_ref().and_then(|fork_config| fork_config.cache_dir.clone()), chain_id: value.chain_id.try_cast()?, chains, coinbase: value.coinbase.try_cast()?, From 738b120d7d19492bbba63db9429aa17cc8cddc47 Mon Sep 17 00:00:00 2001 From: iosh Date: Mon, 16 Dec 2024 20:24:37 +0800 Subject: [PATCH 3/4] Move edr_provider's cache_dir to ForkConfig --- Cargo.lock | 1 + crates/edr_generic/tests/issue_570.rs | 1 + crates/edr_napi/Cargo.toml | 1 + crates/edr_napi/src/config.rs | 5 +++++ crates/edr_napi_core/src/provider/config.rs | 9 +-------- crates/edr_optimism/tests/provider.rs | 1 + crates/edr_provider/src/config.rs | 3 +-- crates/edr_provider/src/data.rs | 8 +++++--- .../src/requests/hardhat/rpc_types/config.rs | 3 ++- crates/edr_provider/src/test_utils.rs | 2 +- .../edr_provider/tests/hardhat_request_serialization.rs | 1 + crates/edr_provider/tests/issues/issue_324.rs | 3 ++- crates/edr_provider/tests/issues/issue_356.rs | 3 ++- crates/edr_provider/tests/issues/issue_384.rs | 3 ++- crates/edr_provider/tests/issues/issue_503.rs | 3 ++- crates/edr_provider/tests/issues/issue_533.rs | 3 ++- crates/edr_provider/tests/issues/issue_588.rs | 3 ++- 17 files changed, 32 insertions(+), 21 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 8774bdc22..baeb420f6 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1348,6 +1348,7 @@ dependencies = [ "alloy-json-abi 0.7.7", "alloy-sol-types 0.5.4", "derive-where", + "edr_defaults", "edr_eth", "edr_evm", "edr_generic", diff --git a/crates/edr_generic/tests/issue_570.rs b/crates/edr_generic/tests/issue_570.rs index bd9dffc83..ef909239e 100644 --- a/crates/edr_generic/tests/issue_570.rs +++ b/crates/edr_generic/tests/issue_570.rs @@ -25,6 +25,7 @@ fn get_provider() -> anyhow::Result> { url: get_alchemy_url().replace("eth-mainnet", "base-sepolia"), block_number: Some(BLOCK_NUMBER), http_headers: None, + cache_dir: edr_defaults::CACHE_DIR.into(), })); config.chains.insert( diff --git a/crates/edr_napi/Cargo.toml b/crates/edr_napi/Cargo.toml index 4397576f1..1e33ff2cf 100644 --- a/crates/edr_napi/Cargo.toml +++ b/crates/edr_napi/Cargo.toml @@ -33,6 +33,7 @@ tracing-flame = { version = "0.2.0", default-features = false, features = ["smal tracing-subscriber = { version = "0.3.18", default-features = false, features = ["ansi", "env-filter", "fmt", "parking_lot", "smallvec", "std"] } parking_lot = { version = "0.12.1", default-features = false } lazy_static = { version = "1.4.0", features = [] } +edr_defaults = { version = "0.3.5", path = "../edr_defaults" } [target.x86_64-unknown-linux-gnu.dependencies] openssl-sys = { version = "0.9.93", features = ["vendored"] } diff --git a/crates/edr_napi/src/config.rs b/crates/edr_napi/src/config.rs index 17974e03e..19c1f760a 100644 --- a/crates/edr_napi/src/config.rs +++ b/crates/edr_napi/src/config.rs @@ -1,8 +1,10 @@ use std::{ num::NonZeroU64, + path::PathBuf, time::{Duration, SystemTime}, }; +use edr_defaults; use edr_eth::HashMap; use edr_provider::AccountConfig; use napi::{ @@ -142,6 +144,9 @@ impl TryFrom for edr_provider::hardhat_rpc_types::ForkConfig { url: value.url, block_number, http_headers, + cache_dir: value + .cache_dir + .map_or(edr_defaults::CACHE_DIR.into(), PathBuf::from), }) } } diff --git a/crates/edr_napi_core/src/provider/config.rs b/crates/edr_napi_core/src/provider/config.rs index 3101b1c95..1c47c69b6 100644 --- a/crates/edr_napi_core/src/provider/config.rs +++ b/crates/edr_napi_core/src/provider/config.rs @@ -1,5 +1,5 @@ use core::num::NonZeroU64; -use std::{path::PathBuf, time::SystemTime}; +use std::time::SystemTime; use edr_eth::{account::AccountInfo, block::BlobGas, Address, ChainId, HashMap, B256, U256}; use edr_provider::{ @@ -52,12 +52,6 @@ where ChainSpecT: RuntimeSpec From<&'s str>>, { fn from(value: Config) -> Self { - let cache_dir = PathBuf::from( - value - .cache_dir - .unwrap_or(String::from(edr_defaults::CACHE_DIR)), - ); - let chains = value .chains .into_iter() @@ -90,7 +84,6 @@ where bail_on_call_failure: value.bail_on_call_failure, bail_on_transaction_failure: value.bail_on_transaction_failure, block_gas_limit: value.block_gas_limit, - cache_dir, chain_id: value.chain_id, chains, coinbase: value.coinbase, diff --git a/crates/edr_optimism/tests/provider.rs b/crates/edr_optimism/tests/provider.rs index ae8abbb13..5f20e237a 100644 --- a/crates/edr_optimism/tests/provider.rs +++ b/crates/edr_optimism/tests/provider.rs @@ -50,6 +50,7 @@ async fn sepolia_call_with_remote_chain_id() -> anyhow::Result<()> { url: sepolia_url(), block_number: None, http_headers: None, + cache_dir: edr_defaults::CACHE_DIR.into(), })); // Set a different chain ID than the forked chain ID diff --git a/crates/edr_provider/src/config.rs b/crates/edr_provider/src/config.rs index f14f2f9b7..93857498d 100644 --- a/crates/edr_provider/src/config.rs +++ b/crates/edr_provider/src/config.rs @@ -1,4 +1,4 @@ -use std::{num::NonZeroU64, path::PathBuf, time::SystemTime}; +use std::{num::NonZeroU64, time::SystemTime}; use derive_where::derive_where; use edr_eth::{account::AccountInfo, block::BlobGas, Address, ChainId, HashMap, B256, U256}; @@ -85,7 +85,6 @@ pub struct ProviderConfig { /// Whether to return an `Err` when a `eth_sendTransaction` fails pub bail_on_transaction_failure: bool, pub block_gas_limit: NonZeroU64, - pub cache_dir: PathBuf, pub chain_id: ChainId, pub chains: HashMap>, pub coinbase: Address, diff --git a/crates/edr_provider/src/data.rs b/crates/edr_provider/src/data.rs index 7c67810d0..5c5809cea 100644 --- a/crates/edr_provider/src/data.rs +++ b/crates/edr_provider/src/data.rs @@ -2640,7 +2640,7 @@ fn create_blockchain_and_state>( let rpc_client = Arc::new(EthRpcClient::::new( &fork_config.url, - config.cache_dir.clone(), + fork_config.cache_dir.clone(), http_headers.clone(), )?); @@ -3818,10 +3818,11 @@ mod tests { let mut fixture = ProviderTestFixture::::new_local()?; let fork_config = Some(ForkConfig { - json_rpc_url: get_alchemy_url(), + url: get_alchemy_url(), // Random recent block for better cache consistency block_number: Some(FORK_BLOCK_NUMBER), http_headers: None, + cache_dir: edr_defaults::CACHE_DIR.into(), }); let block_spec = BlockSpec::Number(FORK_BLOCK_NUMBER); @@ -3910,9 +3911,10 @@ mod tests { .build()?; let default_config = create_test_config_with_fork(Some(ForkConfig { - json_rpc_url: get_alchemy_url(), + url: get_alchemy_url(), block_number: Some(EIP_1559_ACTIVATION_BLOCK), http_headers: None, + cache_dir: edr_defaults::CACHE_DIR.into(), })); let config = ProviderConfig { diff --git a/crates/edr_provider/src/requests/hardhat/rpc_types/config.rs b/crates/edr_provider/src/requests/hardhat/rpc_types/config.rs index 10109a5c4..c3595a695 100644 --- a/crates/edr_provider/src/requests/hardhat/rpc_types/config.rs +++ b/crates/edr_provider/src/requests/hardhat/rpc_types/config.rs @@ -1,4 +1,4 @@ -use std::collections::HashMap; +use std::{collections::HashMap, path::PathBuf}; #[derive(Clone, Debug, PartialEq, serde::Deserialize, serde::Serialize)] pub struct ResetProviderConfig { @@ -12,4 +12,5 @@ pub struct ForkConfig { pub url: String, pub block_number: Option, pub http_headers: Option>, + pub cache_dir: PathBuf, } diff --git a/crates/edr_provider/src/test_utils.rs b/crates/edr_provider/src/test_utils.rs index cde842948..e9664dee7 100644 --- a/crates/edr_provider/src/test_utils.rs +++ b/crates/edr_provider/src/test_utils.rs @@ -81,7 +81,6 @@ pub fn create_test_config_with_fork( min_gas_price: U256::ZERO, mining: MiningConfig::default(), network_id: 123, - cache_dir: edr_defaults::CACHE_DIR.into(), } } @@ -170,6 +169,7 @@ impl> ProviderTestFixture anyhow::Result<()> { let subscriber = Box::new(|_event| {}); let mut config = create_test_config_with_fork(Some(ForkConfig { - json_rpc_url: get_alchemy_url().replace("mainnet", "sepolia"), + url: get_alchemy_url().replace("mainnet", "sepolia"), block_number: Some(DEPLOYMENT_BLOCK_NUMBER), http_headers: None, + cache_dir: edr_defaults::CACHE_DIR.into(), })); config.hardfork = l1::SpecId::CANCUN; diff --git a/crates/edr_provider/tests/issues/issue_356.rs b/crates/edr_provider/tests/issues/issue_356.rs index 104a7a850..960022b08 100644 --- a/crates/edr_provider/tests/issues/issue_356.rs +++ b/crates/edr_provider/tests/issues/issue_356.rs @@ -28,10 +28,11 @@ async fn issue_356() -> anyhow::Result<()> { let subscriber = Box::new(|_event| {}); let mut config = create_test_config_with_fork(Some(ForkConfig { - json_rpc_url: get_alchemy_url().replace("mainnet", "sepolia"), + url: get_alchemy_url().replace("mainnet", "sepolia"), // Pre-cancun Sepolia block block_number: Some(4243456), http_headers: None, + cache_dir: edr_defaults::CACHE_DIR.into(), })); config.hardfork = l1::SpecId::CANCUN; diff --git a/crates/edr_provider/tests/issues/issue_384.rs b/crates/edr_provider/tests/issues/issue_384.rs index 2a51616f4..b40f06236 100644 --- a/crates/edr_provider/tests/issues/issue_384.rs +++ b/crates/edr_provider/tests/issues/issue_384.rs @@ -14,9 +14,10 @@ async fn avalanche_chain_mine_local_block() -> anyhow::Result<()> { let subscriber = Box::new(|_event| {}); let config = create_test_config_with_fork(Some(ForkConfig { - json_rpc_url: get_infura_url().replace("mainnet", "avalanche-mainnet"), + url: get_infura_url().replace("mainnet", "avalanche-mainnet"), block_number: Some(BLOCK_NUMBER), http_headers: None, + cache_dir: edr_defaults::CACHE_DIR.into(), })); let provider = Provider::new( diff --git a/crates/edr_provider/tests/issues/issue_503.rs b/crates/edr_provider/tests/issues/issue_503.rs index 8875224e9..4c9f657fd 100644 --- a/crates/edr_provider/tests/issues/issue_503.rs +++ b/crates/edr_provider/tests/issues/issue_503.rs @@ -18,9 +18,10 @@ async fn issue_503() -> anyhow::Result<()> { let subscriber = Box::new(|_event| {}); let mut config = create_test_config_with_fork(Some(ForkConfig { - json_rpc_url: get_alchemy_url(), + url: get_alchemy_url(), block_number: Some(19_909_475), http_headers: None, + cache_dir: edr_defaults::CACHE_DIR.into(), })); config.hardfork = l1::SpecId::CANCUN; diff --git a/crates/edr_provider/tests/issues/issue_533.rs b/crates/edr_provider/tests/issues/issue_533.rs index 640aed920..b91807ad5 100644 --- a/crates/edr_provider/tests/issues/issue_533.rs +++ b/crates/edr_provider/tests/issues/issue_533.rs @@ -15,9 +15,10 @@ async fn issue_533() -> anyhow::Result<()> { let subscriber = Box::new(|_event| {}); let mut config = create_test_config_with_fork(Some(ForkConfig { - json_rpc_url: get_alchemy_url(), + url: get_alchemy_url(), block_number: Some(20_384_300), http_headers: None, + cache_dir: edr_defaults::CACHE_DIR.into(), })); // The default chain id set by Hardhat diff --git a/crates/edr_provider/tests/issues/issue_588.rs b/crates/edr_provider/tests/issues/issue_588.rs index 1d6801a99..ae68e8a7a 100644 --- a/crates/edr_provider/tests/issues/issue_588.rs +++ b/crates/edr_provider/tests/issues/issue_588.rs @@ -18,9 +18,10 @@ async fn issue_588() -> anyhow::Result<()> { let subscriber = Box::new(|_event| {}); let early_mainnet_fork = create_test_config_with_fork(Some(ForkConfig { - json_rpc_url: get_alchemy_url(), + url: get_alchemy_url(), block_number: Some(2_675_000), http_headers: None, + cache_dir: edr_defaults::CACHE_DIR.into(), })); let current_time_is_1970 = Arc::new(MockTime::with_seconds(0)); From a9d081d942e91d7524bc5baf65c98fcd90e9f9b1 Mon Sep 17 00:00:00 2001 From: iosh Date: Mon, 16 Dec 2024 21:23:41 +0800 Subject: [PATCH 4/4] chore: fix code styles --- crates/edr_napi/Cargo.toml | 2 +- crates/edr_napi/src/config.rs | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/crates/edr_napi/Cargo.toml b/crates/edr_napi/Cargo.toml index 1e33ff2cf..ccd33fcf2 100644 --- a/crates/edr_napi/Cargo.toml +++ b/crates/edr_napi/Cargo.toml @@ -11,6 +11,7 @@ alloy-dyn-abi = { version = "0.7.6", default-features = false, features = ["eip7 alloy-json-abi = { version = "0.7.4", default-features = false } alloy-sol-types = { version = "0.5.1", default-features = false, features = ["std"] } derive-where = { version = "1.2.7", default-features = false } +edr_defaults = { path = "../edr_defaults" } edr_eth = { path = "../edr_eth" } edr_evm = { path = "../edr_evm" } edr_generic = { path = "../edr_generic" } @@ -33,7 +34,6 @@ tracing-flame = { version = "0.2.0", default-features = false, features = ["smal tracing-subscriber = { version = "0.3.18", default-features = false, features = ["ansi", "env-filter", "fmt", "parking_lot", "smallvec", "std"] } parking_lot = { version = "0.12.1", default-features = false } lazy_static = { version = "1.4.0", features = [] } -edr_defaults = { version = "0.3.5", path = "../edr_defaults" } [target.x86_64-unknown-linux-gnu.dependencies] openssl-sys = { version = "0.9.93", features = ["vendored"] } diff --git a/crates/edr_napi/src/config.rs b/crates/edr_napi/src/config.rs index 19c1f760a..f2745ceaa 100644 --- a/crates/edr_napi/src/config.rs +++ b/crates/edr_napi/src/config.rs @@ -261,7 +261,10 @@ impl TryFrom for edr_napi_core::provider::Config { bail_on_call_failure: value.bail_on_call_failure, bail_on_transaction_failure: value.bail_on_transaction_failure, block_gas_limit, - cache_dir: value.fork.as_ref().and_then(|fork_config| fork_config.cache_dir.clone()), + cache_dir: value + .fork + .as_ref() + .and_then(|fork_config| fork_config.cache_dir.clone()), chain_id: value.chain_id.try_cast()?, chains, coinbase: value.coinbase.try_cast()?,