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 ¶
- type Config
- type FirstVotingMessage
- type FirstVotingMessageBody
- type FollowingVotingMessage
- type FollowingVotingMessageBody
- type Mockcoin
- func (m *Mockcoin) EXPECT() *MockcoinMockRecorder
- func (m *Mockcoin) FinishEpoch(arg0 context.Context, arg1 types.EpochID)
- func (m *Mockcoin) FinishRound(arg0 context.Context)
- func (m *Mockcoin) Get(arg0 context.Context, arg1 types.EpochID, arg2 types.RoundID) (bool, error)
- func (m *Mockcoin) HandleProposal(arg0 context.Context, arg1 p2p.Peer, arg2 []byte) error
- func (m *Mockcoin) StartEpoch(arg0 context.Context, arg1 types.EpochID)
- func (m *Mockcoin) StartRound(arg0 context.Context, arg1 types.RoundID, arg2 []weakcoin.Participant)
- type MockcoinMockRecorder
- func (mr *MockcoinMockRecorder) FinishEpoch(arg0, arg1 any) *coinFinishEpochCall
- func (mr *MockcoinMockRecorder) FinishRound(arg0 any) *coinFinishRoundCall
- func (mr *MockcoinMockRecorder) Get(arg0, arg1, arg2 any) *coinGetCall
- func (mr *MockcoinMockRecorder) HandleProposal(arg0, arg1, arg2 any) *coinHandleProposalCall
- func (mr *MockcoinMockRecorder) StartEpoch(arg0, arg1 any) *coinStartEpochCall
- func (mr *MockcoinMockRecorder) StartRound(arg0, arg1, arg2 any) *coinStartRoundCall
- type MockeligibilityChecker
- type MockeligibilityCheckerMockRecorder
- type MocklayerClock
- type MocklayerClockMockRecorder
- type MocknonceFetcher
- type MocknonceFetcherMockRecorder
- type MockvrfSigner
- type MockvrfSignerMockRecorder
- type MockvrfVerifier
- type MockvrfVerifierMockRecorder
- type Opt
- type Proposal
- type ProposalMessage
- type ProposalVrfMessage
- 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) error
- func (pd *ProtocolDriver) HandleFollowingVotes(ctx context.Context, peer p2p.Peer, msg []byte) error
- func (pd *ProtocolDriver) HandleProposal(ctx context.Context, peer p2p.Peer, msg []byte) error
- func (pd *ProtocolDriver) HandleWeakCoinProposal(ctx context.Context, peer p2p.Peer, msg []byte) (err error)
- func (pd *ProtocolDriver) MinerAllowance(epoch types.EpochID, nodeID types.NodeID) uint32
- func (pd *ProtocolDriver) OnAtx(atx *types.ActivationTxHeader)
- func (pd *ProtocolDriver) Register(s *signing.EdSigner)
- func (pd *ProtocolDriver) ReportBeaconFromBallot(epoch types.EpochID, ballot *types.Ballot, beacon types.Beacon, ...)
- func (pd *ProtocolDriver) Results() <-chan result.Beacon
- func (pd *ProtocolDriver) SetSyncState(sync system.SyncStateProvider)
- func (pd *ProtocolDriver) Start(ctx context.Context)
- func (pd *ProtocolDriver) UpdateBeacon(epoch types.EpochID, beacon types.Beacon) error
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 ¶
FinishEpoch mocks base method.
func (*Mockcoin) FinishRound ¶
FinishRound mocks base method.
func (*Mockcoin) HandleProposal ¶
HandleProposal mocks base method.
func (*Mockcoin) StartEpoch ¶
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 ¶
func (m *MockeligibilityChecker) EXPECT() *MockeligibilityCheckerMockRecorder
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 ¶
func (m *MocklayerClock) EXPECT() *MocklayerClockMockRecorder
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 ¶
func (m *MocknonceFetcher) EXPECT() *MocknonceFetcherMockRecorder
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 ¶
func (m *MockvrfSigner) EXPECT() *MockvrfSignerMockRecorder
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 ¶
func (m *MockvrfVerifier) EXPECT() *MockvrfVerifierMockRecorder
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 WithContext ¶
WithContext defines context for beacon.
type Proposal ¶
type Proposal [types.BeaconSize]byte
func ProposalFromVrf ¶
func ProposalFromVrf(vrf types.VrfSignature) Proposal
func (*Proposal) DecodeScale ¶
DecodeScale implements scale codec interface.
func (*Proposal) EncodeScale ¶
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) GetBeacon ¶
GetBeacon returns the beacon for the specified epoch or an error if it doesn't exist.
func (*ProtocolDriver) HandleFirstVotes ¶
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 ¶
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 (*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.