issutil

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Jan 13, 2023 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckParams

func CheckParams(c *ModuleParams) error

CheckParams checks whether the given configuration satisfies all necessary constraints.

func MaxFaulty

func MaxFaulty(n int) int

func RemoveNodeID

func RemoveNodeID(membership []t.NodeID, nID t.NodeID) []t.NodeID

RemoveNodeID removes a node ID from a list of node IDs. Takes a membership list and a Node ID and returns a new list of nodeIDs containing all IDs from the membership list, except for (if present) the specified nID. This is useful for obtaining the list of "other nodes" by removing the own ID from the membership.

func StrongQuorum

func StrongQuorum(n int) int

func WeakQuorum

func WeakQuorum(n int) int

Types

type BlacklistLeaderPolicy

type BlacklistLeaderPolicy struct {
	Membership map[t.NodeID]struct{}
	Suspected  map[t.NodeID]t.EpochNr
	MinLeaders int
}

func BlacklistLeaderPolicyFromBytes

func BlacklistLeaderPolicyFromBytes(data []byte) (*BlacklistLeaderPolicy, error)

func NewBlackListLeaderPolicy

func NewBlackListLeaderPolicy(members []t.NodeID, MinLeaders int) *BlacklistLeaderPolicy

func (*BlacklistLeaderPolicy) Bytes

func (l *BlacklistLeaderPolicy) Bytes() ([]byte, error)

func (*BlacklistLeaderPolicy) Leaders

func (l *BlacklistLeaderPolicy) Leaders() []t.NodeID

Leaders always returns the whole membership for the SimpleLeaderPolicy. All nodes are always leaders.

func (*BlacklistLeaderPolicy) Reconfigure

func (l *BlacklistLeaderPolicy) Reconfigure(nodeIDs []t.NodeID) LeaderSelectionPolicy

Reconfigure informs the leader selection policy about a change in the membership.

func (*BlacklistLeaderPolicy) Suspect

func (l *BlacklistLeaderPolicy) Suspect(e t.EpochNr, node t.NodeID)

Suspect adds a new suspect to the list of suspects, or updates its epoch where it was suspected to the given epoch if this one is more recent than the one it already has

type LeaderPolicyType

type LeaderPolicyType uint64
const (
	Simple LeaderPolicyType = iota
	Blacklist
)

type LeaderSelectionPolicy

type LeaderSelectionPolicy interface {

	// Leaders returns the (ordered) list of leaders based on the given epoch e and on the state of this policy object.
	Leaders() []t.NodeID

	// Suspect updates the state of the policy object by announcing it that node `node` has been suspected in epoch `e`.
	Suspect(e t.EpochNr, node t.NodeID)

	// Reconfigure returns a new LeaderSelectionPolicy based on the state of the current one,
	// but using a new configuration.
	// TODO: Use the whole configuration, not just the node IDs.
	Reconfigure(nodeIDs []t.NodeID) LeaderSelectionPolicy

	Bytes() ([]byte, error)
}

A LeaderSelectionPolicy implements the algorithm for selecting a set of leaders in each ISS epoch. In a nutshell, it gathers information about suspected leaders in the past epochs and uses it to calculate the set of leaders for future epochs. Its state can be updated using Suspect() and the leader set for an epoch is queried using Leaders(). A leader set policy must be deterministic, i.e., calling Leaders() after the same sequence of Suspect() invocations always returns the same set of leaders at every Node.

func LeaderPolicyFromBytes

func LeaderPolicyFromBytes(bytes []byte) (LeaderSelectionPolicy, error)

type ModuleParams

