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

Send reminders for non-mutating channels #77

Merged
merged 9 commits into from
May 10, 2024

Conversation

arik-so
Copy link
Contributor

@arik-so arik-so commented May 9, 2024

Stop filtering channels from the delta set due to non-mutating channel updates absent which reminders would be sent.

@arik-so arik-so requested a review from TheBlueMatt May 9, 2024 19:48
@arik-so arik-so force-pushed the static-channel-reminders branch 2 times, most recently from b9fff82 to 206b767 Compare May 9, 2024 22:40
src/lookup.rs Outdated
let snapshot_scope = current_timestamp.saturating_sub(last_sync_timestamp as u64);
log_debug!(logger, "Current day index: {}", current_day);
log_debug!(logger, "Snapshot scope: {}s", snapshot_scope);
let include_reminders = ((current_day % 5) == 0 || snapshot_scope > (40 * 3600));
Copy link
Contributor

Choose a reason for hiding this comment

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

current_day % 5 means any generated snapshot created on the 5th day, not only at midnight.

src/lookup.rs Outdated
@@ -87,6 +92,16 @@ pub(super) async fn fetch_channel_announcements<L: Deref>(delta_set: &mut DeltaS
log_info!(logger, "Last sync timestamp: {}", last_sync_timestamp);
let last_sync_timestamp_float = last_sync_timestamp as f64;

let current_time = SystemTime::now();
Copy link
Contributor

Choose a reason for hiding this comment

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

Please use the snapshot generation time, not the system time.

Comment on lines 180 to 183
} else if mutated_properties.len() > 0 || mutated_properties.flags {
} else if mutated_property_count > 0 || mutated_properties.flags {
// we don't count flags as mutated properties
serialization_set.updates.push(
UpdateSerialization::Incremental(latest_update, mutated_properties));
serialization_set.updates.push(UpdateSerialization::Incremental(latest_update, mutated_properties));
Copy link
Contributor

@TheBlueMatt TheBlueMatt May 10, 2024

Choose a reason for hiding this comment

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

Can we skip the unnecessary diff?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

sure, I added that for debugging. Can undo.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

hmm, it's actually kinda convenient for debugging though. Is this critical?

Copy link
Contributor

Choose a reason for hiding this comment

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

Why is it convenient to have additional diff for debugging? You can print mutated_properties.len() without needing a local variable for it...

src/lookup.rs Outdated
let is_reminder_day = (current_day % 5) == 0;

let snapshot_scope = current_timestamp.saturating_sub(last_sync_timestamp as u64);
let is_reminder_scope = snapshot_scope > (40 * 3600);
Copy link
Contributor

Choose a reason for hiding this comment

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

Why 40 hours though?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I can set it to 48 hours sharp, that should probably do the trick.

Copy link
Contributor

Choose a reason for hiding this comment

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

Do we need it to be that short? Can we do 5 days to match the above?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We can, but really the trick is to catch it depending on the lowest interval people are gonna set, because it's gonna be a power of two.

With 3 hours as the starting interval, it's gonna be 6, 12, 24, 48, 96, 192.
If users start with 1, it'll be 4, 8, 16, 32, 64, 128. For their case, 128 will be right above 120, which is great, but with 3 hours, the next one is 192, which is more than 6 days, i.e. our reminder interval.

Copy link
Contributor

Choose a reason for hiding this comment

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

Mmm, okay, I still feel like it'd be nice to set higher but its fine.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Right, so how about 50 perhaps? That would start the capture for the 96-hour and 64-hour-intervals.

Previously, whenever a channel hasn't received updates in
6+ days, we would automatically send incremental reminders
that only contain the update flags.

However, if a channel has been received updates
within that six-day-timeframe, but all those updates were
identical, it would result in no updates being added to the
snapshot because the mutation set ended up empty and that
data would get purged from the serialization.

In order to avoid the reminder logic being duped by
channels simply being consistent, we now look up the
beginning of the latest continuous stretch of non-mutating
channel updates. If a channel's details have not been
altered in more than six days, we now send reminders no
matter the frequency with which channel updates have been
received since.
Copy link
Contributor

@TheBlueMatt TheBlueMatt left a comment

Choose a reason for hiding this comment

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

Seems to work. I do want to look at optimizing the indexes here but that can come later.

@TheBlueMatt TheBlueMatt merged commit 81c27c8 into lightningdevkit:main May 10, 2024
4 checks passed
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.

2 participants