Skip to content

smite-ir: add LookupShortChannelId operation - #155

Merged
morehouse merged 1 commit into
lnfuzz:masterfrom
devvaansh:lookup-short-channel-id
Jul 27, 2026
Merged

smite-ir: add LookupShortChannelId operation#155
morehouse merged 1 commit into
lnfuzz:masterfrom
devvaansh:lookup-short-channel-id

Conversation

@devvaansh

@devvaansh devvaansh commented Jul 17, 2026

Copy link
Copy Markdown
Contributor

Adds LookupShortChannelId, which takes a FundingTransaction and produces the BOLT 7 short_channel_id derived from its confirmed block position.

This is the missing piece needed to build validly-signed gossip messages that reference a real on-chain UTXO and can pass the UTXO validation checks in CLN and LND.

If the transaction is not yet confirmed (e.g. a mutator dropped MineBlocks), the sentinel ShortChannelId::new(0, 0, 0) is returned rather than panicking. A valid but unconfirmed program should not be a fatal error.

Ref: #71

@devvaansh
devvaansh force-pushed the lookup-short-channel-id branch 2 times, most recently from 5082f5e to 779e50b Compare July 17, 2026 16:46

@morehouse morehouse left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Just missing an executor test.

Comment thread smite-scenarios/src/executor.rs Outdated
Comment thread smite-ir/src/operation.rs
Comment on lines 923 to +935
pub fn has_side_effects(&self) -> bool {
match self {
Self::SendMessage
| Self::SendOpenChannel
| Self::SendFundingCreated
| Self::SendChannelReady { .. }
| Self::RecvAcceptChannel
| Self::RecvFundingSigned
| Self::RecvChannelReady
| Self::MineBlocks(_)
| Self::CreateFundingTransaction
| Self::BroadcastTransaction => true,
| Self::BroadcastTransaction
| Self::LookupShortChannelId => true,

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I would argue that LookupShortChannelId does not have side effects, since it is a read-only operation. But I see that we need it here to prevent CSE from merging it with other lookups, since the result is nondeterministic (depends on the relative position of a MineBlocks operation).

I think it's fine to put it here to keep this PR simple. But this inconsistency hints that we may want a separate is_deterministic function for use by CSE, which could be a follow-up PR.

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.

Agreed. It's purely a read- no I/O, no state mutation. The only reason it's in has_side_effects is to keep CSE from collapsing two lookups that straddle a MineBlocks. Will track is_deterministic as a follow-up.

@devvaansh
devvaansh force-pushed the lookup-short-channel-id branch from 779e50b to 86782fe Compare July 24, 2026 18:06
Comment thread smite-scenarios/src/executor.rs
Comment thread smite-scenarios/src/executor.rs
@devvaansh
devvaansh force-pushed the lookup-short-channel-id branch from 86782fe to c397439 Compare July 24, 2026 19:28
Comment thread smite-scenarios/src/executor.rs Outdated
Comment thread smite-scenarios/src/executor.rs Outdated
Comment thread smite-scenarios/src/executor.rs Outdated
@devvaansh
devvaansh force-pushed the lookup-short-channel-id branch 2 times, most recently from a2bb508 to 4fac511 Compare July 27, 2026 17:16
Adds an IR operation that takes a broadcast FundingTransaction and
produces the BOLT 7 short_channel_id derived from its confirmed block
position. This bridges the on-chain funding output to the gossip layer
so channel_announcement, channel_update, and announcement_signatures
messages can reference a real UTXO and pass on-chain validation in CLN
and LND.

Under the hood the executor calls BitcoinCli::get_transaction_block_position
and combines the returned (block_height, tx_index) with the funding
transaction's vout. If the transaction is unknown to the node or still
in the mempool (e.g. a mutator dropped MineBlocks between the broadcast
and the lookup), the sentinel ShortChannelId::new(0, 0, 0) is produced
instead of panicking: the resulting gossip message simply fails on-chain
validation, which is the desired behaviour for a valid but unconfirmed
program.

The BitcoinRpc trait grows a get_transaction_block_position method with
a MockBitcoinCli implementation that mirrors the existing confirmations
mock.
@devvaansh
devvaansh force-pushed the lookup-short-channel-id branch from 4fac511 to f76879f Compare July 27, 2026 17:17

@morehouse morehouse left a comment

Copy link
Copy Markdown
Collaborator

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 47dfe48 into lnfuzz:master Jul 27, 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