servicenodevm

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: 21 Imported by: 0

Documentation

Overview

Package servicenodevm implements the Service Node VM for Session-style private messaging infrastructure. It manages service node registration, stake/collateral, swarm assignments, and uptime challenges.

Index

Constants

View Source
const (
	DefaultMinStake            = uint64(1000000)    // 1 LUX in microLUX
	DefaultStakeLockPeriod     = 7 * 24 * time.Hour // 7 days
	DefaultEpochDuration       = 24 * time.Hour     // 1 day
	DefaultEpochBlocks         = uint64(43200)      // ~24h at 2s blocks
	DefaultNodesPerSwarm       = uint32(5)
	DefaultMinActiveNodes      = uint32(10)
	DefaultChallengeInterval   = 1 * time.Hour
	DefaultChallengeTTL        = 5 * time.Minute
	DefaultMessageTTL          = 14 * 24 * time.Hour       // 14 days
	DefaultMaxMessageSize      = uint64(64 * 1024)         // 64KB
	DefaultStorageQuota        = uint64(100 * 1024 * 1024) // 100MB per account
	DefaultJailDuration        = 24 * time.Hour
	DefaultSlashPercent        = uint64(1000) // 10% in basis points
	DefaultRewardPerMessage    = uint64(100)  // microLUX per message
	DefaultRewardPerChallenge  = uint64(10)   // microLUX per challenge passed
	DefaultMaxMessagesPerFetch = 100
)

Default configuration values

View Source
const (
	StateRegistered = "registered"
	StateActive     = "active"
	StateJailed     = "jailed"
	StateExiting    = "exiting"
	StateExited     = "exited"
)

Service node states

View Source
const (
	ChallengeTypeUptime  = "uptime"
	ChallengeTypeStorage = "storage"
	ChallengeTypeRelay   = "relay"
)

Challenge response types

View Source
const (
	Name = "servicenodevm"
)

Variables

View Source
var (
	ErrNodeNotFound      = errors.New("service node not found")
	ErrNodeAlreadyExists = errors.New("service node already exists")
	ErrInsufficientStake = errors.New("insufficient stake")
	ErrNodeJailed        = errors.New("service node is jailed")
	ErrNodeNotActive     = errors.New("service node is not active")
	ErrInvalidSignature  = errors.New("invalid signature")
	ErrEpochNotFound     = errors.New("epoch not found")
	ErrSwarmNotFound     = errors.New("swarm not found")
	ErrChallengeNotFound = errors.New("challenge not found")
	ErrChallengeFailed   = errors.New("challenge response failed")
	ErrChallengeExpired  = errors.New("challenge has expired")
	ErrMessageNotFound   = errors.New("message not found")
	ErrMessageExpired    = errors.New("message has expired")
	ErrQuotaExceeded     = errors.New("storage quota exceeded")
	ErrInvalidProof      = errors.New("invalid proof")
	ErrInvalidEpoch      = errors.New("invalid epoch")
)

Errors

View Source
var VMID = ids.ID{'s', 'e', 'r', 'v', 'i', 'c', 'e', 'n', 'o', 'd', 'e', 'v', 'm'}

VMID is the unique identifier for ServiceNodeVM (S-Chain)

Functions

This section is empty.

Types

type ActivateArgs

type ActivateArgs struct {
	NodeID string `json:"nodeID"`
}

ActivateArgs are the arguments to Activate

type ActivateReply

type ActivateReply struct {
	Success bool `json:"success"`
}

ActivateReply is the reply from Activate

type Block

type Block struct {
	ParentID_      ids.ID `json:"parentId"`
	BlockHeight    uint64 `json:"height"`
	BlockTimestamp int64  `json:"timestamp"`
	EpochID        uint64 `json:"epochId"`

	// Transactions
	Registrations    []*RegistrationTx    `json:"registrations,omitempty"`
	Exits            []*ExitTx            `json:"exits,omitempty"`
	Slashes          []*SlashTx           `json:"slashes,omitempty"`
	ChallengeResults []*Challenge         `json:"challengeResults,omitempty"`
	UptimeProofs     []*UptimeProof       `json:"uptimeProofs,omitempty"`
	StorageCommits   []*StorageCommitment `json:"storageCommits,omitempty"`

	// State roots
	RegistryRoot   [32]byte `json:"registryRoot"`
	AssignmentRoot [32]byte `json:"assignmentRoot"`
	ChallengeRoot  [32]byte `json:"challengeRoot"`
	// contains filtered or unexported fields
}

