Add missing flip256 call

This commit is contained in:
jangko 2024-06-16 08:42:24 +07:00
parent d3f6ec2e6d
commit d9d01c9f28
No known key found for this signature in database
GPG Key ID: 31702AE10541E6B9
4 changed files with 11 additions and 13 deletions

View File

@ -12,9 +12,6 @@ type
BlockNotFound* = object of EVMError
## The block with the given number/hash does not exist.
ParentNotFound* = object of EVMError
## The parent of a given block does not exist.
CanonicalHeadNotFound* = object of EVMError
## The chain has no canonical head.

View File

@ -87,7 +87,7 @@ template getBlockNumber*(c: Computation): UInt256 =
template getDifficulty*(c: Computation): DifficultyInt =
when evmc_enabled:
fromEvmc c.host.getTxContext().block_prev_randao
fromEvmc c.host.getTxContext().block_prev_randao.flip256
else:
c.vmState.difficultyOrPrevRandao
@ -99,7 +99,7 @@ template getGasLimit*(c: Computation): GasInt =
template getBaseFee*(c: Computation): UInt256 =
when evmc_enabled:
fromEvmc c.host.getTxContext().block_base_fee
fromEvmc c.host.getTxContext().block_base_fee.flip256
else:
c.vmState.blockCtx.baseFeePerGas.get(0.u256)
@ -117,7 +117,8 @@ template getOrigin*(c: Computation): EthAddress =
template getGasPrice*(c: Computation): GasInt =
when evmc_enabled:
fromEvmc(c.host.getTxContext().tx_gas_price).truncate(GasInt)
fromEvmc(c.host.getTxContext().tx_gas_price.flip256).
truncate(GasInt)
else:
c.vmState.txCtx.gasPrice
@ -135,7 +136,7 @@ template getVersionedHashesLen*(c: Computation): int =
template getBlobBaseFee*(c: Computation): UInt256 =
when evmc_enabled:
fromEvmc c.host.getTxContext().blob_base_fee
fromEvmc c.host.getTxContext().blob_base_fee.flip256
else:
c.vmState.txCtx.blobBaseFee

View File

@ -115,7 +115,7 @@ proc accountExists*(ctx: HostContext, address: EthAddress): bool =
proc getStorage*(ctx: HostContext, address: EthAddress, key: UInt256): UInt256 =
var key = toEvmc(key)
fromEvmc ctx.host.get_storage(ctx.context, address, key.addr)
fromEvmc ctx.host.get_storage(ctx.context, address, key.addr).flip256
proc setStorage*(ctx: HostContext, address: EthAddress,
key, value: UInt256): evmc_storage_status =
@ -125,7 +125,7 @@ proc setStorage*(ctx: HostContext, address: EthAddress,
ctx.host.set_storage(ctx.context, address, key.addr, value.addr)
proc getBalance*(ctx: HostContext, address: EthAddress): UInt256 =
fromEvmc ctx.host.get_balance(ctx.context, address)
fromEvmc ctx.host.get_balance(ctx.context, address).flip256
proc getCodeSize*(ctx: HostContext, address: EthAddress): uint =
ctx.host.get_code_size(ctx.context, address)
@ -159,11 +159,11 @@ proc accessAccount*(ctx: HostContext,
proc accessStorage*(ctx: HostContext, address: EthAddress,
key: UInt256): evmc_access_status =
var key = toEvmc(key)
ctx.host.access_storage(ctx.context, address, key)
ctx.host.access_storage(ctx.context, address, key.addr)
proc getTransientStorage*(ctx: HostContext, address: EthAddress, key: UInt256): UInt256 =
var key = toEvmc(key)
fromEvmc ctx.host.get_transient_storage(ctx.context, address, key.addr)
fromEvmc ctx.host.get_transient_storage(ctx.context, address, key.addr).flip256
proc setTransientStorage*(ctx: HostContext, address: EthAddress,
key, value: UInt256) =
@ -179,4 +179,4 @@ template getBlockNumber*(ctx: HostContext): uint64 =
ctx.getTxContext().block_number.uint64
template getChainId*(ctx: HostContext): uint64 =
fromEvmc(ctx.getTxContext().chain_id).truncate(uint64)
fromEvmc(ctx.getTxContext().chain_id.flip256).truncate(uint64)

View File

@ -1,5 +1,5 @@
# Nimbus
# Copyright (c) 2020-2023 Status Research & Development GmbH
# Copyright (c) 2020-2024 Status Research & Development GmbH
# Licensed under either of
# * Apache License, version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or
# http://www.apache.org/licenses/LICENSE-2.0)