Skip to content

simln-lib/feat: Surface send_to_route for SimGraph #268

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

chuksys
Copy link
Contributor

@chuksys chuksys commented May 16, 2025

Description

This PR makes it possible for a user of simln-lib (in sim-node mode) to send payments to a predetermined route. This addresses the need for end-users to send custom payments, crucial for scenarios like channel jamming attacks or pathfinding experiments, which the current activity paradigm doesn't support.

Changes

  • A send_to_route method was added to SimGraph.
  • A track_payment_to_route method was added to SimGraph.
  • A build_payment_route helper function was added.
  • 3 test cases were added to test successful route payment and tracking, route building errors and payment tracking errors.

This PR closes #257

@carlaKC carlaKC self-requested a review May 16, 2025 17:37
Comment on lines +786 to +792
pub async fn send_to_route(
&mut self,
sending_node_id: PublicKey,
hops: &[PublicKey],
routing_graph: Arc<NetworkGraph<&WrappedLog>>,
amount_msat: u64,
) -> Result<PaymentHash, LightningError> {
Copy link
Contributor Author

@chuksys chuksys May 16, 2025

Choose a reason for hiding this comment

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

Still thinking which approach is better - 

  1. Passing in hops - which is an ordered list of pubkeys of the nodes to be used to build the LDK route.
  2. Passing in the LDK route directly.

Also, for the use-case of simulating channel jamming attacks, I'm thinking it might be a good idea to pass in a value that we could use to delay the removal of htlcs from channels being targeted - perhaps that could be a follow-up for this PR?

Copy link
Contributor

Choose a reason for hiding this comment

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

Since this is a pretty advanced API (you want to do custom payments on top of the regular simulation's payments), I think that we can get away with passing the LDK route directly.

This also gives more flexibility. For example, in my channel jamming case I sometimes want to set a really high CLTV delta (that our pathfinding wouldn't sanely pick) as part of an attack.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This also gives more flexibility. For example, in my channel jamming case I sometimes want to set a really high CLTV delta (that our pathfinding wouldn't sanely pick) as part of an attack.

I agree - passing the LDK route directly makes a lot of sense. I'll sort this out and push the changes asap!

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.

Feature Request: Surface Send To Route on LightningNode trait
2 participants