tortoisebeacon

package
v0.2.2-beta.1 Latest Latest
Warning

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

Go to latest
Published: Sep 23, 2021 License: MIT Imports: 23 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 (
	// ErrMalformedProposal is returned if proposal message is malformed.
	ErrMalformedProposal = errors.New("malformed proposal message")

	// ErrProposalDoesntPassThreshold is returned if proposal message doesn't pass threshold.
	ErrProposalDoesntPassThreshold = errors.New("proposal doesn't pass threshold")
	// ErrMalformedSignature is returned when signature is malformed.
	ErrMalformedSignature = errors.New("malformed signature")

	// ErrAlreadyProposed is returned when miner doubly proposed for the same epoch.
	ErrAlreadyProposed = errors.New("already proposed")
	// ErrAlreadyVoted is returned when miner doubly voted for the same epoch/round.
	ErrAlreadyVoted = errors.New("already voted")
)
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
	WaitAfterEpochStart      time.Duration `mapstructure:"tortoise-beacon-wait-after-epoch-start"`      // How long to wait after a new epoch is started.
	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
}

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 DB

type DB struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

DB holds beacons for epochs.

func NewDB

func NewDB(dbStore database.Database, log log.Log) *DB

NewDB creates a Tortoise Beacon DB.

func (*DB) GetTortoiseBeacon

func (db *DB) GetTortoiseBeacon(epochID types.EpochID) (types.Hash32, error)

GetTortoiseBeacon gets a Tortoise Beacon value for an epoch.

func (*DB) SetTortoiseBeacon

func (db *DB) SetTortoiseBeacon(epochID types.EpochID, beacon types.Hash32) error

SetTortoiseBeacon sets a Tortoise Beacon value for an epoch.

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 SyncState

type SyncState interface {
	IsSynced(context.Context) bool
}

SyncState interface to check the state the sync.

type TortoiseBeacon

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

TortoiseBeacon represents Tortoise Beacon.

func New

func New(
	conf Config,
	nodeID types.NodeID,
	net broadcaster,
	atxDB activationDB,
	tortoiseBeaconDB tortoiseBeaconDB,
	edSigner signing.Signer,
	edVerifier signing.VerifyExtractor,
	vrfSigner signing.Signer,
	vrfVerifier signing.Verifier,
	weakCoin coin,
	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) ([]byte, error)

GetBeacon returns a Tortoise Beacon value as []byte 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, data service.GossipMessage, _ service.Fetcher)

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

func (*TortoiseBeacon) HandleSerializedFollowingVotingMessage

func (tb *TortoiseBeacon) HandleSerializedFollowingVotingMessage(ctx context.Context, data service.GossipMessage, _ service.Fetcher)

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

func (*TortoiseBeacon) HandleSerializedProposalMessage

func (tb *TortoiseBeacon) HandleSerializedProposalMessage(ctx context.Context, data service.GossipMessage, _ service.Fetcher)

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

func (*TortoiseBeacon) IsClosed

func (tb *TortoiseBeacon) IsClosed() bool

IsClosed returns true if background workers are not running.

func (*TortoiseBeacon) SetSyncState

func (tb *TortoiseBeacon) SetSyncState(sync SyncState)

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.
mocks
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