fabric: github.com/hyperledger/fabric/orderer/common/msgprocessor Index | Files

package msgprocessor

import "github.com/hyperledger/fabric/orderer/common/msgprocessor"

Package msgprocessor provides the implementations for processing of the assorted message types which may arrive in the system through Broadcast.

Index

Package Files

expiration.go filter.go maintenancefilter.go msgprocessor.go sigfilter.go sizefilter.go standardchannel.go systemchannel.go systemchannelfilter.go

Variables

var AcceptRule = Rule(acceptRule{})

AcceptRule always returns Accept as a result for Apply

var EmptyRejectRule = Rule(emptyRejectRule{})

EmptyRejectRule rejects empty messages

var ErrChannelDoesNotExist = errors.New("channel does not exist")

ErrChannelDoesNotExist is returned by the system channel for transactions which are not for the system channel ID and are not attempting to create a new channel

var ErrEmptyMessage = errors.New("Message was empty")

ErrEmptyMessage is returned by the empty message filter on rejection.

var ErrMaintenanceMode = errors.New("maintenance mode")

ErrMaintenanceMode is returned when transactions are rejected because the orderer is in "maintenance mode", as defined by ConsensusType.State != NORMAL. This typically happens during consensus-type migration.

var ErrPermissionDenied = errors.New("permission denied")

ErrPermissionDenied is returned by errors which are caused by transactions which are not permitted due to an authorization failure.

type ChainCreator Uses

type ChainCreator interface {
    // NewChannelConfig returns a template config for a new channel.
    NewChannelConfig(envConfigUpdate *cb.Envelope) (channelconfig.Resources, error)

    // CreateBundle parses the config into resources
    CreateBundle(channelID string, config *cb.Config) (channelconfig.Resources, error)

    // ChannelsCount returns the count of channels which currently exist.
    ChannelsCount() int
}

ChainCreator defines the methods necessary to simulate channel creation.

type ChannelConfigTemplator Uses

type ChannelConfigTemplator interface {
    // NewChannelConfig creates a new template configuration manager.
    NewChannelConfig(env *cb.Envelope) (channelconfig.Resources, error)
}

ChannelConfigTemplator can be used to generate config templates.

type Classification Uses

type Classification int

Classification represents the possible message types for the system.

const (
    // NormalMsg is the class of standard (endorser or otherwise non-config) messages.
    // Messages of this type should be processed by ProcessNormalMsg.
    NormalMsg Classification = iota

    // ConfigUpdateMsg indicates messages of type CONFIG_UPDATE.
    // Messages of this type should be processed by ProcessConfigUpdateMsg.
    ConfigUpdateMsg

    // ConfigMsg indicates message of type ORDERER_TRANSACTION or CONFIG.
    // Messages of this type should be processed by ProcessConfigMsg
    ConfigMsg
)

type DefaultTemplator Uses

type DefaultTemplator struct {
    // contains filtered or unexported fields
}

DefaultTemplator implements the ChannelConfigTemplator interface and is the one used in production deployments.

func NewDefaultTemplator Uses

func NewDefaultTemplator(support DefaultTemplatorSupport) *DefaultTemplator

NewDefaultTemplator returns an instance of the DefaultTemplator.

func (*DefaultTemplator) NewChannelConfig Uses

func (dt *DefaultTemplator) NewChannelConfig(envConfigUpdate *cb.Envelope) (channelconfig.Resources, error)

NewChannelConfig creates a new template channel configuration based on the current config in the ordering system channel.

type DefaultTemplatorSupport Uses

type DefaultTemplatorSupport interface {
    // ConsortiumsConfig returns the ordering system channel's Consortiums config.
    ConsortiumsConfig() (channelconfig.Consortiums, bool)

    // OrdererConfig returns the ordering configuration and whether the configuration exists
    OrdererConfig() (channelconfig.Orderer, bool)

    // ConfigtxValidator returns the configtx manager corresponding to the system channel's current config.
    ConfigtxValidator() configtx.Validator

    // Signer returns the local signer suitable for signing forwarded messages.
    Signer() crypto.LocalSigner
}

DefaultTemplatorSupport is the subset of the channel config required by the DefaultTemplator.

type LimitedSupport Uses

type LimitedSupport interface {
    OrdererConfig() (channelconfig.Orderer, bool)
}

LimitedSupport defines the subset of the channel resources required by the systemchannel filter.

type MaintenanceFilter Uses

type MaintenanceFilter struct {
    // contains filtered or unexported fields
}

MaintenanceFilter checks whether the orderer config ConsensusType is in maintenance mode, and if it is, validates that the transaction is signed by the orderer org admin.

func NewMaintenanceFilter Uses

func NewMaintenanceFilter(support MaintenanceFilterSupport) *MaintenanceFilter

NewMaintenanceFilter creates a new maintenance filter, at every evaluation, the policy manager and orderer config are called to retrieve the latest version of the policy and config.

func (*MaintenanceFilter) Apply Uses

func (mf *MaintenanceFilter) Apply(message *cb.Envelope) error

Apply applies the maintenance filter on a CONFIG tx.

