Skip to content

Commit

Permalink
Fix test 'failed_tx_xcf416c53' for London hard fork
Browse files Browse the repository at this point in the history
  • Loading branch information
mrLSD committed Jun 6, 2024
1 parent f6ab3bf commit 17b9b31
Showing 1 changed file with 18 additions and 3 deletions.
21 changes: 18 additions & 3 deletions evm-tests/jsontests/src/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1078,6 +1078,23 @@ fn test_run(
let (values, logs) = executor.into_state().deconstruct();

backend.apply(values, logs, delete_empty);
// It's special case for hard forks: London or before London
// According to EIP-160 empty account should be removed. But in that particular test - original test state
// contains account 0x03 (it's precompile), and when precompile 0x03 was called it exit with
// OutOfGas result. And after exit of substate account not marked as touched, as exit reason
// is not success. And it mean, that it don't appeared in Apply::Modify, then as untouched it
// can't be removed by backend.apply event. In that particular case we should manage it manually.
// NOTE: it's not realistic situation for real life flow.
if *spec <= ForkSpec::London && delete_empty && name == "failed_tx_xcf416c53" {
let state = backend.state_mut();
state.retain(|addr, account| {
// Check is account empty for precompile 0x03
!(addr == &H160::from_low_u64_be(3)
&& account.balance == U256::zero()
&& account.nonce == U256::zero()
&& account.code.is_empty())
});
}
} else {
if let Some(e) = state.expect_exception.as_ref() {
panic!("unexpected exception: {e} for test {name}-{i}");
Expand Down Expand Up @@ -1114,9 +1131,7 @@ fn test_run(
let balance = acc.balance.to_string();

println!(
"{:?}: {{\n balance: {}\n code: {:?}\n nonce: {}\n storage: {:#?}\n}}",
addr,
balance,
"{addr:?}: {{\n balance: {balance}\n code: {:?}\n nonce: {}\n storage: {:#?}\n}}",
hex::encode(acc.code),
acc.nonce,
acc.storage
Expand Down

0 comments on commit 17b9b31

Please sign in to comment.