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 ¶
- func CreateUptimeResponse(challenge *servicenodevm.Challenge, nodeID ids.NodeID, privateKey []byte) *servicenodevm.ChallengeResponse
- type ChallengeStats
- type Manager
- func (m *Manager) CreateChallenge(ctx context.Context, epochID uint64, targetNodeID, issuerNodeID ids.NodeID, ...) (*servicenodevm.Challenge, error)
- func (m *Manager) CreateRandomChallenges(ctx context.Context, epochID uint64, count int, seed [32]byte) ([]*servicenodevm.Challenge, error)
- func (m *Manager) DistributeRewards(ctx context.Context, epochID uint64, rewardPool uint64) error
- func (m *Manager) GetChallenge(challengeID ids.ID) (*servicenodevm.Challenge, error)
- func (m *Manager) GetChallengeStats(nodeID ids.NodeID) *ChallengeStats
- func (m *Manager) GetPendingChallenges(nodeID ids.NodeID) []*servicenodevm.Challenge
- func (m *Manager) Load(ctx context.Context) error
- func (m *Manager) ProcessExpiredChallenges(ctx context.Context) error
- func (m *Manager) RespondToChallenge(ctx context.Context, response *servicenodevm.ChallengeResponse) error
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 ¶
DistributeRewards distributes rewards to nodes that passed challenges in an epoch
func (*Manager) GetChallenge ¶
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) ProcessExpiredChallenges ¶
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