Skip to content

Conversation

@carlaKC
Copy link
Owner

@carlaKC carlaKC commented May 2, 2025

No description provided.

@carlaKC carlaKC force-pushed the dev-jamming-endorsement-specification branch from d81c1f1 to 4eac67f Compare May 2, 2025 15:38
Comment on lines 180 to 181
We define the `opportunity_cost` of the time a HTLC takes to resolve:
`opportunity_cost`: `ceil ( (resolution_time - resolution_period) / resolution_period) - fees`
Copy link

@elnosh elnosh May 14, 2025

Choose a reason for hiding this comment

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

this should be * fees instead of - fees

Comment on lines 84 to 90
- Otherwise:
- The HTLC is dropped to protect its upstream resources from being
saturated by the downstream peer.
- If any forwarding node receives an `update_add_htlc` with `accountable` set,
but the outgoing channel does not have sufficient reputation:
- The HTLC is dropped to protect its upstream reputation from the downstream
peer.
Copy link

@elnosh elnosh May 14, 2025

Choose a reason for hiding this comment

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

I'm not quite clear what is the difference between these 2 points where they seem to be for the same. Which is to drop the HTLC if the outgoing channel does not have sufficient reputation.

Copy link
Owner Author

Choose a reason for hiding this comment

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

Indeed, I'll reorder this a bit to clean it up.

Comment on lines 324 to 329
- MUST NOT allocate more liquidity than their `capacity_msat` across buckets.

Recommended Defaults:
- General: 40% of `max_accepted_htlcs` and `capacity_msat`.
- Congestion: 20% of `max_accepted_htlcs` and `capacity_msat`.
- Protected: 40% of `max_accepted_htlcs` and `capacity_msat`.
Copy link

Choose a reason for hiding this comment

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

I think these should be max_htlc_value_in_flight_msat instead of capacity_msat?

