Unverified Commit 12949a19 authored by Artem Barger's avatar Artem Barger
Browse files

FAB-14735 don't check consenters if wasn't changed



This fix adds IT to check addition of new orderer organization and fix
the code path where etcd/chain.go checks for consenters set validity.

Change-Id: I96ac3a17df9c0c89c537328aa0d7caded83e3889
Signed-off-by: default avatarArtem Barger <bartem@il.ibm.com>
parent c458d3ae
......@@ -17,11 +17,12 @@ import (
"syscall"
"time"
docker "github.com/fsouza/go-dockerclient"
"github.com/fsouza/go-dockerclient"
"github.com/golang/protobuf/proto"
"github.com/hyperledger/fabric/integration/nwo"
"github.com/hyperledger/fabric/integration/nwo/commands"
"github.com/hyperledger/fabric/protos/common"
"github.com/hyperledger/fabric/protos/msp"
"github.com/hyperledger/fabric/protos/orderer/etcdraft"
"github.com/hyperledger/fabric/protos/utils"
. "github.com/onsi/ginkgo"
......@@ -1010,6 +1011,53 @@ var _ = Describe("EndToEnd reconfiguration and onboarding", func() {
By("Creating another channel via the orderer that is in system channel but not app channel")
network.CreateChannel("three-orderer-channel", network.Orderers[2], peer)
})
When("Adding new orderer organization", func() {
It("it will be added successfully", func() {
network = nwo.New(nwo.MultiNodeEtcdRaft(), testDir, client, BasePort(), components)
network.GenerateConfigTree()
network.Bootstrap()
networkRunner := network.NetworkGroupRunner()
process := ifrit.Invoke(networkRunner)
Eventually(process.Ready(), network.EventuallyTimeout).Should(BeClosed())
peer := network.Peer("Org1", "peer1")
orderer := network.Orderer("orderer1")
channel := "systemchannel"
config := nwo.GetConfig(network, peer, orderer, channel)
updatedConfig := proto.Clone(config).(*common.Config)
ordererOrg := updatedConfig.ChannelGroup.Groups["Orderer"].Groups["OrdererOrg"]
mspConfig := &msp.MSPConfig{}
proto.Unmarshal(ordererOrg.Values["MSP"].Value, mspConfig)
fabMSPConfig := &msp.FabricMSPConfig{}
proto.Unmarshal(mspConfig.Config, fabMSPConfig)
fabMSPConfig.Name = "OrdererMSP2"
mspConfig.Config, _ = proto.Marshal(fabMSPConfig)
updatedConfig.ChannelGroup.Groups["Orderer"].Groups["OrdererMSP2"] = &common.ConfigGroup{
Values: map[string]*common.ConfigValue{
"MSP": {
Value: utils.MarshalOrPanic(mspConfig),
ModPolicy: "Admins",
},
},
ModPolicy: "Admins",
}
nwo.UpdateOrdererConfig(network, orderer, channel, config, updatedConfig, peer, orderer)
if process != nil {
process.Signal(syscall.SIGTERM)
Eventually(process.Wait(), network.EventuallyTimeout).Should(Receive())
}
os.RemoveAll(testDir)
})
})
})
func ensureEvicted(evictedOrderer *nwo.Orderer, submitter *nwo.Peer, network *nwo.Network, channel string) {
......
......@@ -428,15 +428,17 @@ func (c *Chain) checkConfigUpdateValidity(ctx *common.Envelope) error {
return nil
case int32(common.HeaderType_CONFIG):
configUpdate, err := configtx.UnmarshalConfigUpdateFromPayload(payload)
if err != nil {
return err
}
metadata, err := MetadataFromConfigUpdate(configUpdate)
if err != nil {
return err
}
// Validate consenter set if it is updated in the write-set
if ordererConfigGroup, ok := configUpdate.WriteSet.Groups["Orderer"]; ok {
if val, ok := ordererConfigGroup.Values["ConsensusType"]; ok {
return c.checkConsentersSet(val)
}
if metadata != nil {
return c.checkConsentersSet(metadata)
}
return nil
......@@ -1171,13 +1173,7 @@ func (c *Chain) pemToDER(pemBytes []byte, id uint64, certType string) ([]byte, e
}
// checkConsentersSet validates correctness of the consenters set provided within configuration value
func (c *Chain) checkConsentersSet(configValue *common.ConfigValue) error {
// read metadata update from configuration
updatedMetadata, err := MetadataFromConfigValue(configValue)
if err != nil {
return err
}
func (c *Chain) checkConsentersSet(updatedMetadata *etcdraft.ConfigMetadata) error {
// sanity check of certificates
for _, consenter := range updatedMetadata.Consenters {
if bl, _ := pem.Decode(consenter.ServerTlsCert); bl == nil {
......@@ -1189,7 +1185,8 @@ func (c *Chain) checkConsentersSet(configValue *common.ConfigValue) error {
}
}
if err := MetadataHasDuplication(updatedMetadata); err != nil {
var err error
if err = MetadataHasDuplication(updatedMetadata); err != nil {
return err
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment