From b90c40ac2ef6bc9f5e1eb7325a198a3cbaa5a1a7 Mon Sep 17 00:00:00 2001 From: Don Date: Tue, 20 Sep 2022 10:17:49 -0700 Subject: [PATCH 1/8] unused crates and unused variables --- testnet/stacks-node/src/config.rs | 4 ++-- testnet/stacks-node/src/main.rs | 4 ++-- testnet/stacks-node/src/neon_node.rs | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/testnet/stacks-node/src/config.rs b/testnet/stacks-node/src/config.rs index d2e518fb0..b23c79edd 100644 --- a/testnet/stacks-node/src/config.rs +++ b/testnet/stacks-node/src/config.rs @@ -523,7 +523,7 @@ impl Config { name: node.name.unwrap_or(default_node_config.name), seed: match node.seed { Some(seed) => hex_bytes(&seed) - .map_err(|e| format!("node.seed should be a hex encoded string"))?, + .map_err(|_e| format!("node.seed should be a hex encoded string"))?, None => default_node_config.seed, }, working_dir: node.working_dir.unwrap_or(default_node_config.working_dir), @@ -537,7 +537,7 @@ impl Config { None => format!("http://{}", rpc_bind), }, local_peer_seed: match node.local_peer_seed { - Some(seed) => hex_bytes(&seed).map_err(|e| { + Some(seed) => hex_bytes(&seed).map_err(|_e| { format!("node.local_peer_seed should be a hex encoded string") })?, None => default_node_config.local_peer_seed, diff --git a/testnet/stacks-node/src/main.rs b/testnet/stacks-node/src/main.rs index 220972425..b7f20e5bb 100644 --- a/testnet/stacks-node/src/main.rs +++ b/testnet/stacks-node/src/main.rs @@ -120,8 +120,8 @@ fn main() { process::exit(1); } }; - let conf = match Config::from_config_file(config_file) { - Ok(conf) => { + match Config::from_config_file(config_file) { + Ok(_) => { info!("Loaded config!"); process::exit(0); } diff --git a/testnet/stacks-node/src/neon_node.rs b/testnet/stacks-node/src/neon_node.rs index 566232b7a..e3058a0b0 100644 --- a/testnet/stacks-node/src/neon_node.rs +++ b/testnet/stacks-node/src/neon_node.rs @@ -68,7 +68,7 @@ use crate::run_loop::neon::RunLoop; use crate::run_loop::RegisteredKey; use crate::ChainTip; -use super::{BurnchainController, BurnchainTip, Config, EventDispatcher, Keychain}; +use super::{BurnchainController, Config, EventDispatcher, Keychain}; use crate::stacks::vm::database::BurnStateDB; use stacks::monitoring; From 11c36846256cd773e43dc6e537fc955605d0ccbd Mon Sep 17 00:00:00 2001 From: Don Date: Tue, 20 Sep 2022 10:30:20 -0700 Subject: [PATCH 2/8] designate unused vars with _name. leaving the fields in the struct for completeness when compared to matching bitcoin struct --- .../src/burnchains/bitcoin_regtest_controller.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/testnet/stacks-node/src/burnchains/bitcoin_regtest_controller.rs b/testnet/stacks-node/src/burnchains/bitcoin_regtest_controller.rs index bbdec5530..8db6288cc 100644 --- a/testnet/stacks-node/src/burnchains/bitcoin_regtest_controller.rs +++ b/testnet/stacks-node/src/burnchains/bitcoin_regtest_controller.rs @@ -1680,10 +1680,10 @@ pub struct ParsedUTXO { script_pub_key: String, amount: Box, confirmations: u32, - spendable: bool, - solvable: bool, - desc: Option, - safe: bool, + _spendable: bool, + _solvable: bool, + _desc: Option, + _safe: bool, } #[derive(Clone, Debug, PartialEq)] From d3c1ffa1669685b2171e9386f9227e63d257dacd Mon Sep 17 00:00:00 2001 From: Don Date: Tue, 20 Sep 2022 10:30:49 -0700 Subject: [PATCH 3/8] fields are set but not read. allowing dead_code to mute warning --- testnet/stacks-node/src/keychain.rs | 1 + testnet/stacks-node/src/syncctl.rs | 1 + 2 files changed, 2 insertions(+) diff --git a/testnet/stacks-node/src/keychain.rs b/testnet/stacks-node/src/keychain.rs index bc98f7316..4cd727537 100644 --- a/testnet/stacks-node/src/keychain.rs +++ b/testnet/stacks-node/src/keychain.rs @@ -11,6 +11,7 @@ use stacks::util::vrf::{VRFPrivateKey, VRFProof, VRFPublicKey, VRF}; use super::operations::BurnchainOpSigner; +#[allow(dead_code)] #[derive(Clone)] pub struct Keychain { secret_keys: Vec, diff --git a/testnet/stacks-node/src/syncctl.rs b/testnet/stacks-node/src/syncctl.rs index 80afa35de..92ab71350 100644 --- a/testnet/stacks-node/src/syncctl.rs +++ b/testnet/stacks-node/src/syncctl.rs @@ -19,6 +19,7 @@ use std::sync::{ // network if your node is actualy waiting a day in-between reward cycles). const SYNC_WAIT_SECS: u64 = 24 * 3600; +#[allow(dead_code)] #[derive(Clone)] pub struct PoxSyncWatchdogComms { /// how many passes in the p2p state machine have taken place since startup? From 6195c79b43a8d828c632c1a0401d9ac73bf887a2 Mon Sep 17 00:00:00 2001 From: Don Date: Tue, 20 Sep 2022 11:09:12 -0700 Subject: [PATCH 4/8] prefer _name over dead_code --- testnet/stacks-node/src/keychain.rs | 5 ++--- testnet/stacks-node/src/syncctl.rs | 5 ++--- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/testnet/stacks-node/src/keychain.rs b/testnet/stacks-node/src/keychain.rs index 4cd727537..8e8a63db4 100644 --- a/testnet/stacks-node/src/keychain.rs +++ b/testnet/stacks-node/src/keychain.rs @@ -11,7 +11,6 @@ use stacks::util::vrf::{VRFPrivateKey, VRFProof, VRFPublicKey, VRF}; use super::operations::BurnchainOpSigner; -#[allow(dead_code)] #[derive(Clone)] pub struct Keychain { secret_keys: Vec, @@ -21,7 +20,7 @@ pub struct Keychain { microblocks_secret_keys: Vec, vrf_secret_keys: Vec, vrf_map: HashMap, - rotations: u64, + _rotations: u64, } impl Keychain { @@ -47,7 +46,7 @@ impl Keychain { microblocks_secret_keys: vec![], secret_keys, threshold, - rotations: 0, + _rotations: 0, vrf_secret_keys: vec![], vrf_map: HashMap::new(), } diff --git a/testnet/stacks-node/src/syncctl.rs b/testnet/stacks-node/src/syncctl.rs index 92ab71350..0362b390e 100644 --- a/testnet/stacks-node/src/syncctl.rs +++ b/testnet/stacks-node/src/syncctl.rs @@ -19,7 +19,6 @@ use std::sync::{ // network if your node is actualy waiting a day in-between reward cycles). const SYNC_WAIT_SECS: u64 = 24 * 3600; -#[allow(dead_code)] #[derive(Clone)] pub struct PoxSyncWatchdogComms { /// how many passes in the p2p state machine have taken place since startup? @@ -29,7 +28,7 @@ pub struct PoxSyncWatchdogComms { /// how many times have we done a download pass? download_passes: Arc, /// What's the burnchain tip we last saw? - burnchain_tip_height: Arc, + _burnchain_tip_height: Arc, /// What's our last IBD status? last_ibd: Arc, /// Should keep running? @@ -42,7 +41,7 @@ impl PoxSyncWatchdogComms { p2p_state_passes: Arc::new(AtomicU64::new(0)), inv_sync_passes: Arc::new(AtomicU64::new(0)), download_passes: Arc::new(AtomicU64::new(0)), - burnchain_tip_height: Arc::new(AtomicU64::new(0)), + _burnchain_tip_height: Arc::new(AtomicU64::new(0)), last_ibd: Arc::new(AtomicBool::new(true)), should_keep_running, } From 7645beaafed8d290908c2f6f77eea8398caeb555 Mon Sep 17 00:00:00 2001 From: Don Date: Mon, 26 Sep 2022 11:16:06 -0700 Subject: [PATCH 5/8] remove unused fields instead of _name --- .../stacks-node/src/burnchains/bitcoin_regtest_controller.rs | 4 ---- testnet/stacks-node/src/keychain.rs | 2 -- testnet/stacks-node/src/syncctl.rs | 3 --- 3 files changed, 9 deletions(-) diff --git a/testnet/stacks-node/src/burnchains/bitcoin_regtest_controller.rs b/testnet/stacks-node/src/burnchains/bitcoin_regtest_controller.rs index 8db6288cc..a6e1f7ca5 100644 --- a/testnet/stacks-node/src/burnchains/bitcoin_regtest_controller.rs +++ b/testnet/stacks-node/src/burnchains/bitcoin_regtest_controller.rs @@ -1680,10 +1680,6 @@ pub struct ParsedUTXO { script_pub_key: String, amount: Box, confirmations: u32, - _spendable: bool, - _solvable: bool, - _desc: Option, - _safe: bool, } #[derive(Clone, Debug, PartialEq)] diff --git a/testnet/stacks-node/src/keychain.rs b/testnet/stacks-node/src/keychain.rs index 8e8a63db4..98506e308 100644 --- a/testnet/stacks-node/src/keychain.rs +++ b/testnet/stacks-node/src/keychain.rs @@ -20,7 +20,6 @@ pub struct Keychain { microblocks_secret_keys: Vec, vrf_secret_keys: Vec, vrf_map: HashMap, - _rotations: u64, } impl Keychain { @@ -46,7 +45,6 @@ impl Keychain { microblocks_secret_keys: vec![], secret_keys, threshold, - _rotations: 0, vrf_secret_keys: vec![], vrf_map: HashMap::new(), } diff --git a/testnet/stacks-node/src/syncctl.rs b/testnet/stacks-node/src/syncctl.rs index 0362b390e..138235d9f 100644 --- a/testnet/stacks-node/src/syncctl.rs +++ b/testnet/stacks-node/src/syncctl.rs @@ -27,8 +27,6 @@ pub struct PoxSyncWatchdogComms { inv_sync_passes: Arc, /// how many times have we done a download pass? download_passes: Arc, - /// What's the burnchain tip we last saw? - _burnchain_tip_height: Arc, /// What's our last IBD status? last_ibd: Arc, /// Should keep running? @@ -41,7 +39,6 @@ impl PoxSyncWatchdogComms { p2p_state_passes: Arc::new(AtomicU64::new(0)), inv_sync_passes: Arc::new(AtomicU64::new(0)), download_passes: Arc::new(AtomicU64::new(0)), - _burnchain_tip_height: Arc::new(AtomicU64::new(0)), last_ibd: Arc::new(AtomicBool::new(true)), should_keep_running, } From 44e412598f6f9b1a4e5952364b40c86563ed6b9a Mon Sep 17 00:00:00 2001 From: Don Date: Thu, 29 Sep 2022 11:51:15 -0700 Subject: [PATCH 6/8] parenthesis warning fixes --- src/chainstate/burn/db/sortdb.rs | 6 +++--- src/chainstate/stacks/index/storage.rs | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/chainstate/burn/db/sortdb.rs b/src/chainstate/burn/db/sortdb.rs index ba8893ddc..e326fea72 100644 --- a/src/chainstate/burn/db/sortdb.rs +++ b/src/chainstate/burn/db/sortdb.rs @@ -2589,9 +2589,9 @@ impl SortitionDB { pub fn is_db_version_supported_in_epoch(epoch: StacksEpochId, version: &str) -> bool { match epoch { StacksEpochId::Epoch10 => true, - StacksEpochId::Epoch20 => (version == "1" || version == "2" || version == "3"), - StacksEpochId::Epoch2_05 => (version == "2" || version == "3"), - StacksEpochId::Epoch21 => (version == "3"), + StacksEpochId::Epoch20 => version == "1" || version == "2" || version == "3", + StacksEpochId::Epoch2_05 => version == "2" || version == "3", + StacksEpochId::Epoch21 => version == "3", } } diff --git a/src/chainstate/stacks/index/storage.rs b/src/chainstate/stacks/index/storage.rs index 66fc43125..4bb57db52 100644 --- a/src/chainstate/stacks/index/storage.rs +++ b/src/chainstate/stacks/index/storage.rs @@ -1830,7 +1830,7 @@ impl<'a, T: MarfTrieId> TrieStorageTransaction<'a, T> { let size_hint = match self.data.uncommitted_writes { Some((_, ref trie_storage)) => 2 * trie_storage.size_hint(), - None => (1024), // don't try to guess _byte_ allocation here. + None => 1024, // don't try to guess _byte_ allocation here. }; let trie_buf = TrieRAM::new(bhh, size_hint, &self.data.cur_block); @@ -1872,7 +1872,7 @@ impl<'a, T: MarfTrieId> TrieStorageTransaction<'a, T> { // new trie let size_hint = match self.data.uncommitted_writes { Some((_, ref trie_storage)) => 2 * trie_storage.size_hint(), - None => (1024), // don't try to guess _byte_ allocation here. + None => 1024, // don't try to guess _byte_ allocation here. }; ( From 7cc1b13f548b86c6652e42b4ed01d874c929dbe9 Mon Sep 17 00:00:00 2001 From: Don Date: Fri, 30 Sep 2022 09:08:04 -0700 Subject: [PATCH 7/8] unpacking tuples into (_unused, used) --- testnet/stacks-node/src/tests/epoch_21.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/testnet/stacks-node/src/tests/epoch_21.rs b/testnet/stacks-node/src/tests/epoch_21.rs index 02b9ab08f..696672817 100644 --- a/testnet/stacks-node/src/tests/epoch_21.rs +++ b/testnet/stacks-node/src/tests/epoch_21.rs @@ -1023,7 +1023,7 @@ fn transition_adds_get_pox_addr_recipients() { let stacked = 100_000_000_000 * (core::MICROSTACKS_PER_STACKS as u64); - for i in 0..4 { + for _i in 0..4 { let spender_sk = StacksPrivateKey::new(); let spender_addr: PrincipalData = to_addr(&spender_sk).into(); @@ -1045,7 +1045,7 @@ fn transition_adds_get_pox_addr_recipients() { .to_vec(), ); - let (conf, btcd_controller, mut btc_regtest_controller, blocks_processed, coord_channel) = + let (conf, _btcd_controller, mut btc_regtest_controller, blocks_processed, coord_channel) = advance_to_2_1(initial_balances, None, Some(pox_constants.clone())); let mut sort_height = coord_channel.get_sortitions_processed(); @@ -1167,7 +1167,7 @@ fn transition_adds_get_pox_addr_recipients() { let parsed = StacksTransaction::consensus_deserialize(&mut &tx_bytes[..]).unwrap(); if parsed.txid() == cc_txid { // check events for this block - for (i, event) in events.iter().enumerate() { + for (_i, event) in events.iter().enumerate() { if let Some(cev) = event.get("contract_event") { // strip leading `0x` let clarity_serialized_value = hex_bytes( From 48dc9c98dc36e19b2a591d9d65186a00806ad451 Mon Sep 17 00:00:00 2001 From: Don Date: Fri, 30 Sep 2022 09:08:15 -0700 Subject: [PATCH 8/8] unused module --- testnet/stacks-node/src/tests/neon_integrations.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/testnet/stacks-node/src/tests/neon_integrations.rs b/testnet/stacks-node/src/tests/neon_integrations.rs index 9e1bfe975..b6f299254 100644 --- a/testnet/stacks-node/src/tests/neon_integrations.rs +++ b/testnet/stacks-node/src/tests/neon_integrations.rs @@ -73,7 +73,7 @@ use super::{ SK_2, }; use stacks::chainstate::stacks::miner::{ - TransactionErrorEvent, TransactionEvent, TransactionSkippedEvent, TransactionSuccessEvent, + TransactionErrorEvent, TransactionEvent, TransactionSuccessEvent, }; use crate::config::FeeEstimatorName;