Skip to content

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

Closed
wants to merge 42 commits into from
Closed

lightning-net Iteration 1 #1

wants to merge 42 commits into from

Conversation

MaxFangX
Copy link

@MaxFangX MaxFangX commented Apr 22, 2022

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.

@TheBlueMatt
Copy link

FWIW, as a starting point, transliterating https://github.com/lightningdevkit/ldk-c-bindings/blob/main/ldk-net/ldk_net.c into rust should work.

@MaxFangX
Copy link
Author

@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.

@TheBlueMatt
Copy link

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

@MaxFangX
Copy link
Author

MaxFangX commented May 5, 2022

@phlip9 Implemented all comments except the ones where I had a response / wanted to iterate. Plz take a look.

@MaxFangX MaxFangX requested a review from phlip9 May 5, 2022 02:08
@MaxFangX MaxFangX changed the title lightning-net Version 1 lightning-net Iteration 1 May 5, 2022
MaxFangX added a commit that referenced this pull request May 5, 2022
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
@MaxFangX
Copy link
Author

MaxFangX commented May 6, 2022

This PR is done iterating, now in the process of being upstreamed at lightningdevkit#1469

@MaxFangX MaxFangX closed this May 6, 2022
MaxFangX added a commit that referenced this pull request May 6, 2022
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
MaxFangX added a commit that referenced this pull request May 6, 2022
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
@MaxFangX
Copy link
Author

MaxFangX commented May 20, 2022

lightningdevkit#1469 PR closed; replaced by #24

MaxFangX added a commit that referenced this pull request May 20, 2022
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
@MaxFangX MaxFangX deleted the net-sync-1 branch May 20, 2022 20:38
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.

3 participants