Documentation
¶
Overview ¶
Package api defines the committee scheduler API.
Index ¶
Constants ¶
const ModuleName = "scheduler"
ModuleName is a unique module name for the scheduler module.
Variables ¶
var BaseUnitsPerVotingPower quantity.Quantity
BaseUnitsPerVotingPower is the ratio of base units staked to validator power.
Functions ¶
func RegisterService ¶
RegisterService registers a new scheduler service with the given gRPC server.
func VotingPowerFromStake ¶
VotingPowerFromStake computes that by dividing by BaseUnitsPerVotingPower.
NOTE: It's not that we're implementation-hiding the conversion though. It's just that otherwise if we accidentally skip the `IsInt64`, it would still appear to work, and that would be a bad thing to have in a routine that's written multiple times.
Types ¶
type Backend ¶
type Backend interface {
// GetValidators returns the vector of consensus validators for
// a given epoch.
GetValidators(ctx context.Context, height int64) ([]*Validator, error)
// GetCommittees returns the vector of committees for a given
// runtime ID, at the specified block height, and optional callback
// for querying the beacon for a given epoch/block height.
//
// Iff the callback is nil, `beacon.GetBlockBeacon` will be used.
GetCommittees(ctx context.Context, request *GetCommitteesRequest) ([]*Committee, error)
// WatchCommittees returns a channel that produces a stream of
// Committee.
//
// Upon subscription, all committees for the current epoch will
// be sent immediately.
WatchCommittees(ctx context.Context) (<-chan *Committee, pubsub.ClosableSubscription, error)
// StateToGenesis returns the genesis state at specified block height.
StateToGenesis(ctx context.Context, height int64) (*Genesis, error)
// Cleanup cleans up the scheduler backend.
Cleanup()
}
Backend is a scheduler implementation.
func NewSchedulerClient ¶
func NewSchedulerClient(c *grpc.ClientConn) Backend
NewSchedulerClient creates a new gRPC scheduler client service.
type Committee ¶
type Committee struct {
// Kind is the functionality a committee exists to provide.
Kind CommitteeKind `json:"kind"`
// Members is the committee members.
Members []*CommitteeNode `json:"members"`
// RuntimeID is the runtime ID that this committee is for.
RuntimeID common.Namespace `json:"runtime_id"`
// ValidFor is the epoch for which the committee is valid.
ValidFor epochtime.EpochTime `json:"valid_for"`
}
Committee is a per-runtime (instance) committee.
func (*Committee) EncodedMembersHash ¶
EncodedMembersHash returns the encoded cryptographic hash of the committee members.
type CommitteeKind ¶
type CommitteeKind uint8
CommitteeKind is the functionality a committee exists to provide.
const ( // KindInvalid is an invalid committee. KindInvalid CommitteeKind = 0 // KindComputeExecutor is an executor committee. KindComputeExecutor CommitteeKind = 1 // KindComputeTxnScheduler is a transaction scheduler committee. KindComputeTxnScheduler CommitteeKind = 2 // KindComputeMerge is a merge committee. KindComputeMerge CommitteeKind = 3 // KindStorage is a storage committee. KindStorage CommitteeKind = 4 // MaxCommitteeKind is a dummy value used for iterating all committee kinds. MaxCommitteeKind = 5 )
func (CommitteeKind) NeedsLeader ¶
func (k CommitteeKind) NeedsLeader() (bool, error)
NeedsLeader returns if committee kind needs leader role.
func (CommitteeKind) String ¶
func (k CommitteeKind) String() string
String returns a string representation of a CommitteeKind.
type CommitteeNode ¶
type CommitteeNode struct {
// Role is the node's role in a committee.
Role Role `json:"role"`
// PublicKey is the node's public key.
PublicKey signature.PublicKey `json:"public_key"`
}
CommitteeNode is a node participating in a committee.
type ConsensusParameters ¶
type ConsensusParameters struct {
// MinValidators is the minimum number of validators that MUST be
// present in elected validator sets.
MinValidators int `json:"min_validators"`
// MaxValidators is the maximum number of validators that MAY be
// present in elected validator sets.
MaxValidators int `json:"max_validators"`
// MaxValidatorsPerEntity is the maximum number of validators that
// may be elected per entity in a single validator set.
MaxValidatorsPerEntity int `json:"max_validators_per_entity"`
// DebugBypassStake is true iff the scheduler should bypass all of
// the staking related checks and operations.
DebugBypassStake bool `json:"debug_bypass_stake"`
// DebugStaticValidators is true iff the scheduler should use
// a static validator set instead of electing anything.
DebugStaticValidators bool `json:"debug_static_validators"`
// RewardFactorEpochElectionAny is the factor for a reward
// distributed per epoch to entities that have any node considered
// in any election.
RewardFactorEpochElectionAny quantity.Quantity `json:"reward_factor_epoch_election_any"`
}
ConsensusParameters are the scheduler consensus parameters.
type Genesis ¶
type Genesis struct {
// Parameters are the scheduler consensus parameters.
Parameters ConsensusParameters `json:"params"`
}
Genesis is the committee scheduler genesis state.
type GetCommitteesRequest ¶
type GetCommitteesRequest struct {
Height int64 `json:"height"`
RuntimeID common.Namespace `json:"runtime_id"`
}
GetCommitteesRequest is a GetCommittees request.
type Role ¶
type Role uint8
Role is the role a given node plays in a committee.
const ( // Invalid is an invalid role (should never appear on the wire). Invalid Role = 0 // Worker indicates the node is a worker. Worker Role = 1 // BackupWorker indicates the node is a backup worker. BackupWorker Role = 2 // Leader indicates the node is a group leader. Leader Role = 3 )
TODO: Rename these to include the Role prefix.