diff --git a/go.mod b/go.mod index 221ddfc3f..2ac954a28 100644 --- a/go.mod +++ b/go.mod @@ -17,7 +17,6 @@ require ( github.com/gorilla/mux v1.8.0 github.com/grpc-ecosystem/go-grpc-middleware v1.3.0 github.com/hyperledger-labs/SmartBFT v0.0.0-20240916013553-852e5be5889b - github.com/hyperledger/fabric-config v0.3.0 github.com/hyperledger/fabric-lib-go v1.1.3-0.20240523144151-25edd1eaf5f5 github.com/hyperledger/fabric-protos-go-apiv2 v0.3.7 github.com/miekg/pkcs11 v1.1.1 // indirect diff --git a/tools/cryptogen/config_block.go b/tools/cryptogen/config_block.go index 0d97ad8f6..6a9313fc3 100644 --- a/tools/cryptogen/config_block.go +++ b/tools/cryptogen/config_block.go @@ -28,6 +28,7 @@ type ConfigBlockParameters struct { ChannelID string ArmaPath string Organizations []OrganizationParameters + Namespaces []string } // OrganizationParameters represents the properties of an organization. @@ -132,7 +133,21 @@ func CreateDefaultConfigBlockWithCrypto(conf ConfigBlockParameters) (*common.Blo } // We generate a fake organization for the meta namespace. - metaSpec := OrgSpec{Name: metaNamespaceOrg, Domain: metaNamespaceOrg} + // The admin user will be used as the meta-namespace key. + // We create a user for each namespace to be used as its key. + metaSpec := OrgSpec{ + Name: metaNamespaceOrg, + Domain: metaNamespaceOrg, + Users: UsersSpec{ + Specs: make([]UserSpec, len(conf.Namespaces)), + }, + } + for i, ns := range conf.Namespaces { + metaSpec.Users.Specs[i] = UserSpec{ + Name: ns, + } + } + cryptoConf.GenericOrgs = append(cryptoConf.GenericOrgs, metaSpec) profile.Application.MetaNamespaceVerificationKeyPath = path.Join( GenericOrganizationsDir, metaNamespaceOrg, MSPDir, AdminCertsDir, diff --git a/tools/cryptogen/config_block_test.go b/tools/cryptogen/config_block_test.go index 108d251ce..8cf5748ea 100644 --- a/tools/cryptogen/config_block_test.go +++ b/tools/cryptogen/config_block_test.go @@ -35,6 +35,7 @@ func TestMakeConfig(t *testing.T) { block, err := CreateDefaultConfigBlockWithCrypto(ConfigBlockParameters{ TargetPath: target, ChannelID: chanName, + Namespaces: []string{"ns-1", "ns-2"}, Organizations: []OrganizationParameters{ { // Joint org with two ordering parties. Name: "org-1", @@ -99,7 +100,12 @@ func TestMakeConfig(t *testing.T) { t.Log(test.GetTree(t, target)) - var expectedDirs []string //nolint:prealloc // Hard to estimate size. + expectedDirs := []string{ + filepath.Join(GenericOrganizationsDir, "meta-namespace", "msp"), + filepath.Join(GenericOrganizationsDir, "meta-namespace", "users", "Admin@meta-namespace"), + filepath.Join(GenericOrganizationsDir, "meta-namespace", "users", "ns-1@meta-namespace"), + filepath.Join(GenericOrganizationsDir, "meta-namespace", "users", "ns-2@meta-namespace"), + } org1Dir := filepath.Join(GenericOrganizationsDir, "org-1") org2Dir := filepath.Join(OrdererOrganizationsDir, "org-2")