From ab995e4ec6965fd7a913019e3ce1b157922d84ba Mon Sep 17 00:00:00 2001 From: Colin LeMahieu Date: Sat, 23 Mar 2024 16:24:36 +0000 Subject: [PATCH] Remove confirmation_height_currently_processing RPC as it's only for debugging and make the process of confirming more complicated. --- nano/node/json_handler.cpp | 15 --------- nano/node/json_handler.hpp | 1 - nano/rpc/rpc_handler.cpp | 1 - nano/rpc_test/rpc.cpp | 66 -------------------------------------- 4 files changed, 83 deletions(-) diff --git a/nano/node/json_handler.cpp b/nano/node/json_handler.cpp index 9394e7364..7465385a5 100644 --- a/nano/node/json_handler.cpp +++ b/nano/node/json_handler.cpp @@ -2002,20 +2002,6 @@ void nano::json_handler::confirmation_active () response_errors (); } -void nano::json_handler::confirmation_height_currently_processing () -{ - auto hash = node.confirmation_height_processor.current (); - if (!hash.is_zero ()) - { - response_l.put ("hash", hash.to_string ()); - } - else - { - ec = nano::error_rpc::confirmation_height_not_processing; - } - response_errors (); -} - void nano::json_handler::confirmation_history () { boost::property_tree::ptree elections; @@ -5334,7 +5320,6 @@ ipc_json_handler_no_arg_func_map create_ipc_json_handler_no_arg_func_map () no_arg_funcs.emplace ("bootstrap_lazy", &nano::json_handler::bootstrap_lazy); no_arg_funcs.emplace ("bootstrap_status", &nano::json_handler::bootstrap_status); no_arg_funcs.emplace ("confirmation_active", &nano::json_handler::confirmation_active); - no_arg_funcs.emplace ("confirmation_height_currently_processing", &nano::json_handler::confirmation_height_currently_processing); no_arg_funcs.emplace ("confirmation_history", &nano::json_handler::confirmation_history); no_arg_funcs.emplace ("confirmation_info", &nano::json_handler::confirmation_info); no_arg_funcs.emplace ("confirmation_quorum", &nano::json_handler::confirmation_quorum); diff --git a/nano/node/json_handler.hpp b/nano/node/json_handler.hpp index cb7da62c7..cc8d7b7a8 100644 --- a/nano/node/json_handler.hpp +++ b/nano/node/json_handler.hpp @@ -64,7 +64,6 @@ public: void confirmation_history (); void confirmation_info (); void confirmation_quorum (); - void confirmation_height_currently_processing (); void debug_bootstrap_priority_info (); void database_txn_tracker (); void delegators (); diff --git a/nano/rpc/rpc_handler.cpp b/nano/rpc/rpc_handler.cpp index 241c46c47..4d4a6f36d 100644 --- a/nano/rpc/rpc_handler.cpp +++ b/nano/rpc/rpc_handler.cpp @@ -152,7 +152,6 @@ std::unordered_set create_rpc_control_impls () set.emplace ("backoff_info"); set.emplace ("block_create"); set.emplace ("bootstrap_lazy"); - set.emplace ("confirmation_height_currently_processing"); set.emplace ("database_txn_tracker"); set.emplace ("epoch_upgrade"); set.emplace ("keepalive"); diff --git a/nano/rpc_test/rpc.cpp b/nano/rpc_test/rpc.cpp index 3771fd04e..9b8b3b086 100644 --- a/nano/rpc_test/rpc.cpp +++ b/nano/rpc_test/rpc.cpp @@ -5202,72 +5202,6 @@ TEST (rpc, online_reps) node2->stop (); } -TEST (rpc, confirmation_height_currently_processing) -{ - nano::test::system system; - nano::node_flags node_flags; - node_flags.force_use_write_database_queue = true; - nano::node_config node_config = system.default_config (); - node_config.frontiers_confirmation = nano::frontiers_confirmation_mode::disabled; - - auto node = add_ipc_enabled_node (system, node_config, node_flags); - system.wallet (0)->insert_adhoc (nano::dev::genesis_key.prv); - - auto previous_genesis_chain_hash = node->latest (nano::dev::genesis_key.pub); - { - auto transaction = node->store.tx_begin_write (); - nano::keypair key1; - nano::block_builder builder; - auto send = builder - .send () - .previous (previous_genesis_chain_hash) - .destination (key1.pub) - .balance (nano::dev::constants.genesis_amount - nano::Gxrb_ratio - 1) - .sign (nano::dev::genesis_key.prv, nano::dev::genesis_key.pub) - .work (*system.work.generate (previous_genesis_chain_hash)) - .build (); - ASSERT_EQ (nano::block_status::progress, node->ledger.process (transaction, send)); - previous_genesis_chain_hash = send->hash (); - } - - std::shared_ptr frontier; - { - auto transaction = node->store.tx_begin_read (); - frontier = node->ledger.block (transaction, previous_genesis_chain_hash); - } - - boost::property_tree::ptree request; - request.put ("action", "confirmation_height_currently_processing"); - - auto const rpc_ctx = add_rpc (system, node); - - // Begin process for confirming the block (and setting confirmation height) - { - // Write guard prevents the confirmation height processor writing the blocks, so that we can inspect contents during the response - auto write_guard = node->write_database_queue.wait (nano::writer::testing); - nano::test::start_election (system, *node, frontier->hash ()); - - ASSERT_TIMELY_EQ (5s, node->confirmation_height_processor.current (), frontier->hash ()); - - // Make the request - { - auto response (wait_response (system, rpc_ctx, request, 10s)); - auto hash (response.get ("hash")); - ASSERT_EQ (frontier->hash ().to_string (), hash); - } - } - - // Wait until confirmation has been set and not processing anything - ASSERT_TIMELY (10s, node->confirmation_height_processor.current ().is_zero () && node->confirmation_height_processor.awaiting_processing_size () == 0); - - // Make the same request, it should now return an error - { - auto response (wait_response (system, rpc_ctx, request, 10s)); - std::error_code ec (nano::error_rpc::confirmation_height_not_processing); - ASSERT_EQ (response.get ("error"), ec.message ()); - } -} - TEST (rpc, confirmation_history) { nano::test::system system;