beacon

package
v1.4.0-alpha.0 Latest Latest
Warning

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

Go to latest
Published: Feb 2, 2024 License: MIT Imports: 34 Imported by: 0

Documentation

Overview

nolint

Code generated by MockGen. DO NOT EDIT. Source: ./interface.go

Generated by this command:

mockgen -typed -package=beacon -destination=./mocks.go -source=./interface.go

Package beacon is a generated GoMock package.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	// Security parameter (for calculating ATX threshold)
	Kappa int `mapstructure:"beacon-kappa"`
	// Ratio of dishonest spacetime (for calculating ATX threshold). It should be a string representing a rational number.
	Q big.Rat `mapstructure:"beacon-q"`
	// Amount of rounds in every epoch
	RoundsNumber types.RoundID `mapstructure:"beacon-rounds-number"`
	// Grace period duration
	GracePeriodDuration time.Duration `mapstructure:"beacon-grace-period-duration"`
	// Proposal phase duration
	ProposalDuration time.Duration `mapstructure:"beacon-proposal-duration"`
	// First voting round duration
	FirstVotingRoundDuration time.Duration `mapstructure:"beacon-first-voting-round-duration"`
	// Voting round duration
	VotingRoundDuration time.Duration `mapstructure:"beacon-voting-round-duration"`
	// Weak coin round duration
	WeakCoinRoundDuration time.Duration `mapstructure:"beacon-weak-coin-round-duration"`
	// Ratio of votes for reaching consensus
	Theta big.Rat `mapstructure:"beacon-theta"`
	// Maximum allowed number of votes to be sent
	VotesLimit uint32 `mapstructure:"beacon-votes-limit"`
	// Numbers of layers to wait before determining beacon values from ballots when the node didn't participate
	// in previous epoch.
	BeaconSyncWeightUnits int `mapstructure:"beacon-sync-weight-units"`
}

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

	SmesherID types.NodeID
	Signature types.EdSignature
}

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)

type FirstVotingMessageBody

type FirstVotingMessageBody struct {
	EpochID types.EpochID
	// number of proposals is expected to be under 100, 1000 is a safe upper bound
	ValidProposals []Proposal `scale:"max=1000"`
	// number of proposals is expected to be under 100, 1000 is a safe upper bound
	PotentiallyValidProposals []Proposal `scale:"max=1000"`
}

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

	SmesherID types.NodeID
	Signature types.EdSignature
}

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)

type FollowingVotingMessageBody

type FollowingVotingMessageBody struct {
	EpochID        types.EpochID
	RoundID        types.RoundID
	VotesBitVector []byte `scale:"max=128"` // 128 bytes = 1024 bits and we limit the number of proposals to 1000
}

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 Mockcoin

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

Mockcoin is a mock of coin interface.

func NewMockcoin

func NewMockcoin(ctrl *gomock.Controller) *Mockcoin

NewMockcoin creates a new mock instance.

func (*Mockcoin) EXPECT

func (m *Mockcoin) EXPECT() *MockcoinMockRecorder

EXPECT returns an object that allows the caller to indicate expected use.

func (*Mockcoin) FinishEpoch

func (m *Mockcoin) FinishEpoch(arg0 context.Context, arg1 types.EpochID)

FinishEpoch mocks base method.

func (*Mockcoin) FinishRound

func (m *Mockcoin) FinishRound(arg0 context.Context)

FinishRound mocks base method.

func (*Mockcoin) Get

func (m *Mockcoin) Get(arg0 context.Context, arg1 types.EpochID, arg2 types.RoundID) (bool, error)

Get mocks base method.

func (*Mockcoin) HandleProposal

func (m *Mockcoin) HandleProposal(arg0 context.Context, arg1 p2p.Peer, arg2 []byte) error

HandleProposal mocks base method.

func (*Mockcoin) StartEpoch

func (m *Mockcoin) StartEpoch(arg0 context.Context, arg1 types.EpochID)

StartEpoch mocks base method.

func (*Mockcoin) StartRound

func (m *Mockcoin) StartRound(arg0 context.Context, arg1 types.RoundID, arg2 []weakcoin.Participant)

StartRound mocks base method.

type MockcoinMockRecorder

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

MockcoinMockRecorder is the mock recorder for Mockcoin.

func (*MockcoinMockRecorder) FinishEpoch

func (mr *MockcoinMockRecorder) FinishEpoch(arg0, arg1 any) *coinFinishEpochCall

FinishEpoch indicates an expected call of FinishEpoch.

func (*MockcoinMockRecorder) FinishRound

func (mr *MockcoinMockRecorder) FinishRound(arg0 any) *coinFinishRoundCall

FinishRound indicates an expected call of FinishRound.

func (*MockcoinMockRecorder) Get

func (mr *MockcoinMockRecorder) Get(arg0, arg1, arg2 any) *coinGetCall

Get indicates an expected call of Get.

func (*MockcoinMockRecorder) HandleProposal

func (mr *MockcoinMockRecorder) HandleProposal(arg0, arg1, arg2 any) *coinHandleProposalCall

HandleProposal indicates an expected call of HandleProposal.

