Skip to content

Commit

Permalink
Fix break in master
Browse files Browse the repository at this point in the history
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 <ale.linux@sopit.net>
  • Loading branch information
ale-linux committed Feb 23, 2017
1 parent f145efe commit d21f303
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion peer/channel/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,12 @@ import (
"time"

"github.com/golang/protobuf/proto"
"github.com/hyperledger/fabric/common/cauthdsl"
"github.com/hyperledger/fabric/common/configtx"
configtxtest "github.com/hyperledger/fabric/common/configtx/test"
"github.com/hyperledger/fabric/common/configtx/tool/provisional"
configtxapplication "github.com/hyperledger/fabric/common/configvalues/channel/application"
"github.com/hyperledger/fabric/common/configvalues/msp"
mspmgmt "github.com/hyperledger/fabric/msp/mgmt"
"github.com/hyperledger/fabric/peer/common"
cb "github.com/hyperledger/fabric/protos/common"
Expand Down Expand Up @@ -73,7 +75,19 @@ func createChannelFromDefaults(cf *ChannelCmdFactory) (*cb.Envelope, error) {
oTemplate := configtxtest.OrdererTemplate()
oOrgTemplate := configtxtest.OrdererOrgTemplate()
appOrgTemplate := configtxtest.ApplicationOrgTemplate()
gossTemplate := configtx.NewSimpleTemplate(configtxapplication.TemplateAnchorPeers("XXXFakeOrg", anchorPeers))
gosscg := configtxapplication.TemplateAnchorPeers("XXXFakeOrg", anchorPeers)

// FIXME: remove this hack as soon as 'peer channel create' is fixed properly
// we add admin policies for this config group, otherwise a majority won't be reached
p := &cb.ConfigPolicy{
Policy: &cb.Policy{
Type: int32(cb.Policy_SIGNATURE),
Policy: cauthdsl.MarshaledAcceptAllPolicy,
},
}
gosscg.Groups[configtxapplication.GroupKey].Groups["XXXFakeOrg"].Policies[msp.AdminsPolicyKey] = p

gossTemplate := configtx.NewSimpleTemplate(gosscg)
chCrtTemp := configtx.NewCompositeTemplate(oTemplate, oOrgTemplate, appOrgTemplate, gossTemplate)

signer, err := mspmgmt.GetLocalMSP().GetDefaultSigningIdentity()
Expand Down

0 comments on commit d21f303

Please sign in to comment.