From d28bcdf4f54d4574f8dc42c6cdd94a2775422c29 Mon Sep 17 00:00:00 2001 From: drcpu Date: Sat, 4 Jun 2022 21:30:20 +0200 Subject: [PATCH] feat(nodestats): add counters to monitor failed data requests --- data_structures/src/chain.rs | 4 ++++ node/src/actors/chain_manager/mining.rs | 2 ++ src/cli/node/json_rpc_client.rs | 4 ++++ 3 files changed, 10 insertions(+) diff --git a/data_structures/src/chain.rs b/data_structures/src/chain.rs index 97117b3d8..4d003aa56 100644 --- a/data_structures/src/chain.rs +++ b/data_structures/src/chain.rs @@ -3195,8 +3195,12 @@ pub struct NodeStats { pub block_proposed_count: u32, /// Number of blocks included in the block chain pub block_mined_count: u32, + /// Number of times we could not solve a data request because the collateral requirement was too high + pub dr_insufficient_collateral_count: u32, /// Number of times we were eligible to participate in a Data Request pub dr_eligibility_count: u32, + /// Number of times we were eligible to participate in a Data Request but all our collateral was locked + pub dr_all_collateral_locked_count: u32, /// Number of proposed commits pub commits_proposed_count: u32, /// Number of commits included in a data request diff --git a/node/src/actors/chain_manager/mining.rs b/node/src/actors/chain_manager/mining.rs index d10e9960b..d2e227a0e 100644 --- a/node/src/actors/chain_manager/mining.rs +++ b/node/src/actors/chain_manager/mining.rs @@ -393,6 +393,7 @@ impl ChainManager { block_number_limit, ) { log::debug!("Mining data request: Insufficient collateral, the data request need {} mature wits", Wit::from_nanowits(collateral_amount)); + self.chain_state.node_stats.dr_insufficient_collateral_count += 1; continue; } @@ -520,6 +521,7 @@ impl ChainManager { available_balance, required_collateral, ); + act.chain_state.node_stats.dr_all_collateral_locked_count += 1; // Decrease the retrieval limit hoping that some other, cheaper, // data request can be resolved instead cloned_retrieval_count2.fetch_sub(added_retrieval_count, atomic::Ordering::Relaxed); diff --git a/src/cli/node/json_rpc_client.rs b/src/cli/node/json_rpc_client.rs index 85bb7f8f4..65a8c48f8 100644 --- a/src/cli/node/json_rpc_client.rs +++ b/src/cli/node/json_rpc_client.rs @@ -1212,13 +1212,17 @@ pub fn get_node_stats(addr: SocketAddr) -> Result<(), failure::Error> { - Proposed blocks: {}\n\ - Blocks included in the block chain: {}\n\ Data Request mining stats:\n\ + - Times with insuffiencent collateral to mine a data request: {}\n\ - Times with eligibility to mine a data request: {}\n\ + - Times with no available collateral to mine a data request: {}\n\ - Proposed commits: {}\n\ - Accepted commits: {}\n\ - Slashed commits: {}", node_stats.block_proposed_count, node_stats.block_mined_count, + node_stats.dr_insufficient_collateral_count, node_stats.dr_eligibility_count, + node_stats.dr_all_collateral_locked_count, node_stats.commits_proposed_count, node_stats.commits_count, node_stats.slashed_count