hyperledger/fabric · error
unable to retrieve block [%d]
Error message
unable to retrieve block [%d]
What it means
lastConfigBlockFromSupport tries to fetch the most recent block from the ledger (support.Block(height-1)) to locate the last configuration block. If the ledger returns nil for the last block index, it means the ledger is shorter than reported or the block cannot be read, so the etcdraft consenter cannot determine cluster endpoints and aborts. This uses pkg/errors.Errorf (formatted, with stack trace).
Source
Thrown at orderer/consensus/etcdraft/blockpuller.go:54
// EndpointconfigFromSupport extracts TLS CA certificates and endpoints from the ConsenterSupport
func EndpointconfigFromSupport(support consensus.ConsenterSupport, bccsp bccsp.BCCSP) ([]cluster.EndpointCriteria, error) {
lastConfigBlock, err := lastConfigBlockFromSupport(support)
if err != nil {
return nil, err
}
endpointconf, err := cluster.EndpointconfigFromConfigBlock(lastConfigBlock, bccsp)
if err != nil {
return nil, err
}
return endpointconf, nil
}
func lastConfigBlockFromSupport(support consensus.ConsenterSupport) (*common.Block, error) {
lastBlockSeq := support.Height() - 1
lastBlock := support.Block(lastBlockSeq)
if lastBlock == nil {
return nil, errors.Errorf("unable to retrieve block [%d]", lastBlockSeq)
}
lastConfigBlock, err := cluster.LastConfigBlock(lastBlock, support)
if err != nil {
return nil, err
}
return lastConfigBlock, nil
}
// NewBlockPuller creates a new block puller
func NewBlockPuller(support consensus.ConsenterSupport,
baseDialer *cluster.PredicateDialer,
clusterConfig localconfig.Cluster,
bccsp bccsp.BCCSP,
) (BlockPuller, error) {
verifyBlockSequence := func(blocks []*common.Block, _ string) error {
vb := cluster.BlockVerifierBuilder(bccsp)
return cluster.VerifyBlocksBFT(blocks, support.SignatureVerifier(), vb)
}View on GitHub (pinned to 2736b63f8f)
Solutions
- Inspect the orderer logs for ledger errors and verify the channel ledger files under FileLedger are intact.
- Re-sync the channel: remove the channel from the participation API and re-join (or restore from a valid snapshot).
- Check disk space and filesystem health on the orderer node; corrupted block files must be replaced from a healthy peer/orderer.
- Verify support.Height() matches the actual number of blocks retrievable; report a bug if the ledger reports a height for blocks it cannot serve.
Defensive patterns
Strategy: validation
Validate before calling
lastSeq := support.Height() - 1
if lastSeq < 0 {
return errors.New("channel ledger empty")
}
if support.Block(lastSeq) == nil {
return errors.Errorf("ledger cannot serve last block %d", lastSeq)
} Prevention
- Monitor ledger integrity and disk health on orderers
- Never hand-edit or partially copy FileLedger directories
- Restore channels from validated snapshots
When it happens
Trigger: Calling EndpointconfigFromSupport (e.g., when a chain starts or a cluster membership change requires endpoint extraction) when support.Height() > 0 but support.Block(lastBlockSeq) returns nil — e.g., ledger truncation, corruption, or a block still being committed.
Common situations: Orderer ledger files corrupted or truncated (disk issues, crash during write); height/ledger inconsistency after snapshot restore; asking for endpoint config on a channel whose ledger is not fully initialized.
Related errors
- failed to get last block
- failed to restore persisted raft data: %s
- chain is stopped
- chain is not started
- failed to process Raft Step message: %s
AI-assisted analysis of hyperledger/fabric@2736b63f8f (2026-09-04).
Data as JSON: /api/errors/983690c9b3fb7d2d.
Report an issue: GitHub.