eligibility

package
v1.5.6 Latest Latest
Warning

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

Go to latest
Published: May 23, 2024 License: MIT Imports: 21 Imported by: 0

Documentation

Overview

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

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

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

MockRolacle is a mock of Rolacle interface.

func NewMockRolacle

func NewMockRolacle(ctrl *gomock.Controller) *MockRolacle

NewMockRolacle creates a new mock instance.

func (*MockRolacle) CalcEligibility

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

func (m *MockRolacle) EXPECT() *MockRolacleMockRecorder

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

func (*MockRolacle) Proof

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

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 MockRolacleCalcEligibilityCall

type MockRolacleCalcEligibilityCall struct {
	*gomock.Call
}

MockRolacleCalcEligibilityCall wrap *gomock.Call

func (*MockRolacleCalcEligibilityCall) Do

Do rewrite *gomock.Call.Do

func (*MockRolacleCalcEligibilityCall) DoAndReturn

DoAndReturn rewrite *gomock.Call.DoAndReturn

func (*MockRolacleCalcEligibilityCall) Return

Return rewrite *gomock.Call.Return

type MockRolacleMockRecorder

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

MockRolacleMockRecorder is the mock recorder for MockRolacle.

func (*MockRolacleMockRecorder) CalcEligibility

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

CalcEligibility indicates an expected call of CalcEligibility.

func (*MockRolacleMockRecorder) Proof

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

Proof indicates an expected call of Proof.

func (*MockRolacleMockRecorder) Validate

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

Validate indicates an expected call of Validate.

type MockRolacleProofCall

type MockRolacleProofCall struct {
	*gomock.Call
}

MockRolacleProofCall wrap *gomock.Call

func (*MockRolacleProofCall) Do

Do rewrite *gomock.Call.Do

func (*MockRolacleProofCall) DoAndReturn

DoAndReturn rewrite *gomock.Call.DoAndReturn

func (*MockRolacleProofCall) Return

Return rewrite *gomock.Call.Return

type MockRolacleValidateCall

type MockRolacleValidateCall struct {
	*gomock.Call
}

MockRolacleValidateCall wrap *gomock.Call

func (*MockRolacleValidateCall) Do

Do rewrite *gomock.Call.Do

func (*MockRolacleValidateCall) DoAndReturn

DoAndReturn rewrite *gomock.Call.DoAndReturn

func (*MockRolacleValidateCall) Return

Return rewrite *gomock.Call.Return

type MockactiveSetCache

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

MockactiveSetCache is a mock of activeSetCache interface.

func NewMockactiveSetCache

func NewMockactiveSetCache(ctrl *gomock.Controller) *MockactiveSetCache

NewMockactiveSetCache creates a new mock instance.

func (*MockactiveSetCache) Add

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

Add mocks base method.

func (*MockactiveSetCache) EXPECT

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

func (*MockactiveSetCache) Get

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

Get mocks base method.

type MockactiveSetCacheAddCall

type MockactiveSetCacheAddCall struct {
	*gomock.Call
}

MockactiveSetCacheAddCall wrap *gomock.Call

func (*MockactiveSetCacheAddCall) Do

func (c *MockactiveSetCacheAddCall) Do(f func(types.EpochID, *cachedActiveSet) bool) *MockactiveSetCacheAddCall

Do rewrite *gomock.Call.Do

func (*MockactiveSetCacheAddCall) DoAndReturn

func (c *MockactiveSetCacheAddCall) DoAndReturn(f func(types.EpochID, *cachedActiveSet) bool) *MockactiveSetCacheAddCall

DoAndReturn rewrite *gomock.Call.DoAndReturn

func (*MockactiveSetCacheAddCall) Return

Return rewrite *gomock.Call.Return

type MockactiveSetCacheGetCall

type MockactiveSetCacheGetCall struct {
	*gomock.Call
}

MockactiveSetCacheGetCall wrap *gomock.Call

func (*MockactiveSetCacheGetCall) Do

func (c *MockactiveSetCacheGetCall) Do(f func(types.EpochID) (*cachedActiveSet, bool)) *MockactiveSetCacheGetCall

Do rewrite *gomock.Call.Do

func (*MockactiveSetCacheGetCall) DoAndReturn

func (c *MockactiveSetCacheGetCall) DoAndReturn(f func(types.EpochID) (*cachedActiveSet, bool)) *MockactiveSetCacheGetCall

DoAndReturn rewrite *gomock.Call.DoAndReturn

func (*MockactiveSetCacheGetCall) Return

func (c *MockactiveSetCacheGetCall) Return(value *cachedActiveSet, ok bool) *MockactiveSetCacheGetCall

Return rewrite *gomock.Call.Return

type MockactiveSetCacheMockRecorder

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

MockactiveSetCacheMockRecorder is the mock recorder for MockactiveSetCache.

func (*MockactiveSetCacheMockRecorder) Add

Add indicates an expected call of Add.

func (*MockactiveSetCacheMockRecorder) Get

Get indicates an expected call of Get.

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) *MockvrfVerifierVerifyCall

Verify indicates an expected call of Verify.

type MockvrfVerifierVerifyCall

type MockvrfVerifierVerifyCall struct {
	*gomock.Call
}

MockvrfVerifierVerifyCall wrap *gomock.Call

func (*MockvrfVerifierVerifyCall) Do

Do rewrite *gomock.Call.Do

func (*MockvrfVerifierVerifyCall) DoAndReturn

DoAndReturn rewrite *gomock.Call.DoAndReturn

func (*MockvrfVerifierVerifyCall) Return

Return rewrite *gomock.Call.Return

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

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

func (*Oracle) CalcEligibility

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

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

func (*Oracle) UpdateActiveSet

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

func (*Oracle) Validate

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

Rolacle is the roles oracle provider.

type VrfMessage

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

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

func (*VrfMessage) EncodeScale

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