question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Block header hash calculated not properly

See original GitHub issue

Can’t reproduce block hash calculation:

{ number: 200,
  hash: '0xc9e562b66933fb390bc935c046eac4223c47f338bc666c4debde94778c2c7534',
  parentHash: '0x51c9c3fb1d99d7fe9a66e57235983ac5e4d0954032ace9408b28a6754d5efd63',
  mixHash: '0x0000000000000000000000000000000000000000000000000000000000000000',
  nonce: '0x0000000000000000',
  sha3Uncles: '0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347',
  logsBloom: '0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',
  transactionsRoot: '0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421',
  stateRoot: '0x2037312fee597a6aef9529de0bbf7c00a2688994d23530c4669fe4a18fe3522a',
  receiptsRoot: '0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421',
  miner: '0x0000000000000000000000000000000000000000',
  difficulty: 0,
  totalDifficulty: 0,
  extraData: '0x',
  size: 1000,
  gasLimit: 17592186044415,
  gasUsed: 0,
  timestamp: 1543577953,
  transactions: [],
  uncles: [] }

Here is raw BlockHeader constructed with ethereumjs-block/blockFromRpc:

[ <Buffer 51 c9 c3 fb 1d 99 d7 fe 9a 66 e5 72 35 98 3a c5 e4 d0 95 40 32 ac e9 40 8b 28 a6 75 4d 5e fd 63>,
  <Buffer 1d cc 4d e8 de c7 5d 7a ab 85 b5 67 b6 cc d4 1a d3 12 45 1b 94 8a 74 13 f0 a1 42 fd 40 d4 93 47>,
  <Buffer 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00>,
  <Buffer 20 37 31 2f ee 59 7a 6a ef 95 29 de 0b bf 7c 00 a2 68 89 94 d2 35 30 c4 66 9f e4 a1 8f e3 52 2a>,
  <Buffer 56 e8 1f 17 1b cc 55 a6 ff 83 45 e6 92 c0 f8 6e 5b 48 e0 1b 99 6c ad c0 01 62 2f b5 e3 63 b4 21>,
  <Buffer 56 e8 1f 17 1b cc 55 a6 ff 83 45 e6 92 c0 f8 6e 5b 48 e0 1b 99 6c ad c0 01 62 2f b5 e3 63 b4 21>,
  <Buffer 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ... >,
  <Buffer >,
  <Buffer c8>,
  <Buffer 0f ff ff ff ff ff>,
  <Buffer >,
  <Buffer 5c 01 21 61>,
  <Buffer >,
  <Buffer 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00>,
  <Buffer 00 00 00 00 00 00 00 00> ]

And hash of this raw data (utils.rlphash(block.header.raw)):

0xf579b522fd8e0f024333c6af3df45061501dd5efa37b553c532cfd5ed89d0035

is not equal to original block hash:

0xc9e562b66933fb390bc935c046eac4223c47f338bc666c4debde94778c2c7534

Related to https://github.com/ethereumjs/ethereumjs-block/issues/2#issuecomment-443178876

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

3reactions
vpulimcommented, Dec 1, 2018

@davidmurdoch No problem!

https://github.com/trufflesuite/ganache-core/pull/238

I’ll submit another PR to ganache-cli that uses the latest version of ganache-core once this fix is released.

0reactions
k06acommented, Dec 1, 2018

@vpulim thanks!

@davidmurdoch hope for soon release with bug fix 😃

Read more comments on GitHub >

github_iconTop Results From Across the Web

Block header hash calculated not properly · Issue #237 - GitHub
I think I discovered the problem. ganache-core is using a very old version of ethereumjs-block (1.2.2). There was a bug fix in 2.0.0...
Read more >
block-header hash verification - Ethereum Stack Exchange
Below are the steps to calculate blockHash, given a blockNumber: ... I was able to re-calculate block header hash correctly in ETH main...
Read more >
Understanding the Bitcoin Blockchain Header - Medium
A valid block is one whose block header hashes to a number that is less than or equal to a number set by...
Read more >
7. The Blockchain - Mastering Bitcoin [Book] - O'Reilly
The resulting 32-byte hash is called the block hash but is more accurately the block header hash, because only the block header is...
Read more >
Block hashing algorithm - Bitcoin Wiki
When mining bitcoin, the hashcash algorithm repeatedly hashes the block header while incrementing the counter & extraNonce fields. Incrementing ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found