diff --git a/.DS_Store b/.DS_Store index 703ae42..3de2d6a 100644 Binary files a/.DS_Store and b/.DS_Store differ diff --git a/Cargo.lock b/Cargo.lock index 9e35b49..7086c59 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1555,9 +1555,9 @@ dependencies = [ [[package]] name = "drillx" -version = "2.0.0" +version = "2.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0c5fd3a8f11a6420d6efb1952c8c2e788627cb2c9e834537dc4b6bd036461646" +checksum = "9f1b6097a8aeb360dc83cad60047b42cfabf54a56b81a75e254f5854211a7475" dependencies = [ "equix", "serde", @@ -2697,7 +2697,7 @@ dependencies = [ [[package]] name = "more-cli" -version = "2.1.0" +version = "2.2.0" dependencies = [ "bincode", "bs58 0.5.1", diff --git a/Cargo.toml b/Cargo.toml index 2b24692..ae6220e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "more-cli" -version = "2.1.0" +version = "2.2.0" edition = "2021" license = "Apache-2.0" description = "A command line interface for ORE cryptocurrency mining. Tailored by Miraland Labs." @@ -28,7 +28,7 @@ clap = { version = "4.4.12", features = ["derive"] } color-eyre = { version = "0.6" } colored = "2.0" core_affinity = "0.8.1" -drillx = "2.0.0" +drillx = "2.1.0" # drillx = { git = "https://github.com/regolith-labs/drillx", branch = "master", features = ["solana"] } futures = "0.3.30" indicatif = "0.17.8" @@ -63,3 +63,15 @@ url = "2.5" # ore-api = { path = "../ore/api" } # ore-utils = { path = "../ore/utils" } +[profile.release] +opt-level = 3 # Optimize for binary size. You can use "3" for full optimizations if binary size isn't an issue. +codegen-units = 1 # Better optimization with fewer codegen units +lto = true # Enable Link Time Optimization (LTO) +debug = false # Disable debug info to reduce binary size +panic = 'abort' # Reduces the binary size further by not including unwinding information +rpath = false +incremental = false +overflow-checks = false + +[build] +rustflags = ["-C", "target-cpu=native"] \ No newline at end of file diff --git a/src/config.rs b/src/config.rs index a113c03..524ad67 100644 --- a/src/config.rs +++ b/src/config.rs @@ -1,4 +1,5 @@ use colored::Colorize; +use ore_api::consts::EPOCH_DURATION; use crate::{utils, Miner}; @@ -13,5 +14,6 @@ impl Miner { "Top stake".bold(), utils::amount_u64_to_string(config.top_balance) ); + println!("{}: {} sec", "Epoch time".bold(), EPOCH_DURATION); } } diff --git a/src/main.rs b/src/main.rs index 0c75810..fb05a57 100644 --- a/src/main.rs +++ b/src/main.rs @@ -23,11 +23,11 @@ use std::sync::Arc; use args::*; use clap::{ - builder::{ - styling::{AnsiColor, Effects}, - Styles, - }, - command, Parser, Subcommand, + builder::{ + styling::{AnsiColor, Effects}, + Styles, + }, + command, Parser, Subcommand, }; use solana_client::nonblocking::rpc_client::RpcClient; use solana_sdk::{ @@ -129,7 +129,7 @@ struct Args { long, value_name = "FEE_MICROLAMPORTS", help = "Price to pay for compute units when dynamic fee flag is off, or dynamic fee is unavailable.", - default_value = "20000", + default_value = "10000", global = true )] priority_fee: Option, @@ -138,7 +138,7 @@ struct Args { long, value_name = "FEE_CAP_MICROLAMPORTS", help = "Max price to pay for compute units when dynamic fees are enabled.", - default_value = "500000", + default_value = "100000", global = true )] priority_fee_cap: Option, @@ -153,7 +153,7 @@ struct Args { #[arg(long, help = "Enable dynamic priority fees", global = true)] dynamic_fee: bool, - + /// Mine with sound notification on/off #[arg( long, @@ -162,7 +162,7 @@ struct Args { default_value = "false", global = true )] - no_sound_notification: bool, + no_sound_notification: bool, #[command(subcommand)] command: Commands, @@ -288,9 +288,9 @@ impl Miner { } fn styles() -> Styles { - Styles::styled() - .header(AnsiColor::Red.on_default() | Effects::BOLD) - .usage(AnsiColor::Red.on_default() | Effects::BOLD) - .literal(AnsiColor::Blue.on_default() | Effects::BOLD) - .placeholder(AnsiColor::Green.on_default()) + Styles::styled() + .header(AnsiColor::Red.on_default() | Effects::BOLD) + .usage(AnsiColor::Red.on_default() | Effects::BOLD) + .literal(AnsiColor::Blue.on_default() | Effects::BOLD) + .placeholder(AnsiColor::Green.on_default()) } diff --git a/src/mine.rs b/src/mine.rs index 42a6403..d1735cd 100644 --- a/src/mine.rs +++ b/src/mine.rs @@ -219,23 +219,24 @@ impl Miner { let mut best_difficulty = 0; let mut best_hash = Hash::default(); loop { - // Create hash - if let Ok(hx) = drillx::hash_with_memory( + // Get hashes + let hxs = drillx::hashes_with_memory( &mut memory, &proof.challenge, &nonce.to_le_bytes(), - ) { + ); + + // Look for best difficulty score in all hashes + for hx in hxs { let difficulty = hx.difficulty(); if difficulty.gt(&best_difficulty) { best_nonce = nonce; best_difficulty = difficulty; best_hash = hx; - // {{ edit_1 }} if best_difficulty.gt(&*global_best_difficulty.read().unwrap()) { *global_best_difficulty.write().unwrap() = best_difficulty; } - // {{ edit_1 }} } } diff --git a/src/send_and_confirm.rs b/src/send_and_confirm.rs index 6ebab2f..5921074 100644 --- a/src/send_and_confirm.rs +++ b/src/send_and_confirm.rs @@ -139,7 +139,8 @@ impl Miner { }) = difficulty_payload { if solution_difficulty > extra_fee_difficulty { - prio_fee = if let Some(priority_fee_cap) = self.priority_fee_cap { + prio_fee = if let Some(priority_fee_cap) = self.priority_fee_cap + { priority_fee_cap.min( prio_fee .saturating_mul( @@ -217,7 +218,7 @@ impl Miner { // Confirm transaction 'confirm: for _ in 0..CONFIRM_RETRIES { - std::thread::sleep(Duration::from_millis(CONFIRM_DELAY)); + tokio::time::sleep(Duration::from_millis(CONFIRM_DELAY)).await; match client.get_signature_statuses(&[sig]).await { Ok(signature_statuses) => { for status in signature_statuses.value { @@ -313,7 +314,7 @@ impl Miner { } // Retry - std::thread::sleep(Duration::from_millis(GATEWAY_DELAY)); + tokio::time::sleep(Duration::from_millis(GATEWAY_DELAY)).await; if attempts > GATEWAY_RETRIES { log_error(&progress_bar, "Max retries", true); return Err(ClientError { diff --git a/src/utils.rs b/src/utils.rs index e0e4b1d..32c2f07 100644 --- a/src/utils.rs +++ b/src/utils.rs @@ -69,7 +69,7 @@ pub async fn get_updated_proof_with_authority( if proof.last_hash_at.gt(&lash_hash_at) { return proof; } - std::thread::sleep(Duration::from_millis(1000)); + tokio::time::sleep(Duration::from_millis(1_000)).await; } }