Skip to content

Commit ccbfd89

Browse files
author
Jason Yellick
committed
[FAB-9003] Add chaincode lifecycle capability
Although chaincode lifecycle is projected to be part of Fabric v1.2, for development purposes, tying it to the V1_2 capability upfront is not an option, as until everything is in place, we need to keep the code path disabled. Therefore, this CR defines a new capability for chaincode lifecycle which may be turned on separately. It is marked as experimental in the spirit of being able to cut a release at any point. However, the expectation is that this capability will disappear and the chaincode lifecycle will be enabled through the v1.2 capability. Change-Id: I61cdd106c907b4676d35eb1f288f69e578c83aad Signed-off-by: Jason Yellick <jyellick@us.ibm.com>
1 parent 10fdcc9 commit ccbfd89

File tree

6 files changed

+40
-0
lines changed

6 files changed

+40
-0
lines changed

common/capabilities/application.go

+15
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,12 @@ const (
2424

2525
// ApplicationResourcesTreeExperimental is the capabilties string for private data using the experimental feature of collections/sideDB.
2626
ApplicationResourcesTreeExperimental = "V1_1_RESOURCETREE_EXPERIMENTAL"
27+
28+
// ApplicationChaincodeLifecycleExperimental is the capabilties string for improved chaincode lifecycle
29+
// which is targetted to be a real feature for v1.2, but which is being included only as experimental
30+
// during development. This string will hopefully be removed prior to the release of v1.2 and
31+
// Will be enabled along with ApplicationV1_2
32+
ApplicationChaincodeLifecycleExperimental = "V1_2_CHAINCODE_LIFECYCLE_EXPERIMENTAL"
2733
)
2834

2935
// ApplicationProvider provides capabilities information for application level config.
@@ -33,6 +39,7 @@ type ApplicationProvider struct {
3339
v12 bool
3440
v11PvtDataExperimental bool
3541
v11ResourcesTreeExperimental bool
42+
v12LifecycleExperimental bool
3643
}
3744

3845
// NewApplicationProvider creates a application capabilities provider.
@@ -43,6 +50,7 @@ func NewApplicationProvider(capabilities map[string]*cb.Capability) *Application
4350
_, ap.v12 = capabilities[ApplicationV1_2]
4451
_, ap.v11PvtDataExperimental = capabilities[ApplicationPvtDataExperimental]
4552
_, ap.v11ResourcesTreeExperimental = capabilities[ApplicationResourcesTreeExperimental]
53+
_, ap.v12LifecycleExperimental = capabilities[ApplicationChaincodeLifecycleExperimental]
4654
return ap
4755
}
4856

@@ -72,3 +80,10 @@ func (ap *ApplicationProvider) PrivateChannelData() bool {
7280
func (ap *ApplicationProvider) V1_1Validation() bool {
7381
return ap.v11 || ap.v12
7482
}
83+
84+
// MetadataLifecycle indicates whether the peer should use the deprecated and problematic
85+
// v1.0/v1.1 lifecycle, or whether it should use the newer per channel peer local chaincode
86+
// metadata package approach planned for release with Fabric v1.2
87+
func (ap *ApplicationProvider) MetadataLifecycle() bool {
88+
return ap.v12LifecycleExperimental
89+
}

common/capabilities/application_experimental.go

+2
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ func (ap *ApplicationProvider) HasCapability(capability string) bool {
2020
return true
2121
case ApplicationResourcesTreeExperimental:
2222
return true
23+
case ApplicationChaincodeLifecycleExperimental:
24+
return true
2325
default:
2426
return false
2527
}

common/capabilities/application_test.go

+7
Original file line numberDiff line numberDiff line change
@@ -43,3 +43,10 @@ func TestApplicationPvtDataExperimental(t *testing.T) {
4343
})
4444
assert.True(t, op.PrivateChannelData())
4545
}
46+
47+
func TestChaincodeLifecycleExperimental(t *testing.T) {
48+
op := NewApplicationProvider(map[string]*cb.Capability{
49+
ApplicationChaincodeLifecycleExperimental: {},
50+
})
51+
assert.True(t, op.MetadataLifecycle())
52+
}

common/channelconfig/api.go

+5
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,11 @@ type ApplicationCapabilities interface {
129129
// V1_1Validation returns true is this channel is configured to perform stricter validation
130130
// of transactions (as introduced in v1.1).
131131
V1_1Validation() bool
132+
133+
// MetadataLifecycle indicates whether the peer should use the deprecated and problematic
134+
// v1.0/v1.1 lifecycle, or whether it should use the newer per channel peer local chaincode
135+
// metadata package approach planned for release with Fabric v1.2
136+
MetadataLifecycle() bool
132137
}
133138

134139
// OrdererCapabilities defines the capabilities for the orderer portion of a channel

common/mocks/config/application.go

+5
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ type MockApplicationCapabilities struct {
2626
ResourcesTreeRv bool
2727
PrivateChannelDataRv bool
2828
V1_1ValidationRv bool
29+
MetadataLifecycleRv bool
2930
}
3031

3132
func (mac *MockApplicationCapabilities) Supported() error {
@@ -47,3 +48,7 @@ func (mac *MockApplicationCapabilities) PrivateChannelData() bool {
4748
func (mac *MockApplicationCapabilities) V1_1Validation() bool {
4849
return mac.V1_1ValidationRv
4950
}
51+
52+
func (mac *MockApplicationCapabilities) MetadataLifecycle() bool {
53+
return mac.MetadataLifecycleRv
54+
}

sampleconfig/configtx.yaml

+6
Original file line numberDiff line numberDiff line change
@@ -332,3 +332,9 @@ Capabilities:
332332
# NOTE: Use of this feature with non "experimental" binaries on
333333
# the network may cause a fork.
334334
V1_1_RESOURCETREE_EXPERIMENTAL: false
335+
# V1_2_CHAINCODE_LIFECYCLE_EXPERIMENTAL is an Application capability
336+
# to enable the new lifecycle semantics of "Install Code, Install
337+
# Metadata to a Channel, Define Chaincode, Init Chaincode"
338+
# This is an in development feature and is useful only for developer
339+
# testing at this time.
340+
V1_2_CHAINCODE_LIFECYCLE_EXPERIMENTAL: false

0 commit comments

Comments
 (0)