Skip to content

Commit

Permalink
update to orderer main with debug statements
Browse files Browse the repository at this point in the history
Signed-off-by: Parameswaran Selvam <parselva@in.ibm.com>
  • Loading branch information
Param-S committed Nov 22, 2022
1 parent b2b3d2e commit c144b58
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 25 deletions.
3 changes: 2 additions & 1 deletion integration/nwo/standard_networks.go
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,8 @@ func MultiNodeSmartBFT() *Config {

config.Channels = []*Channel{
{Name: "testchannel1", Profile: "TwoOrgsChannel"},
{Name: "testchannel2", Profile: "TwoOrgsChannel"}}
{Name: "testchannel2", Profile: "TwoOrgsChannel"},
}

for _, peer := range config.Peers {
peer.Channels = []*PeerChannel{
Expand Down
40 changes: 19 additions & 21 deletions integration/smartbft/smartbft_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ import (
"github.com/hyperledger/fabric-config/configtx"
"github.com/hyperledger/fabric-config/configtx/orderer"
"github.com/hyperledger/fabric-protos-go/common"
"github.com/hyperledger/fabric/integration/channelparticipation"
conftx "github.com/hyperledger/fabric/integration/configtx"
"github.com/hyperledger/fabric/integration/nwo"
"github.com/hyperledger/fabric/integration/nwo/commands"
Expand Down Expand Up @@ -111,24 +110,24 @@ var _ = Describe("EndToEnd Smart BFT configuration test", func() {
Eventually(peerProcesses.Ready(), network.EventuallyTimeout).Should(BeClosed())
peer := network.Peer("Org1", "peer0")

genesisBlock := applicationChannelGenesisBlock(network, network.Orderers, []*nwo.Peer{peer}, "participation-trophy")
expectedChannelInfoPT := channelparticipation.ChannelInfo{
Name: "participation-trophy",
URL: "/participation/v1/channels/participation-trophy",
Status: "active",
ConsensusRelation: "consenter",
Height: 1,
}

for _, o := range network.Orderers {
By("joining " + o.Name + " to channel as a consenter")
channelparticipation.Join(network, o, "participation-trophy", genesisBlock, expectedChannelInfoPT)
channelInfo := channelparticipation.ListOne(network, o, "participation-trophy")
Expect(channelInfo).To(Equal(expectedChannelInfoPT))
}

Eventually(ordererRunners[1].Err(), 120*time.Second, time.Second).Should(gbytes.Say("Message from 1"))
Fail("stop here")
/* genesisBlock := applicationChannelGenesisBlock(network, network.Orderers, []*nwo.Peer{peer}, "participation-trophy")
expectedChannelInfoPT := channelparticipation.ChannelInfo{
Name: "participation-trophy",
URL: "/participation/v1/channels/participation-trophy",
Status: "active",
ConsensusRelation: "consenter",
Height: 1,
}
for _, o := range network.Orderers {
By("joining " + o.Name + " to channel as a consenter")
channelparticipation.Join(network, o, "participation-trophy", genesisBlock, expectedChannelInfoPT)
channelInfo := channelparticipation.ListOne(network, o, "participation-trophy")
Expect(channelInfo).To(Equal(expectedChannelInfoPT))
}
Eventually(ordererRunners[1].Err(), 120*time.Second, time.Second).Should(gbytes.Say("Message from 1"))
Fail("stop here") */

assertBlockReception(map[string]int{"systemchannel": 0}, network.Orderers, peer, network)
/* By("check block validation policy on system channel")
Expand Down Expand Up @@ -199,7 +198,6 @@ var _ = Describe("EndToEnd Smart BFT configuration test", func() {
By("invoking the chaincode, again")
invokeQuery(network, peer, network.Orderers[2], channel, 80)
})

})
})

Expand Down Expand Up @@ -325,7 +323,7 @@ func extractTarGZ(archive []byte, baseDir string) error {
filePath := filepath.Join(baseDir, header.Name)
switch header.Typeflag {
case tar.TypeDir:
if err := os.Mkdir(filePath, 0755); err != nil {
if err := os.Mkdir(filePath, 0o755); err != nil {
return err
}
case tar.TypeReg:
Expand Down
11 changes: 10 additions & 1 deletion orderer/common/server/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,10 @@ var (
_ = app.Command("start", "Start the orderer node").Default() // preserved for cli compatibility
version = app.Command("version", "Show version information")

clusterTypes = map[string]struct{}{"etcdraft": {}}
clusterTypes = map[string]struct{}{
"etcdraft": {},
"smartbft": {},
}
)

// Main is the entry point of orderer process
Expand Down Expand Up @@ -811,6 +814,7 @@ func initializeMultichannelRegistrar(
if bootstrapBlock != nil && isClusterType(bootstrapBlock, bccsp) {
// with a system channel
consenterType := onboarding.ConsensusType(bootstrapBlock, bccsp)
fmt.Printf("consenterType: %s\n", consenterType)
switch consenterType {
case "etcdraft":
initializeEtcdraftConsenter(consenters, conf, lf, clusterDialer, bootstrapBlock, repInitiator, srvConf, srv, registrar, metricsProvider, bccsp)
Expand All @@ -824,14 +828,18 @@ func initializeMultichannelRegistrar(
consenterType := "smartbft"
bootstrapBlock := initSystemChannelWithJoinBlock(conf, bccsp, lf)
if bootstrapBlock != nil {
fmt.Println("DEBUG_bootstrapBlock is not nil")
consenterType = onboarding.ConsensusType(bootstrapBlock, bccsp)
} else {
fmt.Println("DEBUG_bootstrapBlock is nil")
// load consensus type from orderer config
var consensusConfig localconfig.Consensus
if err := mapstructure.Decode(conf.Consensus, &consensusConfig); err == nil && consensusConfig.Type != "" {
consenterType = consensusConfig.Type
}
}

fmt.Printf("DEBUG_consenterType:%v\n", consenterType)
// the orderer can start without channels at all and have an initialized cluster type consenter
switch consenterType {
case "etcdraft":
Expand Down Expand Up @@ -890,6 +898,7 @@ func initializeSmartBFTConsenter(
metricsProvider metrics.Provider,
bccsp bccsp.BCCSP,
) *smartbft.Consenter {
fmt.Println("DEBUG-initializeSmartBFTConsenter called")
systemChannelName, err := protoutil.GetChannelIDFromBlock(bootstrapBlock)
if err != nil {
logger.Panicf("Failed extracting system channel name from bootstrap block: %v", err)
Expand Down
4 changes: 2 additions & 2 deletions orderer/consensus/smartbft/configverifier.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ package smartbft

import (
"fmt"

mspa "github.com/hyperledger/fabric-protos-go/msp"
"github.com/hyperledger/fabric/common/policydsl"

Expand Down Expand Up @@ -131,10 +132,9 @@ func (cbv *ConfigBlockValidator) checkConsentersMatchPolicy(conf *cb.Config) err
Value: protoutil.MarshalOrPanic(sp),
}


actualPolicy := conf.ChannelGroup.Groups["Orderer"].Policies["BlockValidation"].Policy

if ! proto.Equal(expectedConfigPol, actualPolicy) {
if !proto.Equal(expectedConfigPol, actualPolicy) {
return fmt.Errorf("block validation policy should be a signature policy: %v but it is %v instead", expectedConfigPol, actualPolicy)
}

Expand Down

0 comments on commit c144b58

Please sign in to comment.