-
Notifications
You must be signed in to change notification settings - Fork 0
lightning-net Iteration 1 #1
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
Conversation
FWIW, as a starting point, transliterating https://github.com/lightningdevkit/ldk-c-bindings/blob/main/ldk-net/ldk_net.c into rust should work. |
@TheBlueMatt I deleted the fat finger PR almost immediately but you still noticed, embarrassing 😅 Thanks for the tip! At this point I'm still trying to wrap my head around the async Tokio / C implementations and how it integrates with the rest of LDK. After this code gets closer to a finished state, I'll be in touch to discuss the best way it can be integrated upstream. |
Sounds good. I'd generally recommend you either read the C or the Java code as the tokio one ends up with a bunch of complication to fit into the world of futures. Java is at https://github.com/lightningdevkit/ldk-garbagecollected/blob/main/src/main/java/org/ldk/batteries/NioPeerHandler.java |
@phlip9 Implemented all comments except the ones where I had a response / wanted to iterate. Plz take a look. |
Squashed commits in original PR at #1: - Create empty lightning-net module - SyncSocketDescriptor skeleton implementation - Connection struct with read and write halves - Implement shutdown() for TcpReader and TcpWriter - Implement most of spawn_inbound_handler - Add crossbeam and some associated channels - Implement basic functionality of ConnectionWriter - Pass a Arc<PeerManager> into ConnectionReader - Get a SyncSocketDescriptor into the ConnectionWriter - Implement first half of pausing reads - Renome write tx/rx to write_data tx/rx - Rename ConnectionReader/Writer to Reader/Writer - Create the Reader/Writer cmd channels - Send ResumeRead command to the Reader - Remove write_cmd, rename reader_cmd -> resume_read - Reader can handle ResumeRead events - Implement disconnecting from peer - send_data() actually sends data now - Allow send_data() to pause reads - Get a Arc<PeerManager> into Writer - Refactor write_data tx/rx into writer_cmd tx/rx - Give Reader/Writer a cmd tx for the other - Implement all disconnecting except TcpDisconnectooor - Remove the Arc<Mutex<Connection>> - Refactor Connection into setup() - disconnect_socket() now calls into TcpDisconnectooor - Get a SyncSocketDescriptor into Writer - Call write_buffer_space_avail and socket_disconnected v2 - resume_read check should go before the early return - Handle read() ErrorKind variants - Implement handle_connection and initiate_outbound - Finish writing doc comments, clean up - Basic tests for lightning-net - These is modeled exactly after the tests in lightning-net-tokio - Update GitHub CI and dependabot for lightning-net - Reduce the dependencies used - Implementing PR review feedback from @phlip9 - Remove some comments about SGX - Hide ID_COUNTER in a function, return JoinHandles - Reader/Writer now send commands via the descriptor - Extract do_recv(), do_try_recv(), do_read() fns v2 - Split WriteData command into its own channel v4 - Remove `std::net` limitations from EDP doc comment - Implement ReaderState enum v2
This PR is done iterating, now in the process of being upstreamed at lightningdevkit#1469 |
Squashed commits in original PR at #1: - Create empty lightning-net module - SyncSocketDescriptor skeleton implementation - Connection struct with read and write halves - Implement shutdown() for TcpReader and TcpWriter - Implement most of spawn_inbound_handler - Add crossbeam and some associated channels - Implement basic functionality of ConnectionWriter - Pass a Arc<PeerManager> into ConnectionReader - Get a SyncSocketDescriptor into the ConnectionWriter - Implement first half of pausing reads - Renome write tx/rx to write_data tx/rx - Rename ConnectionReader/Writer to Reader/Writer - Create the Reader/Writer cmd channels - Send ResumeRead command to the Reader - Remove write_cmd, rename reader_cmd -> resume_read - Reader can handle ResumeRead events - Implement disconnecting from peer - send_data() actually sends data now - Allow send_data() to pause reads - Get a Arc<PeerManager> into Writer - Refactor write_data tx/rx into writer_cmd tx/rx - Give Reader/Writer a cmd tx for the other - Implement all disconnecting except TcpDisconnectooor - Remove the Arc<Mutex<Connection>> - Refactor Connection into setup() - disconnect_socket() now calls into TcpDisconnectooor - Get a SyncSocketDescriptor into Writer - Call write_buffer_space_avail and socket_disconnected v2 - resume_read check should go before the early return - Handle read() ErrorKind variants - Implement handle_connection and initiate_outbound - Finish writing doc comments, clean up - Basic tests for lightning-net - These is modeled exactly after the tests in lightning-net-tokio - Update GitHub CI and dependabot for lightning-net - Reduce the dependencies used - Implementing PR review feedback from @phlip9 - Remove some comments about SGX - Hide ID_COUNTER in a function, return JoinHandles - Reader/Writer now send commands via the descriptor - Extract do_recv(), do_try_recv(), do_read() fns v2 - Split WriteData command into its own channel v4 - Remove `std::net` limitations from EDP doc comment - Implement ReaderState enum v2
Squashed commits in original PR at #1: - Create empty lightning-net module - SyncSocketDescriptor skeleton implementation - Connection struct with read and write halves - Implement shutdown() for TcpReader and TcpWriter - Implement most of spawn_inbound_handler - Add crossbeam and some associated channels - Implement basic functionality of ConnectionWriter - Pass a Arc<PeerManager> into ConnectionReader - Get a SyncSocketDescriptor into the ConnectionWriter - Implement first half of pausing reads - Renome write tx/rx to write_data tx/rx - Rename ConnectionReader/Writer to Reader/Writer - Create the Reader/Writer cmd channels - Send ResumeRead command to the Reader - Remove write_cmd, rename reader_cmd -> resume_read - Reader can handle ResumeRead events - Implement disconnecting from peer - send_data() actually sends data now - Allow send_data() to pause reads - Get a Arc<PeerManager> into Writer - Refactor write_data tx/rx into writer_cmd tx/rx - Give Reader/Writer a cmd tx for the other - Implement all disconnecting except TcpDisconnectooor - Remove the Arc<Mutex<Connection>> - Refactor Connection into setup() - disconnect_socket() now calls into TcpDisconnectooor - Get a SyncSocketDescriptor into Writer - Call write_buffer_space_avail and socket_disconnected v2 - resume_read check should go before the early return - Handle read() ErrorKind variants - Implement handle_connection and initiate_outbound - Finish writing doc comments, clean up - Basic tests for lightning-net - These is modeled exactly after the tests in lightning-net-tokio - Update GitHub CI and dependabot for lightning-net - Reduce the dependencies used - Implementing PR review feedback from @phlip9 - Remove some comments about SGX - Hide ID_COUNTER in a function, return JoinHandles - Reader/Writer now send commands via the descriptor - Extract do_recv(), do_try_recv(), do_read() fns v2 - Split WriteData command into its own channel v4 - Remove `std::net` limitations from EDP doc comment - Implement ReaderState enum v2
lightningdevkit#1469 PR closed; replaced by #24 |
Squashed commits in original PR at #1: - Create empty lightning-net module - SyncSocketDescriptor skeleton implementation - Connection struct with read and write halves - Implement shutdown() for TcpReader and TcpWriter - Implement most of spawn_inbound_handler - Add crossbeam and some associated channels - Implement basic functionality of ConnectionWriter - Pass a Arc<PeerManager> into ConnectionReader - Get a SyncSocketDescriptor into the ConnectionWriter - Implement first half of pausing reads - Renome write tx/rx to write_data tx/rx - Rename ConnectionReader/Writer to Reader/Writer - Create the Reader/Writer cmd channels - Send ResumeRead command to the Reader - Remove write_cmd, rename reader_cmd -> resume_read - Reader can handle ResumeRead events - Implement disconnecting from peer - send_data() actually sends data now - Allow send_data() to pause reads - Get a Arc<PeerManager> into Writer - Refactor write_data tx/rx into writer_cmd tx/rx - Give Reader/Writer a cmd tx for the other - Implement all disconnecting except TcpDisconnectooor - Remove the Arc<Mutex<Connection>> - Refactor Connection into setup() - disconnect_socket() now calls into TcpDisconnectooor - Get a SyncSocketDescriptor into Writer - Call write_buffer_space_avail and socket_disconnected v2 - resume_read check should go before the early return - Handle read() ErrorKind variants - Implement handle_connection and initiate_outbound - Finish writing doc comments, clean up - Basic tests for lightning-net - These is modeled exactly after the tests in lightning-net-tokio - Update GitHub CI and dependabot for lightning-net - Reduce the dependencies used - Implementing PR review feedback from @phlip9 - Remove some comments about SGX - Hide ID_COUNTER in a function, return JoinHandles - Reader/Writer now send commands via the descriptor - Extract do_recv(), do_try_recv(), do_read() fns v2 - Split WriteData command into its own channel v4 - Remove `std::net` limitations from EDP doc comment - Implement ReaderState enum v2
Synchronous lightning-net
All the SGX functionality is missing, but the PR is chonky enough already, can probably move forward with that in a follow-on PR.