Skip to content

Commit bbb4cf0

Browse files
committed
more debug logging in candidate selection and private channel graph task
1 parent b7094b0 commit bbb4cf0

File tree

3 files changed

+297
-112
lines changed

3 files changed

+297
-112
lines changed

CHANGELOG.md

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,15 @@
1-
# Changelog
1+
# Changelog,
2+
3+
## [3.0.4] - 2025-04-29
4+
5+
### Added
6+
7+
- more debug logging for candidates selection
8+
9+
### Changed
10+
11+
- only add private channels to graph if they have an alias, remove private channels without an alias
12+
- lower log level to debug for repetitive graph refresh lines
213

314
## [3.0.3] - 2025-03-11
415

src/slings.rs

Lines changed: 184 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -265,6 +265,7 @@ async fn next_route(
265265
if !c.is_empty() {
266266
candidatelist = build_candidatelist(
267267
peer_channels,
268+
task,
268269
job,
269270
&graph,
270271
tempbans,
@@ -275,6 +276,7 @@ async fn next_route(
275276
} else {
276277
candidatelist = build_candidatelist(
277278
peer_channels,
279+
task,
278280
job,
279281
&graph,
280282
tempbans,
@@ -286,6 +288,7 @@ async fn next_route(
286288
} else {
287289
candidatelist = build_candidatelist(
288290
peer_channels,
291+
task,
289292
job,
290293
&graph,
291294
tempbans,
@@ -685,8 +688,10 @@ fn check_private_alias(
685688
true
686689
}
687690

691+
#[allow(clippy::too_many_arguments)]
688692
fn build_candidatelist(
689693
peer_channels: &HashMap<ShortChannelId, ListpeerchannelsChannels>,
694+
task: &Task,
690695
job: &Job,
691696
graph: &LnGraph,
692697
tempbans: &HashMap<ShortChannelId, u64>,
@@ -706,71 +711,193 @@ fn build_candidatelist(
706711
};
707712

708713
for channel in peer_channels.values() {
709-
if let Some(scid) = channel.short_channel_id {
710-
if is_channel_normal(channel).is_ok()
711-
&& channel.peer_connected
712-
&& match custom_candidates {
713-
Some(c) => c.iter().any(|c| *c == scid),
714-
None => true,
715-
}
716-
&& scid.block() <= blockheight - config.candidates_min_age
717-
{
718-
let chan_in_ppm = match get_remote_feeppm_effective(
719-
channel,
720-
graph,
714+
let scid = if let Some(scid) = channel.short_channel_id {
715+
scid
716+
} else {
717+
log::debug!(
718+
"{}/{}: build_candidatelist: channel with {} has no short_channel_id",
719+
task.chan_id,
720+
task.task_id,
721+
channel.peer_id
722+
);
723+
continue;
724+
};
725+
726+
if let Some(c) = custom_candidates {
727+
if c.iter().any(|c| *c == scid) {
728+
log::debug!(
729+
"{}/{}: build_candidatelist: found custom candidate {}",
730+
task.chan_id,
731+
task.task_id,
732+
scid
733+
);
734+
} else {
735+
continue;
736+
}
737+
};
738+
739+
if let Err(e) = is_channel_normal(channel) {
740+
log::debug!(
741+
"{}/{}: build_candidatelist: {} is not normal: {}",
742+
task.chan_id,
743+
task.task_id,
744+
scid,
745+
e
746+
);
747+
continue;
748+
}
749+
750+
if !channel.peer_connected {
751+
log::debug!(
752+
"{}/{}: build_candidatelist: {} is not connected",
753+
task.chan_id,
754+
task.task_id,
755+
scid
756+
);
757+
continue;
758+
}
759+
760+
if scid.block() > blockheight - config.candidates_min_age {
761+
log::debug!(
762+
"{}/{}: build_candidatelist: {} is too new: {}>{}",
763+
task.chan_id,
764+
task.task_id,
765+
scid,
766+
scid.block(),
767+
blockheight - config.candidates_min_age
768+
);
769+
continue;
770+
}
771+
772+
let chan_in_ppm = match get_remote_feeppm_effective(
773+
channel,
774+
graph,
775+
scid,
776+
job.amount_msat,
777+
&config.version,
778+
) {
779+
Ok(o) => o,
780+
Err(e) => {
781+
log::debug!(
782+
"{}/{}: build_candidatelist: could not get remote feeppm for {}: {}",
783+
task.chan_id,
784+
task.task_id,
721785
scid,
722-
job.amount_msat,
723-
&config.version,
724-
) {
725-
Ok(o) => o,
726-
Err(_) => continue,
727-
};
728-
729-
let to_us_msat = Amount::msat(&channel.to_us_msat.unwrap());
730-
let total_msat = Amount::msat(&channel.total_msat.unwrap());
731-
let chan_out_ppm = feeppm_effective(
732-
channel.fee_proportional_millionths.unwrap(),
733-
Amount::msat(&channel.fee_base_msat.unwrap()) as u32,
734-
job.amount_msat,
786+
e
735787
);
788+
continue;
789+
}
790+
};
736791

737-
if match job.sat_direction {
738-
SatDirection::Pull => {
739-
to_us_msat
740-
> max(
741-
job.amount_msat + 10_000_000,
742-
min(
743-
(depleteuptopercent * total_msat as f64) as u64,
744-
depleteuptoamount,
745-
),
746-
)
747-
&& match job.outppm {
748-
Some(out) => chan_out_ppm <= out,
749-
None => true,
750-
}
792+
let to_us_msat = Amount::msat(&channel.to_us_msat.unwrap());
793+
let total_msat = Amount::msat(&channel.total_msat.unwrap());
794+
let chan_out_ppm = feeppm_effective(
795+
channel.fee_proportional_millionths.unwrap(),
796+
Amount::msat(&channel.fee_base_msat.unwrap()) as u32,
797+
job.amount_msat,
798+
);
799+
800+
match job.sat_direction {
801+
SatDirection::Pull => {
802+
let liquidity_target = max(
803+
job.amount_msat + 10_000_000,
804+
min(
805+
(depleteuptopercent * total_msat as f64) as u64,
806+
depleteuptoamount,
807+
),
808+
);
809+
if to_us_msat <= liquidity_target {
810+
log::debug!(
811+
"{}/{}: build_candidatelist: {} does not have enough liquidity: {}<={}",
812+
task.chan_id,
813+
task.task_id,
814+
scid,
815+
to_us_msat,
816+
liquidity_target
817+
);
818+
continue;
819+
}
820+
if let Some(outppm) = job.outppm {
821+
if chan_out_ppm > outppm {
822+
log::debug!(
823+
"{}/{}: build_candidatelist: {} outppm is too high: {}>{}",
824+
task.chan_id,
825+
task.task_id,
826+
scid,
827+
chan_out_ppm,
828+
outppm
829+
);
830+
continue;
751831
}
752-
SatDirection::Push => {
753-
total_msat - to_us_msat
754-
> max(
755-
job.amount_msat + 10_000_000,
756-
min(
757-
(depleteuptopercent * total_msat as f64) as u64,
758-
depleteuptoamount,
759-
),
760-
)
761-
&& match job.outppm {
762-
Some(out) => chan_out_ppm >= out,
763-
None => true,
764-
}
765-
&& job.maxppm as u64 >= chan_in_ppm
832+
}
833+
}
834+
SatDirection::Push => {
835+
let liquidity_target = max(
836+
job.amount_msat + 10_000_000,
837+
min(
838+
(depleteuptopercent * total_msat as f64) as u64,
839+
depleteuptoamount,
840+
),
841+
);
842+
if total_msat - to_us_msat <= liquidity_target {
843+
log::debug!(
844+
"{}/{}: build_candidatelist: {} does not have enough liquidity: {}<={}",
845+
task.chan_id,
846+
task.task_id,
847+
scid,
848+
total_msat - to_us_msat,
849+
liquidity_target
850+
);
851+
continue;
852+
}
853+
if let Some(outppm) = job.outppm {
854+
if chan_out_ppm < outppm {
855+
log::debug!(
856+
"{}/{}: build_candidatelist: {} outppm is too low: {}<{}",
857+
task.chan_id,
858+
task.task_id,
859+
scid,
860+
chan_out_ppm,
861+
outppm
862+
);
863+
continue;
766864
}
767-
} && !tempbans.contains_key(&scid)
768-
&& get_total_htlc_count(channel) <= config.max_htlc_count
769-
{
770-
candidatelist.push(scid);
865+
}
866+
if chan_in_ppm > (job.maxppm as u64) {
867+
log::debug!(
868+
"{}/{}: build_candidatelist: {} inppm is too high: {}>{}",
869+
task.chan_id,
870+
task.task_id,
871+
scid,
872+
chan_in_ppm,
873+
job.maxppm
874+
);
875+
continue;
771876
}
772877
}
878+
};
879+
880+
if tempbans.contains_key(&scid) {
881+
log::debug!(
882+
"{}/{}: build_candidatelist: {} is temporarily banned",
883+
task.chan_id,
884+
task.task_id,
885+
scid
886+
);
887+
continue;
888+
}
889+
890+
if get_total_htlc_count(channel) > config.max_htlc_count {
891+
log::debug!(
892+
"{}/{}: build_candidatelist: {} has too many pending htlcs",
893+
task.chan_id,
894+
task.task_id,
895+
scid
896+
);
897+
continue;
773898
}
899+
900+
candidatelist.push(scid);
774901
}
775902

776903
candidatelist

0 commit comments

Comments
 (0)