abdrc

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Mar 25, 2024 License: AGPL-3.0 Imports: 30 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrDuplicateChangeReq = errors.New("duplicate ir change request")
View Source
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

func (*ConsensusManager) Run

func (x *ConsensusManager) Run(ctx context.Context) error

type ConsensusWithSignatures

type ConsensusWithSignatures struct {
	// contains filtered or unexported fields
}

type IRChangeReqVerifier

type IRChangeReqVerifier struct {
	// contains filtered or unexported fields
}

func (*IRChangeReqVerifier) VerifyIRChangeReq

func (x *IRChangeReqVerifier) VerifyIRChangeReq(round uint64, irChReq *abtypes.IRChangeReq) (*storage.InputData, error)

type IRChangeVerifier

type IRChangeVerifier interface {
	VerifyIRChangeReq(round uint64, irChReq *drctypes.IRChangeReq) (*storage.InputData, error)
}

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 Observability interface {
	Meter(name string, opts ...metric.MeterOption) metric.Meter
	Tracer(name string, options ...trace.TracerOption) trace.Tracer
	Logger() *slog.Logger
}

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

func (x *Pacemaker) AdvanceRoundQC(ctx context.Context, qc *types.QuorumCert) bool

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 (x *Pacemaker) GetCurrentRound() uint64

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

func (x *Pacemaker) GetVoted() *abdrc.VoteMsg

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) SetVoted

func (x *Pacemaker) SetVoted(vote *abdrc.VoteMsg)

SetVoted - remember 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!

func (*Pacemaker) Stop

func (x *Pacemaker) Stop()

type PartitionTimeout

type PartitionTimeout interface {
	GetT2Timeouts(currenRound uint64) ([]types.SystemID, error)
}

type PartitionTimeoutGenerator

type PartitionTimeoutGenerator struct {
	// contains filtered or unexported fields
}

func (*PartitionTimeoutGenerator) GetT2Timeouts

func (x *PartitionTimeoutGenerator) GetT2Timeouts(currentRound uint64) ([]types.SystemID, error)

type QuorumInfo

type QuorumInfo interface {
	GetQuorumThreshold() uint32
	GetMaxFaultyNodes() uint32
}

type RootNet

type RootNet interface {
	Send(ctx context.Context, msg any, receivers ...peer.ID) error
	ReceivedChannel() <-chan any
}

type RootTrustBase

type RootTrustBase struct {
	// contains filtered or unexported fields
}

func NewRootTrustBase

func NewRootTrustBase(keyMap map[string]crypto.Verifier, threshold uint32) (*RootTrustBase, error)

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 (r *RootTrustBase) GetVerifier(nodeID peer.ID) (crypto.Verifier, error)

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 (r *RootTrustBase) VerifyBytes(bytes []byte, sig []byte, author peer.ID) error

func (*RootTrustBase) VerifyQuorumSignatures

func (r *RootTrustBase) VerifyQuorumSignatures(hash []byte, signatures map[string][]byte) error

func (*RootTrustBase) VerifySignature

func (r *RootTrustBase) VerifySignature(hash []byte, sig []byte, author peer.ID) error

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 Signer

type Signer interface {
	Sign(s crypto.Signer) 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()

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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