Skip to content

Commit d21f303

Browse files
committed
Fix break in master
When a new channel is created with `peer channel create`, one extra org is generated for gossip. This extra org brings the total number of orgs to 2 and requires a majority of 2 when admin policies are evaluated. However, this extra org does not come with its admin policy and so the reject policy is used instead. This breaks `peer chaincode instantiate` because the policy evaluation fails. The fix is to add a permit-all policy for the extra org. Change-Id: Ia35da0d83bea7c9ef8fe785164d1daa158791969 Signed-off-by: Alessandro Sorniotti <[email protected]>
1 parent f145efe commit d21f303

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

peer/channel/create.go

+15-1
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,12 @@ import (
2222
"time"
2323

2424
"github.com/golang/protobuf/proto"
25+
"github.com/hyperledger/fabric/common/cauthdsl"
2526
"github.com/hyperledger/fabric/common/configtx"
2627
configtxtest "github.com/hyperledger/fabric/common/configtx/test"
2728
"github.com/hyperledger/fabric/common/configtx/tool/provisional"
2829
configtxapplication "github.com/hyperledger/fabric/common/configvalues/channel/application"
30+
"github.com/hyperledger/fabric/common/configvalues/msp"
2931
mspmgmt "github.com/hyperledger/fabric/msp/mgmt"
3032
"github.com/hyperledger/fabric/peer/common"
3133
cb "github.com/hyperledger/fabric/protos/common"
@@ -73,7 +75,19 @@ func createChannelFromDefaults(cf *ChannelCmdFactory) (*cb.Envelope, error) {
7375
oTemplate := configtxtest.OrdererTemplate()
7476
oOrgTemplate := configtxtest.OrdererOrgTemplate()
7577
appOrgTemplate := configtxtest.ApplicationOrgTemplate()
76-
gossTemplate := configtx.NewSimpleTemplate(configtxapplication.TemplateAnchorPeers("XXXFakeOrg", anchorPeers))
78+
gosscg := configtxapplication.TemplateAnchorPeers("XXXFakeOrg", anchorPeers)
79+
80+
// FIXME: remove this hack as soon as 'peer channel create' is fixed properly
81+
// we add admin policies for this config group, otherwise a majority won't be reached
82+
p := &cb.ConfigPolicy{
83+
Policy: &cb.Policy{
84+
Type: int32(cb.Policy_SIGNATURE),
85+
Policy: cauthdsl.MarshaledAcceptAllPolicy,
86+
},
87+
}
88+
gosscg.Groups[configtxapplication.GroupKey].Groups["XXXFakeOrg"].Policies[msp.AdminsPolicyKey] = p
89+
90+
gossTemplate := configtx.NewSimpleTemplate(gosscg)
7791
chCrtTemp := configtx.NewCompositeTemplate(oTemplate, oOrgTemplate, appOrgTemplate, gossTemplate)
7892

7993
signer, err := mspmgmt.GetLocalMSP().GetDefaultSigningIdentity()

0 commit comments

Comments
 (0)