Documentation
¶
Index ¶
- Constants
- Variables
- type CertReqReason
- type ConsensusManager
- func (x *ConsensusManager) CertificationResult() <-chan *certification.CertificationResponse
- func (x *ConsensusManager) GetState() (*abdrc.StateMsg, error)
- func (x *ConsensusManager) RequestCertification(ctx context.Context, cr IRChangeRequest) error
- func (x *ConsensusManager) Run(ctx context.Context) error
- func (x *ConsensusManager) ShardInfo(partition types.PartitionID, shard types.ShardID) (*storage.ShardInfo, error)
- type ConsensusWithSignatures
- type IRChangeReqVerifier
- type IRChangeRequest
- type IRChangeVerifier
- type InProgressFn
- type IrReqBuffer
- func (x *IrReqBuffer) Add(round uint64, irChReq *drctypes.IRChangeReq, ver IRChangeVerifier) error
- func (x *IrReqBuffer) GeneratePayload(round uint64, timeouts []*types.UnicityCertificate, inProgress InProgressFn) *drctypes.Payload
- func (x *IrReqBuffer) IsChangeInBuffer(partitionID types.PartitionID, shardID types.ShardID) bool
- type Leader
- type Observability
- type Option
- type Optional
- type Orchestration
- 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 Parameters
- type PartitionTimeout
- type PartitionTimeoutGenerator
- type QuorumInfo
- type RootNet
- 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 ¶
const ( BlockRate = 900 LocalTimeout = 10000 HashAlgorithm = gocrypto.SHA256 )
Variables ¶
var ErrDuplicateChangeReq = errors.New("duplicate ir change request")
var ErrVoteIsNil = errors.New("vote is nil")
Functions ¶
This section is empty.
Types ¶
type CertReqReason ¶
type CertReqReason uint8
const ( Quorum CertReqReason = iota QuorumNotPossible )
type ConsensusManager ¶ added in v1.0.0
type ConsensusManager struct {
// contains filtered or unexported fields
}
func NewConsensusManager ¶ added in v1.0.0
func NewConsensusManager( nodeID peer.ID, trustBase types.RootTrustBase, orchestration Orchestration, net RootNet, signer abcrypto.Signer, observe Observability, opts ...Option, ) (*ConsensusManager, error)
NewConsensusManager creates new "Atomic Broadcast" protocol based distributed consensus manager
func (*ConsensusManager) CertificationResult ¶ added in v1.0.0
func (x *ConsensusManager) CertificationResult() <-chan *certification.CertificationResponse
func (*ConsensusManager) GetState ¶ added in v1.0.0
func (x *ConsensusManager) GetState() (*abdrc.StateMsg, error)
func (*ConsensusManager) RequestCertification ¶ added in v1.0.0
func (x *ConsensusManager) RequestCertification(ctx context.Context, cr IRChangeRequest) error
func (*ConsensusManager) Run ¶ added in v1.0.0
func (x *ConsensusManager) Run(ctx context.Context) error
func (*ConsensusManager) ShardInfo ¶ added in v1.0.0
func (x *ConsensusManager) ShardInfo(partition types.PartitionID, shard types.ShardID) (*storage.ShardInfo, error)
type ConsensusWithSignatures ¶ added in v1.0.0
type ConsensusWithSignatures struct {
// contains filtered or unexported fields
}
type IRChangeReqVerifier ¶ added in v1.0.0
type IRChangeReqVerifier struct {
// contains filtered or unexported fields
}
func NewIRChangeReqVerifier ¶ added in v1.0.0
func NewIRChangeReqVerifier(c *Parameters, sMonitor State) (*IRChangeReqVerifier, error)
func (*IRChangeReqVerifier) VerifyIRChangeReq ¶ added in v1.0.0
func (x *IRChangeReqVerifier) VerifyIRChangeReq(rootRound uint64, irChReq *drctypes.IRChangeReq) (*types.InputRecord, error)
type IRChangeRequest ¶
type IRChangeRequest struct {
Partition types.PartitionID
Shard types.ShardID
Reason CertReqReason
Requests []*certification.BlockCertificationRequest
}
type IRChangeVerifier ¶ added in v1.0.0
type IRChangeVerifier interface {
VerifyIRChangeReq(round uint64, irChReq *drctypes.IRChangeReq) (*types.InputRecord, error)
}
type InProgressFn ¶ added in v1.0.0
type InProgressFn func(partition types.PartitionID, shard types.ShardID) *types.InputRecord
type IrReqBuffer ¶ added in v1.0.0
type IrReqBuffer struct {
// contains filtered or unexported fields
}
func NewIrReqBuffer ¶ added in v1.0.0
func NewIrReqBuffer(log *slog.Logger) *IrReqBuffer
func (*IrReqBuffer) Add ¶ added in v1.0.0
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 ¶ added in v1.0.0
func (x *IrReqBuffer) GeneratePayload(round uint64, timeouts []*types.UnicityCertificate, inProgress InProgressFn) *drctypes.Payload
GeneratePayload generates new proposal payload from buffered IR change requests.
func (*IrReqBuffer) IsChangeInBuffer ¶ added in v1.0.0
func (x *IrReqBuffer) IsChangeInBuffer(partitionID types.PartitionID, shardID types.ShardID) bool
IsChangeInBuffer returns true if there is a request for IR change from the partition in the buffer
type Leader ¶ added in v1.0.0
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 ¶ added in v1.0.0
type Option ¶
type Option func(c *Optional)
func WithConsensusParams ¶ added in v1.0.0
func WithConsensusParams(params Parameters) Option
func WithStorage ¶
func WithStorage(db keyvaluedb.KeyValueDB) Option
type Optional ¶
type Optional struct {
Storage keyvaluedb.KeyValueDB
Params *Parameters
}
Optional are common optional parameters for consensus managers
type Orchestration ¶ added in v1.0.0
type Orchestration interface {
NetworkID() types.NetworkID
ShardConfig(partitionID types.PartitionID, shardID types.ShardID, rootRound uint64) (*types.PartitionDescriptionRecord, error)
ShardConfigs(rootRound uint64) (map[types.PartitionShardID]*types.PartitionDescriptionRecord, error)
}
type Pacemaker ¶ added in v1.0.0
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 ¶ added in v1.0.0
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 ¶ added in v1.0.0
AdvanceRoundQC - trigger next round/view on quorum certificate
func (*Pacemaker) AdvanceRoundTC ¶ added in v1.0.0
func (x *Pacemaker) AdvanceRoundTC(ctx context.Context, tc *types.TimeoutCert)
AdvanceRoundTC - trigger next round/view on timeout certificate
func (*Pacemaker) GetCurrentRound ¶ added in v1.0.0
func (*Pacemaker) GetTimeoutVote ¶ added in v1.0.0
func (x *Pacemaker) GetTimeoutVote() *abdrc.TimeoutMsg
GetTimeoutVote - has the node voted for timeout in this round, returns either vote or nil
func (*Pacemaker) GetVoted ¶ added in v1.0.0
GetVoted - has the node voted in this round, returns either vote or nil
func (*Pacemaker) LastRoundTC ¶ added in v1.0.0
func (x *Pacemaker) LastRoundTC() *types.TimeoutCert
func (*Pacemaker) RegisterTimeoutVote ¶ added in v1.0.0
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 ¶ added in v1.0.0
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 ¶ added in v1.0.0
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 ¶ added in v1.0.0
func (x *Pacemaker) RoundQC() *types.QuorumCert
RoundQC returns the latest QC produced by calling RegisterVote.
func (*Pacemaker) SetTimeoutVote ¶ added in v1.0.0
func (x *Pacemaker) SetTimeoutVote(vote *abdrc.TimeoutMsg)
SetTimeoutVote - remember timeout vote sent in this view
func (*Pacemaker) StatusEvents ¶ added in v1.0.0
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 Parameters ¶
type Parameters struct {
BlockRate time.Duration // also known as T3
LocalTimeout time.Duration
ConsensusThreshold uint32
HashAlgorithm gocrypto.Hash
}
Parameters are basic consensus parameters that need to be the same in all root validators. Extracted from root genesis where all validators in the root cluster must have signed them to signal agreement
func NewConsensusParams ¶
func NewConsensusParams() *Parameters
type PartitionTimeout ¶ added in v1.0.0
type PartitionTimeout interface {
GetT2Timeouts(currenRound uint64) ([]types.PartitionID, error)
}
type PartitionTimeoutGenerator ¶ added in v1.0.0
type PartitionTimeoutGenerator struct {
// contains filtered or unexported fields
}
func NewLucBasedT2TimeoutGenerator ¶ added in v1.0.0
func NewLucBasedT2TimeoutGenerator(c *Parameters, sMonitor State) (*PartitionTimeoutGenerator, error)
func (*PartitionTimeoutGenerator) GetT2Timeouts ¶ added in v1.0.0
func (x *PartitionTimeoutGenerator) GetT2Timeouts(currentRound uint64) ([]*types.UnicityCertificate, error)
type QuorumInfo ¶ added in v1.0.0
type SafetyModule ¶ added in v1.0.0
type SafetyModule struct {
// contains filtered or unexported fields
}
func NewSafetyModule ¶ added in v1.0.0
func NewSafetyModule(network types.NetworkID, id string, signer crypto.Signer, db keyvaluedb.KeyValueDB) (*SafetyModule, error)
func (*SafetyModule) GetHighestQcRound ¶ added in v1.0.0
func (s *SafetyModule) GetHighestQcRound() uint64
func (*SafetyModule) GetHighestVotedRound ¶ added in v1.0.0
func (s *SafetyModule) GetHighestVotedRound() uint64
func (*SafetyModule) MakeVote ¶ added in v1.0.0
func (s *SafetyModule) MakeVote(block *drctypes.BlockData, execStateID []byte, highQC *drctypes.QuorumCert, lastRoundTC *drctypes.TimeoutCert) (*abdrc.VoteMsg, error)
func (*SafetyModule) SetHighestQcRound ¶ added in v1.0.0
func (s *SafetyModule) SetHighestQcRound(highestQcRound uint64)
func (*SafetyModule) SetHighestVotedRound ¶ added in v1.0.0
func (s *SafetyModule) SetHighestVotedRound(highestVotedRound uint64)
func (*SafetyModule) Sign ¶ added in v1.0.0
func (s *SafetyModule) Sign(msg Signer) error
func (*SafetyModule) SignTimeout ¶ added in v1.0.0
func (s *SafetyModule) SignTimeout(tmoVote *abdrc.TimeoutMsg, lastRoundTC *drctypes.TimeoutCert) error
type State ¶ added in v1.0.0
type State interface {
ShardInfo(partition types.PartitionID, shard types.ShardID) *storage.ShardInfo
GetCertificates() []*types.UnicityCertificate
IsChangeInProgress(id types.PartitionID, shard types.ShardID) *types.InputRecord
}
type VoteRegister ¶ added in v1.0.0
type VoteRegister struct {
// contains filtered or unexported fields
}
func NewVoteRegister ¶ added in v1.0.0
func NewVoteRegister() *VoteRegister
func (*VoteRegister) InsertTimeoutVote ¶ added in v1.0.0
func (v *VoteRegister) InsertTimeoutVote(timeout *abdrc.TimeoutMsg, quorumInfo QuorumInfo) (*drctypes.TimeoutCert, uint64, error)
InsertTimeoutVote returns non nil TC when quorum has been achieved. Second return value is number of signatures in the TC.
func (*VoteRegister) InsertVote ¶ added in v1.0.0
func (v *VoteRegister) InsertVote(vote *abdrc.VoteMsg, quorumInfo QuorumInfo) (*drctypes.QuorumCert, error)
func (*VoteRegister) Reset ¶ added in v1.0.0
func (v *VoteRegister) Reset()