threefold.grid4.datamodel #
Grid4 Data Model
This module defines data models for nodes, groups, and slices in a cloud/grid infrastructure. Each root object is marked with @[heap]
and can be indexed for efficient querying.
Root Objects Overview
Object | Description | Index Fields |
---|---|---|
Node |
Represents a single node in the grid | id , nodegroupid , country |
NodeGroup |
Represents a group of nodes owned by a farmer | id , farmerid |
Node
Represents a single node in the grid with slices, devices, and capacity.
Field | Type | Description | Indexed |
---|---|---|---|
id |
int |
Unique node ID | ✅ |
nodegroupid |
int |
ID of the owning node group | ✅ |
uptime |
int |
Uptime percentage (0-100) | ✅ |
computeslices |
[]ComputeSlice |
List of compute slices | ❌ |
storageslices |
[]StorageSlice |
List of storage slices | ❌ |
devices |
DeviceInfo |
Hardware device info (storage, memory, etc.) | ❌ |
country |
string |
2-letter country code | ✅ |
capacity |
NodeCapacity |
Aggregated hardware capacity | ❌ |
provisiontime |
u32 |
Provisioning time (simple/compatible format) | ✅ |
NodeGroup
Represents a group of nodes owned by a farmer, with policies.
Field | Type | Description | Indexed |
---|---|---|---|
id |
u32 |
Unique group ID | ✅ |
farmerid |
u32 |
Farmer/user ID | ✅ |
secret |
string |
Encrypted secret for booting nodes | ❌ |
description |
string |
Group description | ❌ |
slapolicy |
SLAPolicy |
SLA policy details | ❌ |
pricingpolicy |
PricingPolicy |
Pricing policy details | ❌ |
compute_slice_normalized_pricing_cc |
f64 |
Pricing per 2GB compute slice in cloud credits | ❌ |
storage_slice_normalized_pricing_cc |
f64 |
Pricing per 1GB storage slice in cloud credits | ❌ |
reputation |
int |
Reputation (0-100) | ✅ |
uptime |
int |
Uptime (0-100) | ✅ |
ComputeSlice
Represents a compute slice (e.g., 1GB memory unit).
Field | Type | Description |
---|---|---|
nodeid |
u32 |
Owning node ID |
id |
int |
Slice ID in node |
mem_gb |
f64 |
Memory in GB |
storage_gb |
f64 |
Storage in GB |
passmark |
int |
Passmark score |
vcores |
int |
Virtual cores |
cpu_oversubscription |
int |
CPU oversubscription ratio |
storage_oversubscription |
int |
Storage oversubscription ratio |
price_range |
[]f64 |
Price range [min, max] |
gpus |
u8 |
Number of GPUs |
price_cc |
f64 |
Price per slice in cloud credits |
pricing_policy |
PricingPolicy |
Pricing policy |
sla_policy |
SLAPolicy |
SLA policy |
StorageSlice
Represents a 1GB storage slice.
Field | Type | Description |
---|---|---|
nodeid |
u32 |
Owning node ID |
id |
int |
Slice ID in node |
price_cc |
f64 |
Price per slice in cloud credits |
pricing_policy |
PricingPolicy |
Pricing policy |
sla_policy |
SLAPolicy |
SLA policy |
DeviceInfo
Hardware device information for a node.
Field | Type | Description |
---|---|---|
vendor |
string |
Vendor of the node |
storage |
[]StorageDevice |
List of storage devices |
memory |
[]MemoryDevice |
List of memory devices |
cpu |
[]CPUDevice |
List of CPU devices |
gpu |
[]GPUDevice |
List of GPU devices |
network |
[]NetworkDevice |
List of network devices |
StorageDevice
Field | Type | Description |
---|---|---|
id |
string |
Unique ID for device |
size_gb |
f64 |
Size in GB |
description |
string |
Description of device |
MemoryDevice
Field | Type | Description |
---|---|---|
id |
string |
Unique ID for device |
size_gb |
f64 |
Size in GB |
description |
string |
Description of device |
CPUDevice
Field | Type | Description |
---|---|---|
id |
string |
Unique ID for device |
cores |
int |
Number of CPU cores |
passmark |
int |
Passmark benchmark score |
description |
string |
Description of device |
cpu_brand |
string |
Brand of the CPU |
cpu_version |
string |
Version of the CPU |
GPUDevice
Field | Type | Description |
---|---|---|
id |
string |
Unique ID for device |
cores |
int |
Number of GPU cores |
memory_gb |
f64 |
GPU memory in GB |
description |
string |
Description of device |
gpu_brand |
string |
Brand of the GPU |
gpu_version |
string |
Version of the GPU |
NetworkDevice
Field | Type | Description |
---|---|---|
id |
string |
Unique ID for device |
speed_mbps |
int |
Network speed in Mbps |
description |
string |
Description of device |
NodeCapacity
Aggregated hardware capacity for a node.
Field | Type | Description |
---|---|---|
storage_gb |
f64 |
Total storage in GB |
mem_gb |
f64 |
Total memory in GB |
mem_gb_gpu |
f64 |
Total GPU memory in GB |
passmark |
int |
Total passmark score |
vcores |
int |
Total virtual cores |
SLAPolicy
Service Level Agreement policy for slices or node groups.
Field | Type | Description |
---|---|---|
sla_uptime |
int |
Required uptime % (e.g., 90) |
sla_bandwidth_mbit |
int |
Guaranteed bandwidth in Mbps (0 = none) |
sla_penalty |
int |
Penalty % if SLA is breached (0-100) |
PricingPolicy
Pricing policy for slices or node groups.
Field | Type | Description |
---|---|---|
marketplace_year_discounts |
[]int |
Discounts for 1Y, 2Y, 3Y prepaid usage (e.g. [30,40,50]) |
volume_discounts |
[]int |
Volume discounts based on purchase size (e.g. [10,20,30]) |
fn play #
fn play(mut plbook PlayBook) !map[string]&Node
this play script should never be called from hero directly its called by gridsimulator
enum BidStatus #
enum BidStatus {
pending
confirmed
assigned
cancelled
done
}
enum ReservationStatus #
enum ReservationStatus {
pending
confirmed
assigned
cancelled
done
}
struct Bid #
struct Bid {
pub mut:
id u32
customer_id u32 // links back to customer for this capacity (user on ledger)
compute_slices_nr int // nr of slices I need in 1 machine
compute_slice f64 // price per 1 GB slice I want to accept
storage_slices []u32
status BidStatus
obligation bool // if obligation then will be charged and money needs to be in escrow, otherwise its an intent
start_date u32 // epoch
end_date u32
}
I can bid for infra, and optionally get accepted
struct CPUDevice #
struct CPUDevice {
pub mut:
id string // can be used in node
cores int // Number of CPU cores
passmark int
description string // Description of the CPU
cpu_brand string // Brand of the CPU
cpu_version string // Version of the CPU
}
struct ComputeSlice #
struct ComputeSlice {
pub mut:
nodeid u32 // the node in the grid, there is an object describing the node
id int // the id of the slice in the node
mem_gb f64
storage_gb f64
passmark int
vcores int
cpu_oversubscription int
storage_oversubscription int
price_range []f64 = [0.0, 0.0]
gpus u8 // nr of GPU's see node to know what GPU's are
price_cc f64 // price per slice (even if the grouped one)
pricing_policy PricingPolicy
sla_policy SLAPolicy
}
typically 1GB of memory, but can be adjusted based based on size of machine
struct DeviceInfo #
struct DeviceInfo {
pub mut:
vendor string
storage []StorageDevice
memory []MemoryDevice
cpu []CPUDevice
gpu []GPUDevice
network []NetworkDevice
}
struct GPUDevice #
struct GPUDevice {
pub mut:
id string // can be used in node
cores int // Number of GPU cores
memory_gb f64 // Size of the GPU memory in gigabytes
description string // Description of the GPU
gpu_brand string
gpu_version string
}
struct MemoryDevice #
struct MemoryDevice {
pub mut:
id string // can be used in node
size_gb f64 // Size of the memory device in gigabytes
description string // Description of the memory device
}
struct NetworkDevice #
struct NetworkDevice {
pub mut:
id string // can be used in node
speed_mbps int // Network speed in Mbps
description string // Description of the network device
}
struct Node #
struct Node {
pub mut:
id int
nodegroupid int
uptime int // 0..100
computeslices []ComputeSlice
storageslices []StorageSlice
devices DeviceInfo
country string // 2 letter code as specified in lib/data/countries/data/countryInfo.txt, use that library for validation
capacity NodeCapacity // Hardware capacity details
provisiontime u32 // lets keep it simple and compatible
pubkey string
signature_node string // signature done on node to validate pubkey with privkey
signature_farmer string // signature as done by farmers to validate their identity
}
struct NodeCapacity #
struct NodeCapacity {
pub mut:
storage_gb f64 // Total storage in gigabytes
mem_gb f64 // Total memory in gigabytes
mem_gb_gpu f64 // Total GPU memory in gigabytes
passmark int // Passmark score for the node
vcores int // Total virtual cores
}
NodeCapacity represents the hardware capacity details of a node.
struct NodeGroup #
struct NodeGroup {
pub mut:
id u32
farmerid u32 // link back to farmer who owns the nodegroup, is a user?
secret string // only visible by farmer, in future encrypted, used to boot a node
description string
slapolicy SLAPolicy
pricingpolicy PricingPolicy
compute_slice_normalized_pricing_cc f64 // pricing in CC - cloud credit, per 2GB node slice
storage_slice_normalized_pricing_cc f64 // pricing in CC - cloud credit, per 1GB storage slice
reputation int = 50 // between 0 and 100, earned over time
uptime int // between 0 and 100, set by system, farmer has no ability to set this
}
is a root object, is the only obj farmer needs to configure in the UI, this defines how slices will be created
struct PricingPolicy #
struct PricingPolicy {
pub mut:
marketplace_year_discounts []int = [30, 40, 50] // e.g. 30,40,50 means if user has more CC in wallet than 1 year utilization on all his purchaes then this provider gives 30%, 2Y 40%, ...
volume_discounts []int = [10, 20, 30] // e.g. 10,20,30
}
struct Reservation #
struct Reservation {
pub mut:
id u32
customer_id u32 // links back to customer for this capacity
compute_slices []u32
storage_slices []u32
status ReservationStatus
start_date u32 // epoch
end_date u32
}
struct SLAPolicy #
struct SLAPolicy {
pub mut:
sla_uptime int // should +90
sla_bandwidth_mbit int // minimal mbits we can expect avg over 1h per node, 0 means we don't guarantee
sla_penalty int // 0-100, percent of money given back in relation to month if sla breached, e.g. 200 means we return 2 months worth of rev if sla missed
}
struct StorageDevice #
struct StorageDevice {
pub mut:
id string // can be used in node
size_gb f64 // Size of the storage device in gigabytes
description string // Description of the storage device
}
struct StorageSlice #
struct StorageSlice {
pub mut:
nodeid u32 // the node in the grid
id int // the id of the slice in the node, are tracked in the node itself
price_cc f64 // price per slice (even if the grouped one)
pricing_policy PricingPolicy
sla_policy SLAPolicy
}
1GB of storage
- README
- fn play
- enum BidStatus
- enum ReservationStatus
- struct Bid
- struct CPUDevice
- struct ComputeSlice
- struct DeviceInfo
- struct GPUDevice
- struct MemoryDevice
- struct NetworkDevice
- struct Node
- struct NodeCapacity
- struct NodeGroup
- struct PricingPolicy
- struct Reservation
- struct SLAPolicy
- struct StorageDevice
- struct StorageSlice