From 0d4b712fad1040dd773d2076d7b4b65b18527136 Mon Sep 17 00:00:00 2001 From: Noor Date: Fri, 9 May 2025 15:55:43 +0530 Subject: [PATCH 1/4] Refactor MappedPort usage to common_proto and update related structures --- build.rs | 6 +----- proto/sgx/app.proto | 8 ++------ proto/shared/common.proto | 5 +++++ proto/snp/vm.proto | 7 +------ src/sgx/types/brain.rs | 7 ++++--- 5 files changed, 13 insertions(+), 20 deletions(-) diff --git a/build.rs b/build.rs index 1557229..b1e1916 100644 --- a/build.rs +++ b/build.rs @@ -7,11 +7,7 @@ fn main() -> Result<(), Box> { "#[derive(serde::Serialize, serde::Deserialize)]", ) .type_attribute( - ".vm_proto.MappedPort", - "#[derive(serde::Serialize, serde::Deserialize)]", - ) - .type_attribute( - ".app_proto.MappedPort", + ".common_proto.MappedPort", "#[derive(serde::Serialize, serde::Deserialize)]", ) .type_attribute( diff --git a/proto/sgx/app.proto b/proto/sgx/app.proto index 68a6240..94d0957 100644 --- a/proto/sgx/app.proto +++ b/proto/sgx/app.proto @@ -11,7 +11,7 @@ message AppContract { string node_pubkey = 4; string public_ipv4 = 5; AppResource resource = 6; - repeated MappedPort mapped_ports = 7; + repeated common_proto.MappedPort mapped_ports = 7; string created_at = 8; string updated_at = 9; uint64 nano_per_minute = 10; @@ -46,14 +46,10 @@ message NewAppRes { string uuid = 1; string status = 2; string ip_address = 3; - repeated MappedPort mapped_ports = 4; + repeated common_proto.MappedPort mapped_ports = 4; string error = 5; } -message MappedPort { - uint32 host_port = 1; - uint32 app_port = 2; -} message DelAppReq { string uuid= 1; diff --git a/proto/shared/common.proto b/proto/shared/common.proto index 65d8b1e..8db07c6 100644 --- a/proto/shared/common.proto +++ b/proto/shared/common.proto @@ -7,3 +7,8 @@ message Empty { message Pubkey { string pubkey = 1; } + +message MappedPort { + uint32 host_port = 1; + uint32 guest_port = 2; +} diff --git a/proto/snp/vm.proto b/proto/snp/vm.proto index 06a09a5..fd886d8 100644 --- a/proto/snp/vm.proto +++ b/proto/snp/vm.proto @@ -3,11 +3,6 @@ package vm_proto; import "shared/common.proto"; -message MappedPort { - uint32 host_port = 1; - uint32 guest_port = 2; -} - message VmContract { string uuid = 1; string hostname = 2; @@ -15,7 +10,7 @@ message VmContract { string node_pubkey = 4; string node_ip = 5; string location = 6; - repeated MappedPort mapped_ports = 7; + repeated common_proto.MappedPort mapped_ports = 7; string vm_public_ipv4 = 8; string vm_public_ipv6 = 9; uint32 disk_size_gb = 10; diff --git a/src/sgx/types/brain.rs b/src/sgx/types/brain.rs index 904b452..53c525d 100644 --- a/src/sgx/types/brain.rs +++ b/src/sgx/types/brain.rs @@ -1,5 +1,6 @@ use crate::app_proto::{daemon_message_app, AppNodeResources, DaemonMessageApp}; -use crate::app_proto::{AppResource, DaemonAuth, MappedPort, NewAppReq, NewAppRes}; +use crate::app_proto::{AppResource, DaemonAuth, NewAppReq, NewAppRes}; +use crate::common_proto::MappedPort; use serde::{Deserialize, Serialize}; #[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Default)] @@ -93,14 +94,14 @@ impl From<(u16, u16)> for MappedPort { fn from(val: (u16, u16)) -> Self { Self { host_port: val.0 as u32, - app_port: val.1 as u32, + guest_port: val.1 as u32, } } } impl From for (u16, u16) { fn from(val: MappedPort) -> Self { - (val.host_port as u16, val.app_port as u16) + (val.host_port as u16, val.guest_port as u16) } } -- 2.43.0 From 637610196f708475230802fa67f1b3ee4d8d0679 Mon Sep 17 00:00:00 2001 From: Noor Date: Tue, 13 May 2025 12:20:12 +0530 Subject: [PATCH 2/4] update app proto Add free_ports field to AppNodeFilters --- proto/sgx/app.proto | 1 + 1 file changed, 1 insertion(+) diff --git a/proto/sgx/app.proto b/proto/sgx/app.proto index 94d0957..a41c262 100644 --- a/proto/sgx/app.proto +++ b/proto/sgx/app.proto @@ -72,6 +72,7 @@ message AppNodeFilters { string city = 6; string ip = 7; string node_pubkey = 8; + uint32 free_ports = 9; } message AppNodeListResp { -- 2.43.0 From f2303c0f2eca3cf3a2d6bc445ed6250155653021 Mon Sep 17 00:00:00 2001 From: Noor Date: Wed, 14 May 2025 15:45:11 +0530 Subject: [PATCH 3/4] Rename app rcp method rename DeployApp RPC to NewApp for make it same for vm --- proto/sgx/app.proto | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/proto/sgx/app.proto b/proto/sgx/app.proto index a41c262..32e343b 100644 --- a/proto/sgx/app.proto +++ b/proto/sgx/app.proto @@ -87,7 +87,7 @@ message AppNodeListResp { } service BrainAppCli { - rpc DeployApp (NewAppReq) returns (NewAppRes); + rpc NewApp (NewAppReq) returns (NewAppRes); rpc DeleteApp (DelAppReq) returns (common_proto.Empty); rpc ListAppContracts (ListAppContractsReq) returns (stream AppContract); rpc ListAppNodes (AppNodeFilters) returns (stream AppNodeListResp); -- 2.43.0 From da0f3269a31e0ebfb7328e2115e212aabe4d984a Mon Sep 17 00:00:00 2001 From: Noor Date: Wed, 14 May 2025 19:22:31 +0530 Subject: [PATCH 4/4] Remove status in new app response --- proto/sgx/app.proto | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/proto/sgx/app.proto b/proto/sgx/app.proto index 32e343b..bc46b35 100644 --- a/proto/sgx/app.proto +++ b/proto/sgx/app.proto @@ -44,10 +44,9 @@ message AppResource { message NewAppRes { string uuid = 1; - string status = 2; - string ip_address = 3; - repeated common_proto.MappedPort mapped_ports = 4; - string error = 5; + string ip_address = 2; + repeated common_proto.MappedPort mapped_ports = 3; + string error = 4; } -- 2.43.0