Block represents a block in the ServiceNodeVM chain

func (*Block) Accept

func (b *Block) Accept(ctx context.Context) error

Accept accepts the block

func (*Block) Bytes

func (b *Block) Bytes() []byte

Bytes returns the serialized block

func (*Block) Hash

func (b *Block) Hash() [32]byte

Hash returns the block hash

func (*Block) Height

func (b *Block) Height() uint64

Height returns the block height

func (*Block) ID

func (b *Block) ID() ids.ID

ID returns the block ID

func (*Block) Parent

func (b *Block) Parent() ids.ID

Parent is an alias for ParentID

func (*Block) ParentID

func (b *Block) ParentID() ids.ID

ParentID returns the parent block ID

func (*Block) Reject

func (b *Block) Reject(ctx context.Context) error

Reject rejects the block

func (*Block) SetStatus

func (b *Block) SetStatus(status choices.Status)

SetStatus sets the block status

func (*Block) SetVM

func (b *Block) SetVM(vm interface{})

SetVM sets the VM reference

func (*Block) Status

func (b *Block) Status() uint8

Status returns the block status

func (*Block) Timestamp

func (b *Block) Timestamp() time.Time

Timestamp returns the block timestamp

func (*Block) Verify

func (b *Block) Verify(ctx context.Context) error

Verify verifies the block

type Challenge

type Challenge struct {
	ID           ids.ID     `json:"id"`
	Type         string     `json:"type"`
	EpochID      uint64     `json:"epochID"`
	TargetNodeID ids.NodeID `json:"targetNodeID"`
	IssuerNodeID ids.NodeID `json:"issuerNodeID"`
	Nonce        [32]byte   `json:"nonce"`
	CreatedAt    time.Time  `json:"createdAt"`
	ExpiresAt    time.Time  `json:"expiresAt"`
	Responded    bool       `json:"responded"`
	ResponseHash [32]byte   `json:"responseHash,omitempty"`
	Success      bool       `json:"success"`
}

Challenge represents an uptime/storage challenge

func (*Challenge) Hash

func (c *Challenge) Hash() [32]byte

Hash returns a deterministic hash of the challenge

func (*Challenge) IsExpired

func (c *Challenge) IsExpired() bool

IsExpired returns whether the challenge has expired

type ChallengeResponse

type ChallengeResponse struct {
	ChallengeID ids.ID     `json:"challengeID"`
	NodeID      ids.NodeID `json:"nodeID"`
	Proof       []byte     `json:"proof"`
	Signature   []byte     `json:"signature"`
	Timestamp   time.Time  `json:"timestamp"`
}

ChallengeResponse represents a response to a challenge

type Config

type Config struct {
	// Staking parameters
	MinStake        uint64 `json:"minStake"`
	StakeLockPeriod int64  `json:"stakeLockPeriod"` // Seconds

	// Epoch parameters
	EpochDuration  int64  `json:"epochDuration"` // Seconds
	EpochBlocks    uint64 `json:"epochBlocks"`
	NodesPerSwarm  uint32 `json:"nodesPerSwarm"`
	MinActiveNodes uint32 `json:"minActiveNodes"`

	// Challenge parameters
	ChallengeInterval  int64  `json:"challengeInterval"` // Seconds
	ChallengeTTL       int64  `json:"challengeTTL"`      // Seconds
	ChallengesPerEpoch uint32 `json:"challengesPerEpoch"`

	// Storage parameters
	MessageTTL          int64  `json:"messageTTL"` // Seconds
	MaxMessageSize      uint64 `json:"maxMessageSize"`
	StorageQuota        uint64 `json:"storageQuota"` // Per account
	MaxMessagesPerFetch int    `json:"maxMessagesPerFetch"`

	// Penalty parameters
	JailDuration        int64  `json:"jailDuration"` // Seconds
	SlashPercent        uint64 `json:"slashPercent"` // Basis points (100 = 1%)
	MaxFailedChallenges uint32 `json:"maxFailedChallenges"`

	// Reward parameters
	RewardPerMessage   uint64 `json:"rewardPerMessage"`
	RewardPerChallenge uint64 `json:"rewardPerChallenge"`
	EpochRewardPool    uint64 `json:"epochRewardPool"`

	// Network parameters
	EnableOnionRouting bool `json:"enableOnionRouting"`
	EnableQUIC         bool `json:"enableQUIC"`
	MaxPeers           int  `json:"maxPeers"`
}

