committee

package
v0.2103.8 Latest Latest
Warning

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

Go to latest
Published: Jan 18, 2022 License: Apache-2.0 Imports: 30 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func TagForCommittee added in v0.2012.0

func TagForCommittee(kind scheduler.CommitteeKind) string

TagForCommittee returns node lookup tag for scheduler committee kind.

Types

type AccessPolicy

type AccessPolicy struct {
	Actions []accessctl.Action
}

AccessPolicy defines a list of actions that are allowed by the policy.

func (AccessPolicy) AddPublicKeyPolicy

func (ap AccessPolicy) AddPublicKeyPolicy(policy *accessctl.Policy, pubKey signature.PublicKey)

AddPublicKeyPolicy augments the given policy by allowing actions in the current AccessPolicy to given TLS public key.

func (AccessPolicy) AddRulesForCommittee

func (ap AccessPolicy) AddRulesForCommittee(policy *accessctl.Policy, committee *CommitteeInfo, nodes nodes.NodeDescriptorLookup)

AddRulesForCommittee augments the given policy by allowing actions in the current AccessPolicy for the nodes in the given committee.

func (AccessPolicy) AddRulesForNodeRoles

func (ap AccessPolicy) AddRulesForNodeRoles(
	policy *accessctl.Policy,
	nodes []*node.Node,
	roles node.RolesMask,
)

AddRulesForNodeRoles augments the given policy by allowing actions in the current AccessPolicy for the nodes that have the given roles mask.

type CommitteeInfo

type CommitteeInfo struct {
	Roles      []scheduler.Role
	Committee  *scheduler.Committee
	PublicKeys map[signature.PublicKey]bool
}

CommitteeInfo contains information about a committee of nodes.

func (*CommitteeInfo) HasRole added in v0.2100.0

func (ci *CommitteeInfo) HasRole(role scheduler.Role) bool

HasRole checks whether the node has the given role.

type EpochSnapshot

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

EpochSnapshot is an immutable snapshot of epoch state.

func (*EpochSnapshot) GetEpochNumber

func (e *EpochSnapshot) GetEpochNumber() beacon.EpochTime

GetEpochNumber returns the sequential number of the epoch.

func (*EpochSnapshot) GetExecutorCommittee added in v0.2010.0

func (e *EpochSnapshot) GetExecutorCommittee() *CommitteeInfo

GetExecutorCommittee returns the current executor committee.

func (*EpochSnapshot) GetGroupVersion

func (e *EpochSnapshot) GetGroupVersion() int64

GetGroupVersion returns the consensus backend block height of the last processed committee election.

func (*EpochSnapshot) GetRuntime

func (e *EpochSnapshot) GetRuntime() *registry.Runtime

GetRuntime returns the current runtime descriptor.

func (*EpochSnapshot) GetStorageCommittee

func (e *EpochSnapshot) GetStorageCommittee() *CommitteeInfo

GetStorageCommittee returns the current storage committee.

func (*EpochSnapshot) IsExecutorBackupWorker

func (e *EpochSnapshot) IsExecutorBackupWorker() bool

IsExecutorBackupWorker checks if the current node is a backup worker of the executor committee in the current epoch.

func (*EpochSnapshot) IsExecutorMember

func (e *EpochSnapshot) IsExecutorMember() bool

IsExecutorMember checks if the current node is a member of the executor committee in the current epoch.

func (*EpochSnapshot) IsExecutorWorker

func (e *EpochSnapshot) IsExecutorWorker() bool

IsExecutorWorker checks if the current node is a worker of the executor committee in the current epoch.

func (*EpochSnapshot) IsTransactionScheduler added in v0.2010.0

func (e *EpochSnapshot) IsTransactionScheduler(round uint64) bool

IsTransactionScheduler checks if the current node is a a transaction scheduler at the specific runtime round.

func (*EpochSnapshot) Node

Node looks up a node descriptor.

Implements commitment.NodeLookup.

func (*EpochSnapshot) Nodes

Nodes returns a node descriptor lookup interface.

func (*EpochSnapshot) VerifyCommitteeSignatures

func (e *EpochSnapshot) VerifyCommitteeSignatures(kind scheduler.CommitteeKind, sigs []signature.Signature) error

VerifyCommitteeSignatures verifies that the given signatures come from the current committee members of the given kind.

Implements commitment.SignatureVerifier.

func (*EpochSnapshot) VerifyTxnSchedulerSigner added in v0.2100.0

func (e *EpochSnapshot) VerifyTxnSchedulerSigner(sig signature.Signature, round uint64) error

VerifyTxnSchedulerSigner verifies that the given signature comes from the transaction scheduler at provided round.

Implements commitment.SignatureVerifier.

type Group

type Group struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

Group encapsulates communication with a group of nodes in the runtime committees.

func NewGroup

func NewGroup(
	ctx context.Context,
	identity *identity.Identity,
	runtime runtimeRegistry.Runtime,
	handler MessageHandler,
	consensus consensus.Backend,
	p2p *p2p.P2P,
) (*Group, error)

NewGroup creates a new group.

func (*Group) AuthenticatePeer

func (g *Group) AuthenticatePeer(peerID signature.PublicKey, msg *p2p.Message) error

AuthenticatePeer handles authenticating a peer that send an incoming message.

func (*Group) EpochTransition

func (g *Group) EpochTransition(ctx context.Context, height int64) error

EpochTransition processes an epoch transition that just happened.

func (*Group) GetEpochSnapshot

