-
Notifications
You must be signed in to change notification settings - Fork 23
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
fix: reject pending offers #1763
Conversation
450eea6
to
04ef4ce
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 👍
I was able to reject an old unacceptable sub channel offer with this, however, I was then in a broken state. See here: #1761
I think your guess that a key was not successfully backed up is very likely for why you ended up in the broken state.
mobile/native/src/ln_dlc/mod.rs
Outdated
runtime.spawn({ | ||
let mut iteration_count = 0; | ||
|
||
while !node |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🤔 is this really needed. It think the channel status is derived from the shadow channel in the database.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I failed once to accept the order because I could not send a message to the coordinator to accept the offer because I was not connected :/
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🙃 But then it's not related to the track_channel_status
but to the sync_position_to_subchannel_state
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are completely right, this might have happened in a rebase. I'll fix it.
df38f76
to
f2a273b
Compare
mobile/native/src/ln_dlc/mod.rs
Outdated
if let Err(e) = node.sync_position_with_subchannel_state().await { | ||
tracing::error!("Failed to sync position with subchannel state. Error: {e:#}"); | ||
} | ||
runtime.spawn({ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🤔 Could that be potentially dangerous as it's not blocking?
What if the user is opening / closing a position in the meantime?
@bonomat is there anything left on this PR or can we get it merged? |
I thought I had pushed the fix for your last comment 🙈 I'm using spawn_blocking now. |
In `track_channel_status` we might need a connection to the coordinator. This is not always guaranteed because we spawn the connection task async as well. Hence, we wait here up to 1 minute. If we still haven't connected we give up and continue nevertheless. The below function call _might_ fail in certain cases but it's not the end of the world as we will retry simply when the user restarts the app the next time. Hopefully by then the coordinator is reachable
This patch adds two things: 1. we check if we have any pending subchannel offers which need to be handled. We check if the subchannel offer is still valid, and if so, we accept, otherwise we reject. 2. if we fail accepting a subchannel offer, we reject it. This is needed so that we can recover in case of an offer which can't be accepted. The user is then invited to simply try again.
f2a273b
to
abbe1bd
Compare
@holzeis : I'm going ahead and merge this with my last fix. |
I was able to reject an old unacceptable sub channel offer with this, however, I was then in a broken state. See here: #1761