Skip to content

Block::totalDifficulty is inconsistent between providers #311

@gregorydemay

Description

@gregorydemay

The field totalDifficulty was removed from the official Ethereum JSON RPC Block schema in ethereum/execution-apis#570.
It seems some clients did already remove it (Erigon), but others chose not to (Nethermind), leading to inconsistent answers between providers when calling the EVM RPC canister with eth_getBlockByNumber.

Example with a recent block:

Ankr when queried for the block 0x1312d00 returns a value containing the field totalDifficulty, while the same query for PublicNode does not:

curl -s --location 'https://rpc.ankr.com/eth' \
--header 'Content-Type: application/json' \
--data '{
        "jsonrpc":"2.0",
        "method":"eth_getBlockByNumber",
        "params":[
                "0x1312d00",
                false
        ],
        "id":1
}' | jq .result.totalDifficulty
"0xc70d815d562d3cfa955"
curl -s --location 'https://ethereum.publicnode.com' \
--header 'Content-Type: application/json' \
--data '{
        "jsonrpc":"2.0",
        "method":"eth_getBlockByNumber",
        "params":[
                "0x1312d00",
                false
        ],
        "id":1
}' | jq .result.totalDifficulty

Example with an old block:

The field totalDifficulty is not only removed from blocks post-merge, but also pre-existing blocks are affected.

Ankr when queried for the block 0x0 returns a value containing the field totalDifficulty, while the same query for PublicNode does not:

curl -s --location 'https://rpc.ankr.com/eth' \
--header 'Content-Type: application/json' \
--data '{
        "jsonrpc":"2.0",
        "method":"eth_getBlockByNumber",
        "params":[
                "0x0",
                false
        ],
        "id":1
}' | jq .result.totalDifficulty
"0x400000000"
curl -s --location 'https://ethereum.publicnode.com' \
--header 'Content-Type: application/json' \
--data '{
        "jsonrpc":"2.0",
        "method":"eth_getBlockByNumber",
        "params":[
                "0x0",
                false
        ],
        "id":1
}' | jq .result.totalDifficulty

Metadata

Metadata

Assignees

No one assigned

    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