Config holds the ServiceNodeVM configuration

func DefaultConfig

func DefaultConfig() *Config

DefaultConfig returns the default configuration

func (*Config) Merge

func (c *Config) Merge(other *Config)

Merge merges another config into this one, using non-zero values

func (*Config) Validate

func (c *Config) Validate() error

Validate validates the configuration

type DeactivateArgs

type DeactivateArgs struct {
	NodeID string `json:"nodeID"`
}

DeactivateArgs are the arguments to Deactivate

type DeactivateReply

type DeactivateReply struct {
	Success bool `json:"success"`
}

DeactivateReply is the reply from Deactivate

type Epoch

type Epoch struct {
	ID               uint64    `json:"id"`
	StartHeight      uint64    `json:"startHeight"`
	EndHeight        uint64    `json:"endHeight"`
	StartTime        time.Time `json:"startTime"`
	EndTime          time.Time `json:"endTime"`
	RegistrySnapshot [32]byte  `json:"registrySnapshot"` // Root of service node registry at epoch start
	AssignmentRoot   [32]byte  `json:"assignmentRoot"`   // Root of swarm assignments
	RandomnessSource [32]byte  `json:"randomnessSource"` // From block hash or VRF
	ActiveNodeCount  uint32    `json:"activeNodeCount"`
	SwarmCount       uint32    `json:"swarmCount"`
	NodesPerSwarm    uint32    `json:"nodesPerSwarm"`
}

Epoch represents a time period for swarm assignments

func (*Epoch) Hash

func (e *Epoch) Hash() [32]byte

Hash returns a deterministic hash of the epoch

type ExitTx

type ExitTx struct {
	NodeID    ids.NodeID `json:"nodeID"`
	Timestamp time.Time  `json:"timestamp"`
	Signature []byte     `json:"signature"`
}

ExitTx represents a service node exit transaction

type Factory

type Factory struct{}

Factory creates new ServiceNodeVM instances

func (*Factory) New

func (f *Factory) New(logger log.Logger) (interface{}, error)

New returns a new instance of the ServiceNodeVM

type Genesis

type Genesis struct {
	Timestamp    int64          `json:"timestamp"`
	Config       *Config        `json:"config,omitempty"`
	ServiceNodes []*GenesisNode `json:"serviceNodes,omitempty"`
	Message      string         `json:"message,omitempty"`
}

Genesis represents genesis data for ServiceNodeVM

func ParseGenesis

func ParseGenesis(genesisBytes []byte) (*Genesis, error)

ParseGenesis parses genesis bytes

type GenesisNode

type GenesisNode struct {
	NodeID       ids.NodeID `json:"nodeID"`
	PublicKey    []byte     `json:"publicKey"`
	EndpointHash [32]byte   `json:"endpointHash"`
	StakeAmount  uint64     `json:"stakeAmount"`
	StakeLockEnd uint64     `json:"stakeLockEnd"`
}

GenesisNode represents a genesis service node

type GetActiveNodesArgs

type GetActiveNodesArgs struct{}

GetActiveNodesArgs are the arguments to GetActiveNodes

type GetActiveNodesReply

