This commit is contained in:
ghe0 2025-08-27 23:33:56 +03:00
parent 4d0a219f07
commit ec437c6a45
Signed by: ghe0
GPG Key ID: 451028EE56A0FBB4
49 changed files with 54 additions and 2 deletions

1
.gitignore vendored

@ -1,4 +1,5 @@
# SPDX-License-Identifier: Apache-2.0 # SPDX-License-Identifier: Apache-2.0
# SPDX-License-Identifier: Unlicense
/target /target
secrets secrets

4
Cargo.lock generated

@ -1,6 +1,6 @@
# This file is automatically @generated by Cargo.
# It is not intended for manual editing.
# SPDX-License-Identifier: Apache-2.0 # SPDX-License-Identifier: Apache-2.0
# SPDX-License-Identifier: Unlicense
version = 4 version = 4
[[package]] [[package]]

@ -1,4 +1,5 @@
# SPDX-License-Identifier: Apache-2.0 # SPDX-License-Identifier: Apache-2.0
# SPDX-License-Identifier: Unlicense
[package] [package]
name = "surreal-brain" name = "surreal-brain"

@ -1,5 +1,6 @@
<!-- <!--
SPDX-License-Identifier: Apache-2.0 SPDX-License-Identifier: Apache-2.0
SPDX-License-Identifier: Unlicense
--> -->
# Brain Miration to SurrealDB # Brain Miration to SurrealDB

@ -1,4 +1,5 @@
# SPDX-License-Identifier: Apache-2.0 # SPDX-License-Identifier: Apache-2.0
# SPDX-License-Identifier: Unlicense
reorder_impl_items = true reorder_impl_items = true
use_small_heuristics = "Max" use_small_heuristics = "Max"

@ -1 +1,2 @@
SPDX-License-Identifier: Apache-2.0 SPDX-License-Identifier: Apache-2.0
SPDX-License-Identifier: Unlicense

@ -1,6 +1,7 @@
#!/bin/bash #!/bin/bash
# SPDX-License-Identifier: Apache-2.0 # SPDX-License-Identifier: Apache-2.0
# SPDX-License-Identifier: Unlicense
cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" cd -- "$( dirname -- "${BASH_SOURCE[0]}" )"

@ -1,6 +1,7 @@
#!/bin/bash #!/bin/bash
# SPDX-License-Identifier: Apache-2.0 # SPDX-License-Identifier: Apache-2.0
# SPDX-License-Identifier: Unlicense
cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" cd -- "$( dirname -- "${BASH_SOURCE[0]}" )"
cd .. cd ..

@ -1 +1,2 @@
SPDX-License-Identifier: Apache-2.0 SPDX-License-Identifier: Apache-2.0
SPDX-License-Identifier: Unlicense

@ -1 +1,2 @@
SPDX-License-Identifier: Apache-2.0 SPDX-License-Identifier: Apache-2.0
SPDX-License-Identifier: Unlicense

@ -1,4 +1,5 @@
// SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: Apache-2.0
// SPDX-License-Identifier: Unlicense
use detee_shared::app_proto::brain_app_cli_server::BrainAppCliServer; use detee_shared::app_proto::brain_app_cli_server::BrainAppCliServer;
use detee_shared::app_proto::brain_app_daemon_server::BrainAppDaemonServer; use detee_shared::app_proto::brain_app_daemon_server::BrainAppDaemonServer;

@ -1,3 +1,5 @@
// SPDX-License-Identifier: Unlicense
use detee_shared::app_proto::brain_app_cli_server::BrainAppCliServer; use detee_shared::app_proto::brain_app_cli_server::BrainAppCliServer;
use detee_shared::app_proto::brain_app_daemon_server::BrainAppDaemonServer; use detee_shared::app_proto::brain_app_daemon_server::BrainAppDaemonServer;
use detee_shared::general_proto::brain_general_cli_server::BrainGeneralCliServer; use detee_shared::general_proto::brain_general_cli_server::BrainGeneralCliServer;

@ -1,4 +1,5 @@
// SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: Apache-2.0
// SPDX-License-Identifier: Unlicense
// After deleting this migration, also delete old_brain structs // After deleting this migration, also delete old_brain structs
// and dangling impls from the model // and dangling impls from the model

