From a061e6da8a897c16be70c00daecfe4415c91e556 Mon Sep 17 00:00:00 2001 From: Jason Yellick Date: Thu, 9 Feb 2017 21:40:55 -0500 Subject: [PATCH] [FAB-2162] Move orderer genesis to common https://jira.hyperledger.org/browse/FAB-2162 This CR moves genesis configuration for the orderer to the common configtx package. Change-Id: I875692e75cb5429ddc747239acf6dab070f586d4 Signed-off-by: Jason Yellick --- Makefile | 4 +- .../configtx/tool}/genesis.yaml | 0 common/configtx/tool/localconfig/config.go | 159 ++++++++++++++++++ .../bootstrap/provisional/provisional.go | 4 +- .../bootstrap/provisional/provisional_test.go | 12 +- orderer/common/deliver/deliver_test.go | 4 +- orderer/kafka/config_test.go | 10 +- orderer/kafka/orderer_test.go | 2 +- orderer/ledger/file/fileledger_test.go | 4 +- orderer/ledger/fileledger_test.go | 4 +- orderer/ledger/ram/ramledger_test.go | 4 +- orderer/localconfig/config.go | 120 ------------- orderer/main.go | 3 +- orderer/multichain/manager_test.go | 8 +- orderer/network_test.go | 2 +- orderer/orderer.yaml | 5 - .../sample_clients/broadcast_config/client.go | 5 +- orderer/sbft_test.go | 5 +- 18 files changed, 200 insertions(+), 155 deletions(-) rename {orderer => common/configtx/tool}/genesis.yaml (100%) create mode 100644 common/configtx/tool/localconfig/config.go diff --git a/Makefile b/Makefile index 0281c894e7d..9fc28d293dc 100644 --- a/Makefile +++ b/Makefile @@ -180,11 +180,11 @@ build/image/peer/payload: build/docker/bin/peer \ build/image/orderer/payload: build/docker/bin/orderer \ build/msp-sampleconfig.tar.bz2 \ orderer/orderer.yaml \ - orderer/genesis.yaml + common/configtx/tool/genesis.yaml build/image/testenv/payload: build/gotools.tar.bz2 \ build/docker/bin/orderer \ orderer/orderer.yaml \ - orderer/genesis.yaml \ + common/configtx/tool/genesis.yaml \ build/docker/bin/peer \ peer/core.yaml \ build/msp-sampleconfig.tar.bz2 \ diff --git a/orderer/genesis.yaml b/common/configtx/tool/genesis.yaml similarity index 100% rename from orderer/genesis.yaml rename to common/configtx/tool/genesis.yaml diff --git a/common/configtx/tool/localconfig/config.go b/common/configtx/tool/localconfig/config.go new file mode 100644 index 00000000000..ba01a9f1a03 --- /dev/null +++ b/common/configtx/tool/localconfig/config.go @@ -0,0 +1,159 @@ +/* +Copyright IBM Corp. 2016 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. +*/ + +package localconfig + +import ( + "fmt" + "os" + "path/filepath" + "strings" + "time" + + "github.com/hyperledger/fabric/common/viperutil" + + "github.com/op/go-logging" + "github.com/spf13/viper" +) + +var logger = logging.MustGetLogger("configtx/tool/localconfig") + +func init() { + logging.SetLevel(logging.ERROR, "") +} + +// Prefix is the default config prefix for the orderer +const Prefix string = "CONFIGTX" + +// TopLevel contains the genesis structures for use by the provisional bootstrapper +type TopLevel struct { + Orderer Orderer +} + +// Orderer contains config which is used for orderer genesis by the provisional bootstrapper +type Orderer struct { + OrdererType string + Addresses []string + BatchTimeout time.Duration + BatchSize BatchSize + Kafka Kafka +} + +// BatchSize contains configuration affecting the size of batches +type BatchSize struct { + MaxMessageCount uint32 + AbsoluteMaxBytes uint32 + PreferredMaxBytes uint32 +} + +// Kafka contains config for the Kafka orderer +type Kafka struct { + Brokers []string +} + +var genesisDefaults = TopLevel{ + Orderer: Orderer{ + OrdererType: "solo", + Addresses: []string{"127.0.0.1:7050"}, + BatchTimeout: 10 * time.Second, + BatchSize: BatchSize{ + MaxMessageCount: 10, + AbsoluteMaxBytes: 100000000, + PreferredMaxBytes: 512 * 1024, + }, + Kafka: Kafka{ + Brokers: []string{"127.0.0.1:9092"}, + }, + }, +} + +func (g *TopLevel) completeInitialization() { + for { + switch { + case g.Orderer.OrdererType == "": + logger.Infof("Orderer.OrdererType unset, setting to %s", genesisDefaults.Orderer.OrdererType) + g.Orderer.OrdererType = genesisDefaults.Orderer.OrdererType + case g.Orderer.Addresses == nil: + logger.Infof("Orderer.Addresses unset, setting to %s", genesisDefaults.Orderer.Addresses) + g.Orderer.Addresses = genesisDefaults.Orderer.Addresses + case g.Orderer.BatchTimeout == 0: + logger.Infof("Orderer.BatchTimeout unset, setting to %s", genesisDefaults.Orderer.BatchTimeout) + g.Orderer.BatchTimeout = genesisDefaults.Orderer.BatchTimeout + case g.Orderer.BatchTimeout == 0: + logger.Infof("Orderer.BatchTimeout unset, setting to %s", genesisDefaults.Orderer.BatchTimeout) + g.Orderer.BatchTimeout = genesisDefaults.Orderer.BatchTimeout + case g.Orderer.BatchSize.MaxMessageCount == 0: + logger.Infof("Orderer.BatchSize.MaxMessageCount unset, setting to %s", genesisDefaults.Orderer.BatchSize.MaxMessageCount) + g.Orderer.BatchSize.MaxMessageCount = genesisDefaults.Orderer.BatchSize.MaxMessageCount + case g.Orderer.BatchSize.AbsoluteMaxBytes == 0: + logger.Infof("Orderer.BatchSize.AbsoluteMaxBytes unset, setting to %s", genesisDefaults.Orderer.BatchSize.AbsoluteMaxBytes) + g.Orderer.BatchSize.AbsoluteMaxBytes = genesisDefaults.Orderer.BatchSize.AbsoluteMaxBytes + case g.Orderer.BatchSize.PreferredMaxBytes == 0: + logger.Infof("Orderer.BatchSize.PreferredMaxBytes unset, setting to %s", genesisDefaults.Orderer.BatchSize.PreferredMaxBytes) + g.Orderer.BatchSize.PreferredMaxBytes = genesisDefaults.Orderer.BatchSize.PreferredMaxBytes + case g.Orderer.Kafka.Brokers == nil: + logger.Infof("Orderer.Kafka.Brokers unset, setting to %v", genesisDefaults.Orderer.Kafka.Brokers) + g.Orderer.Kafka.Brokers = genesisDefaults.Orderer.Kafka.Brokers + default: + return + } + } +} + +func Load() *TopLevel { + config := viper.New() + + config.SetConfigName("genesis") + + var cfgPath string + + // Path to look for the config file in based on ORDERER_CFG_PATH and GOPATH + searchPath := os.Getenv("ORDERER_CFG_PATH") + ":" + os.Getenv("GOPATH") + for _, p := range filepath.SplitList(searchPath) { + genesisPath := filepath.Join(p, "src/github.com/hyperledger/fabric/common/configtx/tool/") + if _, err := os.Stat(filepath.Join(genesisPath, "genesis.yaml")); err != nil { + // The yaml file does not exist in this component of the go src + continue + } + cfgPath = genesisPath + } + if cfgPath == "" { + logger.Fatalf("Could not find genesis.yaml, try setting GOPATH correctly") + } + config.AddConfigPath(cfgPath) // Path to look for the config file in + + // for environment variables + config.SetEnvPrefix(Prefix) + config.AutomaticEnv() + replacer := strings.NewReplacer(".", "_") + config.SetEnvKeyReplacer(replacer) + + err := config.ReadInConfig() + if err != nil { + panic(fmt.Errorf("Error reading %s plugin config from %s: %s", Prefix, cfgPath, err)) + } + + var uconf TopLevel + + err = viperutil.EnhancedExactUnmarshal(config, &uconf) + if err != nil { + panic(fmt.Errorf("Error unmarshaling into structure: %s", err)) + } + + uconf.completeInitialization() + + return &uconf +} diff --git a/orderer/common/bootstrap/provisional/provisional.go b/orderer/common/bootstrap/provisional/provisional.go index 31b2ec6bcd3..4e4d2ff928d 100644 --- a/orderer/common/bootstrap/provisional/provisional.go +++ b/orderer/common/bootstrap/provisional/provisional.go @@ -23,9 +23,9 @@ import ( "github.com/hyperledger/fabric/common/configtx" configtxchannel "github.com/hyperledger/fabric/common/configtx/handlers/channel" configtxorderer "github.com/hyperledger/fabric/common/configtx/handlers/orderer" + genesisconfig "github.com/hyperledger/fabric/common/configtx/tool/localconfig" "github.com/hyperledger/fabric/common/genesis" "github.com/hyperledger/fabric/orderer/common/bootstrap" - "github.com/hyperledger/fabric/orderer/localconfig" cb "github.com/hyperledger/fabric/protos/common" ab "github.com/hyperledger/fabric/protos/orderer" ) @@ -65,7 +65,7 @@ type bootstrapper struct { } // New returns a new provisional bootstrap helper. -func New(conf *config.GenesisTopLevel) Generator { +func New(conf *genesisconfig.TopLevel) Generator { bs := &bootstrapper{ minimalGroups: []*cb.ConfigGroup{ // Chain Config Types diff --git a/orderer/common/bootstrap/provisional/provisional_test.go b/orderer/common/bootstrap/provisional/provisional_test.go index 296c2b56ff3..dea7411545c 100644 --- a/orderer/common/bootstrap/provisional/provisional_test.go +++ b/orderer/common/bootstrap/provisional/provisional_test.go @@ -20,18 +20,18 @@ import ( "bytes" "testing" - "github.com/hyperledger/fabric/orderer/localconfig" + genesisconfig "github.com/hyperledger/fabric/common/configtx/tool/localconfig" cb "github.com/hyperledger/fabric/protos/common" ) -var confSolo, confKafka *config.GenesisTopLevel -var testCases []*config.GenesisTopLevel +var confSolo, confKafka *genesisconfig.TopLevel +var testCases []*genesisconfig.TopLevel func init() { - confSolo = config.LoadGenesis() - confKafka = config.LoadGenesis() + confSolo = genesisconfig.Load() + confKafka = genesisconfig.Load() confKafka.Orderer.OrdererType = ConsensusTypeKafka - testCases = []*config.GenesisTopLevel{confSolo, confKafka} + testCases = []*genesisconfig.TopLevel{confSolo, confKafka} } func TestGenesisBlockHeader(t *testing.T) { diff --git a/orderer/common/deliver/deliver_test.go b/orderer/common/deliver/deliver_test.go index 44a0b7a520e..4710fec91ab 100644 --- a/orderer/common/deliver/deliver_test.go +++ b/orderer/common/deliver/deliver_test.go @@ -22,13 +22,13 @@ import ( "time" configtxapi "github.com/hyperledger/fabric/common/configtx/api" + genesisconfig "github.com/hyperledger/fabric/common/configtx/tool/localconfig" mockconfigtxorderer "github.com/hyperledger/fabric/common/mocks/configtx/handlers/orderer" mockpolicies "github.com/hyperledger/fabric/common/mocks/policies" "github.com/hyperledger/fabric/common/policies" "github.com/hyperledger/fabric/orderer/common/bootstrap/provisional" ordererledger "github.com/hyperledger/fabric/orderer/ledger" ramledger "github.com/hyperledger/fabric/orderer/ledger/ram" - "github.com/hyperledger/fabric/orderer/localconfig" cb "github.com/hyperledger/fabric/protos/common" ab "github.com/hyperledger/fabric/protos/orderer" "github.com/hyperledger/fabric/protos/utils" @@ -44,7 +44,7 @@ const ledgerSize = 10 func init() { logging.SetLevel(logging.DEBUG, "") - genesisBlock = provisional.New(config.LoadGenesis()).GenesisBlock() + genesisBlock = provisional.New(genesisconfig.Load()).GenesisBlock() } type mockD struct { diff --git a/orderer/kafka/config_test.go b/orderer/kafka/config_test.go index 9cb51f2206f..57c56bda828 100644 --- a/orderer/kafka/config_test.go +++ b/orderer/kafka/config_test.go @@ -21,6 +21,7 @@ import ( "time" "github.com/Shopify/sarama" + genesisconfig "github.com/hyperledger/fabric/common/configtx/tool/localconfig" "github.com/hyperledger/fabric/orderer/localconfig" cb "github.com/hyperledger/fabric/protos/common" ) @@ -37,9 +38,16 @@ var ( testTimePadding = 200 * time.Millisecond ) +var testGenesisConf = &genesisconfig.TopLevel{ + Orderer: genesisconfig.Orderer{ + Kafka: genesisconfig.Kafka{ + Brokers: []string{"127.0.0.1:9092"}, + }, + }, +} + var testConf = &config.TopLevel{ Kafka: config.Kafka{ - Brokers: []string{"127.0.0.1:9092"}, Retry: config.Retry{ Period: 3 * time.Second, Stop: 60 * time.Second, diff --git a/orderer/kafka/orderer_test.go b/orderer/kafka/orderer_test.go index 90845de2007..04fd41aea54 100644 --- a/orderer/kafka/orderer_test.go +++ b/orderer/kafka/orderer_test.go @@ -37,7 +37,7 @@ import ( var cp = newChainPartition(provisional.TestChainID, rawPartition) func newMockSharedConfigManager() *mockconfigtxorderer.SharedConfig { - return &mockconfigtxorderer.SharedConfig{KafkaBrokersVal: testConf.Kafka.Brokers} + return &mockconfigtxorderer.SharedConfig{KafkaBrokersVal: testGenesisConf.Orderer.Kafka.Brokers} } type mockConsenterImpl struct { diff --git a/orderer/ledger/file/fileledger_test.go b/orderer/ledger/file/fileledger_test.go index 1558b6f2ef1..e16e8ece9b7 100644 --- a/orderer/ledger/file/fileledger_test.go +++ b/orderer/ledger/file/fileledger_test.go @@ -22,9 +22,9 @@ import ( "os" "testing" + genesisconfig "github.com/hyperledger/fabric/common/configtx/tool/localconfig" "github.com/hyperledger/fabric/orderer/common/bootstrap/provisional" ordererledger "github.com/hyperledger/fabric/orderer/ledger" - "github.com/hyperledger/fabric/orderer/localconfig" cb "github.com/hyperledger/fabric/protos/common" ab "github.com/hyperledger/fabric/protos/orderer" @@ -35,7 +35,7 @@ var genesisBlock *cb.Block func init() { logging.SetLevel(logging.DEBUG, "") - genesisBlock = provisional.New(config.LoadGenesis()).GenesisBlock() + genesisBlock = provisional.New(genesisconfig.Load()).GenesisBlock() } type testEnv struct { diff --git a/orderer/ledger/fileledger_test.go b/orderer/ledger/fileledger_test.go index a9f33a91459..b08913f0776 100644 --- a/orderer/ledger/fileledger_test.go +++ b/orderer/ledger/fileledger_test.go @@ -20,17 +20,17 @@ import ( "io/ioutil" "os" + genesisconfig "github.com/hyperledger/fabric/common/configtx/tool/localconfig" "github.com/hyperledger/fabric/orderer/common/bootstrap/provisional" . "github.com/hyperledger/fabric/orderer/ledger" fileledger "github.com/hyperledger/fabric/orderer/ledger/file" - "github.com/hyperledger/fabric/orderer/localconfig" cb "github.com/hyperledger/fabric/protos/common" ) var genesisBlock *cb.Block func init() { - genesisBlock = provisional.New(config.LoadGenesis()).GenesisBlock() + genesisBlock = provisional.New(genesisconfig.Load()).GenesisBlock() testables = append(testables, &fileLedgerTestEnv{}) } diff --git a/orderer/ledger/ram/ramledger_test.go b/orderer/ledger/ram/ramledger_test.go index 60e64619eca..f9f6308ce9c 100644 --- a/orderer/ledger/ram/ramledger_test.go +++ b/orderer/ledger/ram/ramledger_test.go @@ -19,8 +19,8 @@ package ramledger import ( "testing" + genesisconfig "github.com/hyperledger/fabric/common/configtx/tool/localconfig" "github.com/hyperledger/fabric/orderer/common/bootstrap/provisional" - "github.com/hyperledger/fabric/orderer/localconfig" cb "github.com/hyperledger/fabric/protos/common" logging "github.com/op/go-logging" @@ -30,7 +30,7 @@ var genesisBlock *cb.Block func init() { logging.SetLevel(logging.DEBUG, "") - genesisBlock = provisional.New(config.LoadGenesis()).GenesisBlock() + genesisBlock = provisional.New(genesisconfig.Load()).GenesisBlock() } func NewTestChain(maxSize int) *ramLedger { diff --git a/orderer/localconfig/config.go b/orderer/localconfig/config.go index 8d79c1caf15..ed1c4b2d16a 100644 --- a/orderer/localconfig/config.go +++ b/orderer/localconfig/config.go @@ -74,27 +74,6 @@ type Genesis struct { SbftShared SbftShared } -// GenesisTopLevel contains the genesis structures for use by the provisional bootstrapper -type GenesisTopLevel struct { - Orderer Orderer -} - -// Orderer contains config which is used for orderer genesis by the provisional bootstrapper -type Orderer struct { - OrdererType string - Addresses []string - BatchTimeout time.Duration - BatchSize BatchSize - Kafka Kafka -} - -// BatchSize contains configuration affecting the size of batches -type BatchSize struct { - MaxMessageCount uint32 - AbsoluteMaxBytes uint32 - PreferredMaxBytes uint32 -} - // Profile contains configuration for Go pprof profiling type Profile struct { Enabled bool @@ -114,7 +93,6 @@ type FileLedger struct { // Kafka contains config for the Kafka orderer type Kafka struct { - Brokers []string // TODO This should be removed when the genesis config moves Retry Retry Verbose bool Version sarama.KafkaVersion @@ -186,7 +164,6 @@ var defaults = TopLevel{ Prefix: "hyperledger-fabric-ordererledger", }, Kafka: Kafka{ - Brokers: []string{"127.0.0.1:9092"}, Retry: Retry{ Period: 3 * time.Second, Stop: 60 * time.Second, @@ -273,103 +250,6 @@ func (c *TopLevel) completeInitialization() { } } -var genesisDefaults = GenesisTopLevel{ - Orderer: Orderer{ - OrdererType: "solo", - Addresses: []string{"127.0.0.1:7050"}, - BatchTimeout: 10 * time.Second, - BatchSize: BatchSize{ - MaxMessageCount: 10, - AbsoluteMaxBytes: 100000000, - PreferredMaxBytes: 512 * 1024, - }, - Kafka: Kafka{ - Brokers: []string{"127.0.0.1:9092"}, - }, - }, -} - -func (g *GenesisTopLevel) completeInitialization() { - for { - switch { - case g.Orderer.OrdererType == "": - logger.Infof("Orderer.OrdererType unset, setting to %s", genesisDefaults.Orderer.OrdererType) - g.Orderer.OrdererType = genesisDefaults.Orderer.OrdererType - case g.Orderer.Addresses == nil: - logger.Infof("Orderer.Addresses unset, setting to %s", genesisDefaults.Orderer.Addresses) - g.Orderer.Addresses = genesisDefaults.Orderer.Addresses - case g.Orderer.BatchTimeout == 0: - logger.Infof("Orderer.BatchTimeout unset, setting to %s", genesisDefaults.Orderer.BatchTimeout) - g.Orderer.BatchTimeout = genesisDefaults.Orderer.BatchTimeout - case g.Orderer.BatchTimeout == 0: - logger.Infof("Orderer.BatchTimeout unset, setting to %s", genesisDefaults.Orderer.BatchTimeout) - g.Orderer.BatchTimeout = genesisDefaults.Orderer.BatchTimeout - case g.Orderer.BatchSize.MaxMessageCount == 0: - logger.Infof("Orderer.BatchSize.MaxMessageCount unset, setting to %s", genesisDefaults.Orderer.BatchSize.MaxMessageCount) - g.Orderer.BatchSize.MaxMessageCount = genesisDefaults.Orderer.BatchSize.MaxMessageCount - case g.Orderer.BatchSize.AbsoluteMaxBytes == 0: - logger.Infof("Orderer.BatchSize.AbsoluteMaxBytes unset, setting to %s", genesisDefaults.Orderer.BatchSize.AbsoluteMaxBytes) - g.Orderer.BatchSize.AbsoluteMaxBytes = genesisDefaults.Orderer.BatchSize.AbsoluteMaxBytes - case g.Orderer.BatchSize.PreferredMaxBytes == 0: - logger.Infof("Orderer.BatchSize.PreferredMaxBytes unset, setting to %s", genesisDefaults.Orderer.BatchSize.PreferredMaxBytes) - g.Orderer.BatchSize.PreferredMaxBytes = genesisDefaults.Orderer.BatchSize.PreferredMaxBytes - case g.Orderer.Kafka.Brokers == nil: - logger.Infof("Orderer.Kafka.Brokers unset, setting to %v", genesisDefaults.Orderer.Kafka.Brokers) - g.Orderer.Kafka.Brokers = genesisDefaults.Orderer.Kafka.Brokers - default: - return - } - } -} - -func LoadGenesis() *GenesisTopLevel { - config := viper.New() - - const prefix = "GENESIS" - - config.SetConfigName("genesis") - cfgPath := os.Getenv("ORDERER_CFG_PATH") - if cfgPath == "" { - logger.Infof("No orderer cfg path set, assuming development environment, deriving from go path") - // Path to look for the config file in based on GOPATH - gopath := os.Getenv("GOPATH") - for _, p := range filepath.SplitList(gopath) { - ordererPath := filepath.Join(p, "src/github.com/hyperledger/fabric/orderer/") - if _, err := os.Stat(filepath.Join(ordererPath, "genesis.yaml")); err != nil { - // The yaml file does not exist in this component of the go src - continue - } - cfgPath = ordererPath - } - if cfgPath == "" { - logger.Fatalf("Could not find orderer.yaml, try setting ORDERER_CFG_PATH or GOPATH correctly") - } - } - config.AddConfigPath(cfgPath) // Path to look for the config file in - - // for environment variables - config.SetEnvPrefix(prefix) - config.AutomaticEnv() - replacer := strings.NewReplacer(".", "_") - config.SetEnvKeyReplacer(replacer) - - err := config.ReadInConfig() - if err != nil { - panic(fmt.Errorf("Error reading %s plugin config: %s", prefix, err)) - } - - var uconf GenesisTopLevel - - err = viperutil.EnhancedExactUnmarshal(config, &uconf) - if err != nil { - panic(fmt.Errorf("Error unmarshaling into structure: %s", err)) - } - - uconf.completeInitialization() - - return &uconf -} - // Load parses the orderer.yaml file and environment, producing a struct suitable for config use func Load() *TopLevel { config := viper.New() diff --git a/orderer/main.go b/orderer/main.go index d25c2318550..c07681ca5c6 100644 --- a/orderer/main.go +++ b/orderer/main.go @@ -25,6 +25,7 @@ import ( _ "net/http/pprof" "os" + genesisconfig "github.com/hyperledger/fabric/common/configtx/tool/localconfig" "github.com/hyperledger/fabric/common/flogging" "github.com/hyperledger/fabric/core/comm" "github.com/hyperledger/fabric/orderer/common/bootstrap/file" @@ -114,7 +115,7 @@ func main() { // Select the bootstrapping mechanism switch conf.General.GenesisMethod { case "provisional": - genesisBlock = provisional.New(config.LoadGenesis()).GenesisBlock() + genesisBlock = provisional.New(genesisconfig.Load()).GenesisBlock() case "file": genesisBlock = file.New(conf.General.GenesisFile).GenesisBlock() default: diff --git a/orderer/multichain/manager_test.go b/orderer/multichain/manager_test.go index 2d2a9e326a0..7fbc21c4112 100644 --- a/orderer/multichain/manager_test.go +++ b/orderer/multichain/manager_test.go @@ -22,10 +22,10 @@ import ( "time" "github.com/hyperledger/fabric/common/configtx" + genesisconfig "github.com/hyperledger/fabric/common/configtx/tool/localconfig" "github.com/hyperledger/fabric/orderer/common/bootstrap/provisional" ordererledger "github.com/hyperledger/fabric/orderer/ledger" ramledger "github.com/hyperledger/fabric/orderer/ledger/ram" - "github.com/hyperledger/fabric/orderer/localconfig" cb "github.com/hyperledger/fabric/protos/common" ab "github.com/hyperledger/fabric/protos/orderer" "github.com/hyperledger/fabric/protos/utils" @@ -35,11 +35,11 @@ import ( "github.com/stretchr/testify/assert" ) -var conf *config.GenesisTopLevel +var conf *genesisconfig.TopLevel var genesisBlock *cb.Block func init() { - conf = config.LoadGenesis() + conf = genesisconfig.Load() logging.SetLevel(logging.DEBUG, "") genesisBlock = provisional.New(conf).GenesisBlock() } @@ -217,7 +217,7 @@ func TestSignatureFilter(t *testing.T) { // This test brings up the entire system, with the mock consenter, including the broadcasters etc. and creates a new chain func TestNewChain(t *testing.T) { - conf := config.LoadGenesis() + conf := genesisconfig.Load() lf, rl := NewRAMLedgerAndFactory(10) consenters := make(map[string]Consenter) diff --git a/orderer/network_test.go b/orderer/network_test.go index bcfd5c21283..4d96089db16 100644 --- a/orderer/network_test.go +++ b/orderer/network_test.go @@ -306,7 +306,7 @@ func generateConfigEnv(peerNum uint64, grpcPort int, peerCommPort string, certFi envs := []string{} envs = append(envs, fmt.Sprintf("ORDERER_CFG_PATH=%s", ordererDir)) envs = append(envs, fmt.Sprintf("ORDERER_GENERAL_LISTENPORT=%d", grpcPort)) - envs = append(envs, fmt.Sprintf("GENESIS_ORDERER_ORDERERTYPE=%s", "sbft")) + envs = append(envs, fmt.Sprintf("CONFIGTX_ORDERER_ORDERERTYPE=%s", "sbft")) envs = append(envs, fmt.Sprintf("ORDERER_GENESIS_DEPRECATEDBATCHTIMEOUT=%d", 1000)) envs = append(envs, fmt.Sprintf("ORDERER_GENESIS_DEPRECATED=%d", 1000000000)) envs = append(envs, fmt.Sprintf("ORDERER_GENESIS_SBFTSHARED_REQUESTTIMEOUTNSEC=%d", 1000000000)) diff --git a/orderer/orderer.yaml b/orderer/orderer.yaml index b3907b68be0..ef5438bbff0 100644 --- a/orderer/orderer.yaml +++ b/orderer/orderer.yaml @@ -109,11 +109,6 @@ Kafka: # interact with the Kafka cluster Verbose: false - # Brokers: A list of Kafka brokers to which the orderer connects - # NOTE: Use IP:port notation - Brokers: - - 127.0.0.1:9092 - # TLS: TLS settings for the Kafka client TLS: diff --git a/orderer/sample_clients/broadcast_config/client.go b/orderer/sample_clients/broadcast_config/client.go index 3e8a039acb9..79d380c6415 100644 --- a/orderer/sample_clients/broadcast_config/client.go +++ b/orderer/sample_clients/broadcast_config/client.go @@ -23,13 +23,14 @@ import ( "google.golang.org/grpc" + genesisconfig "github.com/hyperledger/fabric/common/configtx/tool/localconfig" "github.com/hyperledger/fabric/orderer/localconfig" cb "github.com/hyperledger/fabric/protos/common" ab "github.com/hyperledger/fabric/protos/orderer" ) var conf *config.TopLevel -var genConf *config.GenesisTopLevel +var genConf *genesisconfig.TopLevel type broadcastClient struct { ab.AtomicBroadcast_BroadcastClient @@ -68,7 +69,7 @@ type argsImpl struct { func init() { conf = config.Load() - genConf = config.LoadGenesis() + genConf = genesisconfig.Load() } func main() { diff --git a/orderer/sbft_test.go b/orderer/sbft_test.go index d7946540f7f..2fc45b6b63a 100644 --- a/orderer/sbft_test.go +++ b/orderer/sbft_test.go @@ -28,6 +28,7 @@ import ( "bytes" "github.com/golang/protobuf/proto" + genesisconfig "github.com/hyperledger/fabric/common/configtx/tool/localconfig" "github.com/hyperledger/fabric/common/localmsp" mspmgmt "github.com/hyperledger/fabric/msp/mgmt" "github.com/hyperledger/fabric/orderer/common/bootstrap/provisional" @@ -99,7 +100,7 @@ func TestSbftPeer(t *testing.T) { // Start GRPC logger.Info("Creating a GRPC server.") conf := config.Load() - genConf := config.LoadGenesis() + genConf := genesisconfig.Load() genConf.Orderer.OrdererType = sbftName conf.General.LocalMSPDir = pwd + "/../msp/sampleconfig" lf := newRAMLedgerFactory(genConf) @@ -262,7 +263,7 @@ func broadcastSender(t *testing.T, resultch chan item, errorch chan error, clien resultch <- item{itemtype: sent, payload: mpl} } -func newRAMLedgerFactory(conf *config.GenesisTopLevel) ordererledger.Factory { +func newRAMLedgerFactory(conf *genesisconfig.TopLevel) ordererledger.Factory { rlf := ramledger.New(10) genesisBlock := provisional.New(conf).GenesisBlock() rl, err := rlf.GetOrCreate(provisional.TestChainID)