beacon

package
v0.2.14-beta.0 Latest Latest
Warning

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

Go to latest
Published: Mar 23, 2022 License: MIT Imports: 28 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// ProposalProtocol is the protocol for sending proposal messages through Gossip.
	ProposalProtocol = "BeaconProposal"

	// FirstVotesProtocol is the protocol for sending first vote messages through Gossip.
	FirstVotesProtocol = "BeaconFirstVotes"

	// FollowingVotesProtocol is the protocol for sending following vote messages through Gossip.
	FollowingVotesProtocol = "BeaconFollowingVotes"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	Kappa                    uint64        `mapstructure:"beacon-kappa"`                       // Security parameter (for calculating ATX threshold)
	Q                        *big.Rat      `mapstructure:"beacon-q"`                           // Ratio of dishonest spacetime (for calculating ATX threshold). It should be a string representing a rational number.
	RoundsNumber             types.RoundID `mapstructure:"beacon-rounds-number"`               // Amount of rounds in every epoch
	GracePeriodDuration      time.Duration `mapstructure:"beacon-grace-period-duration"`       // Grace period duration
	ProposalDuration         time.Duration `mapstructure:"beacon-proposal-duration"`           // Proposal phase duration
	FirstVotingRoundDuration time.Duration `mapstructure:"beacon-first-voting-round-duration"` // First voting round duration
	VotingRoundDuration      time.Duration `mapstructure:"beacon-voting-round-duration"`       // Voting round duration
	WeakCoinRoundDuration    time.Duration `mapstructure:"beacon-weak-coin-round-duration"`    // Weak coin round duration
	Theta                    *big.Rat      `mapstructure:"beacon-theta"`                       // Ratio of votes for reaching consensus
	VotesLimit               uint32        `mapstructure:"beacon-votes-limit"`                 // Maximum allowed number of votes to be sent
	BeaconSyncNumBallots     uint32        `mapstructure:"beacon-sync-num-blocks"`             // Numbers of layers to wait before determining beacon values from ballots when the node didn't participate in previous epoch.
}

Config is the configuration of the beacon.

func DefaultConfig

func DefaultConfig() Config

DefaultConfig returns the default configuration for the beacon.

func NodeSimUnitTestConfig

func NodeSimUnitTestConfig() Config

NodeSimUnitTestConfig returns configuration for the beacon the unit tests with node simulation .

func UnitTestConfig

func UnitTestConfig() Config

UnitTestConfig returns the unit test configuration for the beacon.

type FirstVotingMessage

type FirstVotingMessage struct {
	FirstVotingMessageBody
	Signature []byte
}

FirstVotingMessage is a message type which is used when sending first voting messages.

func (FirstVotingMessage) String

func (v FirstVotingMessage) String() string

String returns a string form of FirstVotingMessage.

type FirstVotingMessageBody

type FirstVotingMessageBody struct {
	EpochID                   types.EpochID
	ValidProposals            [][]byte
	PotentiallyValidProposals [][]byte
}

FirstVotingMessageBody is FirstVotingMessage without a signature.

type FollowingVotingMessage

type FollowingVotingMessage struct {
	FollowingVotingMessageBody
	Signature []byte
}

FollowingVotingMessage is a message type which is used when sending following voting messages.

func (FollowingVotingMessage) String

func (v FollowingVotingMessage) String() string

String returns a string form of FollowingVotingMessage.

type FollowingVotingMessageBody

type FollowingVotingMessageBody struct {
	EpochID        types.EpochID
	RoundID        types.RoundID
	VotesBitVector []byte
}

FollowingVotingMessageBody is FollowingVotingMessage without a signature.

type Opt

type Opt func(*ProtocolDriver)

Opt for configuring beacon protocol.

func WithConfig

func WithConfig(cfg Config) Opt

WithConfig defines protocol parameters.

func WithContext

func WithContext(ctx context.Context) Opt

WithContext defines context for beacon.

func WithLogger

func WithLogger(logger log.Log) Opt

WithLogger defines logger for beacon.

type ProposalMessage

type ProposalMessage struct {
	EpochID      types.EpochID
	NodeID       types.NodeID
	VRFSignature []byte
}

ProposalMessage is a message type which is used when sending proposals.

func (ProposalMessage) String

func (p ProposalMessage) String() string

String returns a string form of ProposalMessage.

type ProtocolDriver

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

ProtocolDriver is the driver for the beacon protocol.

func New

func New(
	nodeID types.NodeID,
	publisher pubsub.Publisher,
	atxDB activationDB,
	edSigner *signing.EdSigner,
	vrfSigner *signing.VRFSigner,
	db *sql.Database,
	clock layerClock,
	opts ...Opt,
) *ProtocolDriver

New returns a new ProtocolDriver.

func (*ProtocolDriver) Close

func (pd *ProtocolDriver) Close()

Close closes ProtocolDriver.

func (*ProtocolDriver) GetBeacon

func (pd *ProtocolDriver) GetBeacon(targetEpoch types.EpochID) (types.Beacon, error)

GetBeacon returns the beacon for the specified epoch or an error if it doesn't exist.

func (*ProtocolDriver) HandleFirstVotes

func (pd *ProtocolDriver) HandleFirstVotes(ctx context.Context, peer p2p.Peer, msg []byte) pubsub.ValidationResult

HandleFirstVotes handles beacon first votes from gossip.

func (*ProtocolDriver) HandleFollowingVotes

func (pd *ProtocolDriver) HandleFollowingVotes(ctx context.Context, peer p2p.Peer, msg []byte) pubsub.ValidationResult

HandleFollowingVotes handles beacon following votes from gossip.

func (*ProtocolDriver) HandleProposal

func (pd *ProtocolDriver) HandleProposal(ctx context.Context, peer p2p.Peer, msg []byte) pubsub.ValidationResult

HandleProposal handles beacon proposal from gossip.

func (*ProtocolDriver) HandleWeakCoinProposal

func (pd *ProtocolDriver) HandleWeakCoinProposal(ctx context.Context, peer p2p.Peer, msg []byte) pubsub.ValidationResult

HandleWeakCoinProposal handles weakcoin proposal from gossip.

func (*ProtocolDriver) ReportBeaconFromBallot

func (pd *ProtocolDriver) ReportBeaconFromBallot(epoch types.EpochID, bid types.BallotID, beacon types.Beacon, weight uint64)

ReportBeaconFromBallot reports the beacon value in a ballot along with the smesher's weight unit.

func (*ProtocolDriver) SetSyncState

func (pd *ProtocolDriver) SetSyncState(sync system.SyncStateProvider)

SetSyncState updates sync state provider. Must be executed only once.

func (*ProtocolDriver) Start

func (pd *ProtocolDriver) Start(ctx context.Context)

Start starts listening for layers and outputs.

Directories

Path Synopsis
Package mocks is a generated GoMock package.
Package mocks is a generated GoMock package.

Jump to

Keyboard shortcuts

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