Skip to content

Commit

Permalink
eoa forking
Browse files Browse the repository at this point in the history
  • Loading branch information
0xJepsen committed Oct 16, 2023
1 parent 9af3560 commit cb296a6
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
19 changes: 19 additions & 0 deletions bin/fork/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ pub(crate) struct ForkConfig {
block_number: u64,
#[serde(rename = "contracts")]
contracts_meta: HashMap<String, ContractMetadata>,
externally_owned_accounts: Vec<Address>,
}

impl ForkConfig {
Expand All @@ -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.");
Expand Down Expand Up @@ -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)
}
Expand Down
5 changes: 4 additions & 1 deletion example_fork/weth_config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand All @@ -13,4 +16,4 @@ artifacts_path = "example_fork/WETH.json"
[contracts.weth.mappings]
balanceOf = [
"0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045", # vitalik.eth as of 10/2/2023
]
]

0 comments on commit cb296a6

Please sign in to comment.