Transaction: Make `selfDestruct` use `Computation` to pass tests

When processing self destructs on the EVMC host side, it causes incorrect
`rootHash` results in some tests.  This patch fixes the results.

The cause of these results is known: `Computation` is still doing parts of
contract scope entry/exit which need to be moved to the host.  For now, as a
temporary workaround, update self destructs in `Computation` as it did before.

This makes test pass when using Nimbus EVM.  (It breaks third-party EVMs when
`SELFDESTRUCT` ops are used, although most other tests pass.)

We can't keep this as it prevents complete host/EVM separation, but it's useful
in the current code, and it's fine to develop other functionality on top.

Signed-off-by: Jamie Lokier <jamie@shareable.org>
This commit is contained in:
Jamie Lokier 2021-05-24 09:53:53 +01:00
parent b734240291
commit ce0c13c4ca
No known key found for this signature in database
GPG Key ID: CBC25C68435C30A2
1 changed files with 8 additions and 2 deletions

View File

@ -181,8 +181,14 @@ proc selfDestruct(host: TransactionHost, address, beneficiary: HostAddress) {.sh
# contract named itself as the beneficiary.
db.setBalance(address, 0.u256)
host.touchedAccounts.incl(beneficiary)
host.selfDestructs.incl(address)
# TODO: Calling via `computation` is necessary to make some tests pass.
# Here's one that passes only with this:
# tests/fixtures/eth_tests/GeneralStateTests/stRandom2/randomStatetest487.json
# We can't keep using `computation` though.
host.computation.touchedAccounts.incl(beneficiary)
host.computation.selfDestructs.incl(address)
#host.touchedAccounts.incl(beneficiary)
#host.selfDestructs.incl(address)
proc call(host: TransactionHost, msg: EvmcMessage): EvmcResult {.show.} =
echo "**** Nested call not implemented ****"