Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added support for mod policies #45

Merged
merged 1 commit into from
Feb 23, 2021
Merged

Conversation

richardfelkl
Copy link
Contributor

Type of change

  • New feature

Description

Added support for mod policies in config groups: Application, ApplicationOrg, Channel, ConsortiumOrg, Orderer, OrdererOrg. Previous implementation wasn't able to set mod policies which is beneficial when creating production grade custom channel configurations.

Additional details

The previous code was setting mod policies to AdminModPolicyKey by default. This behavior was retained so when the mod policy is not set manually it is automatically set to AdminModPolicyKey.

There are two incompatible changes in methods SetPolicy and SetPolicies which omit first parameter called modPolicy because it's not needed anymore. There is a new field ModPolicy in Policy struct instead of it.

Those changes were tested in a production grade Fabric environment.

@richardfelkl richardfelkl requested a review from a team as a code owner February 18, 2021 09:51
@sykesm
Copy link
Contributor

sykesm commented Feb 18, 2021

I have not looked through the code yet but quickly ran gorelease against the changes. Each of the incompatible changes likely warrants a discussion.

➜  fabric-config git:(pr/45) gorelease
github.com/hyperledger/fabric-config/configtx
---------------------------------------------
Incompatible changes:
- (*ApplicationGroup).SetPolicies: changed from func(string, map[string]Policy) error to func(map[string]Policy) error
- (*ApplicationGroup).SetPolicy: changed from func(string, string, Policy) error to func(string, Policy) error
- (*ApplicationOrg).SetPolicies: changed from func(string, map[string]Policy) error to func(map[string]Policy) error
- (*ApplicationOrg).SetPolicy: changed from func(string, string, Policy) error to func(string, Policy) error
- (*ChannelGroup).SetPolicies: changed from func(string, map[string]Policy) error to func(map[string]Policy) error
- (*ChannelGroup).SetPolicy: changed from func(string, string, Policy) error to func(string, Policy) error
- (*OrdererGroup).SetPolicies: changed from func(string, map[string]Policy) error to func(map[string]Policy) error
- (*OrdererGroup).SetPolicy: changed from func(string, string, Policy) error to func(string, Policy) error
- (*OrdererOrg).SetPolicies: changed from func(string, map[string]Policy) error to func(map[string]Policy) error
- (*OrdererOrg).SetPolicy: changed from func(string, string, Policy) error to func(string, Policy) error
Compatible changes:
- (*ApplicationGroup).SetModPolicy: added
- (*ApplicationOrg).SetModPolicy: added
- (*ChannelGroup).SetModPolicy: added
- (*ConsortiumOrg).SetModPolicy: added
- (*OrdererGroup).SetModPolicy: added
- (*OrdererOrg).SetModPolicy: added
- Application.ModPolicy: added
- Channel.ModPolicy: added
- Orderer.ModPolicy: added
- Organization.ModPolicy: added
- Policy.ModPolicy: added

@richardfelkl
Copy link
Contributor Author

@sykesm I can make those SetPolicy and SetPolicies incompatible methods revert back but the modPolicy parameter will be duplicate. And we need to set preference of those. That's why I removed it. Refactoring to this change will be fairly easy.

@sykesm
Copy link
Contributor

sykesm commented Feb 18, 2021

@sykesm I can make those SetPolicy and SetPolicies incompatible methods revert back but the modPolicy parameter will be duplicate. And we need to set preference of those. That's why I removed it. Refactoring to this change will be fairly easy.

Okay, thanks. Give me a chance to review what's here before you make any changes.

@richardfelkl
Copy link
Contributor Author

@sykesm Hello, did you have time to take a look on the code?

@sykesm
Copy link
Contributor

sykesm commented Feb 22, 2021

@sykesm Hello, did you have time to take a look on the code?

I have not. It's been several months since I spent any time in this library so I'll need to become reacquainted with it before I can make any meaningful comments.

I hope to get through it before the end of the week.

Copy link
Contributor

@sykesm sykesm left a comment

Choose a reason for hiding this comment

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

Overall, looks good. Style items that I've referenced as "nits" wouldn't hold up a merge by themselves but it would be good to take care of those while addressing the other comments.

The missing tests and the error contents are the larger items that need to be resolved.

After looking through this, I agree with the changes to remove the modification policy arguments from the methods. This is something I'll need to highlight in the release notes when we tag it.

configtx/application.go Outdated Show resolved Hide resolved
configtx/application.go Outdated Show resolved Hide resolved
configtx/application.go Outdated Show resolved Hide resolved
configtx/application.go Show resolved Hide resolved
configtx/application_test.go Outdated Show resolved Hide resolved
configtx/consortiums_test.go Outdated Show resolved Hide resolved
configtx/orderer.go Show resolved Hide resolved
configtx/organization.go Show resolved Hide resolved
configtx/policies.go Outdated Show resolved Hide resolved
configtx/policies.go Show resolved Hide resolved
Signed-off-by: Richard Felkl <richard.felkl@gmail.com>
@richardfelkl
Copy link
Contributor Author

@sykesm I've updated the PR and addressed all of the issues you mentioned.

@@ -1268,6 +1268,7 @@ func TestOrdererConfigurationNoOrdererEndpoints(t *testing.T) {
c := New(config)

ordererConf, err := c.Orderer().Configuration()
// ordererConf.ModPolicy = AdminsPolicyKey
Copy link
Contributor

Choose a reason for hiding this comment

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

woops

Copy link
Contributor

@sykesm sykesm left a comment

Choose a reason for hiding this comment

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

LGTM. Thanks for addressing the comments.

@sykesm sykesm merged commit 71abb8e into hyperledger:master Feb 23, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants