From 3b320c6a00f25bd1d872dee8cc2e0f06d60b7ebb Mon Sep 17 00:00:00 2001 From: Jason Yellick Date: Tue, 7 Feb 2017 15:11:31 -0500 Subject: [PATCH] [FAB-2101] Move orderer sharedconfig to common https://jira.hyperledger.org/browse/FAB-2101 It has always been somewhat problematic that orderer config generation is done in the orderer package, even though other pieces of the system depend on it. This CR moves the orderer shared config definitions to the common package. This is necessary to define a config schema going forward in order to lock down the pending more flexible configuration format. Change-Id: I1b1a4c78eedbc18a90d6838af0829950d6d88e72 Signed-off-by: Jason Yellick --- common/configtx/api/api.go | 30 ++++++++++++++ .../handlers/orderer}/sharedconfig.go | 39 ++----------------- .../handlers/orderer}/sharedconfig_test.go | 2 +- .../handlers/orderer}/sharedconfig_util.go | 2 +- .../handlers/orderer}/sharedconfig.go | 18 ++++----- .../handlers/orderer}/sharedconfig_test.go | 4 +- orderer/common/blockcutter/blockcutter.go | 8 ++-- .../common/blockcutter/blockcutter_test.go | 16 ++++---- .../bootstrap/provisional/provisional.go | 16 ++++---- orderer/common/deliver/deliver.go | 4 +- orderer/common/deliver/deliver_test.go | 10 ++--- orderer/kafka/orderer_test.go | 24 ++++++------ orderer/mocks/multichain/multichain.go | 8 ++-- orderer/multichain/chainsupport.go | 4 +- orderer/multichain/manager.go | 8 ++-- orderer/multichain/systemchain.go | 4 +- orderer/multichain/systemchain_test.go | 10 ++--- orderer/solo/consensus_test.go | 10 ++--- 18 files changed, 108 insertions(+), 109 deletions(-) rename {orderer/common/sharedconfig => common/configtx/handlers/orderer}/sharedconfig.go (85%) rename {orderer/common/sharedconfig => common/configtx/handlers/orderer}/sharedconfig_test.go (99%) rename {orderer/common/sharedconfig => common/configtx/handlers/orderer}/sharedconfig_util.go (99%) rename {orderer/mocks/sharedconfig => common/mocks/configtx/handlers/orderer}/sharedconfig.go (80%) rename {orderer/mocks/sharedconfig => common/mocks/configtx/handlers/orderer}/sharedconfig_test.go (85%) diff --git a/common/configtx/api/api.go b/common/configtx/api/api.go index 4afa40af4c8..2230e9acaef 100644 --- a/common/configtx/api/api.go +++ b/common/configtx/api/api.go @@ -17,12 +17,42 @@ limitations under the License. package api import ( + "time" + "github.com/hyperledger/fabric/common/chainconfig" "github.com/hyperledger/fabric/common/policies" "github.com/hyperledger/fabric/msp" cb "github.com/hyperledger/fabric/protos/common" + ab "github.com/hyperledger/fabric/protos/orderer" ) +// OrdererConfig stores the common shared orderer config +type OrdererConfig interface { + // ConsensusType returns the configured consensus type + ConsensusType() string + + // BatchSize returns the maximum number of messages to include in a block + BatchSize() *ab.BatchSize + + // BatchTimeout returns the amount of time to wait before creating a batch + BatchTimeout() time.Duration + + // ChainCreationPolicyNames returns the policy names which are allowed for chain creation + // This field is only set for the system ordering chain + ChainCreationPolicyNames() []string + + // KafkaBrokers returns the addresses (IP:port notation) of a set of "bootstrap" + // Kafka brokers, i.e. this is not necessarily the entire set of Kafka brokers + // used for ordering + KafkaBrokers() []string + + // IngressPolicyNames returns the name of the policy to validate incoming broadcast messages against + IngressPolicyNames() []string + + // EgressPolicyNames returns the name of the policy to validate incoming broadcast messages against + EgressPolicyNames() []string +} + // Handler provides a hook which allows other pieces of code to participate in config proposals type Handler interface { // BeginConfig called when a config proposal is begun diff --git a/orderer/common/sharedconfig/sharedconfig.go b/common/configtx/handlers/orderer/sharedconfig.go similarity index 85% rename from orderer/common/sharedconfig/sharedconfig.go rename to common/configtx/handlers/orderer/sharedconfig.go index 0b159ce46e2..30317fa5ddc 100644 --- a/orderer/common/sharedconfig/sharedconfig.go +++ b/common/configtx/handlers/orderer/sharedconfig.go @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package sharedconfig +package orderer import ( "fmt" @@ -53,37 +53,7 @@ const ( EgressPolicyNamesKey = "EgressPolicyNames" ) -var logger = logging.MustGetLogger("orderer/common/sharedconfig") - -// Manager stores the common shared orderer config -// It is intended to be the primary accessor of ManagerImpl -// It is intended to discourage use of the other exported ManagerImpl methods -// which are used for updating the orderer config by the ConfigManager -type Manager interface { - // ConsensusType returns the configured consensus type - ConsensusType() string - - // BatchSize returns the maximum number of messages to include in a block - BatchSize() *ab.BatchSize - - // BatchTimeout returns the amount of time to wait before creating a batch - BatchTimeout() time.Duration - - // ChainCreationPolicyNames returns the policy names which are allowed for chain creation - // This field is only set for the system ordering chain - ChainCreationPolicyNames() []string - - // KafkaBrokers returns the addresses (IP:port notation) of a set of "bootstrap" - // Kafka brokers, i.e. this is not necessarily the entire set of Kafka brokers - // used for ordering - KafkaBrokers() []string - - // IngressPolicyNames returns the name of the policy to validate incoming broadcast messages against - IngressPolicyNames() []string - - // EgressPolicyNames returns the name of the policy to validate incoming broadcast messages against - EgressPolicyNames() []string -} +var logger = logging.MustGetLogger("configtx/handlers/orderer") type ordererConfig struct { consensusType string @@ -95,14 +65,13 @@ type ordererConfig struct { egressPolicyNames []string } -// ManagerImpl is an implementation of Manager and configtx.ConfigHandler -// In general, it should only be referenced as an Impl for the configtx.ConfigManager +// ManagerImpl is an implementation of configtxapi.OrdererConfig and configtxapi.Handler type ManagerImpl struct { pendingConfig *ordererConfig config *ordererConfig } -// NewManagerImpl creates a new ManagerImpl with the given CryptoHelper +// NewManagerImpl creates a new ManagerImpl func NewManagerImpl() *ManagerImpl { return &ManagerImpl{ config: &ordererConfig{}, diff --git a/orderer/common/sharedconfig/sharedconfig_test.go b/common/configtx/handlers/orderer/sharedconfig_test.go similarity index 99% rename from orderer/common/sharedconfig/sharedconfig_test.go rename to common/configtx/handlers/orderer/sharedconfig_test.go index 776c88a3a82..2e01ecbeb8e 100644 --- a/orderer/common/sharedconfig/sharedconfig_test.go +++ b/common/configtx/handlers/orderer/sharedconfig_test.go @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package sharedconfig +package orderer import ( "os" diff --git a/orderer/common/sharedconfig/sharedconfig_util.go b/common/configtx/handlers/orderer/sharedconfig_util.go similarity index 99% rename from orderer/common/sharedconfig/sharedconfig_util.go rename to common/configtx/handlers/orderer/sharedconfig_util.go index d4a5d3e8972..335955d876c 100644 --- a/orderer/common/sharedconfig/sharedconfig_util.go +++ b/common/configtx/handlers/orderer/sharedconfig_util.go @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package sharedconfig +package orderer import ( cb "github.com/hyperledger/fabric/protos/common" diff --git a/orderer/mocks/sharedconfig/sharedconfig.go b/common/mocks/configtx/handlers/orderer/sharedconfig.go similarity index 80% rename from orderer/mocks/sharedconfig/sharedconfig.go rename to common/mocks/configtx/handlers/orderer/sharedconfig.go index 7fbba936b79..7587f6f2573 100644 --- a/orderer/mocks/sharedconfig/sharedconfig.go +++ b/common/mocks/configtx/handlers/orderer/sharedconfig.go @@ -19,8 +19,8 @@ package sharedconfig import ab "github.com/hyperledger/fabric/protos/orderer" import "time" -// Manager is a mock implementation of sharedconfig.Manager -type Manager struct { +// SharedConfig is a mock implementation of sharedconfig.SharedConfig +type SharedConfig struct { // ConsensusTypeVal is returned as the result of ConsensusType() ConsensusTypeVal string // BatchSizeVal is returned as the result of BatchSize() @@ -38,36 +38,36 @@ type Manager struct { } // ConsensusType returns the ConsensusTypeVal -func (scm *Manager) ConsensusType() string { +func (scm *SharedConfig) ConsensusType() string { return scm.ConsensusTypeVal } // BatchSize returns the BatchSizeVal -func (scm *Manager) BatchSize() *ab.BatchSize { +func (scm *SharedConfig) BatchSize() *ab.BatchSize { return scm.BatchSizeVal } // BatchTimeout returns the BatchTimeoutVal -func (scm *Manager) BatchTimeout() time.Duration { +func (scm *SharedConfig) BatchTimeout() time.Duration { return scm.BatchTimeoutVal } // ChainCreationPolicyNames returns the ChainCreationPolicyNamesVal -func (scm *Manager) ChainCreationPolicyNames() []string { +func (scm *SharedConfig) ChainCreationPolicyNames() []string { return scm.ChainCreationPolicyNamesVal } // KafkaBrokers returns the KafkaBrokersVal -func (scm *Manager) KafkaBrokers() []string { +func (scm *SharedConfig) KafkaBrokers() []string { return scm.KafkaBrokersVal } // IngressPolicyNames returns the IngressPolicyNamesVal -func (scm *Manager) IngressPolicyNames() []string { +func (scm *SharedConfig) IngressPolicyNames() []string { return scm.IngressPolicyNamesVal } // EgressPolicyNames returns the EgressPolicyNamesVal -func (scm *Manager) EgressPolicyNames() []string { +func (scm *SharedConfig) EgressPolicyNames() []string { return scm.EgressPolicyNamesVal } diff --git a/orderer/mocks/sharedconfig/sharedconfig_test.go b/common/mocks/configtx/handlers/orderer/sharedconfig_test.go similarity index 85% rename from orderer/mocks/sharedconfig/sharedconfig_test.go rename to common/mocks/configtx/handlers/orderer/sharedconfig_test.go index 7413945d19d..71600c737a8 100644 --- a/orderer/mocks/sharedconfig/sharedconfig_test.go +++ b/common/mocks/configtx/handlers/orderer/sharedconfig_test.go @@ -19,9 +19,9 @@ package sharedconfig import ( "testing" - "github.com/hyperledger/fabric/orderer/common/sharedconfig" + configtxapi "github.com/hyperledger/fabric/common/configtx/api" ) func TestSharedConfigInterface(t *testing.T) { - _ = sharedconfig.Manager(&Manager{}) + _ = configtxapi.OrdererConfig(&SharedConfig{}) } diff --git a/orderer/common/blockcutter/blockcutter.go b/orderer/common/blockcutter/blockcutter.go index 29e4a843c17..0c555180104 100644 --- a/orderer/common/blockcutter/blockcutter.go +++ b/orderer/common/blockcutter/blockcutter.go @@ -17,8 +17,8 @@ limitations under the License. package blockcutter import ( + configtxapi "github.com/hyperledger/fabric/common/configtx/api" "github.com/hyperledger/fabric/orderer/common/filter" - "github.com/hyperledger/fabric/orderer/common/sharedconfig" cb "github.com/hyperledger/fabric/protos/common" "github.com/op/go-logging" @@ -52,15 +52,15 @@ type Receiver interface { } type receiver struct { - sharedConfigManager sharedconfig.Manager + sharedConfigManager configtxapi.OrdererConfig filters *filter.RuleSet pendingBatch []*cb.Envelope pendingBatchSizeBytes uint32 pendingCommitters []filter.Committer } -// NewReceiverImpl creates a Receiver implementation based on the given sharedconfig manager and filters -func NewReceiverImpl(sharedConfigManager sharedconfig.Manager, filters *filter.RuleSet) Receiver { +// NewReceiverImpl creates a Receiver implementation based on the given configtxorderer manager and filters +func NewReceiverImpl(sharedConfigManager configtxapi.OrdererConfig, filters *filter.RuleSet) Receiver { return &receiver{ sharedConfigManager: sharedConfigManager, filters: filters, diff --git a/orderer/common/blockcutter/blockcutter_test.go b/orderer/common/blockcutter/blockcutter_test.go index 79c57256894..459e856555b 100644 --- a/orderer/common/blockcutter/blockcutter_test.go +++ b/orderer/common/blockcutter/blockcutter_test.go @@ -20,8 +20,8 @@ import ( "bytes" "testing" + mockconfigtxorderer "github.com/hyperledger/fabric/common/mocks/configtx/handlers/orderer" "github.com/hyperledger/fabric/orderer/common/filter" - mocksharedconfig "github.com/hyperledger/fabric/orderer/mocks/sharedconfig" cb "github.com/hyperledger/fabric/protos/common" ab "github.com/hyperledger/fabric/protos/orderer" logging "github.com/op/go-logging" @@ -83,7 +83,7 @@ func TestNormalBatch(t *testing.T) { maxMessageCount := uint32(2) absoluteMaxBytes := uint32(1000) preferredMaxBytes := uint32(100) - r := NewReceiverImpl(&mocksharedconfig.Manager{BatchSizeVal: &ab.BatchSize{MaxMessageCount: maxMessageCount, AbsoluteMaxBytes: absoluteMaxBytes, PreferredMaxBytes: preferredMaxBytes}}, filters) + r := NewReceiverImpl(&mockconfigtxorderer.SharedConfig{BatchSizeVal: &ab.BatchSize{MaxMessageCount: maxMessageCount, AbsoluteMaxBytes: absoluteMaxBytes, PreferredMaxBytes: preferredMaxBytes}}, filters) batches, committers, ok := r.Ordered(goodTx) @@ -112,7 +112,7 @@ func TestBadMessageInBatch(t *testing.T) { maxMessageCount := uint32(2) absoluteMaxBytes := uint32(1000) preferredMaxBytes := uint32(100) - r := NewReceiverImpl(&mocksharedconfig.Manager{BatchSizeVal: &ab.BatchSize{MaxMessageCount: maxMessageCount, AbsoluteMaxBytes: absoluteMaxBytes, PreferredMaxBytes: preferredMaxBytes}}, filters) + r := NewReceiverImpl(&mockconfigtxorderer.SharedConfig{BatchSizeVal: &ab.BatchSize{MaxMessageCount: maxMessageCount, AbsoluteMaxBytes: absoluteMaxBytes, PreferredMaxBytes: preferredMaxBytes}}, filters) batches, committers, ok := r.Ordered(badTx) @@ -150,7 +150,7 @@ func TestUnmatchedMessageInBatch(t *testing.T) { maxMessageCount := uint32(2) absoluteMaxBytes := uint32(1000) preferredMaxBytes := uint32(100) - r := NewReceiverImpl(&mocksharedconfig.Manager{BatchSizeVal: &ab.BatchSize{MaxMessageCount: maxMessageCount, AbsoluteMaxBytes: absoluteMaxBytes, PreferredMaxBytes: preferredMaxBytes}}, filters) + r := NewReceiverImpl(&mockconfigtxorderer.SharedConfig{BatchSizeVal: &ab.BatchSize{MaxMessageCount: maxMessageCount, AbsoluteMaxBytes: absoluteMaxBytes, PreferredMaxBytes: preferredMaxBytes}}, filters) batches, committers, ok := r.Ordered(unmatchedTx) @@ -188,7 +188,7 @@ func TestIsolatedEmptyBatch(t *testing.T) { maxMessageCount := uint32(2) absoluteMaxBytes := uint32(1000) preferredMaxBytes := uint32(100) - r := NewReceiverImpl(&mocksharedconfig.Manager{BatchSizeVal: &ab.BatchSize{MaxMessageCount: maxMessageCount, AbsoluteMaxBytes: absoluteMaxBytes, PreferredMaxBytes: preferredMaxBytes}}, filters) + r := NewReceiverImpl(&mockconfigtxorderer.SharedConfig{BatchSizeVal: &ab.BatchSize{MaxMessageCount: maxMessageCount, AbsoluteMaxBytes: absoluteMaxBytes, PreferredMaxBytes: preferredMaxBytes}}, filters) batches, committers, ok := r.Ordered(isolatedTx) @@ -214,7 +214,7 @@ func TestIsolatedPartialBatch(t *testing.T) { maxMessageCount := uint32(2) absoluteMaxBytes := uint32(1000) preferredMaxBytes := uint32(100) - r := NewReceiverImpl(&mocksharedconfig.Manager{BatchSizeVal: &ab.BatchSize{MaxMessageCount: maxMessageCount, AbsoluteMaxBytes: absoluteMaxBytes, PreferredMaxBytes: preferredMaxBytes}}, filters) + r := NewReceiverImpl(&mockconfigtxorderer.SharedConfig{BatchSizeVal: &ab.BatchSize{MaxMessageCount: maxMessageCount, AbsoluteMaxBytes: absoluteMaxBytes, PreferredMaxBytes: preferredMaxBytes}}, filters) batches, committers, ok := r.Ordered(goodTx) @@ -264,7 +264,7 @@ func TestBatchSizePreferredMaxBytesOverflow(t *testing.T) { // set message count > 9 maxMessageCount := uint32(20) - r := NewReceiverImpl(&mocksharedconfig.Manager{BatchSizeVal: &ab.BatchSize{MaxMessageCount: maxMessageCount, AbsoluteMaxBytes: preferredMaxBytes * 2, PreferredMaxBytes: preferredMaxBytes}}, filters) + r := NewReceiverImpl(&mockconfigtxorderer.SharedConfig{BatchSizeVal: &ab.BatchSize{MaxMessageCount: maxMessageCount, AbsoluteMaxBytes: preferredMaxBytes * 2, PreferredMaxBytes: preferredMaxBytes}}, filters) // enqueue 9 messages for i := 0; i < 9; i++ { @@ -319,7 +319,7 @@ func TestBatchSizePreferredMaxBytesOverflowNoPending(t *testing.T) { // set message count > 1 maxMessageCount := uint32(20) - r := NewReceiverImpl(&mocksharedconfig.Manager{BatchSizeVal: &ab.BatchSize{MaxMessageCount: maxMessageCount, AbsoluteMaxBytes: preferredMaxBytes * 3, PreferredMaxBytes: preferredMaxBytes}}, filters) + r := NewReceiverImpl(&mockconfigtxorderer.SharedConfig{BatchSizeVal: &ab.BatchSize{MaxMessageCount: maxMessageCount, AbsoluteMaxBytes: preferredMaxBytes * 3, PreferredMaxBytes: preferredMaxBytes}}, filters) // submit large message batches, committers, ok := r.Ordered(goodTxLarge) diff --git a/orderer/common/bootstrap/provisional/provisional.go b/orderer/common/bootstrap/provisional/provisional.go index 6ea3eb79a7a..5ab1213baee 100644 --- a/orderer/common/bootstrap/provisional/provisional.go +++ b/orderer/common/bootstrap/provisional/provisional.go @@ -22,9 +22,9 @@ import ( "github.com/hyperledger/fabric/common/cauthdsl" "github.com/hyperledger/fabric/common/chainconfig" "github.com/hyperledger/fabric/common/configtx" + configtxorderer "github.com/hyperledger/fabric/common/configtx/handlers/orderer" "github.com/hyperledger/fabric/common/genesis" "github.com/hyperledger/fabric/orderer/common/bootstrap" - "github.com/hyperledger/fabric/orderer/common/sharedconfig" "github.com/hyperledger/fabric/orderer/localconfig" cb "github.com/hyperledger/fabric/protos/common" ab "github.com/hyperledger/fabric/protos/orderer" @@ -74,15 +74,15 @@ func New(conf *config.TopLevel) Generator { chainconfig.TemplateOrdererAddresses([]string{fmt.Sprintf("%s:%d", conf.General.ListenAddress, conf.General.ListenPort)}), // Orderer Config Types - sharedconfig.TemplateConsensusType(conf.Genesis.OrdererType), - sharedconfig.TemplateBatchSize(&ab.BatchSize{ + configtxorderer.TemplateConsensusType(conf.Genesis.OrdererType), + configtxorderer.TemplateBatchSize(&ab.BatchSize{ MaxMessageCount: conf.Genesis.BatchSize.MaxMessageCount, AbsoluteMaxBytes: conf.Genesis.BatchSize.AbsoluteMaxBytes, PreferredMaxBytes: conf.Genesis.BatchSize.PreferredMaxBytes, }), - sharedconfig.TemplateBatchTimeout(conf.Genesis.BatchTimeout.String()), - sharedconfig.TemplateIngressPolicyNames([]string{AcceptAllPolicyKey}), - sharedconfig.TemplateEgressPolicyNames([]string{AcceptAllPolicyKey}), + configtxorderer.TemplateBatchTimeout(conf.Genesis.BatchTimeout.String()), + configtxorderer.TemplateIngressPolicyNames([]string{AcceptAllPolicyKey}), + configtxorderer.TemplateEgressPolicyNames([]string{AcceptAllPolicyKey}), // Policies cauthdsl.TemplatePolicy(configtx.NewConfigItemPolicyKey, cauthdsl.RejectAllPolicy), @@ -90,14 +90,14 @@ func New(conf *config.TopLevel) Generator { }, systemChainItems: []*cb.ConfigItem{ - sharedconfig.TemplateChainCreationPolicyNames(DefaultChainCreationPolicyNames), + configtxorderer.TemplateChainCreationPolicyNames(DefaultChainCreationPolicyNames), }, } switch conf.Genesis.OrdererType { case ConsensusTypeSolo, ConsensusTypeSbft: case ConsensusTypeKafka: - bs.minimalItems = append(bs.minimalItems, sharedconfig.TemplateKafkaBrokers(conf.Kafka.Brokers)) + bs.minimalItems = append(bs.minimalItems, configtxorderer.TemplateKafkaBrokers(conf.Kafka.Brokers)) default: panic(fmt.Errorf("Wrong consenter type value given: %s", conf.Genesis.OrdererType)) } diff --git a/orderer/common/deliver/deliver.go b/orderer/common/deliver/deliver.go index 7198a3b393c..8813db947fe 100644 --- a/orderer/common/deliver/deliver.go +++ b/orderer/common/deliver/deliver.go @@ -19,9 +19,9 @@ package deliver import ( "fmt" + configtxapi "github.com/hyperledger/fabric/common/configtx/api" "github.com/hyperledger/fabric/common/policies" "github.com/hyperledger/fabric/orderer/common/filter" - "github.com/hyperledger/fabric/orderer/common/sharedconfig" "github.com/hyperledger/fabric/orderer/common/sigfilter" ordererledger "github.com/hyperledger/fabric/orderer/ledger" cb "github.com/hyperledger/fabric/protos/common" @@ -52,7 +52,7 @@ type Support interface { Reader() ordererledger.Reader // SharedConfig returns the shared config manager for this chain - SharedConfig() sharedconfig.Manager + SharedConfig() configtxapi.OrdererConfig } type deliverServer struct { diff --git a/orderer/common/deliver/deliver_test.go b/orderer/common/deliver/deliver_test.go index 673f89d6d95..0161a6ca083 100644 --- a/orderer/common/deliver/deliver_test.go +++ b/orderer/common/deliver/deliver_test.go @@ -21,14 +21,14 @@ import ( "testing" "time" + configtxapi "github.com/hyperledger/fabric/common/configtx/api" + mockconfigtxorderer "github.com/hyperledger/fabric/common/mocks/configtx/handlers/orderer" "github.com/hyperledger/fabric/common/policies" "github.com/hyperledger/fabric/orderer/common/bootstrap/provisional" - "github.com/hyperledger/fabric/orderer/common/sharedconfig" ordererledger "github.com/hyperledger/fabric/orderer/ledger" ramledger "github.com/hyperledger/fabric/orderer/ledger/ram" "github.com/hyperledger/fabric/orderer/localconfig" mockpolicies "github.com/hyperledger/fabric/orderer/mocks/policies" - mocksharedconfig "github.com/hyperledger/fabric/orderer/mocks/sharedconfig" cb "github.com/hyperledger/fabric/protos/common" ab "github.com/hyperledger/fabric/protos/orderer" "github.com/hyperledger/fabric/protos/utils" @@ -84,7 +84,7 @@ func (mm *mockSupportManager) GetChain(chainID string) (Support, bool) { type mockSupport struct { ledger ordererledger.ReadWriter - sharedConfig *mocksharedconfig.Manager + sharedConfig *mockconfigtxorderer.SharedConfig policyManager *mockpolicies.Manager } @@ -103,7 +103,7 @@ func NewRAMLedger() ordererledger.ReadWriter { return rl } -func (mcs *mockSupport) SharedConfig() sharedconfig.Manager { +func (mcs *mockSupport) SharedConfig() configtxapi.OrdererConfig { return mcs.sharedConfig } @@ -114,7 +114,7 @@ func newMockMultichainManager() *mockSupportManager { } mm.chains[systemChainID] = &mockSupport{ ledger: rl, - sharedConfig: &mocksharedconfig.Manager{EgressPolicyNamesVal: []string{"somePolicy"}}, + sharedConfig: &mockconfigtxorderer.SharedConfig{EgressPolicyNamesVal: []string{"somePolicy"}}, policyManager: &mockpolicies.Manager{Policy: &mockpolicies.Policy{}}, } return mm diff --git a/orderer/kafka/orderer_test.go b/orderer/kafka/orderer_test.go index 29af64e3041..90845de2007 100644 --- a/orderer/kafka/orderer_test.go +++ b/orderer/kafka/orderer_test.go @@ -23,11 +23,11 @@ import ( "time" "github.com/Shopify/sarama" + mockconfigtxorderer "github.com/hyperledger/fabric/common/mocks/configtx/handlers/orderer" "github.com/hyperledger/fabric/orderer/common/bootstrap/provisional" "github.com/hyperledger/fabric/orderer/localconfig" mockblockcutter "github.com/hyperledger/fabric/orderer/mocks/blockcutter" mockmultichain "github.com/hyperledger/fabric/orderer/mocks/multichain" - mocksharedconfig "github.com/hyperledger/fabric/orderer/mocks/sharedconfig" "github.com/hyperledger/fabric/orderer/multichain" cb "github.com/hyperledger/fabric/protos/common" ab "github.com/hyperledger/fabric/protos/orderer" @@ -36,8 +36,8 @@ import ( var cp = newChainPartition(provisional.TestChainID, rawPartition) -func newMockSharedConfigManager() *mocksharedconfig.Manager { - return &mocksharedconfig.Manager{KafkaBrokersVal: testConf.Kafka.Brokers} +func newMockSharedConfigManager() *mockconfigtxorderer.SharedConfig { + return &mockconfigtxorderer.SharedConfig{KafkaBrokersVal: testConf.Kafka.Brokers} } type mockConsenterImpl struct { @@ -132,7 +132,7 @@ func TestKafkaConsenterEmptyBatch(t *testing.T) { Batches: make(chan []*cb.Envelope), BlockCutterVal: mockblockcutter.NewReceiver(), ChainIDVal: provisional.TestChainID, - SharedConfigVal: &mocksharedconfig.Manager{BatchTimeoutVal: testTimePadding}, + SharedConfigVal: &mockconfigtxorderer.SharedConfig{BatchTimeoutVal: testTimePadding}, } defer close(cs.BlockCutterVal.Block) @@ -167,7 +167,7 @@ func TestKafkaConsenterBatchTimer(t *testing.T) { Batches: make(chan []*cb.Envelope), BlockCutterVal: mockblockcutter.NewReceiver(), ChainIDVal: provisional.TestChainID, - SharedConfigVal: &mocksharedconfig.Manager{BatchTimeoutVal: batchTimeout}, + SharedConfigVal: &mockconfigtxorderer.SharedConfig{BatchTimeoutVal: batchTimeout}, } defer close(cs.BlockCutterVal.Block) @@ -219,7 +219,7 @@ func TestKafkaConsenterTimerHaltOnFilledBatch(t *testing.T) { Batches: make(chan []*cb.Envelope), BlockCutterVal: mockblockcutter.NewReceiver(), ChainIDVal: provisional.TestChainID, - SharedConfigVal: &mocksharedconfig.Manager{BatchTimeoutVal: batchTimeout}, + SharedConfigVal: &mockconfigtxorderer.SharedConfig{BatchTimeoutVal: batchTimeout}, } defer close(cs.BlockCutterVal.Block) @@ -279,7 +279,7 @@ func TestKafkaConsenterConfigStyleMultiBatch(t *testing.T) { Batches: make(chan []*cb.Envelope), BlockCutterVal: mockblockcutter.NewReceiver(), ChainIDVal: provisional.TestChainID, - SharedConfigVal: &mocksharedconfig.Manager{BatchTimeoutVal: testTimePadding}, + SharedConfigVal: &mockconfigtxorderer.SharedConfig{BatchTimeoutVal: testTimePadding}, } defer close(cs.BlockCutterVal.Block) @@ -329,7 +329,7 @@ func TestKafkaConsenterTimeToCutForced(t *testing.T) { Batches: make(chan []*cb.Envelope), BlockCutterVal: mockblockcutter.NewReceiver(), ChainIDVal: provisional.TestChainID, - SharedConfigVal: &mocksharedconfig.Manager{BatchTimeoutVal: batchTimeout}, + SharedConfigVal: &mockconfigtxorderer.SharedConfig{BatchTimeoutVal: batchTimeout}, } defer close(cs.BlockCutterVal.Block) @@ -386,7 +386,7 @@ func TestKafkaConsenterTimeToCutDuplicate(t *testing.T) { Batches: make(chan []*cb.Envelope), BlockCutterVal: mockblockcutter.NewReceiver(), ChainIDVal: provisional.TestChainID, - SharedConfigVal: &mocksharedconfig.Manager{BatchTimeoutVal: batchTimeout}, + SharedConfigVal: &mockconfigtxorderer.SharedConfig{BatchTimeoutVal: batchTimeout}, } defer close(cs.BlockCutterVal.Block) @@ -475,7 +475,7 @@ func TestKafkaConsenterTimeToCutStale(t *testing.T) { Batches: make(chan []*cb.Envelope), BlockCutterVal: mockblockcutter.NewReceiver(), ChainIDVal: provisional.TestChainID, - SharedConfigVal: &mocksharedconfig.Manager{BatchTimeoutVal: batchTimeout}, + SharedConfigVal: &mockconfigtxorderer.SharedConfig{BatchTimeoutVal: batchTimeout}, } defer close(cs.BlockCutterVal.Block) @@ -534,7 +534,7 @@ func TestKafkaConsenterTimeToCutLarger(t *testing.T) { Batches: make(chan []*cb.Envelope), BlockCutterVal: mockblockcutter.NewReceiver(), ChainIDVal: provisional.TestChainID, - SharedConfigVal: &mocksharedconfig.Manager{BatchTimeoutVal: batchTimeout}, + SharedConfigVal: &mockconfigtxorderer.SharedConfig{BatchTimeoutVal: batchTimeout}, } defer close(cs.BlockCutterVal.Block) @@ -616,7 +616,7 @@ func TestKafkaConsenterRestart(t *testing.T) { Batches: make(chan []*cb.Envelope), BlockCutterVal: mockblockcutter.NewReceiver(), ChainIDVal: provisional.TestChainID, - SharedConfigVal: &mocksharedconfig.Manager{BatchTimeoutVal: batchTimeout}, + SharedConfigVal: &mockconfigtxorderer.SharedConfig{BatchTimeoutVal: batchTimeout}, } defer close(cs.BlockCutterVal.Block) diff --git a/orderer/mocks/multichain/multichain.go b/orderer/mocks/multichain/multichain.go index 10afd81a6dc..3e46accc1ad 100644 --- a/orderer/mocks/multichain/multichain.go +++ b/orderer/mocks/multichain/multichain.go @@ -17,11 +17,11 @@ limitations under the License. package multichain import ( + configtxapi "github.com/hyperledger/fabric/common/configtx/api" + mockconfigtxorderer "github.com/hyperledger/fabric/common/mocks/configtx/handlers/orderer" "github.com/hyperledger/fabric/orderer/common/blockcutter" "github.com/hyperledger/fabric/orderer/common/filter" - "github.com/hyperledger/fabric/orderer/common/sharedconfig" mockblockcutter "github.com/hyperledger/fabric/orderer/mocks/blockcutter" - mocksharedconfig "github.com/hyperledger/fabric/orderer/mocks/sharedconfig" cb "github.com/hyperledger/fabric/protos/common" "github.com/hyperledger/fabric/protos/utils" @@ -34,7 +34,7 @@ var logger = logging.MustGetLogger("orderer/mocks/multichain") // Whenever a block is written, it writes to the Batches channel to allow for synchronization type ConsenterSupport struct { // SharedConfigVal is the value returned by SharedConfig() - SharedConfigVal *mocksharedconfig.Manager + SharedConfigVal *mockconfigtxorderer.SharedConfig // BlockCutterVal is the value returned by BlockCutter() BlockCutterVal *mockblockcutter.Receiver @@ -58,7 +58,7 @@ func (mcs *ConsenterSupport) BlockCutter() blockcutter.Receiver { } // SharedConfig returns SharedConfigVal -func (mcs *ConsenterSupport) SharedConfig() sharedconfig.Manager { +func (mcs *ConsenterSupport) SharedConfig() configtxapi.OrdererConfig { return mcs.SharedConfigVal } diff --git a/orderer/multichain/chainsupport.go b/orderer/multichain/chainsupport.go index 899e9e12a50..79abbff5be3 100644 --- a/orderer/multichain/chainsupport.go +++ b/orderer/multichain/chainsupport.go @@ -17,6 +17,7 @@ limitations under the License. package multichain import ( + configtxapi "github.com/hyperledger/fabric/common/configtx/api" "github.com/hyperledger/fabric/common/crypto" "github.com/hyperledger/fabric/common/policies" "github.com/hyperledger/fabric/common/util" @@ -24,7 +25,6 @@ import ( "github.com/hyperledger/fabric/orderer/common/broadcast" "github.com/hyperledger/fabric/orderer/common/configtxfilter" "github.com/hyperledger/fabric/orderer/common/filter" - "github.com/hyperledger/fabric/orderer/common/sharedconfig" "github.com/hyperledger/fabric/orderer/common/sigfilter" "github.com/hyperledger/fabric/orderer/common/sizefilter" ordererledger "github.com/hyperledger/fabric/orderer/ledger" @@ -66,7 +66,7 @@ type Chain interface { type ConsenterSupport interface { crypto.LocalSigner BlockCutter() blockcutter.Receiver - SharedConfig() sharedconfig.Manager + SharedConfig() configtxapi.OrdererConfig CreateNextBlock(messages []*cb.Envelope) *cb.Block WriteBlock(block *cb.Block, committers []filter.Committer, encodedMetadataValue []byte) *cb.Block ChainID() string // ChainID returns the chain ID this specific consenter instance is associated with diff --git a/orderer/multichain/manager.go b/orderer/multichain/manager.go index b9aaec31686..7ce4968ea9d 100644 --- a/orderer/multichain/manager.go +++ b/orderer/multichain/manager.go @@ -21,7 +21,7 @@ import ( "github.com/hyperledger/fabric/common/configtx" configtxapi "github.com/hyperledger/fabric/common/configtx/api" - "github.com/hyperledger/fabric/orderer/common/sharedconfig" + configtxorderer "github.com/hyperledger/fabric/common/configtx/handlers/orderer" ordererledger "github.com/hyperledger/fabric/orderer/ledger" cb "github.com/hyperledger/fabric/protos/common" "github.com/hyperledger/fabric/protos/utils" @@ -46,10 +46,10 @@ type Manager interface { type configResources struct { configtxapi.Manager - sharedConfig sharedconfig.Manager + sharedConfig configtxapi.OrdererConfig } -func (cr *configResources) SharedConfig() sharedconfig.Manager { +func (cr *configResources) SharedConfig() configtxapi.OrdererConfig { return cr.sharedConfig } @@ -148,7 +148,7 @@ func (ml *multiLedger) GetChain(chainID string) (ChainSupport, bool) { } func newConfigResources(configEnvelope *cb.ConfigEnvelope) (*configResources, error) { - sharedConfigManager := sharedconfig.NewManagerImpl() + sharedConfigManager := configtxorderer.NewManagerImpl() initializer := configtx.NewInitializer() initializer.Handlers()[cb.ConfigItem_Orderer] = sharedConfigManager diff --git a/orderer/multichain/systemchain.go b/orderer/multichain/systemchain.go index 8a96b5664b9..59bbdf0b2af 100644 --- a/orderer/multichain/systemchain.go +++ b/orderer/multichain/systemchain.go @@ -19,9 +19,9 @@ package multichain import ( "github.com/hyperledger/fabric/common/chainconfig" "github.com/hyperledger/fabric/common/configtx" + configtxapi "github.com/hyperledger/fabric/common/configtx/api" "github.com/hyperledger/fabric/common/policies" "github.com/hyperledger/fabric/orderer/common/filter" - "github.com/hyperledger/fabric/orderer/common/sharedconfig" cb "github.com/hyperledger/fabric/protos/common" ab "github.com/hyperledger/fabric/protos/orderer" @@ -37,7 +37,7 @@ type chainCreator interface { type limitedSupport interface { ChainID() string PolicyManager() policies.Manager - SharedConfig() sharedconfig.Manager + SharedConfig() configtxapi.OrdererConfig ChainConfig() chainconfig.Descriptor Enqueue(env *cb.Envelope) bool } diff --git a/orderer/multichain/systemchain_test.go b/orderer/multichain/systemchain_test.go index 370737e4b3a..42e80149a1c 100644 --- a/orderer/multichain/systemchain_test.go +++ b/orderer/multichain/systemchain_test.go @@ -22,12 +22,12 @@ import ( "github.com/hyperledger/fabric/common/chainconfig" "github.com/hyperledger/fabric/common/configtx" + configtxapi "github.com/hyperledger/fabric/common/configtx/api" mockchainconfig "github.com/hyperledger/fabric/common/mocks/chainconfig" + mockconfigtxorderer "github.com/hyperledger/fabric/common/mocks/configtx/handlers/orderer" "github.com/hyperledger/fabric/common/policies" "github.com/hyperledger/fabric/orderer/common/bootstrap/provisional" "github.com/hyperledger/fabric/orderer/common/filter" - "github.com/hyperledger/fabric/orderer/common/sharedconfig" - mocksharedconfig "github.com/hyperledger/fabric/orderer/mocks/sharedconfig" cb "github.com/hyperledger/fabric/protos/common" "github.com/hyperledger/fabric/protos/utils" ) @@ -50,7 +50,7 @@ func (mpm *mockPolicyManager) GetPolicy(id string) (policies.Policy, bool) { type mockSupport struct { mpm *mockPolicyManager - msc *mocksharedconfig.Manager + msc *mockconfigtxorderer.SharedConfig chainID string queue []*cb.Envelope chainConfig *mockchainconfig.Descriptor @@ -59,7 +59,7 @@ type mockSupport struct { func newMockSupport(chainID string) *mockSupport { return &mockSupport{ mpm: &mockPolicyManager{}, - msc: &mocksharedconfig.Manager{}, + msc: &mockconfigtxorderer.SharedConfig{}, chainID: chainID, chainConfig: &mockchainconfig.Descriptor{}, } @@ -78,7 +78,7 @@ func (ms *mockSupport) PolicyManager() policies.Manager { return ms.mpm } -func (ms *mockSupport) SharedConfig() sharedconfig.Manager { +func (ms *mockSupport) SharedConfig() configtxapi.OrdererConfig { return ms.msc } diff --git a/orderer/solo/consensus_test.go b/orderer/solo/consensus_test.go index bd49cc79234..81831179cc8 100644 --- a/orderer/solo/consensus_test.go +++ b/orderer/solo/consensus_test.go @@ -20,9 +20,9 @@ import ( "testing" "time" + mockconfigtxorderer "github.com/hyperledger/fabric/common/mocks/configtx/handlers/orderer" mockblockcutter "github.com/hyperledger/fabric/orderer/mocks/blockcutter" mockmultichain "github.com/hyperledger/fabric/orderer/mocks/multichain" - mocksharedconfig "github.com/hyperledger/fabric/orderer/mocks/sharedconfig" cb "github.com/hyperledger/fabric/protos/common" logging "github.com/op/go-logging" @@ -59,7 +59,7 @@ func TestEmptyBatch(t *testing.T) { support := &mockmultichain.ConsenterSupport{ Batches: make(chan []*cb.Envelope), BlockCutterVal: mockblockcutter.NewReceiver(), - SharedConfigVal: &mocksharedconfig.Manager{BatchTimeoutVal: batchTimeout}, + SharedConfigVal: &mockconfigtxorderer.SharedConfig{BatchTimeoutVal: batchTimeout}, } defer close(support.BlockCutterVal.Block) bs := newChain(support) @@ -80,7 +80,7 @@ func TestBatchTimer(t *testing.T) { support := &mockmultichain.ConsenterSupport{ Batches: make(chan []*cb.Envelope), BlockCutterVal: mockblockcutter.NewReceiver(), - SharedConfigVal: &mocksharedconfig.Manager{BatchTimeoutVal: batchTimeout}, + SharedConfigVal: &mockconfigtxorderer.SharedConfig{BatchTimeoutVal: batchTimeout}, } defer close(support.BlockCutterVal.Block) bs := newChain(support) @@ -115,7 +115,7 @@ func TestBatchTimerHaltOnFilledBatch(t *testing.T) { support := &mockmultichain.ConsenterSupport{ Batches: make(chan []*cb.Envelope), BlockCutterVal: mockblockcutter.NewReceiver(), - SharedConfigVal: &mocksharedconfig.Manager{BatchTimeoutVal: batchTimeout}, + SharedConfigVal: &mockconfigtxorderer.SharedConfig{BatchTimeoutVal: batchTimeout}, } defer close(support.BlockCutterVal.Block) @@ -158,7 +158,7 @@ func TestConfigStyleMultiBatch(t *testing.T) { support := &mockmultichain.ConsenterSupport{ Batches: make(chan []*cb.Envelope), BlockCutterVal: mockblockcutter.NewReceiver(), - SharedConfigVal: &mocksharedconfig.Manager{BatchTimeoutVal: batchTimeout}, + SharedConfigVal: &mockconfigtxorderer.SharedConfig{BatchTimeoutVal: batchTimeout}, } defer close(support.BlockCutterVal.Block) bs := newChain(support)