type MaintenanceFilterSupport Uses

type MaintenanceFilterSupport interface {
    // OrdererConfig returns the config.Orderer for the channel and whether the Orderer config exists
    OrdererConfig() (channelconfig.Orderer, bool)

    ChainID() string
}

MaintenanceFilterSupport provides the resources required for the maintenance filter.

type MaxBytesRule Uses

type MaxBytesRule struct {
    // contains filtered or unexported fields
}

MaxBytesRule implements the Rule interface.

func NewSizeFilter Uses

func NewSizeFilter(resources SizeFilterResources) *MaxBytesRule

NewSizeFilter creates a size filter which rejects messages larger than maxBytes

func (*MaxBytesRule) Apply Uses

func (r *MaxBytesRule) Apply(message *common.Envelope) error

Apply returns an error if the message exceeds the configured absolute max batch size.

type Processor Uses

type Processor interface {
    // ClassifyMsg inspects the message header to determine which type of processing is necessary
    ClassifyMsg(chdr *cb.ChannelHeader) Classification

    // ProcessNormalMsg will check the validity of a message based on the current configuration.  It returns the current
    // configuration sequence number and nil on success, or an error if the message is not valid
    ProcessNormalMsg(env *cb.Envelope) (configSeq uint64, err error)

    // ProcessConfigUpdateMsg will attempt to apply the config update to the current configuration, and if successful
    // return the resulting config message and the configSeq the config was computed from.  If the config update message
    // is invalid, an error is returned.
    ProcessConfigUpdateMsg(env *cb.Envelope) (config *cb.Envelope, configSeq uint64, err error)

    // ProcessConfigMsg takes message of type `ORDERER_TX` or `CONFIG`, unpack the ConfigUpdate envelope embedded
    // in it, and call `ProcessConfigUpdateMsg` to produce new Config message of the same type as original message.
    // This method is used to re-validate and reproduce config message, if it's deemed not to be valid anymore.
    ProcessConfigMsg(env *cb.Envelope) (*cb.Envelope, uint64, error)
}

Processor provides the methods necessary to classify and process any message which arrives through the Broadcast interface.

type Rule Uses

type Rule interface {
    // Apply applies the rule to the given Envelope, either successfully or returns error
    Apply(message *ab.Envelope) error
}

Rule defines a filter function which accepts, rejects, or forwards (to the next rule) an Envelope

func NewExpirationRejectRule Uses

func NewExpirationRejectRule(filterSupport resources) Rule

NewExpirationRejectRule returns a rule that rejects messages signed by identities who's identities have expired, given the capability is active

type RuleSet Uses

type RuleSet struct {
    // contains filtered or unexported fields
}

RuleSet is used to apply a collection of rules

func CreateStandardChannelFilters Uses

func CreateStandardChannelFilters(filterSupport channelconfig.Resources, config localconfig.TopLevel) *RuleSet

CreateStandardChannelFilters creates the set of filters for a normal (non-system) chain.

In maintenance mode, require the signature of /Channel/Orderer/Writer. This will filter out configuration changes that are not related to consensus-type migration (e.g on /Channel/Application).

func CreateSystemChannelFilters Uses

func CreateSystemChannelFilters(chainCreator ChainCreator, ledgerResources channelconfig.Resources, config localconfig.TopLevel) *RuleSet

CreateSystemChannelFilters creates the set of filters for the ordering system chain.

In maintenance mode, require the signature of /Channel/Orderer/Writers. This will filter out configuration changes that are not related to consensus-type migration (e.g on /Channel/Application).

func NewRuleSet Uses

func NewRuleSet(rules []Rule) *RuleSet

NewRuleSet creates a new RuleSet with the given ordered list of Rules

func (*RuleSet) Apply Uses

func (rs *RuleSet) Apply(message *ab.Envelope) error

Apply applies the rules given for this set in order, returning nil on valid or err on invalid

type SigFilter Uses

type SigFilter struct {
    // contains filtered or unexported fields
}

SigFilter stores the name of the policy to apply to deliver requests to determine whether a client is authorized

func NewSigFilter Uses

func NewSigFilter(normalPolicyName, maintenancePolicyName string, support SigFilterSupport) *SigFilter

NewSigFilter creates a new signature filter, at every evaluation, the policy manager is called to retrieve the latest version of the policy.

normalPolicyName is applied when Orderer/ConsensusType.State = NORMAL maintenancePolicyName is applied when Orderer/ConsensusType.State = MAINTENANCE

func (*SigFilter) Apply Uses

func (sf *SigFilter) Apply(message *cb.Envelope) error

Apply applies the policy given, resulting in Reject or Forward, never Accept

type SigFilterSupport Uses

type SigFilterSupport interface {
    // PolicyManager returns a reference to the current policy manager
    PolicyManager() policies.Manager
    // OrdererConfig returns the config.Orderer for the channel and whether the Orderer config exists
    OrdererConfig() (channelconfig.Orderer, bool)
}

SigFilterSupport provides the resources required for the signature filter

type SizeFilterResources Uses

