orderers

package
v0.3.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 24, 2023 License: Apache-2.0 Imports: 25 Imported by: 0

Documentation

Index

Constants

View Source
const (
	PermissiveValidityChecker = iota
	CheckpointValidityChecker
)

Variables

This section is empty.

Functions

func Factory

func Factory(
	mc *ModuleConfig,
	issParams *issconfig.ModuleParams,
	ownID t.NodeID,
	hashImpl crypto.HashImpl,
	chkpVerifier checkpoint.Verifier,
	logger logging.Logger,
) modules.PassiveModule

func HashOrigin

func HashOrigin(module t.ModuleID, origin *ordererspb.SBInstanceHashOrigin) *eventpb.HashOrigin

func InstanceParams

func InstanceParams(
	segment *Segment,
	availabilityID t.ModuleID,
	epoch t.EpochNr,
	validityCheckerType ValidityCheckerType,
) *factorymodulepb.GeneratorParams

func OrdererEvent

func OrdererEvent(
	destModule t.ModuleID,
	event *ordererspb.SBInstanceEvent,
) *eventpb.Event

func OrdererMessage

func OrdererMessage(msg *ordererspb.SBInstanceMessage, destModule t.ModuleID) *messagepb.Message

func PbftCatchUpRequestSBMessage

func PbftCatchUpRequestSBMessage(sn t.SeqNr, digest []byte) *ordererspb.SBInstanceMessage

func PbftCatchUpResponseSBMessage

func PbftCatchUpResponseSBMessage(preprepare *ordererspbftpb.Preprepare) *ordererspb.SBInstanceMessage

func PbftCommitSBMessage

func PbftCommitSBMessage(content *ordererspbftpb.Commit) *ordererspb.SBInstanceMessage

func PbftDoneSBMessage

func PbftDoneSBMessage(digests [][]byte) *ordererspb.SBInstanceMessage

func PbftMissingPreprepareSBMessage

func PbftMissingPreprepareSBMessage(preprepare *ordererspbftpb.Preprepare) *ordererspb.SBInstanceMessage

func PbftNewViewSBMessage

func PbftNewViewSBMessage(newView *ordererspbftpb.NewView) *ordererspb.SBInstanceMessage

func PbftPrepareSBMessage

func PbftPrepareSBMessage(content *ordererspbftpb.Prepare) *ordererspb.SBInstanceMessage

func PbftPreprepareRequestSBMessage

func PbftPreprepareRequestSBMessage(preprepareRequest *ordererspbftpb.PreprepareRequest) *ordererspb.SBInstanceMessage

func PbftPreprepareSBMessage

func PbftPreprepareSBMessage(content *ordererspbftpb.Preprepare) *ordererspb.SBInstanceMessage

func PbftProposeTimeout

func PbftProposeTimeout(numProposals uint64) *ordererspb.SBInstanceEvent

func PbftSignedViewChangeSBMessage

func PbftSignedViewChangeSBMessage(signedViewChange *ordererspbftpb.SignedViewChange) *ordererspb.SBInstanceMessage

func PbftViewChangeSNTimeout

func PbftViewChangeSNTimeout(view t.PBFTViewNr, numCommitted int) *ordererspb.SBInstanceEvent

func PbftViewChangeSegmentTimeout

func PbftViewChangeSegmentTimeout(view t.PBFTViewNr) *ordererspb.SBInstanceEvent

func SBDeliverEvent

func SBDeliverEvent(sn t.SeqNr, data []byte, aborted bool, leader t.NodeID, instanceID t.ModuleID) *isspb.ISSEvent

func SigVerOrigin

func SigVerOrigin(module t.ModuleID, origin *ordererspb.SBInstanceSigVerOrigin) *eventpb.SigVerOrigin

func SignOrigin

func SignOrigin(module t.ModuleID, origin *ordererspb.SBInstanceSignOrigin) *eventpb.SignOrigin

Types

type ModuleConfig

type ModuleConfig struct {
	Self   t.ModuleID
	App    t.ModuleID
	Timer  t.ModuleID
	Hasher t.ModuleID
	Crypto t.ModuleID
	Net    t.ModuleID
	Ord    t.ModuleID
	Ava    t.ModuleID
}

func DefaultModuleConfig

func DefaultModuleConfig() *ModuleConfig

type Orderer

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

Orderer represents a PBFT Orderer. It implements the sbInstance (instance of Sequenced broadcast) interface and thus can be used as an Orderer for ISS.

func NewOrdererModule

func NewOrdererModule(
	moduleConfig *ModuleConfig,
	ownID t.NodeID,
	segment *Segment,
	config *PBFTConfig,
	externalValidator ValidityChecker,
	logger logging.Logger) *Orderer

NewOrdererModule allocates and initializes a new instance of the PBFT Orderer. It takes the following parameters:

  • moduleConfig
  • ownID: The ID of this node.
  • segment: The segment governing this SB instance, specifying the leader, the set of sequence numbers, the buckets, etc.
  • config: PBFT-specific configuration parameters.
  • eventService: OrdererEvent creator object enabling the Orderer to produce events. All events this Orderer creates will be created using the methods of the eventService. since the implementation of the Orderer does not know its own identity at the level of ISS.
  • logger: Logger for outputting debugging messages.

