Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use MonitorUpdatingPersister #456

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

arturgontijo
Copy link
Contributor

This PR aims to solve #441 , making use of MonitorUpdatingPersister in the ChainMonitor.

Note: Not sure about a proper value for its maximum_pending_updates (set it to 10 for now).

Comment on lines 96 to 114
let persister_0 = MonitorUpdatingPersister::new(
store_0,
&chanmon_cfgs[0].logger,
persister_0_max_pending_updates,
&chanmon_cfgs[0].keys_manager,
&chanmon_cfgs[0].keys_manager,
&chanmon_cfgs[0].tx_broadcaster,
&chanmon_cfgs[0].fee_estimator,
);

let persister_1 = MonitorUpdatingPersister::new(
store_1,
&chanmon_cfgs[1].logger,
persister_1_max_pending_updates,
&chanmon_cfgs[1].keys_manager,
&chanmon_cfgs[1].keys_manager,
&chanmon_cfgs[1].tx_broadcaster,
&chanmon_cfgs[1].fee_estimator,
);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Given the duplication, consider extracting this into a helper function.

src/builder.rs Outdated
let persister = Arc::new(Persister::new(
Arc::clone(&kv_store),
Arc::clone(&logger),
10, // (?)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I also don't know what value to recommend here, but pending when @tnull takes a look, you could define a constant to hold this value.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My guess is as good as any, as we don't have super good data on this parameter so far. I think we could bump it to 100 to start with and then see if we run into any issue with it. I agree that we should introduce a const for it though.

Copy link
Contributor

@enigbe enigbe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @arturgontijo, thanks you for submitting this PR. I have done an initial review and left two minor comments regarding the hard-coding of values and using helper functions to reduce duplicated logic. From my POV, this looks good and I am happy to take another look when the comments are addressed.

Copy link
Collaborator

@tnull tnull left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool, thank you very much for looking into this! Excuse the delay, I have to admit it fell of my radar for a few days.

The changes already look pretty good to me, I just have a few minor nits / comments.

Given that this patch, while rather small, affects really the core of the node's functionality, I'm considering holding off landing this for a few days until after the upcoming 0.5 release. This would give us more time to spot any funky behavior that could arise from this, especially since there have been considerable changes made to the MonitorUpdatingPersister on LDK main recently that will ship with LDK v0.2, and further changes to the persistence/storage layer in LDK Node are planned for v0.6.

TLDR: while the patch is pretty simple, I'll go ahead and tag this PR for milestone 0.6, hopefully landing soon after v0.5 shipped.

src/builder.rs Outdated
let persister = Arc::new(Persister::new(
Arc::clone(&kv_store),
Arc::clone(&logger),
10, // (?)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My guess is as good as any, as we don't have super good data on this parameter so far. I think we could bump it to 100 to start with and then see if we run into any issue with it. I agree that we should introduce a const for it though.


use lightning::events::ClosureReason;
use lightning::util::test_utils;
use lightning::{check_added_monitors, check_closed_broadcast, check_closed_event};
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: Not quite sure why the import was changed, but if we already do so, why not move the others up, too?


let monitor_name = MonitorName::from(mon.get_funding_txo().0);
assert_eq!(
store_0
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: Would prefer if we could move this to a variable to avoid the additional indentation and verticality in the assert_eq (same below).

sender = 0;
receiver = 1;
}
send_payment(&nodes[sender], &vec![&nodes[receiver]][..], 21_000);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can avoid the unnecessary allocations here and below by simply dropping vec!, given that you're making it a slice anyways.

Suggested change
send_payment(&nodes[sender], &vec![&nodes[receiver]][..], 21_000);
send_payment(&nodes[sender], &[&nodes[receiver]][..], 21_000);

also, consider moving these to appropriately named variables for clarity.

@tnull tnull added this to the 0.6 milestone Feb 11, 2025
@tnull tnull linked an issue Feb 11, 2025 that may be closed by this pull request
@arturgontijo
Copy link
Contributor Author

Hey @enigbe and @tnull, thanks for the initial review.

Regarding test_utils.rs, I kept it as a copy&paste but now from rust-lightning/.../persist.rs.
But I totally agree that, as it is part of this repo now, we should make it better =)

I'll address all the suggestions and also agree that it can bring side effects that we are not anticipating yet.

@arturgontijo arturgontijo changed the title Use MonitorUpdatingPersister Use MonitorUpdatingPersister Feb 19, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Switch to MonitorUpdatingPersister
3 participants