diff --git a/api/doc/spec.json b/api/doc/spec.json index 2693b4c7289a0..c633b142f25c8 100644 --- a/api/doc/spec.json +++ b/api/doc/spec.json @@ -1900,6 +1900,28 @@ "operationId": "spec" } }, + "/info": { + "get": { + "tags": [ + "General" + ], + "summary": "Show some basic info of the node.", + "responses": { + "200": { + "description": "", + "content": { + "application/json": { + "schema": { + "type": "object", + "additionalProperties": {} + } + } + } + } + }, + "operationId": "info" + } + }, "/-/healthy": { "get": { "tags": [ diff --git a/api/doc/spec.yaml b/api/doc/spec.yaml index 9ff83e9c1dbdc..2212289df30b8 100644 --- a/api/doc/spec.yaml +++ b/api/doc/spec.yaml @@ -1416,6 +1416,20 @@ paths: schema: type: string operationId: spec + /info: + get: + tags: + - General + summary: Show some basic info of the node. + responses: + '200': + description: '' + content: + application/json: + schema: + type: object + additionalProperties: {} + operationId: info /-/healthy: get: tags: diff --git a/api/src/basic.rs b/api/src/basic.rs index d6fed2dd70e3f..ae6fd8fb5c3b3 100644 --- a/api/src/basic.rs +++ b/api/src/basic.rs @@ -10,9 +10,14 @@ use crate::{ }; use anyhow::Context as AnyhowContext; use aptos_api_types::AptosErrorCode; -use poem_openapi::{param::Query, payload::Html, Object, OpenApi}; +use poem_openapi::{ + param::Query, + payload::{Html, Json}, + Object, OpenApi, +}; use serde::{Deserialize, Serialize}; use std::{ + collections::HashMap, ops::Sub, sync::Arc, time::{Duration, SystemTime, UNIX_EPOCH}, @@ -60,6 +65,56 @@ impl BasicApi { Html(OPEN_API_HTML.to_string()) } + /// Show some basic info of the node. + #[oai( + path = "/info", + method = "get", + operation_id = "info", + tag = "ApiTags::General" + )] + async fn info(&self) -> Json> { + let mut info = HashMap::new(); + info.insert( + "bootstrapping_mode".to_string(), + serde_json::to_value( + self.context + .node_config + .state_sync + .state_sync_driver + .bootstrapping_mode, + ) + .unwrap(), + ); + info.insert( + "continuous_syncing_mode".to_string(), + serde_json::to_value( + self.context + .node_config + .state_sync + .state_sync_driver + .continuous_syncing_mode, + ) + .unwrap(), + ); + info.insert( + "new_storage_format".to_string(), + serde_json::to_value( + self.context + .node_config + .storage + .rocksdb_configs + .enable_storage_sharding, + ) + .unwrap(), + ); + info.insert( + "internal_indexer_config".to_string(), + serde_json::to_value(&self.context.node_config.indexer_db_config).unwrap(), + ); + + Json(info) + } + /// Check basic node health /// /// By default this endpoint just checks that it can get the latest ledger