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
- Variables
- type ActivateArgs
- type ActivateReply
- type Block
- func (b *Block) Accept(ctx context.Context) error
- func (b *Block) Bytes() []byte
- func (b *Block) Hash() [32]byte
- func (b *Block) Height() uint64
- func (b *Block) ID() ids.ID
- func (b *Block) Parent() ids.ID
- func (b *Block) ParentID() ids.ID
- func (b *Block) Reject(ctx context.Context) error
- func (b *Block) SetStatus(status choices.Status)
- func (b *Block) SetVM(vm interface{})
- func (b *Block) Status() uint8
- func (b *Block) Timestamp() time.Time
- func (b *Block) Verify(ctx context.Context) error
- type Challenge
- type ChallengeResponse
- type Config
- type DeactivateArgs
- type DeactivateReply
- type Epoch
- type ExitTx
- type Factory
- type Genesis
- type GenesisNode
- type GetActiveNodesArgs
- type GetActiveNodesReply
- type GetNetworkParamsArgs
- type GetNetworkParamsReply
- type GetNodeArgs
- type GetNodeReply
- type GetSwarmForAccountArgs
- type GetSwarmForAccountReply
- type HealthArgs
- type HealthReply
- type RegisterArgs
- type RegisterReply
- type RegistrationTx
- type Registry
- func (r *Registry) Activate(ctx context.Context, nodeID ids.NodeID) error
- func (r *Registry) AddReward(ctx context.Context, nodeID ids.NodeID, amount uint64) error
- func (r *Registry) ClaimRewards(ctx context.Context, nodeID ids.NodeID) (uint64, error)
- func (r *Registry) ComputeRegistryRoot() [32]byte
- func (r *Registry) Deactivate(ctx context.Context, nodeID ids.NodeID) error
- func (r *Registry) Exit(ctx context.Context, nodeID ids.NodeID) error
- func (r *Registry) Get(nodeID ids.NodeID) (*ServiceNode, error)
- func (r *Registry) GetActiveNodeCount() uint32
- func (r *Registry) GetActiveNodeIDs() []ids.NodeID
- func (r *Registry) GetActiveNodes() []*ServiceNode
- func (r *Registry) GetByPublicKey(publicKey []byte) (*ServiceNode, error)
- func (r *Registry) Jail(ctx context.Context, nodeID ids.NodeID, reason string) error
- func (r *Registry) Load(ctx context.Context) error
- func (r *Registry) Register(ctx context.Context, tx *RegistrationTx) (*ServiceNode, error)
- func (r *Registry) Slash(ctx context.Context, nodeID ids.NodeID, amount uint64) error
- func (r *Registry) UpdateUptime(ctx context.Context, nodeID ids.NodeID, passed bool) error
- type Service
- func (s *Service) Activate(r *http.Request, args *ActivateArgs, reply *ActivateReply) error
- func (s *Service) Deactivate(r *http.Request, args *DeactivateArgs, reply *DeactivateReply) error
- func (s *Service) GetActiveNodes(r *http.Request, args *GetActiveNodesArgs, reply *GetActiveNodesReply) error
- func (s *Service) GetNetworkParams(r *http.Request, args *GetNetworkParamsArgs, reply *GetNetworkParamsReply) error
- func (s *Service) GetNode(r *http.Request, args *GetNodeArgs, reply *GetNodeReply) error
- func (s *Service) GetSwarmForAccount(r *http.Request, args *GetSwarmForAccountArgs, reply *GetSwarmForAccountReply) error
- func (s *Service) Health(r *http.Request, args *HealthArgs, reply *HealthReply) error
- func (s *Service) Register(r *http.Request, args *RegisterArgs, reply *RegisterReply) error
- func (s *Service) SubmitStorageCommitment(r *http.Request, args *SubmitStorageCommitmentArgs, ...) error
- func (s *Service) SubmitUptimeProof(r *http.Request, args *SubmitUptimeProofArgs, reply *SubmitUptimeProofReply) error
- type ServiceNode
- type SlashTx
- type StorageCommitment
- type StoredMessage
- type SubmitStorageCommitmentArgs
- type SubmitStorageCommitmentReply
- type SubmitUptimeProofArgs
- type SubmitUptimeProofReply
- type Swarm
- type UptimeProof
- type VM
- func (vm *VM) ActivateServiceNode(ctx context.Context, nodeID ids.NodeID) error
- func (vm *VM) BuildBlock(ctx context.Context) (chain.Block, error)
- func (vm *VM) Connected(ctx context.Context, nodeID ids.NodeID, nodeVersion *chain.VersionInfo) error
- func (vm *VM) CreateHandlers(ctx context.Context) (map[string]http.Handler, error)
- func (vm *VM) DeactivateServiceNode(ctx context.Context, nodeID ids.NodeID) error
- func (vm *VM) Disconnected(ctx context.Context, nodeID ids.NodeID) error
- func (vm *VM) GetActiveServiceNodes() []*ServiceNode
- func (vm *VM) GetBlock(ctx context.Context, blockID ids.ID) (chain.Block, error)
- func (vm *VM) GetBlockIDAtHeight(ctx context.Context, height uint64) (ids.ID, error)
- func (vm *VM) GetConfig() *Config
- func (vm *VM) GetRegistry() *Registry
- func (vm *VM) GetServiceNode(nodeID ids.NodeID) (*ServiceNode, error)
- func (vm *VM) HealthCheck(ctx context.Context) (*chain.HealthResult, error)
- func (vm *VM) Initialize(ctx context.Context, vmInit vmcore.Init) error
- func (vm *VM) LastAccepted(ctx context.Context) (ids.ID, error)
- func (vm *VM) NewHTTPHandler(ctx context.Context) (http.Handler, error)
- func (vm *VM) ParseBlock(ctx context.Context, blockBytes []byte) (chain.Block, error)
- func (vm *VM) RegisterServiceNode(ctx context.Context, tx *RegistrationTx) (*ServiceNode, error)
- func (vm *VM) SetPreference(ctx context.Context, blockID ids.ID) error
- func (vm *VM) SetState(ctx context.Context, state uint32) error
- func (vm *VM) Shutdown(ctx context.Context) error
- func (vm *VM) SubmitStorageCommitment(ctx context.Context, commit *StorageCommitment) error
- func (vm *VM) SubmitUptimeProof(ctx context.Context, proof *UptimeProof) error
- func (vm *VM) Version(ctx context.Context) (string, error)
- func (vm *VM) WaitForEvent(ctx context.Context) (vmcore.Message, error)
Constants ¶
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
const ( StateRegistered = "registered" StateActive = "active" StateJailed = "jailed" StateExiting = "exiting" StateExited = "exited" )
Service node states
const ( ChallengeTypeUptime = "uptime" ChallengeTypeStorage = "storage" ChallengeTypeRelay = "relay" )
Challenge response types
const (
Name = "servicenodevm"
)
Variables ¶
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
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
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
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
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
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 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 ¶
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 ¶
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 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 ¶
NewRegistry creates a new service node registry
func (*Registry) ClaimRewards ¶
ClaimRewards claims and resets pending rewards
func (*Registry) ComputeRegistryRoot ¶
ComputeRegistryRoot computes the Merkle root of the registry
func (*Registry) Deactivate ¶
Deactivate deactivates a service node (starts exit process)
func (*Registry) Get ¶
func (r *Registry) Get(nodeID ids.NodeID) (*ServiceNode, error)
Get retrieves a service node by node ID
func (*Registry) GetActiveNodeCount ¶
GetActiveNodeCount returns the count of active nodes
func (*Registry) GetActiveNodeIDs ¶
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) Register ¶
func (r *Registry) Register(ctx context.Context, tx *RegistrationTx) (*ServiceNode, error)
Register registers a new service 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 ¶
ContainsNode returns whether the swarm contains the given node
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 ¶
ActivateServiceNode activates a registered service node
func (*VM) BuildBlock ¶
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 ¶
CreateHandlers implements chain.ChainVM
func (*VM) DeactivateServiceNode ¶
DeactivateServiceNode starts the exit process for a service node
func (*VM) Disconnected ¶
Disconnected implements chain.ChainVM
func (*VM) GetActiveServiceNodes ¶
func (vm *VM) GetActiveServiceNodes() []*ServiceNode
GetActiveServiceNodes returns all active service nodes
func (*VM) GetBlockIDAtHeight ¶
GetBlockIDAtHeight implements chain.HeightIndexedChainVM
func (*VM) GetRegistry ¶
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 ¶
HealthCheck implements chain.ChainVM
func (*VM) Initialize ¶
Initialize implements chain.ChainVM
func (*VM) LastAccepted ¶
LastAccepted implements chain.ChainVM
func (*VM) NewHTTPHandler ¶
NewHTTPHandler implements chain.ChainVM
func (*VM) ParseBlock ¶
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 ¶
SetPreference 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
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. |