type GetActiveNodesReply struct {
	Nodes []string `json:"nodes"`
	Count int      `json:"count"`
}

GetActiveNodesReply is the reply from GetActiveNodes

type GetNetworkParamsArgs

type GetNetworkParamsArgs struct{}

GetNetworkParamsArgs are the arguments to GetNetworkParams

type GetNetworkParamsReply

type GetNetworkParamsReply struct {
	MinStake         uint64 `json:"minStake"`
	StakeLockPeriod  int64  `json:"stakeLockPeriod"`
	EpochDuration    int64  `json:"epochDuration"`
	NodesPerSwarm    uint32 `json:"nodesPerSwarm"`
	MinActiveNodes   uint32 `json:"minActiveNodes"`
	MessageTTL       int64  `json:"messageTTL"`
	MaxMessageSize   uint64 `json:"maxMessageSize"`
	StorageQuota     uint64 `json:"storageQuota"`
	SlashPercent     uint64 `json:"slashPercent"`
	RewardPerMessage uint64 `json:"rewardPerMessage"`
}

GetNetworkParamsReply is the reply from GetNetworkParams

type GetNodeArgs

type GetNodeArgs struct {
	NodeID string `json:"nodeID"`
}

GetNodeArgs are the arguments to GetNode

type GetNodeReply

type GetNodeReply struct {
	NodeID           string `json:"nodeID"`
	PublicKey        string `json:"publicKey"`
	State            string `json:"state"`
	StakeAmount      uint64 `json:"stakeAmount"`
	StakeLockEnd     uint64 `json:"stakeLockEnd"`
	UptimeScore      uint64 `json:"uptimeScore"`
	ChallengesPassed uint64 `json:"challengesPassed"`
	ChallengesFailed uint64 `json:"challengesFailed"`
	PendingRewards   uint64 `json:"pendingRewards"`
	TotalRewards     uint64 `json:"totalRewards"`
	RegisteredAt     int64  `json:"registeredAt"`
	LastActiveAt     int64  `json:"lastActiveAt"`
}

GetNodeReply is the reply from GetNode

type GetSwarmForAccountArgs

type GetSwarmForAccountArgs struct {
	AccountID string `json:"accountID"` // Hex-encoded account ID hash
}

GetSwarmForAccountArgs are the arguments to GetSwarmForAccount

type GetSwarmForAccountReply

type GetSwarmForAccountReply struct {
	SwarmID uint64   `json:"swarmID"`
	Nodes   []string `json:"nodes"`
	EpochID uint64   `json:"epochID"`
}

GetSwarmForAccountReply is the reply from GetSwarmForAccount

type HealthArgs

type HealthArgs struct{}

HealthArgs are the arguments to Health

type HealthReply

type HealthReply struct {
	Healthy     bool   `json:"healthy"`
	ActiveNodes uint32 `json:"activeNodes"`
	MinRequired uint32 `json:"minRequired"`
}

HealthReply is the reply from Health

type RegisterArgs

type RegisterArgs struct {
	NodeID       string `json:"nodeID"`
	PublicKey    string `json:"publicKey"`    // Hex-encoded
	EndpointHash string `json:"endpointHash"` // Hex-encoded
	StakeAmount  uint64 `json:"stakeAmount"`
	StakeLockEnd uint64 `json:"stakeLockEnd"` // Unix timestamp
	Signature    string `json:"signature"`    // Hex-encoded
}

RegisterArgs are the arguments to Register

type RegisterReply

type RegisterReply struct {
	NodeID    string `json:"nodeID"`
	State     string `json:"state"`
	Timestamp int64  `json:"timestamp"`
}

RegisterReply is the reply from Register

type RegistrationTx

type RegistrationTx struct {
	NodeID       ids.NodeID `json:"nodeID"`
	PublicKey    []byte     `json:"publicKey"`
	EndpointHash [32]byte   `json:"endpointHash"`
	StakeAmount  uint64     `json:"stakeAmount"`
	StakeLockEnd uint64     `json:"stakeLockEnd"`
	Signature    []byte     `json:"signature"`
}

