Skip to content

attempt to create API for regular Pings #382

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 185 commits into from
Closed

attempt to create API for regular Pings #382

wants to merge 185 commits into from

Conversation

Aleru
Copy link

@Aleru Aleru commented Oct 19, 2019

Let me know if there are any revisions you would like or things I should do differently next time.

@TheBlueMatt
Copy link
Collaborator

TheBlueMatt commented Oct 19, 2019 via email

@Aleru
Copy link
Author

Aleru commented Oct 19, 2019

Sounds good, If I understand you correctly the final function would look something like this:

pub fn check_peers(&mut self) -> Result<(), PeerHandleError> {
disconnect_if_no_pong(self); //disconnect if there is no pong in a Peers pending_read_buffer
ping_peers(); // put a ping message in every peers pending outbound buffer
}

A couple notes/concerns though

If I understand correctly the desired implementation would require the user to generate the very first Ping message (I am assuming this is okay).

The disconnect_if_no_pong function (at least the way it is currently written) does not really have any knowledge of specific ping messages it just scans a copy of the pending_read_buffer looking for anything that resembles a pong message, if there is no pong-like message it removes the Peer from PeerHolder. It seems really sketchy that I manually removed (calling the remove method on the hashmap) the Peer from Peerholder.peers as opposed to using some prewritten functionality (I could not find anything that worked so i just manually removed the Peer).

The disconnect_if_no_pong function also does not clear the Pong messages from the pending_read_buffer either, should i be concerned that they will build up and never be removed?

TheBlueMatt and others added 22 commits November 8, 2019 20:01
It suggested figuring something else out after #81, but the API we
settled on after #81 (which I think is just fine) doesn't allow for
anything cleaner, so this is fine as-is.
This carries a surprising amount of complexity despite only being
possible in the case where monitor updating failed during the
processing of funding_generated. Specifically, this requires
handling rebroadcasting funding_locked once we successfully persist
our monitor again.

As an alternative we could never send funding_signed when the
monitor failed to persist, but this approach avoids needless
delays during funding.
This avoids a crash where a channel with a duplicate id is created
immediately after another is closed, where the other still has a
pending funding generation event. Resulting in funding generation
being passed to the wrong channel (which isn't in an appropriate
state).
max_htlc_value_in_flight_msat is applied
per-direction
In case of sending channel_reestablish message, we join
our current per_commitment_point and their highest revocation
secret we know about

We set data_loss_protect by default and adjust encoding_init
test in consequence
If we remote peer provide us a revocation secret which doesn't
match with next_remote_revocation_number we close the channel
If we learn that we are fallen-behind, we send back a CloseDelayBroadcast
error, special take care will be take to log error and channel should
stale, i.e we expect our honest peer to unilateral close to claim
on it our balance

Add ChannelError::CloseDelayBroadcast to signal that you need to close
the channel but not to broadcast it while however update ChannelMonitor
with remote per_commitment_point thanks to our peer being a gentleman
You may use it to get a broadcastable local toxic tx in case of fallen-behind,
i.e when receiving a channel_reestablish with a proof that our remote side
knows a higher revocation secret than the local commitment number we are aware
of. Broadcasting these transactions are UNSAFE, as they allow remote side to punish
you. Nevertheless you may want to broadcast them if remote don't close channel with his
higher commitment transaction after a substantial amount of time (a month or even a year)
to get back funds. Best may be to contact out-of-band the other node operator to coordinate
with him if option is available to you. In any-case, choice is up to the user.

Also, log toxic commitment tx id in channel_reestablish sending back
ChannelError::CloseDelayBroadcast
Also, restrict commitment transaction filters in ChannelMonitor::
block_connected
Update the fuzz and net-tokio crates

first add

updateS

add

commit

commit

updates

s

fixed first bug :D

fixed bug for real this time... probably should read docs of related structures before i begin hacking

coming along nicely

need docs and test

updates

commit

x

 n

another update

cleaning it up a bit for groupwork

more cleaning :P

add todot

remove no longer relevant comment

fixed issue of disconnecting peer

removed extra comment

probably ready for PR

ready for pr... for real this time!

ready for pr act 3

ready for pr act 4
just sharing work, not ready for review
@Aleru
Copy link
Author

Aleru commented Nov 9, 2019

Ouch, I think i will try using GUI. please go ahead and disregard all the commits I don't really know what is going on.

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.

10 participants