Skip to content

Commit

Permalink
[FAB-9002] Define new application v1.2 capability
Browse files Browse the repository at this point in the history
For all the non-backwards compatible work, including the new chaincode
lifecycle and resources config changes, we must use a new capability to
determine whether the behavior is enabled or not.

This CR adds one for the application portion of the config.  At the time
of this writing there are no features which would introduce
incompatibilities at the orderer or channel level, so those capabilities
are being left in place.

This CR also removes the assorted 'V11' profiles, as maintaining a set
of profiles for each version is unmaintainable and confusing.  For this
and subsequent releases, configtx.yaml will contain only defaults for
the current version of fabric.  Users may of course override these
defaults by modifying the config file.

Change-Id: I08729fef76292044440ebc7e4f39145b0640afc4
Signed-off-by: Jason Yellick <jyellick@us.ibm.com>
  • Loading branch information
Jason Yellick committed Mar 22, 2018
1 parent 149d4f5 commit 10fdcc9
Show file tree
Hide file tree
Showing 11 changed files with 103 additions and 172 deletions.
9 changes: 7 additions & 2 deletions common/capabilities/application.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ const (
// ApplicationV1_1 is the capabilties string for standard new non-backwards compatible fabric v1.1 application capabilities.
ApplicationV1_1 = "V1_1"

// ApplicationV1_2 is the capabilties string for standard new non-backwards compatible fabric v1.2 application capabilities.
ApplicationV1_2 = "V1_2"

// ApplicationPvtDataExperimental is the capabilties string for private data using the experimental feature of collections/sideDB.
ApplicationPvtDataExperimental = "V1_1_PVTDATA_EXPERIMENTAL"

Expand All @@ -27,6 +30,7 @@ const (
type ApplicationProvider struct {
*registry
v11 bool
v12 bool
v11PvtDataExperimental bool
v11ResourcesTreeExperimental bool
}
Expand All @@ -36,6 +40,7 @@ func NewApplicationProvider(capabilities map[string]*cb.Capability) *Application
ap := &ApplicationProvider{}
ap.registry = newRegistry(ap, capabilities)
_, ap.v11 = capabilities[ApplicationV1_1]
_, ap.v12 = capabilities[ApplicationV1_2]
_, ap.v11PvtDataExperimental = capabilities[ApplicationPvtDataExperimental]
_, ap.v11ResourcesTreeExperimental = capabilities[ApplicationResourcesTreeExperimental]
return ap
Expand All @@ -54,7 +59,7 @@ func (ap *ApplicationProvider) ResourcesTree() bool {
// ForbidDuplicateTXIdInBlock specifies whether two transactions with the same TXId are permitted
// in the same block or whether we mark the second one as TxValidationCode_DUPLICATE_TXID
func (ap *ApplicationProvider) ForbidDuplicateTXIdInBlock() bool {
return ap.v11
return ap.v11 || ap.v12
}

// PrivateChannelData returns true if support for private channel data (a.k.a. collections) is enabled.
Expand All @@ -65,5 +70,5 @@ func (ap *ApplicationProvider) PrivateChannelData() bool {
// V1_1Validation returns true is this channel is configured to perform stricter validation
// of transactions (as introduced in v1.1).
func (ap *ApplicationProvider) V1_1Validation() bool {
return ap.v11
return ap.v11 || ap.v12
}
2 changes: 2 additions & 0 deletions common/capabilities/application_experimental.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ func (ap *ApplicationProvider) HasCapability(capability string) bool {
// Add new capability names here
case ApplicationV1_1:
return true
case ApplicationV1_2:
return true
case ApplicationPvtDataExperimental:
return true
case ApplicationResourcesTreeExperimental:
Expand Down
4 changes: 2 additions & 2 deletions common/capabilities/application_stable.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ func (ap *ApplicationProvider) HasCapability(capability string) bool {
// Add new capability names here
case ApplicationV1_1:
return true
case ApplicationPvtDataExperimental:
return false
case ApplicationV1_2:
return true
default:
return false
}
Expand Down
9 changes: 9 additions & 0 deletions common/capabilities/application_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,15 @@ func TestApplicationV11(t *testing.T) {
assert.True(t, op.V1_1Validation())
}

func TestApplicationV12(t *testing.T) {
op := NewApplicationProvider(map[string]*cb.Capability{
ApplicationV1_2: {},
})
assert.NoError(t, op.Supported())
assert.True(t, op.ForbidDuplicateTXIdInBlock())
assert.True(t, op.V1_1Validation())
}

func TestApplicationPvtDataExperimental(t *testing.T) {
op := NewApplicationProvider(map[string]*cb.Capability{
ApplicationPvtDataExperimental: {},
Expand Down
11 changes: 5 additions & 6 deletions common/tools/configtxgen/encoder/encoder_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,9 @@ func TestConfigParsing(t *testing.T) {
for _, profile := range []string{
genesisconfig.SampleInsecureSoloProfile,
genesisconfig.SampleSingleMSPSoloProfile,
genesisconfig.SampleSingleMSPSoloV11Profile,
genesisconfig.SampleDevModeSoloProfile,
genesisconfig.SampleInsecureKafkaProfile,
genesisconfig.SampleSingleMSPKafkaProfile,
genesisconfig.SampleSingleMSPKafkaV11Profile,
genesisconfig.SampleDevModeKafkaProfile,
} {
t.Run(profile, func(t *testing.T) {
Expand Down Expand Up @@ -93,6 +91,7 @@ func TestGoodChannelCreateConfigUpdate(t *testing.T) {
func TestChannelCreateWithResources(t *testing.T) {
t.Run("AtV1.0", func(t *testing.T) {
createConfig := genesisconfig.Load(genesisconfig.SampleSingleMSPChannelProfile)
createConfig.Application.Capabilities = nil

configUpdate, err := NewChannelCreateConfigUpdate("channel.id", nil, createConfig)
assert.NoError(t, err)
Expand All @@ -101,7 +100,7 @@ func TestChannelCreateWithResources(t *testing.T) {
})

t.Run("AtV1.1", func(t *testing.T) {
createConfig := genesisconfig.Load(genesisconfig.SampleSingleMSPChannelV11Profile)
createConfig := genesisconfig.Load(genesisconfig.SampleSingleMSPChannelProfile)
createConfig.Application.Capabilities[capabilities.ApplicationResourcesTreeExperimental] = true

configUpdate, err := NewChannelCreateConfigUpdate("channel.id", nil, createConfig)
Expand Down Expand Up @@ -151,7 +150,7 @@ func TestMakeChannelCreationTransactionWithSigner(t *testing.T) {
mspmgmt.LoadDevMsp()
signer := localmsp.NewSigner()

cct, err := MakeChannelCreationTransaction(channelID, signer, nil, genesisconfig.Load(genesisconfig.SampleSingleMSPChannelV11Profile))
cct, err := MakeChannelCreationTransaction(channelID, signer, nil, genesisconfig.Load(genesisconfig.SampleSingleMSPChannelProfile))
assert.NoError(t, err, "Making chain creation tx")

assert.NotEmpty(t, cct.Signature, "Should have signature")
Expand Down Expand Up @@ -191,14 +190,14 @@ func TestMakeChannelCreationTransactionNoSigner(t *testing.T) {

func TestNewApplicationGroup(t *testing.T) {
t.Run("Application with capabilities", func(t *testing.T) {
config := genesisconfig.Load(genesisconfig.SampleSingleMSPChannelV11Profile)
config := genesisconfig.Load(genesisconfig.SampleSingleMSPChannelProfile)
group, err := NewApplicationGroup(config.Application)
assert.NoError(t, err)
assert.NotNil(t, group)
})

t.Run("Application unknown MSP", func(t *testing.T) {
config := genesisconfig.Load(genesisconfig.SampleSingleMSPChannelV11Profile)
config := genesisconfig.Load(genesisconfig.SampleSingleMSPChannelProfile)
config.Application.Organizations[0] = &genesisconfig.Organization{Name: "FakeOrg", ID: "FakeOrg"}
group, err := NewApplicationGroup(config.Application)
assert.Error(t, err)
Expand Down
11 changes: 1 addition & 10 deletions common/tools/configtxgen/localconfig/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,28 +53,18 @@ const (
SampleInsecureSoloProfile = "SampleInsecureSolo"
// SampleDevModeSoloProfile references the sample profile which requires only basic membership for admin privileges and uses solo for ordering.
SampleDevModeSoloProfile = "SampleDevModeSolo"
// SampleDevModeSoloProfileV11 references the sample profile which requires only basic membership for admin privileges and uses solo for ordering, but has v1.1 capabilities enabled
SampleDevModeSoloV11Profile = "SampleDevModeSoloV1_1"
// SampleSingleMSPSoloProfile references the sample profile which includes only the sample MSP and uses solo for ordering.
SampleSingleMSPSoloProfile = "SampleSingleMSPSolo"
// SampleSingleMSPSoloV11Profile references the sample profile which includes only the sample MSP with v1.1 capabilities defined and uses solo for ordering.
SampleSingleMSPSoloV11Profile = "SampleSingleMSPSoloV1_1"

// SampleInsecureKafkaProfile references the sample profile which does not include any MSPs and uses Kafka for ordering.
SampleInsecureKafkaProfile = "SampleInsecureKafka"
// SampleDevModeKafkaProfile references the sample profile which requires only basic membership for admin privileges and uses Kafka for ordering.
SampleDevModeKafkaProfile = "SampleDevModeKafka"
// SampleDevModeKafkaProfileV11 references the sample profile which requires only basic membership for admin privileges and uses Kafka for ordering, but has v1.1 capabilities enabled.
SampleDevModeKafkaV11Profile = "SampleDevModeKafkaV1_1"
// SampleSingleMSPKafkaProfile references the sample profile which includes only the sample MSP and uses Kafka for ordering.
SampleSingleMSPKafkaProfile = "SampleSingleMSPKafka"
// SampleSingleMSPKafkaV11Profile references the sample profile which includes only the sample MSP with v1.1 capabilities defined and uses Kafka for ordering.
SampleSingleMSPKafkaV11Profile = "SampleSingleMSPKafkaV1_1"

// SampleSingleMSPChannelProfile references the sample profile which includes only the sample MSP and is used to create a channel
SampleSingleMSPChannelProfile = "SampleSingleMSPChannel"
// SampleSingleMSPChannelV11Profile references the sample profile which includes only the sample MSP with v1.1 capabilities and is used to create a channel
SampleSingleMSPChannelV11Profile = "SampleSingleMSPChannelV1_1"

// SampleConsortiumName is the sample consortium from the sample configtx.yaml
SampleConsortiumName = "SampleConsortium"
Expand All @@ -91,6 +81,7 @@ const (
type TopLevel struct {
Profiles map[string]*Profile `yaml:"Profiles"`
Organizations []*Organization `yaml:"Organizations"`
Channel *Profile `yaml:"Channel"`
Application *Application `yaml:"Application"`
Orderer *Orderer `yaml:"Orderer"`
Capabilities map[string]map[string]bool `yaml:"Capabilities"`
Expand Down
5 changes: 0 additions & 5 deletions common/tools/configtxgen/localconfig/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,9 @@ func TestLoadProfile(t *testing.T) {
pNames := []string{
SampleDevModeKafkaProfile,
SampleDevModeSoloProfile,
SampleInsecureKafkaProfile,
SampleInsecureSoloProfile,
SampleSingleMSPChannelProfile,
SampleSingleMSPChannelV11Profile,
SampleSingleMSPKafkaProfile,
SampleSingleMSPKafkaV11Profile,
SampleSingleMSPSoloProfile,
SampleSingleMSPSoloV11Profile,
}
for _, pName := range pNames {
t.Run(pName, func(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion examples/e2e_cli/configtx.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -204,4 +204,4 @@ Capabilities:
# determined to be desired for all peers running v1.0.x, but the
# modification of which would cause incompatibilities. Users should
# leave this flag set to true.
V1_1: true
V1_2: true
4 changes: 2 additions & 2 deletions orderer/common/server/benchmark_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,11 +110,11 @@ const (
// be less than 13 KB.
AbsoluteMaxBytes = 15 // KB
PreferredMaxBytes = 10 // KB
ChannelProfile = localconfig.SampleSingleMSPChannelV11Profile
ChannelProfile = localconfig.SampleSingleMSPChannelProfile
)

var envvars = map[string]string{
"ORDERER_GENERAL_GENESISPROFILE": localconfig.SampleDevModeSoloV11Profile,
"ORDERER_GENERAL_GENESISPROFILE": localconfig.SampleDevModeSoloProfile,
"ORDERER_GENERAL_LEDGERTYPE": "file",
"ORDERER_GENERAL_LOGLEVEL": "error",
"ORDERER_KAFKA_VERBOSE": "false",
Expand Down
1 change: 1 addition & 0 deletions orderer/sample_clients/broadcast_config/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ type argsImpl struct {
}

func init() {
var err error
conf, err = config.Load()
if err != nil {
fmt.Println("failed to load config:", err)
Expand Down
Loading

0 comments on commit 10fdcc9

Please sign in to comment.