Skip to content

smite: add channel_ready oracle - #260

Open
NishantBansal2003 wants to merge 8 commits into
lnfuzz:masterfrom
NishantBansal2003:channel-ready-oracle
Open

NishantBansal2003 wants to merge 8 commits into
lnfuzz:masterfrom
NishantBansal2003:channel-ready-oracle

Conversation

@NishantBansal2003

Copy link
Copy Markdown
Contributor

Depends-on: #212 and #259

Add ChannelReadyOracle and consolidate all previously scattered checks relevant to the channel_ready negotiation into it, including unknown channel_id, cases where the target omits the short_channel_id alias required by option_scid_alias, and cases where the target reuses a per-commitment point from an earlier negotiation.

Deferred oracle checks

  • short_channel_id alias collisions: BOLT 2 requires aliases not to collide with any of the target's real short_channel_ids. Checking this requires fetching the short_channel_id for all channels we have with the target over RPC. Bulk fetching adds RPC overhead that reduces fuzzing throughput, while lazy lookups can still miss collisions. Until this can be checked more efficiently, it is not worthwhile for this narrow surface.

Signed-off-by: Nishant Bansal <nishant.bansal.282003@gmail.com>
Signed-off-by: Nishant Bansal <nishant.bansal.282003@gmail.com>
Signed-off-by: Nishant Bansal <nishant.bansal.282003@gmail.com>
Signed-off-by: Nishant Bansal <nishant.bansal.282003@gmail.com>
Signed-off-by: Nishant Bansal <nishant.bansal.282003@gmail.com>
Signed-off-by: Nishant Bansal <nishant.bansal.282003@gmail.com>
Signed-off-by: Nishant Bansal <nishant.bansal.282003@gmail.com>
Signed-off-by: Nishant Bansal <nishant.bansal.282003@gmail.com>

@erickcestari erickcestari left a comment •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The last 2 commits LGTM!

Comment on lines +109 to +114
let key = pubkey(1);
let party = || ChannelPartyConfig {
funding_pubkey: key,
payment_basepoint: key,
revocation_basepoint: key,
delayed_payment_basepoint: key,

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.

Should these be distinct keys?

channel_ready: &ChannelReady,
channel: Option<&ChannelState>,
negotiated_features: &Features,
per_commitment_points: &HashSet<PublicKey>,

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.

Maybe we should consider adding this same parameter for the accept_channel oracle tests. It might make some of the tests a bit cleaner.

Comment on lines +28 to +35
/// # Deferred oracle checks
///
/// - `short_channel_id` alias collisions: BOLT 2 requires aliases not to collide
/// with any of the target's real `short_channel_ids`. Checking this requires
/// fetching the `short_channel_id` for all channels we have with the target
/// over RPC. Bulk fetching adds RPC overhead that reduces fuzzing throughput,
/// while lazy lookups can still miss collisions. Until this can be checked
/// more efficiently, it is not worthwhile for this narrow surface.

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.

Even without the lookups we could at least check that aliases aren't reused by keeping an in-memory set like we do for PCPs.

Comment on lines +49 to +52
if context
.negotiated_features
.supports_feature(Features::OPTION_SCID_ALIAS)
&& context.channel_ready.tlvs.short_channel_id.is_none()

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.

),
));
}

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.

Should we also check that minimum_depth was satisfied?

I know it's unlikely to even run this oracle if the depth isn't reached, since we turn RecvChannelReady into a no-op. But I think it's still possible if there's multiple negotiations in flight.

Also it will be easier to actually receive early channel_readys if we later implement the "implicit receive" logic from #111 (comment). Then we could be attempting to receive a different message and get an unexpected channel_ready instead, allowing us to run this oracle.

}

#[cfg(test)]
mod tests {

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.

Might be worth some executor tests as well like we have for the accept_channel oracle checks.

// earlier negotiation.
if context
.per_commitment_points
.contains(&context.channel_ready.second_per_commitment_point)

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.

The spec does explicitly allow sending multiple channel_ready messages with the same PCPs:

https://github.com/lightning/bolts/blob/152897261850d93c4f4597f39cf22d7d22d6ede6/02-peer-protocol.md?plain=1#L1091

I'm not sure if anyone implements that, but I think we should probably be more careful with this check. Probably we should allow reuse if the first use was for the same channel (i.e. channel.next_counterparty_per_commitment_point exists and matches), otherwise report a violation.

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.

3 participants