func (g *Group) GetEpochSnapshot() *EpochSnapshot

GetEpochSnapshot returns a snapshot of the currently active epoch.

func (*Group) HandlePeerMessage

func (g *Group) HandlePeerMessage(unusedPeerID signature.PublicKey, msg *p2p.Message, isOwn bool) error

HandlePeerMessage handles an incoming message from a peer.

func (*Group) Nodes

func (g *Group) Nodes() nodes.NodeDescriptorLookup

Nodes returns a node descriptor lookup interface that watches all nodes in our committees.

func (*Group) Peers added in v0.2010.0

func (g *Group) Peers() []string

Peers returns a list of connected P2P peers.

func (*Group) Publish added in v0.2010.0

func (g *Group) Publish(msg *p2p.Message) error

Publish publishes a message to the P2P network.

func (*Group) RoundTransition

func (g *Group) RoundTransition()

RoundTransition processes a round transition that just happened.

func (*Group) Start added in v0.2102.4

func (g *Group) Start() error

Start starts the group services.

func (*Group) Storage added in v0.2010.0

func (g *Group) Storage() storage.Backend

Storage returns the storage client backend that talks to the runtime group.

func (*Group) StorageLocal added in v0.2102.7

func (g *Group) StorageLocal() storage.LocalBackend

StorageLocal returns the local storage backend if the local node is also a storage node. Otherwise it returns nil.

func (*Group) Suspend

func (g *Group) Suspend(ctx context.Context)

Suspend processes a runtime suspension that just happened.

Resumption will be processed as a regular epoch transition.

type MessageHandler

type MessageHandler interface {
	// HandlePeerMessage handles a message that has already been authenticated to come from a
	// registered node.
	//
	// The provided context is short-lived so if the handler needs to perform additional work, that
	// should be dispatched to a separate goroutine and not block delivery.
	HandlePeerMessage(ctx context.Context, msg *p2p.Message, isOwn bool) error
}

MessageHandler handles messages from other nodes.

type Node

type Node struct {
	Runtime runtimeRegistry.Runtime

	HostNode control.ControlledNode

	Identity         *identity.Identity
	KeyManager       keymanagerApi.Backend
	KeyManagerClient *keymanagerClient.Client
	Consensus        consensus.Backend
	Group            *Group

	// Mutable and shared between nodes' workers.
	// Guarded by .CrossNode.
	CrossNode             sync.Mutex
	CurrentBlock          *block.Block
	CurrentBlockHeight    int64
	CurrentConsensusBlock *consensus.LightBlock
	Height                int64
	// contains filtered or unexported fields
}

Node is a committee node.

func NewNode

func NewNode(
	hostNode control.ControlledNode,
	runtime runtimeRegistry.Runtime,
	identity *identity.Identity,
	keymanager keymanagerApi.Backend,
	consensus consensus.Backend,
	p2p *p2p.P2P,
) (*Node, error)

func (*Node) AddHooks

func (n *Node) AddHooks(hooks NodeHooks)

AddHooks adds a NodeHooks to be called. There is no going back.

func (*Node) Cleanup

func (n *Node) Cleanup()

Cleanup performs the service specific post-termination cleanup.

func (*Node) GetRuntime

func (n *Node) GetRuntime() runtimeRegistry.Runtime

Implements RuntimeHostHandlerFactory.

func (*Node) GetStatus added in v0.2010.0

func (n *Node) GetStatus(ctx context.Context) (*api.Status, error)

GetStatus returns the common committee node status.

func (*Node) HandlePeerMessage

func (n *Node) HandlePeerMessage(ctx context.Context, message *p2p.Message, isOwn bool) error

HandlePeerMessage forwards a message from the group system to our hooks.

func (*Node) Initialized

func (n *Node) Initialized() <-chan struct{}

Initialized returns a channel that will be closed when the node is initialized and ready to service requests.

func (*Node) Name

func (n *Node) Name() string

Name returns the service name.

func (*Node) NewRuntimeHostHandler

func (n *Node) NewRuntimeHostHandler() protocol.Handler

Implements RuntimeHostHandlerFactory.

func (*Node) NewRuntimeHostNotifier added in v0.2103.0

func (n *Node) NewRuntimeHostNotifier(ctx context.Context, host host.Runtime) protocol.Notifier

Implements RuntimeHostHandlerFactory.

func (*Node) Quit

func (n *Node) Quit() <-chan struct{}

Quit returns a channel that will be closed when the service terminates.

func (*Node) Start

func (n *Node) Start() error

Start starts the service.

func (*Node) Stop

func (n *Node) Stop()

Stop halts the service.

type NodeHooks

type NodeHooks interface {
	HandlePeerMessage(context.Context, *p2p.Message, bool) (bool, error)
	// Guarded by CrossNode.
	HandleEpochTransitionLocked(*EpochSnapshot)
	// Guarded by CrossNode.
	HandleNewBlockEarlyLocked(*block.Block)
	// Guarded by CrossNode.
	HandleNewBlockLocked(*block.Block)
	// Guarded by CrossNode.
	HandleNewEventLocked(*roothash.Event)
	// Guarded by CrossNode.
	HandleNodeUpdateLocked(*nodes.NodeUpdate, *EpochSnapshot)

	// Initialized returns a channel that will be closed when the worker is initialized and ready
	// to service requests.
	Initialized() <-chan struct{}
}

NodeHooks defines a worker's duties at common events. These are called from the runtime's common node's worker.

Jump to

Keyboard shortcuts

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