Revert "ChainMonitor::_entropy_source -> ::entropy_source"
What changed, and why it matters
This commit simply renames a field inside the ChainMonitor struct from `entropy_source` back to `_entropy_source`. The leading underscore is a Rust convention meaning 'this field is intentionally unused.' The commit message explains the field is no longer needed for generating random monitor event IDs because those IDs are now created deterministically. The entropy source is still used in one peer-storage feature path, so it is kept in the struct but marked as mostly unused. There is no security bug being fixed here—this is a code cleanup/revert of a previous naming change.
No security action required. Treat as routine maintenance/cleanup. Reviewers may verify that deterministic monitor event ID generation is intentional and that the entropy source is still correctly supplied where needed (e.g., peer storage encryption).
Security signals we found
No strong security signals were identified.
Evidence from the diff
The patch reverts commit 721265b34802956e6c34f8b4f8c36b772a812044, changing the ChainMonitor field and constructor parameter name from entropy_source to _entropy_source throughout lightning/src/chain/chainmonitor.rs. The underscore prefix suppresses Rust ‘unused field’ warnings because monitor event IDs are now deterministic. The entropy source is still referenced in send_peer_storage (behind #[cfg(peer_storage)]) and is passed to ChannelMonitor methods, so it remains part of the struct. No functional or security-relevant behavior changes.
Changed components
lightning/src/chain/chainmonitor.rsInspect captured patch +12 / −12
### lightning/src/chain/chainmonitor.rs
@@ -380,7 +380,7 @@ pub struct ChainMonitor<
logger: L,
fee_estimator: F,
persister: P,
- entropy_source: ES,
+ _entropy_source: ES,
/// "User-provided" (ie persistence-completion/-failed) [`MonitorEvent`]s. These came directly
/// from the user and not from a [`ChannelMonitor`].
pending_monitor_events: Mutex<Vec<(OutPoint, ChannelId, Vec<(u128, MonitorEvent)>, PublicKey)>>,
@@ -440,7 +440,7 @@ where
/// This is not exported to bindings users as async is not supported outside of Rust.
pub fn new_async_beta(
chain_source: Option<C>, broadcaster: T, logger: L, feeest: F,
- persister: MonitorUpdatingPersisterAsync<K, S, L, ES, SP, T, F>, entropy_source: ES,
+ persister: MonitorUpdatingPersisterAsync<K, S, L, ES, SP, T, F>, _entropy_source: ES,
_our_peerstorage_encryption_key: PeerStorageKey, deferred: bool,
) -> Self {
let event_notifier = Arc::new(Notifier::new());
@@ -450,7 +450,7 @@ where
broadcaster,
logger,
fee_estimator: feeest,
- entropy_source,
+ _entropy_source,
pending_monitor_events: Mutex::new(Vec::new()),
highest_chain_height: AtomicUsize::new(0),
event_notifier: Arc::clone(&event_notifier),
@@ -662,7 +662,7 @@ where
/// [`ChannelManager`]: crate::ln::channelmanager::ChannelManager
pub fn new(
chain_source: Option<C>, broadcaster: T, logger: L, feeest: F, persister: P,
- entropy_source: ES, _our_peerstorage_encryption_key: PeerStorageKey, deferred: bool,
+ _entropy_source: ES, _our_peerstorage_encryption_key: PeerStorageKey, deferred: bool,
) -> Self {
Self {
monitors: RwLock::new(new_hash_map()),
@@ -671,7 +671,7 @@ where
logger,
fee_estimator: feeest,
persister,
- entropy_source,
+ _entropy_source,
pending_monitor_events: Mutex::new(Vec::new()),
highest_chain_height: AtomicUsize::new(0),
event_notifier: Arc::new(Notifier::new()),
@@ -1011,7 +1011,7 @@ where
#[cfg(peer_storage)]
fn send_peer_storage(&self, their_node_id: PublicKey) {
let mut monitors_list: Vec<PeerStorageMonitorHolder> = Vec::new();
- let random_bytes = self.entropy_source.get_secure_random_bytes();
+ let random_bytes = self._entropy_source.get_secure_random_bytes();
const MAX_PEER_STORAGE_SIZE: usize = 65531;
const USIZE_LEN: usize = core::mem::size_of::<usize>();
@@ -1210,7 +1210,7 @@ where
&self.broadcaster,
&self.fee_estimator,
&self.logger,
- &self.entropy_source,
+ &self._entropy_source,
);
let update_id = update.update_id;
@@ -1487,7 +1487,7 @@ where
&self.broadcaster,
&self.fee_estimator,
&self.logger,
- &self.entropy_source,
+ &self._entropy_source,
)
});
@@ -1515,7 +1515,7 @@ where
&self.broadcaster,
&self.fee_estimator,
&self.logger,
- &self.entropy_source,
+ &self._entropy_source,
);
}
}
@@ -1549,7 +1549,7 @@ where
&self.broadcaster,
&self.fee_estimator,
&self.logger,
- &self.entropy_source,
+ &self._entropy_source,
)
});
// Assume we may have some new events and wake the event processor
@@ -1565,7 +1565,7 @@ where
&self.broadcaster,
&self.fee_estimator,
&self.logger,
- &self.entropy_source,
+ &self._entropy_source,
);
}
}
@@ -1587,7 +1587,7 @@ where
&self.broadcaster,
&self.fee_estimator,
&self.logger,
- &self.entropy_source,
+ &self._entropy_source,
)
});
Why this scored 15/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.