-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
blockhash()
broken between nightly-2044faec
and nightly-b1e93654
#9198
Comments
on const parts = [
"0xa2f9a8897a7dd5f1a0ae653ce793b42548bf9e4401b3ec5070ac94c383caac1f",
"0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347",
"0x0000000000000000000000000000000000000000",
"0x5186dcad803ce44d801473eb727d4fecc20f759869d4a4daf3e71606c0d580bd",
"0xa4f2579787fc3ffad5e146925c46fdeda1215edb484443c8bf9bc82f3e5ebc4f",
"0xa53dd7e7f6147d1f1f6081694647a3e4057eb6553638829138c7204ef86c29a1",
"0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
"0x",
"0x04",
"0x01c9c380",
"0x0d921e",
"0x671c6817",
"0x",
"0x0000000000000000000000000000000000000000000000000000000000000000",
"0x0000000000000000",
"0x29b2d57d",
null,
"0x",
"0x",
null
];
const rlp = `0xf90200a0a2f9a8897a7dd5f1a0ae653ce793b42548bf9e4401b3ec5070ac94c383caac1fa01dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347940000000000000000000000000000000000000000a05186dcad803ce44d801473eb727d4fecc20f759869d4a4daf3e71606c0d580bda0a4f2579787fc3ffad5e146925c46fdeda1215edb484443c8bf9bc82f3e5ebc4fa0a53dd7e7f6147d1f1f6081694647a3e4057eb6553638829138c7204ef86c29a1b901000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000080048401c9c380830d921e84671c681780a000000000000000000000000000000000000000000000000000000000000000008800000000000000008429b2d57d808080`;
const hash = `0x6ba7a2ecef76fd6cefb179b9d7e469e9acb6ada08ae54809aef5b14c3d665d0a` on const parts = [
"0x0f915aef13700d93f833d79fae367fc290265667680128c4444fcf4da71049c2",
"0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347",
"0x0000000000000000000000000000000000000000",
"0x19115cf7490ca6c5d6ab3e14ec8822899ef75706e164f580ba081939fdd465c6",
"0xa4f2579787fc3ffad5e146925c46fdeda1215edb484443c8bf9bc82f3e5ebc4f",
"0xa53dd7e7f6147d1f1f6081694647a3e4057eb6553638829138c7204ef86c29a1",
"0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
"0x",
"0x04",
"0x01c9c380",
"0x0d921e",
"0x671c687e",
"0x",
"0x0000000000000000000000000000000000000000000000000000000000000000",
"0x0000000000000000",
"0x29b2d57d",
null,
"0x",
"0x",
null
];
const rlp = `0xf90200a00f915aef13700d93f833d79fae367fc290265667680128c4444fcf4da71049c2a01dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347940000000000000000000000000000000000000000a019115cf7490ca6c5d6ab3e14ec8822899ef75706e164f580ba081939fdd465c6a0a4f2579787fc3ffad5e146925c46fdeda1215edb484443c8bf9bc82f3e5ebc4fa0a53dd7e7f6147d1f1f6081694647a3e4057eb6553638829138c7204ef86c29a1b901000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000080048401c9c380830d921e84671c687e80a000000000000000000000000000000000000000000000000000000000000000008800000000000000008429b2d57d808080`;
// keccak256(rlp)
const hash1 = `0x846f24652b2f79182e55f2f6d74ab36c1b5cab6893113658f69a0bf326509cb1`;
// eth_getBlock(x).hash or blockhash(x)
const hash2 = `0xa53dd7e7f6147d1f1f6081694647a3e4057eb6553638829138c7204ef86c29a1` |
hey @adraffy do you mind sharing steps to produce such block? |
assuming that rlp you've provided corresponds to block header rlp it seems that parent hash (first element) changed between commits so would be nice to get data for the first block of the chain which ended up with different hash |
I couldn't exactly trace out the issue, but since I noticed it was wrong after running I'm not sure how to give a repo: take any non-fork anvil block, compute the blockhash, compare. Oh, let me fix the genesis timestamp and retry. |
which software are you using for calculating block hashes? |
Custom code but it just follows Ethereum Spec |
could you please share complete rpc respone for block you are getting mismatch for? |
{
"block": {
"hash": "0x0f5f17c2e499f9ce082e5e6ad62259a2521642055499b6b989b5f87748b027ce",
"parentHash": "0x61549544fe8860f5639424662e6d76481dfe116e74d00c47a5bfb9a67022e8f2",
"sha3Uncles": "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347",
"miner": "0x0000000000000000000000000000000000000000",
"stateRoot": "0x7abe738f5dfba083438b59b6b3c52f20636ab3de1b25c2b4341f1cac5e6287a7",
"transactionsRoot": "0x4a3029a969a44c52bbf6ccc8b206dd6ad17aae74ee9013acbca7e088822b3c54",
"receiptsRoot": "0x80fd06f06aac644e62bfb7a663dfe6e3f71b4f49bbeb932b5b3f935a508db9a2",
"logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
"difficulty": "0x0",
"number": "0x1",
"gasLimit": "0x1c9c380",
"gasUsed": "0x15053",
"timestamp": "0x3e9",
"totalDifficulty": "0x0",
"extraData": "0x",
"mixHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
"nonce": "0x0000000000000000",
"baseFeePerGas": "0x3b9aca00",
"blobGasUsed": "0x0",
"excessBlobGas": "0x0",
"uncles": [],
"transactions": [
"0x2b7c2ac25f2b6f03273827e3bf38615f5e1bd6b7783bcb3b3273c0b7e3d886ac"
],
"size": "0x31a"
},
"parts": [
"0x61549544fe8860f5639424662e6d76481dfe116e74d00c47a5bfb9a67022e8f2",
"0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347",
"0x0000000000000000000000000000000000000000",
"0x7abe738f5dfba083438b59b6b3c52f20636ab3de1b25c2b4341f1cac5e6287a7",
"0x4a3029a969a44c52bbf6ccc8b206dd6ad17aae74ee9013acbca7e088822b3c54",
"0x80fd06f06aac644e62bfb7a663dfe6e3f71b4f49bbeb932b5b3f935a508db9a2",
"0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
"0x",
"0x01",
"0x01c9c380",
"0x015053",
"0x03e9",
"0x",
"0x0000000000000000000000000000000000000000000000000000000000000000",
"0x0000000000000000",
"0x3b9aca00",
null,
"0x",
"0x",
null
],
"rlp": "0xf901fea061549544fe8860f5639424662e6d76481dfe116e74d00c47a5bfb9a67022e8f2a01dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347940000000000000000000000000000000000000000a07abe738f5dfba083438b59b6b3c52f20636ab3de1b25c2b4341f1cac5e6287a7a04a3029a969a44c52bbf6ccc8b206dd6ad17aae74ee9013acbca7e088822b3c54a080fd06f06aac644e62bfb7a663dfe6e3f71b4f49bbeb932b5b3f935a508db9a2b901000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000080018401c9c380830150538203e980a00000000000000000000000000000000000000000000000000000000000000000880000000000000000843b9aca00808080",
"hashFromRPC": "0x0f5f17c2e499f9ce082e5e6ad62259a2521642055499b6b989b5f87748b027ce",
"hashFromSol": "0x0f5f17c2e499f9ce082e5e6ad62259a2521642055499b6b989b5f87748b027ce",
"hashFromRLP": "0x0f5f17c2e499f9ce082e5e6ad62259a2521642055499b6b989b5f87748b027ce"
}
{
"block": {
"hash": "0x5a76af1bafbb5aaa7e1b20d0d31d2553a7916257a3c2f20399bf8c99f3395179",
"parentHash": "0xf7a835f834b91de00f38edf5a7acdd1ebfc290f712c6f93effb8833ec28de646",
"sha3Uncles": "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347",
"miner": "0x0000000000000000000000000000000000000000",
"stateRoot": "0x7abe738f5dfba083438b59b6b3c52f20636ab3de1b25c2b4341f1cac5e6287a7",
"transactionsRoot": "0x4a3029a969a44c52bbf6ccc8b206dd6ad17aae74ee9013acbca7e088822b3c54",
"receiptsRoot": "0x80fd06f06aac644e62bfb7a663dfe6e3f71b4f49bbeb932b5b3f935a508db9a2",
"logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
"difficulty": "0x0",
"number": "0x1",
"gasLimit": "0x1c9c380",
"gasUsed": "0x15053",
"timestamp": "0x3e8",
"totalDifficulty": "0x0",
"extraData": "0x",
"mixHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
"nonce": "0x0000000000000000",
"baseFeePerGas": "0x3b9aca00",
"blobGasUsed": "0x0",
"excessBlobGas": "0x0",
"uncles": [],
"transactions": [
"0x2b7c2ac25f2b6f03273827e3bf38615f5e1bd6b7783bcb3b3273c0b7e3d886ac"
],
"size": "0x319"
},
"parts": [
"0xf7a835f834b91de00f38edf5a7acdd1ebfc290f712c6f93effb8833ec28de646",
"0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347",
"0x0000000000000000000000000000000000000000",
"0x7abe738f5dfba083438b59b6b3c52f20636ab3de1b25c2b4341f1cac5e6287a7",
"0x4a3029a969a44c52bbf6ccc8b206dd6ad17aae74ee9013acbca7e088822b3c54",
"0x80fd06f06aac644e62bfb7a663dfe6e3f71b4f49bbeb932b5b3f935a508db9a2",
"0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
"0x",
"0x01",
"0x01c9c380",
"0x015053",
"0x03e8",
"0x",
"0x0000000000000000000000000000000000000000000000000000000000000000",
"0x0000000000000000",
"0x3b9aca00",
null,
"0x",
"0x",
null
],
"rlp": "0xf901fea0f7a835f834b91de00f38edf5a7acdd1ebfc290f712c6f93effb8833ec28de646a01dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347940000000000000000000000000000000000000000a07abe738f5dfba083438b59b6b3c52f20636ab3de1b25c2b4341f1cac5e6287a7a04a3029a969a44c52bbf6ccc8b206dd6ad17aae74ee9013acbca7e088822b3c54a080fd06f06aac644e62bfb7a663dfe6e3f71b4f49bbeb932b5b3f935a508db9a2b901000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000080018401c9c380830150538203e880a00000000000000000000000000000000000000000000000000000000000000000880000000000000000843b9aca00808080",
"hashFromRPC": "0x5a76af1bafbb5aaa7e1b20d0d31d2553a7916257a3c2f20399bf8c99f3395179",
"hashFromSol": "0x5a76af1bafbb5aaa7e1b20d0d31d2553a7916257a3c2f20399bf8c99f3395179",
"hashFromRLP": "0x1296f251b9bf477b924a212d877a1a5e8781fc998c97fa02945516589a7db039"
} |
hum, I fixed the genesis timestamp, what else introduces randomness into the state? |
two blocks you've linked have number 1 and different parent hashes so I guess they are still produced by chains with different genesis, you could compare the responses for block 0 |
I had deployed a contract to query
{
"block": {
"hash": "0x61549544fe8860f5639424662e6d76481dfe116e74d00c47a5bfb9a67022e8f2",
"parentHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
"sha3Uncles": "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347",
"miner": "0x0000000000000000000000000000000000000000",
"stateRoot": "0x0000000000000000000000000000000000000000000000000000000000000000",
"transactionsRoot": "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421",
"receiptsRoot": "0x0000000000000000000000000000000000000000000000000000000000000000",
"logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
"difficulty": "0x0",
"number": "0x0",
"gasLimit": "0x1c9c380",
"gasUsed": "0x0",
"timestamp": "0x3e8",
"totalDifficulty": "0x0",
"extraData": "0x",
"mixHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
"nonce": "0x0000000000000000",
"baseFeePerGas": "0x3b9aca00",
"blobGasUsed": "0x0",
"excessBlobGas": "0x0",
"uncles": [],
"transactions": [],
"size": "0x203"
},
"parts": [
"0x0000000000000000000000000000000000000000000000000000000000000000",
"0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347",
"0x0000000000000000000000000000000000000000",
"0x0000000000000000000000000000000000000000000000000000000000000000",
"0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421",
"0x0000000000000000000000000000000000000000000000000000000000000000",
"0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
"0x",
"0x",
"0x01c9c380",
"0x",
"0x03e8",
"0x",
"0x0000000000000000000000000000000000000000000000000000000000000000",
"0x0000000000000000",
"0x3b9aca00",
null,
"0x",
"0x",
null
],
"rlp": "0xf901fba00000000000000000000000000000000000000000000000000000000000000000a01dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347940000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000000a056e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421a00000000000000000000000000000000000000000000000000000000000000000b901000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000080808401c9c380808203e880a00000000000000000000000000000000000000000000000000000000000000000880000000000000000843b9aca00808080",
"hashFromRPC": "0x61549544fe8860f5639424662e6d76481dfe116e74d00c47a5bfb9a67022e8f2",
"hashFromRLP": "0x61549544fe8860f5639424662e6d76481dfe116e74d00c47a5bfb9a67022e8f2"
}
{
"block": {
"hash": "0xf7a835f834b91de00f38edf5a7acdd1ebfc290f712c6f93effb8833ec28de646",
"parentHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
"sha3Uncles": "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347",
"miner": "0x0000000000000000000000000000000000000000",
"stateRoot": "0x0000000000000000000000000000000000000000000000000000000000000000",
"transactionsRoot": "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421",
"receiptsRoot": "0x0000000000000000000000000000000000000000000000000000000000000000",
"logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
"difficulty": "0x0",
"number": "0x0",
"gasLimit": "0x1c9c380",
"gasUsed": "0x0",
"timestamp": "0x3e8",
"totalDifficulty": "0x0",
"extraData": "0x",
"mixHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
"nonce": "0x0000000000000000",
"baseFeePerGas": "0x3b9aca00",
"blobGasUsed": "0x0",
"excessBlobGas": "0x0",
"uncles": [],
"transactions": [],
"size": "0x202"
},
"parts": [
"0x0000000000000000000000000000000000000000000000000000000000000000",
"0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347",
"0x0000000000000000000000000000000000000000",
"0x0000000000000000000000000000000000000000000000000000000000000000",
"0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421",
"0x0000000000000000000000000000000000000000000000000000000000000000",
"0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
"0x",
"0x",
"0x01c9c380",
"0x",
"0x03e8",
"0x",
"0x0000000000000000000000000000000000000000000000000000000000000000",
"0x0000000000000000",
"0x3b9aca00",
null,
"0x",
"0x",
null
],
"rlp": "0xf901fba00000000000000000000000000000000000000000000000000000000000000000a01dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347940000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000000a056e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421a00000000000000000000000000000000000000000000000000000000000000000b901000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000080808401c9c380808203e880a00000000000000000000000000000000000000000000000000000000000000000880000000000000000843b9aca00808080",
"hashFromRPC": "0xf7a835f834b91de00f38edf5a7acdd1ebfc290f712c6f93effb8833ec28de646",
"hashFromRLP": "0x61549544fe8860f5639424662e6d76481dfe116e74d00c47a5bfb9a67022e8f2"
} |
I think this is likely related to alloy-rs/alloy#1524 cc @mattsse @Rjected |
however, I think alloy-rs/alloy#1524 is actually correct the only difference between header rlp between and another pov here is that this is actually incorrect for anvil to return blocks without parent beacon block root because every block should have one after cancun, this would need to be addressed |
I believe the RLP encoding for trailing nulls is special, which is why my code doesn't use |
It's the optional stuff—trailing null optionals aren't included. From what I remember, this prevents blockhashes from breaking when new fields are added. |
yep, that's how it is now. it was incorrect before on our side |
#9202 would fix the fields not being correctly set for now closing this as I believe rlp encoding is correct on our side |
I'm not sure I follow, which fields are you saying are optional? I can only replicate the hash in |
I think my code is also wrong as I was saying an optional RLP encoded integer |
I'd recommend to just wait for the next nightly, it should fix the encoding |
geth says: // BaseFee was added by EIP-1559 and is ignored in legacy headers.
BaseFee *big.Int `json:"baseFeePerGas" rlp:"optional"`
// WithdrawalsHash was added by EIP-4895 and is ignored in legacy headers.
WithdrawalsHash *common.Hash `json:"withdrawalsRoot" rlp:"optional"`
// BlobGasUsed was added by EIP-4844 and is ignored in legacy headers.
BlobGasUsed *uint64 `json:"blobGasUsed" rlp:"optional"`
// ExcessBlobGas was added by EIP-4844 and is ignored in legacy headers.
ExcessBlobGas *uint64 `json:"excessBlobGas" rlp:"optional"`
// ParentBeaconRoot was added by EIP-4788 and is ignored in legacy headers.
ParentBeaconRoot *common.Hash `json:"parentBeaconBlockRoot" rlp:"optional"`
// RequestsHash was added by EIP-7685 and is ignored in legacy headers.
RequestsHash *common.Hash `json:"requestsRoot" rlp:"optional"` {
"block": {
"hash": "0xf3fb8013ae5e20cfed8ae36e77367d3cbdc51ccf9fa95d6763fd5f895bd8122d",
"parentHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
"sha3Uncles": "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347",
"miner": "0x0000000000000000000000000000000000000000",
"stateRoot": "0x0000000000000000000000000000000000000000000000000000000000000000",
"transactionsRoot": "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421",
"receiptsRoot": "0x0000000000000000000000000000000000000000000000000000000000000000",
"logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
"difficulty": "0x0",
"number": "0x0",
"gasLimit": "0x1c9c380",
"gasUsed": "0x0",
"timestamp": "0x671d4f54",
"totalDifficulty": "0x0",
"extraData": "0x",
"mixHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
"nonce": "0x0000000000000000",
"baseFeePerGas": "0x3b9aca00",
"blobGasUsed": "0x0",
"excessBlobGas": "0x0",
"uncles": [],
"transactions": [],
"size": "0x204"
},
"parts": [
"0x0000000000000000000000000000000000000000000000000000000000000000",
"0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347",
"0x0000000000000000000000000000000000000000",
"0x0000000000000000000000000000000000000000000000000000000000000000",
"0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421",
"0x0000000000000000000000000000000000000000000000000000000000000000",
"0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
"0x",
"0x",
"0x01c9c380",
"0x",
"0x671d4f54",
"0x",
"0x0000000000000000000000000000000000000000000000000000000000000000",
"0x0000000000000000",
"0x3b9aca00", // baseFeePerGas
null, // withdrawalsRoot
"0x", // blobGasUsed
null, // excessBlobGas
null, // parentBeaconBlockRoot
null // requestsRoot
],
"hashFromRPC": "0xf3fb8013ae5e20cfed8ae36e77367d3cbdc51ccf9fa95d6763fd5f895bd8122d",
"hashFromRLP": "0xf3fb8013ae5e20cfed8ae36e77367d3cbdc51ccf9fa95d6763fd5f895bd8122d"
} I can only match this blockhash if I say |
Does that correctly handle |
in in but in both cases, those last 6 fields are optional, and only The alloy code looks wrong, as must encode up to the last valued optional, and |
it does,
with #9202 it would get fixed because |
if I don't see how the alloy code does that with separate if statements? |
where is this requirement from? for Ethereum blocks it is not possible to have |
this code will indeed encode null pointers as 0x80. however, rlp does not define encoding for None/null and geth's rlp implementation will decode it is not possible to have a block which will get encoded like this because all trailing fields appear in order of corresponding hardforks being activated |
I guess my point is that:
The last 6 values of block header encoding are optional. if
|
[0, 0, 0] must be encoded as the only way to get "" is |
the issue is that anvil produces incorrect blocks with latest fields being |
I'm still not sure I follow: if the struct is [req, req, opt, opt]
The length of list is up to the last non-zero optional. Trailing optionals are dropped. Possibly I am misreading the go code? |
yep, in this case it means that the length is up to the last non-nil pointer. if pointer points to 0 it will not be dropped |
So if the last 6 values are optional: in in I find the geth rlp code nearly unreadable, so I'm not sure if an optional integer of 0 is considered null, however, it seems like both of these could be encoded as just |
there is only 1 way to correctly encode a well-formed block header in rlp and per specification and it is to encode 0's as 0x80 and skip trailing nil's header with nil followed by non-nil fields is not well-formed |
I'm confused then, doesn't my original issue describe the problem? The blockhash in And |
the root issue is that anvil produced invalid blocks with |
Thanks for the help. I guess the confusion here is that I'm using And you're saying the blockhash calculation was wrong in |
Component
Anvil
Have you ensured that all of these are up to date?
What version of Foundry are you on?
No response
What command(s) is the bug in?
anvil
Operating System
None
Describe the bug
foundryup -v nightly-2044faec64f99a21f0e5f0094458a973612d0712
blockhash(x) == keccak256(rlpEncodeBlock(x))
foundryup -v nightly-b1e93654348a0f31effa34790adae18865b14aa8
blockhash(x) != keccak256(rlpEncodeBlock(x))
The text was updated successfully, but these errors were encountered: