Skip to content

Commit

Permalink
[FAB-15970] Enable MSP 1.4.3 at Channel Config
Browse files Browse the repository at this point in the history
The goal is to return MSP version 1.4.3 when
the channel is configured at that version or higher.

Change-Id: I483d3b3c139049c1c8437b7ebb2d46edf5f5854d
Signed-off-by: Angelo De Caro <[email protected]>
  • Loading branch information
adecaro committed Sep 17, 2019
1 parent 9ad8706 commit d2afa53
Show file tree
Hide file tree
Showing 6 changed files with 58 additions and 17 deletions.
15 changes: 12 additions & 3 deletions common/capabilities/channel.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ const (
// ChannelV1_4_2 is the capabilities string for standard new non-backwards compatible fabric v1.4.2 channel capabilities.
ChannelV1_4_2 = "V1_4_2"

// ChannelV1_4_3 is the capabilities string for standard new non-backwards compatible fabric v1.4.3 channel capabilities.
ChannelV1_4_3 = "V1_4_3"

// ChannelV2_0 is the capabilities string for standard new non-backwards compatible fabric v2.0 channel capabilities.
ChannelV2_0 = "V2_0"
)
Expand All @@ -33,6 +36,7 @@ type ChannelProvider struct {
v11 bool
v13 bool
v142 bool
v143 bool
v20 bool
}

Expand All @@ -43,6 +47,7 @@ func NewChannelProvider(capabilities map[string]*cb.Capability) *ChannelProvider
_, cp.v11 = capabilities[ChannelV1_1]
_, cp.v13 = capabilities[ChannelV1_3]
_, cp.v142 = capabilities[ChannelV1_4_2]
_, cp.v143 = capabilities[ChannelV1_4_3]
_, cp.v20 = capabilities[ChannelV2_0]
return cp
}
Expand All @@ -58,6 +63,8 @@ func (cp *ChannelProvider) HasCapability(capability string) bool {
// Add new capability names here
case ChannelV2_0:
return true
case ChannelV1_4_3:
return true
case ChannelV1_4_2:
return true
case ChannelV1_3:
Expand All @@ -72,7 +79,9 @@ func (cp *ChannelProvider) HasCapability(capability string) bool {
// MSPVersion returns the level of MSP support required by this channel.
func (cp *ChannelProvider) MSPVersion() msp.MSPVersion {
switch {
case cp.v13 || cp.v142 || cp.v20:
case cp.v143 || cp.v20:
return msp.MSPv1_4_3
case cp.v13 || cp.v142:
return msp.MSPv1_3
case cp.v11:
return msp.MSPv1_1
Expand All @@ -83,10 +92,10 @@ func (cp *ChannelProvider) MSPVersion() msp.MSPVersion {

// ConsensusTypeMigration return true if consensus-type migration is supported and permitted in both orderer and peer.
func (cp *ChannelProvider) ConsensusTypeMigration() bool {
return cp.v142 || cp.v20
return cp.v142 || cp.v143 || cp.v20
}

// OrgSpecificOrdererEndpoints allows for individual orderer orgs to specify their external addresses for their OSNs.
func (cp *ChannelProvider) OrgSpecificOrdererEndpoints() bool {
return cp.v142 || cp.v20
return cp.v142 || cp.v143 || cp.v20
}
22 changes: 21 additions & 1 deletion common/capabilities/channel_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,12 +70,32 @@ func TestChannelV142(t *testing.T) {
assert.True(t, cp.OrgSpecificOrdererEndpoints())
}

func TestChannelV143(t *testing.T) {
cp := NewChannelProvider(map[string]*cb.Capability{
ChannelV1_3: {},
ChannelV1_4_2: {},
ChannelV1_4_3: {},
})
assert.NoError(t, cp.Supported())
assert.True(t, cp.MSPVersion() == msp.MSPv1_4_3)
assert.True(t, cp.ConsensusTypeMigration())
assert.True(t, cp.OrgSpecificOrdererEndpoints())

cp = NewChannelProvider(map[string]*cb.Capability{
ChannelV1_4_3: {},
})
assert.NoError(t, cp.Supported())
assert.True(t, cp.MSPVersion() == msp.MSPv1_4_3)
assert.True(t, cp.ConsensusTypeMigration())
assert.True(t, cp.OrgSpecificOrdererEndpoints())
}

func TestChannelV20(t *testing.T) {
cp := NewChannelProvider(map[string]*cb.Capability{
ChannelV2_0: {},
})
assert.NoError(t, cp.Supported())
assert.True(t, cp.MSPVersion() == msp.MSPv1_3)
assert.True(t, cp.MSPVersion() == msp.MSPv1_4_3)
assert.True(t, cp.ConsensusTypeMigration())
assert.True(t, cp.OrgSpecificOrdererEndpoints())
}
Expand Down
12 changes: 12 additions & 0 deletions core/peer/pkg_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,18 @@ func createMSPConfig(rootCerts, tlsRootCerts, tlsIntermediateCerts [][]byte,
TlsRootCerts: tlsRootCerts,
TlsIntermediateCerts: tlsIntermediateCerts,
Name: mspID,
FabricNodeOus: &mspproto.FabricNodeOUs{
Enable: true,
ClientOuIdentifier: &mspproto.FabricOUIdentifier{
OrganizationalUnitIdentifier: "client",
},
PeerOuIdentifier: &mspproto.FabricOUIdentifier{
OrganizationalUnitIdentifier: "peer",
},
AdminOuIdentifier: &mspproto.FabricOUIdentifier{
OrganizationalUnitIdentifier: "admin",
},
},
}

fmpsjs, err := proto.Marshal(fmspconf)
Expand Down
8 changes: 4 additions & 4 deletions msp/factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const (
MSPv1_0 = iota
MSPv1_1
MSPv1_3
MSPv1_4_2
MSPv1_4_3
)

// NewOpts represent
Expand Down Expand Up @@ -56,14 +56,14 @@ func New(opts NewOpts, cryptoProvider bccsp.BCCSP) (MSP, error) {
return newBccspMsp(MSPv1_1, cryptoProvider)
case MSPv1_3:
return newBccspMsp(MSPv1_3, cryptoProvider)
case MSPv1_4_2:
return newBccspMsp(MSPv1_4_2, cryptoProvider)
case MSPv1_4_3:
return newBccspMsp(MSPv1_4_3, cryptoProvider)
default:
return nil, errors.Errorf("Invalid *BCCSPNewOpts. Version not recognized [%v]", opts.GetVersion())
}
case *IdemixNewOpts:
switch opts.GetVersion() {
case MSPv1_4_2:
case MSPv1_4_3:
fallthrough
case MSPv1_3:
return newIdemixMsp(MSPv1_3)
Expand Down
2 changes: 1 addition & 1 deletion msp/mspimpl.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ func newBccspMsp(version MSPVersion, defaultBCCSP bccsp.BCCSP) (MSP, error) {
theMsp.internalValidateIdentityOusFunc = theMsp.validateIdentityOUsV11
theMsp.internalSatisfiesPrincipalInternalFunc = theMsp.satisfiesPrincipalInternalV13
theMsp.internalSetupAdmin = theMsp.setupAdminsPreV142
case MSPv1_4_2:
case MSPv1_4_3:
theMsp.internalSetupFunc = theMsp.setupV142
theMsp.internalValidateIdentityOusFunc = theMsp.validateIdentityOUsV142
theMsp.internalSatisfiesPrincipalInternalFunc = theMsp.satisfiesPrincipalInternalV142
Expand Down
16 changes: 8 additions & 8 deletions msp/nodeous_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ func TestSatisfiesPrincipalClient(t *testing.T) {
func TestSatisfiesPrincipalAdmin(t *testing.T) {
// testdata/nodeouadmin:
// the configuration enables NodeOUs (with adminOU) and admin and signing identity are valid
thisMSP := getLocalMSPWithVersion(t, "testdata/nodeouadmin", MSPv1_4_2)
thisMSP := getLocalMSPWithVersion(t, "testdata/nodeouadmin", MSPv1_4_3)
assert.True(t, thisMSP.(*bccspmsp).ouEnforcement)

cert, err := readFile("testdata/nodeouadmin/adm/testadmincert.pem")
Expand Down Expand Up @@ -271,7 +271,7 @@ func TestLoad142MSPWithInvalidAdminConfiguration(t *testing.T) {
assert.NoError(t, err)
cryptoProvider, err := sw.NewDefaultSecurityLevelWithKeystore(sw.NewDummyKeyStore())
assert.NoError(t, err)
thisMSP, err := NewBccspMspWithKeyStore(MSPv1_4_2, ks, cryptoProvider)
thisMSP, err := NewBccspMspWithKeyStore(MSPv1_4_3, ks, cryptoProvider)
assert.NoError(t, err)

err = thisMSP.Setup(conf)
Expand All @@ -285,7 +285,7 @@ func TestLoad142MSPWithInvalidAdminConfiguration(t *testing.T) {

ks, err = sw.NewFileBasedKeyStore(nil, filepath.Join("testdata/nodeouadmin3", "keystore"), true)
assert.NoError(t, err)
thisMSP, err = NewBccspMspWithKeyStore(MSPv1_4_2, ks, cryptoProvider)
thisMSP, err = NewBccspMspWithKeyStore(MSPv1_4_3, ks, cryptoProvider)
assert.NoError(t, err)

err = thisMSP.Setup(conf)
Expand All @@ -296,7 +296,7 @@ func TestLoad142MSPWithInvalidAdminConfiguration(t *testing.T) {
func TestSatisfiesPrincipalOrderer(t *testing.T) {
// testdata/nodeouorderer:
// the configuration enables NodeOUs (with orderOU)
thisMSP := getLocalMSPWithVersion(t, "testdata/nodeouorderer", MSPv1_4_2)
thisMSP := getLocalMSPWithVersion(t, "testdata/nodeouorderer", MSPv1_4_3)
assert.True(t, thisMSP.(*bccspmsp).ouEnforcement)

id, err := thisMSP.(*bccspmsp).GetDefaultSigningIdentity()
Expand All @@ -321,7 +321,7 @@ func TestLoad142MSPWithInvalidOrdererConfiguration(t *testing.T) {
assert.NoError(t, err)
cryptoProvider, err := sw.NewDefaultSecurityLevelWithKeystore(sw.NewDummyKeyStore())
assert.NoError(t, err)
thisMSP, err := NewBccspMspWithKeyStore(MSPv1_4_2, ks, cryptoProvider)
thisMSP, err := NewBccspMspWithKeyStore(MSPv1_4_3, ks, cryptoProvider)
assert.NoError(t, err)

err = thisMSP.Setup(conf)
Expand All @@ -345,7 +345,7 @@ func TestLoad142MSPWithInvalidOrdererConfiguration(t *testing.T) {

ks, err = sw.NewFileBasedKeyStore(nil, filepath.Join("testdata/nodeouorderer3", "keystore"), true)
assert.NoError(t, err)
thisMSP, err = NewBccspMspWithKeyStore(MSPv1_4_2, ks, cryptoProvider)
thisMSP, err = NewBccspMspWithKeyStore(MSPv1_4_3, ks, cryptoProvider)
assert.NoError(t, err)

err = thisMSP.Setup(conf)
Expand All @@ -370,7 +370,7 @@ func TestValidMSPWithNodeOUMissingClassification(t *testing.T) {
assert.Error(t, err)
assert.Equal(t, "Failed setting up NodeOUs. ClientOU must be different from nil.", err.Error())

_, err = getLocalMSPWithVersionAndError(t, "testdata/nodeousbadconf1", MSPv1_4_2)
_, err = getLocalMSPWithVersionAndError(t, "testdata/nodeousbadconf1", MSPv1_4_3)
assert.Error(t, err)
assert.Equal(t, "admin 0 is invalid [cannot test for classification, node ou for type [CLIENT], not defined, msp: [SampleOrg],The identity does not contain OU [ADMIN], MSP: [SampleOrg]]", err.Error())

Expand All @@ -380,6 +380,6 @@ func TestValidMSPWithNodeOUMissingClassification(t *testing.T) {
assert.Error(t, err)
assert.Equal(t, "Failed setting up NodeOUs. PeerOU must be different from nil.", err.Error())

_, err = getLocalMSPWithVersionAndError(t, "testdata/nodeousbadconf2", MSPv1_4_2)
_, err = getLocalMSPWithVersionAndError(t, "testdata/nodeousbadconf2", MSPv1_4_3)
assert.NoError(t, err)
}

0 comments on commit d2afa53

Please sign in to comment.