Hold the `total_consistency_lock` while in `outbound_payment` fns
authorMatt Corallo <git@bluematt.me>
Fri, 3 Feb 2023 00:33:27 +0000 (00:33 +0000)
committerMatt Corallo <git@bluematt.me>
Tue, 28 Feb 2023 01:06:35 +0000 (01:06 +0000)
commit1d4bc1e0fb491a255dc7575ef77703bec073bbc8
treec3e91e3f0d2de1a143127099b994342810f5dea9
parentb5e5435c4e840a1b6a6ff0d552a7fa399fa5a424
Hold the `total_consistency_lock` while in `outbound_payment` fns

We previously avoided holding the `total_consistency_lock` while
doing crypto operations to build onions. However, now that we've
abstracted out the outbound payment logic into a utility module,
ensuring the state is consistent at all times is now abstracted
away from code authors and reviewers, making it likely to break.

Further, because we now call `send_payment_along_path` both with,
and without, the `total_consistency_lock`, and because recursive
read locks may deadlock, it would now be quite difficult to figure
out which paths through `outbound_payment` need the lock and which
don't.

While it may slow writes somewhat, it's not really worth trying to
figure out this mess, instead we just hold the
`total_consistency_lock` before going into `outbound_payment`
functions.
lightning/src/ln/channelmanager.rs
lightning/src/ln/functional_tests.rs