forked from ghe0/brain-to-surreal
Compare commits
4 Commits
app_data_i
...
master
Author | SHA1 | Date | |
---|---|---|---|
363724e5d7 | |||
6a99c146ce | |||
d9f4df2c3d | |||
ee75412bb0 |
@ -1,10 +1,11 @@
|
|||||||
DEFINE TABLE account SCHEMAFULL;
|
DEFINE TABLE account SCHEMAFULL;
|
||||||
DEFINE FIELD balance ON TABLE account TYPE int;
|
DEFINE FIELD balance ON TABLE account TYPE int DEFAULT 0;
|
||||||
DEFINE FIELD tmp_locked ON TABLE account TYPE int;
|
DEFINE FIELD tmp_locked ON TABLE account TYPE int DEFAULT 0;
|
||||||
DEFINE FIELD escrow ON TABLE account TYPE int;
|
DEFINE FIELD escrow ON TABLE account TYPE int DEFAULT 0;
|
||||||
DEFINE FIELD email ON TABLE account TYPE string;
|
DEFINE FIELD email ON TABLE account TYPE string DEFAULT "";
|
||||||
|
|
||||||
DEFINE TABLE vm_node SCHEMAFULL;
|
DEFINE TABLE vm_node SCHEMAFULL;
|
||||||
|
DEFINE FIELD operator ON TABLE vm_node TYPE record<account>;
|
||||||
DEFINE FIELD country ON TABLE vm_node TYPE string;
|
DEFINE FIELD country ON TABLE vm_node TYPE string;
|
||||||
DEFINE FIELD region ON TABLE vm_node TYPE string;
|
DEFINE FIELD region ON TABLE vm_node TYPE string;
|
||||||
DEFINE FIELD city ON TABLE vm_node TYPE string;
|
DEFINE FIELD city ON TABLE vm_node TYPE string;
|
||||||
@ -19,24 +20,63 @@ DEFINE FIELD max_ports_per_vm ON TABLE vm_node TYPE int;
|
|||||||
DEFINE FIELD price ON TABLE vm_node TYPE int;
|
DEFINE FIELD price ON TABLE vm_node TYPE int;
|
||||||
DEFINE FIELD offline_minutes ON TABLE vm_node TYPE int;
|
DEFINE FIELD offline_minutes ON TABLE vm_node TYPE int;
|
||||||
|
|
||||||
DEFINE TABLE vm_contract TYPE RELATION FROM account TO vm_node SCHEMAFULL;
|
DEFINE TABLE new_vm_req TYPE RELATION FROM account TO vm_node SCHEMAFULL;
|
||||||
DEFINE FIELD state ON TABLE vm_contract TYPE string;
|
DEFINE FIELD hostname ON TABLE new_vm_req TYPE string;
|
||||||
DEFINE FIELD hostname ON TABLE vm_contract TYPE string;
|
DEFINE FIELD extra_ports ON TABLE new_vm_req TYPE array<int>;
|
||||||
DEFINE FIELD mapped_ports ON TABLE vm_contract TYPE array<[int, int]>;
|
DEFINE FIELD public_ipv4 ON TABLE new_vm_req TYPE bool;
|
||||||
DEFINE FIELD public_ipv4 ON TABLE vm_contract TYPE string;
|
DEFINE FIELD public_ipv6 ON TABLE new_vm_req TYPE bool;
|
||||||
DEFINE FIELD public_ipv6 ON TABLE vm_contract TYPE string;
|
DEFINE FIELD disk_size_gb ON TABLE new_vm_req TYPE int;
|
||||||
DEFINE FIELD disk_size_gb ON TABLE vm_contract TYPE int;
|
DEFINE FIELD vcpus ON TABLE new_vm_req TYPE int;
|
||||||
DEFINE FIELD vcpus ON TABLE vm_contract TYPE int;
|
DEFINE FIELD memory_mb ON TABLE new_vm_req TYPE int;
|
||||||
DEFINE FIELD memory_mb ON TABLE vm_contract TYPE int;
|
DEFINE FIELD dtrfs_sha ON TABLE new_vm_req TYPE string;
|
||||||
DEFINE FIELD dtrfs_sha ON TABLE vm_contract TYPE string;
|
DEFINE FIELD dtrfs_url ON TABLE new_vm_req TYPE string;
|
||||||
DEFINE FIELD kernel_sha ON TABLE vm_contract TYPE string;
|
DEFINE FIELD kernel_sha ON TABLE new_vm_req TYPE string;
|
||||||
DEFINE FIELD created_at ON TABLE vm_contract TYPE datetime;
|
DEFINE FIELD kernel_url ON TABLE new_vm_req TYPE string;
|
||||||
DEFINE FIELD updated_at ON TABLE vm_contract TYPE datetime;
|
DEFINE FIELD created_at ON TABLE new_vm_req TYPE datetime;
|
||||||
DEFINE FIELD price_per_unit ON TABLE vm_contract TYPE int;
|
DEFINE FIELD updated_at ON TABLE new_vm_req TYPE datetime;
|
||||||
DEFINE FIELD locked_nano ON TABLE vm_contract TYPE int;
|
DEFINE FIELD price_per_unit ON TABLE new_vm_req TYPE int;
|
||||||
DEFINE FIELD collected_at ON TABLE vm_contract TYPE datetime;
|
DEFINE FIELD locked_nano ON TABLE new_vm_req TYPE int;
|
||||||
|
|
||||||
|
DEFINE TABLE active_vm TYPE RELATION FROM account TO vm_node SCHEMAFULL;
|
||||||
|
DEFINE FIELD hostname ON TABLE active_vm TYPE string;
|
||||||
|
DEFINE FIELD mapped_ports ON TABLE active_vm TYPE array<[int, int]>;
|
||||||
|
DEFINE FIELD public_ipv4 ON TABLE active_vm TYPE string;
|
||||||
|
DEFINE FIELD public_ipv6 ON TABLE active_vm TYPE string;
|
||||||
|
DEFINE FIELD disk_size_gb ON TABLE active_vm TYPE int;
|
||||||
|
DEFINE FIELD vcpus ON TABLE active_vm TYPE int;
|
||||||
|
DEFINE FIELD memory_mb ON TABLE active_vm TYPE int;
|
||||||
|
DEFINE FIELD dtrfs_sha ON TABLE active_vm TYPE string;
|
||||||
|
DEFINE FIELD kernel_sha ON TABLE active_vm TYPE string;
|
||||||
|
DEFINE FIELD created_at ON TABLE active_vm TYPE datetime;
|
||||||
|
DEFINE FIELD price_per_unit ON TABLE active_vm TYPE int;
|
||||||
|
DEFINE FIELD locked_nano ON TABLE active_vm TYPE int;
|
||||||
|
DEFINE FIELD collected_at ON TABLE active_vm TYPE datetime;
|
||||||
|
|
||||||
|
DEFINE TABLE update_vm_req TYPE RELATION FROM account TO vm_node SCHEMAFULL;
|
||||||
|
DEFINE FIELD vcpus ON TABLE update_vm_req TYPE int;
|
||||||
|
DEFINE FIELD memory_mb ON TABLE update_vm_req TYPE int;
|
||||||
|
DEFINE FIELD disk_size_gb ON TABLE update_vm_req TYPE int;
|
||||||
|
DEFINE FIELD dtrfs_sha ON TABLE update_vm_req TYPE string;
|
||||||
|
DEFINE FIELD dtrfs_url ON TABLE update_vm_req TYPE string;
|
||||||
|
DEFINE FIELD kernel_sha ON TABLE update_vm_req TYPE string;
|
||||||
|
DEFINE FIELD kernel_url ON TABLE update_vm_req TYPE string;
|
||||||
|
|
||||||
|
DEFINE TABLE deleted_vm TYPE RELATION FROM account TO vm_node SCHEMAFULL;
|
||||||
|
DEFINE FIELD hostname ON TABLE deleted_vm TYPE string;
|
||||||
|
DEFINE FIELD mapped_ports ON TABLE deleted_vm TYPE array<[int, int]>;
|
||||||
|
DEFINE FIELD public_ipv4 ON TABLE deleted_vm TYPE string;
|
||||||
|
DEFINE FIELD public_ipv6 ON TABLE deleted_vm TYPE string;
|
||||||
|
DEFINE FIELD disk_size_gb ON TABLE deleted_vm TYPE int;
|
||||||
|
DEFINE FIELD vcpus ON TABLE deleted_vm TYPE int;
|
||||||
|
DEFINE FIELD memory_mb ON TABLE deleted_vm TYPE int;
|
||||||
|
DEFINE FIELD dtrfs_sha ON TABLE deleted_vm TYPE string;
|
||||||
|
DEFINE FIELD kernel_sha ON TABLE deleted_vm TYPE string;
|
||||||
|
DEFINE FIELD created_at ON TABLE deleted_vm TYPE datetime;
|
||||||
|
DEFINE FIELD deleted_at ON TABLE deleted_vm TYPE datetime;
|
||||||
|
DEFINE FIELD price_per_unit ON TABLE deleted_vm TYPE int;
|
||||||
|
|
||||||
DEFINE TABLE app_node SCHEMAFULL;
|
DEFINE TABLE app_node SCHEMAFULL;
|
||||||
|
DEFINE FIELD operator ON TABLE app_node TYPE record<account>;
|
||||||
DEFINE FIELD country ON TABLE app_node TYPE string;
|
DEFINE FIELD country ON TABLE app_node TYPE string;
|
||||||
DEFINE FIELD region ON TABLE app_node TYPE string;
|
DEFINE FIELD region ON TABLE app_node TYPE string;
|
||||||
DEFINE FIELD city ON TABLE app_node TYPE string;
|
DEFINE FIELD city ON TABLE app_node TYPE string;
|
||||||
@ -49,22 +89,36 @@ DEFINE FIELD max_ports_per_app ON TABLE app_node TYPE int;
|
|||||||
DEFINE FIELD price ON TABLE app_node TYPE int;
|
DEFINE FIELD price ON TABLE app_node TYPE int;
|
||||||
DEFINE FIELD offline_minutes ON TABLE app_node TYPE int;
|
DEFINE FIELD offline_minutes ON TABLE app_node TYPE int;
|
||||||
|
|
||||||
DEFINE TABLE app_contract TYPE RELATION FROM account TO app_node SCHEMAFULL;
|
DEFINE TABLE active_app TYPE RELATION FROM account TO app_node SCHEMAFULL;
|
||||||
DEFINE FIELD state ON TABLE app_contract TYPE string;
|
DEFINE FIELD app_name ON TABLE active_app TYPE string;
|
||||||
DEFINE FIELD app_name ON TABLE app_contract TYPE string;
|
DEFINE FIELD mapped_ports ON TABLE active_app TYPE array<[int, int]>;
|
||||||
DEFINE FIELD mapped_ports ON TABLE app_contract TYPE array<[int, int]>;
|
DEFINE FIELD host_ipv4 ON TABLE active_app TYPE string;
|
||||||
DEFINE FIELD host_ipv4 ON TABLE app_contract TYPE string;
|
DEFINE FIELD vcpus ON TABLE active_app TYPE int;
|
||||||
DEFINE FIELD vcpus ON TABLE app_contract TYPE int;
|
DEFINE FIELD memory_mb ON TABLE active_app TYPE int;
|
||||||
DEFINE FIELD memory_mb ON TABLE app_contract TYPE int;
|
DEFINE FIELD disk_size_gb ON TABLE active_app TYPE int;
|
||||||
DEFINE FIELD disk_size_gb ON TABLE app_contract TYPE int;
|
DEFINE FIELD created_at ON TABLE active_app TYPE datetime;
|
||||||
DEFINE FIELD created_at ON TABLE app_contract TYPE datetime;
|
DEFINE FIELD price_per_unit ON TABLE active_app TYPE int;
|
||||||
DEFINE FIELD updated_at ON TABLE app_contract TYPE datetime;
|
DEFINE FIELD locked_nano ON TABLE active_app TYPE int;
|
||||||
DEFINE FIELD price_per_unit ON TABLE app_contract TYPE int;
|
DEFINE FIELD collected_at ON TABLE active_app TYPE datetime;
|
||||||
DEFINE FIELD locked_nano ON TABLE app_contract TYPE int;
|
DEFINE FIELD mr_enclave ON TABLE active_app TYPE string;
|
||||||
DEFINE FIELD collected_at ON TABLE app_contract TYPE datetime;
|
DEFINE FIELD package_url ON TABLE active_app TYPE string;
|
||||||
DEFINE FIELD mr_enclave ON TABLE app_contract TYPE string;
|
DEFINE FIELD hratls_pubkey ON TABLE active_app TYPE string;
|
||||||
DEFINE FIELD package_url ON TABLE app_contract TYPE string;
|
|
||||||
DEFINE FIELD hratls_pubkey ON TABLE app_contract TYPE string;
|
DEFINE TABLE deleted_app TYPE RELATION FROM account TO app_node SCHEMAFULL;
|
||||||
|
DEFINE FIELD app_name ON TABLE deleted_app TYPE string;
|
||||||
|
DEFINE FIELD mapped_ports ON TABLE deleted_app TYPE array<[int, int]>;
|
||||||
|
DEFINE FIELD host_ipv4 ON TABLE deleted_app TYPE string;
|
||||||
|
DEFINE FIELD vcpus ON TABLE deleted_app TYPE int;
|
||||||
|
DEFINE FIELD memory_mb ON TABLE deleted_app TYPE int;
|
||||||
|
DEFINE FIELD disk_size_gb ON TABLE deleted_app TYPE int;
|
||||||
|
DEFINE FIELD created_at ON TABLE deleted_app TYPE datetime;
|
||||||
|
DEFINE FIELD deleted_at ON TABLE deleted_app TYPE datetime;
|
||||||
|
DEFINE FIELD price_per_unit ON TABLE deleted_app TYPE int;
|
||||||
|
DEFINE FIELD locked_nano ON TABLE deleted_app TYPE int;
|
||||||
|
DEFINE FIELD collected_at ON TABLE deleted_app TYPE datetime;
|
||||||
|
DEFINE FIELD mr_enclave ON TABLE deleted_app TYPE string;
|
||||||
|
DEFINE FIELD package_url ON TABLE deleted_app TYPE string;
|
||||||
|
DEFINE FIELD hratls_pubkey ON TABLE deleted_app TYPE string;
|
||||||
|
|
||||||
DEFINE TABLE ban TYPE RELATION FROM account TO account;
|
DEFINE TABLE ban TYPE RELATION FROM account TO account;
|
||||||
DEFINE FIELD created_at ON TABLE ban TYPE datetime;
|
DEFINE FIELD created_at ON TABLE ban TYPE datetime;
|
||||||
@ -72,10 +126,8 @@ DEFINE FIELD created_at ON TABLE ban TYPE datetime;
|
|||||||
DEFINE TABLE kick TYPE RELATION FROM account TO account;
|
DEFINE TABLE kick TYPE RELATION FROM account TO account;
|
||||||
DEFINE FIELD created_at ON TABLE kick TYPE datetime;
|
DEFINE FIELD created_at ON TABLE kick TYPE datetime;
|
||||||
DEFINE FIELD reason ON TABLE kick TYPE string;
|
DEFINE FIELD reason ON TABLE kick TYPE string;
|
||||||
DEFINE FIELD contract ON TABLE kick TYPE record<vm_contract|app_contract>;
|
DEFINE FIELD contract ON TABLE kick TYPE record<deleted_vm|deleted_app>;
|
||||||
|
|
||||||
DEFINE TABLE report TYPE RELATION FROM account TO vm_node|app_node;
|
DEFINE TABLE report TYPE RELATION FROM account TO vm_node|app_node;
|
||||||
DEFINE FIELD created_at ON TABLE ban TYPE datetime;
|
DEFINE FIELD created_at ON TABLE report TYPE datetime;
|
||||||
DEFINE FIELD reason ON TABLE ban TYPE string;
|
DEFINE FIELD reason ON TABLE report TYPE string;
|
||||||
|
|
||||||
DEFINE TABLE operator TYPE RELATION FROM account TO vm_node|app_node;
|
|
||||||
|
567
saved_data.yaml
567
saved_data.yaml
@ -113,328 +113,275 @@ operators:
|
|||||||
email: first_on_detee@proton.me
|
email: first_on_detee@proton.me
|
||||||
banned_users: []
|
banned_users: []
|
||||||
vm_nodes:
|
vm_nodes:
|
||||||
- HiyMp21zaBVbRCjDsD5hEjQnHeHv4e1gpUR6pVfHTKqv
|
- HiyMp21zaBVbRCjDsD5hEjQnHeHv4e1gpUR6pVfHTKqv
|
||||||
- 3zRxiGRnf46vd3zAEmpaYBJocTV9oJB6yXf5GZFR1Sq4
|
- 3zRxiGRnf46vd3zAEmpaYBJocTV9oJB6yXf5GZFR1Sq4
|
||||||
- Du3UfPSUUZmA5thQmc9Vrxdy7UimpygcpDsQNnwRQPtu
|
- Du3UfPSUUZmA5thQmc9Vrxdy7UimpygcpDsQNnwRQPtu
|
||||||
- 4QbUXDM915RUFnHm3NiysLXFLk1WRGZvABwLNzx4tTEW
|
- 4QbUXDM915RUFnHm3NiysLXFLk1WRGZvABwLNzx4tTEW
|
||||||
- DgkbsrwttkZXvzxY5kDwQQoDd79GLmZ5tc7fYJUFkQQb
|
- DgkbsrwttkZXvzxY5kDwQQoDd79GLmZ5tc7fYJUFkQQb
|
||||||
app_nodes: []
|
app_nodes: []
|
||||||
x52w7jARC5erhWWK65VZmjdGXzBK6ZDgfv1A283d8XK:
|
x52w7jARC5erhWWK65VZmjdGXzBK6ZDgfv1A283d8XK:
|
||||||
escrow: 5499700480000
|
escrow: 5499700480000
|
||||||
email: gheo@detee.ltd
|
email: gheo@detee.ltd
|
||||||
banned_users: []
|
banned_users: []
|
||||||
vm_nodes:
|
vm_nodes:
|
||||||
- 2Uf5pxhxKTUm6gRMnpbJHYDuyA6BWUfFsdmPyWfbMV1f
|
- 2Uf5pxhxKTUm6gRMnpbJHYDuyA6BWUfFsdmPyWfbMV1f
|
||||||
- 7Xw3RxbP5pvfjZ8U6yA3HHVSS9YXjKH5Vkas3JRbQYd9
|
- 7Xw3RxbP5pvfjZ8U6yA3HHVSS9YXjKH5Vkas3JRbQYd9
|
||||||
app_nodes: []
|
app_nodes: []
|
||||||
7V3rEuh6j8VuwMVB5PyGqWKLmjJ4fYSv6WtrTL51NZTB:
|
7V3rEuh6j8VuwMVB5PyGqWKLmjJ4fYSv6WtrTL51NZTB:
|
||||||
escrow: 0
|
escrow: 0
|
||||||
email: ""
|
email: ''
|
||||||
banned_users: []
|
banned_users: []
|
||||||
vm_nodes: []
|
vm_nodes: []
|
||||||
app_nodes:
|
app_nodes:
|
||||||
- BiqoPUEoAxYxMRXUmyofoS9H1TBQgQqvLJ6MbWh88AQg
|
- BiqoPUEoAxYxMRXUmyofoS9H1TBQgQqvLJ6MbWh88AQg
|
||||||
vm_nodes:
|
vm_nodes:
|
||||||
- public_key: 7Xw3RxbP5pvfjZ8U6yA3HHVSS9YXjKH5Vkas3JRbQYd9
|
- public_key: 7Xw3RxbP5pvfjZ8U6yA3HHVSS9YXjKH5Vkas3JRbQYd9
|
||||||
operator_wallet: x52w7jARC5erhWWK65VZmjdGXzBK6ZDgfv1A283d8XK
|
operator_wallet: x52w7jARC5erhWWK65VZmjdGXzBK6ZDgfv1A283d8XK
|
||||||
country: GB
|
country: GB
|
||||||
region: England
|
region: England
|
||||||
city: London
|
city: London
|
||||||
ip: 173.234.17.2
|
ip: 173.234.17.2
|
||||||
avail_mem_mb: 26000
|
avail_mem_mb: 26000
|
||||||
avail_vcpus: 28
|
avail_vcpus: 28
|
||||||
avail_storage_gbs: 680
|
avail_storage_gbs: 680
|
||||||
avail_ipv4: 2
|
avail_ipv4: 2
|
||||||
avail_ipv6: 65516
|
avail_ipv6: 65516
|
||||||
avail_ports: 19999
|
avail_ports: 19999
|
||||||
max_ports_per_vm: 5
|
max_ports_per_vm: 5
|
||||||
price: 20000
|
price: 20000
|
||||||
reports: {}
|
reports: {}
|
||||||
offline_minutes: 0
|
offline_minutes: 0
|
||||||
- public_key: Du3UfPSUUZmA5thQmc9Vrxdy7UimpygcpDsQNnwRQPtu
|
- public_key: Du3UfPSUUZmA5thQmc9Vrxdy7UimpygcpDsQNnwRQPtu
|
||||||
operator_wallet: BFopWmwcZAMF1h2PFECZNdEucdZfnZZ32p6R9ZaBiVsS
|
operator_wallet: BFopWmwcZAMF1h2PFECZNdEucdZfnZZ32p6R9ZaBiVsS
|
||||||
country: FR
|
country: FR
|
||||||
region: Île-de-France
|
region: Île-de-France
|
||||||
city: Paris
|
city: Paris
|
||||||
ip: 156.146.63.215
|
ip: 156.146.63.215
|
||||||
avail_mem_mb: 123000
|
avail_mem_mb: 123000
|
||||||
avail_vcpus: 46
|
avail_vcpus: 46
|
||||||
avail_storage_gbs: 440
|
avail_storage_gbs: 440
|
||||||
avail_ipv4: 2
|
avail_ipv4: 2
|
||||||
avail_ipv6: 0
|
avail_ipv6: 0
|
||||||
avail_ports: 20000
|
avail_ports: 20000
|
||||||
max_ports_per_vm: 5
|
max_ports_per_vm: 5
|
||||||
price: 20000
|
price: 20000
|
||||||
reports: {}
|
reports: {}
|
||||||
offline_minutes: 0
|
offline_minutes: 0
|
||||||
- public_key: 2Uf5pxhxKTUm6gRMnpbJHYDuyA6BWUfFsdmPyWfbMV1f
|
- public_key: 2Uf5pxhxKTUm6gRMnpbJHYDuyA6BWUfFsdmPyWfbMV1f
|
||||||
operator_wallet: x52w7jARC5erhWWK65VZmjdGXzBK6ZDgfv1A283d8XK
|
operator_wallet: x52w7jARC5erhWWK65VZmjdGXzBK6ZDgfv1A283d8XK
|
||||||
country: CA
|
country: CA
|
||||||
region: Quebec
|
region: Quebec
|
||||||
city: Montréal
|
city: Montréal
|
||||||
ip: 184.107.169.199
|
ip: 184.107.169.199
|
||||||
avail_mem_mb: 30000
|
avail_mem_mb: 30000
|
||||||
avail_vcpus: 31
|
avail_vcpus: 31
|
||||||
avail_storage_gbs: 700
|
avail_storage_gbs: 700
|
||||||
avail_ipv4: 0
|
avail_ipv4: 0
|
||||||
avail_ipv6: 0
|
avail_ipv6: 0
|
||||||
avail_ports: 20000
|
avail_ports: 20000
|
||||||
max_ports_per_vm: 5
|
max_ports_per_vm: 5
|
||||||
price: 18000
|
price: 18000
|
||||||
reports: {}
|
reports: {}
|
||||||
offline_minutes: 0
|
offline_minutes: 0
|
||||||
- public_key: DgkbsrwttkZXvzxY5kDwQQoDd79GLmZ5tc7fYJUFkQQb
|
- public_key: DgkbsrwttkZXvzxY5kDwQQoDd79GLmZ5tc7fYJUFkQQb
|
||||||
operator_wallet: BFopWmwcZAMF1h2PFECZNdEucdZfnZZ32p6R9ZaBiVsS
|
operator_wallet: BFopWmwcZAMF1h2PFECZNdEucdZfnZZ32p6R9ZaBiVsS
|
||||||
country: CA
|
country: CA
|
||||||
region: British Columbia
|
region: British Columbia
|
||||||
city: Vancouver
|
city: Vancouver
|
||||||
ip: 149.22.95.1
|
ip: 149.22.95.1
|
||||||
avail_mem_mb: 109000
|
avail_mem_mb: 109000
|
||||||
avail_vcpus: 45
|
avail_vcpus: 45
|
||||||
avail_storage_gbs: 400
|
avail_storage_gbs: 400
|
||||||
avail_ipv4: 25
|
avail_ipv4: 25
|
||||||
avail_ipv6: 0
|
avail_ipv6: 0
|
||||||
avail_ports: 20000
|
avail_ports: 20000
|
||||||
max_ports_per_vm: 5
|
max_ports_per_vm: 5
|
||||||
price: 20000
|
price: 20000
|
||||||
reports: {}
|
reports: {}
|
||||||
offline_minutes: 0
|
offline_minutes: 0
|
||||||
- public_key: 3zRxiGRnf46vd3zAEmpaYBJocTV9oJB6yXf5GZFR1Sq4
|
- public_key: 3zRxiGRnf46vd3zAEmpaYBJocTV9oJB6yXf5GZFR1Sq4
|
||||||
operator_wallet: BFopWmwcZAMF1h2PFECZNdEucdZfnZZ32p6R9ZaBiVsS
|
operator_wallet: BFopWmwcZAMF1h2PFECZNdEucdZfnZZ32p6R9ZaBiVsS
|
||||||
country: US
|
country: US
|
||||||
region: California
|
region: California
|
||||||
city: San Jose
|
city: San Jose
|
||||||
ip: 149.36.48.99
|
ip: 149.36.48.99
|
||||||
avail_mem_mb: 120000
|
avail_mem_mb: 120000
|
||||||
avail_vcpus: 41
|
avail_vcpus: 41
|
||||||
avail_storage_gbs: 390
|
avail_storage_gbs: 390
|
||||||
avail_ipv4: 23
|
avail_ipv4: 23
|
||||||
avail_ipv6: 0
|
avail_ipv6: 0
|
||||||
avail_ports: 19999
|
avail_ports: 19999
|
||||||
max_ports_per_vm: 5
|
max_ports_per_vm: 5
|
||||||
price: 20000
|
price: 20000
|
||||||
reports: {}
|
reports: {}
|
||||||
offline_minutes: 0
|
offline_minutes: 0
|
||||||
- public_key: HiyMp21zaBVbRCjDsD5hEjQnHeHv4e1gpUR6pVfHTKqv
|
- public_key: HiyMp21zaBVbRCjDsD5hEjQnHeHv4e1gpUR6pVfHTKqv
|
||||||
operator_wallet: BFopWmwcZAMF1h2PFECZNdEucdZfnZZ32p6R9ZaBiVsS
|
operator_wallet: BFopWmwcZAMF1h2PFECZNdEucdZfnZZ32p6R9ZaBiVsS
|
||||||
country: CA
|
country: CA
|
||||||
region: British Columbia
|
region: British Columbia
|
||||||
city: Vancouver
|
city: Vancouver
|
||||||
ip: 149.22.95.28
|
ip: 149.22.95.28
|
||||||
avail_mem_mb: 125000
|
avail_mem_mb: 125000
|
||||||
avail_vcpus: 46
|
avail_vcpus: 46
|
||||||
avail_storage_gbs: 400
|
avail_storage_gbs: 400
|
||||||
avail_ipv4: 26
|
avail_ipv4: 26
|
||||||
avail_ipv6: 0
|
avail_ipv6: 0
|
||||||
avail_ports: 20000
|
avail_ports: 20000
|
||||||
max_ports_per_vm: 5
|
max_ports_per_vm: 5
|
||||||
price: 20000
|
price: 20000
|
||||||
reports: {}
|
reports: {}
|
||||||
offline_minutes: 0
|
offline_minutes: 0
|
||||||
vm_contracts:
|
vm_contracts:
|
||||||
- uuid: 958165e3-dea8-407d-8c42-dd17002ef79c
|
- uuid: 958165e3-dea8-407d-8c42-dd17002ef79c
|
||||||
hostname: detee-landing-fr
|
hostname: detee-landing-fr
|
||||||
admin_pubkey: FHuecMbeC1PfjkW2JKyoicJAuiU7khgQT16QUB3Q1XdL
|
admin_pubkey: FHuecMbeC1PfjkW2JKyoicJAuiU7khgQT16QUB3Q1XdL
|
||||||
node_pubkey: Du3UfPSUUZmA5thQmc9Vrxdy7UimpygcpDsQNnwRQPtu
|
node_pubkey: Du3UfPSUUZmA5thQmc9Vrxdy7UimpygcpDsQNnwRQPtu
|
||||||
exposed_ports: []
|
exposed_ports: []
|
||||||
public_ipv4: 156.146.63.216
|
public_ipv4: 156.146.63.216
|
||||||
public_ipv6: ""
|
public_ipv6: ''
|
||||||
disk_size_gb: 10
|
disk_size_gb: 10
|
||||||
vcpus: 2
|
vcpus: 2
|
||||||
memory_mb: 3000
|
memory_mb: 3000
|
||||||
kernel_sha: 3ec4fc5aa5729f515967ec71be4a851622785c0080f7191b1b07717149840151
|
kernel_sha: 3ec4fc5aa5729f515967ec71be4a851622785c0080f7191b1b07717149840151
|
||||||
dtrfs_sha: 3f6b3e5740f249eedfb2f7248c521a551be8b2676f7fcb040f3f3bc840a5004b
|
dtrfs_sha: 3f6b3e5740f249eedfb2f7248c521a551be8b2676f7fcb040f3f3bc840a5004b
|
||||||
created_at: 2025-02-28T23:19:41.769423466Z
|
created_at: 2025-02-28T23:19:41.769423466Z
|
||||||
updated_at: 2025-04-12T12:11:58.516768949Z
|
updated_at: 2025-04-12T12:11:58.516768949Z
|
||||||
price_per_unit: 20000
|
price_per_unit: 20000
|
||||||
locked_nano: 14875500000
|
locked_nano: 14875500000
|
||||||
collected_at: 2025-04-20T00:34:15.461165181Z
|
collected_at: 2025-04-20T00:34:15.461165181Z
|
||||||
- uuid: e807a2fd-cf90-4a14-bc3a-89ce6dc59033
|
- uuid: e807a2fd-cf90-4a14-bc3a-89ce6dc59033
|
||||||
hostname: detee-landing-gb
|
hostname: detee-landing-gb
|
||||||
admin_pubkey: FHuecMbeC1PfjkW2JKyoicJAuiU7khgQT16QUB3Q1XdL
|
admin_pubkey: FHuecMbeC1PfjkW2JKyoicJAuiU7khgQT16QUB3Q1XdL
|
||||||
node_pubkey: 7Xw3RxbP5pvfjZ8U6yA3HHVSS9YXjKH5Vkas3JRbQYd9
|
node_pubkey: 7Xw3RxbP5pvfjZ8U6yA3HHVSS9YXjKH5Vkas3JRbQYd9
|
||||||
exposed_ports: []
|
exposed_ports: []
|
||||||
public_ipv4: 173.234.136.154
|
public_ipv4: 173.234.136.154
|
||||||
public_ipv6: ""
|
public_ipv6: ''
|
||||||
disk_size_gb: 10
|
disk_size_gb: 10
|
||||||
vcpus: 2
|
vcpus: 2
|
||||||
memory_mb: 3000
|
memory_mb: 3000
|
||||||
kernel_sha: 3ec4fc5aa5729f515967ec71be4a851622785c0080f7191b1b07717149840151
|
kernel_sha: 3ec4fc5aa5729f515967ec71be4a851622785c0080f7191b1b07717149840151
|
||||||
dtrfs_sha: 3f6b3e5740f249eedfb2f7248c521a551be8b2676f7fcb040f3f3bc840a5004b
|
dtrfs_sha: 3f6b3e5740f249eedfb2f7248c521a551be8b2676f7fcb040f3f3bc840a5004b
|
||||||
created_at: 2025-03-06T19:51:39.595163157Z
|
created_at: 2025-03-06T19:51:39.595163157Z
|
||||||
updated_at: 2025-03-06T19:51:39.595163842Z
|
updated_at: 2025-03-06T19:51:39.595163842Z
|
||||||
price_per_unit: 20000
|
price_per_unit: 20000
|
||||||
locked_nano: 14875500000
|
locked_nano: 14875500000
|
||||||
collected_at: 2025-04-20T00:34:15.461181545Z
|
collected_at: 2025-04-20T00:34:15.461181545Z
|
||||||
- uuid: 23094406-2307-4332-a642-acee718d0186
|
- uuid: 23094406-2307-4332-a642-acee718d0186
|
||||||
hostname: heroic-door
|
hostname: heroic-door
|
||||||
admin_pubkey: DwfL5iFu32xh2YMCUxg63oEAThLRqehDAumiP9q6zuuX
|
admin_pubkey: DwfL5iFu32xh2YMCUxg63oEAThLRqehDAumiP9q6zuuX
|
||||||
node_pubkey: 7Xw3RxbP5pvfjZ8U6yA3HHVSS9YXjKH5Vkas3JRbQYd9
|
node_pubkey: 7Xw3RxbP5pvfjZ8U6yA3HHVSS9YXjKH5Vkas3JRbQYd9
|
||||||
exposed_ports:
|
exposed_ports:
|
||||||
- 38288
|
- 38288
|
||||||
public_ipv4: ""
|
public_ipv4: ''
|
||||||
public_ipv6: ""
|
public_ipv6: ''
|
||||||
disk_size_gb: 10
|
disk_size_gb: 10
|
||||||
vcpus: 1
|
vcpus: 1
|
||||||
memory_mb: 1000
|
memory_mb: 1000
|
||||||
kernel_sha: 14e225e4aaf84cc2e0b5f64206121186ddebc4b378b886da3b2f7515dfd41692
|
kernel_sha: 14e225e4aaf84cc2e0b5f64206121186ddebc4b378b886da3b2f7515dfd41692
|
||||||
dtrfs_sha: 03ce24dbbe917fdd4f6347e61036805ddbdded5044c272bab188ef9333093bee
|
dtrfs_sha: 03ce24dbbe917fdd4f6347e61036805ddbdded5044c272bab188ef9333093bee
|
||||||
created_at: 2025-03-12T16:28:24.749161605Z
|
created_at: 2025-03-12T16:28:24.749161605Z
|
||||||
updated_at: 2025-03-12T16:28:24.749162477Z
|
updated_at: 2025-03-12T16:28:24.749162477Z
|
||||||
price_per_unit: 20000
|
price_per_unit: 20000
|
||||||
locked_nano: 14134140000
|
locked_nano: 14134140000
|
||||||
collected_at: 2025-04-20T00:34:15.461191231Z
|
collected_at: 2025-04-20T00:34:15.461191231Z
|
||||||
- uuid: 1f49a71c-f68c-4c64-a82e-f50e0ba0b574
|
- uuid: 1f49a71c-f68c-4c64-a82e-f50e0ba0b574
|
||||||
hostname: astromech-wrench
|
hostname: astromech-wrench
|
||||||
admin_pubkey: FHuecMbeC1PfjkW2JKyoicJAuiU7khgQT16QUB3Q1XdL
|
admin_pubkey: FHuecMbeC1PfjkW2JKyoicJAuiU7khgQT16QUB3Q1XdL
|
||||||
node_pubkey: DgkbsrwttkZXvzxY5kDwQQoDd79GLmZ5tc7fYJUFkQQb
|
node_pubkey: DgkbsrwttkZXvzxY5kDwQQoDd79GLmZ5tc7fYJUFkQQb
|
||||||
exposed_ports: []
|
exposed_ports: []
|
||||||
public_ipv4: 149.22.95.2
|
public_ipv4: 149.22.95.2
|
||||||
public_ipv6: ""
|
public_ipv6: ''
|
||||||
disk_size_gb: 10
|
disk_size_gb: 10
|
||||||
vcpus: 2
|
vcpus: 2
|
||||||
memory_mb: 3000
|
memory_mb: 3000
|
||||||
kernel_sha: 3a68709138bed09c16671949cf1f03acee95a08381ba84fc70fb586001fa6767
|
kernel_sha: 3a68709138bed09c16671949cf1f03acee95a08381ba84fc70fb586001fa6767
|
||||||
dtrfs_sha: 0bb93443f65c9f4379ed469f94794f5c1bf14d8905b0b2c56a125df4a9ebe83e
|
dtrfs_sha: 0bb93443f65c9f4379ed469f94794f5c1bf14d8905b0b2c56a125df4a9ebe83e
|
||||||
created_at: 2025-03-20T14:40:25.557753393Z
|
created_at: 2025-03-20T14:40:25.557753393Z
|
||||||
updated_at: 2025-03-20T14:40:25.557754242Z
|
updated_at: 2025-03-20T14:40:25.557754242Z
|
||||||
price_per_unit: 20000
|
price_per_unit: 20000
|
||||||
locked_nano: 11865620000
|
locked_nano: 11865620000
|
||||||
collected_at: 2025-04-20T00:34:15.461201690Z
|
collected_at: 2025-04-20T00:34:15.461201690Z
|
||||||
- uuid: 16577f1c-9867-4a17-80a8-6cf0490f1270
|
- uuid: 16577f1c-9867-4a17-80a8-6cf0490f1270
|
||||||
hostname: sofenty
|
hostname: sofenty
|
||||||
admin_pubkey: FHuecMbeC1PfjkW2JKyoicJAuiU7khgQT16QUB3Q1XdL
|
admin_pubkey: FHuecMbeC1PfjkW2JKyoicJAuiU7khgQT16QUB3Q1XdL
|
||||||
node_pubkey: Du3UfPSUUZmA5thQmc9Vrxdy7UimpygcpDsQNnwRQPtu
|
node_pubkey: Du3UfPSUUZmA5thQmc9Vrxdy7UimpygcpDsQNnwRQPtu
|
||||||
exposed_ports: []
|
exposed_ports: []
|
||||||
public_ipv4: 156.146.63.217
|
public_ipv4: 156.146.63.217
|
||||||
public_ipv6: ""
|
public_ipv6: ''
|
||||||
disk_size_gb: 10
|
disk_size_gb: 10
|
||||||
vcpus: 2
|
vcpus: 2
|
||||||
memory_mb: 3000
|
memory_mb: 3000
|
||||||
kernel_sha: e49c8587287b21df7600c04326fd7393524453918c14d67f73757dc769a13542
|
kernel_sha: e49c8587287b21df7600c04326fd7393524453918c14d67f73757dc769a13542
|
||||||
dtrfs_sha: b5f408d00e2b93dc594fed3a7f2466a9878802ff1c7ae502247471cd06728a45
|
dtrfs_sha: b5f408d00e2b93dc594fed3a7f2466a9878802ff1c7ae502247471cd06728a45
|
||||||
created_at: 2025-04-07T22:57:57.646151746Z
|
created_at: 2025-04-07T22:57:57.646151746Z
|
||||||
updated_at: 2025-04-07T22:57:57.646152630Z
|
updated_at: 2025-04-07T22:57:57.646152630Z
|
||||||
price_per_unit: 20000
|
price_per_unit: 20000
|
||||||
locked_nano: 11867500000
|
locked_nano: 11867500000
|
||||||
collected_at: 2025-04-20T00:34:15.461211040Z
|
collected_at: 2025-04-20T00:34:15.461211040Z
|
||||||
- uuid: 4b6e25ca-87ac-478b-8f16-aa8f5c44c704
|
- uuid: 4b6e25ca-87ac-478b-8f16-aa8f5c44c704
|
||||||
hostname: cloaked-mailbox
|
hostname: cloaked-mailbox
|
||||||
admin_pubkey: DwfL5iFu32xh2YMCUxg63oEAThLRqehDAumiP9q6zuuX
|
admin_pubkey: DwfL5iFu32xh2YMCUxg63oEAThLRqehDAumiP9q6zuuX
|
||||||
node_pubkey: DgkbsrwttkZXvzxY5kDwQQoDd79GLmZ5tc7fYJUFkQQb
|
node_pubkey: DgkbsrwttkZXvzxY5kDwQQoDd79GLmZ5tc7fYJUFkQQb
|
||||||
exposed_ports: []
|
exposed_ports: []
|
||||||
public_ipv4: 149.22.95.2
|
public_ipv4: 149.22.95.2
|
||||||
public_ipv6: ""
|
public_ipv6: ''
|
||||||
disk_size_gb: 30
|
disk_size_gb: 30
|
||||||
vcpus: 1
|
vcpus: 1
|
||||||
memory_mb: 1000
|
memory_mb: 1000
|
||||||
kernel_sha: e49c8587287b21df7600c04326fd7393524453918c14d67f73757dc769a13542
|
kernel_sha: e49c8587287b21df7600c04326fd7393524453918c14d67f73757dc769a13542
|
||||||
dtrfs_sha: b5f408d00e2b93dc594fed3a7f2466a9878802ff1c7ae502247471cd06728a45
|
dtrfs_sha: b5f408d00e2b93dc594fed3a7f2466a9878802ff1c7ae502247471cd06728a45
|
||||||
created_at: 2025-04-12T13:44:56.957037550Z
|
created_at: 2025-04-12T13:44:56.957037550Z
|
||||||
updated_at: 2025-04-12T13:44:56.957038546Z
|
updated_at: 2025-04-12T13:44:56.957038546Z
|
||||||
price_per_unit: 20000
|
price_per_unit: 20000
|
||||||
locked_nano: 11177760000
|
locked_nano: 11177760000
|
||||||
collected_at: 2025-04-20T00:34:15.461219779Z
|
collected_at: 2025-04-20T00:34:15.461219779Z
|
||||||
- uuid: eb1a13ed-d782-4b71-8860-73540129cb7d
|
- uuid: eb1a13ed-d782-4b71-8860-73540129cb7d
|
||||||
hostname: twenty
|
hostname: twenty
|
||||||
admin_pubkey: FHuecMbeC1PfjkW2JKyoicJAuiU7khgQT16QUB3Q1XdL
|
admin_pubkey: FHuecMbeC1PfjkW2JKyoicJAuiU7khgQT16QUB3Q1XdL
|
||||||
node_pubkey: 3zRxiGRnf46vd3zAEmpaYBJocTV9oJB6yXf5GZFR1Sq4
|
node_pubkey: 3zRxiGRnf46vd3zAEmpaYBJocTV9oJB6yXf5GZFR1Sq4
|
||||||
exposed_ports: []
|
exposed_ports: []
|
||||||
public_ipv4: 149.36.48.100
|
public_ipv4: 149.36.48.100
|
||||||
public_ipv6: ""
|
public_ipv6: ''
|
||||||
disk_size_gb: 10
|
disk_size_gb: 10
|
||||||
vcpus: 4
|
vcpus: 4
|
||||||
memory_mb: 4000
|
memory_mb: 4000
|
||||||
kernel_sha: e49c8587287b21df7600c04326fd7393524453918c14d67f73757dc769a13542
|
kernel_sha: e49c8587287b21df7600c04326fd7393524453918c14d67f73757dc769a13542
|
||||||
dtrfs_sha: b5f408d00e2b93dc594fed3a7f2466a9878802ff1c7ae502247471cd06728a45
|
dtrfs_sha: b5f408d00e2b93dc594fed3a7f2466a9878802ff1c7ae502247471cd06728a45
|
||||||
created_at: 2025-04-15T00:46:35.622165457Z
|
created_at: 2025-04-15T00:46:35.622165457Z
|
||||||
updated_at: 2025-04-15T00:46:35.622166372Z
|
updated_at: 2025-04-15T00:46:35.622166372Z
|
||||||
price_per_unit: 20000
|
price_per_unit: 20000
|
||||||
locked_nano: 15570720000
|
locked_nano: 15570720000
|
||||||
collected_at: 2025-04-20T00:34:15.461230948Z
|
collected_at: 2025-04-20T00:34:15.461230948Z
|
||||||
- uuid: 1bf36309-3774-4825-b023-b2a0ef0405ed
|
- uuid: 1bf36309-3774-4825-b023-b2a0ef0405ed
|
||||||
hostname: shadowy-hobo
|
hostname: shadowy-hobo
|
||||||
admin_pubkey: x52w7jARC5erhWWK65VZmjdGXzBK6ZDgfv1A283d8XK
|
admin_pubkey: x52w7jARC5erhWWK65VZmjdGXzBK6ZDgfv1A283d8XK
|
||||||
node_pubkey: 3zRxiGRnf46vd3zAEmpaYBJocTV9oJB6yXf5GZFR1Sq4
|
node_pubkey: 3zRxiGRnf46vd3zAEmpaYBJocTV9oJB6yXf5GZFR1Sq4
|
||||||
exposed_ports:
|
exposed_ports:
|
||||||
- 46393
|
- 46393
|
||||||
public_ipv4: ""
|
public_ipv4: ''
|
||||||
public_ipv6: ""
|
public_ipv6: ''
|
||||||
disk_size_gb: 10
|
disk_size_gb: 10
|
||||||
vcpus: 1
|
vcpus: 1
|
||||||
memory_mb: 1000
|
memory_mb: 1000
|
||||||
kernel_sha: e765e56166ef321b53399b9638584d1279821dbe3d46191c1f66bbaa075e7919
|
kernel_sha: e765e56166ef321b53399b9638584d1279821dbe3d46191c1f66bbaa075e7919
|
||||||
dtrfs_sha: d207644ee60d54009b6ecdfb720e2ec251cde31774dd249fcc7435aca0377990
|
dtrfs_sha: d207644ee60d54009b6ecdfb720e2ec251cde31774dd249fcc7435aca0377990
|
||||||
created_at: 2025-04-16T20:37:57.176592933Z
|
created_at: 2025-04-16T20:37:57.176592933Z
|
||||||
updated_at: 2025-04-16T20:37:57.176594069Z
|
updated_at: 2025-04-16T20:37:57.176594069Z
|
||||||
price_per_unit: 20000
|
price_per_unit: 20000
|
||||||
locked_nano: 12730960000
|
locked_nano: 12730960000
|
||||||
collected_at: 2025-04-20T00:34:15.461240342Z
|
collected_at: 2025-04-20T00:34:15.461240342Z
|
||||||
app_nodes:
|
app_nodes:
|
||||||
- node_pubkey: BiqoPUEoAxYxMRXUmyofoS9H1TBQgQqvLJ6MbWh88AQg
|
- node_pubkey: BiqoPUEoAxYxMRXUmyofoS9H1TBQgQqvLJ6MbWh88AQg
|
||||||
operator_wallet: 7V3rEuh6j8VuwMVB5PyGqWKLmjJ4fYSv6WtrTL51NZTB
|
operator_wallet: 7V3rEuh6j8VuwMVB5PyGqWKLmjJ4fYSv6WtrTL51NZTB
|
||||||
country: DE
|
country: DE
|
||||||
region: Hesse
|
region: Hesse
|
||||||
city: Frankfurt am Main
|
city: Frankfurt am Main
|
||||||
ip: 212.95.45.139
|
ip: 212.95.45.139
|
||||||
avail_mem_mb: 16000
|
avail_mem_mb: 16000
|
||||||
avail_vcpus: 16
|
avail_vcpus: 16
|
||||||
avail_storage_mb: 200000
|
avail_storage_mb: 200000
|
||||||
avail_no_of_port: 20000
|
avail_no_of_port: 20000
|
||||||
max_ports_per_app: 9
|
max_ports_per_app: 9
|
||||||
price: 20000
|
price: 20000
|
||||||
offline_minutes: 0
|
offline_minutes: 0
|
||||||
app_contracts:
|
app_contracts: []
|
||||||
- uuid: e3d01f25-2b2a-410b-80e3-12f44e474334
|
|
||||||
package_url: https://registry.detee.ltd/sgx/packages/base_package_2025-04-17_11-01-08.tar.gz
|
|
||||||
admin_pubkey: H21Shi4iE7vgfjWEQNvzmpmBMJSaiZ17PYUcdNoAoKNc
|
|
||||||
node_pubkey: BiqoPUEoAxYxMRXUmyofoS9H1TBQgQqvLJ6MbWh88AQg
|
|
||||||
mapped_ports:
|
|
||||||
- - 27158
|
|
||||||
- 34500
|
|
||||||
- - 28667
|
|
||||||
- 8080
|
|
||||||
host_ipv4: 212.95.45.139
|
|
||||||
disk_size_mb: 1000
|
|
||||||
vcpus: 1
|
|
||||||
memory_mb: 1000
|
|
||||||
created_at: 2025-04-21T11:27:28.833236909Z
|
|
||||||
updated_at: 2025-04-21T11:27:28.833237729Z
|
|
||||||
price_per_unit: 200000
|
|
||||||
locked_nano: 121200000
|
|
||||||
collected_at: 2025-04-21T11:28:24.905665571Z
|
|
||||||
hratls_pubkey: 7E0F887AA6BB9104EEC1066F454D4C2D9063D676715F55F919D3FBCEDC63240B
|
|
||||||
public_package_mr_enclave:
|
|
||||||
- 52
|
|
||||||
- 183
|
|
||||||
- 102
|
|
||||||
- 210
|
|
||||||
- 251
|
|
||||||
- 219
|
|
||||||
- 218
|
|
||||||
- 140
|
|
||||||
- 168
|
|
||||||
- 118
|
|
||||||
- 10
|
|
||||||
- 193
|
|
||||||
- 98
|
|
||||||
- 240
|
|
||||||
- 147
|
|
||||||
- 124
|
|
||||||
- 240
|
|
||||||
- 189
|
|
||||||
- 46
|
|
||||||
- 95
|
|
||||||
- 138
|
|
||||||
- 172
|
|
||||||
- 15
|
|
||||||
- 246
|
|
||||||
- 227
|
|
||||||
- 114
|
|
||||||
- 70
|
|
||||||
- 159
|
|
||||||
- 232
|
|
||||||
- 212
|
|
||||||
- 9
|
|
||||||
- 234
|
|
||||||
app_name: diligent-seahorse
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
use detee_shared::general_proto::brain_general_cli_server::BrainGeneralCliServer;
|
use detee_shared::general_proto::brain_general_cli_server::BrainGeneralCliServer;
|
||||||
use detee_shared::vm_proto::brain_vm_cli_server::BrainVmCliServer;
|
use detee_shared::vm_proto::brain_vm_cli_server::BrainVmCliServer;
|
||||||
use surreal_brain::grpc::BrainGeneralCliMock;
|
use surreal_brain::grpc::BrainGeneralCliForReal;
|
||||||
use surreal_brain::grpc::BrainVmCliMock;
|
use surreal_brain::grpc::BrainVmCliForReal;
|
||||||
use surreal_brain::db;
|
use surreal_brain::db;
|
||||||
use tonic::transport::{Identity, Server, ServerTlsConfig};
|
use tonic::transport::{Identity, Server, ServerTlsConfig};
|
||||||
|
|
||||||
@ -11,8 +11,8 @@ async fn main() {
|
|||||||
db::init().await.unwrap();
|
db::init().await.unwrap();
|
||||||
let addr = "0.0.0.0:31337".parse().unwrap();
|
let addr = "0.0.0.0:31337".parse().unwrap();
|
||||||
|
|
||||||
let snp_cli_server = BrainVmCliServer::new(BrainVmCliMock {});
|
let snp_cli_server = BrainVmCliServer::new(BrainVmCliForReal {});
|
||||||
let general_service_server = BrainGeneralCliServer::new(BrainGeneralCliMock {});
|
let general_service_server = BrainGeneralCliServer::new(BrainGeneralCliForReal {});
|
||||||
|
|
||||||
let cert = std::fs::read_to_string("./tmp/brain-crt.pem").unwrap();
|
let cert = std::fs::read_to_string("./tmp/brain-crt.pem").unwrap();
|
||||||
let key = std::fs::read_to_string("./tmp/brain-key.pem").unwrap();
|
let key = std::fs::read_to_string("./tmp/brain-key.pem").unwrap();
|
||||||
|
462
src/db.rs
462
src/db.rs
@ -5,19 +5,25 @@ use surrealdb::{
|
|||||||
engine::remote::ws::{Client, Ws},
|
engine::remote::ws::{Client, Ws},
|
||||||
opt::auth::Root,
|
opt::auth::Root,
|
||||||
sql::Datetime,
|
sql::Datetime,
|
||||||
RecordId, Surreal,
|
Notification, RecordId, Surreal,
|
||||||
};
|
};
|
||||||
|
use tokio::sync::mpsc::Sender;
|
||||||
|
use tokio_stream::StreamExt as _;
|
||||||
|
|
||||||
static DB: LazyLock<Surreal<Client>> = LazyLock::new(Surreal::init);
|
static DB: LazyLock<Surreal<Client>> = LazyLock::new(Surreal::init);
|
||||||
const ACCOUNT: &str = "account";
|
pub const ACCOUNT: &str = "account";
|
||||||
const OPERATOR: &str = "operator";
|
pub const VM_NODE: &str = "vm_node";
|
||||||
const VM_CONTRACT: &str = "vm_contract";
|
pub const ACTIVE_VM: &str = "active_vm";
|
||||||
const VM_NODE: &str = "vm_node";
|
pub const NEW_VM_REQ: &str = "new_vm_req";
|
||||||
|
pub const UPDATE_VM_REQ: &str = "update_vm_req";
|
||||||
|
pub const DELETED_VM: &str = "deleted_vm";
|
||||||
|
|
||||||
#[derive(thiserror::Error, Debug)]
|
#[derive(thiserror::Error, Debug)]
|
||||||
pub enum Error {
|
pub enum Error {
|
||||||
#[error(transparent)]
|
#[error("Internal DB error: {0}")]
|
||||||
DataBase(#[from] surrealdb::Error),
|
DataBase(#[from] surrealdb::Error),
|
||||||
|
#[error("Daemon channel got closed: {0}")]
|
||||||
|
DaemonConnection(#[from] tokio::sync::mpsc::error::SendError<DaemonNotification>),
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn init() -> surrealdb::Result<()> {
|
pub async fn init() -> surrealdb::Result<()> {
|
||||||
@ -32,9 +38,7 @@ pub async fn migration0(old_data: &old_brain::BrainData) -> surrealdb::Result<()
|
|||||||
let accounts: Vec<Account> = old_data.into();
|
let accounts: Vec<Account> = old_data.into();
|
||||||
let vm_nodes: Vec<VmNode> = old_data.into();
|
let vm_nodes: Vec<VmNode> = old_data.into();
|
||||||
let app_nodes: Vec<AppNode> = old_data.into();
|
let app_nodes: Vec<AppNode> = old_data.into();
|
||||||
let vm_contracts: Vec<VmContract> = old_data.into();
|
let vm_contracts: Vec<ActiveVm> = old_data.into();
|
||||||
let operators: Vec<OperatorRelation> = old_data.into();
|
|
||||||
let app_contracts: Vec<AppContract> = old_data.into();
|
|
||||||
|
|
||||||
init().await?;
|
init().await?;
|
||||||
|
|
||||||
@ -45,11 +49,7 @@ pub async fn migration0(old_data: &old_brain::BrainData) -> surrealdb::Result<()
|
|||||||
println!("Inserting app nodes...");
|
println!("Inserting app nodes...");
|
||||||
let _: Vec<AppNode> = DB.insert(()).content(app_nodes).await?;
|
let _: Vec<AppNode> = DB.insert(()).content(app_nodes).await?;
|
||||||
println!("Inserting vm contracts...");
|
println!("Inserting vm contracts...");
|
||||||
let _: Vec<VmContract> = DB.insert("vm_contract").relation(vm_contracts).await?;
|
let _: Vec<ActiveVm> = DB.insert("vm_contract").relation(vm_contracts).await?;
|
||||||
println!("Inserting app contracts...");
|
|
||||||
let _: Vec<AppContract> = DB.insert("app_contract").relation(app_contracts).await?;
|
|
||||||
println!("Inserting operators...");
|
|
||||||
let _: Vec<OperatorRelation> = DB.insert(OPERATOR).relation(operators).await?;
|
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
@ -88,6 +88,7 @@ impl Account {
|
|||||||
#[derive(Debug, Serialize, Deserialize)]
|
#[derive(Debug, Serialize, Deserialize)]
|
||||||
pub struct VmNode {
|
pub struct VmNode {
|
||||||
pub id: RecordId,
|
pub id: RecordId,
|
||||||
|
pub operator: RecordId,
|
||||||
pub country: String,
|
pub country: String,
|
||||||
pub region: String,
|
pub region: String,
|
||||||
pub city: String,
|
pub city: String,
|
||||||
@ -103,14 +104,87 @@ pub struct VmNode {
|
|||||||
pub offline_minutes: u64,
|
pub offline_minutes: u64,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl VmNode {
|
||||||
|
pub async fn register(self) -> Result<(), Error> {
|
||||||
|
let _: Option<VmNode> = DB.upsert(self.id.clone()).content(self).await?;
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Debug, Serialize, Deserialize)]
|
#[derive(Debug, Serialize, Deserialize)]
|
||||||
pub struct VmContract {
|
pub struct VmNodeWithReports {
|
||||||
|
pub id: RecordId,
|
||||||
|
pub operator: RecordId,
|
||||||
|
pub country: String,
|
||||||
|
pub region: String,
|
||||||
|
pub city: String,
|
||||||
|
pub ip: String,
|
||||||
|
pub avail_mem_mb: u32,
|
||||||
|
pub avail_vcpus: u32,
|
||||||
|
pub avail_storage_gbs: u32,
|
||||||
|
pub avail_ipv4: u32,
|
||||||
|
pub avail_ipv6: u32,
|
||||||
|
pub avail_ports: u32,
|
||||||
|
pub max_ports_per_vm: u32,
|
||||||
|
pub price: u64,
|
||||||
|
pub offline_minutes: u64,
|
||||||
|
pub reports: Vec<Report>,
|
||||||
|
}
|
||||||
|
|
||||||
|
pub enum DaemonNotification {
|
||||||
|
Create(NewVmReq),
|
||||||
|
Update(UpdateVmReq),
|
||||||
|
Delete(DeletedVm),
|
||||||
|
}
|
||||||
|
|
||||||
|
impl From<NewVmReq> for DaemonNotification {
|
||||||
|
fn from(value: NewVmReq) -> Self {
|
||||||
|
Self::Create(value)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl From<UpdateVmReq> for DaemonNotification {
|
||||||
|
fn from(value: UpdateVmReq) -> Self {
|
||||||
|
Self::Update(value)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl From<DeletedVm> for DaemonNotification {
|
||||||
|
fn from(value: DeletedVm) -> Self {
|
||||||
|
Self::Delete(value)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Serialize, Deserialize)]
|
||||||
|
pub struct NewVmReq {
|
||||||
|
pub id: RecordId,
|
||||||
|
#[serde(rename = "in")]
|
||||||
|
pub admin: RecordId,
|
||||||
|
#[serde(rename = "out")]
|
||||||
|
pub vm_node: RecordId,
|
||||||
|
pub hostname: String,
|
||||||
|
pub extra_ports: Vec<u32>,
|
||||||
|
pub public_ipv4: bool,
|
||||||
|
pub public_ipv6: bool,
|
||||||
|
pub disk_size_gb: u32,
|
||||||
|
pub vcpus: u32,
|
||||||
|
pub memory_mb: u32,
|
||||||
|
pub dtrfs_url: String,
|
||||||
|
pub dtrfs_sha: String,
|
||||||
|
pub kernel_sha: String,
|
||||||
|
pub kernel_url: String,
|
||||||
|
pub created_at: Datetime,
|
||||||
|
pub price_per_unit: u64,
|
||||||
|
pub locked_nano: u64,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Serialize, Deserialize)]
|
||||||
|
pub struct ActiveVm {
|
||||||
pub id: RecordId,
|
pub id: RecordId,
|
||||||
#[serde(rename = "in")]
|
#[serde(rename = "in")]
|
||||||
pub admin: RecordId,
|
pub admin: RecordId,
|
||||||
#[serde(rename = "out")]
|
#[serde(rename = "out")]
|
||||||
pub vm_node: RecordId,
|
pub vm_node: RecordId,
|
||||||
pub state: String,
|
|
||||||
pub hostname: String,
|
pub hostname: String,
|
||||||
pub mapped_ports: Vec<(u32, u32)>,
|
pub mapped_ports: Vec<(u32, u32)>,
|
||||||
pub public_ipv4: String,
|
pub public_ipv4: String,
|
||||||
@ -121,13 +195,124 @@ pub struct VmContract {
|
|||||||
pub dtrfs_sha: String,
|
pub dtrfs_sha: String,
|
||||||
pub kernel_sha: String,
|
pub kernel_sha: String,
|
||||||
pub created_at: Datetime,
|
pub created_at: Datetime,
|
||||||
pub updated_at: Datetime,
|
|
||||||
pub price_per_unit: u64,
|
pub price_per_unit: u64,
|
||||||
pub locked_nano: u64,
|
pub locked_nano: u64,
|
||||||
pub collected_at: Datetime,
|
pub collected_at: Datetime,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl VmContract {
|
#[derive(Debug, Serialize, Deserialize)]
|
||||||
|
pub struct UpdateVmReq {
|
||||||
|
pub id: RecordId,
|
||||||
|
#[serde(rename = "in")]
|
||||||
|
pub admin: RecordId,
|
||||||
|
#[serde(rename = "out")]
|
||||||
|
pub vm_node: RecordId,
|
||||||
|
pub disk_size_gb: u32,
|
||||||
|
pub vcpus: u32,
|
||||||
|
pub memory_mb: u32,
|
||||||
|
pub dtrfs_url: String,
|
||||||
|
pub dtrfs_sha: String,
|
||||||
|
pub kernel_sha: String,
|
||||||
|
pub kernel_url: String,
|
||||||
|
pub created_at: Datetime,
|
||||||
|
pub price_per_unit: u64,
|
||||||
|
pub locked_nano: u64,
|
||||||
|
}
|
||||||
|
|
||||||
|
pub async fn listen_for_node<T: Into<DaemonNotification> + std::marker::Unpin + for<'de> Deserialize<'de>>(
|
||||||
|
node: &str,
|
||||||
|
tx: Sender<DaemonNotification>,
|
||||||
|
) -> Result<(), Error> {
|
||||||
|
let table_name = match std::any::type_name::<T>() {
|
||||||
|
"surreal_brain::db::NewVmReq" => NEW_VM_REQ.to_string(),
|
||||||
|
"surreal_brain::db::UpdateVmReq" => UPDATE_VM_REQ.to_string(),
|
||||||
|
"surreal_brain::db::DeletedVm" => DELETED_VM.to_string(),
|
||||||
|
wat => {
|
||||||
|
log::error!("listen_for_node: T has type {wat}");
|
||||||
|
String::from("wat")
|
||||||
|
},
|
||||||
|
};
|
||||||
|
let mut resp =
|
||||||
|
DB.query(format!("live select * from {table_name} where out = vm_node:{node};")).await?;
|
||||||
|
let mut live_stream = resp.stream::<Notification<T>>(0)?;
|
||||||
|
while let Some(result) = live_stream.next().await {
|
||||||
|
match result {
|
||||||
|
Ok(notification) => match notification.action {
|
||||||
|
surrealdb::Action::Create => tx.send(notification.data.into()).await?,
|
||||||
|
_ => {}
|
||||||
|
},
|
||||||
|
Err(e) => {
|
||||||
|
log::warn!("listen_for_deletion DB stream failed for {node}: {e}");
|
||||||
|
return Err(Error::from(e));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Serialize, Deserialize)]
|
||||||
|
pub struct DeletedVm {
|
||||||
|
pub id: RecordId,
|
||||||
|
#[serde(rename = "in")]
|
||||||
|
pub admin: RecordId,
|
||||||
|
#[serde(rename = "out")]
|
||||||
|
pub vm_node: RecordId,
|
||||||
|
pub hostname: String,
|
||||||
|
pub mapped_ports: Vec<(u32, u32)>,
|
||||||
|
pub public_ipv4: String,
|
||||||
|
pub public_ipv6: String,
|
||||||
|
pub disk_size_gb: u32,
|
||||||
|
pub vcpus: u32,
|
||||||
|
pub memory_mb: u32,
|
||||||
|
pub dtrfs_sha: String,
|
||||||
|
pub kernel_sha: String,
|
||||||
|
pub created_at: Datetime,
|
||||||
|
pub deleted_at: Datetime,
|
||||||
|
pub price_per_unit: u64,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl DeletedVm {
|
||||||
|
pub async fn get_by_uuid(uuid: &str) -> Result<Option<Self>, Error> {
|
||||||
|
let contract: Option<Self> =
|
||||||
|
DB.query(format!("select * from {DELETED_VM}:{uuid};")).await?.take(0)?;
|
||||||
|
Ok(contract)
|
||||||
|
}
|
||||||
|
|
||||||
|
pub async fn list_by_admin(admin: &str) -> Result<Vec<Self>, Error> {
|
||||||
|
let mut result =
|
||||||
|
DB.query(format!("select * from {DELETED_VM} where in = {ACCOUNT}:{admin};")).await?;
|
||||||
|
let contracts: Vec<Self> = result.take(0)?;
|
||||||
|
Ok(contracts)
|
||||||
|
}
|
||||||
|
|
||||||
|
pub async fn list_by_node(admin: &str) -> Result<Vec<Self>, Error> {
|
||||||
|
let mut result =
|
||||||
|
DB.query(format!("select * from {DELETED_VM} where out = {VM_NODE}:{admin};")).await?;
|
||||||
|
let contracts: Vec<Self> = result.take(0)?;
|
||||||
|
Ok(contracts)
|
||||||
|
}
|
||||||
|
|
||||||
|
pub async fn list_by_operator(operator: &str) -> Result<Vec<Self>, Error> {
|
||||||
|
let mut result = DB
|
||||||
|
.query(format!(
|
||||||
|
"select
|
||||||
|
(select * from ->operator->vm_node<-{DELETED_VM}) as contracts
|
||||||
|
from {ACCOUNT}:{operator};"
|
||||||
|
))
|
||||||
|
.await?;
|
||||||
|
|
||||||
|
#[derive(Deserialize)]
|
||||||
|
struct Wrapper {
|
||||||
|
contracts: Vec<DeletedVm>,
|
||||||
|
}
|
||||||
|
|
||||||
|
let c: Option<Wrapper> = result.take(0)?;
|
||||||
|
match c {
|
||||||
|
Some(c) => Ok(c.contracts),
|
||||||
|
None => Ok(Vec::new()),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// total hardware units of this VM
|
/// total hardware units of this VM
|
||||||
fn total_units(&self) -> u64 {
|
fn total_units(&self) -> u64 {
|
||||||
// TODO: Optimize this based on price of hardware.
|
// TODO: Optimize this based on price of hardware.
|
||||||
@ -145,8 +330,27 @@ impl VmContract {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl ActiveVm {
|
||||||
|
/// total hardware units of this VM
|
||||||
|
fn total_units(&self) -> u64 {
|
||||||
|
// TODO: Optimize this based on price of hardware.
|
||||||
|
// I tried, but this can be done better.
|
||||||
|
// Storage cost should also be based on tier
|
||||||
|
(self.vcpus as u64 * 10)
|
||||||
|
+ ((self.memory_mb + 256) as u64 / 200)
|
||||||
|
+ (self.disk_size_gb as u64 / 10)
|
||||||
|
+ (!self.public_ipv4.is_empty() as u64 * 10)
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Returns price per minute in nanoLP
|
||||||
|
pub fn price_per_minute(&self) -> u64 {
|
||||||
|
self.total_units() * self.price_per_unit
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Debug, Serialize, Deserialize)]
|
#[derive(Debug, Serialize, Deserialize)]
|
||||||
pub struct VmContractWithNode {
|
pub struct ActiveVmWithNode {
|
||||||
pub id: RecordId,
|
pub id: RecordId,
|
||||||
#[serde(rename = "in")]
|
#[serde(rename = "in")]
|
||||||
pub admin: RecordId,
|
pub admin: RecordId,
|
||||||
@ -169,16 +373,24 @@ pub struct VmContractWithNode {
|
|||||||
pub collected_at: Datetime,
|
pub collected_at: Datetime,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl VmContractWithNode {
|
impl ActiveVmWithNode {
|
||||||
pub async fn get_by_uuid(uuid: &str) -> Result<Option<Self>, Error> {
|
pub async fn get_by_uuid(uuid: &str) -> Result<Option<Self>, Error> {
|
||||||
let contract: Option<Self> =
|
let contract: Option<Self> =
|
||||||
DB.query(format!("select * from {VM_CONTRACT}:{uuid} fetch out;")).await?.take(0)?;
|
DB.query(format!("select * from {ACTIVE_VM}:{uuid} fetch out;")).await?.take(0)?;
|
||||||
Ok(contract)
|
Ok(contract)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn list_by_admin(admin: &str) -> Result<Vec<Self>, Error> {
|
pub async fn list_by_admin(admin: &str) -> Result<Vec<Self>, Error> {
|
||||||
let mut result = DB
|
let mut result = DB
|
||||||
.query(format!("select * from {VM_CONTRACT} where in = {ACCOUNT}:{admin} fetch out;"))
|
.query(format!("select * from {ACTIVE_VM} where in = {ACCOUNT}:{admin} fetch out;"))
|
||||||
|
.await?;
|
||||||
|
let contracts: Vec<Self> = result.take(0)?;
|
||||||
|
Ok(contracts)
|
||||||
|
}
|
||||||
|
|
||||||
|
pub async fn list_by_node(admin: &str) -> Result<Vec<Self>, Error> {
|
||||||
|
let mut result = DB
|
||||||
|
.query(format!("select * from {ACTIVE_VM} where out = {VM_NODE}:{admin} fetch out;"))
|
||||||
.await?;
|
.await?;
|
||||||
let contracts: Vec<Self> = result.take(0)?;
|
let contracts: Vec<Self> = result.take(0)?;
|
||||||
Ok(contracts)
|
Ok(contracts)
|
||||||
@ -188,14 +400,14 @@ impl VmContractWithNode {
|
|||||||
let mut result = DB
|
let mut result = DB
|
||||||
.query(format!(
|
.query(format!(
|
||||||
"select
|
"select
|
||||||
(select * from ->operator->vm_node<-vm_contract fetch out) as contracts
|
(select * from ->operator->vm_node<-{ACTIVE_VM} fetch out) as contracts
|
||||||
from {ACCOUNT}:{operator};"
|
from {ACCOUNT}:{operator};"
|
||||||
))
|
))
|
||||||
.await?;
|
.await?;
|
||||||
|
|
||||||
#[derive(Deserialize)]
|
#[derive(Deserialize)]
|
||||||
struct Wrapper {
|
struct Wrapper {
|
||||||
contracts: Vec<VmContractWithNode>,
|
contracts: Vec<ActiveVmWithNode>,
|
||||||
}
|
}
|
||||||
|
|
||||||
let c: Option<Wrapper> = result.take(0)?;
|
let c: Option<Wrapper> = result.take(0)?;
|
||||||
@ -224,18 +436,37 @@ impl VmContractWithNode {
|
|||||||
|
|
||||||
#[derive(Debug, Serialize, Deserialize)]
|
#[derive(Debug, Serialize, Deserialize)]
|
||||||
pub struct AppNode {
|
pub struct AppNode {
|
||||||
id: RecordId,
|
pub id: RecordId,
|
||||||
country: String,
|
pub operator: RecordId,
|
||||||
region: String,
|
pub country: String,
|
||||||
city: String,
|
pub region: String,
|
||||||
ip: String,
|
pub city: String,
|
||||||
avail_mem_mb: u32,
|
pub ip: String,
|
||||||
avail_vcpus: u32,
|
pub avail_mem_mb: u32,
|
||||||
avail_storage_gbs: u32,
|
pub avail_vcpus: u32,
|
||||||
avail_ports: u32,
|
pub avail_storage_gbs: u32,
|
||||||
max_ports_per_app: u32,
|
pub avail_ports: u32,
|
||||||
price: u64,
|
pub max_ports_per_app: u32,
|
||||||
offline_minutes: u64,
|
pub price: u64,
|
||||||
|
pub offline_minutes: u64,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Serialize, Deserialize)]
|
||||||
|
pub struct AppNodeWithReports {
|
||||||
|
pub id: RecordId,
|
||||||
|
pub operator: RecordId,
|
||||||
|
pub country: String,
|
||||||
|
pub region: String,
|
||||||
|
pub city: String,
|
||||||
|
pub ip: String,
|
||||||
|
pub avail_mem_mb: u32,
|
||||||
|
pub avail_vcpus: u32,
|
||||||
|
pub avail_storage_gbs: u32,
|
||||||
|
pub avail_ports: u32,
|
||||||
|
pub max_ports_per_app: u32,
|
||||||
|
pub price: u64,
|
||||||
|
pub offline_minutes: u64,
|
||||||
|
pub reports: Vec<Report>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Serialize, Deserialize)]
|
#[derive(Debug, Serialize, Deserialize)]
|
||||||
@ -247,11 +478,11 @@ pub struct AppContract {
|
|||||||
app_node: RecordId,
|
app_node: RecordId,
|
||||||
state: String,
|
state: String,
|
||||||
app_name: String,
|
app_name: String,
|
||||||
mapped_ports: Vec<(u32, u32)>,
|
mapped_ports: Vec<(u64, u64)>,
|
||||||
host_ipv4: String,
|
host_ipv4: String,
|
||||||
vcpus: u32,
|
vcpus: u64,
|
||||||
memory_mb: u32,
|
memory_mb: u64,
|
||||||
disk_size_gb: u32,
|
disk_size_gb: u64,
|
||||||
created_at: Datetime,
|
created_at: Datetime,
|
||||||
updated_at: Datetime,
|
updated_at: Datetime,
|
||||||
price_per_unit: u64,
|
price_per_unit: u64,
|
||||||
@ -291,7 +522,7 @@ pub struct Report {
|
|||||||
#[serde(rename = "out")]
|
#[serde(rename = "out")]
|
||||||
to_node: RecordId,
|
to_node: RecordId,
|
||||||
created_at: Datetime,
|
created_at: Datetime,
|
||||||
reason: String,
|
pub reason: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Report {
|
impl Report {
|
||||||
@ -309,23 +540,6 @@ impl Report {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Serialize, Deserialize)]
|
|
||||||
pub struct OperatorRelation {
|
|
||||||
#[serde(rename = "in")]
|
|
||||||
pub account: RecordId,
|
|
||||||
#[serde(rename = "out")]
|
|
||||||
pub node: RecordId,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl OperatorRelation {
|
|
||||||
fn new(account: &str, vm_node: &str) -> Self {
|
|
||||||
Self {
|
|
||||||
account: RecordId::from(("account", account.to_string())),
|
|
||||||
node: RecordId::from(("vm_node", vm_node.to_string())),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// This is the operator obtained from the DB,
|
/// This is the operator obtained from the DB,
|
||||||
/// however the relation is defined using OperatorRelation
|
/// however the relation is defined using OperatorRelation
|
||||||
#[derive(Debug, Serialize, Deserialize)]
|
#[derive(Debug, Serialize, Deserialize)]
|
||||||
@ -342,21 +556,62 @@ impl Operator {
|
|||||||
pub async fn list() -> Result<Vec<Self>, Error> {
|
pub async fn list() -> Result<Vec<Self>, Error> {
|
||||||
let mut result = DB
|
let mut result = DB
|
||||||
.query(format!(
|
.query(format!(
|
||||||
"select *,
|
"array::distinct(array::flatten( [
|
||||||
in as account,
|
(select operator from vm_node group by operator).operator,
|
||||||
<-account.email[0] as email,
|
(select operator from app_node group by operator).operator
|
||||||
<-account.escrow[0] as escrow,
|
]));"
|
||||||
count(->vm_node) as vm_nodes,
|
|
||||||
count(->app_node) as app_nodes,
|
|
||||||
(select in from <-account->operator->vm_node<-report).len() +
|
|
||||||
(select in from <-account->operator->app_node<-report).len()
|
|
||||||
as reports
|
|
||||||
from operator group by in;"
|
|
||||||
))
|
))
|
||||||
.await?;
|
.await?;
|
||||||
let operators: Vec<Self> = result.take(0)?;
|
let operator_accounts: Vec<RecordId> = result.take(0)?;
|
||||||
|
let mut operators: Vec<Self> = Vec::new();
|
||||||
|
for account in operator_accounts.iter() {
|
||||||
|
if let Some(operator) = Self::inspect(&account.key().to_string()).await? {
|
||||||
|
operators.push(operator);
|
||||||
|
}
|
||||||
|
}
|
||||||
Ok(operators)
|
Ok(operators)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub async fn inspect(account: &str) -> Result<Option<Self>, Error> {
|
||||||
|
let mut result = DB
|
||||||
|
.query(format!(
|
||||||
|
"$vm_nodes = (select id from vm_node where operator = account:{account}).id;
|
||||||
|
$app_nodes = (select id from app_node where operator = account:{account}).id;
|
||||||
|
select *,
|
||||||
|
id as account,
|
||||||
|
email,
|
||||||
|
escrow,
|
||||||
|
$vm_nodes.len() as vm_nodes,
|
||||||
|
$app_nodes.len() as app_nodes,
|
||||||
|
(select id from report where $vm_nodes contains out).len() +
|
||||||
|
(select id from report where $app_nodes contains out).len()
|
||||||
|
as reports
|
||||||
|
from account where id = account:{account};"
|
||||||
|
))
|
||||||
|
.await?;
|
||||||
|
let operator: Option<Self> = result.take(2)?;
|
||||||
|
Ok(operator)
|
||||||
|
}
|
||||||
|
|
||||||
|
pub async fn inspect_nodes(
|
||||||
|
account: &str,
|
||||||
|
) -> Result<(Option<Self>, Vec<VmNodeWithReports>, Vec<AppNodeWithReports>), Error> {
|
||||||
|
let operator = Self::inspect(account).await?;
|
||||||
|
let mut result = DB
|
||||||
|
.query(format!(
|
||||||
|
"select *, operator, <-report.* as reports from vm_node
|
||||||
|
where operator = account:{account};"
|
||||||
|
))
|
||||||
|
.query(format!(
|
||||||
|
"select *, operator, <-report.* as reports from app_node
|
||||||
|
where operator = account:{account};"
|
||||||
|
))
|
||||||
|
.await?;
|
||||||
|
let vm_nodes: Vec<VmNodeWithReports> = result.take(0)?;
|
||||||
|
let app_nodes: Vec<AppNodeWithReports> = result.take(1)?;
|
||||||
|
|
||||||
|
Ok((operator, vm_nodes, app_nodes))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: delete all of these From implementation after migration 0 gets executed
|
// TODO: delete all of these From implementation after migration 0 gets executed
|
||||||
@ -366,7 +621,8 @@ impl From<&old_brain::BrainData> for Vec<VmNode> {
|
|||||||
let mut nodes = Vec::new();
|
let mut nodes = Vec::new();
|
||||||
for old_node in old_data.vm_nodes.iter() {
|
for old_node in old_data.vm_nodes.iter() {
|
||||||
nodes.push(VmNode {
|
nodes.push(VmNode {
|
||||||
id: RecordId::from(("vm_node", old_node.public_key.clone())),
|
id: RecordId::from((VM_NODE, old_node.public_key.clone())),
|
||||||
|
operator: RecordId::from((ACCOUNT, old_node.operator_wallet.clone())),
|
||||||
country: old_node.country.clone(),
|
country: old_node.country.clone(),
|
||||||
region: old_node.region.clone(),
|
region: old_node.region.clone(),
|
||||||
city: old_node.city.clone(),
|
city: old_node.city.clone(),
|
||||||
@ -386,7 +642,7 @@ impl From<&old_brain::BrainData> for Vec<VmNode> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<&old_brain::BrainData> for Vec<VmContract> {
|
impl From<&old_brain::BrainData> for Vec<ActiveVm> {
|
||||||
fn from(old_data: &old_brain::BrainData) -> Self {
|
fn from(old_data: &old_brain::BrainData) -> Self {
|
||||||
let mut contracts = Vec::new();
|
let mut contracts = Vec::new();
|
||||||
for old_c in old_data.vm_contracts.iter() {
|
for old_c in old_data.vm_contracts.iter() {
|
||||||
@ -394,11 +650,10 @@ impl From<&old_brain::BrainData> for Vec<VmContract> {
|
|||||||
for port in old_c.exposed_ports.iter() {
|
for port in old_c.exposed_ports.iter() {
|
||||||
mapped_ports.push((*port, 8080 as u32));
|
mapped_ports.push((*port, 8080 as u32));
|
||||||
}
|
}
|
||||||
contracts.push(VmContract {
|
contracts.push(ActiveVm {
|
||||||
id: RecordId::from((VM_CONTRACT, old_c.uuid.replace("-", ""))),
|
id: RecordId::from((ACTIVE_VM, old_c.uuid.replace("-", ""))),
|
||||||
admin: RecordId::from((ACCOUNT, old_c.admin_pubkey.clone())),
|
admin: RecordId::from((ACCOUNT, old_c.admin_pubkey.clone())),
|
||||||
vm_node: RecordId::from((VM_NODE, old_c.node_pubkey.clone())),
|
vm_node: RecordId::from((VM_NODE, old_c.node_pubkey.clone())),
|
||||||
state: "active".to_string(),
|
|
||||||
hostname: old_c.hostname.clone(),
|
hostname: old_c.hostname.clone(),
|
||||||
mapped_ports,
|
mapped_ports,
|
||||||
public_ipv4: old_c.public_ipv4.clone(),
|
public_ipv4: old_c.public_ipv4.clone(),
|
||||||
@ -411,7 +666,6 @@ impl From<&old_brain::BrainData> for Vec<VmContract> {
|
|||||||
price_per_unit: old_c.price_per_unit,
|
price_per_unit: old_c.price_per_unit,
|
||||||
locked_nano: old_c.locked_nano,
|
locked_nano: old_c.locked_nano,
|
||||||
created_at: old_c.created_at.into(),
|
created_at: old_c.created_at.into(),
|
||||||
updated_at: old_c.updated_at.into(),
|
|
||||||
collected_at: old_c.collected_at.into(),
|
collected_at: old_c.collected_at.into(),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -425,6 +679,7 @@ impl From<&old_brain::BrainData> for Vec<AppNode> {
|
|||||||
for old_node in old_data.app_nodes.iter() {
|
for old_node in old_data.app_nodes.iter() {
|
||||||
nodes.push(AppNode {
|
nodes.push(AppNode {
|
||||||
id: RecordId::from(("app_node", old_node.node_pubkey.clone())),
|
id: RecordId::from(("app_node", old_node.node_pubkey.clone())),
|
||||||
|
operator: RecordId::from((ACCOUNT, old_node.operator_wallet.clone())),
|
||||||
country: old_node.country.clone(),
|
country: old_node.country.clone(),
|
||||||
region: old_node.region.clone(),
|
region: old_node.region.clone(),
|
||||||
city: old_node.city.clone(),
|
city: old_node.city.clone(),
|
||||||
@ -442,48 +697,6 @@ impl From<&old_brain::BrainData> for Vec<AppNode> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<&old_brain::BrainData> for Vec<AppContract> {
|
|
||||||
fn from(old_data: &old_brain::BrainData) -> Self {
|
|
||||||
let mut contracts = Vec::new();
|
|
||||||
for old_c in old_data.app_contracts.iter() {
|
|
||||||
let mut mapped_ports = Vec::new();
|
|
||||||
for port in old_c.mapped_ports.clone().into_iter().map(|(b, c)| (b as u32, c as u32)) {
|
|
||||||
mapped_ports.push(port);
|
|
||||||
}
|
|
||||||
|
|
||||||
let mr_enclave_hex = old_c
|
|
||||||
.public_package_mr_enclave
|
|
||||||
.clone()
|
|
||||||
.unwrap_or_default()
|
|
||||||
.iter()
|
|
||||||
.map(|byte| format!("{:02X}", byte))
|
|
||||||
.collect();
|
|
||||||
|
|
||||||
contracts.push(AppContract {
|
|
||||||
id: RecordId::from(("app_contract", old_c.uuid.replace("-", ""))),
|
|
||||||
admin: RecordId::from(("account", old_c.admin_pubkey.clone())),
|
|
||||||
app_node: RecordId::from(("app_node", old_c.node_pubkey.clone())),
|
|
||||||
state: "active".to_string(),
|
|
||||||
mapped_ports,
|
|
||||||
host_ipv4: old_c.host_ipv4.clone(),
|
|
||||||
disk_size_gb: old_c.disk_size_mb * 1024,
|
|
||||||
vcpus: old_c.vcpus,
|
|
||||||
memory_mb: old_c.memory_mb,
|
|
||||||
price_per_unit: old_c.price_per_unit,
|
|
||||||
locked_nano: old_c.locked_nano,
|
|
||||||
created_at: old_c.created_at.into(),
|
|
||||||
updated_at: old_c.updated_at.into(),
|
|
||||||
collected_at: old_c.collected_at.into(),
|
|
||||||
app_name: old_c.app_name.clone(),
|
|
||||||
mr_enclave: mr_enclave_hex,
|
|
||||||
package_url: old_c.package_url.clone(),
|
|
||||||
hratls_pubkey: old_c.hratls_pubkey.clone(),
|
|
||||||
});
|
|
||||||
}
|
|
||||||
contracts
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl From<&old_brain::BrainData> for Vec<Account> {
|
impl From<&old_brain::BrainData> for Vec<Account> {
|
||||||
fn from(old_data: &old_brain::BrainData) -> Self {
|
fn from(old_data: &old_brain::BrainData) -> Self {
|
||||||
let mut accounts = Vec::new();
|
let mut accounts = Vec::new();
|
||||||
@ -504,18 +717,3 @@ impl From<&old_brain::BrainData> for Vec<Account> {
|
|||||||
accounts
|
accounts
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<&old_brain::BrainData> for Vec<OperatorRelation> {
|
|
||||||
fn from(old_data: &old_brain::BrainData) -> Self {
|
|
||||||
let mut operator_entries = Vec::new();
|
|
||||||
for operator in old_data.operators.clone() {
|
|
||||||
for vm_node in operator.1.vm_nodes.iter() {
|
|
||||||
operator_entries.push(OperatorRelation::new(&operator.0, vm_node));
|
|
||||||
}
|
|
||||||
for app_node in operator.1.app_nodes.iter() {
|
|
||||||
operator_entries.push(OperatorRelation::new(&operator.0, app_node));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
operator_entries
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
328
src/grpc.rs
328
src/grpc.rs
@ -1,6 +1,6 @@
|
|||||||
#![allow(dead_code)]
|
#![allow(dead_code)]
|
||||||
use crate::db;
|
use crate::db;
|
||||||
use detee_shared::app_proto::AppContract;
|
use detee_shared::app_proto::{AppContract, AppNodeListResp};
|
||||||
use detee_shared::{
|
use detee_shared::{
|
||||||
common_proto::{Empty, Pubkey},
|
common_proto::{Empty, Pubkey},
|
||||||
general_proto::{
|
general_proto::{
|
||||||
@ -8,19 +8,20 @@ use detee_shared::{
|
|||||||
InspectOperatorResp, KickReq, KickResp, ListOperatorsResp, RegOperatorReq, ReportNodeReq,
|
InspectOperatorResp, KickReq, KickResp, ListOperatorsResp, RegOperatorReq, ReportNodeReq,
|
||||||
SlashReq,
|
SlashReq,
|
||||||
},
|
},
|
||||||
vm_proto::{brain_vm_cli_server::BrainVmCli, ListVmContractsReq, *},
|
vm_proto::{
|
||||||
|
brain_vm_cli_server::BrainVmCli, brain_vm_daemon_server::BrainVmDaemon, ListVmContractsReq,
|
||||||
|
*,
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
use log::info;
|
use log::info;
|
||||||
use std::pin::Pin;
|
use std::pin::Pin;
|
||||||
use tokio::sync::mpsc;
|
use tokio::sync::mpsc;
|
||||||
use tokio_stream::wrappers::ReceiverStream;
|
use tokio_stream::wrappers::ReceiverStream;
|
||||||
// use tokio::sync::mpsc;
|
use tokio_stream::{Stream, StreamExt};
|
||||||
// use tokio_stream::{wrappers::ReceiverStream, Stream};
|
use tonic::{Request, Response, Status, Streaming};
|
||||||
use tokio_stream::Stream;
|
|
||||||
use tonic::{Request, Response, Status};
|
|
||||||
|
|
||||||
pub struct BrainGeneralCliMock {}
|
pub struct BrainGeneralCliForReal {}
|
||||||
|
|
||||||
impl From<db::Account> for AccountBalance {
|
impl From<db::Account> for AccountBalance {
|
||||||
fn from(account: db::Account) -> Self {
|
fn from(account: db::Account) -> Self {
|
||||||
@ -28,8 +29,74 @@ impl From<db::Account> for AccountBalance {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<db::VmContractWithNode> for VmContract {
|
impl From<db::NewVmReq> for NewVmReq {
|
||||||
fn from(db_c: db::VmContractWithNode) -> Self {
|
fn from(new_vm_req: db::NewVmReq) -> Self {
|
||||||
|
Self {
|
||||||
|
uuid: new_vm_req.id.key().to_string(),
|
||||||
|
hostname: new_vm_req.hostname,
|
||||||
|
admin_pubkey: new_vm_req.admin.key().to_string(),
|
||||||
|
node_pubkey: new_vm_req.vm_node.key().to_string(),
|
||||||
|
extra_ports: new_vm_req.extra_ports,
|
||||||
|
public_ipv4: new_vm_req.public_ipv4,
|
||||||
|
public_ipv6: new_vm_req.public_ipv6,
|
||||||
|
disk_size_gb: new_vm_req.disk_size_gb,
|
||||||
|
vcpus: new_vm_req.vcpus,
|
||||||
|
memory_mb: new_vm_req.memory_mb,
|
||||||
|
kernel_url: new_vm_req.kernel_url,
|
||||||
|
kernel_sha: new_vm_req.kernel_sha,
|
||||||
|
dtrfs_url: new_vm_req.dtrfs_url,
|
||||||
|
dtrfs_sha: new_vm_req.dtrfs_sha,
|
||||||
|
price_per_unit: new_vm_req.price_per_unit,
|
||||||
|
locked_nano: new_vm_req.locked_nano,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl From<db::UpdateVmReq> for UpdateVmReq {
|
||||||
|
fn from(update_vm_req: db::UpdateVmReq) -> Self {
|
||||||
|
Self {
|
||||||
|
uuid: update_vm_req.id.key().to_string(),
|
||||||
|
// daemon does not care about VM hostname
|
||||||
|
hostname: String::new(),
|
||||||
|
admin_pubkey: update_vm_req.admin.key().to_string(),
|
||||||
|
disk_size_gb: update_vm_req.disk_size_gb,
|
||||||
|
vcpus: update_vm_req.vcpus,
|
||||||
|
memory_mb: update_vm_req.memory_mb,
|
||||||
|
kernel_url: update_vm_req.kernel_url,
|
||||||
|
kernel_sha: update_vm_req.kernel_sha,
|
||||||
|
dtrfs_url: update_vm_req.dtrfs_url,
|
||||||
|
dtrfs_sha: update_vm_req.dtrfs_sha,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl From<db::DeletedVm> for DeleteVmReq {
|
||||||
|
fn from(delete_vm_req: db::DeletedVm) -> Self {
|
||||||
|
Self {
|
||||||
|
uuid: delete_vm_req.id.key().to_string(),
|
||||||
|
admin_pubkey: delete_vm_req.admin.key().to_string(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl From<db::DaemonNotification> for BrainVmMessage {
|
||||||
|
fn from(notification: db::DaemonNotification) -> Self {
|
||||||
|
match notification {
|
||||||
|
db::DaemonNotification::Create(new_vm_req) => {
|
||||||
|
BrainVmMessage { msg: Some(brain_vm_message::Msg::NewVmReq(new_vm_req.into())) }
|
||||||
|
}
|
||||||
|
db::DaemonNotification::Update(update_vm_req) => BrainVmMessage {
|
||||||
|
msg: Some(brain_vm_message::Msg::UpdateVmReq(update_vm_req.into())),
|
||||||
|
},
|
||||||
|
db::DaemonNotification::Delete(deleted_vm) => {
|
||||||
|
BrainVmMessage { msg: Some(brain_vm_message::Msg::DeleteVm(deleted_vm.into())) }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl From<db::ActiveVmWithNode> for VmContract {
|
||||||
|
fn from(db_c: db::ActiveVmWithNode) -> Self {
|
||||||
let mut exposed_ports = Vec::new();
|
let mut exposed_ports = Vec::new();
|
||||||
for port in db_c.mapped_ports.iter() {
|
for port in db_c.mapped_ports.iter() {
|
||||||
exposed_ports.push(port.0);
|
exposed_ports.push(port.0);
|
||||||
@ -84,8 +151,179 @@ impl From<db::Operator> for ListOperatorsResp {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl From<db::VmNodeWithReports> for VmNodeListResp {
|
||||||
|
fn from(vm_node: db::VmNodeWithReports) -> Self {
|
||||||
|
Self {
|
||||||
|
operator: vm_node.operator.key().to_string(),
|
||||||
|
node_pubkey: vm_node.id.key().to_string(),
|
||||||
|
country: vm_node.country,
|
||||||
|
region: vm_node.region,
|
||||||
|
city: vm_node.city,
|
||||||
|
ip: vm_node.ip,
|
||||||
|
reports: vm_node.reports.iter().map(|n| n.reason.clone()).collect(),
|
||||||
|
price: vm_node.price,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl From<db::AppNodeWithReports> for AppNodeListResp {
|
||||||
|
fn from(app_node: db::AppNodeWithReports) -> Self {
|
||||||
|
Self {
|
||||||
|
operator: app_node.operator.key().to_string(),
|
||||||
|
node_pubkey: app_node.id.key().to_string(),
|
||||||
|
country: app_node.country,
|
||||||
|
region: app_node.region,
|
||||||
|
city: app_node.city,
|
||||||
|
ip: app_node.ip,
|
||||||
|
reports: app_node.reports.iter().map(|n| n.reason.clone()).collect(),
|
||||||
|
price: app_node.price,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
struct BrainVmDaemonForReal {}
|
||||||
|
|
||||||
#[tonic::async_trait]
|
#[tonic::async_trait]
|
||||||
impl BrainGeneralCli for BrainGeneralCliMock {
|
impl BrainVmDaemon for BrainVmDaemonForReal {
|
||||||
|
type RegisterVmNodeStream = Pin<Box<dyn Stream<Item = Result<VmContract, Status>> + Send>>;
|
||||||
|
async fn register_vm_node(
|
||||||
|
&self,
|
||||||
|
req: Request<RegisterVmNodeReq>,
|
||||||
|
) -> Result<Response<Self::RegisterVmNodeStream>, Status> {
|
||||||
|
let req = check_sig_from_req(req)?;
|
||||||
|
info!("Starting registration process for {:?}", req);
|
||||||
|
db::VmNode {
|
||||||
|
id: surrealdb::RecordId::from((db::VM_NODE, req.node_pubkey.clone())),
|
||||||
|
operator: surrealdb::RecordId::from((db::ACCOUNT, req.operator_wallet)),
|
||||||
|
country: req.country,
|
||||||
|
region: req.region,
|
||||||
|
city: req.city,
|
||||||
|
ip: req.main_ip,
|
||||||
|
price: req.price,
|
||||||
|
avail_mem_mb: 0,
|
||||||
|
avail_vcpus: 0,
|
||||||
|
avail_storage_gbs: 0,
|
||||||
|
avail_ipv4: 0,
|
||||||
|
avail_ipv6: 0,
|
||||||
|
avail_ports: 0,
|
||||||
|
max_ports_per_vm: 0,
|
||||||
|
offline_minutes: 0,
|
||||||
|
}
|
||||||
|
.register()
|
||||||
|
.await?;
|
||||||
|
|
||||||
|
info!("Sending existing contracts to {}", req.node_pubkey);
|
||||||
|
let contracts = db::ActiveVmWithNode::list_by_node(&req.node_pubkey).await?;
|
||||||
|
let (tx, rx) = mpsc::channel(6);
|
||||||
|
tokio::spawn(async move {
|
||||||
|
for contract in contracts {
|
||||||
|
let _ = tx.send(Ok(contract.into())).await;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
let output_stream = ReceiverStream::new(rx);
|
||||||
|
Ok(Response::new(Box::pin(output_stream) as Self::RegisterVmNodeStream))
|
||||||
|
}
|
||||||
|
|
||||||
|
type BrainMessagesStream = Pin<Box<dyn Stream<Item = Result<BrainVmMessage, Status>> + Send>>;
|
||||||
|
async fn brain_messages(
|
||||||
|
&self,
|
||||||
|
req: Request<DaemonStreamAuth>,
|
||||||
|
) -> Result<Response<Self::BrainMessagesStream>, Status> {
|
||||||
|
let auth = req.into_inner();
|
||||||
|
let pubkey = auth.pubkey.clone();
|
||||||
|
check_sig_from_parts(
|
||||||
|
&pubkey,
|
||||||
|
&auth.timestamp,
|
||||||
|
&format!("{:?}", auth.contracts),
|
||||||
|
&auth.signature,
|
||||||
|
)?;
|
||||||
|
info!("Daemon {} connected to receive brain messages", pubkey);
|
||||||
|
|
||||||
|
let (tx, rx) = mpsc::channel(6);
|
||||||
|
{
|
||||||
|
let pubkey = pubkey.clone();
|
||||||
|
let tx = tx.clone();
|
||||||
|
tokio::spawn(async move {
|
||||||
|
match db::listen_for_node::<db::DeletedVm>(&pubkey, tx).await {
|
||||||
|
Ok(()) => log::info!("db::VmContract::listen_for_node ended for {pubkey}"),
|
||||||
|
Err(e) => {
|
||||||
|
log::warn!("db::VmContract::listen_for_node errored for {pubkey}: {e}")
|
||||||
|
}
|
||||||
|
};
|
||||||
|
});
|
||||||
|
}
|
||||||
|
{
|
||||||
|
let pubkey = pubkey.clone();
|
||||||
|
let tx = tx.clone();
|
||||||
|
tokio::spawn(async move {
|
||||||
|
let _ = db::listen_for_node::<db::NewVmReq>(&pubkey, tx.clone()).await;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
{
|
||||||
|
let pubkey = pubkey.clone();
|
||||||
|
let tx = tx.clone();
|
||||||
|
tokio::spawn(async move {
|
||||||
|
let _ = db::listen_for_node::<db::UpdateVmReq>(&pubkey, tx.clone()).await;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
let output_stream = ReceiverStream::new(rx).map(|msg| Ok(msg.into()));
|
||||||
|
Ok(Response::new(Box::pin(output_stream) as Self::BrainMessagesStream))
|
||||||
|
}
|
||||||
|
|
||||||
|
async fn daemon_messages(
|
||||||
|
&self,
|
||||||
|
_req: Request<Streaming<VmDaemonMessage>>,
|
||||||
|
) -> Result<Response<Empty>, Status> {
|
||||||
|
todo!();
|
||||||
|
// let mut req_stream = req.into_inner();
|
||||||
|
// let pubkey: String;
|
||||||
|
// if let Some(Ok(msg)) = req_stream.next().await {
|
||||||
|
// log::debug!("demon_messages received the following auth message: {:?}", msg.msg);
|
||||||
|
// if let Some(vm_daemon_message::Msg::Auth(auth)) = msg.msg {
|
||||||
|
// pubkey = auth.pubkey.clone();
|
||||||
|
// check_sig_from_parts(
|
||||||
|
// &pubkey,
|
||||||
|
// &auth.timestamp,
|
||||||
|
// &format!("{:?}", auth.contracts),
|
||||||
|
// &auth.signature,
|
||||||
|
// )?;
|
||||||
|
// } else {
|
||||||
|
// return Err(Status::unauthenticated(
|
||||||
|
// "Could not authenticate the daemon: could not extract auth signature",
|
||||||
|
// ));
|
||||||
|
// }
|
||||||
|
// } else {
|
||||||
|
// return Err(Status::unauthenticated("Could not authenticate the daemon"));
|
||||||
|
// }
|
||||||
|
|
||||||
|
// // info!("Received a message from daemon {pubkey}: {daemon_message:?}");
|
||||||
|
// while let Some(daemon_message) = req_stream.next().await {
|
||||||
|
// match daemon_message {
|
||||||
|
// Ok(msg) => match msg.msg {
|
||||||
|
// Some(vm_daemon_message::Msg::NewVmResp(new_vm_resp)) => {
|
||||||
|
// self.data.submit_newvm_resp(new_vm_resp).await;
|
||||||
|
// }
|
||||||
|
// Some(vm_daemon_message::Msg::UpdateVmResp(update_vm_resp)) => {
|
||||||
|
// self.data.submit_updatevm_resp(update_vm_resp).await;
|
||||||
|
// }
|
||||||
|
// Some(vm_daemon_message::Msg::VmNodeResources(node_resources)) => {
|
||||||
|
// self.data.submit_node_resources(node_resources);
|
||||||
|
// }
|
||||||
|
// _ => {}
|
||||||
|
// },
|
||||||
|
// Err(e) => {
|
||||||
|
// log::warn!("Daemon disconnected: {e:?}");
|
||||||
|
// self.data.del_daemon_tx(&pubkey);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// Ok(Response::new(Empty {}))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[tonic::async_trait]
|
||||||
|
impl BrainGeneralCli for BrainGeneralCliForReal {
|
||||||
type ListAccountsStream = Pin<Box<dyn Stream<Item = Result<Account, Status>> + Send>>;
|
type ListAccountsStream = Pin<Box<dyn Stream<Item = Result<Account, Status>> + Send>>;
|
||||||
type ListAllAppContractsStream =
|
type ListAllAppContractsStream =
|
||||||
Pin<Box<dyn Stream<Item = Result<AppContract, Status>> + Send>>;
|
Pin<Box<dyn Stream<Item = Result<AppContract, Status>> + Send>>;
|
||||||
@ -100,7 +338,7 @@ impl BrainGeneralCli for BrainGeneralCliMock {
|
|||||||
|
|
||||||
async fn report_node(&self, req: Request<ReportNodeReq>) -> Result<Response<Empty>, Status> {
|
async fn report_node(&self, req: Request<ReportNodeReq>) -> Result<Response<Empty>, Status> {
|
||||||
let req = check_sig_from_req(req)?;
|
let req = check_sig_from_req(req)?;
|
||||||
let (account, node) = match db::VmContractWithNode::get_by_uuid(&req.contract).await? {
|
let (account, node) = match db::ActiveVmWithNode::get_by_uuid(&req.contract).await? {
|
||||||
Some(vm_contract)
|
Some(vm_contract)
|
||||||
if vm_contract.admin.key().to_string() == req.admin_pubkey
|
if vm_contract.admin.key().to_string() == req.admin_pubkey
|
||||||
&& vm_contract.vm_node.id.key().to_string() == req.node_pubkey =>
|
&& vm_contract.vm_node.id.key().to_string() == req.node_pubkey =>
|
||||||
@ -134,13 +372,16 @@ impl BrainGeneralCli for BrainGeneralCliMock {
|
|||||||
|
|
||||||
async fn inspect_operator(
|
async fn inspect_operator(
|
||||||
&self,
|
&self,
|
||||||
_req: Request<Pubkey>,
|
req: Request<Pubkey>,
|
||||||
) -> Result<Response<InspectOperatorResp>, Status> {
|
) -> Result<Response<InspectOperatorResp>, Status> {
|
||||||
todo!();
|
match db::Operator::inspect_nodes(&req.into_inner().pubkey).await? {
|
||||||
// match self.data.inspect_operator(&req.into_inner().pubkey) {
|
(Some(op), vm_nodes, app_nodes) => Ok(Response::new(InspectOperatorResp {
|
||||||
// Some(op) => Ok(Response::new(op.into())),
|
operator: Some(op.into()),
|
||||||
// None => Err(Status::not_found("The wallet you specified is not an operator")),
|
vm_nodes: vm_nodes.into_iter().map(|n| n.into()).collect(),
|
||||||
// }
|
app_nodes: app_nodes.into_iter().map(|n| n.into()).collect(),
|
||||||
|
})),
|
||||||
|
(None, _, _) => Err(Status::not_found("The wallet you specified is not an operator")),
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn register_operator(
|
async fn register_operator(
|
||||||
@ -244,10 +485,10 @@ impl BrainGeneralCli for BrainGeneralCliMock {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct BrainVmCliMock {}
|
pub struct BrainVmCliForReal {}
|
||||||
|
|
||||||
#[tonic::async_trait]
|
#[tonic::async_trait]
|
||||||
impl BrainVmCli for BrainVmCliMock {
|
impl BrainVmCli for BrainVmCliForReal {
|
||||||
type ListVmContractsStream = Pin<Box<dyn Stream<Item = Result<VmContract, Status>> + Send>>;
|
type ListVmContractsStream = Pin<Box<dyn Stream<Item = Result<VmContract, Status>> + Send>>;
|
||||||
type ListVmNodesStream = Pin<Box<dyn Stream<Item = Result<VmNodeListResp, Status>> + Send>>;
|
type ListVmNodesStream = Pin<Box<dyn Stream<Item = Result<VmNodeListResp, Status>> + Send>>;
|
||||||
|
|
||||||
@ -329,7 +570,7 @@ impl BrainVmCli for BrainVmCliMock {
|
|||||||
);
|
);
|
||||||
let mut contracts = Vec::new();
|
let mut contracts = Vec::new();
|
||||||
if !req.uuid.is_empty() {
|
if !req.uuid.is_empty() {
|
||||||
if let Some(specific_contract) = db::VmContractWithNode::get_by_uuid(&req.uuid).await? {
|
if let Some(specific_contract) = db::ActiveVmWithNode::get_by_uuid(&req.uuid).await? {
|
||||||
if specific_contract.admin.key().to_string() == req.wallet {
|
if specific_contract.admin.key().to_string() == req.wallet {
|
||||||
contracts.push(specific_contract.into());
|
contracts.push(specific_contract.into());
|
||||||
}
|
}
|
||||||
@ -337,12 +578,11 @@ impl BrainVmCli for BrainVmCliMock {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if req.as_operator {
|
if req.as_operator {
|
||||||
contracts.append(
|
contracts
|
||||||
&mut db::VmContractWithNode::list_by_operator(&req.wallet).await?.into(),
|
.append(&mut db::ActiveVmWithNode::list_by_operator(&req.wallet).await?.into());
|
||||||
);
|
|
||||||
} else {
|
} else {
|
||||||
contracts
|
contracts
|
||||||
.append(&mut db::VmContractWithNode::list_by_admin(&req.wallet).await?.into());
|
.append(&mut db::ActiveVmWithNode::list_by_admin(&req.wallet).await?.into());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
let (tx, rx) = mpsc::channel(6);
|
let (tx, rx) = mpsc::channel(6);
|
||||||
@ -499,6 +739,46 @@ fn check_sig_from_req<T: std::fmt::Debug + PubkeyGetter>(req: Request<T>) -> Res
|
|||||||
Ok(req)
|
Ok(req)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn check_sig_from_parts(pubkey: &str, time: &str, msg: &str, sig: &str) -> Result<(), Status> {
|
||||||
|
let now = chrono::Utc::now();
|
||||||
|
let parsed_time = chrono::DateTime::parse_from_rfc3339(time)
|
||||||
|
.map_err(|_| Status::unauthenticated("Coult not parse timestamp"))?;
|
||||||
|
let seconds_elapsed = now.signed_duration_since(parsed_time).num_seconds();
|
||||||
|
if seconds_elapsed > 4 || seconds_elapsed < -4 {
|
||||||
|
return Err(Status::unauthenticated(format!(
|
||||||
|
"Date is not within 4 sec of the time of the server: CLI {} vs Server {}",
|
||||||
|
parsed_time, now
|
||||||
|
)));
|
||||||
|
}
|
||||||
|
|
||||||
|
let signature = bs58::decode(sig)
|
||||||
|
.into_vec()
|
||||||
|
.map_err(|_| Status::unauthenticated("signature is not a bs58 string"))?;
|
||||||
|
let signature = ed25519_dalek::Signature::from_bytes(
|
||||||
|
signature
|
||||||
|
.as_slice()
|
||||||
|
.try_into()
|
||||||
|
.map_err(|_| Status::unauthenticated("could not parse ed25519 signature"))?,
|
||||||
|
);
|
||||||
|
|
||||||
|
let pubkey = ed25519_dalek::VerifyingKey::from_bytes(
|
||||||
|
&bs58::decode(&pubkey)
|
||||||
|
.into_vec()
|
||||||
|
.map_err(|_| Status::unauthenticated("pubkey is not a bs58 string"))?
|
||||||
|
.try_into()
|
||||||
|
.map_err(|_| Status::unauthenticated("pubkey does not have the correct size."))?,
|
||||||
|
)
|
||||||
|
.map_err(|_| Status::unauthenticated("could not parse ed25519 pubkey"))?;
|
||||||
|
|
||||||
|
let msg = time.to_string() + msg;
|
||||||
|
use ed25519_dalek::Verifier;
|
||||||
|
pubkey
|
||||||
|
.verify(msg.as_bytes(), &signature)
|
||||||
|
.map_err(|_| Status::unauthenticated("the signature is not valid"))?;
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
const ADMIN_ACCOUNTS: &[&str] = &[
|
const ADMIN_ACCOUNTS: &[&str] = &[
|
||||||
"x52w7jARC5erhWWK65VZmjdGXzBK6ZDgfv1A283d8XK",
|
"x52w7jARC5erhWWK65VZmjdGXzBK6ZDgfv1A283d8XK",
|
||||||
"FHuecMbeC1PfjkW2JKyoicJAuiU7khgQT16QUB3Q1XdL",
|
"FHuecMbeC1PfjkW2JKyoicJAuiU7khgQT16QUB3Q1XdL",
|
||||||
|
Loading…
Reference in New Issue
Block a user