RegistrationTx represents a service node registration transaction

type Registry

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

Registry manages service node registration and state

func NewRegistry

func NewRegistry(db database.Database, config *Config) *Registry

NewRegistry creates a new service node registry

func (*Registry) Activate

func (r *Registry) Activate(ctx context.Context, nodeID ids.NodeID) error

Activate activates a registered service node

func (*Registry) AddReward

func (r *Registry) AddReward(ctx context.Context, nodeID ids.NodeID, amount uint64) error

AddReward adds pending rewards to a node

func (*Registry) ClaimRewards

func (r *Registry) ClaimRewards(ctx context.Context, nodeID ids.NodeID) (uint64, error)

ClaimRewards claims and resets pending rewards

func (*Registry) ComputeRegistryRoot

func (r *Registry) ComputeRegistryRoot() [32]byte

ComputeRegistryRoot computes the Merkle root of the registry

func (*Registry) Deactivate

func (r *Registry) Deactivate(ctx context.Context, nodeID ids.NodeID) error

Deactivate deactivates a service node (starts exit process)

func (*Registry) Exit

func (r *Registry) Exit(ctx context.Context, nodeID ids.NodeID) error

Exit completes the exit process for a node

func (*Registry) Get

func (r *Registry) Get(nodeID ids.NodeID) (*ServiceNode, error)

Get retrieves a service node by node ID

func (*Registry) GetActiveNodeCount

func (r *Registry) GetActiveNodeCount() uint32

GetActiveNodeCount returns the count of active nodes

func (*Registry) GetActiveNodeIDs

func (r *Registry) GetActiveNodeIDs() []ids.NodeID

GetActiveNodeIDs returns the IDs of all active service nodes

func (*Registry) GetActiveNodes

func (r *Registry) GetActiveNodes() []*ServiceNode

GetActiveNodes returns all active service nodes

func (*Registry) GetByPublicKey

func (r *Registry) GetByPublicKey(publicKey []byte) (*ServiceNode, error)

GetByPublicKey retrieves a service node by public key

func (*Registry) Jail

func (r *Registry) Jail(ctx context.Context, nodeID ids.NodeID, reason string) error

Jail jails a service node for misbehavior

func (*Registry) Load

func (r *Registry) Load(ctx context.Context) error

Load loads the registry state from the database

func (*Registry) Register

func (r *Registry) Register(ctx context.Context, tx *RegistrationTx) (*ServiceNode, error)

Register registers a new service node

func (*Registry) Slash

func (r *Registry) Slash(ctx context.Context, nodeID ids.NodeID, amount uint64) error

Slash slashes stake from a misbehaving node

func (*Registry) UpdateUptime

func (r *Registry) UpdateUptime(ctx context.Context, nodeID ids.NodeID, passed bool) error

UpdateUptime updates the uptime metrics for a node

type Service

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

Service provides RPC endpoints for the ServiceNodeVM

func (*Service) Activate

func (s *Service) Activate(r *http.Request, args *ActivateArgs, reply *ActivateReply) error

Activate activates a registered service node

func (*Service) Deactivate

func (s *Service) Deactivate(r *http.Request, args *DeactivateArgs, reply *DeactivateReply) error

Deactivate starts the exit process for a service node

func (*Service) GetActiveNodes

func (s *Service) GetActiveNodes(r *http.Request, args *GetActiveNodesArgs, reply *GetActiveNodesReply) error

GetActiveNodes returns all active service node IDs

func (*Service) GetNetworkParams

func (s *Service) GetNetworkParams(r *http.Request, args *GetNetworkParamsArgs, reply *GetNetworkParamsReply) error

GetNetworkParams returns network parameters

func (*Service) GetNode

func (s *Service) GetNode(r *http.Request, args *GetNodeArgs, reply *GetNodeReply) error

GetNode retrieves a service node by ID

func (*Service) GetSwarmForAccount

func (s *Service) GetSwarmForAccount(r *http.Request, args *GetSwarmForAccountArgs, reply *GetSwarmForAccountReply) error

