Proposed design for channel jamming mitigation

未關閉
#4,384 2 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視

還沒有人認領這個 Issue。

評估

難度
5/5
預估耗時
一週以上
新手友好度
18/100
Issue 類型
功能
描述清晰度
需要釐清
活躍度
停滯
技術堆疊
rust
領域
backend, security

研究方向

This issue is a design RFC for BOLT jamming mitigation in LDK, not a scoped first patch. Read the proposed ResourceManager trait and how ChannelManager would call add_channel, add_htlc, and resolve_htlc; also note process_forward_htlcs and Channel pending/outbound HTLCs. Done means maintainers agree on locking, HTLC storage, and general-bucket hashing—or the design is rejected—not a merged implementation.

由索引模型根據 Issue 內容生成。

描述

Opening up this issue to seek design feedback on implementation of bolts/1280. We would like to implement the full mitigation in LDK and run it in “read only” mode:

  • Set the accountable signal on HTLCs
  • Log the action that the mitigation suggests (forward/fail)
  • Take no action on HTLC forwards, so traffic is unaffected

TL;DR
The mitigation can be implemented in a standalone module, and will implement the trait described below to receive information from ChannelManager. By default it will log its forwarding decisions and reputation scores, and we will surface a config option to disable the mitigation.

pub trait ResourceManager {
    fn add_channel(
        &self, channel_type: &ChannelTypeFeatures, channel_id: u64,
        max_htlc_value_in_flight_msat: u64, max_accepted_htlcs: u16,
    ) -> Result<(), ()>;

    fn remove_channel(&self, channel_id: u64) -> Result<(), ()>;

    fn add_htlc(
        &self, incoming_channel_id: u64, incoming_amount_msat: u64, incoming_cltv_expiry: u32,
        outgoing_channel_id: u64, outgoing_amount_msat: u64, incoming_accountable: bool,
        htlc_id: u64, height_added: u32, added_at: u64,
    ) -> Result<ForwardingOutcome, ()>;

    fn resolve_htlc(
        &self, incoming_channel_id: u64, htlc_id: u64, settled: bool, resolved_at: u64,
    ) -> Result<(), ()>;
}

Approaches that rely on events or interception were also considered, but ultimately decided against because it’s unlikely (and unadvisable) that people will want to “bring their own” DOS protection.

Implementation Considerations
There are a few design decisions that we’d like to highlight in this work - open to feedback here!

  1. Single lock on add/remove: our current approach has a single high level lock that will be acquired on htlc and channel add/remove(s). This seems acceptable because lightning is primarily IO bound, LDK currently has serial processing in process_forward_htlcs and the operations in the resource manager are lightweight relative to the crypto to process HTLCs. Happy to pursue a similar locking structure in the resource manager if there are bottleneck concerns!

  2. O(n) HTLC storage: our proposed design maintains its own view of the current set of in-flight HTLCs, relying on ChannelManager to report updates to our state. This information is available in Channel’s pending/outbound_htlcs, but only adds ~100 bytes per HTLC so is considered worthwhile for the sake of a well abstracted, modular implementation.

  3. O(n^2) general bucket memory usage and hashing: a portion of our channel’s liquidity and slots are assigned to a “general” bucket which is available regardless of a node’s reputation status. We mimic the behavior of addrman in core:

  • Each outgoing channel is assigned a set of slots/liquidity on the incoming channel that they are allowed to utilize in the general bucket of resources.
  • These slots are decided by salting and hashing the incoming/outgoing channel pair.

Our design performs this assignment just in time, computing slots for an incoming–outgoing pair only when an HTLC is forwarded. The hashing involved is negligible compared to the cost an adversary would incur to exploit it, which would require onion construction and committing funds to send a payment.

主要語言
Rust
星號
1.4k
分支
482
PR 合併指標
30 天內沒有已合併 PR

環境準備

  • 沒有 Dockerfile 或 Docker Compose 檔案
  • 沒有 Pull Request 範本
  • 閱讀貢獻指南

從這裡開始

  1. 先讀完整個 Issue,再讀專案的貢獻指南。
  2. 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
  3. Fork 儲存庫,在一個分支上完成修改。
  4. 送出 Pull Request,並在描述裡引用這個 Issue 編號。

lightningdevkit/rust-lightning 的其他 Issue

查看 lightningdevkit/rust-lightning 的全部 Issue

相似的 Issue

更多 Rust Issue

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。