Documentation
¶
Index ¶
- Constants
- type Config
- type FirstVotingMessage
- type FirstVotingMessageBody
- type FollowingVotingMessage
- type FollowingVotingMessageBody
- type Opt
- type ProposalMessage
- type ProtocolDriver
- func (pd *ProtocolDriver) Close()
- func (pd *ProtocolDriver) GetBeacon(targetEpoch types.EpochID) (types.Beacon, error)
- func (pd *ProtocolDriver) HandleFirstVotes(ctx context.Context, peer p2p.Peer, msg []byte) pubsub.ValidationResult
- func (pd *ProtocolDriver) HandleFollowingVotes(ctx context.Context, peer p2p.Peer, msg []byte) pubsub.ValidationResult
- func (pd *ProtocolDriver) HandleProposal(ctx context.Context, peer p2p.Peer, msg []byte) pubsub.ValidationResult
- func (pd *ProtocolDriver) HandleWeakCoinProposal(ctx context.Context, peer p2p.Peer, msg []byte) pubsub.ValidationResult
- func (pd *ProtocolDriver) ReportBeaconFromBallot(epoch types.EpochID, bid types.BallotID, beacon types.Beacon, weight uint64)
- func (pd *ProtocolDriver) SetSyncState(sync system.SyncStateProvider)
- func (pd *ProtocolDriver) Start(ctx context.Context)
Constants ¶
const ( // ProposalProtocol is the protocol for sending proposal messages through Gossip. ProposalProtocol = "BeaconProposal/1" // FirstVotesProtocol is the protocol for sending first vote messages through Gossip. FirstVotesProtocol = "BeaconFirstVotes/1" // FollowingVotesProtocol is the protocol for sending following vote messages through Gossip. FollowingVotesProtocol = "BeaconFollowingVotes/1" )
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 WithContext ¶
WithContext defines context for beacon.
type ProposalMessage ¶
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) GetBeacon ¶
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.