Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
29 changes: 18 additions & 11 deletions crates/evm/core/src/backend/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -752,17 +752,24 @@ impl Backend {
self.set_caller(env.tx.caller);
self.set_spec_id(env.evm_env.cfg_env.spec);

let test_contract = match env.tx.kind {
TxKind::Call(to) => to,
TxKind::Create => {
let nonce = self
.basic_ref(env.tx.caller)
.map(|b| b.unwrap_or_default().nonce)
.unwrap_or_default();
env.tx.caller.create(nonce)
}
};
self.set_test_contract(test_contract);
// Only set test contract if it hasn't been set yet.
// In foundry-polkadot, test_contract is set early (before CREATE2 deployer) via
// explicit set_test_contract() call in runner.rs to enable PVM mode detection.
// This prevents infrastructure deployments (like CREATE2 deployer) from
// overwriting the actual test contract address.
if self.inner.test_contract.is_none() {
let test_contract = match env.tx.kind {
TxKind::Call(to) => to,
TxKind::Create => {
let nonce = self
.basic_ref(env.tx.caller)
.map(|b| b.unwrap_or_default().nonce)
.unwrap_or_default();
env.tx.caller.create(nonce)
}
};
self.set_test_contract(test_contract);
}
}

/// Executes the configured test call of the `env` without committing state changes.
Expand Down
6 changes: 3 additions & 3 deletions crates/revive-strategy/src/cheatcodes/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -641,9 +641,9 @@ impl foundry_cheatcodes::CheatcodeInspectorStrategyExt for PvmCheatcodeInspector
let (res, _call_trace, prestate_trace) = execute_with_externalities(|externalities| {
externalities.execute_with(|| {
trace::<Runtime, _, _>(|| {
// TODO: Find a way how to do it correctly
// Use pallet-revive origin to bypass EIP-3607.
let origin = OriginFor::<Runtime>::signed(Pallet::<Runtime>::account_id());
let origin = OriginFor::<Runtime>::signed(AccountId::to_fallback_account_id(
&H160::from_slice(input.caller().as_slice()),
));
let evm_value = sp_core::U256::from_little_endian(&input.value().as_le_bytes());

let (gas_limit, storage_deposit_limit) =
Expand Down
Loading