design icon indicating copy to clipboard operation
design copied to clipboard

EEI: add isAccountEmpty method

Open s1na opened this issue 5 years ago • 4 comments

This method is required for metering CALL in runevm/evm2ewasm (#138 and https://github.com/axic/runevm/issues/18 for some context), and can also be used in implementingEXTCODEHASH (without adding an additional method to EEI).

I believe #112 could alternatively also solve this problem. I'm not sure however what's the consensus on that.

s1na avatar Apr 11 '19 07:04 s1na

How about accountState, which returns:

  • 0: empty
  • 1: external (exists, but has no code)
  • 2: contract (exists, but has code)
  • 3: evicted (state-rent, this is the state before it is fully pruned?)

@chfast what do you think?

axic avatar May 29 '19 09:05 axic

@s1na cannot you emulate this feature by externalBalance() != 0 || extcodeHash() != 0 ?

axic avatar May 29 '19 09:05 axic

Hm, perhaps we just need to implement #183, because that brings in EXTCODEHASH which supposed to be able to tell if an account exists: https://eips.ethereum.org/EIPS/eip-1052

axic avatar May 29 '19 09:05 axic

  1. In EVMC it is called account_exists() although it works the same as described here.
  2. You will need it to price CALL and SELFDESTRUCT.
  3. In theory you can use that to implement EXTCODEHASH by hashing the code in the VM, but EXTCODEHASH assumes the hash is already known in the state and no hashing is required.
  4. I'm rather for adding simple method as proposed here.

Returning all account information at once was proposed here:

  • https://github.com/ewasm/design/issues/112
  • https://github.com/ethereum/evmc/issues/124

chfast avatar May 29 '19 09:05 chfast