Updates the app engine resource units for memory and disk size from MB and GB to MiB.
This commit is contained in:
parent
fd8dbd9ce7
commit
1d69e04e22
2
Cargo.lock
generated
2
Cargo.lock
generated
@ -1183,7 +1183,7 @@ dependencies = [
|
|||||||
[[package]]
|
[[package]]
|
||||||
name = "detee-shared"
|
name = "detee-shared"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
source = "git+ssh://git@gitea.detee.cloud/testnet/proto.git?branch=credits-v2#6d377926408953e8da2c0f4c6625d4fb90ba7652"
|
source = "git+ssh://git@gitea.detee.cloud/testnet/proto.git?branch=credits_app#01e93d3a2e4502c0e8e72026e8a1c55810961815"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bincode",
|
"bincode",
|
||||||
"prost",
|
"prost",
|
||||||
|
@ -36,7 +36,7 @@ tokio-retry = "0.3.0"
|
|||||||
detee-sgx = { git = "ssh://git@gitea.detee.cloud/testnet/detee-sgx.git", branch = "hratls", features=["hratls", "qvl"] }
|
detee-sgx = { git = "ssh://git@gitea.detee.cloud/testnet/detee-sgx.git", branch = "hratls", features=["hratls", "qvl"] }
|
||||||
shadow-rs = { version = "1.1.1", features = ["metadata"] }
|
shadow-rs = { version = "1.1.1", features = ["metadata"] }
|
||||||
|
|
||||||
detee-shared = { git = "ssh://git@gitea.detee.cloud/testnet/proto.git", branch = "credits-v2" }
|
detee-shared = { git = "ssh://git@gitea.detee.cloud/testnet/proto.git", branch = "credits_app" }
|
||||||
# detee-shared = { path = "../detee-shared" }
|
# detee-shared = { path = "../detee-shared" }
|
||||||
|
|
||||||
[build-dependencies]
|
[build-dependencies]
|
||||||
|
@ -176,8 +176,8 @@ fn clap_cmd() -> Command {
|
|||||||
.arg(
|
.arg(
|
||||||
Arg::new("price")
|
Arg::new("price")
|
||||||
.long("price")
|
.long("price")
|
||||||
.help("price per unit per minute; check docs")
|
.help("maxium accepted price per unit per minute")
|
||||||
.default_value("200000")
|
.default_value("4000")
|
||||||
.value_parser(clap::value_parser!(u64).range(1..50000000))
|
.value_parser(clap::value_parser!(u64).range(1..50000000))
|
||||||
)
|
)
|
||||||
.arg(
|
.arg(
|
||||||
|
@ -81,8 +81,8 @@ fn handle_deploy(
|
|||||||
(AppDeployConfig::from_path(file_path).unwrap(), None)
|
(AppDeployConfig::from_path(file_path).unwrap(), None)
|
||||||
} else {
|
} else {
|
||||||
let vcpus = *deploy_match.get_one::<u32>("vcpus").unwrap();
|
let vcpus = *deploy_match.get_one::<u32>("vcpus").unwrap();
|
||||||
let memory_mb = *deploy_match.get_one::<u32>("memory").unwrap();
|
let memory_mib = *deploy_match.get_one::<u32>("memory").unwrap();
|
||||||
let disk_size_gb = *deploy_match.get_one::<u32>("disk").unwrap();
|
let disk_size_mib = *deploy_match.get_one::<u32>("disk").unwrap() * 1024;
|
||||||
let port =
|
let port =
|
||||||
deploy_match.get_many::<u32>("port").unwrap_or_default().cloned().collect::<Vec<_>>();
|
deploy_match.get_many::<u32>("port").unwrap_or_default().cloned().collect::<Vec<_>>();
|
||||||
let package_name = deploy_match.get_one::<String>("package").unwrap().clone();
|
let package_name = deploy_match.get_one::<String>("package").unwrap().clone();
|
||||||
@ -98,7 +98,7 @@ fn handle_deploy(
|
|||||||
|
|
||||||
let private_package = false;
|
let private_package = false;
|
||||||
|
|
||||||
let resource = Resource { vcpus, memory_mb, disk_size_gb, port };
|
let resource = Resource { vcpus, memory_mib, disk_size_mib, port };
|
||||||
let node_pubkey = match block_on(get_app_node(resource.clone(), location.into())) {
|
let node_pubkey = match block_on(get_app_node(resource.clone(), location.into())) {
|
||||||
Ok(node) => node.node_pubkey,
|
Ok(node) => node.node_pubkey,
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
|
@ -65,7 +65,9 @@ impl crate::HumanOutput for AppContract {
|
|||||||
println!("The app has mapped ports by the node are: {mapped_ports}");
|
println!("The app has mapped ports by the node are: {mapped_ports}");
|
||||||
println!(
|
println!(
|
||||||
"The App has {} vCPUS, {}MB of memory and a disk of {} GB.",
|
"The App has {} vCPUS, {}MB of memory and a disk of {} GB.",
|
||||||
app_resource.vcpus, app_resource.memory_mb, app_resource.disk_size_gb
|
app_resource.vcpus,
|
||||||
|
app_resource.memory_mib,
|
||||||
|
app_resource.disk_size_mib / 1024
|
||||||
);
|
);
|
||||||
println!("You have locked {} nanocredits in the contract, that get collected at a rate of {} nanocredits per minute.",
|
println!("You have locked {} nanocredits in the contract, that get collected at a rate of {} nanocredits per minute.",
|
||||||
self.locked_nano, self.nano_per_minute);
|
self.locked_nano, self.nano_per_minute);
|
||||||
@ -87,8 +89,8 @@ pub async fn new_app(app_deploy_config: AppDeployConfig) -> Result<NewAppRes> {
|
|||||||
|
|
||||||
let locked_nano = calculate_nanolp_for_app(
|
let locked_nano = calculate_nanolp_for_app(
|
||||||
resource.vcpus,
|
resource.vcpus,
|
||||||
resource.memory_mb,
|
resource.memory_mib,
|
||||||
resource.disk_size_gb,
|
resource.disk_size_mib,
|
||||||
app_deploy_config.hours,
|
app_deploy_config.hours,
|
||||||
req.price_per_unit,
|
req.price_per_unit,
|
||||||
);
|
);
|
||||||
|
@ -43,9 +43,9 @@ pub struct AppContract {
|
|||||||
#[tabled(rename = "Cores")]
|
#[tabled(rename = "Cores")]
|
||||||
pub vcpus: u32,
|
pub vcpus: u32,
|
||||||
#[tabled(rename = "Mem (MB)")]
|
#[tabled(rename = "Mem (MB)")]
|
||||||
pub memory_mb: u32,
|
pub memory_mib: u32,
|
||||||
#[tabled(rename = "Disk (GB)")]
|
#[tabled(rename = "Disk (GB)")]
|
||||||
pub disk_size_gb: u32,
|
pub disk_size_mib: u32,
|
||||||
#[tabled(rename = "credits/h")]
|
#[tabled(rename = "credits/h")]
|
||||||
pub cost_h: String,
|
pub cost_h: String,
|
||||||
#[tabled(rename = "time left", display_with = "display_mins")]
|
#[tabled(rename = "time left", display_with = "display_mins")]
|
||||||
@ -137,7 +137,7 @@ impl From<AppContractPB> for AppContract {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
let AppResource { vcpus, memory_mb, disk_size_gb, .. } =
|
let AppResource { vcpus, memory_mib, disk_size_mib, .. } =
|
||||||
brain_app_contract.resource.unwrap_or_default();
|
brain_app_contract.resource.unwrap_or_default();
|
||||||
|
|
||||||
let exposed_host_ports = brain_app_contract
|
let exposed_host_ports = brain_app_contract
|
||||||
@ -151,8 +151,8 @@ impl From<AppContractPB> for AppContract {
|
|||||||
uuid: brain_app_contract.uuid,
|
uuid: brain_app_contract.uuid,
|
||||||
name: brain_app_contract.app_name,
|
name: brain_app_contract.app_name,
|
||||||
vcpus,
|
vcpus,
|
||||||
memory_mb,
|
memory_mib,
|
||||||
disk_size_gb,
|
disk_size_mib,
|
||||||
cost_h: format!(
|
cost_h: format!(
|
||||||
"{:.4}",
|
"{:.4}",
|
||||||
(brain_app_contract.nano_per_minute * 60) as f64 / 1_000_000_000.0
|
(brain_app_contract.nano_per_minute * 60) as f64 / 1_000_000_000.0
|
||||||
@ -229,8 +229,8 @@ pub async fn get_app_node(
|
|||||||
) -> Result<AppNodeListResp, grpc_brain::Error> {
|
) -> Result<AppNodeListResp, grpc_brain::Error> {
|
||||||
let app_node_filter = AppNodeFilters {
|
let app_node_filter = AppNodeFilters {
|
||||||
vcpus: resource.vcpus,
|
vcpus: resource.vcpus,
|
||||||
memory_mb: resource.memory_mb,
|
memory_mib: resource.memory_mib,
|
||||||
storage_gb: resource.disk_size_gb,
|
storage_mib: resource.disk_size_mib,
|
||||||
country: location.country.clone().unwrap_or_default(),
|
country: location.country.clone().unwrap_or_default(),
|
||||||
region: location.region.clone().unwrap_or_default(),
|
region: location.region.clone().unwrap_or_default(),
|
||||||
city: location.city.clone().unwrap_or_default(),
|
city: location.city.clone().unwrap_or_default(),
|
||||||
|
@ -68,14 +68,15 @@ pub async fn fetch_config(package_name: &str) -> Result<DtpmConfig, Error> {
|
|||||||
|
|
||||||
pub fn calculate_nanolp_for_app(
|
pub fn calculate_nanolp_for_app(
|
||||||
vcpus: u32,
|
vcpus: u32,
|
||||||
memory_mb: u32,
|
memory_mib: u32,
|
||||||
disk_size_gb: u32,
|
disk_size_mib: u32,
|
||||||
hours: u64,
|
hours: u64,
|
||||||
node_price: u64,
|
node_price: u64,
|
||||||
) -> u64 {
|
) -> u64 {
|
||||||
// this calculation needs to match the calculation of the network
|
// this calculation needs to match the calculation of the network
|
||||||
let total_units =
|
let total_units = (vcpus as f64 * 5f64)
|
||||||
(vcpus as f64 * 5f64) + (memory_mb as f64 / 200f64) + (disk_size_gb as f64 / 10f64);
|
+ (memory_mib as f64 / 200f64)
|
||||||
|
+ (disk_size_mib as f64 / 1024f64 / 10f64);
|
||||||
let locked_nano = (hours as f64 * 60f64 * total_units * node_price as f64) as u64;
|
let locked_nano = (hours as f64 * 60f64 * total_units * node_price as f64) as u64;
|
||||||
eprintln!(
|
eprintln!(
|
||||||
"Node price: {}/unit/minute. Total Units for hardware requested: {:.4}. Locking {} LP (offering the App for {} hours).",
|
"Node price: {}/unit/minute. Total Units for hardware requested: {:.4}. Locking {} LP (offering the App for {} hours).",
|
||||||
|
Loading…
Reference in New Issue
Block a user