hyperledger/fabric · error

malformed orderer metadata in block

Error message

malformed orderer metadata in block

What it means

verifySignatureIsBoundToProposal successfully unmarshalled the block's SIGNATURES metadata but then failed to unmarshal signatureMetadata.Value into cb.OrdererBlockMetadata. The Value bytes inside the signature metadata are corrupt or were written by a component that does not serialize OrdererBlockMetadata correctly.

Source

Thrown at orderer/consensus/smartbft/verifier.go:433

	if err != nil {
		v.Logger.Warnf("got malformed proposal: %v", err)
		return err
	}

	// Ensure Metadata slice is of the right size
	if len(block.Metadata.Metadata) != len(cb.BlockMetadataIndex_name) {
		return errors.Errorf("block metadata is of size %d but should be of size %d",
			len(block.Metadata.Metadata), len(cb.BlockMetadataIndex_name))
	}

	signatureMetadata := &cb.Metadata{}
	if err := proto.Unmarshal(block.Metadata.Metadata[cb.BlockMetadataIndex_SIGNATURES], signatureMetadata); err != nil {
		return errors.Wrap(err, "malformed signature metadata")
	}

	ordererMDFromBlock := &cb.OrdererBlockMetadata{}
	if err := proto.Unmarshal(signatureMetadata.Value, ordererMDFromBlock); err != nil {
		return errors.Wrap(err, "malformed orderer metadata in block")
	}

	// Ensure the block's OrdererBlockMetadata matches the signature.
	if !proto.Equal(ordererMDFromBlock, ordererMD) {
		return errors.Errorf("signature's OrdererBlockMetadata and OrdererBlockMetadata extracted from block do not match")
	}

	return nil
}

type consenterVerifier struct {
	logger        *flogging.FabricLogger
	channel       string
	policyManager policies.Manager
}

// Evaluate evaluates signed data and returns no error if signature is valid and satisfies the policy
func (cv *consenterVerifier) Evaluate(signatureSet []*protoutil.SignedData) error {

View on GitHub (pinned to 2736b63f8f)

Solutions

  1. Ensure the block originates from a SmartBFT-consensus orderer of a compatible version
  2. Restore the block from a peer/other orderer or from backup
  3. Inspect the wrapped proto error to identify the malformed field
  4. If testing, fix the block-building code to serialize cb.OrdererBlockMetadata into Value

Example fix

// before: hand-crafted metadata in tests
sigMeta.Value = []byte("not-a-proto")
// after
obm := &cb.OrdererBlockMetadata{ConsenterMetadata: consenterMD}
val, _ := proto.Marshal(obm)
sigMeta.Value = val
Defensive patterns

Strategy: validation

Validate before calling

sigMD, err := protoutil.GetMetadataFromBlock(blk, cb.BlockMetadataIndex_SIGNATURES)
if err != nil { return err }
obm := &cb.OrdererBlockMetadata{}
if err := proto.Unmarshal(sigMD.Value, obm); err != nil {
    return fmt.Errorf("invalid OrdererBlockMetadata in block %d: %w", blk.Header.Number, err)
}

Type guard

func hasOrdererBlockMetadata(m *cb.Metadata) bool {
    if m == nil || len(m.Value) == 0 { return false }
    obm := &cb.OrdererBlockMetadata{}
    return proto.Unmarshal(m.Value, obm) == nil
}

Try / catch

if err := verifier.VerifyConsenterSig(blk, sig); err != nil {
    if strings.Contains(err.Error(), "malformed orderer metadata in block") {
        log.Warnf("rejecting block %d: %v", blk.Header.Number, err)
        return errRejectBlock
    }
    return err
}

Prevention

When it happens

Trigger: VerifyConsenterSig called on a block where the unmarshalled cb.Metadata.Value field is not a valid serialized cb.OrdererBlockMetadata message.

Common situations: Blocks produced by older Fabric consensus (e.g. etcdraft-style metadata) fed into a SmartBFT channel; corrupted block store; custom block producers/test harnesses writing wrong Value bytes.

Understand the failure class

Background: "cannot parse invalid wire-format data", "cannot unmarshal", "failed unmarshalling": protobuf unmarshal errors explained — this error's family across 10 libraries.

Related errors


AI-assisted analysis of hyperledger/fabric@2736b63f8f (2026-09-04). Data as JSON: /api/errors/2e28bb659a45bc20. Report an issue: GitHub.