GetSwarmForAccount returns the swarm assignment for an account

func (*Service) Health

func (s *Service) Health(r *http.Request, args *HealthArgs, reply *HealthReply) error

Health returns the health status

func (*Service) Register

func (s *Service) Register(r *http.Request, args *RegisterArgs, reply *RegisterReply) error

Register registers a new service node

func (*Service) SubmitStorageCommitment

func (s *Service) SubmitStorageCommitment(r *http.Request, args *SubmitStorageCommitmentArgs, reply *SubmitStorageCommitmentReply) error

SubmitStorageCommitment submits a storage commitment

func (*Service) SubmitUptimeProof

func (s *Service) SubmitUptimeProof(r *http.Request, args *SubmitUptimeProofArgs, reply *SubmitUptimeProofReply) error

SubmitUptimeProof submits an uptime proof

type ServiceNode

type ServiceNode struct {
	// Identity
	ID        ids.ID     `json:"id"`
	NodeID    ids.NodeID `json:"nodeID"`
	PublicKey []byte     `json:"publicKey"`

	// Contact info (hashed for privacy)
	EndpointHash [32]byte `json:"endpointHash"`

	// Stake
	StakeAmount  uint64 `json:"stakeAmount"`
	StakeLockEnd uint64 `json:"stakeLockEnd"` // Unix timestamp

	// State
	State       string    `json:"state"`
	JailReason  string    `json:"jailReason,omitempty"`
	JailedAt    time.Time `json:"jailedAt,omitempty"`
	JailRelease uint64    `json:"jailRelease,omitempty"` // Unix timestamp

	// Registration
	RegisteredAt   time.Time `json:"registeredAt"`
	LastActiveAt   time.Time `json:"lastActiveAt"`
	ActivationTime uint64    `json:"activationTime"` // Unix timestamp when became active

	// Performance metrics
	UptimeScore      uint64 `json:"uptimeScore"` // 0-10000 (basis points)
	ChallengesPassed uint64 `json:"challengesPassed"`
	ChallengesFailed uint64 `json:"challengesFailed"`
	MessagesRelayed  uint64 `json:"messagesRelayed"`

	// Rewards
	PendingRewards uint64 `json:"pendingRewards"`
	TotalRewards   uint64 `json:"totalRewards"`
}

ServiceNode represents a registered service node

func (*ServiceNode) CanReceiveMessages

func (sn *ServiceNode) CanReceiveMessages() bool

CanReceiveMessages returns whether the node can receive messages

func (*ServiceNode) Hash

func (sn *ServiceNode) Hash() [32]byte

Hash returns a deterministic hash of the service node

func (*ServiceNode) IsActive

func (sn *ServiceNode) IsActive() bool

IsActive returns whether the node is in active state

type SlashTx

type SlashTx struct {
	NodeID      ids.NodeID `json:"nodeID"`
	Reason      string     `json:"reason"`
	Evidence    []byte     `json:"evidence"`
	SlashAmount uint64     `json:"slashAmount"`
	Timestamp   time.Time  `json:"timestamp"`
}

SlashTx represents a slashing transaction for misbehavior

type StorageCommitment

type StorageCommitment struct {
	NodeID       ids.NodeID `json:"nodeID"`
	EpochID      uint64     `json:"epochID"`
	StoreRoot    [32]byte   `json:"storeRoot"` // Merkle root of stored messages
	MessageCount uint64     `json:"messageCount"`
	TotalSize    uint64     `json:"totalSize"`
	Timestamp    time.Time  `json:"timestamp"`
	Signature    []byte     `json:"signature"`
}

StorageCommitment represents a commitment to stored data

func (*StorageCommitment) Hash

func (sc *StorageCommitment) Hash() [32]byte

Hash returns a deterministic hash of the storage commitment

type StoredMessage

