erigon icon indicating copy to clipboard operation
erigon copied to clipboard

erigon2: eth_getBlockByHash returns incorrect miner field on matic

Open quickchase opened this issue 1 year ago • 2 comments

System information

Erigon version: erigon/2.60.9/linux-amd64/go1.22.8

Chain/Network: bor-mainnet (matic)

Expected behaviour

eth_getBlockByHash output is the same as eth_getBlockByNumber output when the block/hashes are the same block

Actual behaviour

eth_getBlockByHash returns with the miner field populated, instead of 0x0000000000000000000000000000000000000000

Steps to reproduce the behaviour

# Set your node URL
NODE=http://localhost:8545

# Get the block hash of 0x3d146d3
curl -s -H 'Content-Type: application/json' $NODE -d '{"jsonrpc":"2.0","id":1,"method":"eth_getBlockByNumber","params":["0x3d146d3",false]}' | jq '.result.hash'
"0x8d7953e6bc4c154e1b4561554effa23f17850829bdfb755d7ff6aa2b30232dc4"

# Check the miner field of 0x3d146d3
curl -s -H 'Content-Type: application/json' $NODE -d '{"jsonrpc":"2.0","id":1,"method":"eth_getBlockByNumber","params":["0x3d146d3",false]}' | jq '.result.miner'
"0x0000000000000000000000000000000000000000"

# Check the miner field of 0x3d146d3, but this time using the hash
curl -s -H 'Content-Type: application/json' $NODE -d '{"jsonrpc":"2.0","id":1,"method":"eth_getBlockByHash","params":["0x8d7953e6bc4c154e1b4561554effa23f17850829bdfb755d7ff6aa2b30232dc4",false]}' | jq '.result.miner'
"0x794e44d1334a56fea7f4df12633b88820d0c5888"

As you can see, the miner field is wrong for eth_getBlockByHash

quickchase avatar Nov 08 '24 20:11 quickchase

Happening for us as well.. for all blocks..

Fetching the block hash for block number 0x3dc03b1...
Block Hash: 0x1e3b36405cac88d4980cf5e3893f8b773a9833fee87f7e33253a773d1a08f3ed
Checking the miner field for block number 0x3dc03b1...
Miner field for block 0x3dc03b1: 0x0000000000000000000000000000000000000000
Checking the miner field for the block using its hash 0x1e3b36405cac88d4980cf5e3893f8b773a9833fee87f7e33253a773d1a08f3ed...
Miner field for block hash 0x1e3b36405cac88d4980cf5e3893f8b773a9833fee87f7e33253a773d1a08f3ed: 0xfcccd43296d9c1601a904eca9b339d94a5e5e098

cshintov avatar Nov 26 '24 16:11 cshintov

Seems like block by hash has special handling for miner field..

https://github.com/erigontech/erigon/blob/0bff9b8675ddbfa10c7aceccf658925c82789951/turbo/jsonrpc/eth_block.go#L322-L325

cshintov avatar Nov 26 '24 17:11 cshintov

This is not fixed, you guys made it worse... this change has been debated multiple times and this causes block hash validation to fail because the miner field is suppose to be 0x0

See previous discussions: https://github.com/erigontech/erigon/pull/6080

quickchase avatar Feb 12 '25 22:02 quickchase

@quickchase thanks for bringing this up - I misread your issue and thus the incorrect fix. I have opened an PR for Erigon 3, and this will be ported to Erigon 2.

However as Polygon on Erigon 2 is deprecated, you will have to compile the latest changes yourself, or upgrade to Erigon 3.

shohamc1 avatar Feb 13 '25 12:02 shohamc1