func (*Orderer) ApplyEvent

func (orderer *Orderer) ApplyEvent(event *eventpb.Event) (*events.EventList, error)

ApplyEvent receives one event and applies it to the PBFT Orderer state machine, potentially altering its state and producing a (potentially empty) list of more events.

func (*Orderer) ApplyEvents

func (orderer *Orderer) ApplyEvents(evts *events.EventList) (*events.EventList, error)

func (*Orderer) ImplementsModule

func (orderer *Orderer) ImplementsModule()

The ImplementsModule method only serves the purpose of indicating that this is a Module and must not be called.

func (*Orderer) Segment

func (orderer *Orderer) Segment() *Segment

Segment returns the segment associated with this Orderer.

type PBFTConfig

type PBFTConfig struct {

	// The IDs of all nodes that execute this instance of the protocol.
	// Must not be empty.
	Membership []t.NodeID

	// The maximum time duration between two proposals of new certificatees during normal operation.
	// This parameter caps the waiting time in order to bound latency.
	// When MaxProposeDelay has elapsed since the last proposal,
	// the protocol tries to propose a new availability certificate.
	// Must not be negative.
	MaxProposeDelay time.Duration

	// When a node has committed all certificates in a segment, it will periodically send the Done message
	// in intervals of DoneResendPeriod.
	DoneResendPeriod time.Duration

	// After a node learns about a quorum of other nodes finishing a segment,
	// it waits for CatchUpDelay before requesting missing committed certificates from other nodes.
	CatchUpDelay time.Duration

	// Maximal number of bytes used for message backlogging buffers
	// (only message payloads are counted towards MsgBufCapacity).
	// Same as ModuleParams.MsgBufCapacity, but used only for one instance of PBFT.
	// Must not be negative.
	MsgBufCapacity int

	// Per-sequence-number view change timeout for view 0.
	// If no certificate is delivered by a PBFT instance within this timeout, the node triggers a view change.
	// With each new view, the timeout doubles (without changing this value)
	ViewChangeSNTimeout time.Duration

	// View change timeout for view 0 for the whole segment.
	// If not all certificates of the associated segment are delivered by a PBFT instance within this timeout,
	// the node triggers a view change.
	// With each new view, the timeout doubles (without changing this value)
	ViewChangeSegmentTimeout time.Duration

	// Time period between resending a ViewChange message.
	// ViewChange messages need to be resent periodically to preserve liveness.
	// Otherwise, the system could get stuck if a ViewChange message is dropped by the network.
	ViewChangeResendPeriod time.Duration
	// contains filtered or unexported fields
}

PBFTConfig holds PBFT-specific configuration parameters used by a concrete instance of PBFT. They are mostly inherited from the ISS configuration at the time of creating the PBFT instance.

type Segment

type Segment struct {

	// The leader node of the orderer.
	Leader t.NodeID

	// All nodes executing the orderer implementation.
	Membership map[t.NodeID]t.NodeAddress

	// Sequence numbers for which the orderer is responsible, along with corresponding (optional) pre-defined proposals.
	// The keys of this map are the actual "segment" of the commit log.
	// A nil value means that no proposal is specified (and the protocol implementation will decide what to propose).
	// A non-nil value will be proposed (by this node) for that sequence number whenever possible.
	// Currently, such a "free" proposal is a new availability certificate in view 0,
	// and a special empty one in other views.
	Proposals map[t.SeqNr][]byte
}

The Segment type represents an ISS Segment. It is used to parametrize an orderer (i.e. the SB instance).

func NewSegment added in v0.2.2

func NewSegment(leader t.NodeID, membership map[t.NodeID]t.NodeAddress, proposals map[t.SeqNr][]byte) *Segment

func SegmentFromPb added in v0.2.2

func SegmentFromPb(seg *ordererspb.PBFTSegment) *Segment

func (*Segment) LeaderIndex added in v0.2.2

func (seg *Segment) LeaderIndex() int

func (*Segment) Len added in v0.2.2

func (seg *Segment) Len() int

func (*Segment) NodeIDs added in v0.2.2

func (seg *Segment) NodeIDs() []t.NodeID

func (*Segment) Pb added in v0.2.2

func (seg *Segment) Pb() *ordererspb.PBFTSegment

func (*Segment) PrimaryNode added in v0.2.2

func (seg *Segment) PrimaryNode(view t.PBFTViewNr) t.NodeID

func (*Segment) SeqNrs

func (seg *Segment) SeqNrs() []t.SeqNr

type ValidityChecker added in v0.2.2

type ValidityChecker interface {

	// Check returns nil if the provided proposal data is valid, a non-nil error otherwise.
	Check(data []byte) error
}

ValidityChecker is the interface of an external checker of validity of proposed data. Each orderer is provided with an object implementing this interface and applies its Check method to all received proposals.

type ValidityCheckerType added in v0.2.2

type ValidityCheckerType uint64

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL