Skip to content
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

Add a message retransmission sub-system #137

Closed
Roasbeef opened this issue Feb 12, 2017 · 1 comment
Closed

Add a message retransmission sub-system #137

Roasbeef opened this issue Feb 12, 2017 · 1 comment
Labels
advanced Issues suitable for very experienced developers database Related to the database/storage of LND enhancement Improvements to existing features / behaviour intermediate Issues suitable for developers moderately familiar with the codebase and LN p2p Code related to the peer-to-peer behaviour

Comments

@Roasbeef
Copy link
Member

Roasbeef commented Feb 12, 2017

Message retransmission has now been described in detail within the spec. The implementation specified is (at a high-level ) rather straight forward: for each message sent, there exists a message which when received implicitly "ACKs" the message sent. Once the message has been ACK'd, the sending node does not need to retransmit any message to the target peer which have been ACK'd.

I have a sketch that I thin allows for a simple implementation, while logically centralizing the logic for transmissions into a single place within the daemon.

Currently when a sub-system needs to send a message directly to a peer, it uses the peer's queueMessage method directly (with some exceptions). Rather than using that method, all requests to send directly to a peer should instead be routed through the sever's sendToPeer method. This allows funnel all send requests to a single point so we can compactly include our retransmission logic.

Within sendToPeer, before sending the message, the re-transmission sub-system should first be notified of the new send attempt to it can flush the message to disk within an area dedicated to un-ACK'd messages by that peer. The storage can either be implemented within boltdb or within flat-files, with the latter likely being more performant. Within the readHandler, upon receipt of a new message, the retransmission sub-system should be notified of the new message. If the message ACK's a previously un-ACK'd message, then the entry can safely be deleted.

If the server is unable to send the message to the peer due to it being offline, them the message should be queue'd on-disk to be transmitted upon connection of the peer.

Finally, upon reconnection, when first creating the peer and after the init message is sent, then the un-ACK'd queue for that peer should be examined. If it's non-empty (or exists), then all the messages should immediately_ be retransmitted to the remote peer before accepting any other send requests.

Follow Up Tasks

A similar sub-system should be added within he daemon that ensures that all transactions broadcast eventually end up in a block. This capability can either be included within lnd itself, or the WalletController contract be extended to ensure that all transactions submitted to the PublishTransaction method are rebroadcast until confirmation.

@Roasbeef Roasbeef added advanced Issues suitable for very experienced developers database Related to the database/storage of LND enhancement Improvements to existing features / behaviour intermediate Issues suitable for developers moderately familiar with the codebase and LN p2p Code related to the peer-to-peer behaviour labels Feb 12, 2017
@Roasbeef Roasbeef added this to the v0.2-alpha milestone Feb 12, 2017
@andrewshvv
Copy link
Contributor

will take this one

andrewshvv added a commit to andrewshvv/lnd that referenced this issue Mar 16, 2017
Issue: lightningnetwork#137

In this commit retranmission subsystem and boltdb mesage storage were
added. Retransmission subsystem described in details in BOLT #2
(Message Retransmission) section. This subsystem keeps records
of all messages that were sent to other peer and waits the ACK
message to be received from other side and after that removes all
acked messaged from the storage.
andrewshvv added a commit to andrewshvv/lnd that referenced this issue Mar 16, 2017
Issue: lightningnetwork#137

In this commit the retransmission subsystem was included in lnd,
now upon peer reconnection we fetch all messages from message storage
that were not acked and send them again to remote side.
@Roasbeef Roasbeef modified the milestones: v0.3.1-alpha, v0.2-alpha Aug 27, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
advanced Issues suitable for very experienced developers database Related to the database/storage of LND enhancement Improvements to existing features / behaviour intermediate Issues suitable for developers moderately familiar with the codebase and LN p2p Code related to the peer-to-peer behaviour
Projects
None yet
Development

No branches or pull requests

2 participants