Documentation ¶
Index ¶
- Variables
- type ConsensusManager
- func (x *ConsensusManager) CertificationResult() <-chan *types.UnicityCertificate
- func (x *ConsensusManager) GetLatestUnicityCertificate(id types.SystemID) (*types.UnicityCertificate, error)
- func (x *ConsensusManager) RequestCertification(ctx context.Context, cr consensus.IRChangeRequest) error
- func (x *ConsensusManager) Run(ctx context.Context) error
- type ConsensusWithSignatures
- type IRChangeReqVerifier
- type IRChangeVerifier
- type InProgressFn
- type IrReqBuffer
- type Leader
- type Observability
- type Pacemaker
- func (x *Pacemaker) AdvanceRoundQC(ctx context.Context, qc *types.QuorumCert) bool
- func (x *Pacemaker) AdvanceRoundTC(ctx context.Context, tc *types.TimeoutCert)
- func (x *Pacemaker) GetCurrentRound() uint64
- func (x *Pacemaker) GetTimeoutVote() *abdrc.TimeoutMsg
- func (x *Pacemaker) GetVoted() *abdrc.VoteMsg
- func (x *Pacemaker) LastRoundTC() *types.TimeoutCert
- func (x *Pacemaker) RegisterTimeoutVote(ctx context.Context, vote *abdrc.TimeoutMsg, quorum QuorumInfo) (*types.TimeoutCert, error)
- func (x *Pacemaker) RegisterVote(vote *abdrc.VoteMsg, quorum QuorumInfo) (*types.QuorumCert, bool, error)
- func (x *Pacemaker) Reset(ctx context.Context, highQCRound uint64, lastTc *types.TimeoutCert, ...)
- func (x *Pacemaker) RoundQC() *types.QuorumCert
- func (x *Pacemaker) SetTimeoutVote(vote *abdrc.TimeoutMsg)
- func (x *Pacemaker) SetVoted(vote *abdrc.VoteMsg)
- func (x *Pacemaker) StatusEvents() <-chan paceMakerStatus
- func (x *Pacemaker) Stop()
- type PartitionTimeout
- type PartitionTimeoutGenerator
- type QuorumInfo
- type RootNet
- type RootTrustBase
- func (r *RootTrustBase) GetMaxFaultyNodes() uint32
- func (r *RootTrustBase) GetQuorumThreshold() uint32
- func (r *RootTrustBase) GetVerifier(nodeID peer.ID) (crypto.Verifier, error)
- func (r *RootTrustBase) GetVerifiers() map[string]crypto.Verifier
- func (r *RootTrustBase) ValidateQuorum(authors []string) error
- func (r *RootTrustBase) VerifyBytes(bytes []byte, sig []byte, author peer.ID) error
- func (r *RootTrustBase) VerifyQuorumSignatures(hash []byte, signatures map[string][]byte) error
- func (r *RootTrustBase) VerifySignature(hash []byte, sig []byte, author peer.ID) error
- type SafetyModule
- func (s *SafetyModule) GetHighestQcRound() uint64
- func (s *SafetyModule) GetHighestVotedRound() uint64
- func (s *SafetyModule) MakeVote(block *drctypes.BlockData, execStateID []byte, highQC *drctypes.QuorumCert, ...) (*abdrc.VoteMsg, error)
- func (s *SafetyModule) SetHighestQcRound(highestQcRound uint64)
- func (s *SafetyModule) SetHighestVotedRound(highestVotedRound uint64)
- func (s *SafetyModule) Sign(msg Signer) error
- func (s *SafetyModule) SignTimeout(tmoVote *abdrc.TimeoutMsg, lastRoundTC *drctypes.TimeoutCert) error
- type Signer
- type State
- type VoteRegister
Constants ¶
This section is empty.
Variables ¶
var ErrDuplicateChangeReq = errors.New("duplicate ir change request")
var ErrVoteIsNil = errors.New("vote is nil")
Functions ¶
This section is empty.
Types ¶
type ConsensusManager ¶
type ConsensusManager struct {
// contains filtered or unexported fields
}
func NewDistributedAbConsensusManager ¶
func NewDistributedAbConsensusManager(nodeID peer.ID, rg *genesis.RootGenesis, partitionStore partitions.PartitionConfiguration, net RootNet, signer crypto.Signer, observe Observability, opts ...consensus.Option) (*ConsensusManager, error)
NewDistributedAbConsensusManager creates new "Atomic Broadcast" protocol based distributed consensus manager
func (*ConsensusManager) CertificationResult ¶
func (x *ConsensusManager) CertificationResult() <-chan *types.UnicityCertificate
func (*ConsensusManager) GetLatestUnicityCertificate ¶
func (x *ConsensusManager) GetLatestUnicityCertificate(id types.SystemID) (*types.UnicityCertificate, error)
func (*ConsensusManager) RequestCertification ¶
func (x *ConsensusManager) RequestCertification(ctx context.Context, cr consensus.IRChangeRequest) error
type ConsensusWithSignatures ¶
type ConsensusWithSignatures struct {
// contains filtered or unexported fields
}
type IRChangeReqVerifier ¶
type IRChangeReqVerifier struct {
// contains filtered or unexported fields
}
func NewIRChangeReqVerifier ¶
func NewIRChangeReqVerifier(c *consensus.Parameters, pInfo partitions.PartitionConfiguration, sMonitor State) (*IRChangeReqVerifier, error)
func (*IRChangeReqVerifier) VerifyIRChangeReq ¶
func (x *IRChangeReqVerifier) VerifyIRChangeReq(round uint64, irChReq *abtypes.IRChangeReq) (*storage.InputData, error)
type IRChangeVerifier ¶
type InProgressFn ¶
type InProgressFn func(id32 types.SystemID) *types.InputRecord
type IrReqBuffer ¶
type IrReqBuffer struct {
// contains filtered or unexported fields
}
func NewIrReqBuffer ¶
func NewIrReqBuffer(log *slog.Logger) *IrReqBuffer
func (*IrReqBuffer) Add ¶
func (x *IrReqBuffer) Add(round uint64, irChReq *drctypes.IRChangeReq, ver IRChangeVerifier) error
Add validates incoming IR change request and buffers valid requests. If for any reason the IR request is found not valid, reason is logged, error is returned and request is ignored.
func (*IrReqBuffer) GeneratePayload ¶
func (x *IrReqBuffer) GeneratePayload(round uint64, timeouts []types.SystemID, inProgress InProgressFn) *drctypes.Payload
GeneratePayload generates new proposal payload from buffered IR change requests.
func (*IrReqBuffer) IsChangeInBuffer ¶
func (x *IrReqBuffer) IsChangeInBuffer(id types.SystemID) bool
IsChangeInBuffer returns true if there is a request for IR change from the partition in the buffer
type Leader ¶
type Leader interface { // GetLeaderForRound returns valid leader (node id) for round/view number GetLeaderForRound(round uint64) peer.ID // GetNodes - get all node id's currently active GetNodes() []peer.ID // Update - what PaceMaker considers to be the current round at the time QC is processed. Update(qc *drctypes.QuorumCert, currentRound uint64, b leader.BlockLoader) error }
Leader provides interface to different leader selection algorithms
type Observability ¶
type Pacemaker ¶
type Pacemaker struct {
// contains filtered or unexported fields
}
Pacemaker tracks the current round/view number - a new round/view starts if there is a quorum certificate or timeout certificate for the previous round. It also provides "round clock" which allows to make sure that rounds are not produced too fast but also do not take too long (timeout). In addition it keeps track of validator data related to the active round (votes received if next leader or votes sent if follower).
func NewPacemaker ¶
func NewPacemaker(minRoundLen, maxRoundLen time.Duration, observe Observability) (*Pacemaker, error)
NewPacemaker initializes new Pacemaker instance (zero value is not usable).
- minRoundLen is the minimum round duration, rounds shouldn't advance faster than that;
- maxRoundLen is maximum round duration, after that round is considered to be timed out;
The maxRoundLen must be greater than minRoundLen or the Pacemaker will crash at some point!
func (*Pacemaker) AdvanceRoundQC ¶
AdvanceRoundQC - trigger next round/view on quorum certificate
func (*Pacemaker) AdvanceRoundTC ¶
func (x *Pacemaker) AdvanceRoundTC(ctx context.Context, tc *types.TimeoutCert)
AdvanceRoundTC - trigger next round/view on timeout certificate
func (*Pacemaker) GetCurrentRound ¶
func (*Pacemaker) GetTimeoutVote ¶
func (x *Pacemaker) GetTimeoutVote() *abdrc.TimeoutMsg
GetTimeoutVote - has the node voted for timeout in this round, returns either vote or nil
func (*Pacemaker) GetVoted ¶
GetVoted - has the node voted in this round, returns either vote or nil
func (*Pacemaker) LastRoundTC ¶
func (x *Pacemaker) LastRoundTC() *types.TimeoutCert
func (*Pacemaker) RegisterTimeoutVote ¶
func (x *Pacemaker) RegisterTimeoutVote(ctx context.Context, vote *abdrc.TimeoutMsg, quorum QuorumInfo) (*types.TimeoutCert, error)
RegisterTimeoutVote registers time-out vote from root node (including vote from self) and tries to assemble a timeout quorum certificate for the round.
func (*Pacemaker) RegisterVote ¶
func (x *Pacemaker) RegisterVote(vote *abdrc.VoteMsg, quorum QuorumInfo) (*types.QuorumCert, bool, error)
RegisterVote register vote for the round and assembles quorum certificate when quorum condition is met. It returns non nil QC in case of quorum is achieved. It also returns bool which indicates is the round "mature", ie it has lasted at least the minimum required amount of time to make proposal.
func (*Pacemaker) Reset ¶
func (x *Pacemaker) Reset(ctx context.Context, highQCRound uint64, lastTc *types.TimeoutCert, lastVote any)
Reset sets the pacemaker's "last committed round" and starts next round. This method should only used to start the pacemaker and reset it's status on system recovery, during normal operation current round is advanced by calling AdvanceRoundQC or AdvanceRoundTC.
func (*Pacemaker) RoundQC ¶
func (x *Pacemaker) RoundQC() *types.QuorumCert
RoundQC returns the latest QC produced by calling RegisterVote.
func (*Pacemaker) SetTimeoutVote ¶
func (x *Pacemaker) SetTimeoutVote(vote *abdrc.TimeoutMsg)
SetTimeoutVote - remember timeout vote sent in this view
func (*Pacemaker) StatusEvents ¶
func (x *Pacemaker) StatusEvents() <-chan paceMakerStatus
StatusEvents returns channel into which events are posted when round state changes.
Events are produced once per state change, except pmsRoundTimeout which will be repeated every time maxRoundLen elapses and new round hasn't been started yet.
pmsRoundInProgress (ie new round started) event is never produced!
type PartitionTimeout ¶
type PartitionTimeoutGenerator ¶
type PartitionTimeoutGenerator struct {
// contains filtered or unexported fields
}
func NewLucBasedT2TimeoutGenerator ¶
func NewLucBasedT2TimeoutGenerator(c *consensus.Parameters, pInfo partitions.PartitionConfiguration, sMonitor State) (*PartitionTimeoutGenerator, error)
func (*PartitionTimeoutGenerator) GetT2Timeouts ¶
func (x *PartitionTimeoutGenerator) GetT2Timeouts(currentRound uint64) ([]types.SystemID, error)
type QuorumInfo ¶
type RootTrustBase ¶
type RootTrustBase struct {
// contains filtered or unexported fields
}
func NewRootTrustBase ¶
func NewRootTrustBaseFromGenesis ¶
func NewRootTrustBaseFromGenesis(genesisRoot *genesis.GenesisRootRecord) (*RootTrustBase, error)
func (*RootTrustBase) GetMaxFaultyNodes ¶
func (r *RootTrustBase) GetMaxFaultyNodes() uint32
GetMaxFaultyNodes a.k.a get max allowed faulty nodes
func (*RootTrustBase) GetQuorumThreshold ¶
func (r *RootTrustBase) GetQuorumThreshold() uint32
GetQuorumThreshold returns quorum power needed. Currently, all validators are equal and each vote counts as one.
func (*RootTrustBase) GetVerifier ¶
func (*RootTrustBase) GetVerifiers ¶
func (r *RootTrustBase) GetVerifiers() map[string]crypto.Verifier
func (*RootTrustBase) ValidateQuorum ¶
func (r *RootTrustBase) ValidateQuorum(authors []string) error
func (*RootTrustBase) VerifyBytes ¶
func (*RootTrustBase) VerifyQuorumSignatures ¶
func (r *RootTrustBase) VerifyQuorumSignatures(hash []byte, signatures map[string][]byte) error
func (*RootTrustBase) VerifySignature ¶
type SafetyModule ¶
type SafetyModule struct {
// contains filtered or unexported fields
}
func NewSafetyModule ¶
func NewSafetyModule(id string, signer crypto.Signer, db keyvaluedb.KeyValueDB) (*SafetyModule, error)
func (*SafetyModule) GetHighestQcRound ¶
func (s *SafetyModule) GetHighestQcRound() uint64
func (*SafetyModule) GetHighestVotedRound ¶
func (s *SafetyModule) GetHighestVotedRound() uint64
func (*SafetyModule) MakeVote ¶
func (s *SafetyModule) MakeVote(block *drctypes.BlockData, execStateID []byte, highQC *drctypes.QuorumCert, lastRoundTC *drctypes.TimeoutCert) (*abdrc.VoteMsg, error)
func (*SafetyModule) SetHighestQcRound ¶
func (s *SafetyModule) SetHighestQcRound(highestQcRound uint64)
func (*SafetyModule) SetHighestVotedRound ¶
func (s *SafetyModule) SetHighestVotedRound(highestVotedRound uint64)
func (*SafetyModule) Sign ¶
func (s *SafetyModule) Sign(msg Signer) error
func (*SafetyModule) SignTimeout ¶
func (s *SafetyModule) SignTimeout(tmoVote *abdrc.TimeoutMsg, lastRoundTC *drctypes.TimeoutCert) error
type State ¶
type State interface { GetCertificate(id types.SystemID) (*types.UnicityCertificate, error) GetCertificates() map[types.SystemID]*types.UnicityCertificate IsChangeInProgress(id types.SystemID) *types.InputRecord }
type VoteRegister ¶
type VoteRegister struct {
// contains filtered or unexported fields
}
func NewVoteRegister ¶
func NewVoteRegister() *VoteRegister
func (*VoteRegister) InsertTimeoutVote ¶
func (v *VoteRegister) InsertTimeoutVote(timeout *abdrc.TimeoutMsg, quorumInfo QuorumInfo) (*drctypes.TimeoutCert, uint32, error)
InsertTimeoutVote returns non nil TC when quorum has been achieved. Second return value is number of signatures in the TC.
func (*VoteRegister) InsertVote ¶
func (v *VoteRegister) InsertVote(vote *abdrc.VoteMsg, quorumInfo QuorumInfo) (*drctypes.QuorumCert, error)
func (*VoteRegister) Reset ¶
func (v *VoteRegister) Reset()