- [Local Reputation](#local-reputation)
- [Recommendations for Reputation Scoring](#recommendations-for-reputation-scoring)
- [Effective HTLC Fees](#effective-htlc-fees)
- [Outgoing Channel Revenue](#outgoing-channel-revenue)
Copy link

Choose a reason for hiding this comment

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

*outgoing-channel-reputation

@carlaKC carlaKC force-pushed the dev-jamming-endorsement-specification branch 2 times, most recently from a158157 to 33f6af2 Compare May 27, 2025 14:44
HTLC forwards are assigned resources as follows:
- If `accountable` is set in the received `update_add_htlc`:
- If the outgoing peer has sufficient reputation:
- SHOULD forward the HTLC, assigning usage to the protected bucket.
Copy link
Owner Author

Choose a reason for hiding this comment

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

The protected bucket section says that you can use general/congested if requied.

Is it clear that you should try use protected and fall back if necessary?

Don't want it to be interpreted as:

  • Try protected bucket
  • End up using general
  • Still count towards protected bucket count

Copy link

Choose a reason for hiding this comment

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

I think it could also be interpreted as "fail the HTLC if protected is full" (without the fall back on other buckets).

If a HTLC is assigned a bucket that does not have sufficient resources, it
SHOULD be failed back with `temporary_channel_failure`.
In the Resource Bucketing section says If a HTLC is assigned a bucket that does not have sufficient resources, it SHOULD be failed back which could be contradicting this part.

Copy link
Owner Author

Choose a reason for hiding this comment

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

Hm yeah indeed, I'll think about a better way to describe this.

Comment on lines +383 to +406
reputation can operate as usual during periods of attack. If this bucket is
full, HTLCs that were eligible to use it may utilize any other available
resources in general or congestion buckets.
Copy link
Owner Author

Choose a reason for hiding this comment

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

One thing that's unfortunate about this approach is that previously we didn't need to track the protected bucket, we could just forward HTLCs if they were protected and rely on our channel tracking its own balance to allow payments through (or not).

Don't think there's much we can do about this, just noticed it on implementation.


Channel jamming is a known denial-of-service attack against the Lightning
Network. An attacker can disrupt regular usage of the network by spamming it
with doomed-to-fail payments, or simply delaying resolution of (their own or

Choose a reason for hiding this comment

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

"doomed-to-fail" is a bit strange, maybe with "payments they intend to fail"?

for the fast resolution of the HTLC. This signal is originally provided by
the recipient, and is propagated along the route.
- [Resource Bucketing](#resource-bucketing): restrictions on the HTLCs that
will be forwarded to outgoing nodes with insufficient reputation that may

Choose a reason for hiding this comment

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

nodes with good reputation will also have some restrictions in general and congestion

slow resolving payments (regardless of successful resolution).

We define the following parameters:
- `resolution_period`: the amount of time a HTLC is allowed to resolve in that

Choose a reason for hiding this comment

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

add "," to resolve in, that

`opportunity_cost = ceil ( (resolution_time - resolution_period) / resolution_period) * fees`
`
Given that `resolution_time` will be > 0 in practice, `opportunity_cost` is 0
for HTLCs that resolve within `resolution_period`, and charges the `fees` that

Choose a reason for hiding this comment

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

confusing choice of words "and charges the fees that
the HTLC would have earned per period it is held thereafter."


We define the `outgoing_channel_reputation`:
- for each `update_add_htlc` offered on the outgoing channel over
the rolling window [`now` - `revenue_window` - `reputation_multiplier`; `now`]:

Choose a reason for hiding this comment

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

revenue_window - reputation_multiplier -> revenue_window * reputation_multiplier

The outstanding risk of an `update_add_htlc` is defined as follows:
- `height_added`: the block height at which the HTLC was irrevocably committed
to by the local node.
- `maximum_hold_blocks` = `cltv_expiry` - `height_added`

Choose a reason for hiding this comment

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

maybe "+" and not "-"?

Copy link
Owner Author

Choose a reason for hiding this comment

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

This is correct - if the HTLC expires at height 150 and it's currently height 100, it can be held for 50 blocks max before we force close.

- `height_added`: the block height at which the HTLC was irrevocably committed
to by the local node.
- `maximum_hold_blocks` = `cltv_expiry` - `height_added`
- `outstanding_risk` = `fees * ( maximum_hold_blocks * 10 * 60) / resolution_period`

Choose a reason for hiding this comment

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

say that 10*60 is the 10 min. per block?

We define the `in_flight_htlc_risk` for an outgoing channel as:
- for each `update_add_htlc` offered to the outgoing channel:
- if `accountable` is present:
- if there is a corresponding incoming `update_add_htlc`

Choose a reason for hiding this comment

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

not sure what this means if there is update_add_htlc offered

Copy link
Owner Author

Choose a reason for hiding this comment

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

"offered" is spec-speak for when we send our peer a HTLC we want them to add

accrue on the channel, it is pairwise valuable to the local node. In flight
HTLCs have no impact on incoming channel revenue, as their fee contribution is
unknown.
##### Rationale

Choose a reason for hiding this comment

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

do we need to paragraphs with this title?

- The onion packet has `upgrade_accountability` set.
- The incoming `update_add_htlc` does not have `accountable` set.
- The `amount_msat` < `bucket_capacity_msat` / `bucket_slots`.

Choose a reason for hiding this comment

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

No #### Rationale for congestion

The recipient of a payment is ultimately responsible for the fast
resolution of a payment (though intermediate node can, of course,
slow it down).

We add a signal from the final recipient that the sender can use to
reason about the amount of time it should take to resolve.
Once we have a signal from the recipient, we need a way to propagate
this information throughout the route. Including a signal in the onion
provides an uncorruptable way for the sender to propagate this signal.
If the sender is dishonest, this will eventually be detected by the
final recipient.

In the commits that follow we'll add reputation and resource management
that will allow nodes to use this signal to protect against jamming
attacks.
@carlaKC carlaKC force-pushed the dev-jamming-endorsement-specification branch 2 times, most recently from 3440b32 to 34d469c Compare August 13, 2025 13:39
@carlaKC carlaKC force-pushed the dev-jamming-endorsement-specification branch from 34d469c to 4c35777 Compare August 13, 2025 14:06
@carlaKC carlaKC closed this Sep 15, 2025
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.

4 participants