Skip to content

Prevent channel_id collisions - #3337

Merged
t-bast merged 2 commits into
masterfrom
prevent-channel-id-collisions
Jul 28, 2026
Merged

Prevent channel_id collisions#3337
t-bast merged 2 commits into
masterfrom
prevent-channel-id-collisions

Conversation

@t-bast

@t-bast t-bast commented Jul 28, 2026

Copy link
Copy Markdown
Member

If the first DB write of a channel fails, we want to abort the channel immediately, otherwise our state may be unusable. If for some reason we already have a channel (for example because of a partial restore from a DB backup), we want to avoid overwriting this state as well. This is implemented in the first commit of this PR.

In the second commit, we prevent channel_id collisions across peers: while highly unlikely (since they depend on the actual funding transaction for single-funding and the random revocation basepoint for dual-funding), they would trigger a force-close. We thus add a global, concurrent channel_id map, which can be reused in the future for accounting.

t-bast added 2 commits July 28, 2026 11:26
If the first DB write of a channel fails, we want to abort the channel
immediately, otherwise our state may be unusable. If for some reason
we already have a channel (for example because of a partial restore
from a DB backup), we want to avoid overwriting this state as well.
We add a global, concurrent map that keeps track of every temporary
and final `channel_id` being used. We always add to this map before
creating channel actors or transitioning to a final `channel_id`
(and thus before storing channel data in the DB).

We only remove from that map when a channel actor dies: no other
channel can be associated with the corresponding temporary or
final `channel_id` since the channel was created after registering
the IDs.
@t-bast
t-bast requested review from pm47 and sstone July 28, 2026 09:29
@t-bast
t-bast merged commit 45ea9fb into master Jul 28, 2026
1 check passed
@t-bast
t-bast deleted the prevent-channel-id-collisions branch July 28, 2026 13:55
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.

2 participants