Skip to content

smite-ir: implement RecvChannelReady operation#129

Merged
morehouse merged 2 commits into
morehouse:masterfrom
NishantBansal2003:recv-channel-ready
Jun 28, 2026
Merged

smite-ir: implement RecvChannelReady operation#129
morehouse merged 2 commits into
morehouse:masterfrom
NishantBansal2003:recv-channel-ready

Conversation

@NishantBansal2003

Copy link
Copy Markdown
Contributor

Depends-on: #128

Adds a RecvChannelReady operation. Receiving channel_ready from the target is different from other channel-opening messages: it is independent of whether we have sent our own channel_ready, and the target will only send it once the funding transaction has been broadcast and reached the minimum_depth requested in accept_channel.

To handle this, RecvChannelReady is made conditional. When executed, it may either receive a channel_ready or do nothing. A channel_ready is expected when a tracked channel is still at commitment number 0, the counterparty’s next per-commitment point is unknown, and the funding transaction has at least 8 confirmations. Since Lightning implementations typically use a default maximum minimum_depth of 8 in accept_channel, reaching 8 confirmations guarantees the target has sent its channel_ready

Comment thread smite-ir/src/operation.rs
Comment on lines +237 to +243
/// Receive and parse a `channel_ready` response.
///
/// This is a no-op unless some tracked channel is awaiting `channel_ready`
/// (still at commitment number 0 with the counterparty's next per-commitment
/// point unknown) and its funding transaction has enough confirmations for
/// the target to have sent `channel_ready`.
RecvChannelReady,

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

The executor automatically handles the second_per_commitment_point internally, but would it still be valuable to output the ChannelReady object, or maybe just the alias field?

Copy link
Copy Markdown
Contributor 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 output the alias field from the peer, but there are two issues:

  • it is a tlv, so it may be absent
  • the RecvChannelReady operation itself can be a no-op in some cases if no channel_ready is expected

So, if we want the output_type to be VariableType::ShortChannelId, we would need to output a default alias value whenever we are unable to extract one. Perhaps we could use the SCID 0 in those cases?

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Ah, yeah that's a bit ugly. We can figure it out later if we need it.

Comment thread smite-ir/src/operation.rs Outdated
Comment thread smite-scenarios/src/executor.rs
Comment thread smite-scenarios/src/executor.rs Outdated
Comment thread smite-scenarios/src/executor.rs Outdated
Signed-off-by: Nishant Bansal <nishant.bansal.282003@gmail.com>

@morehouse morehouse left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Ready to merge after squashing the fixup

state.commitment.commitment_number == 0
&& state.next_counterparty_per_commitment_point().is_none()
&& bitcoin_cli.get_transaction_confirmations(state.config.funding_outpoint.txid)
>= MAX_MINIMUM_DEPTH

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

In the future, once we start saving open_channel and accept_channel data, we could use the actual minimum_depth value from accept_channel instead.

Comment thread smite-ir/src/operation.rs
Comment on lines +237 to +243
/// Receive and parse a `channel_ready` response.
///
/// This is a no-op unless some tracked channel is awaiting `channel_ready`
/// (still at commitment number 0 with the counterparty's next per-commitment
/// point unknown) and its funding transaction has enough confirmations for
/// the target to have sent `channel_ready`.
RecvChannelReady,

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Ah, yeah that's a bit ugly. We can figure it out later if we need it.

Signed-off-by: Nishant Bansal <nishant.bansal.282003@gmail.com>
@morehouse morehouse merged commit f35b23e into morehouse:master Jun 28, 2026
5 checks passed
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