Skip to content

Commit d971c17

Browse files
committed
remove unused parameters from config block
Signed-off-by: Senthilnathan <cendhu@gmail.com>
1 parent 00f397e commit d971c17

12 files changed

Lines changed: 18 additions & 288 deletions

File tree

common/channelconfig/channel.go

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -182,13 +182,6 @@ func (cc *ChannelConfig) Validate(channelCapabilities ChannelCapabilities) error
182182
}
183183
}
184184

185-
// We check global orderer addresses only if we are below ChannelV1_4_2
186-
if !channelCapabilities.OrgSpecificOrdererEndpoints() {
187-
if err := cc.validateOrdererAddresses(); err != nil {
188-
return err
189-
}
190-
}
191-
192185
// We validate no global endpoints at V3_0 or above
193186
if channelCapabilities.ConsensusTypeBFT() {
194187
return cc.validateNoOrdererAddresses()

common/channelconfig/orderer.go

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -90,12 +90,6 @@ func NewOrdererOrgConfig(orgName string, orgGroup *cb.ConfigGroup, mspConfigHand
9090
return nil, fmt.Errorf("OrdererOrg config does not allow sub-groups")
9191
}
9292

93-
if !channelCapabilities.OrgSpecificOrdererEndpoints() {
94-
if _, ok := orgGroup.Values[EndpointsKey]; ok {
95-
return nil, errors.Errorf("Orderer Org %s cannot contain endpoints value until V1_4_2+ capabilities have been enabled", orgName)
96-
}
97-
}
98-
9993
protos := &OrdererOrgProtos{}
10094
orgProtos := &OrganizationProtos{}
10195

@@ -146,7 +140,7 @@ func NewOrdererConfig(ordererGroup *cb.ConfigGroup, mspConfig *MSPConfigHandler,
146140
}
147141
}
148142

