candidate

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: 19 Imported by: 0

README

Candidate Generator Component

This package implements a candidate generator, for the blind-bid protocol of the SBA* consensus protocol.

Abstract

For more information on block generation, please refer to the generation package readme.

Values

Candidate (Block)
Field Type
Version uint8
Height uint64
Timestamp int64
Previous block hash uint256
Block seed BLS Signature
Merkle root []byte (32 bytes)
Certificate Certificate*
Block hash []byte (32 bytes)
Transactions []Transaction* (variable size)

Architecture

The candidate generator exposes its functionality through a single interface method: GenerateCandidateMessage. It should logically follow a call to the score generator to generate a score proposal. This score proposal should also be fed into the candidate generator, which combines it with the candidate block, in order to create a fully-fledged Score message.

The component should be initialized with a public key, to which the potential reward can be attributed. Once called, the block generator goes through these steps:

  • It will generate a committee for the given round and step. This committee contains all the people that can potentially be rewarded, if this block is finalized
  • The generator will ask the mempool for a list of transactions, up to a certain size (determined by the block size cap)
  • A coinbase transaction will be appended to the end of the list, as per the consensus rules
  • A block header is constructed, leaving only the certificate field empty. This certificate is constructed later, in the agreement phase
  • The block is put together, and is then concatenated with the score proposal, to create a `Score message. This message is then returned to the caller

This message is then fully ready to be encoded and gossiped to the network.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GenerateGenesisBlock

func GenerateGenesisBlock(e *consensus.Emitter) (string, error)

GenerateGenesisBlock is a developer utility for regenerating the genesis block as they would be different per network type. Once a genesis block is approved, its hex blob should be copied into config.TestNetGenesisBlob.

Types

type Generator

type Generator interface {
	GenerateCandidateMessage(ctx context.Context, r consensus.RoundUpdate, step uint8) (*message.NewBlock, error)
}

Generator is responsible for generating candidate blocks, and propagating them alongside received Scores. It is triggered by the ScoreEvent, sent by the score generator.

func Mock

func Mock(e *consensus.Emitter) Generator

Mock the candidate generator.

func New

New creates a new block generator.

type Helper

type Helper struct {
	*consensus.Emitter
	ThisSender       []byte
	ProvisionersKeys []key.Keys
	P                *user.Provisioners
	Nr               int
}

Helper for reducing test boilerplate.

func NewHelper

func NewHelper(provisioners int, timeOut time.Duration) *Helper

NewHelper creates a Helper.

func (*Helper) MockRPCCalls

func (hlp *Helper) MockRPCCalls(provisionersKeys []key.Keys)

MockRPCCalls makes sure that the RPCBus methods are registered.

Jump to

Keyboard shortcuts

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