type StoredMessage struct {
	ID          ids.ID    `json:"id"`
	RecipientID [32]byte  `json:"recipientID"` // Account ID hash
	SenderID    [32]byte  `json:"senderID"`    // Account ID hash (encrypted)
	SwarmID     uint64    `json:"swarmID"`
	Payload     []byte    `json:"payload"` // Encrypted message content
	TTL         uint64    `json:"ttl"`     // Seconds
	CreatedAt   time.Time `json:"createdAt"`
	ExpiresAt   time.Time `json:"expiresAt"`
	Size        uint64    `json:"size"`
	Delivered   bool      `json:"delivered"`
	DeliveredAt time.Time `json:"deliveredAt,omitempty"`
}

StoredMessage represents a message stored in the inbox

func (*StoredMessage) Hash

func (m *StoredMessage) Hash() [32]byte

Hash returns a deterministic hash of the message

func (*StoredMessage) IsExpired

func (m *StoredMessage) IsExpired() bool

IsExpired returns whether the message has expired

type SubmitStorageCommitmentArgs

type SubmitStorageCommitmentArgs struct {
	NodeID       string `json:"nodeID"`
	EpochID      uint64 `json:"epochID"`
	StoreRoot    string `json:"storeRoot"` // Hex-encoded
	MessageCount uint64 `json:"messageCount"`
	TotalSize    uint64 `json:"totalSize"`
	Signature    string `json:"signature"` // Hex-encoded
}

SubmitStorageCommitmentArgs are the arguments to SubmitStorageCommitment

type SubmitStorageCommitmentReply

type SubmitStorageCommitmentReply struct {
	Success bool `json:"success"`
}

SubmitStorageCommitmentReply is the reply from SubmitStorageCommitment

type SubmitUptimeProofArgs

type SubmitUptimeProofArgs struct {
	NodeID      string `json:"nodeID"`
	EpochID     uint64 `json:"epochID"`
	BlockHeight uint64 `json:"blockHeight"`
	Signature   string `json:"signature"` // Hex-encoded
}

SubmitUptimeProofArgs are the arguments to SubmitUptimeProof

type SubmitUptimeProofReply

type SubmitUptimeProofReply struct {
	Success bool `json:"success"`
}

SubmitUptimeProofReply is the reply from SubmitUptimeProof

type Swarm

type Swarm struct {
	ID         uint64       `json:"id"`
	EpochID    uint64       `json:"epochID"`
	NodeIDs    []ids.NodeID `json:"nodeIDs"`
	AccountIDs [][32]byte   `json:"accountIDs"` // Account ID hashes assigned to this swarm
}

Swarm represents a group of service nodes serving a set of accounts

func (*Swarm) ContainsNode

func (s *Swarm) ContainsNode(nodeID ids.NodeID) bool

ContainsNode returns whether the swarm contains the given node

func (*Swarm) Hash

func (s *Swarm) Hash() [32]byte

Hash returns a deterministic hash of the swarm

type UptimeProof

type UptimeProof struct {
	NodeID      ids.NodeID `json:"nodeID"`
	EpochID     uint64     `json:"epochID"`
	BlockHeight uint64     `json:"blockHeight"`
	Timestamp   time.Time  `json:"timestamp"`
	Signature   []byte     `json:"signature"`
}

UptimeProof represents a signed proof of uptime

func (*UptimeProof) Hash

func (p *UptimeProof) Hash() [32]byte

Hash returns a deterministic hash of the uptime proof

type VM

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

VM implements the ServiceNodeVM for private messaging infrastructure

func (*VM) ActivateServiceNode

func (vm *VM) ActivateServiceNode(ctx context.Context, nodeID ids.NodeID) error

ActivateServiceNode activates a registered service node

func (*VM) BuildBlock

func (vm *VM) BuildBlock(ctx context.Context) (chain.Block, error)

BuildBlock implements chain.ChainVM

func (*VM) Connected

func (vm *VM) Connected(ctx context.Context, nodeID ids.NodeID, nodeVersion *chain.VersionInfo) error

Connected implements chain.ChainVM

func (*VM) CreateHandlers

func (vm *VM) CreateHandlers(ctx context.Context) (map[string]http.Handler, error)

CreateHandlers implements chain.ChainVM

func (*VM) DeactivateServiceNode