type ModuleParams struct {

	// The identities of all nodes that execute the protocol in the first epoch.
	// Must not be empty.
	InitialMembership map[t.NodeID]t.NodeAddress

	// Number of epochs by which to delay configuration changes.
	// If a configuration is agreed upon in epoch e, it will take effect in epoch e + 1 + configOffset.
	// Thus, in the "current" configuration, ConfigOffset subsequent configurations are already known.
	ConfigOffset int

	// The length of an ISS segment, in sequence numbers.
	// This is the number of commitLog entries each orderer needs to output in an epoch.
	// Depending on the number of leaders (and thus orderers), this will result in epoch of different lengths.
	// If set to 0, the EpochLength parameter must be non-zero and will be used to calculate the length of the segments
	// such that their lengths sum up to EpochLength.
	// Must not be negative.
	SegmentLength int

	// The length of an ISS epoch, in sequence numbers.
	// If EpochLength is non-zero, the epoch will always have a fixed
	// length, regardless of the number of leaders.
	// In each epoch, the corresponding segment lengths will be calculated to sum up to EpochLength,
	// potentially resulting in different segment length across epochs as well as within an epoch.
	// If set to zero, SegmentLength must be non-zero and will be used directly to set the length of each segment.
	// Must not be negative.
	// TODO: That EpochLength is not implemented now. SegmentLength has to be used.
	EpochLength int

	// The maximum time duration between two proposals of an orderer, where applicable.
	// For orderers that wait for an availability certificate to fill before proposing it (e.g. PBFT),
	// this parameter caps the waiting time in order to bound latency.
	// When MaxProposeDelay has elapsed since the last proposal made by an orderer,
	// the orderer proposes a new availability certificate.
	// Must not be negative.
	MaxProposeDelay time.Duration

	// Total number of buckets used by ISS.
	// In each epoch, these buckets are re-distributed evenly among the orderers.
	// Must be greater than 0.
	NumBuckets int

	// Number of logical time ticks to wait until demanding retransmission of missing requests.
	// If a node receives a proposal containing requests that are not in the node's buckets,
	// it cannot accept the proposal.
	// In such a case, the node will wait for RequestNAckTimeout ticks
	// before trying to fetch those requests from other nodes.
	// Must be positive.
	RequestNAckTimeout int

	// Maximal number of bytes used for message backlogging buffers
	// (only message payloads are counted towards MsgBufCapacity).
	// On reception of a message that the node is not yet ready to process
	// (e.g., a message from a future epoch received from another node that already transitioned to that epoch),
	// the message is stored in a buffer for later processing (e.g., when this node also transitions to that epoch).
	// This total buffer capacity is evenly split among multiple buffers, one for each node,
	// so that one misbehaving node cannot exhaust the whole buffer space.
	// The most recently received messages that together do not exceed the capacity are stored.
	// If the capacity is set to 0, all messages that cannot yet be processed are dropped on reception.
	// Must not be negative.
	MsgBufCapacity int

	// Number of most recent epochs that are older than the latest stable checkpoint.
	RetainedEpochs int

	// Every CatchUpTimerPeriod, a node checks whether other nodes have fallen behind
	// and, if so, sends them the latest state.
	CatchUpTimerPeriod time.Duration

	// Time interval for repeated retransmission of checkpoint messages.
	CheckpointResendPeriod time.Duration

	// View change timeout for the PBFT sub-protocol, in ticks.
	// TODO: Separate this in a sub-group of the ISS params, maybe even use a field of type PBFTConfig in ModuleParams.
	PBFTDoneResendPeriod         time.Duration
	PBFTCatchUpDelay             time.Duration
	PBFTViewChangeSNTimeout      time.Duration
	PBFTViewChangeSegmentTimeout time.Duration
	PBFTViewChangeResendPeriod   time.Duration
}

The ModuleParams type defines all the ISS configuration parameters. Note that some fields specify delays in ticks of the logical clock. To obtain real time delays, these need to be multiplied by the period of the ticker provided to the Node at runtime.

func DefaultParams

func DefaultParams(initialMembership map[t.NodeID]t.NodeAddress) *ModuleParams

DefaultParams returns the default configuration for a given membership. There is no guarantee that this configuration ensures good performance, but it will pass the CheckParams test. DefaultParams is intended for use during testing and hello-world examples. A proper deployment is expected to craft a custom configuration, for which DefaultParams can serve as a starting point.

func (*ModuleParams) AdjustSpeed

func (mp *ModuleParams) AdjustSpeed(maxProposeDelay time.Duration) *ModuleParams

AdjustSpeed sets multiple ISS parameters (e.g. view change timeouts) to their default values relative to maxProposeDelay. It can be useful to make the whole protocol run faster or slower. For example, for a large maxProposeDelay, the view change timeouts must be increased correspondingly, otherwise the view change can kick in before a node makes a proposal. AdjustSpeed makes these adjustments automatically.

type SimpleLeaderPolicy

type SimpleLeaderPolicy struct {
	Membership []t.NodeID
}

The SimpleLeaderPolicy is a trivial leader selection policy. It must be initialized with a set of node IDs and always returns that full set as leaders, regardless of which nodes have been suspected. In other words, each node is leader each epoch with this policy.

func NewSimpleLeaderPolicy

func NewSimpleLeaderPolicy(membership []t.NodeID) *SimpleLeaderPolicy

func SimpleLeaderPolicyFromBytes

func SimpleLeaderPolicyFromBytes(data []byte) (*SimpleLeaderPolicy, error)

func (*SimpleLeaderPolicy) Bytes

func (simple *SimpleLeaderPolicy) Bytes() ([]byte, error)

func (*SimpleLeaderPolicy) Leaders

func (simple *SimpleLeaderPolicy) Leaders() []t.NodeID

Leaders always returns the whole membership for the SimpleLeaderPolicy. All nodes are always leaders.

func (*SimpleLeaderPolicy) Reconfigure

func (simple *SimpleLeaderPolicy) Reconfigure(nodeIDs []t.NodeID) LeaderSelectionPolicy

Reconfigure informs the leader selection policy about a change in the membership.

func (*SimpleLeaderPolicy) Suspect

func (simple *SimpleLeaderPolicy) Suspect(e t.EpochNr, node t.NodeID)

Suspect does nothing for the SimpleLeaderPolicy.

Jump to

Keyboard shortcuts

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