Documentation ¶
Index ¶
- Constants
- func Factory(mc ModuleConfig, ownID t.NodeID, logger logging.Logger) modules.PassiveModule
- func NewModule(moduleConfig ModuleConfig, params *ModuleParams, logger logging.Logger) modules.PassiveModule
- type Certificate
- type ModuleConfig
- type ModuleParams
- type StableCheckpoint
- func (sc *StableCheckpoint) AttachCert(cert *Certificate) *StableCheckpoint
- func (sc *StableCheckpoint) Certificate() Certificate
- func (sc *StableCheckpoint) ClientProgress(logger logging.Logger) *clientprogress.ClientProgress
- func (sc *StableCheckpoint) Deserialize(data []byte) error
- func (sc *StableCheckpoint) Epoch() tt.EpochNr
- func (sc *StableCheckpoint) Memberships() []*trantorpbtypes.Membership
- func (sc *StableCheckpoint) Pb() *checkpointpb.StableCheckpoint
- func (sc *StableCheckpoint) PreviousMembership() *trantorpbtypes.Membership
- func (sc *StableCheckpoint) SeqNr() tt.SeqNr
- func (sc *StableCheckpoint) Serialize() ([]byte, error)
- func (sc *StableCheckpoint) StateSnapshot() *trantorpbtypes.StateSnapshot
- func (sc *StableCheckpoint) StripCert() *StableCheckpoint
- func (sc *StableCheckpoint) SyntacticCheck(configOffset int) error
- func (sc *StableCheckpoint) Verify(configOffset int, hashImpl crypto.HashImpl, chkpVerifier Verifier, ...) error
- func (sc *StableCheckpoint) VerifyCert(h crypto.HashImpl, v Verifier, membership *trantorpbtypes.Membership) error
- type State
- type Verifier
Constants ¶
const (
DefaultResendPeriod = types.Duration(time.Second)
)
Variables ¶
This section is empty.
Functions ¶
func Factory ¶
func Factory(mc ModuleConfig, ownID t.NodeID, logger logging.Logger) modules.PassiveModule
func NewModule ¶ added in v0.4.0
func NewModule( moduleConfig ModuleConfig, params *ModuleParams, logger logging.Logger) modules.PassiveModule
NewModule allocates and returns a new instance of the ModuleParams associated with sequence number sn.
Types ¶
type Certificate ¶ added in v0.1.1
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 ModuleParams ¶ added in v0.4.0
type ModuleParams struct { // The ID of the node executing this instance of the protocol. OwnID t.NodeID // The IDs of nodes to execute this instance of the checkpoint protocol. // Note that it is the Membership of Epoch e-1 that constructs the Membership for Epoch e. // (As the starting checkpoint for e is the "finishing" checkpoint for e-1.) Membership *trantorpbtypes.Membership // EpochConfig to which this checkpoint belongs // It contains:. // - the Epoch the checkpoint's associated sequence number (SeqNr) is part of. // - Sequence number associated with this checkpoint protocol instance. // This checkpoint encompasses SeqNr sequence numbers, // i.e., SeqNr is the first sequence number *not* encompassed by this checkpoint. // One can imagine that the checkpoint represents the state of the system just before SeqNr, // i.e., "between" SeqNr-1 and SeqNr. // among others EpochConfig *trantorpbtypes.EpochConfig // LeaderPolicy serialization data. LeaderPolicyData []byte // Time interval for repeated retransmission of checkpoint messages. ResendPeriod types.Duration }
ModuleParams represents the state associated with a single instance of the checkpoint protocol (establishing a single stable checkpoint).
type StableCheckpoint ¶
type StableCheckpoint checkpointpbtypes.StableCheckpoint
StableCheckpoint represents a stable checkpoint.
func Genesis ¶
func Genesis(initialStateSnapshot *trantorpbtypes.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() tt.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() []*trantorpbtypes.Membership
Memberships returns the memberships configured for the epoch of this checkpoint and potentially several subsequent ones.
func (*StableCheckpoint) Pb ¶
func (sc *StableCheckpoint) Pb() *checkpointpb.StableCheckpoint
Pb returns a protobuf representation of the stable checkpoint.
func (*StableCheckpoint) PreviousMembership ¶ added in v0.2.2
func (sc *StableCheckpoint) PreviousMembership() *trantorpbtypes.Membership
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() tt.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() *trantorpbtypes.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) SyntacticCheck ¶ added in v0.4.0
func (sc *StableCheckpoint) SyntacticCheck( configOffset int, ) error
SyntacticCheck checks whether the stable checkpoint is well-formed.
func (*StableCheckpoint) Verify ¶ added in v0.4.0
func (sc *StableCheckpoint) Verify( configOffset int, hashImpl crypto.HashImpl, chkpVerifier Verifier, membership *trantorpbtypes.Membership, ) error
Verify makes the necessary checks to verify a checkpoint
func (*StableCheckpoint) VerifyCert ¶
func (sc *StableCheckpoint) VerifyCert(h crypto.HashImpl, v Verifier, membership *trantorpbtypes.Membership) 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 State ¶ added in v0.4.0
type State struct { // State snapshot associated with this checkpoint. StateSnapshot *trantorpbtypes.StateSnapshot // Hash of the state snapshot data associated with this checkpoint. StateSnapshotHash []byte // Set of nodes' valid checkpoint Signatures (these will make up a checkpoint certificate). Signatures map[t.NodeID][]byte // Set of nodes from which a (potentially invalid) Checkpoint messages has been received // (used to ignore duplicate messages). SigReceived map[t.NodeID]struct{} // Set of Checkpoint messages that were received ahead of time. PendingMessages map[t.NodeID]*checkpointpbtypes.Checkpoint // Flag ensuring that the stable checkpoint is only Announced once. // Set to true when announcing a stable checkpoint for the first time. // When true, stable checkpoints are not Announced anymore. Announced bool }
func (*State) SnapshotReady ¶ added in v0.4.0
func (*State) Stable ¶ added in v0.4.0
func (state *State) Stable(p *ModuleParams) bool
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.