-
Notifications
You must be signed in to change notification settings - Fork 421
Description
I'm trying to figure out why I occasionally get this error on invoices that should not be expired, typically happens to me on brand new instances.
2023-06-08 18:53:55.097 DEBUG [mutiny_core::event:427] EVENT: PendingHTLCsForwardable: 100ms, processing...
2023-06-08 18:53:55.317 TRACE [lightning::ln::inbound_payment:380] Failing HTLC with payment_hash bd2a6e0f7cf3767cda376f9e79f01dea8ead4ad2e4b33453ca8227675c664b7d: expired payment
2023-06-08 18:53:55.317 TRACE [lightning::ln::channelmanager:3604] Failing new HTLC with payment_hash bd2a6e0f7cf3767cda376f9e79f01dea8ead4ad2e4b33453ca8227675c664b7d as payment verification failed
2023-06-08 18:53:55.319 TRACE [lightning::ln::channelmanager:4103] Failing HTLC with payment_hash bd2a6e0f7cf3767cda376f9e79f01dea8ead4ad2e4b33453ca8227675c664b7d backwards from us with HTLC error code 16399
2023-06-08 18:53:55.320 DEBUG [mutiny_core::event:424] EVENT: HTLCHandlingFailed, ignored
rust-lightning/lightning/src/ln/inbound_payment.rs
Lines 379 to 382 in b6787a4
| if expiry < highest_seen_timestamp { | |
| log_trace!(logger, "Failing HTLC with payment_hash {}: expired payment", log_bytes!(payment_hash.0)); | |
| return Err(()) | |
| } |
If I'm following the code correctly, this gets updated via best_block_updated:
rust-lightning/lightning/src/ln/channelmanager.rs
Line 6444 in b6787a4
| max_time!(self.highest_seen_timestamp); |
So I added a log before we called that to make sure that we're providing it a good timestamp, and from the same failed invoice above, this is the timestamp from the last time it was called before the failure:
2023-06-08 18:53:36.799 INFO [mutiny_core::esplora:220] Starting transaction sync.
2023-06-08 18:53:36.920 DEBUG [mutiny_core::esplora:332] Updating best block header time: 1686250398
2023-06-08 18:53:36.921 TRACE [lightning::ln::channelmanager:6076] New best block: 0000012e841f0c6c4b8ec5ec3c3b2566e1e14ffa7413c4d182e1c78d79ae5de5 at height 139572
2023-06-08 18:53:36.923 DEBUG [mutiny_core::esplora:332] Updating best block header time: 1686250398
2023-06-08 18:53:36.924 DEBUG [lightning::chain::chainmonitor:612] New best block 0000012e841f0c6c4b8ec5ec3c3b2566e1e14ffa7413c4d182e1c78d79ae5de5 at height 139572 provided via best_block_updated
2023-06-08 18:53:36.926 TRACE [mutiny_core::background:656] Persisting ChannelManager...
2023-06-08 18:53:36.927 TRACE [mutiny_core::background:656] Done persisting ChannelManager.
2023-06-08 18:53:36.954 INFO [mutiny_core::esplora:316] Finished transaction sync.
The invoice was:
lntbs75u1pjgyge6dqqnp4q2rzvkj5h0rz56kwx5z572pk42vnshg48a9qhq0dycgy207j5mnrzpp5h54xurmu7dm8ek3hd708nuqaa2826jkjujeng572sgnkwhrxfd7ssp5mn9e7x55gq75vvrx08vyhwkx9ulh2rykax57q8shaeveuqjjmm0s9qyysgqcqzptxqrpwusumuzwvetqwmzsqh4kwum5vz7txhtm9e2c7f7q3yz4j40t2xuqzx8mrrwk0x5dtazdrzud73v3jzcg8fuzz029drxrhhk8vazn2v9aspzvjshm
Which has a timestamp of 1686250298 with an expiry of 1500, so it should it should not be below highest seen of 1686250398.
Perhaps could the max time function not be working properly? Or we have some other time race going on? Or is expiry < highest_seen_timestamp correct? Perhaps just a naming issue but expiry is relative, so 1500 would be below timestamp and would cause the problem too, I would expect it to be invoice_timestamp + expiry < highest_seen_timestamp