Skip to content

Can not override block time when using debug_traceCall #3425

@vaigay

Description

@vaigay

System information

Geth version: v1.6.1
OS & Version: Linux

Description

  • Steps to reproduce the behaviour
    Use debug_traceCall to invoke the Solidity function getBlockTime and retrieve the current timestamp, overriding the contract’s bytecode with deployedBytecode.
    Solidity code
pragma solidity ^0.8.10;

contract TestContract {

    // return current block time
    function getBlockTime() external view returns (uint256) {
        return block.timestamp;
    }

    // return current block number
    function getBlockNumber() external view returns (uint256) {
        return block.number;
    }
}

debug_traceCall request

curl --location '${node_url}' \
--header 'Content-Type: application/json' \
--data '{
    "method": "debug_traceCall",
    "params": [
        {
            "data": "0x87ceff09",
            "from": "0x0000000000000000000000000000000000000123",
            "gas": "0x989680",
            "to": "0x0000000000000000000000000000000000000456"
        },
        {
            "blockNumber": "latest"
        },
        {
            "blockOverrides": {
                "time": "0x6900f01c"
            },
            "stateOverrides": {
                "0x0000000000000000000000000000000000000456": {
                    "code": "0x60808060405260043610156011575f80fd5b5f3560e01c90816342cbb15c14604b57506387ceff0914602f575f80fd5b346047575f3660031901126047576020604051428152f35b5f80fd5b346047575f366003190112604757602090438152f3fea2646970667358221220e7829528880307a115d058645cd271cb41b041ae2c7b547548acd9e4d893093964736f6c634300081c0033"
                }
            },
            "tracer": "callTracer",
            "tracerConfig": {
                "onlyTopCall": false,
                "withLog": true
            }
        }
    ],
    "id": 1,
    "jsonrpc": "2.0"
}'
  • Expected behaviour
    The output response should return override timestamp 6900f01c like this:
{
    "jsonrpc": "2.0",
    "id": 1,
    "result": {
        "from": "0x0000000000000000000000000000000000000123",
        "gas": "0x989680",
        "gasUsed": "0x52f3",
        "to": "0x0000000000000000000000000000000000000456",
        "input": "0x87ceff09",
        "output": "0x000000000000000000000000000000000000000000000000000000006900f01c",
        "value": "0x0",
        "type": "CALL"
    }
}

You can try to use a geth node it will return response above

  • Actual behaviour
    Response still return current block timestamp 0x6900f78d
{
    "jsonrpc": "2.0",
    "id": 1,
    "result": {
        "from": "0x0000000000000000000000000000000000000123",
        "gas": "0x989680",
        "gasUsed": "0x52f3",
        "to": "0x0000000000000000000000000000000000000456",
        "input": "0x87ceff09",
        "output": "0x000000000000000000000000000000000000000000000000000000006900f78d",
        "value": "0x0",
        "type": "CALL"
    }
}

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions