L2-Technology / sensei

A lightning node implementation for everyone
https://l2.technology/sensei
Other
199 stars 39 forks source link

use separate runtime for ldk tasks #74

Closed johncantrell97 closed 2 years ago

johncantrell97 commented 2 years ago

An attempt to avoid running into deadlocks when ldk is holding mutexes and we need to block in ldk user land.

Need to test this patch with devrandom's python tests

praveenperera commented 2 years ago

@johncantrell97 in the past I've used once-cell to hold a runtime, might make it easier in this case, to avoid passing the runtime handles around.

use once_cell::sync::{Lazy, OnceCell};

pub static SENSEI_RUNTIME: Lazy<tokio::runtime::Runtime> = Lazy::new(|| {
    tokio::runtime::Builder::new_multi_thread()
         .worker_threads(10)
         .thread_name("sensei")
         .enable_all()
         .build()
         .unwrap();
});
TheBlueMatt commented 2 years ago

I don't believe that this should be required. I'd really like to understand where the issue lies before we fall down this path.

TheBlueMatt commented 2 years ago

Ah, if @devrandom is right at https://github.com/lightningdevkit/rust-lightning/issues/1367#issuecomment-1129092514 then I think a much simpler approach would be to just create a single threaded runtime in place in the persister. This would also make it simpler to just revert the changes after https://github.com/lightningdevkit/rust-lightning/issues/1470 . I'm not aware of any other lock issues as there's not much other reentrancy in LDK.

johncantrell97 commented 2 years ago

going to close this in favor of the hopefully simpler workaround