Skip to content

Commit

Permalink
WIP on fix_ci
Browse files Browse the repository at this point in the history
clippy
  • Loading branch information
SWvheerden committed Jul 9, 2024
1 parent e9a3444 commit 2834cfc
Show file tree
Hide file tree
Showing 67 changed files with 177 additions and 244 deletions.
16 changes: 12 additions & 4 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ const REQUIRED_IDENTITY_PERMS: u32 = 0o100600;
/// - `identity_file` - Reference to file path
/// - `public_address` - Network address of the base node
/// - `create_id` - Only applies if the identity_file does not exist or is malformed. If true, a new identity will be
/// created, otherwise the user will be prompted to create a new ID
/// created, otherwise the user will be prompted to create a new ID
/// - `peer_features` - Enables features of the base node
///
/// # Return
Expand Down
2 changes: 1 addition & 1 deletion applications/minotari_console_wallet/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ futures = { version = "^0.3.16", default-features = false, features = [
] }
ledger-transport-hid = { git = "https://github.com/Zondax/ledger-rs", rev = "20e2a20", optional = true }
log = { version = "0.4.8", features = ["std"] }
log4rs = { version = "1.3.0", default_features = false, features = [
log4rs = { version = "1.3.0", default-features = false, features = [
"config_parsing",
"threshold_filter",
"yaml_format",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -409,7 +409,7 @@ pub async fn make_it_rain(
// - If a slower rate is requested as what is achievable, transactions will be delayed to match the rate.
// - If a faster rate is requested as what is achievable, the maximum rate will be that of the integrated system.
// - The default value of 25/s may not be achievable.
let transactions_per_second = transactions_per_second.abs().max(0.01).min(250.0);
let transactions_per_second = transactions_per_second.abs().clamp(0.01, 250.0);
// We are spawning this command in parallel, thus not collecting transaction IDs
tokio::task::spawn(async move {
// Wait until specified test start time
Expand Down
1 change: 1 addition & 0 deletions applications/minotari_console_wallet/src/notifier/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ pub const CANCELLED: &str = "cancelled";

#[derive(Clone)]
// FIXME
#[allow(dead_code)]
#[allow(clippy::large_enum_variant)]
pub enum WalletEventMessage {
Completed {
Expand Down
1 change: 1 addition & 0 deletions applications/minotari_console_wallet/src/ui/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ use crate::{
pub const LOG_TARGET: &str = "wallet::ui::app";

pub struct App<B: Backend> {
#[allow(dead_code)]
pub title: String,
pub should_quit: bool,
// Cached state this will need to be cleaned up into a threadsafe container
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,7 @@ pub struct BlockTemplateData {
pub monero_difficulty: u64,
pub tari_difficulty: u64,
pub tari_merge_mining_hash: FixedHash,
#[allow(dead_code)]
pub aux_chain_hashes: Vec<monero::Hash>,
pub new_block_template: grpc::NewBlockTemplate,
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ impl BlockTemplateProtocol<'_> {
let grpc::NewBlockTemplateResponse {
miner_data,
new_block_template: template,
initial_sync_achieved,
initial_sync_achieved: _,
} = self
.base_node_client
.get_new_block_template(grpc::NewBlockTemplateRequest {
Expand All @@ -289,11 +289,7 @@ impl BlockTemplateProtocol<'_> {

let miner_data = miner_data.ok_or(MmProxyError::GrpcResponseMissingField("miner_data"))?;
let template = template.ok_or(MmProxyError::GrpcResponseMissingField("new_block_template"))?;
Ok(NewBlockTemplateData {
template,
miner_data,
initial_sync_achieved,
})
Ok(NewBlockTemplateData { template, miner_data })
}

/// Check if the height is more than the actual tip. So if still makes sense to compute block for that height.
Expand Down Expand Up @@ -439,7 +435,6 @@ fn add_monero_data(
pub struct NewBlockTemplateData {
pub template: grpc::NewBlockTemplate,
pub miner_data: grpc::MinerData,
pub initial_sync_achieved: bool,
}

impl NewBlockTemplateData {
Expand Down
3 changes: 3 additions & 0 deletions applications/minotari_merge_mining_proxy/src/monero_fail.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,13 @@ pub struct MonerodEntry {
/// Whether the server is currently up
pub up: bool,
/// Whether the server is web compatible
#[allow(dead_code)]
pub web_compatible: bool,
/// The network the server is on (mainnet, stagenet, testnet)
#[allow(dead_code)]
pub network: String,
/// Time since the server was checked
#[allow(dead_code)]
pub last_checked: String,
/// The history of the server being up
pub up_history: Vec<bool>,
Expand Down
11 changes: 6 additions & 5 deletions applications/minotari_merge_mining_proxy/src/proxy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -642,11 +642,12 @@ impl InnerService {
};

// Query the list twice before giving up, starting after the last used entry
let pos = if let Some(index) = self.config.monerod_url.iter().position(|x| x == &last_used_url) {
index
} else {
0
};
let pos = self
.config
.monerod_url
.iter()
.position(|x| x == &last_used_url)
.unwrap_or(0);
let (left, right) = self.config.monerod_url.split_at(pos);
let left = left.to_vec();
let right = right.to_vec();
Expand Down
6 changes: 3 additions & 3 deletions applications/minotari_miner/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,14 @@ derivative = "2.2.0"
futures = "0.3"
hex = "0.4.2"
log = { version = "0.4", features = ["std"] }
log4rs = { version = "1.3.0", default_features = false, features = ["config_parsing", "threshold_filter", "yaml_format", "console_appender", "rolling_file_appender", "compound_policy", "size_trigger", "fixed_window_roller"] }
log4rs = { version = "1.3.0", default-features = false, features = ["config_parsing", "threshold_filter", "yaml_format", "console_appender", "rolling_file_appender", "compound_policy", "size_trigger", "fixed_window_roller"] }
native-tls = "0.2"
num_cpus = "1.13"
rand = "0.8"
serde = { version = "1.0", default_features = false, features = ["derive"] }
serde = { version = "1.0", default-features = false, features = ["derive"] }
serde_json = "1.0.57"
thiserror = "1.0"
tokio = { version = "1.36", default_features = false, features = ["rt-multi-thread"] }
tokio = { version = "1.36", default-features = false, features = ["rt-multi-thread"] }
tonic = { version = "0.8.3", features = ["tls", "tls-roots"] }

[dev-dependencies]
Expand Down
9 changes: 3 additions & 6 deletions applications/minotari_miner/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,11 @@
// configuration management
//! from [tari_common] crate, also extending with few
//! specific options:
//! - base_node_grpc_address - is IPv4/IPv6 address including port
//! number, by which Minotari Base Node can be found
//! - base_node_grpc_address - is IPv4/IPv6 address including port number, by which Minotari Base Node can be found
//! - num_mining_threads - number of mining threads, defaults to number of cpu cores
//! - mine_on_tip_only - will start mining only when node is reporting bootstrapped state
//! - validate_tip_timeout_sec - will check tip with node every N seconds to validate that still
//! mining on a tip
//! All miner options configured under `[miner]` section of
//! Minotari's `config.toml`.
//! - validate_tip_timeout_sec - will check tip with node every N seconds to validate that still mining on a tip All
//! miner options configured under `[miner]` section of Minotari's `config.toml`.
use std::{
path::{Path, PathBuf},
Expand Down
3 changes: 0 additions & 3 deletions applications/minotari_miner/src/miner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ pub struct MiningReport {
/// Will be set for when mined header is matching required difficulty
pub header: Option<BlockHeader>,
pub height: u64,
pub last_nonce: u64,
}

/// Miner is starting number of mining threads and implements Stream for async reports polling
Expand Down Expand Up @@ -212,7 +211,6 @@ pub fn mining_task(
hashes: hasher.hashes,
elapsed: start.elapsed(),
height: hasher.height(),
last_nonce: hasher.header.nonce,
header: Some(hasher.create_header()),
target_difficulty,
}) {
Expand All @@ -235,7 +233,6 @@ pub fn mining_task(
hashes: hasher.hashes,
elapsed: start.elapsed(),
header: None,
last_nonce: hasher.header.nonce,
height: hasher.height(),
target_difficulty,
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ use serde::{Deserialize, Serialize};
pub struct LoginParams {
pub login: String,
#[derivative(Debug = "ignore")]
#[allow(dead_code)]
#[serde(skip_serializing)]
pub pass: String,
pub agent: String,
Expand Down
2 changes: 1 addition & 1 deletion applications/minotari_node/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ futures = { version = "^0.3.16", default-features = false, features = ["alloc"]
qrcode = { version = "0.12" }
log = { version = "0.4.8", features = ["std"] }
log-mdc = "0.1.0"
log4rs = { version = "1.3.0", default_features = false, features = ["config_parsing", "threshold_filter", "yaml_format", "console_appender", "rolling_file_appender", "compound_policy", "size_trigger", "fixed_window_roller"] }
log4rs = { version = "1.3.0", default-features = false, features = ["config_parsing", "threshold_filter", "yaml_format", "console_appender", "rolling_file_appender", "compound_policy", "size_trigger", "fixed_window_roller"] }
nom = "7.1"
rustyline = "9.0"
rustyline-derive = "0.5"
Expand Down
8 changes: 1 addition & 7 deletions applications/minotari_node/src/bootstrap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,7 @@
// WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
// USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

use std::{
cmp,
str::FromStr,
sync::{Arc, RwLock},
};
use std::{cmp, str::FromStr, sync::Arc};

use log::*;
use minotari_app_utilities::{consts, identity_management, identity_management::load_from_json};
Expand Down Expand Up @@ -56,7 +52,6 @@ use tari_core::{
mempool::{service::MempoolHandle, Mempool, MempoolServiceInitializer, MempoolSyncInitializer},
proof_of_work::randomx_factory::RandomXFactory,
transactions::CryptoFactories,
OutputSmt,
};
use tari_p2p::{
auto_update::SoftwareUpdaterService,
Expand Down Expand Up @@ -86,7 +81,6 @@ pub struct BaseNodeBootstrapper<'a, B> {
pub factories: CryptoFactories,
pub randomx_factory: RandomXFactory,
pub interrupt_signal: ShutdownSignal,
pub smt: Arc<RwLock<OutputSmt>>,
}

impl<B> BaseNodeBootstrapper<'_, B>
Expand Down
1 change: 0 additions & 1 deletion applications/minotari_node/src/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,6 @@ async fn build_node_context(
factories: factories.clone(),
randomx_factory,
interrupt_signal: interrupt_signal.clone(),
smt,
}
.bootstrap()
.await?;
Expand Down
4 changes: 0 additions & 4 deletions applications/minotari_node/src/commands/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,6 @@ use thiserror::Error;

use super::command::Command;

#[derive(Debug, Error)]
#[error("invalid format '{0}'")]
pub struct FormatParseError(String);

#[derive(Debug, Display, EnumString)]
#[strum(serialize_all = "kebab-case")]
pub enum Format {
Expand Down
1 change: 1 addition & 0 deletions base_layer/chat_ffi/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ pub enum InterfaceError {
#[derive(Debug, Clone)]
pub struct LibChatError {
pub code: i32,
#[allow(dead_code)]
pub message: String,
}

Expand Down
3 changes: 1 addition & 2 deletions base_layer/contacts/src/contacts_service/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -224,9 +224,8 @@ where T: ContactsBackend + 'static
error!(target: LOG_TARGET, "Error handling request: {:?}", e);
e
});
let _result = reply_tx.send(response).map_err(|e| {
let _result = reply_tx.send(response).inspect_err(|_| {
error!(target: LOG_TARGET, "Failed to send reply");
e
});
},

Expand Down
3 changes: 3 additions & 0 deletions base_layer/core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -113,3 +113,6 @@ tari_features = { path = "../../common/tari_features", version = "1.0.0-pre.15"
[[bench]]
name = "mempool"
harness = false

[lints.rust]
unexpected_cfgs = { level = "warn", check-cfg = ['cfg(tari_target_network_mainnet)', 'cfg(tari_target_network_nextnet)', 'cfg(tari_target_network_testnet)'] }
2 changes: 1 addition & 1 deletion base_layer/core/src/chain_storage/lmdb_db/lmdb_db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1445,7 +1445,7 @@ impl LMDBDatabase {
seed: &[u8],
height: u64,
) -> Result<(), ChainStorageError> {
let current_height = lmdb_get(write_txn, &self.monero_seed_height_db, seed)?.unwrap_or(std::u64::MAX);
let current_height = lmdb_get(write_txn, &self.monero_seed_height_db, seed)?.unwrap_or(u64::MAX);
if height < current_height {
lmdb_replace(write_txn, &self.monero_seed_height_db, seed, &height, None)?;
};
Expand Down
2 changes: 1 addition & 1 deletion base_layer/core/src/common/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ use crate::consensus::DomainSeparatedConsensusHasher;

pub mod borsh;
pub mod byte_counter;
pub mod limited_reader;
// pub mod limited_reader;
pub mod one_sided;

#[cfg(feature = "base_node")]
Expand Down
43 changes: 0 additions & 43 deletions base_layer/core/src/consensus/consensus_constants.rs
Original file line number Diff line number Diff line change
Expand Up @@ -919,49 +919,6 @@ mod test {
ConsensusConstants::mainnet();
}

// Comment out the feature flag to run this test
#[test]
#[cfg(feature = "schedule_get_constants")]
fn esmeralda_schedule_get_constants() {
let mut esmeralda = ConsensusConstants::esmeralda();
loop {
let schedule = EmissionSchedule::new(
esmeralda[0].emission_initial,
esmeralda[0].emission_decay,
esmeralda[0].emission_tail,
);
// No genesis block coinbase
assert_eq!(schedule.block_reward(0), MicroMinotari(0));
// Coinbases starts at block 1
let coinbase_offset = 1;
let first_reward = schedule.block_reward(coinbase_offset);
assert_eq!(first_reward, esmeralda[0].emission_initial * uT);
assert_eq!(schedule.supply_at_block(coinbase_offset), first_reward);
// Tail emission starts after block 3,255,552 + coinbase_offset
let mut rewards = schedule
.iter()
.skip(3_255_552 + usize::try_from(coinbase_offset).unwrap());
let supply = loop {
let (block_num, reward, supply) = rewards.next().unwrap();
let total_supply = supply + esmeralda[0].faucet_value;
println!(
"Initial: {}, Block: {}, Reward: {}, Supply: {}, Total supply: {}",
esmeralda[0].emission_initial, block_num, reward, supply, total_supply
);
if reward == esmeralda[0].emission_tail {
break supply;
}
};
let total_supply_up_to_tail_emission = supply + esmeralda[0].faucet_value;
if total_supply_up_to_tail_emission >= 21_000_000_800_000_000 * uT {
println!("Total supply up to tail emission: {}", total_supply_up_to_tail_emission);
break;
}
esmeralda[0].emission_initial = esmeralda[0].emission_initial + MicroMinotari(1);
}
panic!("\n\nThis test may not pass in CI\n\n");
}

#[test]
fn esmeralda_schedule() {
let esmeralda = ConsensusConstants::esmeralda();
Expand Down
Loading

0 comments on commit 2834cfc

Please sign in to comment.