{"record":{"id":"98d981380b8e5469","repo":"hyperledger/fabric","slug":"the-supplied-bytes-are-not-of-genesis-block-block","errorCode":null,"errorMessage":"The supplied bytes are not of genesis block. blockNum=%d, blockHash=%x","messagePattern":"The supplied bytes are not of genesis block\\. blockNum=(.+?), blockHash=%x","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"common/ledger/blkstorage/reset.go","lineNumber":118,"sourceCode":"\n\tif err := assertIsGenesisBlock(genesisBlockBytes); err != nil {\n\t\treturn \"\", -1, err\n\t}\n\t// just for an extra safety make a backup of genesis block\n\tif err := os.WriteFile(path.Join(ledgerDir, \"__backupGenesisBlockBytes\"), genesisBlockBytes, 0o640); err != nil {\n\t\treturn \"\", -1, err\n\t}\n\tlogger.Infof(\"Genesis block backed up. Genesis block info file [%s], offset [%d]\", blockfilePath, endOffsetGenesisBlock)\n\treturn blockfilePath, endOffsetGenesisBlock, nil\n}\n\nfunc assertIsGenesisBlock(blockBytes []byte) error {\n\tblock, err := deserializeBlock(blockBytes)\n\tif err != nil {\n\t\treturn err\n\t}\n\tif block.Header.Number != 0 || block.Header.GetDataHash() == nil {\n\t\treturn fmt.Errorf(\"The supplied bytes are not of genesis block. blockNum=%d, blockHash=%x\", block.Header.Number, block.Header.GetDataHash())\n\t}\n\treturn nil\n}\n\nfunc pathExists(path string) (bool, error) {\n\t_, err := os.Stat(path)\n\tif os.IsNotExist(err) {\n\t\treturn false, nil\n\t}\n\tif err != nil {\n\t\treturn false, err\n\t}\n\treturn true, nil\n}\n\nconst (\n\tfileNamePreRestHt = \"__preResetHeight\"\n)","sourceCodeStart":100,"sourceCodeEnd":136,"githubUrl":"https://github.com/hyperledger/fabric/blob/2736b63f8fd5932511d56fe68b7039d15977f7f6/common/ledger/blkstorage/reset.go#L100-L136","documentation":"assertIsGenesisBlock verifies that bytes supplied to a rollback/restore path (via retrieveGenesisBlkOffsetAndMakeACopy) actually serialize to a block whose header number is 0 and whose data hash is non-nil. If not, it throws \"The supplied bytes are not of genesis block. blockNum=%d, blockHash=%x\" so the ledger file reset does not copy a wrong block as the genesis anchor.","triggerScenarios":"Calling the rollback/restore flow and providing a block file or byte range that is not the genesis block: offset points to block 1+, the ledger dir contains no genesis block, or the file was overwritten/truncated so deserialization yields a non-zero block number.","commonSituations":"Rollback (peer node rollback) run against a ledger whose first block file no longer holds block 0 (earlier truncation, cleanup of old files), pointing the tool at the wrong channel/ledger directory, or corrupted genesis record.","solutions":["Confirm you are rolling back the correct ledger directory/channel and that the genesis block (block 0) file is present and intact.","Restore the genesis block from a backup or snapshot before retrying the rollback/restore.","If the ledger is unrecoverable, reset the ledger and re-join/re-sync the channel from peers."],"exampleFix":"// before\npeer node rollback --channelID mychannel --blockNumber 100 // ledger dir missing block 0 file\n// after\nrestore the earliest blockfile containing the genesis block, then:\npeer node rollback --channelID mychannel --blockNumber 100","handlingStrategy":"validation","validationCode":"block, err := deserializeBlock(blockBytes)\nif err != nil {\n    return err\n}\nif block.Header.Number != 0 || block.Header.GetDataHash() == nil {\n    return fmt.Errorf(\"refusing rollback: bytes are block %d, not genesis\", block.Header.Number)\n}","typeGuard":null,"tryCatchPattern":"if err := assertIsGenesisBlock(blockBytes); err != nil {\n    var numErr *fmt.NumError\n    _ = numErr\n    return fmt.Errorf(\"aborting rollback: %w\", err)\n}","preventionTips":["Never delete or prune the earliest block file containing block 0.","Verify you target the correct channel's ledger directory before rollback.","Keep a verified backup that includes the genesis block.","After any truncation/cleanup, confirm block 0 is still readable before running restore operations."],"tags":["ledger","rollback","genesis-block"],"backgroundTag":"genesis-block-missing","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"}