Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Block::totalDifficulty is inconsistent between providers #311

Closed
gregorydemay opened this issue Oct 16, 2024 · 0 comments · Fixed by #312
Closed

Block::totalDifficulty is inconsistent between providers #311

gregorydemay opened this issue Oct 16, 2024 · 0 comments · Fixed by #312

Comments

@gregorydemay
Copy link
Member

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
@gregorydemay gregorydemay linked a pull request Oct 16, 2024 that will close this issue
gregorydemay added a commit that referenced this issue Oct 16, 2024
As explained in #311, the field `totalDifficulty` was removed from the
official Ethereum JSON RPC Block schema in
ethereum/execution-apis#570, leading to
inconsistent answers between providers when calling the EVM RPC canister
with `eth_getBlockByNumber`. This seems to affect all blocks and not
only post-merge blocks.

As a workaround, the EVM RPC canister no longer deserializes the field
`totalDifficulty` in the provider's JSON response and set the Candid
returned value for `evm_rpc_types::Block::totalDifficulty` always to
`None` to be backwards-compatible.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant