-
Notifications
You must be signed in to change notification settings - Fork 367
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
Need to relax temporary_channel_id check #105
Comments
Hmm, indeed, though honestly I'd kinda like to get the spec changed for that, it seems kinda shitty that we have to make the map use a (node_id, temporary_channel_id) instead of just channel_id key and I'd be highly surprised if any clients currently violate that. |
Technically we violate the spec, so this should stay open, even if I'd prefer the solution be a change to the spec. |
Note that this should come for free with #422. |
When we receive an error message from a peer, it can indicate a channel which we should close. However, we previously did not check that the counterparty who sends us such a message is the counterparty with whom we have the channel, allowing any connected peer to make us force-close any channel we have as long as they know the channel id. This commit simply changes the force-close logic to check that the sender matches the channel's counterparty node_id, though as noted in lightningdevkit#105, we eventually need to change the indexing anyway to allow absurdly terrible peers to open channels with us.
When we receive an error message from a peer, it can indicate a channel which we should close. However, we previously did not check that the counterparty who sends us such a message is the counterparty with whom we have the channel, allowing any connected peer to make us force-close any channel we have as long as they know the channel id. This commit simply changes the force-close logic to check that the sender matches the channel's counterparty node_id, though as noted in lightningdevkit#105, we eventually need to change the indexing anyway to allow absurdly terrible peers to open channels with us.
When we receive an error message from a peer, it can indicate a channel which we should close. However, we previously did not check that the counterparty who sends us such a message is the counterparty with whom we have the channel, allowing any connected peer to make us force-close any channel we have as long as they know the channel id. This commit simply changes the force-close logic to check that the sender matches the channel's counterparty node_id, though as noted in lightningdevkit#105, we eventually need to change the indexing anyway to allow absurdly terrible peers to open channels with us.
When we receive an error message from a peer, it can indicate a channel which we should close. However, we previously did not check that the counterparty who sends us such a message is the counterparty with whom we have the channel, allowing any connected peer to make us force-close any channel we have as long as they know the channel id. This commit simply changes the force-close logic to check that the sender matches the channel's counterparty node_id, though as noted in lightningdevkit#105, we eventually need to change the indexing anyway to allow absurdly terrible peers to open channels with us. Found during review of lightningdevkit#777.
When we receive an error message from a peer, it can indicate a channel which we should close. However, we previously did not check that the counterparty who sends us such a message is the counterparty with whom we have the channel, allowing any connected peer to make us force-close any channel we have as long as they know the channel id. This commit simply changes the force-close logic to check that the sender matches the channel's counterparty node_id, though as noted in lightningdevkit#105, we eventually need to change the indexing anyway to allow absurdly terrible peers to open channels with us.
When we receive an error message from a peer, it can indicate a channel which we should close. However, we previously did not check that the counterparty who sends us such a message is the counterparty with whom we have the channel, allowing any connected peer to make us force-close any channel we have as long as they know the channel id. This commit simply changes the force-close logic to check that the sender matches the channel's counterparty node_id, though as noted in lightningdevkit#105, we eventually need to change the indexing anyway to allow absurdly terrible peers to open channels with us. Found during review of lightningdevkit#777.
When we receive an error message from a peer, it can indicate a channel which we should close. However, we previously did not check that the counterparty who sends us such a message is the counterparty with whom we have the channel, allowing any connected peer to make us force-close any channel we have as long as they know the channel id. This commit simply changes the force-close logic to check that the sender matches the channel's counterparty node_id, though as noted in lightningdevkit#105, we eventually need to change the indexing anyway to allow absurdly terrible peers to open channels with us. Found during review of lightningdevkit#777.
When we receive an error message from a peer, it can indicate a channel which we should close. However, we previously did not check that the counterparty who sends us such a message is the counterparty with whom we have the channel, allowing any connected peer to make us force-close any channel we have as long as they know the channel id. This commit simply changes the force-close logic to check that the sender matches the channel's counterparty node_id, though as noted in lightningdevkit#105, we eventually need to change the indexing anyway to allow absurdly terrible peers to open channels with us. Found during review of lightningdevkit#777.
When we receive an error message from a peer, it can indicate a channel which we should close. However, we previously did not check that the counterparty who sends us such a message is the counterparty with whom we have the channel, allowing any connected peer to make us force-close any channel we have as long as they know the channel id. This commit simply changes the force-close logic to check that the sender matches the channel's counterparty node_id, though as noted in lightningdevkit#105, we eventually need to change the indexing anyway to allow absurdly terrible peers to open channels with us. Found during review of lightningdevkit#777.
Hmmm how would we like to design this? Would a good first step be to update the
Naturally the issue then becomes that there's no efficient way to retrieve a But, that proposed design is also problematic as we would then need to change the I'd be very thankful for any feedback :)! |
Yes, I think that's roughly the right design. I'm a bit worried about getting the locking right, but ultimately we want to get a bit of per-peer parallelism anyway, re #422.
Good! We should avoid doing that, which is most of the point of this issue :) You're right, we'll need to change a few public functions to take the |
Perfect I'll start with that then :).
Ok great thanks, I'll scrap the idea of the |
Hmmm given that the My idea above was to make it possible to fetch the My suggestion would be to only add Do you have a better suggestion of how to solve the problem, or do you think this would suffice :)? |
I don't think we need a new map here, we should just make the |
Thanks for the very helpful feedback @TheBlueMatt, and apologies for the delay on this one! I've been traveling most of last week, but I hope to be able to push a PR for this later this week. While working on this one a few more problems and questions have arisen, for which it would be very helpful to get some clarifications of: Question 1) rust-lightning/lightning/src/ln/channelmanager.rs Line 4851 in 75ca50f
From my understanding, we lack the data required to always be able to generate the short_channel_id at that stage, which otherwise would make it possible to find the channel through the short_to_id map.Therefore I guess the other approach would need to be to pass the counterparty_node_id with the affected MonitorEvent s (UpdateFailed and UpdateCompleted ). However, that is also problematic as that would require that we add the counterparty_node_id to some field in the MonitorHolder/ChannelMonitorImpl , so that it can be passed when the Events are generated. Adding the counterparty_node_id to the ChannelMonitorImpl would ruin the backwards compatibility though, as it would need to be a required field, and any ChannelMonitorImpl objects serialized prior to adding the field would lack it...
Am I missing something, or do you have any suggestion of how to solve this problem? Question 2a) Is the comment above only applicable for ensuring that we lock the channel storage before the Question 2b) Old design proposal (with slightly updated naming to be more correct):
New design proposal:
That would still open up for some per-peer parallelism, though perhaps to some lesser degree. But given the comment in 2a, the extra potential parallelism by the old design proposal seems be something we don't want anyways. Question 3) Looping over each channel is sadly done in quite a few places, and unfortunately I think theres no way around this inefficient looping in a few instances. Is that an ok efficiency loss? In a few instances where we are looping over the channels though, we are only interested in channels which have the Lastly: |
Question 1) Grrrrrrrrr, yea, that's a good point, and somewhat frustrating indeed. Long-term we can consider changing the monitor updates to include the counterparty node id (which I think may be useful in ChannelMonitors for other reasons), but for now I suppose we'll need to reintroduce the channel_id/funding_txo -> counterparty id lookup table (though only using it in monitor update handling). Question 2a) Question 2b) Question 3) |
Thanks a lot for the detailed answers @TheBlueMatt! |
Per
https://github.com/lightningnetwork/lightning-rfc/blame/4b62d26af93a07166d6a9de2cb5eff80849d9c19/02-peer-protocol.md#L172,
temporary_channel_id
is required to be unique only within the same peer.Then, this seems too restrictive:
https://github.com/rust-bitcoin/rust-lightning/blob/f975639d036b08706fc007aa327bffbc0a5f217b/src/ln/channelmanager.rs#L1265-L1267
The text was updated successfully, but these errors were encountered: