Skip to content

Commit c8ff4b1

Browse files
author
Jason Yellick
committed
[FAB-2396] Move orderer config to common Proposer
https://jira.hyperledger.org/browse/FAB-2396 This is the second in a series of CRs which will migrate the config value handlers off of their own custom transaction handling code and onto the common Proposer code. This will not only reduce the amount of reimplimented logic (and corresponding bugs) and will also facilitate the two-way config translation for the configtxgen tool. Change-Id: I0e4bd1228c12b02fbf074b05379e917d463bf877 Signed-off-by: Jason Yellick <[email protected]>
1 parent 8b20459 commit c8ff4b1

File tree

14 files changed

+366
-677
lines changed

14 files changed

+366
-677
lines changed

common/configtx/template.go

+5-14
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,14 @@ package configtx
1919
import (
2020
"fmt"
2121

22-
"github.com/golang/protobuf/proto"
23-
configtxorderer "github.com/hyperledger/fabric/common/configvalues/channel/orderer"
22+
config "github.com/hyperledger/fabric/common/configvalues/root"
2423
"github.com/hyperledger/fabric/common/util"
2524
"github.com/hyperledger/fabric/msp"
2625
cb "github.com/hyperledger/fabric/protos/common"
2726
ab "github.com/hyperledger/fabric/protos/orderer"
2827
"github.com/hyperledger/fabric/protos/utils"
28+
29+
"github.com/golang/protobuf/proto"
2930
)
3031

