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

The block hash from web3 RPC is different from the one generated by using the block header information returned by web3 RPC on the Rinkeby network #23512

Closed
yytyy1 opened this issue Aug 31, 2021 · 1 comment
Labels

Comments

@yytyy1
Copy link

yytyy1 commented Aug 31, 2021

System information

Geth version: geth v1.10.8
OS & Version: Windows/Linux
Network: rinkeby
Node: infura

Expected behaviour

The block hash from web3 RPC is same as the one generated by using the block header information returned by web3 RPC

Actual behaviour

The block hash from web3 RPC is different from the one generated by using the block header information returned by web3 RPC

Steps to reproduce the behaviour

e.g., in a block with a block number 9204314, the block hash from web3 rpc is 0xb339bd0b82a47e8d072c11aace1119099c137ad819b47ee342ef001577a91539,
but the one generated by types.block.Hash() is 0xa30d74603c598be4f2cdebb68cca2aab4ec3efa50169993e3ee5a32bc2c82a61
The golang example is below:

	client, err := ethclient.Dial("https://rinkeby.infura.io/v3/<PROJECT ID>")
	if err != nil {
		log.Fatal(err)
		return
	}
	block, err := client.BlockByNumber(context.TODO(), big.NewInt(9204314)) 
	if err != nil {
		log.Fatal(err)
		return
	}
	fmt.Printf("block number: %v, block hash: %v, parent hash: %v", block.Number().String(), block.Hash().String(), block.ParentHash().String())

block.Hash() call the header.Hash() to generate the block hash at the first time.
The log is below:
block number: 9204314, block hash: 0xa30d74603c598be4f2cdebb68cca2aab4ec3efa50169993e3ee5a32bc2c82a61, parent hash: 0x636455431c7f50ca5867a5bd63a0a8f12aa731c235ae963d8d5f5169f4cd47b3
If the requested block height is 9204315, then the outpu is below:
block number: 9204315, block hash: 0x412dd0cfde7eff5b2944b130158cffcd0e81c7e2b8c0b09007bfe736bcb18fbf, parent hash: 0xb339bd0b82a47e8d072c11aace1119099c137ad819b47ee342ef001577a91539
The parent hash in the block number 9204315 is same as the block hash from web3 rpc and Etherscan in the block number 9204314, but is different from the one generated by types.block.Hash() in the block number 9204314.
web3 RPC response is below with the block number 9204314:

{
    "jsonrpc": "2.0",
    "id": 1,
    "result": {
        "baseFeePerGas": "0xa",
        "difficulty": "0x1",
        "extraData": "0xd883010a09846765746888676f312e31362e37856c696e757800000000000000dce10f4248e9e16dadd77b4e4cd843c97593cd77cf0a1d9bff115b415584a1737bda42c977bd25ad14d6ba034c420be13855196793fef816c7ab303ed26e69df01",
        "gasLimit": "0x1c9c380",
        "gasUsed": "0x35e205",
        "hash": "0xb339bd0b82a47e8d072c11aace1119099c137ad819b47ee342ef001577a91539",
        "logsBloom": "0x00a40042400000004480044082800850208800000420820010000000648402008000002000000010100280240200000000100000024104a0020000420034008028008cc1584000802100000802080020000000020000900000008400000880018080e8c402000c012200440000000800810082001664000042001030000080002000080020104020000040020020001000008000000000080000004148002004020043901008240110000004008824064800000041804201010000000000450010008206220000010000010000000800880010000000001200001800001068000010085080040c40004080000000000800008100008020180000000000940000",
        "miner": "0x7ffc57839b00206d1ad20c69a1981b489f772031",
        "mixHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
        "nonce": "0x0000000000000000",
        "number": "0x8c725a",
        "parentHash": "0x636455431c7f50ca5867a5bd63a0a8f12aa731c235ae963d8d5f5169f4cd47b3",
        "receiptsRoot": "0x87ca355fc3ef226975eeea4af06f9526961fe96632c2302f0cf8825cb907a383",
        "sha3Uncles": "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347",
        "size": "0x304a",
        "stateRoot": "0x84a995e71dd0ade677f32e7143b608ab9354ab1cc09f8d589fea210d4fe21c69",
        "timestamp": "0x612c820d",
        "totalDifficulty": "0xee3415",
        "transactions": [
         “...”
        ],
        "transactionsRoot": "0xbcad791650a2acb94b0eb6a6021d868b0afd8a616d9f633ada668c0f6d6db223",
        "uncles": []
    }
}

note: this exception only appears in rinkeby

@holiman
Copy link
Contributor

holiman commented Sep 2, 2021

This was fixed by #23466, will be included in the next release v1.10.9

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants