Skip to content

tracing via debug_traceCall with blockOverrides causes a previous block hash of 0 #32175

@nthpool

Description

@nthpool

System information

Geth version: v1.16.1
CL client & version: n/a
OS & Version: osx

Expected behaviour

the solidity blockhash(block.number - 1) will read the latest block hash. i.e. the block overrides are applied to the block context when it's created: vmctx := core.NewEVMBlockContext(block.Header(), api.chainContext(ctx), nil).

Actual behaviour

blockhash(block.number - 1) returns a blockhash of 0.

Steps to reproduce the behaviour

attempt to trace a contract call that uses blockhash(block.number - 1) via debug_traceCall when the block number is overridden to pending (latest + 1). blockhash(block.number - 1) will always return 0.

this behavior allows malicious contract code to detect that it's running in a simulation.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions