Skip to content

Commit

Permalink
Add check in zk create to check whether we are deploying the test con…
Browse files Browse the repository at this point in the history
…tract or not
  • Loading branch information
Jrigada committed Sep 19, 2024
1 parent d9af657 commit 2888a3c
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
17 changes: 17 additions & 0 deletions crates/cheatcodes/src/inspector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -939,6 +939,23 @@ impl Cheatcodes {
return None
}

if let Some(CreateScheme::Create) = input.scheme() {
let caller = input.caller();
let nonce = ecx
.inner
.journaled_state
.load_account(input.caller(), &mut ecx.inner.db)
.unwrap()
.0
.info
.nonce;
let address = caller.create(nonce);
if let Some(true) = ecx.db.get_test_contract_address().map(|addr| address == addr) {
info!("running create in EVM, instead of zkEVM (Test Contract) {:#?}", address);
return None
}
}

if input.init_code().0 == DEFAULT_CREATE2_DEPLOYER_CODE {
info!("running create in EVM, instead of zkEVM (DEFAULT_CREATE2_DEPLOYER_CODE)");
return None
Expand Down
2 changes: 1 addition & 1 deletion crates/script/src/runner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ impl ScriptRunner {

let address = CALLER.create(self.executor.get_nonce(CALLER)?);

self.executor.backend_mut().set_test_contract(address);
// Set the contracts initial balance before deployment, so it is available during the
// construction
self.executor.set_balance(address, self.evm_opts.initial_balance)?;
Expand All @@ -147,7 +148,6 @@ impl ScriptRunner {

// Optionally call the `setUp` function
let (success, gas_used, labeled_addresses, transactions) = if !setup {
self.executor.backend_mut().set_test_contract(address);
(true, 0, Default::default(), Some(library_transactions))
} else {
match self.executor.setup(Some(self.evm_opts.sender), address, None) {
Expand Down

0 comments on commit 2888a3c

Please sign in to comment.