func (*MockcoinMockRecorder) StartEpoch

func (mr *MockcoinMockRecorder) StartEpoch(arg0, arg1 any) *coinStartEpochCall

StartEpoch indicates an expected call of StartEpoch.

func (*MockcoinMockRecorder) StartRound

func (mr *MockcoinMockRecorder) StartRound(arg0, arg1, arg2 any) *coinStartRoundCall

StartRound indicates an expected call of StartRound.

type MockeligibilityChecker

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

MockeligibilityChecker is a mock of eligibilityChecker interface.

func NewMockeligibilityChecker

func NewMockeligibilityChecker(ctrl *gomock.Controller) *MockeligibilityChecker

NewMockeligibilityChecker creates a new mock instance.

func (*MockeligibilityChecker) EXPECT

EXPECT returns an object that allows the caller to indicate expected use.

func (*MockeligibilityChecker) PassStrictThreshold

func (m *MockeligibilityChecker) PassStrictThreshold(arg0 types.VrfSignature) bool

PassStrictThreshold mocks base method.

func (*MockeligibilityChecker) PassThreshold

func (m *MockeligibilityChecker) PassThreshold(arg0 types.VrfSignature) bool

PassThreshold mocks base method.

type MockeligibilityCheckerMockRecorder

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

MockeligibilityCheckerMockRecorder is the mock recorder for MockeligibilityChecker.

func (*MockeligibilityCheckerMockRecorder) PassStrictThreshold

func (mr *MockeligibilityCheckerMockRecorder) PassStrictThreshold(arg0 any) *eligibilityCheckerPassStrictThresholdCall

PassStrictThreshold indicates an expected call of PassStrictThreshold.

func (*MockeligibilityCheckerMockRecorder) PassThreshold

func (mr *MockeligibilityCheckerMockRecorder) PassThreshold(arg0 any) *eligibilityCheckerPassThresholdCall

PassThreshold indicates an expected call of PassThreshold.

type MocklayerClock

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

MocklayerClock is a mock of layerClock interface.

func NewMocklayerClock

func NewMocklayerClock(ctrl *gomock.Controller) *MocklayerClock

NewMocklayerClock creates a new mock instance.

func (*MocklayerClock) AwaitLayer

func (m *MocklayerClock) AwaitLayer(arg0 types.LayerID) <-chan struct{}

AwaitLayer mocks base method.

func (*MocklayerClock) CurrentLayer

func (m *MocklayerClock) CurrentLayer() types.LayerID

CurrentLayer mocks base method.

func (*MocklayerClock) EXPECT

EXPECT returns an object that allows the caller to indicate expected use.

func (*MocklayerClock) LayerToTime

func (m *MocklayerClock) LayerToTime(arg0 types.LayerID) time.Time

LayerToTime mocks base method.

type MocklayerClockMockRecorder

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

MocklayerClockMockRecorder is the mock recorder for MocklayerClock.

func (*MocklayerClockMockRecorder) AwaitLayer

func (mr *MocklayerClockMockRecorder) AwaitLayer(arg0 any) *layerClockAwaitLayerCall

AwaitLayer indicates an expected call of AwaitLayer.

func (*MocklayerClockMockRecorder) CurrentLayer

func (mr *MocklayerClockMockRecorder) CurrentLayer() *layerClockCurrentLayerCall

CurrentLayer indicates an expected call of CurrentLayer.

func (*MocklayerClockMockRecorder) LayerToTime

func (mr *MocklayerClockMockRecorder) LayerToTime(arg0 any) *layerClockLayerToTimeCall

LayerToTime indicates an expected call of LayerToTime.

type MocknonceFetcher

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

MocknonceFetcher is a mock of nonceFetcher interface.

func NewMocknonceFetcher

func NewMocknonceFetcher(ctrl *gomock.Controller) *MocknonceFetcher

NewMocknonceFetcher creates a new mock instance.

func (*MocknonceFetcher) EXPECT

EXPECT returns an object that allows the caller to indicate expected use.

func (*MocknonceFetcher) VRFNonce

func (m *MocknonceFetcher) VRFNonce(arg0 types.NodeID, arg1 types.EpochID) (types.VRFPostIndex, error)

VRFNonce mocks base method.

type MocknonceFetcherMockRecorder

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

MocknonceFetcherMockRecorder is the mock recorder for MocknonceFetcher.

func (*MocknonceFetcherMockRecorder) VRFNonce

func (mr *MocknonceFetcherMockRecorder) VRFNonce(arg0, arg1 any) *nonceFetcherVRFNonceCall

VRFNonce indicates an expected call of VRFNonce.

type MockvrfSigner

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

MockvrfSigner is a mock of vrfSigner interface.

func NewMockvrfSigner

func NewMockvrfSigner(ctrl *gomock.Controller) *MockvrfSigner

NewMockvrfSigner creates a new mock instance.

func (*MockvrfSigner) EXPECT

EXPECT returns an object that allows the caller to indicate expected use.

func (*MockvrfSigner) NodeID

func (m *MockvrfSigner) NodeID() types.NodeID

