Documentation ¶
Overview ¶
nolint
nolint
Index ¶
- type BuildProposalMessage
- 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 ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BuildProposalMessage ¶
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 int `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 WithContext ¶
WithContext defines context for beacon.
type ProposalMessage ¶
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) 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.