From a1c09277274a510574b4ce3b364a9aeb59c3f8eb Mon Sep 17 00:00:00 2001 From: Collin Jackson Date: Tue, 10 Feb 2026 11:43:49 -0800 Subject: [PATCH 1/3] style: fix rustfmt formatting in keys.rs Fix formatting issues introduced in #2050: trailing whitespace in doc comments, method chain indentation, and inline if/else expansion. Co-Authored-By: Claude Opus 4.6 --- clients/cli/src/keys.rs | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/clients/cli/src/keys.rs b/clients/cli/src/keys.rs index ec816706..fd684fce 100644 --- a/clients/cli/src/keys.rs +++ b/clients/cli/src/keys.rs @@ -24,10 +24,10 @@ pub fn is_valid_eth_address(address: &str) -> bool { } /// Validates EIP-55 checksum for Ethereum addresses. -/// +/// /// EIP-55 defines a checksum encoding for Ethereum addresses that uses mixed case /// to encode the address hash. This allows for error detection when typing addresses. -/// +/// /// Algorithm: /// 1. Convert address to lowercase /// 2. Compute Keccak256 hash of the lowercase address @@ -39,8 +39,12 @@ fn validate_eip55_checksum(address: &str) -> bool { let hex = &address[2..]; // If the address is all lower or all upper, it's valid per EIP-55 - if hex.chars().all(|c| !c.is_ascii_alphabetic() || c.is_ascii_lowercase()) - || hex.chars().all(|c| !c.is_ascii_alphabetic() || c.is_ascii_uppercase()) + if hex + .chars() + .all(|c| !c.is_ascii_alphabetic() || c.is_ascii_lowercase()) + || hex + .chars() + .all(|c| !c.is_ascii_alphabetic() || c.is_ascii_uppercase()) { return true; } @@ -59,7 +63,11 @@ fn validate_eip55_checksum(address: &str) -> bool { // Determine the corresponding nibble from the hash let hash_byte = hash[i / 2]; - let nibble = if i % 2 == 0 { hash_byte >> 4 } else { hash_byte & 0x0F }; + let nibble = if i % 2 == 0 { + hash_byte >> 4 + } else { + hash_byte & 0x0F + }; if nibble >= 8 { if !ch.is_ascii_uppercase() { From 67787754d13a237cc005973194ba442c67add9ac Mon Sep 17 00:00:00 2001 From: Collin Jackson Date: Tue, 10 Feb 2026 11:52:59 -0800 Subject: [PATCH 2/3] fix: use valid EIP-55 checksummed address in register test The test address had mixed case that doesn't pass EIP-55 checksum validation introduced in #2050, causing test failure. Co-Authored-By: Claude Opus 4.6 --- clients/cli/src/register.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/clients/cli/src/register.rs b/clients/cli/src/register.rs index fc1b9155..ecfd34f2 100644 --- a/clients/cli/src/register.rs +++ b/clients/cli/src/register.rs @@ -263,7 +263,7 @@ mod tests { let dir = tempdir().unwrap(); let config_path = dir.path().join("config.json"); - let wallet_address = "0xABCDEFabcdef1234567890123456789012345678"; + let wallet_address = "0x5aAeb6053F3E94C9b9A09f33669435E7Ef1BeAed"; let user_id = "existing-user-id"; // Write a pre-existing config with matching wallet and user_id From 1be8742e6618fc1885f51696356cbd03c845ab3a Mon Sep 17 00:00:00 2001 From: Collin Jackson Date: Tue, 17 Mar 2026 14:07:07 -0700 Subject: [PATCH 3/3] feat: remove cache strike notification logic Removes the rewards_processed notification feature that displayed a "You've hit a cache of points!" overlay in the TUI header. This includes removing the REWARDS_EVENT_SENDER, Worker::Rewards event type, show_rewards_overlay state, show_mock_notification debug flag, and all associated wiring through analytics, runtime, events, and UI layers. Co-Authored-By: Claude Sonnet 4.6 --- clients/cli/src/analytics.rs | 40 +------------------ clients/cli/src/consts.rs | 4 -- clients/cli/src/events.rs | 6 --- clients/cli/src/main.rs | 10 +---- clients/cli/src/runtime.rs | 4 -- clients/cli/src/session/tui_mode.rs | 3 -- clients/cli/src/ui/app.rs | 11 ----- .../cli/src/ui/dashboard/components/header.rs | 9 +---- clients/cli/src/ui/dashboard/state.rs | 3 -- clients/cli/src/ui/dashboard/updaters.rs | 7 ---- clients/cli/src/ui/dashboard/utils.rs | 1 - 11 files changed, 4 insertions(+), 94 deletions(-) diff --git a/clients/cli/src/analytics.rs b/clients/cli/src/analytics.rs index b16012f1..b5a93a67 100644 --- a/clients/cli/src/analytics.rs +++ b/clients/cli/src/analytics.rs @@ -1,6 +1,4 @@ use crate::environment::Environment; -use crate::events::{Event, EventType}; -use crate::logging::LogLevel; use crate::prover::input::InputParser; use crate::system::{estimate_peak_gflops, measure_gflops, num_cores}; use crate::task::Task; @@ -160,21 +158,12 @@ const CLI_USER_AGENT: &str = concat!("nexus-cli/", env!("CARGO_PKG_VERSION")); static LAST_REPORT_BY_ADDRESS: OnceLock>> = OnceLock::new(); /// Global wallet address for reporting; set once during session setup static REPORT_WALLET_ADDRESS: OnceLock = OnceLock::new(); -/// Optional event sender for rewards notifications (TUI only); set during session setup -static REWARDS_EVENT_SENDER: OnceLock> = - OnceLock::new(); /// Set the wallet address used for reporting proving activity pub fn set_wallet_address_for_reporting(address: String) { let _ = REPORT_WALLET_ADDRESS.set(address); } -/// Set the event sender for rewards notifications (called from runtime when TUI is used). -/// When reportProving returns rewards_processed, an event is sent to display the notification. -pub fn set_rewards_event_sender(sender: tokio::sync::mpsc::Sender) { - let _ = REWARDS_EVENT_SENDER.set(sender); -} - /// Report proving activity to our Cloud Function at most once per hour per wallet address. /// When the response contains `{"result":{"status":"ok","message":"rewards_processed"}}`, /// sends a rewards event to the TUI for display (if event sender is configured). @@ -219,34 +208,7 @@ pub async fn report_proving_if_needed() { .send() .await; - // Parse response for rewards_processed; send TUI notification if present - if let Ok(resp) = response { - if let Ok(text) = resp.text().await { - if let Ok(json) = serde_json::from_str::(&text) { - if json - .get("result") - .and_then(|r| r.get("status")) - .and_then(|s| s.as_str()) - == Some("ok") - && json - .get("result") - .and_then(|r| r.get("message")) - .and_then(|m| m.as_str()) - == Some("rewards_processed") - { - if let Some(sender) = REWARDS_EVENT_SENDER.get() { - let _ = sender - .send(Event::rewards_with_level( - crate::consts::cli_consts::REWARDS_PROCESSED_MESSAGE.to_string(), - EventType::Success, - LogLevel::Info, - )) - .await; - } - } - } - } - } + drop(response); } /// Track analytics for getting a task from orchestrator (non-blocking) diff --git a/clients/cli/src/consts.rs b/clients/cli/src/consts.rs index e7b1ba41..af1add56 100644 --- a/clients/cli/src/consts.rs +++ b/clients/cli/src/consts.rs @@ -13,10 +13,6 @@ pub mod cli_consts { /// The maximum number of events to keep in the activity logs. pub const MAX_ACTIVITY_LOGS: usize = 100; - /// Message shown in header and activity log when reportProving returns rewards_processed - pub const REWARDS_PROCESSED_MESSAGE: &str = - "You've hit a cache of points! Claim at quest.nexus.xyz."; - /// Maximum number of event buffer size for worker threads pub const EVENT_QUEUE_SIZE: usize = 100; diff --git a/clients/cli/src/events.rs b/clients/cli/src/events.rs index ad09c6a1..79f71443 100644 --- a/clients/cli/src/events.rs +++ b/clients/cli/src/events.rs @@ -14,8 +14,6 @@ pub enum Worker { Prover(usize), /// Worker that submits proofs to the orchestrator. ProofSubmitter, - /// System-level notifications (e.g., rewards processed from reportProving). - Rewards, } #[derive(Debug, Copy, Clone, Eq, PartialEq, strum::Display)] @@ -109,10 +107,6 @@ impl Event { Self::new(Worker::Prover(thread_id), msg, event_type, log_level) } - pub fn rewards_with_level(msg: String, event_type: EventType, log_level: LogLevel) -> Self { - Self::new(Worker::Rewards, msg, event_type, log_level) - } - pub fn should_display(&self) -> bool { // Always show success events and info level events if self.event_type == EventType::Success || self.log_level >= LogLevel::Info { diff --git a/clients/cli/src/main.rs b/clients/cli/src/main.rs index cd1cefba..1a99287f 100644 --- a/clients/cli/src/main.rs +++ b/clients/cli/src/main.rs @@ -127,10 +127,6 @@ enum Command { /// Override max difficulty to request. Auto-promotion occurs when tasks complete in < 7 min #[arg(long = "max-difficulty", value_name = "DIFFICULTY")] max_difficulty: Option, - - /// [Debug] Show the rewards notification on startup for testing - #[arg(long = "show-mock-notification", hide = true, action = ArgAction::SetTrue)] - show_mock_notification: bool, }, /// Register a new user RegisterUser { @@ -181,7 +177,6 @@ async fn main() -> Result<(), Box> { with_background, max_tasks, max_difficulty, - show_mock_notification, } => { // If a custom orchestrator URL is provided, create a custom environment let final_environment = if let Some(url) = orchestrator_url { @@ -201,7 +196,6 @@ async fn main() -> Result<(), Box> { with_background, max_tasks, max_difficulty, - show_mock_notification, ) .await } @@ -247,7 +241,6 @@ async fn main() -> Result<(), Box> { /// * `check_mem` - Whether to check risky memory usage. /// * `with_background` - Whether to use the alternate TUI background color. /// * `max_tasks` - Optional maximum number of tasks to prove. -/// * `show_mock_notification` - [Debug] Show rewards overlay on startup for testing. #[allow(clippy::too_many_arguments)] async fn start( node_id: Option, @@ -259,7 +252,6 @@ async fn start( with_background: bool, max_tasks: Option, max_difficulty: Option, - show_mock_notification: bool, ) -> Result<(), Box> { // 1. Version checking (will internally perform country detection without race) validate_version_requirements().await?; @@ -302,7 +294,7 @@ async fn start( if headless { run_headless_mode(session).await } else { - run_tui_mode(session, with_background, show_mock_notification).await + run_tui_mode(session, with_background).await } } diff --git a/clients/cli/src/runtime.rs b/clients/cli/src/runtime.rs index ea6fd7dd..34b56a24 100644 --- a/clients/cli/src/runtime.rs +++ b/clients/cli/src/runtime.rs @@ -1,6 +1,5 @@ //! Simplified runtime for coordinating authenticated workers -use crate::analytics::set_rewards_event_sender; use crate::environment::Environment; use crate::events::Event; use crate::orchestrator::OrchestratorClient; @@ -33,9 +32,6 @@ pub async fn start_authenticated_worker( let (event_sender, event_receiver) = mpsc::channel::(crate::consts::cli_consts::EVENT_QUEUE_SIZE); - // Allow analytics to send rewards_processed notifications to the TUI - set_rewards_event_sender(event_sender.clone()); - // Create a separate shutdown sender for max tasks completion let (shutdown_sender, _) = broadcast::channel(1); diff --git a/clients/cli/src/session/tui_mode.rs b/clients/cli/src/session/tui_mode.rs index 55361ee2..74e9d04e 100644 --- a/clients/cli/src/session/tui_mode.rs +++ b/clients/cli/src/session/tui_mode.rs @@ -25,7 +25,6 @@ use std::{error::Error, io}; /// # Arguments /// * `session` - Session data from setup /// * `with_background` - Whether to enable background colors -/// * `show_mock_notification` - [Debug] Show rewards overlay on startup for testing /// /// # Returns /// * `Ok(())` - TUI mode completed successfully @@ -33,7 +32,6 @@ use std::{error::Error, io}; pub async fn run_tui_mode( session: SessionData, with_background: bool, - show_mock_notification: bool, ) -> Result<(), Box> { // Print session start message print_session_starting("TUI", session.node_id); @@ -67,7 +65,6 @@ pub async fn run_tui_mode( session.num_workers, version_update_available, latest_version, - show_mock_notification, ); let app = ui::App::new( diff --git a/clients/cli/src/ui/app.rs b/clients/cli/src/ui/app.rs index 376d05c5..4f0e093b 100644 --- a/clients/cli/src/ui/app.rs +++ b/clients/cli/src/ui/app.rs @@ -19,8 +19,6 @@ pub struct UIConfig { pub num_threads: usize, pub update_available: bool, pub latest_version: Option, - /// [Debug] Show rewards overlay on startup for testing - pub show_mock_notification: bool, } impl UIConfig { @@ -29,14 +27,12 @@ impl UIConfig { num_threads: usize, update_available: bool, latest_version: Option, - show_mock_notification: bool, ) -> Self { Self { with_background_color, num_threads, update_available, latest_version, - show_mock_notification, } } } @@ -88,9 +84,6 @@ pub struct App { /// Latest version available, if any. latest_version: Option, - - /// [Debug] Show rewards overlay on startup for testing - show_mock_notification: bool, } impl App { @@ -115,7 +108,6 @@ impl App { num_threads: ui_config.num_threads, version_update_available: ui_config.update_available, latest_version: ui_config.latest_version, - show_mock_notification: ui_config.show_mock_notification, } } @@ -128,7 +120,6 @@ impl App { self.num_threads, self.version_update_available, self.latest_version.clone(), - self.show_mock_notification, ); let state = DashboardState::new( node_id, @@ -181,7 +172,6 @@ pub async fn run(terminal: &mut Terminal, mut app: App) -> std::i app.num_threads, app.version_update_available, app.latest_version.clone(), - app.show_mock_notification, ); app.current_screen = Screen::Dashboard(Box::new(DashboardState::new( app.node_id, @@ -217,7 +207,6 @@ pub async fn run(terminal: &mut Terminal, mut app: App) -> std::i app.num_threads, app.version_update_available, app.latest_version.clone(), - app.show_mock_notification, ); app.current_screen = Screen::Dashboard(Box::new(DashboardState::new( app.node_id, diff --git a/clients/cli/src/ui/dashboard/components/header.rs b/clients/cli/src/ui/dashboard/components/header.rs index 80c21f1a..043b48f3 100644 --- a/clients/cli/src/ui/dashboard/components/header.rs +++ b/clients/cli/src/ui/dashboard/components/header.rs @@ -17,14 +17,9 @@ pub fn render_header(f: &mut Frame, area: ratatui::layout::Rect, state: &Dashboa .constraints([Constraint::Length(2), Constraint::Length(2)]) .split(area); - // Title section: rewards notification takes priority, then version update, else default + // Title section: version update takes priority, else default let version = env!("CARGO_PKG_VERSION"); - let (title_text, title_color) = if state.show_rewards_overlay { - ( - crate::consts::cli_consts::REWARDS_PROCESSED_MESSAGE.to_string(), - Color::Rgb(255, 193, 7), // Amber/gold - ) - } else if state.update_available { + let (title_text, title_color) = if state.update_available { let text = if let Some(latest) = &state.latest_version { format!("NEXUS PROVER v{} -> {} UPDATE AVAILABLE", version, latest) } else { diff --git a/clients/cli/src/ui/dashboard/state.rs b/clients/cli/src/ui/dashboard/state.rs index 2080d486..e70a25d3 100644 --- a/clients/cli/src/ui/dashboard/state.rs +++ b/clients/cli/src/ui/dashboard/state.rs @@ -69,8 +69,6 @@ pub struct DashboardState { pub step2_start_time: Option, /// Track the start time and original wait duration for current waiting period pub waiting_start_info: Option<(Instant, u64)>, // (start_time, original_wait_secs) - /// Whether to show the rewards_processed congratulations overlay (dismissed on next proof submission) - pub show_rewards_overlay: bool, } impl DashboardState { @@ -105,7 +103,6 @@ impl DashboardState { current_prover_state: ProverState::Waiting, step2_start_time: None, waiting_start_info: None, - show_rewards_overlay: ui_config.show_mock_notification, } } // Getter methods for private fields diff --git a/clients/cli/src/ui/dashboard/updaters.rs b/clients/cli/src/ui/dashboard/updaters.rs index 17bdb46b..00e0706a 100644 --- a/clients/cli/src/ui/dashboard/updaters.rs +++ b/clients/cli/src/ui/dashboard/updaters.rs @@ -45,7 +45,6 @@ impl DashboardState { Worker::TaskFetcher => self.handle_task_fetcher_event(event), Worker::Prover(_) => self.handle_prover_event(event), Worker::ProofSubmitter => self.handle_proof_submitter_event(event), - Worker::Rewards => self.handle_rewards_event(event), } // Handle state changes regardless of worker @@ -141,12 +140,6 @@ impl DashboardState { } } - /// Handle Rewards events (rewards_processed from reportProving). - /// Worker::Rewards is only sent when reportProving returns rewards_processed. - fn handle_rewards_event(&mut self, _event: &WorkerEvent) { - self.show_rewards_overlay = true; - } - /// Update task fetch countdown based on current waiting state fn update_task_fetch_countdown(&mut self) { if let Some((start_time, original_secs)) = &self.waiting_start_info { diff --git a/clients/cli/src/ui/dashboard/utils.rs b/clients/cli/src/ui/dashboard/utils.rs index f549e7ac..76da688e 100644 --- a/clients/cli/src/ui/dashboard/utils.rs +++ b/clients/cli/src/ui/dashboard/utils.rs @@ -11,7 +11,6 @@ pub fn get_worker_color(worker: &Worker) -> Color { Worker::TaskFetcher => Color::Cyan, Worker::Prover(_) => Color::Yellow, Worker::ProofSubmitter => Color::Green, - Worker::Rewards => Color::LightYellow, } }