silkworm icon indicating copy to clipboard operation
silkworm copied to clipboard

Incorrect incarnation number for an re-created account

Open chfast opened this issue 1 year ago • 0 comments

Silkworm is failing the CREATE2 - recreate EEST test in variant recreate_on_separate_block=True.

The scenario is like this:

  1. Block 1
    1. Create account X with CREATE2 (incarnation 1)
    2. Set X storage [0] = 1
  2. Block 2
    1. Selfdestruct X
    2. Send value 1 to X
  3. Block 3
    1. Create account X with CREATE2 (incarnation 2).

In the final state the X should have empty storage. However, it has [0] == 1 because the incarnation number for the second CREATE2 is incorrectly 1.

This bug don't happen when the transaction 3.1 is in block 2 (same where selfdestruct happens): recreate_on_separate_block=False.

It seems we don't properly remember the X's prev_incarnation at the end of block 2. Formally, the account exist is not empty but has not been created with IntraBlockState::create_contract.

I tried to also keep prev_incarnation of "current" accounts in InMemoryState::update_account, but this didn't fix the problem.

chfast avatar Oct 23 '24 11:10 chfast