Skip to content

Commit

Permalink
Merge pull request #3041 from G8XSU/followup-2957
Browse files Browse the repository at this point in the history
Followups to #2957
  • Loading branch information
TheBlueMatt committed May 9, 2024
2 parents 38690bf + 8861a9a commit 33b9ba5
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 18 deletions.
5 changes: 2 additions & 3 deletions lightning/src/chain/chainmonitor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ pub trait Persist<ChannelSigner: WriteableEcdsaChannelSigner> {
/// The [`ChannelMonitorUpdate::update_id`] or [`ChannelMonitor::get_latest_update_id`] uniquely
/// links this call to [`ChainMonitor::channel_monitor_updated`].
/// For [`Persist::update_persisted_channel`], it is only necessary to call [`ChainMonitor::channel_monitor_updated`]
/// when an [`ChannelMonitorUpdate`] is provided and when you return [`ChannelMonitorUpdateStatus::InProgress`].
/// when a [`ChannelMonitorUpdate`] is provided and when you return [`ChannelMonitorUpdateStatus::InProgress`].
///
/// See [`Writeable::write`] on [`ChannelMonitor`] for writing out a `ChannelMonitor`,
/// [`Writeable::write`] on [`ChannelMonitorUpdate`] for writing out an update, and
Expand Down Expand Up @@ -312,7 +312,7 @@ where C::Target: chain::Filter,
log_funding_info!(monitor)
),
ChannelMonitorUpdateStatus::InProgress => {
log_debug!(logger, "Channel Monitor sync for channel {} in progress.", log_funding_info!(monitor));
log_trace!(logger, "Channel Monitor sync for channel {} in progress.", log_funding_info!(monitor));
},
ChannelMonitorUpdateStatus::UnrecoverableError => {
return Err(());
Expand Down Expand Up @@ -992,7 +992,6 @@ mod tests {
let nodes = create_network(2, &node_cfgs, &node_chanmgrs);
create_announced_chan_between_nodes(&nodes, 0, 1);

chanmon_cfgs[0].persister.chain_sync_monitor_persistences.lock().unwrap().clear();
chanmon_cfgs[0].persister.set_update_ret(ChannelMonitorUpdateStatus::UnrecoverableError);

assert!(std::panic::catch_unwind(|| {
Expand Down
1 change: 0 additions & 1 deletion lightning/src/ln/payment_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1102,7 +1102,6 @@ fn do_test_dup_htlc_onchain_doesnt_fail_on_reload(persist_manager_post_event: bo
// Now connect the HTLC claim transaction with the ChainMonitor-generated ChannelMonitor update
// returning InProgress. This should cause the claim event to never make its way to the
// ChannelManager.
chanmon_cfgs[0].persister.chain_sync_monitor_persistences.lock().unwrap().clear();
chanmon_cfgs[0].persister.set_update_ret(ChannelMonitorUpdateStatus::InProgress);

if payment_timeout {
Expand Down
15 changes: 1 addition & 14 deletions lightning/src/util/test_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -513,9 +513,6 @@ pub struct TestPersister {
/// The queue of update statuses we'll return. If none are queued, ::Completed will always be
/// returned.
pub update_rets: Mutex<VecDeque<chain::ChannelMonitorUpdateStatus>>,
/// When we get an update_persisted_channel call with no ChannelMonitorUpdate, we insert the
/// MonitorId here.
pub chain_sync_monitor_persistences: Mutex<VecDeque<OutPoint>>,
/// When we get an update_persisted_channel call *with* a ChannelMonitorUpdate, we insert the
/// [`ChannelMonitor::get_latest_update_id`] here.
///
Expand All @@ -526,7 +523,6 @@ impl TestPersister {
pub fn new() -> Self {
Self {
update_rets: Mutex::new(VecDeque::new()),
chain_sync_monitor_persistences: Mutex::new(VecDeque::new()),
offchain_monitor_updates: Mutex::new(new_hash_map()),
}
}
Expand All @@ -552,22 +548,13 @@ impl<Signer: sign::ecdsa::WriteableEcdsaChannelSigner> chainmonitor::Persist<Sig

if let Some(update) = update {
self.offchain_monitor_updates.lock().unwrap().entry(funding_txo).or_insert(new_hash_set()).insert(update.update_id);
} else {
self.chain_sync_monitor_persistences.lock().unwrap().push_back(funding_txo);
}
ret
}

fn archive_persisted_channel(&self, funding_txo: OutPoint) {
// remove the channel from the offchain_monitor_updates map
match self.offchain_monitor_updates.lock().unwrap().remove(&funding_txo) {
Some(_) => {},
None => {
// If the channel was not in the offchain_monitor_updates map, it should be in the
// chain_sync_monitor_persistences map.
self.chain_sync_monitor_persistences.lock().unwrap().retain(|x| x != &funding_txo);
}
};
self.offchain_monitor_updates.lock().unwrap().remove(&funding_txo);
}
}

Expand Down

0 comments on commit 33b9ba5

Please sign in to comment.