func (vm *VM) DeactivateServiceNode(ctx context.Context, nodeID ids.NodeID) error

DeactivateServiceNode starts the exit process for a service node

func (*VM) Disconnected

func (vm *VM) Disconnected(ctx context.Context, nodeID ids.NodeID) error

Disconnected implements chain.ChainVM

func (*VM) GetActiveServiceNodes

func (vm *VM) GetActiveServiceNodes() []*ServiceNode

GetActiveServiceNodes returns all active service nodes

func (*VM) GetBlock

func (vm *VM) GetBlock(ctx context.Context, blockID ids.ID) (chain.Block, error)

GetBlock implements chain.ChainVM

func (*VM) GetBlockIDAtHeight

func (vm *VM) GetBlockIDAtHeight(ctx context.Context, height uint64) (ids.ID, error)

GetBlockIDAtHeight implements chain.HeightIndexedChainVM

func (*VM) GetConfig

func (vm *VM) GetConfig() *Config

GetConfig returns the VM configuration

func (*VM) GetRegistry

func (vm *VM) GetRegistry() *Registry

GetRegistry returns the service node registry

func (*VM) GetServiceNode

func (vm *VM) GetServiceNode(nodeID ids.NodeID) (*ServiceNode, error)

GetServiceNode retrieves a service node by ID

func (*VM) HealthCheck

func (vm *VM) HealthCheck(ctx context.Context) (*chain.HealthResult, error)

HealthCheck implements chain.ChainVM

func (*VM) Initialize

func (vm *VM) Initialize(
	ctx context.Context,
	vmInit vmcore.Init,
) error

Initialize implements chain.ChainVM

func (*VM) LastAccepted

func (vm *VM) LastAccepted(ctx context.Context) (ids.ID, error)

LastAccepted implements chain.ChainVM

func (*VM) NewHTTPHandler

func (vm *VM) NewHTTPHandler(ctx context.Context) (http.Handler, error)

NewHTTPHandler implements chain.ChainVM

func (*VM) ParseBlock

func (vm *VM) ParseBlock(ctx context.Context, blockBytes []byte) (chain.Block, error)

ParseBlock implements chain.ChainVM

func (*VM) RegisterServiceNode

func (vm *VM) RegisterServiceNode(ctx context.Context, tx *RegistrationTx) (*ServiceNode, error)

RegisterServiceNode registers a new service node

func (*VM) SetPreference

func (vm *VM) SetPreference(ctx context.Context, blockID ids.ID) error

SetPreference implements chain.ChainVM

func (*VM) SetState

func (vm *VM) SetState(ctx context.Context, state uint32) error

SetState implements chain.ChainVM

func (*VM) Shutdown

func (vm *VM) Shutdown(ctx context.Context) error

Shutdown implements chain.ChainVM

func (*VM) SubmitStorageCommitment

func (vm *VM) SubmitStorageCommitment(ctx context.Context, commit *StorageCommitment) error

SubmitStorageCommitment submits a storage commitment

func (*VM) SubmitUptimeProof

func (vm *VM) SubmitUptimeProof(ctx context.Context, proof *UptimeProof) error

SubmitUptimeProof submits an uptime proof

func (*VM) Version

func (vm *VM) Version(ctx context.Context) (string, error)

Version implements chain.ChainVM

func (*VM) WaitForEvent

func (vm *VM) WaitForEvent(ctx context.Context) (vmcore.Message, error)

WaitForEvent implements chain.ChainVM

Directories

Path Synopsis
Package challenge implements the uptime challenge and incentive system for service nodes.
Package challenge implements the uptime challenge and incentive system for service nodes.
Package daemon implements the store-and-forward inbox for service nodes.
Package daemon implements the store-and-forward inbox for service nodes.
Package epoch provides deterministic epoch coordination and swarm assignment for the service node network.
Package epoch provides deterministic epoch coordination and swarm assignment for the service node network.
Package storage implements provable storage availability commitments for service nodes.
Package storage implements provable storage availability commitments for service nodes.

Jump to

Keyboard shortcuts

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