Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 0 additions & 7 deletions common/channelconfig/channel.go
Original file line number Diff line number Diff line change
Expand Up @@ -182,13 +182,6 @@ func (cc *ChannelConfig) Validate(channelCapabilities ChannelCapabilities) error
}
}

// We check global orderer addresses only if we are below ChannelV1_4_2
if !channelCapabilities.OrgSpecificOrdererEndpoints() {
if err := cc.validateOrdererAddresses(); err != nil {
return err
}
}

// We validate no global endpoints at V3_0 or above
if channelCapabilities.ConsensusTypeBFT() {
return cc.validateNoOrdererAddresses()
Expand Down
8 changes: 1 addition & 7 deletions common/channelconfig/orderer.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,12 +90,6 @@ func NewOrdererOrgConfig(orgName string, orgGroup *cb.ConfigGroup, mspConfigHand
return nil, fmt.Errorf("OrdererOrg config does not allow sub-groups")
}

if !channelCapabilities.OrgSpecificOrdererEndpoints() {
if _, ok := orgGroup.Values[EndpointsKey]; ok {
return nil, errors.Errorf("Orderer Org %s cannot contain endpoints value until V1_4_2+ capabilities have been enabled", orgName)
}
}

protos := &OrdererOrgProtos{}
orgProtos := &OrganizationProtos{}

Expand Down Expand Up @@ -146,7 +140,7 @@ func NewOrdererConfig(ordererGroup *cb.ConfigGroup, mspConfig *MSPConfigHandler,
}
}

