internet-computer-protocol / evm-rpc-canister

Interact with EVM blockchains from the Internet Computer.
https://internetcomputer.org/docs/current/developer-docs/multi-chain/ethereum/evm-rpc/overview
Apache License 2.0
63 stars 13 forks source link

`Block::totalDifficulty` is inconsistent between providers #311

Closed gregorydemay closed 3 days ago

gregorydemay commented 3 days ago

The field totalDifficulty was removed from the official Ethereum JSON RPC Block schema in https://github.com/ethereum/execution-apis/pull/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