@ -1,4 +1,5 @@
// SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: Apache-2.0
// SPDX-License-Identifier: Unlicense
use std::sync::LazyLock; use std::sync::LazyLock;

@ -1,4 +1,5 @@
// SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: Apache-2.0
// SPDX-License-Identifier: Unlicense
use std::time::Duration; use std::time::Duration;

@ -1,4 +1,5 @@
// SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: Apache-2.0
// SPDX-License-Identifier: Unlicense
use super::Error; use super::Error;
use crate::constants::{ACCOUNT, BAN, KICK, TOKEN_DECIMAL, VM_NODE}; use crate::constants::{ACCOUNT, BAN, KICK, TOKEN_DECIMAL, VM_NODE};

@ -1,4 +1,5 @@
// SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: Apache-2.0
// SPDX-License-Identifier: Unlicense
pub mod app; pub mod app;
pub mod general; pub mod general;

@ -1,4 +1,5 @@
// SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: Apache-2.0
// SPDX-License-Identifier: Unlicense
use std::str::FromStr; use std::str::FromStr;
use std::time::Duration; use std::time::Duration;

@ -1,4 +1,5 @@
// SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: Apache-2.0
// SPDX-License-Identifier: Unlicense
use crate::constants::{ACCOUNT, APP_NODE, DEFAULT_ENDPOINT}; use crate::constants::{ACCOUNT, APP_NODE, DEFAULT_ENDPOINT};
use crate::db::app::ActiveApp; use crate::db::app::ActiveApp;

@ -1,4 +1,5 @@
// SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: Apache-2.0
// SPDX-License-Identifier: Unlicense
use crate::db::prelude as db; use crate::db::prelude as db;
use crate::grpc::{check_admin_key, check_sig_from_req}; use crate::grpc::{check_admin_key, check_sig_from_req};

@ -1,4 +1,5 @@
// SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: Apache-2.0
// SPDX-License-Identifier: Unlicense
pub mod app; pub mod app;
pub mod general; pub mod general;

@ -1,4 +1,5 @@
// SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: Apache-2.0
// SPDX-License-Identifier: Unlicense
use crate::constants::{ACCOUNT, APP_NODE, ID_ALPHABET, NEW_APP_REQ, NEW_VM_REQ, VM_NODE}; use crate::constants::{ACCOUNT, APP_NODE, ID_ALPHABET, NEW_APP_REQ, NEW_VM_REQ, VM_NODE};
use crate::db::prelude as db; use crate::db::prelude as db;

@ -1,6 +1,7 @@
#![allow(dead_code)] #![allow(dead_code)]
// SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: Apache-2.0
// SPDX-License-Identifier: Unlicense
use crate::constants::{ACCOUNT, DEFAULT_ENDPOINT, NEW_VM_REQ, UPDATE_VM_REQ, VM_NODE}; use crate::constants::{ACCOUNT, DEFAULT_ENDPOINT, NEW_VM_REQ, UPDATE_VM_REQ, VM_NODE};
use crate::db::prelude as db; use crate::db::prelude as db;

@ -1,4 +1,5 @@
// SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: Apache-2.0
// SPDX-License-Identifier: Unlicense
pub mod constants; pub mod constants;
pub mod db; pub mod db;

@ -1,5 +1,6 @@
<!-- <!--
SPDX-License-Identifier: Apache-2.0 SPDX-License-Identifier: Apache-2.0
SPDX-License-Identifier: Unlicense
--> -->
This is actually SurrealQL (`.surql`), but the files have the `.sql` This is actually SurrealQL (`.surql`), but the files have the `.sql`

@ -1,6 +1,7 @@
#!/bin/bash #!/bin/bash
# SPDX-License-Identifier: Apache-2.0 # SPDX-License-Identifier: Apache-2.0
# SPDX-License-Identifier: Unlicense
source /etc/detee/brain/config.ini source /etc/detee/brain/config.ini

