challenge

package
v1.22.88 Latest Latest
Warning

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

Go to latest
Published: Jan 19, 2026 License: BSD-3-Clause Imports: 10 Imported by: 0

Documentation

Overview

Package challenge implements the uptime challenge and incentive system for service nodes. It ensures nodes remain available and responsive through random challenges with on-chain verification.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateUptimeResponse

func CreateUptimeResponse(challenge *servicenodevm.Challenge, nodeID ids.NodeID, privateKey []byte) *servicenodevm.ChallengeResponse

SubmitUptimeProof creates a response for an uptime challenge

Types

type ChallengeStats

type ChallengeStats struct {
	NodeID           ids.NodeID `json:"nodeID"`
	TotalChallenges  uint64     `json:"totalChallenges"`
	PassedChallenges uint64     `json:"passedChallenges"`
	FailedChallenges uint64     `json:"failedChallenges"`
	UptimeScore      uint64     `json:"uptimeScore"`
}

ChallengeStats holds challenge statistics for a node

type Manager

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

Manager handles challenge creation, verification, and incentives

func NewManager

func NewManager(db database.Database, registry *servicenodevm.Registry, config *servicenodevm.Config) *Manager

NewManager creates a new challenge manager

func (*Manager) CreateChallenge

func (m *Manager) CreateChallenge(ctx context.Context, epochID uint64, targetNodeID, issuerNodeID ids.NodeID, challengeType string) (*servicenodevm.Challenge, error)

CreateChallenge creates a new challenge for a target node

func (*Manager) CreateRandomChallenges

func (m *Manager) CreateRandomChallenges(ctx context.Context, epochID uint64, count int, seed [32]byte) ([]*servicenodevm.Challenge, error)

CreateRandomChallenges creates challenges for random nodes in an epoch

func (*Manager) DistributeRewards

func (m *Manager) DistributeRewards(ctx context.Context, epochID uint64, rewardPool uint64) error

DistributeRewards distributes rewards to nodes that passed challenges in an epoch

func (*Manager) GetChallenge

func (m *Manager) GetChallenge(challengeID ids.ID) (*servicenodevm.Challenge, error)

GetChallenge retrieves a challenge by ID

func (*Manager) GetChallengeStats

func (m *Manager) GetChallengeStats(nodeID ids.NodeID) *ChallengeStats

GetChallengeStats returns challenge statistics for a node

func (*Manager) GetPendingChallenges

func (m *Manager) GetPendingChallenges(nodeID ids.NodeID) []*servicenodevm.Challenge

GetPendingChallenges returns all pending challenges for a node

func (*Manager) Load

func (m *Manager) Load(ctx context.Context) error

Load loads pending challenges from the database

func (*Manager) ProcessExpiredChallenges

func (m *Manager) ProcessExpiredChallenges(ctx context.Context) error

ProcessExpiredChallenges processes challenges that have expired without response

func (*Manager) RespondToChallenge

func (m *Manager) RespondToChallenge(ctx context.Context, response *servicenodevm.ChallengeResponse) error

RespondToChallenge processes a challenge response

Jump to

Keyboard shortcuts

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