From 783d387e4e2d9bae7d693244c814a46f679e2cf3 Mon Sep 17 00:00:00 2001 From: steviez Date: Fri, 6 Dec 2024 11:01:38 -0600 Subject: [PATCH] Move RewardsRecorderService from solana-core to solana-rpc (#3953) RewardsRecorderService is only created when a node is running with RPC flags (--rpc-enable-transaction-history) --- core/src/lib.rs | 1 - core/src/validator.rs | 2 +- ledger-tool/src/ledger_utils.rs | 6 +++-- rpc/src/lib.rs | 1 + {core => rpc}/src/rewards_recorder_service.rs | 25 +++++++++++++------ 5 files changed, 23 insertions(+), 12 deletions(-) rename {core => rpc}/src/rewards_recorder_service.rs (78%) diff --git a/core/src/lib.rs b/core/src/lib.rs index c88488f0876667..fc1473e125213f 100644 --- a/core/src/lib.rs +++ b/core/src/lib.rs @@ -30,7 +30,6 @@ pub mod poh_timing_reporter; pub mod repair; pub mod replay_stage; mod result; -pub mod rewards_recorder_service; pub mod sample_performance_service; mod shred_fetch_stage; pub mod sigverify; diff --git a/core/src/validator.rs b/core/src/validator.rs index 736dca8cb38ed6..a846684aff28bb 100644 --- a/core/src/validator.rs +++ b/core/src/validator.rs @@ -21,7 +21,6 @@ use { serve_repair::ServeRepair, serve_repair_service::ServeRepairService, }, - rewards_recorder_service::RewardsRecorderService, sample_performance_service::SamplePerformanceService, sigverify, snapshot_packager_service::{PendingSnapshotPackages, SnapshotPackagerService}, @@ -88,6 +87,7 @@ use { BankNotificationSenderConfig, OptimisticallyConfirmedBank, OptimisticallyConfirmedBankTracker, }, + rewards_recorder_service::RewardsRecorderService, rpc::JsonRpcConfig, rpc_completed_slots_service::RpcCompletedSlotsService, rpc_pubsub_service::{PubSubConfig, PubSubService}, diff --git a/ledger-tool/src/ledger_utils.rs b/ledger-tool/src/ledger_utils.rs index 03856acbbf756c..58c2a54f725055 100644 --- a/ledger-tool/src/ledger_utils.rs +++ b/ledger-tool/src/ledger_utils.rs @@ -9,7 +9,6 @@ use { }, solana_core::{ accounts_hash_verifier::AccountsHashVerifier, - rewards_recorder_service::RewardsRecorderService, snapshot_packager_service::PendingSnapshotPackages, validator::BlockVerificationMethod, }, solana_geyser_plugin_manager::geyser_plugin_service::{ @@ -27,7 +26,10 @@ use { use_snapshot_archives_at_startup::UseSnapshotArchivesAtStartup, }, solana_measure::measure_time, - solana_rpc::transaction_status_service::TransactionStatusService, + solana_rpc::{ + rewards_recorder_service::RewardsRecorderService, + transaction_status_service::TransactionStatusService, + }, solana_runtime::{ accounts_background_service::{ AbsRequestHandlers, AbsRequestSender, AccountsBackgroundService, diff --git a/rpc/src/lib.rs b/rpc/src/lib.rs index 9763ebd791a162..a2fd313b5dbb96 100644 --- a/rpc/src/lib.rs +++ b/rpc/src/lib.rs @@ -4,6 +4,7 @@ pub mod filter; pub mod max_slots; pub mod optimistically_confirmed_bank_tracker; pub mod parsed_token_accounts; +pub mod rewards_recorder_service; pub mod rpc; mod rpc_cache; pub mod rpc_completed_slots_service; diff --git a/core/src/rewards_recorder_service.rs b/rpc/src/rewards_recorder_service.rs similarity index 78% rename from core/src/rewards_recorder_service.rs rename to rpc/src/rewards_recorder_service.rs index 3100ab62c6a18c..3467a151632317 100644 --- a/core/src/rewards_recorder_service.rs +++ b/rpc/src/rewards_recorder_service.rs @@ -1,3 +1,6 @@ +//! The `RewardsRecorderService` is responsible for receiving rewards data and +//! persisting it into the `Blockstore`. + use { crossbeam_channel::RecvTimeoutError, solana_ledger::{ @@ -29,15 +32,21 @@ impl RewardsRecorderService { ) -> Self { let thread_hdl = Builder::new() .name("solRewardsWritr".to_string()) - .spawn(move || loop { - if exit.load(Ordering::Relaxed) { - break; - } - if let Err(RecvTimeoutError::Disconnected) = - Self::write_rewards(&rewards_receiver, &max_complete_rewards_slot, &blockstore) - { - break; + .spawn(move || { + info!("RewardsRecorderService has started"); + loop { + if exit.load(Ordering::Relaxed) { + break; + } + if let Err(RecvTimeoutError::Disconnected) = Self::write_rewards( + &rewards_receiver, + &max_complete_rewards_slot, + &blockstore, + ) { + break; + } } + info!("RewardsRecorderService has stopped"); }) .unwrap(); Self { thread_hdl }