type SizeFilterResources interface {
    // OrdererConfig returns the config.Orderer for the channel and whether the Orderer config exists
    OrdererConfig() (channelconfig.Orderer, bool)
}

SizeFilterResources defines the subset of the channel resources required to create this filter

type StandardChannel Uses

type StandardChannel struct {
    // contains filtered or unexported fields
}

StandardChannel implements the Processor interface for standard extant channels

func NewStandardChannel Uses

func NewStandardChannel(support StandardChannelSupport, filters *RuleSet) *StandardChannel

NewStandardChannel creates a new standard message processor

func (*StandardChannel) ClassifyMsg Uses

func (s *StandardChannel) ClassifyMsg(chdr *cb.ChannelHeader) Classification

ClassifyMsg inspects the message to determine which type of processing is necessary

func (*StandardChannel) ProcessConfigMsg Uses

func (s *StandardChannel) ProcessConfigMsg(env *cb.Envelope) (config *cb.Envelope, configSeq uint64, err error)

ProcessConfigMsg takes an envelope of type `HeaderType_CONFIG`, unpacks the `ConfigEnvelope` from it extracts the `ConfigUpdate` from `LastUpdate` field, and calls `ProcessConfigUpdateMsg` on it.

func (*StandardChannel) ProcessConfigUpdateMsg Uses

func (s *StandardChannel) ProcessConfigUpdateMsg(env *cb.Envelope) (config *cb.Envelope, configSeq uint64, err error)

ProcessConfigUpdateMsg will attempt to apply the config impetus msg to the current configuration, and if successful return the resulting config message and the configSeq the config was computed from. If the config impetus message is invalid, an error is returned.

func (*StandardChannel) ProcessNormalMsg Uses

func (s *StandardChannel) ProcessNormalMsg(env *cb.Envelope) (configSeq uint64, err error)

ProcessNormalMsg will check the validity of a message based on the current configuration. It returns the current configuration sequence number and nil on success, or an error if the message is not valid

type StandardChannelSupport Uses

type StandardChannelSupport interface {
    // Sequence should return the current configSeq
    Sequence() uint64

    // ChainID returns the ChannelID
    ChainID() string

    // Signer returns the signer for this orderer
    Signer() crypto.LocalSigner

    // ProposeConfigUpdate takes in an Envelope of type CONFIG_UPDATE and produces a
    // ConfigEnvelope to be used as the Envelope Payload Data of a CONFIG message
    ProposeConfigUpdate(configtx *cb.Envelope) (*cb.ConfigEnvelope, error)

    OrdererConfig() (channelconfig.Orderer, bool)
}

StandardChannelSupport includes the resources needed for the StandardChannel processor.

type SystemChainFilter Uses

type SystemChainFilter struct {
    // contains filtered or unexported fields
}

SystemChainFilter implements the filter.Rule interface.

func NewSystemChannelFilter Uses

func NewSystemChannelFilter(ls LimitedSupport, cc ChainCreator) *SystemChainFilter

NewSystemChannelFilter returns a new instance of a *SystemChainFilter.

func (*SystemChainFilter) Apply Uses

func (scf *SystemChainFilter) Apply(env *cb.Envelope) error

Apply rejects bad messages with an error.

type SystemChannel Uses

type SystemChannel struct {
    *StandardChannel
    // contains filtered or unexported fields
}

SystemChannel implements the Processor interface for the system channel.

func NewSystemChannel Uses

func NewSystemChannel(support StandardChannelSupport, templator ChannelConfigTemplator, filters *RuleSet) *SystemChannel

NewSystemChannel creates a new system channel message processor.

func (*SystemChannel) ProcessConfigMsg Uses

func (s *SystemChannel) ProcessConfigMsg(env *cb.Envelope) (*cb.Envelope, uint64, error)

ProcessConfigMsg takes envelope of following two types:

- `HeaderType_CONFIG`: system channel itself is the target of config, we simply unpack `ConfigUpdate`
  envelope from `LastUpdate` field and call `ProcessConfigUpdateMsg` on the underlying standard channel
- `HeaderType_ORDERER_TRANSACTION`: it's a channel creation message, we unpack `ConfigUpdate` envelope
  and run `ProcessConfigUpdateMsg` on it

func (*SystemChannel) ProcessConfigUpdateMsg Uses

func (s *SystemChannel) ProcessConfigUpdateMsg(envConfigUpdate *cb.Envelope) (config *cb.Envelope, configSeq uint64, err error)

ProcessConfigUpdateMsg handles messages of type CONFIG_UPDATE either for the system channel itself or, for channel creation. In the channel creation case, the CONFIG_UPDATE is wrapped into a resulting ORDERER_TRANSACTION, and in the standard CONFIG_UPDATE case, a resulting CONFIG message

func (*SystemChannel) ProcessNormalMsg Uses

func (s *SystemChannel) ProcessNormalMsg(msg *cb.Envelope) (configSeq uint64, err error)

ProcessNormalMsg handles normal messages, rejecting them if they are not bound for the system channel ID with ErrChannelDoesNotExist.

Package msgprocessor imports 16 packages (graph) and is imported by 14 packages. Updated 2019-08-09. Refresh now. Tools for package owners.