fixes evmc 'accountExists' definition
This commit is contained in:
parent
64f0e59487
commit
3e384f764d
|
@ -77,6 +77,9 @@ template getBlockHash*(c: Computation, blockNumber: Uint256): Hash256 =
|
|||
template accountExists*(c: Computation, address: EthAddress): bool =
|
||||
when evmc_enabled:
|
||||
c.host.accountExists(address)
|
||||
else:
|
||||
if c.fork >= FkSpurious:
|
||||
not c.vmState.readOnlyStateDB.isDeadAccount(address)
|
||||
else:
|
||||
c.vmState.readOnlyStateDB.accountExists(address)
|
||||
|
||||
|
|
|
@ -23,7 +23,11 @@ proc hostGetBlockHashImpl(ctx: Computation, number: int64): evmc_bytes32 {.cdecl
|
|||
ctx.vmState.getAncestorHash(number.u256).toEvmc()
|
||||
|
||||
proc hostAccountExistsImpl(ctx: Computation, address: var evmc_address): c99bool {.cdecl.} =
|
||||
ctx.vmState.readOnlyStateDB.accountExists(fromEvmc(address))
|
||||
let db = ctx.vmState.readOnlyStateDB
|
||||
if ctx.fork >= FkSpurious:
|
||||
not db.isDeadAccount(fromEvmc(address))
|
||||
else:
|
||||
db.accountExists(fromEvmc(address))
|
||||
|
||||
proc hostGetStorageImpl(ctx: Computation, address: var evmc_address, key: var evmc_bytes32): evmc_bytes32 {.cdecl.} =
|
||||
let storageAddr = fromEvmc(address)
|
||||
|
|
|
@ -686,11 +686,6 @@ template genCall(callName: untyped, opCode: Op): untyped =
|
|||
|
||||
let (memInPos, memInLen, memOutPos, memOutLen) = (memoryInputStartPosition.cleanMemRef, memoryInputSize.cleanMemRef, memoryOutputStartPosition.cleanMemRef, memoryOutputSize.cleanMemRef)
|
||||
|
||||
let isNewAccount = if c.fork >= FkSpurious:
|
||||
c.vmState.readOnlyStateDb.isDeadAccount(contractAddress)
|
||||
else:
|
||||
not c.accountExists(contractAddress)
|
||||
|
||||
let (memOffset, memLength) = if calcMemSize(memInPos, memInLen) > calcMemSize(memOutPos, memOutLen):
|
||||
(memInPos, memInLen)
|
||||
else:
|
||||
|
@ -699,7 +694,7 @@ template genCall(callName: untyped, opCode: Op): untyped =
|
|||
let (childGasFee, childGasLimit) = c.gasCosts[opCode].c_handler(
|
||||
value,
|
||||
GasParams(kind: opCode,
|
||||
c_isNewAccount: isNewAccount,
|
||||
c_isNewAccount: not c.accountExists(contractAddress),
|
||||
c_gasBalance: c.gasMeter.gasRemaining,
|
||||
c_contractGas: gas,
|
||||
c_currentMemSize: c.memory.len,
|
||||
|
@ -861,8 +856,7 @@ op selfDestructEip161, inline = false:
|
|||
|
||||
let
|
||||
beneficiary = c.stack.popAddress()
|
||||
stateDb = c.vmState.readOnlyStateDb
|
||||
isDead = stateDb.isDeadAccount(beneficiary)
|
||||
isDead = not c.accountExists(beneficiary)
|
||||
balance = c.getBalance(c.msg.contractAddress)
|
||||
|
||||
let gasParams = GasParams(kind: SelfDestruct,
|
||||
|
|
Loading…
Reference in New Issue