From ec790c85c017be18c9e98783fb160a6b006b87a0 Mon Sep 17 00:00:00 2001 From: James-Mart Date: Mon, 2 Dec 2024 16:59:27 +0000 Subject: [PATCH 1/6] add link to x-admin GUI after starting a new node --- programs/psinode/main.cpp | 36 +++++++++++++++++++++++++++++------- 1 file changed, 29 insertions(+), 7 deletions(-) diff --git a/programs/psinode/main.cpp b/programs/psinode/main.cpp index b4488221c..1f076945a 100644 --- a/programs/psinode/main.cpp +++ b/programs/psinode/main.cpp @@ -2097,9 +2097,9 @@ void run(const std::string& db_path, } else { - check( - false, - "should not get here, because service should have been checked already"); + check(false, + "should not get here, because service should have been checked " + "already"); } std::vector claim; result->get(claim); @@ -2374,8 +2374,30 @@ void run(const std::string& db_path, { if (!showedBootMsg) { - PSIBASE_LOG(node.chain().getLogger(), notice) - << "Need genesis block; use 'psibase boot' to boot chain"; + std::string xAdminSubdomain; + for (const auto& service : services) + { + if (service.root.string().find("services/x-admin") != std::string::npos && + service.host.ends_with('.')) + { + xAdminSubdomain = service.host; + if (!host.empty()) + { + xAdminSubdomain += host; + } + break; + } + } + + std::string message = "Node is not yet booted. To boot, use the 'psibase boot' CLI"; + + if (!xAdminSubdomain.empty()) + { + message += " or visit '" + xAdminSubdomain + + "' app in browser for a graphical boot interface"; + } + + PSIBASE_LOG(node.chain().getLogger(), notice) << message; showedBootMsg = true; } //continue; @@ -2448,8 +2470,8 @@ int main(int argc, char* argv[]) "Controls client access to the admin API"); opt("database-cache-size", po::value(&db_cache_size)->default_value({std::size_t(1) << 33}, "8 GiB"), - "The amount of RAM reserved for the database cache. Must be at least 64 MiB. Warning: this " - "will not modify an existing database. This option is subject to change."); + "The amount of RAM reserved for the database cache. Must be at least 64 MiB. Warning: " + "this will not modify an existing database. This option is subject to change."); #ifdef PSIBASE_ENABLE_SSL opt("tls-trustfile", po::value(&root_ca)->default_value({}, "")->value_name("path"), "A list of trusted Certification Authorities in PEM format"); From 5c09c3e81bacc541502fe95fc9703e54a53677cf Mon Sep 17 00:00:00 2001 From: James-Mart Date: Mon, 2 Dec 2024 17:00:29 +0000 Subject: [PATCH 2/6] link to homepage after cli boot --- rust/psibase/src/main.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rust/psibase/src/main.rs b/rust/psibase/src/main.rs index 8f39ae18f..109675b69 100644 --- a/rust/psibase/src/main.rs +++ b/rust/psibase/src/main.rs @@ -729,7 +729,7 @@ async fn boot( progress.inc(1) } if !args.suppress_ok { - println!("Ok"); + println!("Ok. Successfully booted {}", args.api); } Ok(()) } From 7250f3384ee952bef2311fc19608eebaa2eb3a7c Mon Sep 17 00:00:00 2001 From: James-Mart Date: Mon, 2 Dec 2024 17:24:23 +0000 Subject: [PATCH 3/6] add protocol/port to x-admin boot url --- programs/psinode/main.cpp | 28 +++++++++++++++++++++++----- 1 file changed, 23 insertions(+), 5 deletions(-) diff --git a/programs/psinode/main.cpp b/programs/psinode/main.cpp index 1f076945a..f6d1155c9 100644 --- a/programs/psinode/main.cpp +++ b/programs/psinode/main.cpp @@ -2380,17 +2380,35 @@ void run(const std::string& db_path, if (service.root.string().find("services/x-admin") != std::string::npos && service.host.ends_with('.')) { - xAdminSubdomain = service.host; - if (!host.empty()) + xAdminSubdomain = service.host + host; + break; + } + } + + if (!xAdminSubdomain.empty()) + { + std::string protocol; + std::string port; + for (const auto& listen : http_config->listen) + { + if (std::holds_alternative>(listen)) { - xAdminSubdomain += host; + const auto& spec = std::get>(listen); + protocol = "https://"; + port = std::to_string(spec.endpoint.port()); + break; + } + else if (std::holds_alternative>(listen)) + { + const auto& spec = std::get>(listen); + protocol = "http://"; + port = std::to_string(spec.endpoint.port()); } - break; } + xAdminSubdomain = protocol + xAdminSubdomain + ":" + port; } std::string message = "Node is not yet booted. To boot, use the 'psibase boot' CLI"; - if (!xAdminSubdomain.empty()) { message += " or visit '" + xAdminSubdomain + From ce6f3f8e38727bd53d3c7a9ae1644e3a6c69985b Mon Sep 17 00:00:00 2001 From: James-Mart Date: Mon, 2 Dec 2024 22:47:32 +0000 Subject: [PATCH 4/6] pr feedback --- .../psibase/native/include/psibase/ForkDb.hpp | 2 +- libraries/psibase_http/handle_request.cpp | 2 +- programs/psinode/main.cpp | 21 +++++++++---------- programs/psitest/main.cpp | 3 ++- rust/psibase/src/main.rs | 4 ++-- 5 files changed, 16 insertions(+), 16 deletions(-) diff --git a/libraries/psibase/native/include/psibase/ForkDb.hpp b/libraries/psibase/native/include/psibase/ForkDb.hpp index 8b95f7eab..1c160b569 100644 --- a/libraries/psibase/native/include/psibase/ForkDb.hpp +++ b/libraries/psibase/native/include/psibase/ForkDb.hpp @@ -1449,7 +1449,7 @@ namespace psibase try { if (bc->needGenesisAction) - trace.error = "Need genesis block; use 'psibase boot' to boot chain"; + trace.error = "Node is not yet booted. To boot, use the 'psibase boot' CLI"; else { check(trx.proofs.size() == trx.transaction->claims().size(), diff --git a/libraries/psibase_http/handle_request.cpp b/libraries/psibase_http/handle_request.cpp index 167c27787..d7edc92eb 100644 --- a/libraries/psibase_http/handle_request.cpp +++ b/libraries/psibase_http/handle_request.cpp @@ -696,7 +696,7 @@ namespace psibase::http bc.start(); if (bc.needGenesisAction) return send(error(bhttp::status::internal_server_error, - "Need genesis block; use 'psibase boot' to boot chain")); + "Node is not yet booted. To boot, use the 'psibase boot' CLI")); SignedTransaction trx; TransactionTrace trace; diff --git a/programs/psinode/main.cpp b/programs/psinode/main.cpp index f6d1155c9..5ba41ea60 100644 --- a/programs/psinode/main.cpp +++ b/programs/psinode/main.cpp @@ -688,7 +688,7 @@ bool pushTransaction(psibase::SharedState& sharedState, try { if (bc.needGenesisAction) - trace.error = "Need genesis block; use 'psibase boot' to boot chain"; + trace.error = "Node is not yet booted. To boot, use the 'psibase boot' CLI"; else { check(trx.proofs.size() == trx.transaction->claims().size(), @@ -2391,18 +2391,18 @@ void run(const std::string& db_path, std::string port; for (const auto& listen : http_config->listen) { - if (std::holds_alternative>(listen)) + if (const auto* spec = + std::get_if>(&listen)) { - const auto& spec = std::get>(listen); - protocol = "https://"; - port = std::to_string(spec.endpoint.port()); + protocol = "https://"; + port = std::to_string(spec->endpoint.port()); break; } - else if (std::holds_alternative>(listen)) + else if (const auto* spec = + std::get_if>(&listen)) { - const auto& spec = std::get>(listen); - protocol = "http://"; - port = std::to_string(spec.endpoint.port()); + protocol = "http://"; + port = std::to_string(spec->endpoint.port()); } } xAdminSubdomain = protocol + xAdminSubdomain + ":" + port; @@ -2411,8 +2411,7 @@ void run(const std::string& db_path, std::string message = "Node is not yet booted. To boot, use the 'psibase boot' CLI"; if (!xAdminSubdomain.empty()) { - message += " or visit '" + xAdminSubdomain + - "' app in browser for a graphical boot interface"; + message += " or visit '" + xAdminSubdomain + "' for node setup"; } PSIBASE_LOG(node.chain().getLogger(), notice) << message; diff --git a/programs/psitest/main.cpp b/programs/psitest/main.cpp index 5f7866059..b92a6d5ee 100644 --- a/programs/psitest/main.cpp +++ b/programs/psitest/main.cpp @@ -1358,7 +1358,8 @@ struct callbacks psibase::BlockContext bc{*chain.sys, chain.head, chain.writer, true}; bc.start(); - psibase::check(!bc.needGenesisAction, "Need genesis block; use 'psibase boot' to boot chain"); + psibase::check(!bc.needGenesisAction, + "Node is not yet booted. To boot, use the 'psibase boot' CLI"); psibase::SignedTransaction trx; psibase::TransactionContext tc{bc, trx, trace, true, false, true}; diff --git a/rust/psibase/src/main.rs b/rust/psibase/src/main.rs index 109675b69..ea37b0286 100644 --- a/rust/psibase/src/main.rs +++ b/rust/psibase/src/main.rs @@ -729,7 +729,7 @@ async fn boot( progress.inc(1) } if !args.suppress_ok { - println!("Ok. Successfully booted {}", args.api); + println!("Ok, booted {}", args.api); } Ok(()) } @@ -1166,7 +1166,7 @@ fn handle_unbooted(list: Result) -> Result Date: Wed, 4 Dec 2024 20:47:47 +0000 Subject: [PATCH 5/6] reword the response message when node is not connected --- libraries/psibase/native/include/psibase/ForkDb.hpp | 2 +- libraries/psibase_http/handle_request.cpp | 2 +- programs/psinode/main.cpp | 6 +++--- programs/psitest/main.cpp | 3 +-- rust/psibase/src/main.rs | 2 +- 5 files changed, 7 insertions(+), 8 deletions(-) diff --git a/libraries/psibase/native/include/psibase/ForkDb.hpp b/libraries/psibase/native/include/psibase/ForkDb.hpp index 1c160b569..d18a8f2d5 100644 --- a/libraries/psibase/native/include/psibase/ForkDb.hpp +++ b/libraries/psibase/native/include/psibase/ForkDb.hpp @@ -1449,7 +1449,7 @@ namespace psibase try { if (bc->needGenesisAction) - trace.error = "Node is not yet booted. To boot, use the 'psibase boot' CLI"; + trace.error = "Node is not connected to any psibase network."; else { check(trx.proofs.size() == trx.transaction->claims().size(), diff --git a/libraries/psibase_http/handle_request.cpp b/libraries/psibase_http/handle_request.cpp index d7edc92eb..6ba2d3b10 100644 --- a/libraries/psibase_http/handle_request.cpp +++ b/libraries/psibase_http/handle_request.cpp @@ -696,7 +696,7 @@ namespace psibase::http bc.start(); if (bc.needGenesisAction) return send(error(bhttp::status::internal_server_error, - "Node is not yet booted. To boot, use the 'psibase boot' CLI")); + "Node is not connected to any psibase network.")); SignedTransaction trx; TransactionTrace trace; diff --git a/programs/psinode/main.cpp b/programs/psinode/main.cpp index 5ba41ea60..1daab2c5a 100644 --- a/programs/psinode/main.cpp +++ b/programs/psinode/main.cpp @@ -688,7 +688,7 @@ bool pushTransaction(psibase::SharedState& sharedState, try { if (bc.needGenesisAction) - trace.error = "Node is not yet booted. To boot, use the 'psibase boot' CLI"; + trace.error = "Node is not connected to any psibase network."; else { check(trx.proofs.size() == trx.transaction->claims().size(), @@ -2408,10 +2408,10 @@ void run(const std::string& db_path, xAdminSubdomain = protocol + xAdminSubdomain + ":" + port; } - std::string message = "Node is not yet booted. To boot, use the 'psibase boot' CLI"; + std::string message = "Node is not connected to any psibase network."; if (!xAdminSubdomain.empty()) { - message += " or visit '" + xAdminSubdomain + "' for node setup"; + message += " Visit '" + xAdminSubdomain + "' for node setup."; } PSIBASE_LOG(node.chain().getLogger(), notice) << message; diff --git a/programs/psitest/main.cpp b/programs/psitest/main.cpp index b92a6d5ee..9b276d96c 100644 --- a/programs/psitest/main.cpp +++ b/programs/psitest/main.cpp @@ -1358,8 +1358,7 @@ struct callbacks psibase::BlockContext bc{*chain.sys, chain.head, chain.writer, true}; bc.start(); - psibase::check(!bc.needGenesisAction, - "Node is not yet booted. To boot, use the 'psibase boot' CLI"); + psibase::check(!bc.needGenesisAction, "Node is not connected to any psibase network."); psibase::SignedTransaction trx; psibase::TransactionContext tc{bc, trx, trace, true, false, true}; diff --git a/rust/psibase/src/main.rs b/rust/psibase/src/main.rs index 094f9065f..655ab6e8e 100644 --- a/rust/psibase/src/main.rs +++ b/rust/psibase/src/main.rs @@ -1258,7 +1258,7 @@ fn handle_unbooted(list: Result) -> Result Date: Wed, 4 Dec 2024 20:49:45 +0000 Subject: [PATCH 6/6] fix after merge --- rust/psibase/src/main.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rust/psibase/src/main.rs b/rust/psibase/src/main.rs index 655ab6e8e..b7f930600 100644 --- a/rust/psibase/src/main.rs +++ b/rust/psibase/src/main.rs @@ -825,7 +825,7 @@ async fn boot(args: &BootArgs) -> Result<(), anyhow::Error> { } if !args.tx_args.suppress_ok { - println!("Ok, booted {}", args.api); + println!("Successfully booted {}", args.node_args.api); } Ok(()) }