Skip to content

Commit 7c63447

Browse files
yacovmGerrit Code Review
authored andcommitted
Merge "FAB-13666 consensus migration: kafka2raft green path #3"
2 parents 637634e + 4950edd commit 7c63447

File tree

18 files changed

+2054
-1105
lines changed

18 files changed

+2054
-1105
lines changed

orderer/common/broadcast/mock/channel_support.go

Lines changed: 311 additions & 226 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

orderer/common/broadcast/mock/channel_support_registrar.go

Lines changed: 96 additions & 20 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

orderer/common/multichannel/blockwriter_test.go

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,7 @@
11
/*
2-
Copyright IBM Corp. 2016 All Rights Reserved.
2+
Copyright IBM Corp. All Rights Reserved.
33
4-
Licensed under the Apache License, Version 2.0 (the "License");
5-
you may not use this file except in compliance with the License.
6-
You may obtain a copy of the License at
7-
8-
http://www.apache.org/licenses/LICENSE-2.0
9-
10-
Unless required by applicable law or agreed to in writing, software
11-
distributed under the License is distributed on an "AS IS" BASIS,
12-
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13-
See the License for the specific language governing permissions and
14-
limitations under the License.
4+
SPDX-License-Identifier: Apache-2.0
155
*/
166

177
package multichannel
@@ -23,6 +13,8 @@ import (
2313
"github.com/hyperledger/fabric/common/crypto"
2414
"github.com/hyperledger/fabric/common/ledger/blockledger"
2515
mockconfigtx "github.com/hyperledger/fabric/common/mocks/configtx"
16+
"github.com/hyperledger/fabric/common/tools/configtxgen/configtxgentest"
17+
"github.com/hyperledger/fabric/common/tools/configtxgen/encoder"
2618
genesisconfig "github.com/hyperledger/fabric/common/tools/configtxgen/localconfig"
2719
cb "github.com/hyperledger/fabric/protos/common"
2820
"github.com/hyperledger/fabric/protos/utils"
@@ -165,7 +157,9 @@ func TestWriteConfigBlock(t *testing.T) {
165157
}
166158

167159
func TestGoodWriteConfig(t *testing.T) {
168-
l := NewRAMLedger(10)
160+
confSys := configtxgentest.Load(genesisconfig.SampleInsecureSoloProfile)
161+
genesisBlockSys := encoder.New(confSys).GenesisBlock()
162+
_, l := newRAMLedgerAndFactory(10, genesisconfig.TestChainID, genesisBlockSys)
169163

170164
bw := &BlockWriter{
171165
support: &mockBlockWriterSupport{
@@ -176,7 +170,7 @@ func TestGoodWriteConfig(t *testing.T) {
176170
}
177171

178172
ctx := makeConfigTx(genesisconfig.TestChainID, 1)
179-
block := cb.NewBlock(1, genesisBlock.Header.Hash())
173+
block := cb.NewBlock(1, genesisBlockSys.Header.Hash())
180174
block.Data.Data = [][]byte{utils.MarshalOrPanic(ctx)}
181175
consenterMetadata := []byte("foo")
182176
bw.WriteConfigBlock(block, consenterMetadata)

orderer/common/multichannel/chainsupport.go

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@ type ChainSupport struct {
2727
consensus.Chain
2828
cutter blockcutter.Receiver
2929
crypto.LocalSigner
30+
// Needed for consensus-type migration: to execute the migration state machine correctly,
31+
// chains need to know if they are system or standard channel.
32+
systemChannel bool
3033
}
3134

3235
func newChainSupport(
@@ -38,7 +41,6 @@ func newChainSupport(
3841
) *ChainSupport {
3942
// Read in the last block and metadata for the channel
4043
lastBlock := blockledger.GetBlock(ledgerResources, ledgerResources.Height()-1)
41-
4244
metadata, err := utils.GetMetadataFromBlock(lastBlock, cb.BlockMetadataIndex_ORDERER)
4345
// Assuming a block created with cb.NewBlock(), this should not
4446
// error even if the orderer metadata is an empty byte slice
@@ -57,6 +59,9 @@ func newChainSupport(
5759
),
5860
}
5961

62+
// When ConsortiumsConfig exists, it is the system channel
63+
_, cs.systemChannel = ledgerResources.ConsortiumsConfig()
64+
6065
// Set up the msgprocessor
6166
cs.Processor = msgprocessor.NewStandardChannel(cs, msgprocessor.CreateStandardChannelFilters(cs))
6267

@@ -172,3 +177,8 @@ func (cs *ChainSupport) VerifyBlockSignature(sd []*cb.SignedData, envelope *cb.C
172177
}
173178
return nil
174179
}
180+
181+
// IsSystemChannel returns true if this is the system channel.
182+
func (cs *ChainSupport) IsSystemChannel() bool {
183+
return cs.systemChannel
184+
}

0 commit comments

Comments
 (0)