3132
const (
@@ -34,16 +35,6 @@ const (
3435
CreationPolicyKey = "CreationPolicy"
3536
msgVersion = int32(0)
3637
epoch = 0
37-
38-
// ApplicationGroup identifies the `groups` map key in the channel
39-
// config, under which the application-related config group is set.
40-
ApplicationGroup = "Application"
41-
// OrdererGroup identifies the `groups` map key in the channel
42-
// config, under which the orderer-related config group is set.
43-
OrdererGroup = "Orderer"
44-
// MSPKey identifies the config key in the channel config,
45-
// under which the application-related config group is set.
46-
MSPKey = "MSP"
4738
)
4839

4940
// Template can be used to faciliate creation of config transactions
@@ -157,8 +148,8 @@ func (ct *compositeTemplate) Envelope(chainID string) (*cb.ConfigUpdateEnvelope,
157148
// Template which outputs an appropriately constructed list of ConfigUpdateEnvelopes.
158149
func NewChainCreationTemplate(creationPolicy string, template Template) Template {
159150
result := cb.NewConfigGroup()
160-
result.Groups[configtxorderer.GroupKey] = cb.NewConfigGroup()
161-
result.Groups[configtxorderer.GroupKey].Values[CreationPolicyKey] = &cb.ConfigValue{
151+
result.Groups[config.OrdererGroupKey] = cb.NewConfigGroup()
152+
result.Groups[config.OrdererGroupKey].Values[CreationPolicyKey] = &cb.ConfigValue{
162153
Value: utils.MarshalOrPanic(&ab.CreationPolicy{
163154
Policy: creationPolicy,
164155
}),

common/configtx/template_test.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import (
2121
"testing"
2222

2323
"github.com/golang/protobuf/proto"
24-
configtxorderer "github.com/hyperledger/fabric/common/configvalues/channel/orderer"
24+
config "github.com/hyperledger/fabric/common/configvalues/root"
2525
cb "github.com/hyperledger/fabric/protos/common"
2626
ab "github.com/hyperledger/fabric/protos/orderer"
2727

@@ -104,7 +104,7 @@ func TestNewChainTemplate(t *testing.T) {
104104
assert.True(t, ok, "Expected to find %d but did not", i)
105105
}
106106

107-
configValue, ok := configNext.WriteSet.Groups[configtxorderer.GroupKey].Values[CreationPolicyKey]
107+
configValue, ok := configNext.WriteSet.Groups[config.OrdererGroupKey].Values[CreationPolicyKey]
108108
assert.True(t, ok, "Did not find creation policy")
109109

110110
creationPolicyMessage := new(ab.CreationPolicy)

common/configtx/test/helper.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ import (
2424
genesisconfig "github.com/hyperledger/fabric/common/configtx/tool/localconfig"
2525
"github.com/hyperledger/fabric/common/configtx/tool/provisional"
2626
configtxapplication "github.com/hyperledger/fabric/common/configvalues/channel/application"
27-
configtxorderer "github.com/hyperledger/fabric/common/configvalues/channel/orderer"
2827
configtxmsp "github.com/hyperledger/fabric/common/configvalues/msp"
28+
config "github.com/hyperledger/fabric/common/configvalues/root"
2929
"github.com/hyperledger/fabric/common/genesis"
3030
"github.com/hyperledger/fabric/msp"
3131
cb "github.com/hyperledger/fabric/protos/common"
@@ -104,7 +104,7 @@ func OrdererOrgTemplate() configtx.Template {
104104
if err != nil {
105105
logger.Panicf("Could not load sample MSP config: %s", err)
106106
}
107-
return configtx.NewSimpleTemplate(configtxmsp.TemplateGroupMSP([]string{configtxorderer.GroupKey, sampleOrgID}, mspConf))
107+
return configtx.NewSimpleTemplate(configtxmsp.TemplateGroupMSP([]string{config.OrdererGroupKey, sampleOrgID}, mspConf))
108108
}
109109

110110
// CompositeTemplate returns the composite template of peer, orderer, and MSP

common/configtx/tool/provisional/provisional.go

+10-11
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ import (
2323
"github.com/hyperledger/fabric/common/configtx"
2424
genesisconfig "github.com/hyperledger/fabric/common/configtx/tool/localconfig"
2525
configtxapplication "github.com/hyperledger/fabric/common/configvalues/channel/application"
26-
configtxorderer "github.com/hyperledger/fabric/common/configvalues/channel/orderer"
2726
configvaluesmsp "github.com/hyperledger/fabric/common/configvalues/msp"
2827
config "github.com/hyperledger/fabric/common/configvalues/root"
2928
"github.com/hyperledger/fabric/common/genesis"
@@ -100,40 +99,40 @@ func New(conf *genesisconfig.Profile) Generator {
10099
if conf.Orderer != nil {
101100
bs.ordererGroups = []*cb.ConfigGroup{
102101
// Orderer Config Types
103-
configtxorderer.TemplateConsensusType(conf.Orderer.OrdererType),
104-
configtxorderer.TemplateBatchSize(&ab.BatchSize{
102+
config.TemplateConsensusType(conf.Orderer.OrdererType),
103+
config.TemplateBatchSize(&ab.BatchSize{
105104
MaxMessageCount: conf.Orderer.BatchSize.MaxMessageCount,
106105
AbsoluteMaxBytes: conf.Orderer.BatchSize.AbsoluteMaxBytes,
107106
PreferredMaxBytes: conf.Orderer.BatchSize.PreferredMaxBytes,
108107
}),
109-
configtxorderer.TemplateBatchTimeout(conf.Orderer.BatchTimeout.String()),
108+
config.TemplateBatchTimeout(conf.Orderer.BatchTimeout.String()),
110109

111110
// Initialize the default Reader/Writer/Admins orderer policies, as well as block validation policy
112-
policies.TemplateImplicitMetaPolicyWithSubPolicy([]string{configtxorderer.GroupKey}, BlockValidationPolicyKey, configvaluesmsp.WritersPolicyKey, cb.ImplicitMetaPolicy_ANY),
113-
policies.TemplateImplicitMetaAnyPolicy([]string{configtxorderer.GroupKey}, configvaluesmsp.ReadersPolicyKey),
114-
policies.TemplateImplicitMetaAnyPolicy([]string{configtxorderer.GroupKey}, configvaluesmsp.WritersPolicyKey),
115-
policies.TemplateImplicitMetaMajorityPolicy([]string{configtxorderer.GroupKey}, configvaluesmsp.AdminsPolicyKey),
111+
policies.TemplateImplicitMetaPolicyWithSubPolicy([]string{config.OrdererGroupKey}, BlockValidationPolicyKey, configvaluesmsp.WritersPolicyKey, cb.ImplicitMetaPolicy_ANY),
112+
policies.TemplateImplicitMetaAnyPolicy([]string{config.OrdererGroupKey}, configvaluesmsp.ReadersPolicyKey),
113+
policies.TemplateImplicitMetaAnyPolicy([]string{config.OrdererGroupKey}, configvaluesmsp.WritersPolicyKey),
114+
policies.TemplateImplicitMetaMajorityPolicy([]string{config.OrdererGroupKey}, configvaluesmsp.AdminsPolicyKey),
116115
}
117116

118117
for _, org := range conf.Orderer.Organizations {
119118
mspConfig, err := msp.GetVerifyingMspConfig(org.MSPDir, org.BCCSP, org.ID)
120119
if err != nil {
121120
logger.Panicf("Error loading MSP configuration for org %s: %s", org.Name, err)
122121
}
123-
bs.ordererGroups = append(bs.ordererGroups, configvaluesmsp.TemplateGroupMSP([]string{configtxorderer.GroupKey, org.Name}, mspConfig))
122+
bs.ordererGroups = append(bs.ordererGroups, configvaluesmsp.TemplateGroupMSP([]string{config.OrdererGroupKey, org.Name}, mspConfig))
124123
}
125124

126125
switch conf.Orderer.OrdererType {
127126
case ConsensusTypeSolo, ConsensusTypeSbft:
128127
case ConsensusTypeKafka:
129-
bs.ordererGroups = append(bs.ordererGroups, configtxorderer.TemplateKafkaBrokers(conf.Orderer.Kafka.Brokers))
128+
bs.ordererGroups = append(bs.ordererGroups, config.TemplateKafkaBrokers(conf.Orderer.Kafka.Brokers))
130129
default:
131130
panic(fmt.Errorf("Wrong consenter type value given: %s", conf.Orderer.OrdererType))
132131
}
133132

134133
bs.ordererSystemChannelGroups = []*cb.ConfigGroup{
135134
// Policies
136-
configtxorderer.TemplateChainCreationPolicyNames(DefaultChainCreationPolicyNames),
135+
config.TemplateChainCreationPolicyNames(DefaultChainCreationPolicyNames),
137136
}
138137
}
139138

0 commit comments

Comments
 (0)