blockchainibm-blockchainhyperledger-explorer

Hyperledger Explorer seems to display incorrect block hash


I am using Hyperledger Explorer against Hyperledger Composer's fabric (v1.0.4), and can consequently view the block data. However they seem incorrect, for example:

#2 hash:     38afae3941a400149c8508f7d8e4a26bf938cf60dd3a6f4be602ec829f7115fd
   previous: e4617a6446d30628b723206d3f0a0e61308e08dc5eef502bb4c87d228c1c4d10

#1 hash:     5db250d70a874db0fbe186b8c39f28b41d17cab09d5515284688844b8834ca19
   previous: 3f9cb6a6c20d50b0c9908cfc9505832a30a39f253ba70409a7cb1b2b948ffd48

#0 hash:     abc8d27b021ae9636ae379926a5a1a14b96fe9f4a04d9653c72a935c43bd087e
   previous: (none indeed)

Each block's previous hash does not match the previous block's hash. Do you observe the same? Is it a misintrepretation of what data_hash is?

Thanks!


Solution

  • Looking inside the structure of a block,

    {
      header: {
        number: {}, 
        previous_hash: "e4617a6446d30628b723206d3f0a0e61308e08dc5eef502bb4c87d228c1c4d10", 
        data_hash: "38afae3941a400149c8508f7d8e4a26bf938cf60dd3a6f4be602ec829f7115fd"
      }, 
      data: {
        data: []
      }, 
      metadata: {
        metadata: []
      }
    }
    

    data_hash is calculated only with the data object of the current block and written at its header. Must not be confused with the currentBlockHash.

    currentBlockHash A block hash is calculated by hashing over the concatenated ASN.1 encoded bytes of: the block number, previous block hash, and current block data hash. It's the chain of the block hashs that guarantees the immutability of the ledger

    https://fabric-sdk-node.github.io/global.html#BlockchainInfo__anchor

    The currentBlockHash will be the previousBlockHash at the next block.