mirror of
https://github.com/status-im/nimbus-eth1.git
synced 2025-01-12 13:24:21 +00:00
fix t8n does not support BLOCKHASH opcode
This commit is contained in:
parent
05584a21b9
commit
ed518c760f
@ -9,7 +9,7 @@
|
||||
# according to those terms.
|
||||
|
||||
import
|
||||
".."/[db/accounts_cache],
|
||||
".."/[db/accounts_cache, constants],
|
||||
"."/[code_stream, memory, message, stack, state],
|
||||
"."/[transaction_tracer, types],
|
||||
./interpreter/[gas_meter, gas_costs, op_codes],
|
||||
@ -113,11 +113,25 @@ template getGasPrice*(c: Computation): GasInt =
|
||||
else:
|
||||
c.vmState.txGasPrice
|
||||
|
||||
template getBlockHash*(c: Computation, blockNumber: UInt256): Hash256 =
|
||||
proc getBlockHash*(c: Computation, number: UInt256): Hash256 =
|
||||
when evmc_enabled:
|
||||
c.host.getBlockHash(blockNumber)
|
||||
let
|
||||
blockNumber = c.host.getTxContext().block_number.u256
|
||||
ancestorDepth = blockNumber - number - 1
|
||||
if ancestorDepth >= constants.MAX_PREV_HEADER_DEPTH:
|
||||
return
|
||||
if number >= blockNumber:
|
||||
return
|
||||
c.host.getBlockHash(number)
|
||||
else:
|
||||
c.vmState.getAncestorHash(blockNumber.vmWordToBlockNumber)
|
||||
let
|
||||
blockNumber = c.vmState.blockNumber
|
||||
ancestorDepth = blockNumber - number - 1
|
||||
if ancestorDepth >= constants.MAX_PREV_HEADER_DEPTH:
|
||||
return
|
||||
if number >= blockNumber:
|
||||
return
|
||||
c.vmState.getAncestorHash(number.vmWordToBlockNumber)
|
||||
|
||||
template accountExists*(c: Computation, address: EthAddress): bool =
|
||||
when evmc_enabled:
|
||||
|
@ -94,13 +94,6 @@ proc getTxContext*(ctx: HostContext): nimbus_tx_context {.inline.} =
|
||||
ctx.host.get_tx_context(ctx.context)
|
||||
|
||||
proc getBlockHash*(ctx: HostContext, number: UInt256): Hash256 =
|
||||
let
|
||||
blockNumber = ctx.getTxContext().block_number.u256
|
||||
ancestorDepth = blockNumber - number - 1
|
||||
if ancestorDepth >= constants.MAX_PREV_HEADER_DEPTH:
|
||||
return
|
||||
if number >= blockNumber:
|
||||
return
|
||||
ctx.host.get_block_hash(ctx.context, number.truncate(int64))
|
||||
|
||||
proc accountExists*(ctx: HostContext, address: EthAddress): bool {.inline.} =
|
||||
|
@ -309,12 +309,6 @@ when defined(geth):
|
||||
import db/geth_db
|
||||
|
||||
method getAncestorHash*(vmState: BaseVMState, blockNumber: BlockNumber): Hash256 {.base, gcsafe, raises: [Defect,CatchableError,Exception].} =
|
||||
var ancestorDepth = vmState.blockNumber - blockNumber - 1
|
||||
if ancestorDepth >= MAX_PREV_HEADER_DEPTH:
|
||||
return
|
||||
if blockNumber >= vmState.blockNumber:
|
||||
return
|
||||
|
||||
let db = vmState.com.db
|
||||
when defined(geth):
|
||||
result = db.headerHash(blockNumber.truncate(uint64))
|
||||
|
Loading…
x
Reference in New Issue
Block a user