selection

package
v0.6.1 Latest Latest
Warning

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

Go to latest
Published: Dec 21, 2022 License: MIT Imports: 24 Imported by: 0

README

Selection Component

The Selector is the component appointed to collect the scores, verify the zero-knowledge proof thereto associated and to propagate the block hash associated with the highest score observed during a period of time denoted as timeLength. The block hash is then forwarded to the EventBus to be picked up by the Block Reducer

An abstract description of the Selection phase in the SBA* consensus protocol can be found here.

Values

Score Message
Field Type
score uint256
proof proof
identity hash uint256
seed BLS signature
previous block hash uint256
candidate block block.Block

Architecture

The Selection component is implemented through the Phase struct. Internally, it carries a BlockGenerator in order to fully synchronize the creation of a candidate block and score, with the Selection phase. When the Selection component is called, the first thing it does is this block generation routine. Once finished (or if no block generator was actually initialized), queued events are flushed in order to catch up with any delays, and a listening loop is started. The selection component will listen on four channels:

  • The internalScoreResult chan, on which it can receive a Score message from its own block generator - this message is then forwarded into the standard processing pipeline
  • The evChan, which catches events coming from the network
  • The timeOutChan, responsible for telling the Selection component when the time for the selection phase has ran out, and the component needs to wrap up its activites
  • The ctx.Done chan, which notifies the Selection component of context cancellations, and allows for swift cleanup of the hanging goroutine

When an event comes through over the evChan, the following processing pipeline is followed:

  1. Check if the event score is higher than the current bestEvent. If not, the flow ends here.
  2. Verify the proof, included in the Score event. If the verification fails, the flow ends here.
  3. The Score event is repropagated to the network.
  4. The bestEvent field on the Selection component will now be set to the new Score event.

The purpose of this processing flow is to have the Score message with the highest score in memory when the timer expires. Once this timer expires, the message is returned and can be used to vote in the reduction step.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ProvisionerNr = 10

ProvisionerNr is the default amount of Provisioners utilized in the selection tests. This nr is just used to create the RoundUpdate and bares no importance in the selection step.

Functions

This section is empty.

Types

type Handler added in v0.2.0

type Handler struct {
	*committee.Handler
}

Handler is responsible for performing operations that need to know about specific event fields.

func NewHandler added in v0.4.4

func NewHandler(keys key.Keys, p user.Provisioners, seed []byte) *Handler

NewHandler will return a Handler, injected with the passed committee and an unmarshaller which uses the injected validation function.

func (*Handler) AmMember added in v0.4.4

func (b *Handler) AmMember(round uint64, step uint8) bool

AmMember checks if we are part of the committee.

func (*Handler) Committee added in v0.4.4

func (b *Handler) Committee(round uint64, step uint8) user.VotingCommittee

Committee returns a VotingCommittee for a given round and step.

func (*Handler) IsMember added in v0.4.4

func (b *Handler) IsMember(pubKeyBLS []byte, round uint64, step uint8) bool

IsMember delegates the committee.Handler to check if a BLS public key belongs to a committee for the specified round and step.

func (*Handler) VerifySignature added in v0.4.4

func (b *Handler) VerifySignature(scr message.NewBlock) error

VerifySignature verifies the BLS signature of the NewBlock event. Since the payload is nil, verifying the signature equates to verifying solely the Header.

type Helper added in v0.2.0

type Helper struct {
	*consensus.Emitter
	Round uint64
	Step  uint8

	P *user.Provisioners
	// contains filtered or unexported fields
}

Helper for reducing selection test boilerplate.

func NewHelper added in v0.2.0

func NewHelper(scoreToSpawn int) *Helper

NewHelper creates a Helper.

func (*Helper) RoundUpdate added in v0.4.0

func (h *Helper) RoundUpdate() consensus.RoundUpdate

RoundUpdate mocks a round update with the Round and Step embedded in the Helper.

func (*Helper) Spawn added in v0.2.0

func (h *Helper) Spawn() []message.NewBlock

Spawn a number of score events.

type Phase added in v0.4.0

type Phase struct {
	*consensus.Emitter
	// contains filtered or unexported fields
}

Phase is the implementation of the Selection step component.

func New added in v0.4.0

New creates and launches the component which responsibility is to validate and select a Provisioner to propagate NewBlock message.

func (*Phase) Initialize added in v0.4.0

func (p *Phase) Initialize(_ consensus.InternalPacket) consensus.PhaseFn

Initialize returns the Phase state function for the next phase, and initializes it with the result from this phase.

func (*Phase) Run added in v0.4.0

func (p *Phase) Run(parentCtx context.Context, queue *consensus.Queue, newBlockChan, _ chan message.Message, r consensus.RoundUpdate, step uint8) consensus.PhaseFn

Run executes the logic for this phase. In this case the selection listens to NewBlock messages.

func (*Phase) String added in v0.4.0

func (p *Phase) String() string

String as required by the interface PhaseFn.

Jump to

Keyboard shortcuts

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