tortoisebeacon

package
v0.2.12-beta-0 Latest Latest
Warning

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

Go to latest
Published: Jan 19, 2022 License: MIT Imports: 27 Imported by: 0

Documentation

Index

Constants

View Source
const TBFirstVotingProtocol = "TBFirstVotingGossip"

TBFirstVotingProtocol is a protocol for sending Tortoise Beacon first voting messages through Gossip.

View Source
const TBFollowingVotingProtocol = "TBFollowingVotingGossip"

TBFollowingVotingProtocol is a protocol for sending Tortoise Beacon following voting messages through Gossip.

View Source
const TBProposalProtocol = "TBProposalGossip"

TBProposalProtocol is a protocol for sending Tortoise Beacon proposal messages through Gossip.

Variables

View Source
var (
	ErrBeaconNotCalculated = errors.New("beacon is not calculated for this epoch")
	ErrZeroEpochWeight     = errors.New("zero epoch weight provided")
	ErrZeroEpoch           = errors.New("zero epoch provided")
)

Tortoise Beacon errors.

Functions

This section is empty.

Types

type Config

type Config struct {
	Kappa                    uint64        `mapstructure:"tortoise-beacon-kappa"`                       // Security parameter (for calculating ATX threshold)
	Q                        *big.Rat      `mapstructure:"tortoise-beacon-q"`                           // Ratio of dishonest spacetime (for calculating ATX threshold). It should be a string representing a rational number.
	RoundsNumber             types.RoundID `mapstructure:"tortoise-beacon-rounds-number"`               // Amount of rounds in every epoch
	GracePeriodDuration      time.Duration `mapstructure:"tortoise-beacon-grace-period-duration"`       // Grace period duration
	ProposalDuration         time.Duration `mapstructure:"tortoise-beacon-proposal-duration"`           // Proposal phase duration
	FirstVotingRoundDuration time.Duration `mapstructure:"tortoise-beacon-first-voting-round-duration"` // First voting round duration
	VotingRoundDuration      time.Duration `mapstructure:"tortoise-beacon-voting-round-duration"`       // Voting round duration
	WeakCoinRoundDuration    time.Duration `mapstructure:"tortoise-beacon-weak-coin-round-duration"`    // Weak coin round duration
	Theta                    *big.Rat      `mapstructure:"tortoise-beacon-theta"`                       // Ratio of votes for reaching consensus
	VotesLimit               uint64        `mapstructure:"tortoise-beacon-votes-limit"`                 // Maximum allowed number of votes to be sent
	BeaconSyncNumBallots     uint32        `mapstructure:"tortoise-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 Tortoise Beacon.

func DefaultConfig

func DefaultConfig() Config

DefaultConfig returns the default configuration for the tortoise beacon.

func NodeSimUnitTestConfig

func NodeSimUnitTestConfig() Config

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

func UnitTestConfig

func UnitTestConfig() Config

UnitTestConfig returns the unit test configuration for the tortoise 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 []uint64
}

FollowingVotingMessageBody is FollowingVotingMessage without a signature.

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 TortoiseBeacon

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

TortoiseBeacon represents Tortoise Beacon.

func New

func New(
	conf Config,
	nodeID types.NodeID,
	publisher pubsub.Publisher,
	atxDB activationDB,
	edSigner signing.Signer,
	edVerifier signing.VerifyExtractor,
	vrfSigner signing.Signer,
	vrfVerifier signing.Verifier,
	weakCoin coin,
	db database.Database,
	clock layerClock,
	logger log.Log,
) *TortoiseBeacon

New returns a new TortoiseBeacon.

func (*TortoiseBeacon) Close

func (tb *TortoiseBeacon) Close()

Close closes TortoiseBeacon.

func (*TortoiseBeacon) GetBeacon

func (tb *TortoiseBeacon) GetBeacon(epochID types.EpochID) (types.Beacon, error)

GetBeacon returns a Tortoise Beacon value as types.Beacon for a certain epoch or an error if it doesn't exist. TODO(nkryuchkov): consider not using (using DB instead).

func (*TortoiseBeacon) HandleSerializedFirstVotingMessage

func (tb *TortoiseBeacon) HandleSerializedFirstVotingMessage(ctx context.Context, pid peer.ID, msg []byte) pubsub.ValidationResult

HandleSerializedFirstVotingMessage defines method to handle Tortoise Beacon first voting Messages from gossip.

func (*TortoiseBeacon) HandleSerializedFollowingVotingMessage

func (tb *TortoiseBeacon) HandleSerializedFollowingVotingMessage(ctx context.Context, pid peer.ID, msg []byte) pubsub.ValidationResult

HandleSerializedFollowingVotingMessage defines method to handle Tortoise Beacon following voting Messages from gossip.

func (*TortoiseBeacon) HandleSerializedProposalMessage

func (tb *TortoiseBeacon) HandleSerializedProposalMessage(ctx context.Context, pid peer.ID, msg []byte) pubsub.ValidationResult

HandleSerializedProposalMessage defines method to handle Tortoise Beacon proposal Messages from gossip.

func (*TortoiseBeacon) ReportBeaconFromBallot

func (tb *TortoiseBeacon) 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 (*TortoiseBeacon) SetSyncState

func (tb *TortoiseBeacon) SetSyncState(sync system.SyncStateProvider)

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

func (*TortoiseBeacon) Start

func (tb *TortoiseBeacon) Start(ctx context.Context) error

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