checkpoint

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: 21 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultResendPeriod = t.TimeDuration(time.Second)
)

Variables

This section is empty.

Functions

func Factory

func Factory(mc *ModuleConfig, ownID t.NodeID, logger logging.Logger) modules.PassiveModule

Types

type Certificate added in v0.1.1

type Certificate map[t.NodeID][]byte

Certificate represents a certificate of validity of a checkpoint. It is included in a stable checkpoint itself.

func (*Certificate) Deserialize added in v0.1.1

func (cert *Certificate) Deserialize(data []byte) error

func (*Certificate) Pb added in v0.1.1

func (cert *Certificate) Pb() map[string][]byte

func (*Certificate) Serialize added in v0.1.1

func (cert *Certificate) Serialize() ([]byte, error)

type ModuleConfig

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

func DefaultModuleConfig

func DefaultModuleConfig() *ModuleConfig

type Protocol

type Protocol struct {
	logging.Logger
	// contains filtered or unexported fields
}

Protocol represents the state associated with a single instance of the checkpoint protocol (establishing a single stable checkpoint).

func NewProtocol

func NewProtocol(
	moduleConfig *ModuleConfig,
	ownID t.NodeID,
	membership map[t.NodeID]t.NodeAddress,
	epochConfig *commonpb.EpochConfig,
	leaderPolicyData []byte,
	resendPeriod t.TimeDuration,
	logger logging.Logger,
) *Protocol

NewProtocol allocates and returns a new instance of the Protocol associated with sequence number sn.

func (*Protocol) ApplyEvents

func (p *Protocol) ApplyEvents(evts *events.EventList) (*events.EventList, error)

func (*Protocol) ImplementsModule

func (p *Protocol) ImplementsModule()

type StableCheckpoint

type StableCheckpoint checkpointpb.StableCheckpoint

StableCheckpoint represents a stable checkpoint.

func Genesis

func Genesis(initialStateSnapshot *commonpb.StateSnapshot) *StableCheckpoint

Genesis returns a stable checkpoint that serves as the starting checkpoint of the first epoch (epoch 0). Its certificate is empty and is always considered valid, as there is no previous epoch's membership to verify it against.

func StableCheckpointFromPb

func StableCheckpointFromPb(checkpoint *checkpointpb.StableCheckpoint) *StableCheckpoint

StableCheckpointFromPb creates a new StableCheckpoint from its protobuf representation. The given protobuf object is assumed to not be modified after calling StableCheckpointFromPb. Modifying it may lead to undefined behavior.

func (*StableCheckpoint) AttachCert added in v0.1.1

func (sc *StableCheckpoint) AttachCert(cert *Certificate) *StableCheckpoint

AttachCert returns a new stable checkpoint with the given certificate attached. If the stable checkpoint already had a certificate attached, the old certificate is replaced by the new one.

func (*StableCheckpoint) Certificate added in v0.1.1

func (sc *StableCheckpoint) Certificate() *Certificate

func (*StableCheckpoint) ClientProgress

func (sc *StableCheckpoint) ClientProgress(logger logging.Logger) *clientprogress.ClientProgress

func (*StableCheckpoint) Deserialize added in v0.1.1

func (sc *StableCheckpoint) Deserialize(data []byte) error

Deserialize populates its fields from the serialized representation previously returned from StableCheckpoint.Serialize.

func (*StableCheckpoint) Epoch

func (sc *StableCheckpoint) Epoch() t.EpochNr

Epoch returns the epoch associated with this checkpoint. It is the epoch **started** by this checkpoint, **not** the last one included in it.

func (*StableCheckpoint) Memberships

func (sc *StableCheckpoint) Memberships() []map[t.NodeID]t.NodeAddress

Memberships returns the memberships configured for the epoch of this checkpoint and potentially several subsequent ones.

func (*StableCheckpoint) Pb

Pb returns a protobuf representation of the stable checkpoint.

func (*StableCheckpoint) PreviousMembership added in v0.2.2

func (sc *StableCheckpoint) PreviousMembership() map[t.NodeID]t.NodeAddress

PreviousMembership returns the membership of the epoch preceding the epoch the checkpoint is associated with (i.e. the membership of sc.Epoch()-1). This is the membership that created the checkpoint and must be used to verify its certificate. Note that this membership is contained in the checkpoint itself and thus can be forged. Using PreviousMembership as an argument to VerifyCert without independently checking its validity is not secure (in this sense, the checkpoint certificate is self-signed).

func (*StableCheckpoint) SeqNr

func (sc *StableCheckpoint) SeqNr() t.SeqNr

SeqNr returns the sequence number of the stable checkpoint. It is defined as the number of sequence numbers comprised in the checkpoint, or, in other words, the first (i.e., lowest) sequence number not included in the checkpoint.

func (*StableCheckpoint) Serialize

func (sc *StableCheckpoint) Serialize() ([]byte, error)

Serialize returns the stable checkpoint serialized as a byte slice. It is the inverse of Deserialize, to which the returned byte slice can be passed to restore the checkpoint.

func (*StableCheckpoint) StateSnapshot

func (sc *StableCheckpoint) StateSnapshot() *commonpb.StateSnapshot

StateSnapshot returns the serialized application state and system configuration associated with this checkpoint.

func (*StableCheckpoint) StripCert added in v0.1.1

func (sc *StableCheckpoint) StripCert() *StableCheckpoint

StripCert returns a stable new stable checkpoint with the certificate stripped off. The returned copy is a shallow one, sharing the data with the original.

func (*StableCheckpoint) VerifyCert

func (sc *StableCheckpoint) VerifyCert(h crypto.HashImpl, v Verifier, membership map[t.NodeID]t.NodeAddress) error

VerifyCert verifies the certificate of the stable checkpoint using the provided hash implementation and verifier. The same (or corresponding) modules must have been used when the certificate was created by the checkpoint module. The has implementation is a crypto.HashImpl used to create a Mir hasher module and the verifier interface is a subset of the crypto.Crypto interface (narrowed down to only the Verify function). Thus, the same (or equivalent) crypto implementation that was used to create checkpoint can be used as a Verifier to verify it.

Note that VerifyCert performs all the necessary hashing and signature verifications synchronously (only returns when the signature is verified). This may become a very computationally expensive operation. It is thus recommended not to use this function directly within a sequential protocol implementation, and rather delegating the hashing and signature verification tasks to dedicated modules using the corresponding events. Also, in case the verifier implementation is used by other goroutines, make sure that calling Vetify on it is thread-safe.

For simplicity, we require all nodes that signed the certificate to be contained in the provided membership, as well as all signatures to be valid. Moreover, the number of nodes that signed the certificate must be greater than one third of the membership size.

type Verifier

type Verifier interface {
	// Verify verifies a signature produced by the node with ID nodeID over data.
	// Returns nil on success (i.e., if the given signature is valid) and a non-nil error otherwise.
	Verify(data [][]byte, signature []byte, nodeID t.NodeID) error
}

The Verifier interface represents a subset of the crypto.Crypto interface that can be used for verifying stable checkpoint certificates.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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