beacon

package
v0.2.19-beta.0 Latest Latest
Warning

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

Go to latest
Published: Nov 28, 2022 License: MIT Imports: 31 Imported by: 0

Documentation

Overview

nolint

nolint

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BuildProposalMessage

type BuildProposalMessage struct {
	Prefix string
	Epoch  uint32
}

BuildProposalMessage is a message for buildProposal below.

func (*BuildProposalMessage) DecodeScale

func (t *BuildProposalMessage) DecodeScale(dec *scale.Decoder) (total int, err error)

func (*BuildProposalMessage) EncodeScale

func (t *BuildProposalMessage) EncodeScale(enc *scale.Encoder) (total int, err error)

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) DecodeScale

func (t *FirstVotingMessage) DecodeScale(dec *scale.Decoder) (total int, err error)

func (*FirstVotingMessage) EncodeScale

func (t *FirstVotingMessage) EncodeScale(enc *scale.Encoder) (total int, err error)

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.

func (*FirstVotingMessageBody) DecodeScale

func (t *FirstVotingMessageBody) DecodeScale(dec *scale.Decoder) (total int, err error)

func (*FirstVotingMessageBody) EncodeScale

func (t *FirstVotingMessageBody) EncodeScale(enc *scale.Encoder) (total int, err error)

type FollowingVotingMessage

type FollowingVotingMessage struct {
	FollowingVotingMessageBody
	Signature []byte
}

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

func (*FollowingVotingMessage) DecodeScale

func (t *FollowingVotingMessage) DecodeScale(dec *scale.Decoder) (total int, err error)

func (*FollowingVotingMessage) EncodeScale

func (t *FollowingVotingMessage) EncodeScale(enc *scale.Encoder) (total int, err error)

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.

func (*FollowingVotingMessageBody) DecodeScale

func (t *FollowingVotingMessageBody) DecodeScale(dec *scale.Decoder) (total int, err error)

func (*FollowingVotingMessageBody) EncodeScale

func (t *FollowingVotingMessageBody) EncodeScale(enc *scale.Encoder) (total int, err error)

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) DecodeScale

func (t *ProposalMessage) DecodeScale(dec *scale.Decoder) (total int, err error)

func (*ProposalMessage) EncodeScale

func (t *ProposalMessage) EncodeScale(enc *scale.Encoder) (total int, err error)

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,
	edSigner *signing.EdSigner,
	vrfSigner *signing.VRFSigner,
	cdb *datastore.CachedDB,
	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