Skip to content

Commit 7aae799

Browse files
committed
[FAB-5450] Log genesis block hash while boostrapping
Change-Id: Iee0189272d332690443ba1cf2f449325033f0b14 Signed-off-by: Jay Guo <guojiannan1101@gmail.com>
1 parent 5101b9e commit 7aae799

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

orderer/common/multichannel/registrar.go

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import (
1919
"github.com/hyperledger/fabric/orderer/common/msgprocessor"
2020
"github.com/hyperledger/fabric/orderer/consensus"
2121
cb "github.com/hyperledger/fabric/protos/common"
22+
ab "github.com/hyperledger/fabric/protos/orderer"
2223
"github.com/hyperledger/fabric/protos/utils"
2324
"github.com/op/go-logging"
2425

@@ -107,7 +108,19 @@ func NewRegistrar(ledgerFactory ledger.Factory, consenters map[string]consensus.
107108
signer)
108109
r.templator = msgprocessor.NewDefaultTemplator(chain)
109110
chain.Processor = msgprocessor.NewSystemChannel(chain, r.templator, msgprocessor.CreateSystemChannelFilters(r, chain))
110-
logger.Infof("Starting with system channel %s and orderer type %s", chainID, chain.SharedConfig().ConsensusType())
111+
112+
// Retrieve genesis block to log its hash. See FAB-5450 for the purpose
113+
iter, pos := rl.Iterator(&ab.SeekPosition{Type: &ab.SeekPosition_Oldest{Oldest: &ab.SeekOldest{}}})
114+
defer iter.Close()
115+
if pos != uint64(0) {
116+
logger.Panicf("Error iterating over system channel: '%s', expected position 0, got %d", chainID, pos)
117+
}
118+
genesisBlock, status := iter.Next()
119+
if status != cb.Status_SUCCESS {
120+
logger.Panicf("Error reading genesis block of system channel '%s'", chainID)
121+
}
122+
logger.Infof("Starting system channel '%s' with genesis block hash %x and orderer type %s", chainID, genesisBlock.Header.Hash(), chain.SharedConfig().ConsensusType())
123+
111124
r.chains[chainID] = chain
112125
r.systemChannelID = chainID
113126
r.systemChannel = chain

orderer/common/server/main_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,7 @@ func TestInitializeBootstrapChannel(t *testing.T) {
156156
GenesisMethod: tc.genesisMethod,
157157
GenesisProfile: "SampleSingleMSPSolo",
158158
GenesisFile: "genesisblock",
159+
SystemChannel: provisional.TestChainID,
159160
},
160161
}
161162

0 commit comments

Comments
 (0)