Skip to content

smite-ir: implement RecvFundingSigned operation#123

Merged
morehouse merged 2 commits into
morehouse:masterfrom
NishantBansal2003:recv-funding-signed
Jun 17, 2026
Merged

smite-ir: implement RecvFundingSigned operation#123
morehouse merged 2 commits into
morehouse:masterfrom
NishantBansal2003:recv-funding-signed

Conversation

@NishantBansal2003

Copy link
Copy Markdown
Contributor

This PR adds RecvFundingSigned operation, which receives a funding_signed message from the target and verifies that it is expected for the given channel_id. It also checks that a funding_signed message is not received when the opener cannot afford the feerate. Finally, it verifies that the commitment signature sent by the remote party is valid for the local commitment transaction.

I also took this PR as an opportunity to address the comment in: #97 (comment), since otherwise there would be an inconsistency between the Display implementations of RecvFundingSigned and RecvAcceptChannel

Signed-off-by: Nishant Bansal <nishant.bansal.282003@gmail.com>
Comment thread smite-scenarios/src/scenarios/ir.rs Outdated
Comment thread smite-scenarios/src/executor.rs Outdated
Comment on lines +128 to +130
/// The opener cannot afford the feerate for the commitment transaction.
#[error("opener cannot afford commitment fee for channel_id {0:?}")]
OpenerCannotAffordFee(ChannelId),

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.

According to the spec, a correct target should reject this case immediately after receiving the invalid open_channel. So it seems that this check should really live in the handling of RecvAcceptChannel.

I think it would be a good future PR to implement an open_channel/accept_channel oracle that checks whether the target properly validates the channel parameters according to the spec.

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.

Yeah, ideally that’s the correct place to perform the check. However, we currently key the state by ChannelId, which is derived from the funding outpoint, and we don’t know the funding outpoint when processing RecvAcceptChannel. Even if we were to verify it manually at that stage, we’d still need funding_satoshis from the corresponding open_channel message to fully validate it. Because of that, we first need a way to map an accept_channel response back to its corresponding open_channel message. The verification in funding_signed is effectively doing that mapping indirectly, which is why I placed the check there.

But yeah, we could definitely move this validation to immediately after RecvAcceptChannel if we maintain that mapping explicitly. I think we can revisit this in the future and keep the current approach for the MVP?

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.

Sounds good. Maybe we could create a OpenAcceptChannelOracle object that we inform about every open_channel and accept_channel, and the oracle could manage the mapping itself via temporary_channel_id...

Comment thread smite-scenarios/src/executor.rs
Comment thread smite-scenarios/src/executor.rs Outdated

@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.

Looks good, ready to squash.

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.

LGTM

@morehouse morehouse merged commit 2ed34ce into morehouse:master Jun 17, 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