149-
if channelCapabilities.ConsensusTypeBFT() {
143+
if oc.ConsensusType() == "arma" || oc.ConsensusType() == "BFT" {
150144
if err := oc.validateAllOrgsHaveEndpoints(); err != nil {
151145
return nil, err
152146
}

common/channelconfig/realconfig_test.go

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ SPDX-License-Identifier: Apache-2.0
77
package channelconfig_test
88

99
import (
10+
"path/filepath"
1011
"testing"
1112

1213
"github.com/hyperledger/fabric-lib-go/bccsp/sw"
@@ -34,8 +35,11 @@ func TestWithRealConfigTX(t *testing.T) {
3435
}
3536

3637
func TestOrgSpecificOrdererEndpoints(t *testing.T) {
37-
t.Run("could not create channel orderer config with empty organization endpoints", func(t *testing.T) {
38-
conf := configtxgen.Load(configtxgen.SampleDevModeSoloProfile, configtest.GetDevConfigDir())
38+
t.Parallel()
39+
t.Run("could not create arma orderer config with empty organization endpoints", func(t *testing.T) {
40+
t.Parallel()
41+
conf := configtxgen.Load(configtxgen.SampleFabricX, configtest.GetDevConfigDir())
42+
conf.Orderer.Arma.Path = filepath.Join(configtest.GetDevConfigDir(), "arma_shared_config.pbbin")
3943

4044
cg, err := configtxgen.NewChannelGroup(conf)
4145
require.NoError(t, err)
@@ -49,6 +53,7 @@ func TestOrgSpecificOrdererEndpoints(t *testing.T) {
4953
})
5054

5155
t.Run("could not create channelgroup with empty organization endpoints", func(t *testing.T) {
56+
t.Parallel()
5257
conf := configtxgen.Load(configtxgen.SampleDevModeSoloProfile, configtest.GetDevConfigDir())
5358
conf.Capabilities = map[string]bool{"V3_0": true}
5459
conf.Orderer.Organizations[0].OrdererEndpoints = nil
@@ -69,6 +74,7 @@ func TestOrgSpecificOrdererEndpoints(t *testing.T) {
6974
})
7075

7176
t.Run("With V2_0 Capability", func(t *testing.T) {
77+
t.Parallel()
7278
conf := configtxgen.Load(configtxgen.SampleDevModeSoloProfile, configtest.GetDevConfigDir())
7379
conf.Capabilities = map[string]bool{"V2_0": true}
7480
require.NotEmpty(t, conf.Orderer.Organizations[0].OrdererEndpoints)
@@ -88,6 +94,7 @@ func TestOrgSpecificOrdererEndpoints(t *testing.T) {
8894
})
8995

9096
t.Run("no global address With V3_0 Capability", func(t *testing.T) {
97+
t.Parallel()
9198
conf := configtxgen.Load(configtxgen.SampleDevModeSoloProfile, configtest.GetDevConfigDir())
9299
conf.Orderer.Addresses = []string{"globalAddress"}
93100
conf.Capabilities = map[string]bool{"V3_0": true}

common/deliverclient/verifier_assembler.go

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -42,15 +42,11 @@ func (bva *BlockVerifierAssembler) VerifierFromConfig(configuration *common.Conf
4242
return createErrorFunc(err), err
4343
}
4444

45-
bftEnabled := bundle.ChannelConfig().Capabilities().ConsensusTypeBFT()
45+
cfg, ok := bundle.OrdererConfig()
46+
bftEnabled := ok && (cfg.ConsensusType() == "BFT" || cfg.ConsensusType() == "arma")
4647

4748
var consenters []*common.Consenter
4849
if bftEnabled {
49-
cfg, ok := bundle.OrdererConfig()
50-
if !ok {
51-
err := errors.New("no orderer section in config block")
52-
return createErrorFunc(err), err
53-
}
5450
consenters = cfg.Consenters()
5551
}
5652

core/aclmgmt/defaultaclprovider.go

Lines changed: 0 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ import (
1313
pb "github.com/hyperledger/fabric-protos-go-apiv2/peer"
1414

1515
"github.com/hyperledger/fabric-x-common/common/policies"
16-
"github.com/hyperledger/fabric-x-common/core/aclmgmt/resources"
1716
"github.com/hyperledger/fabric-x-common/core/policy"
1817
"github.com/hyperledger/fabric-x-common/protoutil"
1918
)
@@ -47,73 +46,6 @@ func newDefaultACLProvider(policyChecker policy.PolicyChecker) defaultACLProvide
4746
cResourcePolicyMap: map[string]string{},
4847
}
4948

50-
// -------------- _lifecycle --------------
51-
d.pResourcePolicyMap[resources.Lifecycle_InstallChaincode] = policy.Admins
52-
d.pResourcePolicyMap[resources.Lifecycle_QueryInstalledChaincode] = policy.Admins
53-
d.pResourcePolicyMap[resources.Lifecycle_GetInstalledChaincodePackage] = policy.Admins
54-
d.pResourcePolicyMap[resources.Lifecycle_QueryInstalledChaincodes] = policy.Admins
55-
d.pResourcePolicyMap[resources.Lifecycle_ApproveChaincodeDefinitionForMyOrg] = policy.Admins
56-
d.pResourcePolicyMap[resources.Lifecycle_QueryApprovedChaincodeDefinition] = policy.Admins
57-
d.pResourcePolicyMap[resources.Lifecycle_QueryApprovedChaincodeDefinitions] = policy.Admins
58-
59-
d.cResourcePolicyMap[resources.Lifecycle_CommitChaincodeDefinition] = CHANNELWRITERS
60-
d.cResourcePolicyMap[resources.Lifecycle_QueryChaincodeDefinition] = CHANNELWRITERS
61-
d.cResourcePolicyMap[resources.Lifecycle_QueryChaincodeDefinitions] = CHANNELWRITERS
62-
d.cResourcePolicyMap[resources.Lifecycle_CheckCommitReadiness] = CHANNELWRITERS
63-
64-
// -------------- snapshot ---------------
65-
d.pResourcePolicyMap[resources.Snapshot_submitrequest] = policy.Admins
66-
d.pResourcePolicyMap[resources.Snapshot_cancelrequest] = policy.Admins
67-
d.pResourcePolicyMap[resources.Snapshot_listpending] = policy.Admins
68-
69-
// -------------- LSCC --------------
70-
// p resources (implemented by the chaincode currently)
71-
d.pResourcePolicyMap[resources.Lscc_Install] = policy.Admins
72-
d.pResourcePolicyMap[resources.Lscc_GetInstalledChaincodes] = policy.Admins
73-
74-
// c resources
75-
d.cResourcePolicyMap[resources.Lscc_Deploy] = "" // ACL check covered by PROPOSAL
76-
d.cResourcePolicyMap[resources.Lscc_Upgrade] = "" // ACL check covered by PROPOSAL
77-
d.cResourcePolicyMap[resources.Lscc_ChaincodeExists] = CHANNELREADERS
78-
d.cResourcePolicyMap[resources.Lscc_GetDeploymentSpec] = CHANNELREADERS
79-
d.cResourcePolicyMap[resources.Lscc_GetChaincodeData] = CHANNELREADERS
80-
d.cResourcePolicyMap[resources.Lscc_GetInstantiatedChaincodes] = CHANNELREADERS
81-
d.cResourcePolicyMap[resources.Lscc_GetCollectionsConfig] = CHANNELREADERS
82-
83-
// -------------- QSCC --------------
84-
// p resources (none)
85-
86-
// c resources
87-
d.cResourcePolicyMap[resources.Qscc_GetChainInfo] = CHANNELREADERS
88-
d.cResourcePolicyMap[resources.Qscc_GetBlockByNumber] = CHANNELREADERS
89-
d.cResourcePolicyMap[resources.Qscc_GetBlockByHash] = CHANNELREADERS
90-
d.cResourcePolicyMap[resources.Qscc_GetTransactionByID] = CHANNELREADERS
91-
d.cResourcePolicyMap[resources.Qscc_GetBlockByTxID] = CHANNELREADERS
92-
93-
// --------------- CSCC resources -----------
94-
// p resources (implemented by the chaincode currently)
95-
d.pResourcePolicyMap[resources.Cscc_JoinChain] = policy.Admins
96-
d.pResourcePolicyMap[resources.Cscc_JoinChainBySnapshot] = policy.Admins
97-
d.pResourcePolicyMap[resources.Cscc_JoinBySnapshotStatus] = policy.Admins
98-
d.pResourcePolicyMap[resources.Cscc_GetChannels] = policy.Members
99-
100-
// c resources
101-
d.cResourcePolicyMap[resources.Cscc_GetConfigBlock] = CHANNELREADERS
102-
d.cResourcePolicyMap[resources.Cscc_GetChannelConfig] = CHANNELREADERS
103-
104-
// ---------------- non-scc resources ------------
105-
// Peer resources
106-
d.cResourcePolicyMap[resources.Peer_Propose] = CHANNELWRITERS
107-
d.cResourcePolicyMap[resources.Peer_ChaincodeToChaincode] = CHANNELWRITERS
108-
109-
// Event resources
110-
d.cResourcePolicyMap[resources.Event_Block] = CHANNELREADERS
111-
d.cResourcePolicyMap[resources.Event_FilteredBlock] = CHANNELREADERS
112-
113-
// Gateway resources
114-
d.cResourcePolicyMap[resources.Gateway_CommitStatus] = CHANNELREADERS
115-
d.cResourcePolicyMap[resources.Gateway_ChaincodeEvents] = CHANNELREADERS
116-
11749
return d
11850
}
11951

core/aclmgmt/resources/resources.go

Lines changed: 0 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -5,65 +5,4 @@ SPDX-License-Identifier: Apache-2.0
55
*/
66

77
// Package resources contains resource names used in fabric for ACL checks.
8-
// Note that some of the checks such as Lscc_INSTALL are "peer wide" (current
9-
// access checks in peer are based on local MSP). These are not currently
10-
// covered by resource or default ACLProviders
118
package resources
12-
13-
const (
14-
// _lifecycle resources
15-
Lifecycle_InstallChaincode = "_lifecycle/InstallChaincode"
16-
Lifecycle_QueryInstalledChaincode = "_lifecycle/QueryInstalledChaincode"
17-
Lifecycle_GetInstalledChaincodePackage = "_lifecycle/GetInstalledChaincodePackage"
18-
Lifecycle_QueryInstalledChaincodes = "_lifecycle/QueryInstalledChaincodes"
19-
Lifecycle_ApproveChaincodeDefinitionForMyOrg = "_lifecycle/ApproveChaincodeDefinitionForMyOrg"
20-
Lifecycle_QueryApprovedChaincodeDefinition = "_lifecycle/QueryApprovedChaincodeDefinition"
21-
Lifecycle_QueryApprovedChaincodeDefinitions = "_lifecycle/QueryApprovedChaincodeDefinitions"
22-
Lifecycle_CommitChaincodeDefinition = "_lifecycle/CommitChaincodeDefinition"
23-
Lifecycle_QueryChaincodeDefinition = "_lifecycle/QueryChaincodeDefinition"
24-
Lifecycle_QueryChaincodeDefinitions = "_lifecycle/QueryChaincodeDefinitions"
25-
Lifecycle_CheckCommitReadiness = "_lifecycle/CheckCommitReadiness"
26-
27-
// snapshot resources
28-
Snapshot_submitrequest = "snapshot/submitrequest"
29-
Snapshot_cancelrequest = "snapshot/cancelrequest"
30-
Snapshot_listpending = "snapshot/listpending"
31-
32-
// Lscc resources
33-
Lscc_Install = "lscc/Install"
34-
Lscc_Deploy = "lscc/Deploy"
35-
Lscc_Upgrade = "lscc/Upgrade"
36-
Lscc_ChaincodeExists = "lscc/ChaincodeExists"
37-
Lscc_GetDeploymentSpec = "lscc/GetDeploymentSpec"
38-
Lscc_GetChaincodeData = "lscc/GetChaincodeData"
39-
Lscc_GetInstantiatedChaincodes = "lscc/GetInstantiatedChaincodes"
40-
Lscc_GetInstalledChaincodes = "lscc/GetInstalledChaincodes"
41-
Lscc_GetCollectionsConfig = "lscc/GetCollectionsConfig"
42-
43-
// Qscc resources
44-
Qscc_GetChainInfo = "qscc/GetChainInfo"
45-
Qscc_GetBlockByNumber = "qscc/GetBlockByNumber"
46-
Qscc_GetBlockByHash = "qscc/GetBlockByHash"
47-
Qscc_GetTransactionByID = "qscc/GetTransactionByID"
48-
Qscc_GetBlockByTxID = "qscc/GetBlockByTxID"
49-
50-
// Cscc resources
51-
Cscc_JoinChain = "cscc/JoinChain"
52-
Cscc_JoinChainBySnapshot = "cscc/JoinChainBySnapshot"
53-
Cscc_JoinBySnapshotStatus = "cscc/JoinBySnapshotStatus"
54-
Cscc_GetConfigBlock = "cscc/GetConfigBlock"
55-
Cscc_GetChannelConfig = "cscc/GetChannelConfig"
56-
Cscc_GetChannels = "cscc/GetChannels"
57-
58-
// Peer resources
59-
Peer_Propose = "peer/Propose"
60-
Peer_ChaincodeToChaincode = "peer/ChaincodeToChaincode"
61-
62-
// Events
63-
Event_Block = "event/Block"
64-
Event_FilteredBlock = "event/FilteredBlock"
65-
66-
// Gateway resources
67-
Gateway_CommitStatus = "gateway/CommitStatus"
68-
Gateway_ChaincodeEvents = "gateway/ChaincodeEvents"
69-
)

protoutil/blockutils_test.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -586,7 +586,7 @@ func TestBlockSignatureVerifierWithRealPolicy(t *testing.T) {
586586
}
587587
}
588588

589-
//nolint:ireturn,revive
589+
//nolint:ireturn,revive // interface return needed for test
590590
func makePolicyTestEnv(t *testing.T, size int) (policies.Policy, []*cb.Consenter, []uint32, []msp.SigningIdentity) {
591591
t.Helper()
592592
endpoints := make([]*types.OrdererEndpoint, size)
@@ -611,8 +611,7 @@ func makePolicyTestEnv(t *testing.T, size int) (policies.Policy, []*cb.Consenter
611611
oc, ok := configMaterial.Bundle.OrdererConfig()
612612
require.True(t, ok)
613613

614-
bftEnabled := configMaterial.Bundle.ChannelConfig().Capabilities().ConsensusTypeBFT()
615-
require.True(t, bftEnabled)
614+
require.Equal(t, "arma", oc.ConsensusType())
616615
consenters := oc.Consenters()
617616
require.Len(t, consenters, size)
618617

sampleconfig/configtx.yaml

Lines changed: 3 additions & 103 deletions
Original file line numberDiff line numberDiff line change
@@ -136,36 +136,15 @@ Organizations:
136136
Capabilities:
137137
# Channel capabilities apply to both the orderers and the peers and must be
138138
# supported by both.
139-
# Set the value of the capability to true to require it.
140-
Channel: &ChannelCapabilities
141-
# V3.0 for Channel is a catchall flag for behavior which has been
142-
# determined to be desired for all orderers and peers running at the v3.0.0
143-
# level, but which would be incompatible with orderers and peers from
144-
# prior releases.
145-
# Prior to enabling V3.0 channel capabilities, ensure that all
146-
# orderers and peers on a channel are at v3.0.0 or later.
147-
V3_0: true
139+
Channel: &ChannelCapabilities {}
148140

149141
# Orderer capabilities apply only to the orderers, and may be safely
150142
# used with prior release peers.
151-
# Set the value of the capability to true to require it.
152-
Orderer: &OrdererCapabilities
153-
# V1.1 for Orderer is a catchall flag for behavior which has been
154-
# determined to be desired for all orderers running at the v1.1.x
155-
# level, but which would be incompatible with orderers from prior releases.
156-
# Prior to enabling V2.0 orderer capabilities, ensure that all
157-
# orderers on a channel are at v2.0.0 or later.
158-
V2_0: true
143+
Orderer: &OrdererCapabilities {}
159144

160145
# Application capabilities apply only to the peer network, and may be safely
161146
# used with prior release orderers.
162-
# Set the value of the capability to true to require it.
163-
Application: &ApplicationCapabilities
164-
# V2.5 for Application enables the new non-backwards compatible
165-
# features of fabric v2.5, namely the ability to purge private data.
166-
# Prior to enabling V2.5 application capabilities, ensure that all
167-
# peers on a channel are at v2.5.0 or later.
168-
V2_5: true
147+
Application: &ApplicationCapabilities {}
169148

170149
################################################################################
171150
#
@@ -176,85 +155,6 @@ Capabilities:
176155
#
177156
################################################################################
178157
Application: &ApplicationDefaults
179-
ACLs:
180-
# This section provides defaults for policies for various resources
181-
# in the system. These "resources" could be functions on system chaincodes
182-
# (e.g., "GetBlockByNumber" on the "qscc" system chaincode) or other resources
183-
# (e.g.,who can receive Block events). This section does NOT specify the resource's
184-
# definition or API, but just the ACL policy for it.
185-
#
186-
# Users can override these defaults with their own policy mapping by defining the
187-
# mapping under ACLs in their channel definition
188-
189-
#---New Lifecycle System Chaincode (_lifecycle) function to policy mapping for access control--#
190-
191-
# ACL policy for _lifecycle's "CheckCommitReadiness" function
192-
_lifecycle/CheckCommitReadiness: /Channel/Application/Writers
193-
194-
# ACL policy for _lifecycle's "CommitChaincodeDefinition" function
195-
_lifecycle/CommitChaincodeDefinition: /Channel/Application/Writers
196-
197-
# ACL policy for _lifecycle's "QueryChaincodeDefinition" function
198-
_lifecycle/QueryChaincodeDefinition: /Channel/Application/Writers
199-
200-
# ACL policy for _lifecycle's "QueryChaincodeDefinitions" function
201-
_lifecycle/QueryChaincodeDefinitions: /Channel/Application/Writers
202-
203-
#---Lifecycle System Chaincode (lscc) function to policy mapping for access control---#
204-
205-
# ACL policy for lscc's "getid" function
206-
lscc/ChaincodeExists: /Channel/Application/Readers
207-
208-
# ACL policy for lscc's "getdepspec" function
209-
lscc/GetDeploymentSpec: /Channel/Application/Readers
210-
211-
# ACL policy for lscc's "getccdata" function
212-
lscc/GetChaincodeData: /Channel/Application/Readers
213-
214-
# ACL Policy for lscc's "getchaincodes" function
215-
lscc/GetInstantiatedChaincodes: /Channel/Application/Readers
216-
217-
#---Query System Chaincode (qscc) function to policy mapping for access control---#
218-
219-
# ACL policy for qscc's "GetChainInfo" function
220-
qscc/GetChainInfo: /Channel/Application/Readers
221-
222-
# ACL policy for qscc's "GetBlockByNumber" function
223-
qscc/GetBlockByNumber: /Channel/Application/Readers
224-
225-
# ACL policy for qscc's "GetBlockByHash" function
226-
qscc/GetBlockByHash: /Channel/Application/Readers
227-
228-
# ACL policy for qscc's "GetTransactionByID" function
229-
qscc/GetTransactionByID: /Channel/Application/Readers
230-
231-
# ACL policy for qscc's "GetBlockByTxID" function
232-
qscc/GetBlockByTxID: /Channel/Application/Readers
233-
234-
#---Configuration System Chaincode (cscc) function to policy mapping for access control---#
235-
236-
# ACL policy for cscc's "GetConfigBlock" function
237-
cscc/GetConfigBlock: /Channel/Application/Readers
238-
239-
# ACL policy for cscc's "GetChannelConfig" function
240-
cscc/GetChannelConfig: /Channel/Application/Readers
241-
242-
#---Miscellaneous peer function to policy mapping for access control---#
243-
244-
# ACL policy for invoking chaincodes on peer
245-
peer/Propose: /Channel/Application/Writers
246-
247-
# ACL policy for chaincode to chaincode invocation
248-
peer/ChaincodeToChaincode: /Channel/Application/Writers
249-
250-
#---Events resource to policy mapping for access control###---#
251-
252-
# ACL policy for sending block events
253-
event/Block: /Channel/Application/Readers
254-
255-
# ACL policy for sending filtered block events
256-
event/FilteredBlock: /Channel/Application/Readers
257-
258158
# Organizations lists the orgs participating on the application side of the
259159
# network.
260160
Organizations:

0 commit comments

Comments
 (0)