NodeID mocks base method.

func (*MockvrfSigner) Sign

func (m *MockvrfSigner) Sign(msg []byte) types.VrfSignature

Sign mocks base method.

type MockvrfSignerMockRecorder

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

MockvrfSignerMockRecorder is the mock recorder for MockvrfSigner.

func (*MockvrfSignerMockRecorder) NodeID

func (mr *MockvrfSignerMockRecorder) NodeID() *vrfSignerNodeIDCall

NodeID indicates an expected call of NodeID.

func (*MockvrfSignerMockRecorder) Sign

func (mr *MockvrfSignerMockRecorder) Sign(msg any) *vrfSignerSignCall

Sign indicates an expected call of Sign.

type MockvrfVerifier

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

MockvrfVerifier is a mock of vrfVerifier interface.

func NewMockvrfVerifier

func NewMockvrfVerifier(ctrl *gomock.Controller) *MockvrfVerifier

NewMockvrfVerifier creates a new mock instance.

func (*MockvrfVerifier) EXPECT

EXPECT returns an object that allows the caller to indicate expected use.

func (*MockvrfVerifier) Verify

func (m *MockvrfVerifier) Verify(nodeID types.NodeID, msg []byte, sig types.VrfSignature) bool

Verify mocks base method.

type MockvrfVerifierMockRecorder

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

MockvrfVerifierMockRecorder is the mock recorder for MockvrfVerifier.

func (*MockvrfVerifierMockRecorder) Verify

func (mr *MockvrfVerifierMockRecorder) Verify(nodeID, msg, sig any) *vrfVerifierVerifyCall

Verify indicates an expected call of Verify.

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 Proposal

type Proposal [types.BeaconSize]byte

func ProposalFromVrf

func ProposalFromVrf(vrf types.VrfSignature) Proposal

func (*Proposal) DecodeScale

func (p *Proposal) DecodeScale(d *scale.Decoder) (int, error)

DecodeScale implements scale codec interface.

func (*Proposal) EncodeScale

func (p *Proposal) EncodeScale(e *scale.Encoder) (int, error)

EncodeScale implements scale codec interface.

func (Proposal) MarshalLogObject added in v1.2.2

func (p Proposal) MarshalLogObject(enc zapcore.ObjectEncoder) error

type ProposalMessage

type ProposalMessage struct {
	EpochID      types.EpochID
	NodeID       types.NodeID
	VRFSignature types.VrfSignature
}

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)

type ProposalVrfMessage

type ProposalVrfMessage struct {
	Type  types.EligibilityType // always types.EligibilityBeacon
	Nonce types.VRFPostIndex
	Epoch types.EpochID
}

ProposalVrfMessage is the payload for the VRF Signature in `ProposalMessage`.

func (*ProposalVrfMessage) DecodeScale

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

func (*ProposalVrfMessage) EncodeScale

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

type ProtocolDriver

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

ProtocolDriver is the driver for the beacon protocol.

func New

func New(
	publisher pubsub.Publisher,
	edVerifier *signing.EdVerifier,
	vrfVerifier vrfVerifier,
	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) error

HandleFirstVotes handles beacon first votes from gossip.

func (*ProtocolDriver) HandleFollowingVotes

func (pd *ProtocolDriver) HandleFollowingVotes(ctx context.Context, peer p2p.Peer, msg []byte) error

HandleFollowingVotes handles beacon following votes from gossip.

func (*ProtocolDriver) HandleProposal

func (pd *ProtocolDriver) HandleProposal(ctx context.Context, peer p2p.Peer, msg []byte) error

HandleProposal handles beacon proposal from gossip.

func (*ProtocolDriver) HandleWeakCoinProposal

func (pd *ProtocolDriver) HandleWeakCoinProposal(ctx context.Context, peer p2p.Peer, msg []byte) (err error)

HandleWeakCoinProposal handles weakcoin proposal from gossip.

func (*ProtocolDriver) MinerAllowance

func (pd *ProtocolDriver) MinerAllowance(epoch types.EpochID, nodeID types.NodeID) uint32

func (*ProtocolDriver) OnAtx

func (pd *ProtocolDriver) OnAtx(atx *types.ActivationTxHeader)

func (*ProtocolDriver) Register added in v1.3.0

func (pd *ProtocolDriver) Register(s *signing.EdSigner)

func (*ProtocolDriver) ReportBeaconFromBallot

func (pd *ProtocolDriver) ReportBeaconFromBallot(
	epoch types.EpochID,
	ballot *types.Ballot,
	beacon types.Beacon,
	weightPer fixed.Fixed,
)

ReportBeaconFromBallot reports the beacon value in a ballot along with the smesher's weight unit.

func (*ProtocolDriver) Results

func (pd *ProtocolDriver) Results() <-chan result.Beacon

Results notifies waiter that beacon for a target epoch has completed.

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.

func (*ProtocolDriver) UpdateBeacon

func (pd *ProtocolDriver) UpdateBeacon(epoch types.EpochID, beacon types.Beacon) error

Directories

Path Synopsis
Code generated by MockGen.
Code generated by MockGen.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL