eligibility

package
v1.4.0-alpha.1 Latest Latest
Warning

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

Go to latest
Published: Feb 14, 2024 License: MIT Imports: 21 Imported by: 0

Documentation

Overview

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

Generated by this command:

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

Package eligibility is a generated GoMock package.

nolint

Index

Constants

View Source
const (
	// CertifyRound is not part of the hare protocol, but it shares the same oracle for eligibility.
	CertifyRound uint32 = math.MaxUint32 >> 1
)

Variables

View Source
var (
	ErrNotActive = errors.New("oracle: miner is not active in epoch")
)

Functions

func GenVRF added in v1.3.0

func GenVRF(
	ctx context.Context,
	signer *signing.VRFSigner,
	beacon types.Beacon,
	layer types.LayerID,
	round uint32,
) types.VrfSignature

GenVRF generates vrf for hare eligibility.

Types

type Config

type Config struct {
	// ConfidenceParam specifies how many layers into the epoch hare uses active set generated in the previous epoch.
	// For example, if epoch size is 100 and confidence is 10 hare will use previous active set for layers 0-9
	// and then generate a new activeset.
	//
	// This was done like that so that we have higher `confidence` that hare will succeed atleast
	// once during this interval. If it doesn't we have to provide centralized fallback.
	ConfidenceParam uint32 `mapstructure:"eligibility-confidence-param"`
}

Config is the configuration of the oracle package.

func DefaultConfig

func DefaultConfig() Config

DefaultConfig returns the default configuration for the oracle package.

func (*Config) MarshalLogObject

func (c *Config) MarshalLogObject(encoder log.ObjectEncoder) error

type MockRolacle added in v1.3.0

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

MockRolacle is a mock of Rolacle interface.

func NewMockRolacle added in v1.3.0

func NewMockRolacle(ctrl *gomock.Controller) *MockRolacle

NewMockRolacle creates a new mock instance.

func (*MockRolacle) CalcEligibility added in v1.3.0

func (m *MockRolacle) CalcEligibility(arg0 context.Context, arg1 types.LayerID, arg2 uint32, arg3 int, arg4 types.NodeID, arg5 types.VrfSignature) (uint16, error)

CalcEligibility mocks base method.

func (*MockRolacle) EXPECT added in v1.3.0

func (m *MockRolacle) EXPECT() *MockRolacleMockRecorder

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

func (*MockRolacle) Proof added in v1.3.0

func (m *MockRolacle) Proof(arg0 context.Context, arg1 *signing.VRFSigner, arg2 types.LayerID, arg3 uint32) (types.VrfSignature, error)

Proof mocks base method.

func (*MockRolacle) Validate added in v1.3.0

func (m *MockRolacle) Validate(arg0 context.Context, arg1 types.LayerID, arg2 uint32, arg3 int, arg4 types.NodeID, arg5 types.VrfSignature, arg6 uint16) (bool, error)

Validate mocks base method.

type MockRolacleMockRecorder added in v1.3.0

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

MockRolacleMockRecorder is the mock recorder for MockRolacle.

func (*MockRolacleMockRecorder) CalcEligibility added in v1.3.0

func (mr *MockRolacleMockRecorder) CalcEligibility(arg0, arg1, arg2, arg3, arg4, arg5 any) *RolacleCalcEligibilityCall

CalcEligibility indicates an expected call of CalcEligibility.

func (*MockRolacleMockRecorder) Proof added in v1.3.0

func (mr *MockRolacleMockRecorder) Proof(arg0, arg1, arg2, arg3 any) *RolacleProofCall

Proof indicates an expected call of Proof.

func (*MockRolacleMockRecorder) Validate added in v1.3.0

func (mr *MockRolacleMockRecorder) Validate(arg0, arg1, arg2, arg3, arg4, arg5, arg6 any) *RolacleValidateCall

Validate indicates an expected call of Validate.

type MockactiveSetCache added in v1.0.0

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

MockactiveSetCache is a mock of activeSetCache interface.

func NewMockactiveSetCache added in v1.0.0

func NewMockactiveSetCache(ctrl *gomock.Controller) *MockactiveSetCache

NewMockactiveSetCache creates a new mock instance.

func (*MockactiveSetCache) Add added in v1.0.0

func (m *MockactiveSetCache) Add(key types.EpochID, value *cachedActiveSet) bool

Add mocks base method.

func (*MockactiveSetCache) EXPECT added in v1.0.0

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

func (*MockactiveSetCache) Get added in v1.0.0

func (m *MockactiveSetCache) Get(key types.EpochID) (*cachedActiveSet, bool)

Get mocks base method.

type MockactiveSetCacheMockRecorder added in v1.0.0

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

MockactiveSetCacheMockRecorder is the mock recorder for MockactiveSetCache.

func (*MockactiveSetCacheMockRecorder) Add added in v1.0.0

func (mr *MockactiveSetCacheMockRecorder) Add(key, value any) *activeSetCacheAddCall

Add indicates an expected call of Add.

func (*MockactiveSetCacheMockRecorder) Get added in v1.0.0

func (mr *MockactiveSetCacheMockRecorder) Get(key any) *activeSetCacheGetCall

Get indicates an expected call of Get.

type MockvrfVerifier added in v1.0.0

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

MockvrfVerifier is a mock of vrfVerifier interface.

func NewMockvrfVerifier added in v1.0.0

func NewMockvrfVerifier(ctrl *gomock.Controller) *MockvrfVerifier

NewMockvrfVerifier creates a new mock instance.

func (*MockvrfVerifier) EXPECT added in v1.0.0

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

func (*MockvrfVerifier) Verify added in v1.0.0

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

Verify mocks base method.

type MockvrfVerifierMockRecorder added in v1.0.0

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

MockvrfVerifierMockRecorder is the mock recorder for MockvrfVerifier.

func (*MockvrfVerifierMockRecorder) Verify added in v1.0.0

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

Verify indicates an expected call of Verify.

type Opt

type Opt func(*Oracle)

func WithConfig

func WithConfig(config Config) Opt

func WithLogger

func WithLogger(logger log.Log) Opt

type Oracle

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

Oracle is the hare eligibility oracle.

func New

func New(
	beacons system.BeaconGetter,
	db sql.Executor,
	atxsdata *atxsdata.Data,
	vrfVerifier vrfVerifier,
	layersPerEpoch uint32,
	opts ...Opt,
) *Oracle

New returns a new eligibility oracle instance.

func (*Oracle) ActiveSet added in v1.0.0

func (o *Oracle) ActiveSet(ctx context.Context, targetEpoch types.EpochID) ([]types.ATXID, error)

func (*Oracle) CalcEligibility added in v1.0.0

func (o *Oracle) CalcEligibility(
	ctx context.Context,
	layer types.LayerID,
	round uint32,
	committeeSize int,
	id types.NodeID,
	vrfSig types.VrfSignature,
) (uint16, error)

CalcEligibility calculates the number of eligibilities of ID on the given Layer where msg is the VRF message, sig is the role proof and assuming commSize as the expected committee size.

func (*Oracle) IsIdentityActiveOnConsensusView

func (o *Oracle) IsIdentityActiveOnConsensusView(
	ctx context.Context,
	edID types.NodeID,
	layer types.LayerID,
) (bool, error)

IsIdentityActiveOnConsensusView returns true if the provided identity is active on the consensus view derived from the specified layer, false otherwise.

func (*Oracle) Proof

func (o *Oracle) Proof(
	ctx context.Context,
	signer *signing.VRFSigner,
	layer types.LayerID,
	round uint32,
) (types.VrfSignature, error)

Proof returns the role proof for the current Layer & Round.

func (*Oracle) SetSync added in v1.1.4

func (o *Oracle) SetSync(sync system.SyncStateProvider)

func (*Oracle) UpdateActiveSet added in v1.0.0

func (o *Oracle) UpdateActiveSet(epoch types.EpochID, activeSet []types.ATXID)

func (*Oracle) Validate added in v1.0.0

func (o *Oracle) Validate(
	ctx context.Context,
	layer types.LayerID,
	round uint32,
	committeeSize int,
	id types.NodeID,
	sig types.VrfSignature,
	eligibilityCount uint16,
) (bool, error)

Validate validates the number of eligibilities of ID on the given Layer where msg is the VRF message, sig is the role proof and assuming commSize as the expected committee size.

type Rolacle added in v1.3.0

Rolacle is the roles oracle provider.

type RolacleCalcEligibilityCall added in v1.3.0

type RolacleCalcEligibilityCall struct {
	*gomock.Call
}

RolacleCalcEligibilityCall wrap *gomock.Call

func (*RolacleCalcEligibilityCall) Do added in v1.3.0

Do rewrite *gomock.Call.Do

func (*RolacleCalcEligibilityCall) DoAndReturn added in v1.3.0

DoAndReturn rewrite *gomock.Call.DoAndReturn

func (*RolacleCalcEligibilityCall) Return added in v1.3.0

Return rewrite *gomock.Call.Return

type RolacleProofCall added in v1.3.0

type RolacleProofCall struct {
	*gomock.Call
}

RolacleProofCall wrap *gomock.Call

func (*RolacleProofCall) Do added in v1.3.0

Do rewrite *gomock.Call.Do

func (*RolacleProofCall) DoAndReturn added in v1.3.0

DoAndReturn rewrite *gomock.Call.DoAndReturn

func (*RolacleProofCall) Return added in v1.3.0

func (c *RolacleProofCall) Return(arg0 types.VrfSignature, arg1 error) *RolacleProofCall

Return rewrite *gomock.Call.Return

type RolacleValidateCall added in v1.3.0

type RolacleValidateCall struct {
	*gomock.Call
}

RolacleValidateCall wrap *gomock.Call

func (*RolacleValidateCall) Do added in v1.3.0

Do rewrite *gomock.Call.Do

func (*RolacleValidateCall) DoAndReturn added in v1.3.0

DoAndReturn rewrite *gomock.Call.DoAndReturn

func (*RolacleValidateCall) Return added in v1.3.0

func (c *RolacleValidateCall) Return(arg0 bool, arg1 error) *RolacleValidateCall

Return rewrite *gomock.Call.Return

type VrfMessage added in v1.0.0

type VrfMessage struct {
	Type   types.EligibilityType // always types.EligibilityHare
	Beacon types.Beacon
	Round  uint32
	Layer  types.LayerID
}

VrfMessage is a verification message. It is also the payload for the signature in `types.HareEligibility`.

func (*VrfMessage) DecodeScale added in v1.0.0

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

func (*VrfMessage) EncodeScale added in v1.0.0

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

Jump to

Keyboard shortcuts

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