Skip to content

Commit

Permalink
Merge "FAB-13666 consensus migration: kafka2raft green path #3"
Browse files Browse the repository at this point in the history
  • Loading branch information
yacovm authored and Gerrit Code Review committed Feb 18, 2019
2 parents 637634e + 4950edd commit 7c63447
Show file tree
Hide file tree
Showing 18 changed files with 2,054 additions and 1,105 deletions.
537 changes: 311 additions & 226 deletions orderer/common/broadcast/mock/channel_support.go

Large diffs are not rendered by default.

116 changes: 96 additions & 20 deletions orderer/common/broadcast/mock/channel_support_registrar.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

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

package multichannel
Expand All @@ -23,6 +13,8 @@ import (
"github.com/hyperledger/fabric/common/crypto"
"github.com/hyperledger/fabric/common/ledger/blockledger"
mockconfigtx "github.com/hyperledger/fabric/common/mocks/configtx"
"github.com/hyperledger/fabric/common/tools/configtxgen/configtxgentest"
"github.com/hyperledger/fabric/common/tools/configtxgen/encoder"
genesisconfig "github.com/hyperledger/fabric/common/tools/configtxgen/localconfig"
cb "github.com/hyperledger/fabric/protos/common"
"github.com/hyperledger/fabric/protos/utils"
Expand Down Expand Up @@ -165,7 +157,9 @@ func TestWriteConfigBlock(t *testing.T) {
}

func TestGoodWriteConfig(t *testing.T) {
l := NewRAMLedger(10)
confSys := configtxgentest.Load(genesisconfig.SampleInsecureSoloProfile)
genesisBlockSys := encoder.New(confSys).GenesisBlock()
_, l := newRAMLedgerAndFactory(10, genesisconfig.TestChainID, genesisBlockSys)

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

ctx := makeConfigTx(genesisconfig.TestChainID, 1)
block := cb.NewBlock(1, genesisBlock.Header.Hash())
block := cb.NewBlock(1, genesisBlockSys.Header.Hash())
block.Data.Data = [][]byte{utils.MarshalOrPanic(ctx)}
consenterMetadata := []byte("foo")
bw.WriteConfigBlock(block, consenterMetadata)
Expand Down
12 changes: 11 additions & 1 deletion orderer/common/multichannel/chainsupport.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ type ChainSupport struct {
consensus.Chain
cutter blockcutter.Receiver
crypto.LocalSigner
// Needed for consensus-type migration: to execute the migration state machine correctly,
// chains need to know if they are system or standard channel.
systemChannel bool
}

func newChainSupport(
Expand All @@ -38,7 +41,6 @@ func newChainSupport(
) *ChainSupport {
// Read in the last block and metadata for the channel
lastBlock := blockledger.GetBlock(ledgerResources, ledgerResources.Height()-1)

metadata, err := utils.GetMetadataFromBlock(lastBlock, cb.BlockMetadataIndex_ORDERER)
// Assuming a block created with cb.NewBlock(), this should not
// error even if the orderer metadata is an empty byte slice
Expand All @@ -57,6 +59,9 @@ func newChainSupport(
),
}

// When ConsortiumsConfig exists, it is the system channel
_, cs.systemChannel = ledgerResources.ConsortiumsConfig()

// Set up the msgprocessor
cs.Processor = msgprocessor.NewStandardChannel(cs, msgprocessor.CreateStandardChannelFilters(cs))

Expand Down Expand Up @@ -172,3 +177,8 @@ func (cs *ChainSupport) VerifyBlockSignature(sd []*cb.SignedData, envelope *cb.C
}
return nil
}

// IsSystemChannel returns true if this is the system channel.
func (cs *ChainSupport) IsSystemChannel() bool {
return cs.systemChannel
}
Loading

0 comments on commit 7c63447

Please sign in to comment.