Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(evm): use completely separated storage sections in multifork #2301

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
facf73f
refactor: completely separate fork states
mattsse Jul 13, 2022
48fa0c6
refactor: turn fuzz wrapper into cow
mattsse Jul 13, 2022
b4c05dd
refactor: add subroutine to trait
mattsse Jul 13, 2022
f034c69
feat: track subroutine
mattsse Jul 13, 2022
f0442d8
copy sender and receiver
mattsse Jul 13, 2022
91cc474
test: extend fork test
mattsse Jul 13, 2022
c293fed
fix: initialize accounts on setup
mattsse Jul 13, 2022
2ce1c4d
test: add create select test
mattsse Jul 13, 2022
0a47717
Update evm/src/executor/backend/fuzz.rs
mattsse Jul 14, 2022
55a4d6d
update docs
mattsse Jul 14, 2022
03d3a26
Merge branch 'master' into matt/use-separate-memory-sections-for-forks
mattsse Jul 14, 2022
732e690
Merge branch 'master' into matt/use-separate-memory-sections-for-forks
mattsse Jul 15, 2022
9e3ea1a
Merge branch 'master' into matt/use-separate-memory-sections-for-forks
mattsse Jul 18, 2022
6627102
fix: clone cheat code address and add traces
mattsse Jul 18, 2022
b46d191
test: add another test
mattsse Jul 18, 2022
af4b76d
Merge branch 'master' into matt/use-separate-memory-sections-for-forks
mattsse Jul 21, 2022
28f20f8
introduce persistent accounts
mattsse Jul 21, 2022
a36d697
feat: add persistent cheatcodes
mattsse Jul 21, 2022
75ae314
add persistent tests
mattsse Jul 21, 2022
60625f5
test: add persistent test
mattsse Jul 21, 2022
5ffc5b2
feat: add revert error multifork diagnostic
mattsse Jul 21, 2022
d1e4679
feat: better diagnostic
mattsse Jul 21, 2022
a3a6cdb
Merge branch 'master' into matt/use-separate-memory-sections-for-forks
mattsse Jul 23, 2022
74777a1
Merge branch 'master' into matt/use-separate-memory-sections-for-forks
mattsse Jul 24, 2022
4d9fb2e
Merge branch 'master' into matt/use-separate-memory-sections-for-forks
mattsse Jul 26, 2022
cf14878
docs
mattsse Jul 26, 2022
c41598b
Merge branch 'master' into matt/use-separate-memory-sections-for-forks
mattsse Jul 26, 2022
974d604
Merge branch 'master' into matt/use-separate-memory-sections-for-forks
mattsse Jul 27, 2022
df7ecd8
feat: fork revert diagnostic
mattsse Jul 27, 2022
2153670
Merge branch 'master' into matt/use-separate-memory-sections-for-forks
mattsse Jul 27, 2022
0cfa13e
Merge branch 'master' into matt/use-separate-memory-sections-for-forks
mattsse Jul 28, 2022
dd8acb6
test: remove uncommented left over
mattsse Jul 28, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion evm/src/executor/abi/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use std::collections::HashMap;
///
/// This is the same address as the one used in DappTools's HEVM.
/// `address(bytes20(uint160(uint256(keccak256('hevm cheat code')))))`
pub static CHEATCODE_ADDRESS: Address = H160([
pub const CHEATCODE_ADDRESS: Address = H160([
0x71, 0x09, 0x70, 0x9E, 0xcf, 0xa9, 0x1a, 0x80, 0x62, 0x6f, 0xf3, 0x98, 0x9d, 0x68, 0xf6, 0x7f,
0x5b, 0x1d, 0xd1, 0x2d,
]);
Expand Down Expand Up @@ -95,6 +95,13 @@ ethers::contract::abigen!(
createSelectFork(string)(uint256)
selectFork(uint256)
activeFork()(uint256)
makePersistent(address)
makePersistent(address,address)
makePersistent(address,address,address)
makePersistent(address[])
revokePersistent(address)
revokePersistent(address[])
isPersistent(address)(bool)
rollFork(uint256)
rollFork(uint256,uint256)
rpcUrl(string)(string)
Expand Down
45 changes: 45 additions & 0 deletions evm/src/executor/backend/diagnostic.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
use crate::{
executor::{backend::LocalForkId, inspector::Cheatcodes},
Address,
};
use foundry_common::fmt::UIfmt;

/// Represents possible diagnostic cases on revert
#[derive(Debug, Clone)]
pub enum RevertDiagnostic {
/// The `contract` does not exist on the `active` fork but exist on other fork(s)
ContractExistsOnOtherForks {
contract: Address,
active: LocalForkId,
available_on: Vec<LocalForkId>,
},
ContractDoesNotExist {
contract: Address,
active: LocalForkId,
},
}

// === impl RevertDiagnostic ===

impl RevertDiagnostic {
/// Converts the diagnostic to a readable error message
pub fn to_error_msg(&self, cheats: &Cheatcodes) -> String {
let get_label = |addr| cheats.labels.get(addr).cloned().unwrap_or_else(|| addr.pretty());

match self {
RevertDiagnostic::ContractExistsOnOtherForks { contract, active, available_on } => {
let contract_label = get_label(contract);

format!(
r#"Contract {} does not exists on active fork with id `{}`
But exists on non active forks: `{:?}`"#,
contract_label, active, available_on
)
}
RevertDiagnostic::ContractDoesNotExist { contract, .. } => {
let contract_label = get_label(contract);
format!("Contract {} does not exists", contract_label)
}
}
}
}
Loading