{"record":{"id":"46f15a226208bf8d","repo":"hyperledger/fabric","slug":"failed-unmarshaling-smartbft-metadata-from-block","errorCode":null,"errorMessage":"failed unmarshaling smartbft metadata from block","messagePattern":"failed unmarshaling smartbft metadata from block","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"orderer/consensus/smartbft/verifier.go","lineNumber":286,"sourceCode":"\n\tif block.Metadata == nil || len(block.Metadata.Metadata) < len(cb.BlockMetadataIndex_name) {\n\t\treturn nil, errors.New(\"block metadata is either missing or contains too few entries\")\n\t}\n\n\tsignatureMetadata, err := protoutil.GetMetadataFromBlock(block, cb.BlockMetadataIndex_SIGNATURES)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tordererMetadataFromSignature := &cb.OrdererBlockMetadata{}\n\tif err := proto.Unmarshal(signatureMetadata.Value, ordererMetadataFromSignature); err != nil {\n\t\treturn nil, errors.Wrap(err, \"failed unmarshaling OrdererBlockMetadata\")\n\t}\n\n\t// Ensure the view metadata in the block signature and in the proposal are the same\n\n\tmetadataInBlock := &smartbftprotos.ViewMetadata{}\n\tif err := proto.Unmarshal(ordererMetadataFromSignature.ConsenterMetadata, metadataInBlock); err != nil {\n\t\treturn nil, errors.Wrap(err, \"failed unmarshaling smartbft metadata from block\")\n\t}\n\n\tmetadataFromProposal := &smartbftprotos.ViewMetadata{}\n\tif err := proto.Unmarshal(metadata, metadataFromProposal); err != nil {\n\t\treturn nil, errors.Wrap(err, \"failed unmarshaling smartbft metadata from proposal\")\n\t}\n\n\tif !proto.Equal(metadataInBlock, metadataFromProposal) {\n\t\treturn nil, errors.Errorf(\n\t\t\t\"expected metadata in block to be [view_id:%d latest_sequence:%d] but got [view_id:%d latest_sequence:%d]\",\n\t\t\tmetadataFromProposal.GetViewId(), metadataFromProposal.GetLatestSequence(),\n\t\t\tmetadataInBlock.GetViewId(), metadataInBlock.GetLatestSequence(),\n\t\t)\n\t}\n\n\trtc := v.RuntimeConfig.Load().(RuntimeConfig)\n\tlastConfig := rtc.LastConfigBlock.Header.Number\n","sourceCodeStart":268,"sourceCodeEnd":304,"githubUrl":"https://github.com/hyperledger/fabric/blob/2736b63f8fd5932511d56fe68b7039d15977f7f6/orderer/consensus/smartbft/verifier.go#L268-L304","documentation":"Inside the block's OrdererBlockMetadata, the ConsenterMetadata field must decode into the smartbft ViewMetadata proto. Failure means the SmartBFT view metadata stored in the block is not valid protobuf for the expected message, so the verifier cannot compare it against the proposal metadata.","triggerScenarios":"proto.Unmarshal(ordererMetadataFromSignature.ConsenterMetadata, metadataInBlock) errors — ConsenterMetadata is empty/garbage, or was produced by a different smartbft proto version.","commonSituations":"Nodes running mismatched smartbft library versions with different ViewMetadata schemas; consenter metadata overwritten by custom ordering-system code; corrupted proposal bytes; metadata not populated when the block was built.","solutions":["Ensure ConsenterMetadata is set to a valid marshaled smartbftprotos.ViewMetadata during block assembly","Align all cluster nodes on the same fabric/smartbft version","Log and inspect the offending ConsenterMetadata bytes to spot truncation or emptiness","Re-propose the block from a node with correct metadata"],"exampleFix":"// before\nobm.ConsenterMetadata = nil\n// after\nvm := &smartbftprotos.ViewMetadata{ViewId: seq, LatestSequence: latest}\nobm.ConsenterMetadata, _ = proto.Marshal(vm)","handlingStrategy":"validation","validationCode":"vm := &smartbftprotos.ViewMetadata{}\nif err := proto.Unmarshal(obm.ConsenterMetadata, vm); err != nil {\n    return errors.New(\"ConsenterMetadata is not a valid ViewMetadata\")\n}","typeGuard":"func validViewMetadata(b []byte) bool { return proto.Unmarshal(b, &smartbftprotos.ViewMetadata{}) == nil }","tryCatchPattern":"if _, err := verifier.VerifyProposal(...); err != nil && strings.Contains(err.Error(), \"smartbft metadata from block\") {\n    logger.Warn(\"invalid ViewMetadata in block; discarding proposal\")\n}","preventionTips":["Always set ConsenterMetadata from a marshaled smartbftprotos.ViewMetadata","Keep smartbft proto versions aligned across nodes","Guard against other components overwriting ConsenterMetadata","Validate view metadata before proposal submission"],"tags":["smartbft","fabric","protobuf","view-metadata"],"backgroundTag":"metadata-unmarshal-failed","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"}