{"record":{"id":"075e684cf1b9d6c8","repo":"hyperledger/fabric","slug":"previous-header-hash-is-s-but-expected-s","errorCode":null,"errorMessage":"previous header hash is %s but expected %s","messagePattern":"previous header hash is (.+?) but expected (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"orderer/consensus/smartbft/verifier.go","lineNumber":248,"sourceCode":"\texpectedMsgToBeSigned := util.ConcatenateBytes(sig.OrdererBlockMetadata, sig.IdentifierHeader, sig.BlockHeader, nil)\n\tsignedData := &protoutil.SignedData{\n\t\tSignature: signature.Value,\n\t\tData:      expectedMsgToBeSigned,\n\t\tIdentity:  identity,\n\t}\n\n\treturn nil, v.ConsenterVerifier.Evaluate([]*protoutil.SignedData{signedData})\n}\n\n// VerificationSequence returns verification sequence\nfunc (v *Verifier) VerificationSequence() uint64 {\n\treturn v.VerificationSequencer.Sequence()\n}\n\nfunc verifyHashChainAndDataHash(block *cb.Block, prevHeaderHash string) error {\n\tthisHdrHashOfPrevHdr := hex.EncodeToString(block.Header.PreviousHash)\n\tif prevHeaderHash != thisHdrHashOfPrevHdr {\n\t\treturn errors.Errorf(\"previous header hash is %s but expected %s\", thisHdrHashOfPrevHdr, prevHeaderHash)\n\t}\n\n\tdataHash, err := protoutil.BlockDataHash(block.Data)\n\tif err != nil {\n\t\treturn err\n\t}\n\tdataHashString := hex.EncodeToString(block.Header.DataHash)\n\n\tactualHashOfData := hex.EncodeToString(dataHash)\n\tif dataHashString != actualHashOfData {\n\t\treturn errors.Errorf(\"data hash is %s but expected %s\", dataHashString, actualHashOfData)\n\t}\n\treturn nil\n}\n\nfunc (v *Verifier) verifyBlockDataAndMetadata(block *cb.Block, metadata []byte) ([]types.RequestInfo, error) {\n\tif block.Data == nil || len(block.Data.Data) == 0 {\n\t\treturn nil, errors.New(\"empty block data\")","sourceCodeStart":230,"sourceCodeEnd":266,"githubUrl":"https://github.com/hyperledger/fabric/blob/2736b63f8fd5932511d56fe68b7039d15977f7f6/orderer/consensus/smartbft/verifier.go#L230-L266","documentation":"verifyHashChainAndDataHash compares the proposed block's Header.PreviousHash with the hash of the previous block that the verifier expects (prevHeaderHash). A mismatch means the proposed block does not continue the chain, so the proposal is invalid.","triggerScenarios":"VerifyProposal calls verifyHashChainAndDataHash with a block whose PreviousHash differs from hex-encoded hash of the prior block header, e.g. a proposal built on a stale or different chain.","commonSituations":"A node proposing while behind on blocks or diverged after a view change; competing proposals from different parents; a node resynchronizing after a crash with an older local ledger; epoch/sequence arithmetic errors after config change.","solutions":["Ensure the proposing node has the latest committed block before building the proposal","Force re-sync of the diverged node's ledger and re-propose","Check for split-brain / multiple leaders after view change; confirm the leader is the current one","Compare the block number and previous-hash of proposal vs local ledger to spot divergence"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"prevHdrHash := hex.EncodeToString(sha256Sum(lastCommittedHeader))\nif hex.EncodeToString(block.Header.PreviousHash) != prevHdrHash {\n    return errors.New(\"proposal does not extend the current chain; re-sync leader\")\n}","typeGuard":null,"tryCatchPattern":"if err := verifyHashChainAndDataHash(block, expectedPrevHash); err != nil && strings.Contains(err.Error(), \"previous header hash\") {\n    logger.Warn(\"stale/divergent proposal; requesting fresh proposal from leader\")\n}","preventionTips":["Leaders must sync to the latest committed block before proposing","Monitor ledger heights across nodes to detect divergence early","Ensure view-change logic elects a leader with the latest ledger","Compare proposal sequence and previous hash before verification"],"tags":["smartbft","fabric","hash-chain","block-proposal"],"backgroundTag":"hash-chain-mismatch","analyzedSha":"2736b63f8fd5932511d56fe68b7039d15977f7f6","analyzedAt":"2026-09-04T08:52:36.465Z","contentChangedAt":"2026-09-04T08:52:36.465Z","schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}