@ -1,4 +1,5 @@
-- SPDX-License-Identifier: Apache-2.0 -- SPDX-License-Identifier: Apache-2.0
-- SPDX-License-Identifier: Unlicense
DEFINE FUNCTION OVERWRITE fn::vm_price_per_minute( DEFINE FUNCTION OVERWRITE fn::vm_price_per_minute(
$vm_id: record $vm_id: record

@ -1,3 +1,5 @@
-- SPDX-License-Identifier: Unlicense
-- ------------------------------ -- ------------------------------
-- OPTION -- OPTION
-- ------------------------------ -- ------------------------------

@ -1,4 +1,5 @@
-- SPDX-License-Identifier: Apache-2.0 -- SPDX-License-Identifier: Apache-2.0
-- SPDX-License-Identifier: Unlicense
DEFINE TABLE account SCHEMAFULL; DEFINE TABLE account SCHEMAFULL;
DEFINE FIELD balance ON TABLE account TYPE int DEFAULT 0; DEFINE FIELD balance ON TABLE account TYPE int DEFAULT 0;

@ -1,4 +1,5 @@
-- SPDX-License-Identifier: Apache-2.0 -- SPDX-License-Identifier: Apache-2.0
-- SPDX-License-Identifier: Unlicense
DEFINE TABLE account SCHEMAFULL; DEFINE TABLE account SCHEMAFULL;
DEFINE FIELD balance ON TABLE account TYPE int DEFAULT 0; DEFINE FIELD balance ON TABLE account TYPE int DEFAULT 0;

@ -1,4 +1,5 @@
-- SPDX-License-Identifier: Apache-2.0 -- SPDX-License-Identifier: Apache-2.0
-- SPDX-License-Identifier: Unlicense
REMOVE FIELD price ON TABLE vm_node; REMOVE FIELD price ON TABLE vm_node;
REMOVE FIELD avail_vcpus ON TABLE vm_node; REMOVE FIELD avail_vcpus ON TABLE vm_node;

@ -1,4 +1,5 @@
-- SPDX-License-Identifier: Apache-2.0 -- SPDX-License-Identifier: Apache-2.0
-- SPDX-License-Identifier: Unlicense
INSERT { INSERT {
id: vm_node:online_node, id: vm_node:online_node,

@ -1,6 +1,7 @@
#!/bin/bash #!/bin/bash
# SPDX-License-Identifier: Apache-2.0 # SPDX-License-Identifier: Apache-2.0
# SPDX-License-Identifier: Unlicense
cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" cd -- "$( dirname -- "${BASH_SOURCE[0]}" )"
import="docker run -i --rm --net=host \ import="docker run -i --rm --net=host \

@ -1,4 +1,5 @@
-- SPDX-License-Identifier: Apache-2.0 -- SPDX-License-Identifier: Apache-2.0
-- SPDX-License-Identifier: Unlicense
if (select balance from account:operator1)[0].balance != 15_000_000_000 { if (select balance from account:operator1)[0].balance != 15_000_000_000 {
throw("Operator 1 did't get paid for serving a VM.") throw("Operator 1 did't get paid for serving a VM.")

@ -1,4 +1,5 @@
-- SPDX-License-Identifier: Apache-2.0 -- SPDX-License-Identifier: Apache-2.0
-- SPDX-License-Identifier: Unlicense
FOR $contract IN (select * from active_vm fetch out) { FOR $contract IN (select * from active_vm fetch out) {
LET $operator = (select * from $contract.out.operator)[0]; LET $operator = (select * from $contract.out.operator)[0];

@ -1,4 +1,5 @@
// SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: Apache-2.0
// SPDX-License-Identifier: Unlicense
use anyhow::Result; use anyhow::Result;
use detee_shared::app_proto::brain_app_cli_client::BrainAppCliClient; use detee_shared::app_proto::brain_app_cli_client::BrainAppCliClient;

@ -1,4 +1,5 @@
// SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: Apache-2.0
// SPDX-License-Identifier: Unlicense
use super::test_utils::Key; use super::test_utils::Key;
use crate::common::test_utils::{generate_random_public_ip, get_ip_info}; use crate::common::test_utils::{generate_random_public_ip, get_ip_info};

@ -1,4 +1,5 @@
// SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: Apache-2.0
// SPDX-License-Identifier: Unlicense
#[allow(dead_code)] #[allow(dead_code)]
pub mod prepare_test_env; pub mod prepare_test_env;

@ -1,4 +1,5 @@
// SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: Apache-2.0
// SPDX-License-Identifier: Unlicense
use anyhow::Result; use anyhow::Result;
use detee_shared::app_proto::brain_app_cli_server::BrainAppCliServer; use detee_shared::app_proto::brain_app_cli_server::BrainAppCliServer;

@ -1,4 +1,5 @@
// SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: Apache-2.0
// SPDX-License-Identifier: Unlicense
use anyhow::Result; use anyhow::Result;
use detee_shared::general_proto::brain_general_cli_client::BrainGeneralCliClient; use detee_shared::general_proto::brain_general_cli_client::BrainGeneralCliClient;

@ -1,4 +1,5 @@
// SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: Apache-2.0
// SPDX-License-Identifier: Unlicense
use super::test_utils::Key; use super::test_utils::Key;
use anyhow::{anyhow, Result}; use anyhow::{anyhow, Result};

@ -1,4 +1,5 @@
// SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: Apache-2.0
// SPDX-License-Identifier: Unlicense
use super::test_utils::Key; use super::test_utils::Key;
use crate::common::test_utils::{generate_random_public_ip, get_ip_info}; use crate::common::test_utils::{generate_random_public_ip, get_ip_info};

@ -1,3 +1,5 @@
// SPDX-License-Identifier: Unlicense
use common::prepare_test_env::prepare_test_db; use common::prepare_test_env::prepare_test_db;
use detee_shared::app_proto::{AppResource, NewAppReq}; use detee_shared::app_proto::{AppResource, NewAppReq};
use surreal_brain::db::prelude as db; use surreal_brain::db::prelude as db;

@ -1,4 +1,5 @@
// SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: Apache-2.0
// SPDX-License-Identifier: Unlicense
use common::app_daemon_utils::mock_app_daemon; use common::app_daemon_utils::mock_app_daemon;
use common::prepare_test_env::{prepare_test_db, run_service_for_stream}; use common::prepare_test_env::{prepare_test_db, run_service_for_stream};

@ -1,3 +1,5 @@
// SPDX-License-Identifier: Unlicense
use common::app_daemon_utils::{mock_app_daemon, register_app_node}; use common::app_daemon_utils::{mock_app_daemon, register_app_node};
use common::prepare_test_env::{prepare_test_db, run_service_for_stream}; use common::prepare_test_env::{prepare_test_db, run_service_for_stream};
use common::test_utils::{airdrop, Key}; use common::test_utils::{airdrop, Key};

@ -1,4 +1,5 @@
// SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: Apache-2.0
// SPDX-License-Identifier: Unlicense
use common::prepare_test_env::{prepare_test_db, run_service_for_stream}; use common::prepare_test_env::{prepare_test_db, run_service_for_stream};
use common::test_utils::{admin_keys, airdrop, Key}; use common::test_utils::{admin_keys, airdrop, Key};

@ -1,4 +1,5 @@
// SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: Apache-2.0
// SPDX-License-Identifier: Unlicense
use common::prepare_test_env::{prepare_test_db, run_service_for_stream}; use common::prepare_test_env::{prepare_test_db, run_service_for_stream};
use common::test_utils::{airdrop, Key}; use common::test_utils::{airdrop, Key};

@ -1,4 +1,5 @@
// SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: Apache-2.0
// SPDX-License-Identifier: Unlicense
use common::prepare_test_env::{prepare_test_db, run_service_for_stream}; use common::prepare_test_env::{prepare_test_db, run_service_for_stream};
use common::test_utils::{airdrop, Key}; use common::test_utils::{airdrop, Key};

@ -1,4 +1,5 @@
// SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: Apache-2.0
// SPDX-License-Identifier: Unlicense
use crate::common::test_utils::{airdrop, Key}; use crate::common::test_utils::{airdrop, Key};
use common::prepare_test_env::{prepare_test_db, run_service_for_stream}; use common::prepare_test_env::{prepare_test_db, run_service_for_stream};