Skip to content

Drop system clock calls for PendingHTLCsForwardable events. #351

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

Merged
merged 2 commits into from
Jul 19, 2019
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 2 additions & 7 deletions src/ln/channel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ use util::config::{UserConfig,ChannelConfig};
use std;
use std::default::Default;
use std::{cmp,mem};
use std::time::Instant;
use std::sync::{Arc};

#[cfg(test)]
Expand Down Expand Up @@ -133,14 +132,13 @@ struct OutboundHTLCOutput {

/// See AwaitingRemoteRevoke ChannelState for more info
enum HTLCUpdateAwaitingACK {
AddHTLC {
AddHTLC { // TODO: Time out if we're getting close to cltv_expiry
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just to be sure, timeout here is only relevant if you are last peer in the payment route, don't have the preimage and can initiate the canceling walk back?

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And furthermore, I've a doubt where the cltv_expiry field of AddHTLC should be used in our API, I mean we have fail_htlc_backwards, which is public but how API consumer is leaded to be aware of delay ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These are HTLCs which we accepted for relay but which we have not yet added to the outbound channel (as we were waiting for a remote revoke_and_ack at the time we received them, or were otherwise unable to forward them). AFAIR, we will never fail these HTLCs backwards as the ChannelMonitor isn't even aware of them at this time.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay gotcha, not implemented yet, it's going with other TODO in Channel::update_add_htlc, need to pass height in process_pending_htlc_forwards I guess

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can just fail them backwards if they're still waiting to be forwarded as the CLTV starts to get close in a hook from block_connected.

// always outbound
amount_msat: u64,
cltv_expiry: u32,
payment_hash: PaymentHash,
source: HTLCSource,
onion_routing_packet: msgs::OnionPacket,
time_created: Instant, //TODO: Some kind of timeout thing-a-majig
},
ClaimHTLC {
payment_preimage: PaymentPreimage,
Expand Down Expand Up @@ -3252,7 +3250,6 @@ impl Channel {
cltv_expiry: cltv_expiry,
source,
onion_routing_packet: onion_routing_packet,
time_created: Instant::now(),
});
return Ok(None);
}
Expand Down Expand Up @@ -3622,14 +3619,13 @@ impl Writeable for Channel {
(self.holding_cell_htlc_updates.len() as u64).write(writer)?;
for update in self.holding_cell_htlc_updates.iter() {
match update {
&HTLCUpdateAwaitingACK::AddHTLC { ref amount_msat, ref cltv_expiry, ref payment_hash, ref source, ref onion_routing_packet, time_created: _ } => {
&HTLCUpdateAwaitingACK::AddHTLC { ref amount_msat, ref cltv_expiry, ref payment_hash, ref source, ref onion_routing_packet } => {
0u8.write(writer)?;
amount_msat.write(writer)?;
cltv_expiry.write(writer)?;
payment_hash.write(writer)?;
source.write(writer)?;
onion_routing_packet.write(writer)?;
// time_created is not serialized - we re-init the timeout upon deserialization
},
&HTLCUpdateAwaitingACK::ClaimHTLC { ref payment_preimage, ref htlc_id } => {
1u8.write(writer)?;
Expand Down Expand Up @@ -3796,7 +3792,6 @@ impl<R : ::std::io::Read> ReadableArgs<R, Arc<Logger>> for Channel {
payment_hash: Readable::read(reader)?,
source: Readable::read(reader)?,
onion_routing_packet: Readable::read(reader)?,
time_created: Instant::now(),
},
1 => HTLCUpdateAwaitingACK::ClaimHTLC {
payment_preimage: Readable::read(reader)?,
Expand Down