diff --git a/atoma-bin/atoma_node.rs b/atoma-bin/atoma_node.rs index 9a95826b..dfd3c923 100644 --- a/atoma-bin/atoma_node.rs +++ b/atoma-bin/atoma_node.rs @@ -1,4 +1,8 @@ -use std::{path::Path, str::FromStr, sync::Arc}; +use std::{ + path::{Path, PathBuf}, + str::FromStr, + sync::Arc, +}; use anyhow::{Context, Result}; use atoma_confidential::AtomaConfidentialComputeService; @@ -16,7 +20,7 @@ use dotenv::dotenv; use futures::future::try_join_all; use hf_hub::{api::sync::ApiBuilder, Repo, RepoType}; use sui_keys::keystore::FileBasedKeystore; -use sui_sdk::types::base_types::ObjectID; +use sui_sdk::{types::base_types::ObjectID, wallet_context::WalletContext}; use tokenizers::Tokenizer; use tokio::{ net::TcpListener, @@ -47,8 +51,8 @@ const DAEMON_LOG_FILE: &str = "atoma-daemon.log"; #[derive(Parser)] struct Args { /// Index of the address to use from the keystore - #[arg(short, long, default_value_t = 0)] - address_index: usize, + #[arg(short, long)] + address_index: Option, /// Path to the configuration file #[arg(short, long)] @@ -184,6 +188,19 @@ async fn main() -> Result<()> { let keystore = FileBasedKeystore::new(&config.sui.sui_keystore_path().into()) .context("Failed to initialize keystore")?; + let mut wallet_ctx = WalletContext::new( + &PathBuf::from(config.sui.sui_config_path()), + config.sui.request_timeout(), + config.sui.max_concurrent_requests(), + )?; + let address = wallet_ctx.active_address()?; + let address_index = args.address_index.unwrap_or( + wallet_ctx + .get_addresses() + .iter() + .position(|a| a == &address) + .unwrap(), + ); info!( target = "atoma-node-service", @@ -213,6 +230,19 @@ async fn main() -> Result<()> { let (app_state_encryption_sender, _app_state_encryption_receiver) = tokio::sync::mpsc::unbounded_channel(); + for (_, node_small_id) in config.daemon.node_badges.iter() { + if let Err(e) = + register_on_proxy(&config.proxy, *node_small_id, &keystore, address_index).await + { + error!( + target = "atoma-node-service", + event = "register_on_proxy_error", + error = ?e, + "Failed to register on proxy server" + ); + } + } + info!( target = "atoma-node-service", event = "confidential_compute_service_spawn", @@ -223,10 +253,6 @@ async fn main() -> Result<()> { AtomaSuiClient::new_from_config(args.config_path).await?, )); - for (_, node_small_id) in config.daemon.node_badges.iter() { - register_on_proxy(&config.proxy, *node_small_id, &keystore, args.address_index).await?; - } - let (compute_shared_secret_sender, _compute_shared_secret_receiver) = tokio::sync::mpsc::unbounded_channel(); @@ -311,7 +337,7 @@ async fn main() -> Result<()> { .image_generations_service_url .context("Image generations service URL not configured")?, keystore: Arc::new(keystore), - address_index: args.address_index, + address_index: address_index, }; let daemon_app_state = DaemonState { diff --git a/atoma-daemon/docs/openapi.yml b/atoma-daemon/docs/openapi.yml index 16cfd19f..c1572184 100644 --- a/atoma-daemon/docs/openapi.yml +++ b/atoma-daemon/docs/openapi.yml @@ -631,7 +631,6 @@ components: required: - task_small_id - price_per_one_million_compute_units - - max_num_compute_units properties: gas: type: string @@ -656,11 +655,6 @@ components: Optional gas price. If not provided, the default is `None`. minimum: 0 - max_num_compute_units: - type: integer - format: int64 - description: The maximum number of compute units. - minimum: 0 node_badge_id: type: string description: |- @@ -669,7 +663,7 @@ components: price_per_one_million_compute_units: type: integer format: int64 - description: The price per compute unit. + description: The price per one million compute units. minimum: 0 task_small_id: type: integer @@ -752,7 +746,6 @@ components: required: - task_small_id - price_per_one_million_compute_units - - max_num_compute_units properties: gas: type: string @@ -777,11 +770,6 @@ components: Optional gas price. If not provided, the default is `None`. minimum: 0 - max_num_compute_units: - type: integer - format: int64 - description: The maximum number of compute units. - minimum: 0 node_badge_id: type: string description: |- @@ -790,7 +778,7 @@ components: price_per_one_million_compute_units: type: integer format: int64 - description: The price per compute unit. + description: The price per one million compute units. minimum: 0 task_small_id: type: integer diff --git a/atoma-daemon/src/types.rs b/atoma-daemon/src/types.rs index 3e2f6736..d081d22c 100644 --- a/atoma-daemon/src/types.rs +++ b/atoma-daemon/src/types.rs @@ -97,7 +97,7 @@ pub struct NodeTaskSubscriptionRequest { #[schema(value_type = String)] pub node_badge_id: Option, - /// The price per compute unit. + /// The price per one million compute units. pub price_per_one_million_compute_units: u64, /// Optional gas object ID. @@ -139,7 +139,7 @@ pub struct NodeTaskUpdateSubscriptionRequest { #[schema(value_type = String)] pub node_badge_id: Option, - /// The price per compute unit. + /// The price per one million compute units. pub price_per_one_million_compute_units: u64, /// Optional gas object ID. diff --git a/config.example.toml b/config.example.toml index 2b9d3842..017fc469 100644 --- a/config.example.toml +++ b/config.example.toml @@ -35,9 +35,9 @@ node_badges = [ ] # List of node badges, where each badge is a tuple of (badge_id, small_id), both values are assigned once the node registers itself [proxy_server] -# replace this with the address of the proxy server +# replace this with the public url address of the proxy server proxy_address = "" -# replace this with the public address of this node +# replace this with the public url address of this node node_public_address = "" # replace this with the country of the node country = ""