quorum

package
v0.1.25 Latest Latest
Warning

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

Go to latest
Published: Sep 13, 2022 License: LGPL-3.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Decider

type Decider interface {
	fmt.Stringer
	SignatureReader
	DependencyInjectionWriter
	SetVoters(subCommittee *shard.Committee, epoch *big.Int) (*TallyResult, error)
	Policy() Policy
	AddNewVote(
		p Phase, pubkeys []*bls_cosi.PublicKeyWrapper,
		sig *bls_core.Sign, headerHash common.Hash,
		height, viewID uint64,
	) (*votepower.Ballot, error)
	IsQuorumAchieved(Phase) bool
	IsQuorumAchievedByMask(mask *bls_cosi.Mask) bool
	QuorumThreshold() numeric.Dec
	AmIMemberOfCommitee() bool
	IsAllSigsCollected() bool
	ResetPrepareAndCommitVotes()
	ResetViewChangeVotes()
	CurrentTotalPower(p Phase) (*numeric.Dec, error)
}

Decider ..

func NewDecider

func NewDecider(p Policy, shardID uint32) Decider

NewDecider ..

type DependencyInjectionReader

type DependencyInjectionReader interface {
	MyPublicKey() func() (multibls.PublicKeys, error)
}

DependencyInjectionReader ..

type DependencyInjectionWriter

type DependencyInjectionWriter interface {
	SetMyPublicKeyProvider(func() (multibls.PublicKeys, error))
}

DependencyInjectionWriter ..

type ParticipantTracker

type ParticipantTracker interface {
	Participants() multibls.PublicKeys
	IndexOf(bls.SerializedPublicKey) int
	ParticipantsCount() int64
	NthNext(*bls.PublicKeyWrapper, int) (bool, *bls.PublicKeyWrapper)
	NthNextHmy(shardingconfig.Instance, *bls.PublicKeyWrapper, int) (bool, *bls.PublicKeyWrapper)
	NthNextHmyExt(shardingconfig.Instance, *bls.PublicKeyWrapper, int) (bool, *bls.PublicKeyWrapper)
	FirstParticipant(shardingconfig.Instance) *bls.PublicKeyWrapper
	UpdateParticipants(pubKeys, allowlist []bls.PublicKeyWrapper)
}

ParticipantTracker ..

type Phase

type Phase byte

Phase is a phase that needs quorum to proceed

const (
	// Prepare ..
	Prepare Phase = iota
	// Commit ..
	Commit
	// ViewChange ..
	ViewChange
)

func (Phase) String

func (p Phase) String() string

type Policy

type Policy byte

Policy is the rule we used to decide is quorum achieved

const (
	// SuperMajorityVote is a 2/3s voting mechanism, pre-PoS
	SuperMajorityVote Policy = iota
	// SuperMajorityStake is 2/3s of total staked amount for epoch
	SuperMajorityStake
)

func (Policy) String

func (p Policy) String() string

type Registry

type Registry struct {
	Deciders      map[string]Decider `json:"quorum-deciders"`
	ExternalCount int                `json:"external-slot-count"`
	MedianStake   numeric.Dec        `json:"epos-median-stake"`
	Epoch         int                `json:"epoch"`
}

Registry ..

func NewRegistry

func NewRegistry(extern int, epoch int) Registry

NewRegistry ..

type SignatoryTracker

type SignatoryTracker interface {
	ParticipantTracker

	// Caller assumes concurrency protection
	SignersCount(Phase) int64
	// contains filtered or unexported methods
}

SignatoryTracker ..

type SignatureReader

type SignatureReader interface {
	SignatoryTracker
	ReadAllBallots(Phase) []*votepower.Ballot
	ReadBallot(p Phase, pubkey bls.SerializedPublicKey) *votepower.Ballot
	TwoThirdsSignersCount() int64
	// 96 bytes aggregated signature
	AggregateVotes(p Phase) *bls_core.Sign
}

SignatureReader ..

type TallyResult

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

TallyResult is the result of when we calculate voting power, recall that it happens to us at epoch change

type Transition

type Transition struct {
	Previous Registry `json:"previous"`
	Current  Registry `json:"current"`
}

Transition ..

type Verifier

type Verifier interface {
	IsQuorumAchievedByMask(mask *bls_cosi.Mask) bool
}

Verifier is the interface to verify the whether the quorum is achieved by mask at each epoch. TODO: Add some unit tests to make sure Verifier get exactly the same result as Decider

func NewVerifier

func NewVerifier(committee *shard.Committee, epoch *big.Int, isStaking bool) (Verifier, error)

NewVerifier creates the quorum verifier for the given committee, epoch and whether the scenario is staking.

type VoteTally

type VoteTally struct {
	Prepare    *tallyAndQuorum
	Commit     *tallyAndQuorum
	ViewChange *tallyAndQuorum
}

VoteTally is the vote tally for each phase

Jump to

Keyboard shortcuts

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