Skip to content

Commit

Permalink
[FAB-2723] (PA) Remove old ChainCreationPolicyName
Browse files Browse the repository at this point in the history
Before FAB-1302, channel creation was governed by a list of
ChainCreationPolicyNames.  This mechanism was replaced by the notion of
consortiums and a corresponding consortium channel creation policy.
This allows channel creation policies to be tied to the consortium,
rather than to an arbitrary list and is both simpler, and more
expressive.

Consequently, the old chain creaiton policy name, and chain creation
policy protos are no longer needed.  This CR removes them to erase any
confusion.  This is an ABI break, and will prevent channels created with
the older style config to fail to start.

Change-Id: I08f82d66a8bf48c2b3301ed8f1394d7e4edb53ad
Signed-off-by: Jason Yellick <jyellick@us.ibm.com>
Signed-off-by: Kostas Christidis <kostas@christidis.io>
  • Loading branch information
Jason Yellick authored and kchristidis committed Apr 26, 2017
1 parent 312628c commit 0fcb145
Show file tree
Hide file tree
Showing 9 changed files with 32 additions and 148 deletions.
4 changes: 0 additions & 4 deletions common/config/api.go
Expand Up @@ -86,10 +86,6 @@ type Orderer interface {
// BatchTimeout returns the amount of time to wait before creating a batch
BatchTimeout() time.Duration

// ChainCreationPolicyNames returns the policy names which are allowed for chain creation
// This field is only set for the system ordering chain
ChainCreationPolicyNames() []string

// MaxChannelsCount returns the maximum count of channels to allow for an ordering network
MaxChannelsCount() uint64

Expand Down
21 changes: 5 additions & 16 deletions common/config/orderer.go
Expand Up @@ -42,9 +42,6 @@ const (
// BatchTimeoutKey is the cb.ConfigItem type key name for the BatchTimeout message
BatchTimeoutKey = "BatchTimeout"

// ChainCreationPolicyNamesKey is the cb.ConfigItem type key name for the ChainCreationPolicyNames message
ChainCreationPolicyNamesKey = "ChainCreationPolicyNames"

// ChannelRestrictions is the key name for the ChannelRestrictions message
ChannelRestrictionsKey = "ChannelRestrictions"

Expand All @@ -54,13 +51,11 @@ const (

// OrdererProtos is used as the source of the OrdererConfig
type OrdererProtos struct {
ConsensusType *ab.ConsensusType
BatchSize *ab.BatchSize
BatchTimeout *ab.BatchTimeout
ChainCreationPolicyNames *ab.ChainCreationPolicyNames
KafkaBrokers *ab.KafkaBrokers
CreationPolicy *ab.CreationPolicy
ChannelRestrictions *ab.ChannelRestrictions
ConsensusType *ab.ConsensusType
BatchSize *ab.BatchSize
BatchTimeout *ab.BatchTimeout
KafkaBrokers *ab.KafkaBrokers
ChannelRestrictions *ab.ChannelRestrictions
}

// Config is stores the orderer component configuration
Expand Down Expand Up @@ -133,12 +128,6 @@ func (oc *OrdererConfig) BatchTimeout() time.Duration {
return oc.batchTimeout
}

// ChainCreationPolicyNames returns the policy names which are allowed for chain creation
// This field is only set for the system ordering chain
func (oc *OrdererConfig) ChainCreationPolicyNames() []string {
return oc.protos.ChainCreationPolicyNames.Names
}

// KafkaBrokers returns the addresses (IP:port notation) of a set of "bootstrap"
// Kafka brokers, i.e. this is not necessarily the entire set of Kafka brokers
// used for ordering
Expand Down
5 changes: 0 additions & 5 deletions common/config/orderer_util.go
Expand Up @@ -46,11 +46,6 @@ func TemplateBatchTimeout(batchTimeout string) *cb.ConfigGroup {
return ordererConfigGroup(BatchTimeoutKey, utils.MarshalOrPanic(&ab.BatchTimeout{Timeout: batchTimeout}))
}

// TemplateChainCreationPolicyNames creates a headerless configuraiton item representing the chain creation policy names
func TemplateChainCreationPolicyNames(names []string) *cb.ConfigGroup {
return ordererConfigGroup(ChainCreationPolicyNamesKey, utils.MarshalOrPanic(&ab.ChainCreationPolicyNames{Names: names}))
}

// TemplateChannelRestrictions creates a config group with ChannelRestrictions specified
func TemplateChannelRestrictions(maxChannels uint64) *cb.ConfigGroup {
return ordererConfigGroup(ChannelRestrictionsKey, utils.MarshalOrPanic(&ab.ChannelRestrictions{MaxCount: maxChannels}))
Expand Down
26 changes: 4 additions & 22 deletions common/configtx/tool/provisional/provisional.go
Expand Up @@ -19,7 +19,6 @@ package provisional
import (
"fmt"

"github.com/hyperledger/fabric/common/cauthdsl"
"github.com/hyperledger/fabric/common/config"
configvaluesmsp "github.com/hyperledger/fabric/common/config/msp"
"github.com/hyperledger/fabric/common/configtx"
Expand Down Expand Up @@ -73,22 +72,15 @@ const (
// does not exist.
TestChainID = "testchainid"

// AcceptAllPolicyKey is the key of the AcceptAllPolicy.
AcceptAllPolicyKey = "AcceptAllPolicy"

// BlockValidationPolicyKey TODO
BlockValidationPolicyKey = "BlockValidation"
)

// DefaultChainCreationPolicyNames is the default value of ChainCreatorsKey.
var DefaultChainCreationPolicyNames = []string{AcceptAllPolicyKey}

type bootstrapper struct {
channelGroups []*cb.ConfigGroup
ordererGroups []*cb.ConfigGroup
applicationGroups []*cb.ConfigGroup
ordererSystemChannelGroups []*cb.ConfigGroup
consortiumsGroups []*cb.ConfigGroup
channelGroups []*cb.ConfigGroup
ordererGroups []*cb.ConfigGroup
applicationGroups []*cb.ConfigGroup
consortiumsGroups []*cb.ConfigGroup
}

// New returns a new provisional bootstrap helper.
Expand All @@ -104,9 +96,6 @@ func New(conf *genesisconfig.Profile) Generator {
policies.TemplateImplicitMetaAnyPolicy([]string{}, configvaluesmsp.ReadersPolicyKey),
policies.TemplateImplicitMetaAnyPolicy([]string{}, configvaluesmsp.WritersPolicyKey),
policies.TemplateImplicitMetaMajorityPolicy([]string{}, configvaluesmsp.AdminsPolicyKey),

// Temporary AcceptAllPolicy XXX, remove
cauthdsl.TemplatePolicy(AcceptAllPolicyKey, cauthdsl.AcceptAllPolicy),
},
}

Expand Down Expand Up @@ -148,11 +137,6 @@ func New(conf *genesisconfig.Profile) Generator {
default:
panic(fmt.Errorf("Wrong consenter type value given: %s", conf.Orderer.OrdererType))
}

bs.ordererSystemChannelGroups = []*cb.ConfigGroup{
// Policies
config.TemplateChainCreationPolicyNames(DefaultChainCreationPolicyNames),
}
}

if conf.Application != nil {
Expand Down Expand Up @@ -234,7 +218,6 @@ func (bs *bootstrapper) GenesisBlock() *cb.Block {
configtx.NewModPolicySettingTemplate(
configvaluesmsp.AdminsPolicyKey,
configtx.NewCompositeTemplate(
configtx.NewSimpleTemplate(bs.ordererSystemChannelGroups...),
configtx.NewSimpleTemplate(bs.consortiumsGroups...),
bs.ChannelTemplate(),
),
Expand All @@ -253,7 +236,6 @@ func (bs *bootstrapper) GenesisBlockForChannel(channelID string) *cb.Block {
configtx.NewModPolicySettingTemplate(
configvaluesmsp.AdminsPolicyKey,
configtx.NewCompositeTemplate(
configtx.NewSimpleTemplate(bs.ordererSystemChannelGroups...),
configtx.NewSimpleTemplate(bs.consortiumsGroups...),
bs.ChannelTemplate(),
),
Expand Down
21 changes: 0 additions & 21 deletions common/mocks/configvalues/channel/orderer/sharedconfig.go
Expand Up @@ -27,14 +27,8 @@ type SharedConfig struct {
BatchSizeVal *ab.BatchSize
// BatchTimeoutVal is returned as the result of BatchTimeout()
BatchTimeoutVal time.Duration
// ChainCreationPolicyNamesVal is returned as the result of ChainCreationPolicyNames()
ChainCreationPolicyNamesVal []string
// KafkaBrokersVal is returned as the result of KafkaBrokers()
KafkaBrokersVal []string
// IngressPolicyNamesVal is returned as the result of IngressPolicyNames()
IngressPolicyNamesVal []string
// EgressPolicyNamesVal is returned as the result of EgressPolicyNames()
EgressPolicyNamesVal []string
// MaxChannelsCountVal is returns as the result of MaxChannelsCount()
MaxChannelsCountVal uint64
}
Expand All @@ -54,11 +48,6 @@ func (scm *SharedConfig) BatchTimeout() time.Duration {
return scm.BatchTimeoutVal
}

// ChainCreationPolicyNames returns the ChainCreationPolicyNamesVal
func (scm *SharedConfig) ChainCreationPolicyNames() []string {
return scm.ChainCreationPolicyNamesVal
}

// KafkaBrokers returns the KafkaBrokersVal
func (scm *SharedConfig) KafkaBrokers() []string {
return scm.KafkaBrokersVal
Expand All @@ -68,13 +57,3 @@ func (scm *SharedConfig) KafkaBrokers() []string {
func (scm *SharedConfig) MaxChannelsCount() uint64 {
return scm.MaxChannelsCountVal
}

// IngressPolicyNames returns the IngressPolicyNamesVal
func (scm *SharedConfig) IngressPolicyNames() []string {
return scm.IngressPolicyNamesVal
}

// EgressPolicyNames returns the EgressPolicyNamesVal
func (scm *SharedConfig) EgressPolicyNames() []string {
return scm.EgressPolicyNamesVal
}
2 changes: 1 addition & 1 deletion orderer/multichain/manager.go
Expand Up @@ -109,7 +109,7 @@ func NewManagerImpl(ledgerFactory ledger.Factory, consenters map[string]Consente
ledgerResources := ml.newLedgerResources(configTx)
chainID := ledgerResources.ChainID()

if ledgerResources.SharedConfig().ChainCreationPolicyNames() != nil {
if ledgerResources.ConsortiumsConfig() != nil {
if ml.systemChannelID != "" {
logger.Fatalf("There appear to be two system chains %s and %s", ml.systemChannelID, chainID)
}
Expand Down
2 changes: 0 additions & 2 deletions protos/orderer/ab.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

79 changes: 22 additions & 57 deletions protos/orderer/configuration.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 0 additions & 20 deletions protos/orderer/configuration.proto
Expand Up @@ -50,26 +50,6 @@ message BatchTimeout {
string timeout = 1;
}

// When submitting a new chain configuration transaction to create a new chain,
// the first configuration item must be of type Orderer with Key CreationPolicy
// and contents of a Marshaled CreationPolicy. The policy should be set to the
// policy which was supplied by the ordering service for the client's chain
// creation. The digest should be the hash of the concatenation of the remaining
// ConfigurationItem bytes. The signatures of the configuration item should
// satisfy the policy for chain creation.
message CreationPolicy {
// The name of the policy which should be used to validate the creation of
// this chain
string policy = 1;
}

// ChainCreationPolicyNames is the set of policies which may be invoked for chain creation
message ChainCreationPolicyNames {
// A list of policies, in evaluation these are 'or'-ed, note this is not a proper policy
// because implementing referential policies in a general way is difficult, and dangerous
repeated string names = 1;
}

// Carries a list of bootstrap brokers, i.e. this is not the exclusive set of
// brokers an ordering service
message KafkaBrokers {
Expand Down

0 comments on commit 0fcb145

Please sign in to comment.