@@ -15,7 +15,6 @@ import (
1515 "github.com/hyperledger/fabric/orderer/common/msgprocessor"
1616 "github.com/hyperledger/fabric/orderer/consensus"
1717 cb "github.com/hyperledger/fabric/protos/common"
18- "github.com/hyperledger/fabric/protos/orderer"
1918 "github.com/hyperledger/fabric/protos/utils"
2019 "github.com/pkg/errors"
2120)
@@ -69,14 +68,6 @@ func newChainSupport(
6968 // Set up the block writer
7069 cs .BlockWriter = newBlockWriter (lastBlock , registrar , cs )
7170
72- // TODO Identify recovery after crash in the middle of consensus-type migration
73- if cs .detectMigration (lastBlock ) {
74- // We do this because the last block after migration (COMMIT/CONTEXT) carries Kafka metadata.
75- // This prevents the code down the line from unmarshaling it as Raft, and panicking.
76- metadata .Value = nil
77- logger .Debugf ("[channel: %s] Consensus-type migration: restart on to Raft, resetting Kafka block metadata" , cs .ChainID ())
78- }
79-
8071 // Set up the consenter
8172 consenterType := ledgerResources .SharedConfig ().ConsensusType ()
8273 consenter , ok := consenters [consenterType ]
@@ -94,53 +85,6 @@ func newChainSupport(
9485 return cs
9586}
9687
97- // detectMigration identifies restart after consensus-type migration was committed (green path).
98- // Restart after migration is detected by:
99- // 1. The Kafka2RaftMigration capability in on
100- // 2. The last block carries a config-tx
101- // 3. In the config-tx, you have:
102- // - (system-channel && state=COMMIT), OR
103- // - (standard-channel && state=CONTEXT)
104- // This assumes that migration was successful (green path). When migration ends successfully,
105- // every channel will have a config block as the last block. On the system channel, containing state=COMMIT;
106- // on standard channels, containing state=CONTEXT.
107- func (cs * ChainSupport ) detectMigration (lastBlock * cb.Block ) bool {
108- isMigration := false
109-
110- if ! cs .ledgerResources .SharedConfig ().Capabilities ().Kafka2RaftMigration () {
111- return isMigration
112- }
113-
114- lastConfigIndex , err := utils .GetLastConfigIndexFromBlock (lastBlock )
115- if err != nil {
116- logger .Panicf ("Chain did not have appropriately encoded last config in its latest block: %s" , err )
117- }
118-
119- logger .Debugf ("[channel: %s], sysChan=%v, lastConfigIndex=%d, H=%d, mig-state: %s" ,
120- cs .ChainID (), cs .systemChannel , lastConfigIndex , cs .ledgerResources .Height (),
121- cs .ledgerResources .SharedConfig ().ConsensusMigrationState ())
122-
123- if lastConfigIndex == lastBlock .Header .Number { //The last block was a config-tx
124- state := cs .ledgerResources .SharedConfig ().ConsensusMigrationState ()
125- if cs .systemChannel {
126- if state == orderer .ConsensusType_MIG_STATE_COMMIT {
127- isMigration = true
128- }
129- } else {
130- if state == orderer .ConsensusType_MIG_STATE_CONTEXT {
131- isMigration = true
132- }
133- }
134-
135- if isMigration {
136- logger .Infof ("[channel: %s], Restarting after consensus-type migration. New consensus-type is: %s" ,
137- cs .ChainID (), cs .ledgerResources .SharedConfig ().ConsensusType ())
138- }
139- }
140-
141- return isMigration
142- }
143-
14488// Block returns a block with the following number,
14589// or nil if such a block doesn't exist.
14690func (cs * ChainSupport ) Block (number uint64 ) * cb.Block {
0 commit comments