if channelCapabilities.ConsensusTypeBFT() {
if oc.ConsensusType() == "arma" || oc.ConsensusType() == "BFT" {
if err := oc.validateAllOrgsHaveEndpoints(); err != nil {
return nil, err
}
Expand Down
18 changes: 14 additions & 4 deletions common/channelconfig/realconfig_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ SPDX-License-Identifier: Apache-2.0
package channelconfig_test

import (
"path/filepath"
"testing"

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

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

cg, err := configtxgen.NewChannelGroup(conf)
require.NoError(t, err)
Expand All @@ -49,14 +53,17 @@ func TestOrgSpecificOrdererEndpoints(t *testing.T) {
})

t.Run("could not create channelgroup with empty organization endpoints", func(t *testing.T) {
t.Parallel()
conf := configtxgen.Load(configtxgen.SampleDevModeSoloProfile, configtest.GetDevConfigDir())
conf.Capabilities = map[string]bool{"V3_0": true}
conf.Orderer.Organizations[0].OrdererEndpoints = nil
conf.Orderer.Addresses = []string{}

cg, err := configtxgen.NewChannelGroup(conf)
require.Nil(t, cg)
require.EqualError(t, err, "could not create orderer group: failed to create orderer org: orderer endpoints for organization SampleOrg are missing and must be configured when capability V3_0 is enabled")
require.EqualError(t, err, "could not create orderer group: "+
"failed to create orderer org: "+
"orderer endpoints for organization SampleOrg are missing and must be configured")

conf.Orderer.Organizations[0].OrdererEndpoints = []*types.OrdererEndpoint{{Host: "127.0.0.1", Port: 7050}}
cg, err = configtxgen.NewChannelGroup(conf)
Expand All @@ -69,6 +76,7 @@ func TestOrgSpecificOrdererEndpoints(t *testing.T) {
})

t.Run("With V2_0 Capability", func(t *testing.T) {
t.Parallel()
conf := configtxgen.Load(configtxgen.SampleDevModeSoloProfile, configtest.GetDevConfigDir())
conf.Capabilities = map[string]bool{"V2_0": true}
require.NotEmpty(t, conf.Orderer.Organizations[0].OrdererEndpoints)
Expand All @@ -88,13 +96,15 @@ func TestOrgSpecificOrdererEndpoints(t *testing.T) {
})

t.Run("no global address With V3_0 Capability", func(t *testing.T) {
t.Parallel()
conf := configtxgen.Load(configtxgen.SampleDevModeSoloProfile, configtest.GetDevConfigDir())
conf.Orderer.Addresses = []string{"globalAddress"}
conf.Capabilities = map[string]bool{"V3_0": true}
require.NotEmpty(t, conf.Orderer.Organizations[0].OrdererEndpoints)
require.NotEmpty(t, conf.Orderer.Addresses)

_, err := configtxgen.NewChannelGroup(conf)
require.EqualError(t, err, "could not create orderer group: global orderer endpoints exist, but can not be used with V3_0 capability: [globalAddress]")
require.EqualError(t, err, "could not create orderer group: "+
"global orderer endpoints exist, but are not supported: [globalAddress]")
})
}
13 changes: 7 additions & 6 deletions common/deliverclient/verifier_assembler.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,16 @@ func (bva *BlockVerifierAssembler) VerifierFromConfig(configuration *common.Conf
return createErrorFunc(err), err
}

bftEnabled := bundle.ChannelConfig().Capabilities().ConsensusTypeBFT()
cfg, ok := bundle.OrdererConfig()

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

check the ok and if it is false emit an error like in the original code err := errors.New("no orderer section in config block")

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed. Added ok check — returns error "no orderer section in config block" when OrdererConfig() returns false. See e4a448f.

if !ok {
err := errors.New("no orderer section in config block")
return createErrorFunc(err), err
}

bftEnabled := cfg.ConsensusType() == "BFT" || cfg.ConsensusType() == "arma"

var consenters []*common.Consenter
if bftEnabled {
cfg, ok := bundle.OrdererConfig()
if !ok {
err := errors.New("no orderer section in config block")
return createErrorFunc(err), err
}
consenters = cfg.Consenters()
}

Expand Down
68 changes: 0 additions & 68 deletions core/aclmgmt/defaultaclprovider.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import (
pb "github.com/hyperledger/fabric-protos-go-apiv2/peer"

"github.com/hyperledger/fabric-x-common/common/policies"
"github.com/hyperledger/fabric-x-common/core/aclmgmt/resources"
"github.com/hyperledger/fabric-x-common/core/policy"
"github.com/hyperledger/fabric-x-common/protoutil"
)
Expand Down Expand Up @@ -47,73 +46,6 @@ func newDefaultACLProvider(policyChecker policy.PolicyChecker) defaultACLProvide
cResourcePolicyMap: map[string]string{},
}

// -------------- _lifecycle --------------
d.pResourcePolicyMap[resources.Lifecycle_InstallChaincode] = policy.Admins
d.pResourcePolicyMap[resources.Lifecycle_QueryInstalledChaincode] = policy.Admins
d.pResourcePolicyMap[resources.Lifecycle_GetInstalledChaincodePackage] = policy.Admins
d.pResourcePolicyMap[resources.Lifecycle_QueryInstalledChaincodes] = policy.Admins
d.pResourcePolicyMap[resources.Lifecycle_ApproveChaincodeDefinitionForMyOrg] = policy.Admins
d.pResourcePolicyMap[resources.Lifecycle_QueryApprovedChaincodeDefinition] = policy.Admins
d.pResourcePolicyMap[resources.Lifecycle_QueryApprovedChaincodeDefinitions] = policy.Admins

d.cResourcePolicyMap[resources.Lifecycle_CommitChaincodeDefinition] = CHANNELWRITERS
d.cResourcePolicyMap[resources.Lifecycle_QueryChaincodeDefinition] = CHANNELWRITERS
d.cResourcePolicyMap[resources.Lifecycle_QueryChaincodeDefinitions] = CHANNELWRITERS
d.cResourcePolicyMap[resources.Lifecycle_CheckCommitReadiness] = CHANNELWRITERS

// -------------- snapshot ---------------
d.pResourcePolicyMap[resources.Snapshot_submitrequest] = policy.Admins
d.pResourcePolicyMap[resources.Snapshot_cancelrequest] = policy.Admins
d.pResourcePolicyMap[resources.Snapshot_listpending] = policy.Admins

// -------------- LSCC --------------
// p resources (implemented by the chaincode currently)
d.pResourcePolicyMap[resources.Lscc_Install] = policy.Admins
d.pResourcePolicyMap[resources.Lscc_GetInstalledChaincodes] = policy.Admins

// c resources
d.cResourcePolicyMap[resources.Lscc_Deploy] = "" // ACL check covered by PROPOSAL
d.cResourcePolicyMap[resources.Lscc_Upgrade] = "" // ACL check covered by PROPOSAL
d.cResourcePolicyMap[resources.Lscc_ChaincodeExists] = CHANNELREADERS
d.cResourcePolicyMap[resources.Lscc_GetDeploymentSpec] = CHANNELREADERS
d.cResourcePolicyMap[resources.Lscc_GetChaincodeData] = CHANNELREADERS
d.cResourcePolicyMap[resources.Lscc_GetInstantiatedChaincodes] = CHANNELREADERS
d.cResourcePolicyMap[resources.Lscc_GetCollectionsConfig] = CHANNELREADERS

// -------------- QSCC --------------
// p resources (none)

// c resources
d.cResourcePolicyMap[resources.Qscc_GetChainInfo] = CHANNELREADERS
d.cResourcePolicyMap[resources.Qscc_GetBlockByNumber] = CHANNELREADERS
d.cResourcePolicyMap[resources.Qscc_GetBlockByHash] = CHANNELREADERS
d.cResourcePolicyMap[resources.Qscc_GetTransactionByID] = CHANNELREADERS
d.cResourcePolicyMap[resources.Qscc_GetBlockByTxID] = CHANNELREADERS

// --------------- CSCC resources -----------
// p resources (implemented by the chaincode currently)
d.pResourcePolicyMap[resources.Cscc_JoinChain] = policy.Admins
d.pResourcePolicyMap[resources.Cscc_JoinChainBySnapshot] = policy.Admins
d.pResourcePolicyMap[resources.Cscc_JoinBySnapshotStatus] = policy.Admins
d.pResourcePolicyMap[resources.Cscc_GetChannels] = policy.Members

// c resources
d.cResourcePolicyMap[resources.Cscc_GetConfigBlock] = CHANNELREADERS
d.cResourcePolicyMap[resources.Cscc_GetChannelConfig] = CHANNELREADERS

// ---------------- non-scc resources ------------
// Peer resources
d.cResourcePolicyMap[resources.Peer_Propose] = CHANNELWRITERS
d.cResourcePolicyMap[resources.Peer_ChaincodeToChaincode] = CHANNELWRITERS

// Event resources
d.cResourcePolicyMap[resources.Event_Block] = CHANNELREADERS
d.cResourcePolicyMap[resources.Event_FilteredBlock] = CHANNELREADERS

// Gateway resources
d.cResourcePolicyMap[resources.Gateway_CommitStatus] = CHANNELREADERS
d.cResourcePolicyMap[resources.Gateway_ChaincodeEvents] = CHANNELREADERS

return d
}

Expand Down
61 changes: 0 additions & 61 deletions core/aclmgmt/resources/resources.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,65 +5,4 @@ SPDX-License-Identifier: Apache-2.0
*/

// Package resources contains resource names used in fabric for ACL checks.
// Note that some of the checks such as Lscc_INSTALL are "peer wide" (current
// access checks in peer are based on local MSP). These are not currently
// covered by resource or default ACLProviders
package resources

const (
// _lifecycle resources
Lifecycle_InstallChaincode = "_lifecycle/InstallChaincode"
Lifecycle_QueryInstalledChaincode = "_lifecycle/QueryInstalledChaincode"
Lifecycle_GetInstalledChaincodePackage = "_lifecycle/GetInstalledChaincodePackage"
Lifecycle_QueryInstalledChaincodes = "_lifecycle/QueryInstalledChaincodes"
Lifecycle_ApproveChaincodeDefinitionForMyOrg = "_lifecycle/ApproveChaincodeDefinitionForMyOrg"
Lifecycle_QueryApprovedChaincodeDefinition = "_lifecycle/QueryApprovedChaincodeDefinition"
Lifecycle_QueryApprovedChaincodeDefinitions = "_lifecycle/QueryApprovedChaincodeDefinitions"
Lifecycle_CommitChaincodeDefinition = "_lifecycle/CommitChaincodeDefinition"
Lifecycle_QueryChaincodeDefinition = "_lifecycle/QueryChaincodeDefinition"
Lifecycle_QueryChaincodeDefinitions = "_lifecycle/QueryChaincodeDefinitions"
Lifecycle_CheckCommitReadiness = "_lifecycle/CheckCommitReadiness"

// snapshot resources
Snapshot_submitrequest = "snapshot/submitrequest"
Snapshot_cancelrequest = "snapshot/cancelrequest"
Snapshot_listpending = "snapshot/listpending"

// Lscc resources
Lscc_Install = "lscc/Install"
Lscc_Deploy = "lscc/Deploy"
Lscc_Upgrade = "lscc/Upgrade"
Lscc_ChaincodeExists = "lscc/ChaincodeExists"
Lscc_GetDeploymentSpec = "lscc/GetDeploymentSpec"
Lscc_GetChaincodeData = "lscc/GetChaincodeData"
Lscc_GetInstantiatedChaincodes = "lscc/GetInstantiatedChaincodes"
Lscc_GetInstalledChaincodes = "lscc/GetInstalledChaincodes"
Lscc_GetCollectionsConfig = "lscc/GetCollectionsConfig"

// Qscc resources
Qscc_GetChainInfo = "qscc/GetChainInfo"
Qscc_GetBlockByNumber = "qscc/GetBlockByNumber"
Qscc_GetBlockByHash = "qscc/GetBlockByHash"
Qscc_GetTransactionByID = "qscc/GetTransactionByID"
Qscc_GetBlockByTxID = "qscc/GetBlockByTxID"

// Cscc resources
Cscc_JoinChain = "cscc/JoinChain"
Cscc_JoinChainBySnapshot = "cscc/JoinChainBySnapshot"
Cscc_JoinBySnapshotStatus = "cscc/JoinBySnapshotStatus"
Cscc_GetConfigBlock = "cscc/GetConfigBlock"
Cscc_GetChannelConfig = "cscc/GetChannelConfig"
Cscc_GetChannels = "cscc/GetChannels"

// Peer resources
Peer_Propose = "peer/Propose"
Peer_ChaincodeToChaincode = "peer/ChaincodeToChaincode"

// Events
Event_Block = "event/Block"
Event_FilteredBlock = "event/FilteredBlock"

// Gateway resources
Gateway_CommitStatus = "gateway/CommitStatus"
Gateway_ChaincodeEvents = "gateway/ChaincodeEvents"
)
5 changes: 2 additions & 3 deletions protoutil/blockutils_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -586,7 +586,7 @@ func TestBlockSignatureVerifierWithRealPolicy(t *testing.T) {
}
}

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

bftEnabled := configMaterial.Bundle.ChannelConfig().Capabilities().ConsensusTypeBFT()
require.True(t, bftEnabled)
require.Equal(t, "arma", oc.ConsensusType())
consenters := oc.Consenters()
require.Len(t, consenters, size)

Expand Down
Loading
Loading