integrate evmc 'getStorage'
This commit is contained in:
parent
a4a1148a45
commit
fdbc888840
|
@ -80,6 +80,12 @@ template accountExists*(c: Computation, address: EthAddress): bool =
|
|||
else:
|
||||
c.vmState.readOnlyStateDB.accountExists(address)
|
||||
|
||||
template getStorage*(c: Computation, slot: Uint256): Uint256 =
|
||||
when evmc_enabled:
|
||||
c.host.getStorage(c.msg.contractAddress, slot)
|
||||
else:
|
||||
c.vmState.readOnlyStateDB.getStorage(c.msg.contractAddress, slot)[0]
|
||||
|
||||
proc newComputation*(vmState: BaseVMState, message: Message): Computation =
|
||||
new result
|
||||
result.vmState = vmState
|
||||
|
|
|
@ -48,7 +48,8 @@ proc getStorage*(ctx: HostContext, address: EthAddress, key: Uint256): Uint256 =
|
|||
var
|
||||
address = toEvmc(address)
|
||||
key = toEvmc(key)
|
||||
Uint256.fromEvmc ctx.host.get_storage(ctx.context, address.addr, key.addr)
|
||||
{.gcsafe.}:
|
||||
Uint256.fromEvmc ctx.host.get_storage(ctx.context, address.addr, key.addr)
|
||||
|
||||
proc setStorage*(ctx: HostContext, address: EthAddress,
|
||||
key, value: Uint256): evmc_storage_status =
|
||||
|
|
|
@ -426,15 +426,13 @@ op mstore8, inline = true, memStartPos, value:
|
|||
|
||||
op sload, inline = true, slot:
|
||||
## 0x54, Load word from storage.
|
||||
|
||||
let (value, _) = c.vmState.readOnlyStateDB.getStorage(c.msg.contractAddress, slot)
|
||||
push(value)
|
||||
push: c.getStorage(slot)
|
||||
|
||||
op sstore, inline = false, slot, value:
|
||||
## 0x55, Save word to storage.
|
||||
checkInStaticContext(c)
|
||||
|
||||
let (currentValue, existing) = c.vmState.readOnlyStateDB.getStorage(c.msg.contractAddress, slot)
|
||||
let currentValue = c.getStorage(slot)
|
||||
|
||||
let
|
||||
gasParam = GasParams(kind: Op.Sstore, s_isStorageEmpty: currentValue.isZero)
|
||||
|
@ -930,7 +928,7 @@ op sstoreEIP2200, inline = false, slot, value:
|
|||
raise newException(OutOfGas, "Gas not enough to perform EIP2200 SSTORE")
|
||||
|
||||
let stateDB = c.vmState.readOnlyStateDB
|
||||
let (currentValue, existing) = stateDB.getStorage(c.msg.contractAddress, slot)
|
||||
let currentValue = c.getStorage(slot)
|
||||
|
||||
let
|
||||
gasParam = GasParams(kind: Op.Sstore,
|
||||
|
|
Loading…
Reference in New Issue