From cb296a67da5fabd764f9199f5f01c3fa0176c898 Mon Sep 17 00:00:00 2001 From: Waylon Jepsen Date: Mon, 16 Oct 2023 17:43:24 -0600 Subject: [PATCH] eoa forking --- bin/fork/mod.rs | 19 +++++++++++++++++++ example_fork/weth_config.toml | 5 ++++- 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/bin/fork/mod.rs b/bin/fork/mod.rs index f07c0ac9..1109e385 100644 --- a/bin/fork/mod.rs +++ b/bin/fork/mod.rs @@ -30,6 +30,7 @@ pub(crate) struct ForkConfig { block_number: u64, #[serde(rename = "contracts")] contracts_meta: HashMap, + externally_owned_accounts: Vec
, } impl ForkConfig { @@ -42,7 +43,9 @@ impl ForkConfig { .ok_or(ConfigError::NotFound("File not found!".to_owned()))?, )) .build()?; + println!("before"); let mut fork_config: ForkConfig = config.try_deserialize()?; + println!("after"); if fork_config.output_directory.is_none() { println!("No output path specified. Defaulting to current directory."); @@ -84,6 +87,22 @@ impl ForkConfig { let storage_layout = artifacts.storage_layout; digest::create_storage_layout(contract_data, storage_layout, &mut db, ethers_db)?; + + for eoa in &self.externally_owned_accounts { + let info = ethers_db + .basic(eoa.to_fixed_bytes().into()) + .map_err(|_| { + ArbiterError::DBError( + "Failed to fetch account info with + EthersDB." + .to_string(), + ) + })? + .ok_or(ArbiterError::DBError( + "Failed to fetch account info with EthersDB.".to_string(), + ))?; + db.insert_account_info(eoa.to_fixed_bytes().into(), info); + } } Ok(db) } diff --git a/example_fork/weth_config.toml b/example_fork/weth_config.toml index fdfad03d..2b719f07 100644 --- a/example_fork/weth_config.toml +++ b/example_fork/weth_config.toml @@ -4,6 +4,9 @@ output_filename = "test.json" provider = "https://eth.llamarpc.com" block_number = 18228556 +# EOAs +externally_owned_accounts = ["0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045"] # vitalik.eth as of 10/2/2023 + # Contracts stored in a mapping # Try this out with the weth contract [contracts.weth] @@ -13,4 +16,4 @@ artifacts_path = "example_fork/WETH.json" [contracts.weth.mappings] balanceOf = [ "0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045", # vitalik.eth as of 10/2/2023 -] \ No newline at end of file +]