-
Notifications
You must be signed in to change notification settings - Fork 520
draft: Upfront Fees to Mitigate Channel Jamming #1052
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
a96f8f9
proposals: channel jamming mitigation
carlaKC 8109e87
features: add option upfront fee
carlaKC 973b8ca
bolt07: advertise upfront fee policies in channel_update
carlaKC 8ff01b2
bolt11: add upfront fee policy for final hop to invoice
carlaKC ff2394b
bolt2: add upfront_fee to update_add_htlc TLVs
carlaKC 57be678
bolt03: include upfront fees in to_local and to_remote balances
carlaKC c400cae
bolt04: add upfront fee to onion routing payload
carlaKC 6890e60
bolt04: add error for insufficient upfront fee for forwarding nodes
carlaKC dc31129
bolt04: add final incorrect upfront fee for last hop
carlaKC File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -201,6 +201,9 @@ This is formatted according to the Type-Length-Value format defined in [BOLT #1] | |
| 1. type: 16 (`payment_metadata`) | ||
| 2. data: | ||
| * [`...*byte`:`payment_metadata`] | ||
| 1. type: 2 (`upfront_fee_to_forward`) | ||
| 2. data: | ||
| * [`tu64`:`upfront_fee_to_forward`] | ||
|
|
||
| `short_channel_id` is the ID of the outgoing channel used to route the | ||
| message; the receiving peer should operate the other end of this channel. | ||
|
|
@@ -227,11 +230,16 @@ The requirements ensure consistency in responding to an unexpected | |
| `outgoing_cltv_value`, whether it is the final node or not, to avoid | ||
| leaking its position in the route. | ||
|
|
||
| `upfront_fee_to_forward` is the upfront fee value, in millisatoshis, that | ||
| should be pushed to the next receiving peer specified within the routing | ||
| information, or for the final destination. | ||
|
|
||
| ### Requirements | ||
|
|
||
| The writer: | ||
| - For every node: | ||
| - MUST include `amt_to_forward` and `outgoing_cltv_value`. | ||
| - MUST include `upfront_fee_to_forward` if every hop advertises `option_upfront_fee`, otherwise MUST NOT include `upfront_fee_to_forward`. | ||
| - For every non-final node: | ||
| - MUST include `short_channel_id` | ||
| - MUST NOT include `payment_data` | ||
|
|
@@ -247,19 +255,23 @@ The writer: | |
|
|
||
| The reader: | ||
| - MUST return an error if `amt_to_forward` or `outgoing_cltv_value` are not present. | ||
| - MUST return an error if `upfront_fee_msat` is present and `upfront_fee_to_forward` is not. | ||
| - MUST return an error if `upfront_fee_msat` is not present and `upfront_fee_to_forward` is. | ||
| - if it is not the final node: | ||
| - MUST return an error if: | ||
| - `short_channel_id` is not present, | ||
| - it cannot forward the HTLC to the peer indicated by the channel `short_channel_id`. | ||
| - incoming `amount_msat` - `fee` < `amt_to_forward` (where `fee` is the advertised fee as described in [BOLT #7](07-routing-gossip.md#htlc-fees)) | ||
| - `cltv_expiry` - `cltv_expiry_delta` < `outgoing_cltv_value` | ||
| - incoming `upfront_fee_msat` - `upfront_fee` < `upfront_fee_to_forward` (where `upfront_fee` is the advertised fee as described in [BOLT #7](07-routing-gossip.md#upfront-fees)) | ||
This comment was marked as abuse.
Sorry, something went wrong. |
||
| - if it is the final node: | ||
| - MUST treat `total_msat` as if it were equal to `amt_to_forward` if it | ||
| is not present. | ||
| - MUST return an error if: | ||
| - incoming `amount_msat` < `amt_to_forward`. | ||
| - incoming `cltv_expiry` < `outgoing_cltv_value`. | ||
| - incoming `cltv_expiry` < `current_block_height` + `min_final_cltv_expiry_delta`. | ||
| - incoming `upfront_fee_msat` < `upfront_fee_to_forward` | ||
|
|
||
| Additional requirements are specified [below](#basic-multi-part-payments). | ||
|
|
||
|
|
@@ -273,7 +285,9 @@ Note that `amt_to_forward` is the amount for this HTLC only: a | |
| `total_msat` field containing a greater value is a promise by the | ||
| ultimate sender that the rest of the payment will follow in succeeding | ||
| HTLCs; we call these outstanding HTLCs which have the same preimage, | ||
| an "HTLC set". | ||
| an "HTLC set". The amount paid in `upfront_fee_to_forward` by every HTLC in | ||
| the set contributes to the `total_msat` paid by sender, as these amounts are | ||
| unconditionally pushed to the receiver. | ||
|
|
||
| `payment_metadata` is to be included in every payment part, so that | ||
| invalid payment details can be detected as early as possible. | ||
|
|
@@ -292,10 +306,12 @@ The writer: | |
| than or equal to twice `amount`. | ||
| - otherwise: | ||
| - MUST set `total_msat` to the amount it wishes to pay. | ||
| - MUST ensure that the total `amt_to_forward` of the HTLC set which arrives | ||
| at the payee is equal to or greater than `total_msat`. | ||
| - MUST NOT send another HTLC if the total `amt_to_forward` of the HTLC set | ||
| is already greater or equal to `total_msat`. | ||
| - MUST ensure that the total `amt_to_forward` + total | ||
| `upfront_fee_to_forward` of the HTLC set which arrives at the payee is | ||
| equal to or greater than `total_msat`. | ||
| - MUST NOT send another HTLC if the total `amt_to_forward` + total | ||
| `upfront_fee_to_forward` of the HTLC set is already greater or equal to | ||
| `total_msat`. | ||
| - MUST include `payment_secret`. | ||
| - otherwise: | ||
| - MUST set `total_msat` equal to `amt_to_forward`. | ||
|
|
@@ -309,11 +325,11 @@ The final node: | |
| - MUST add it to the HTLC set corresponding to that `payment_hash`. | ||
| - SHOULD fail the entire HTLC set if `total_msat` is not the same for | ||
| all HTLCs in the set. | ||
| - if the total `amt_to_forward` of this HTLC set is equal to or greater | ||
| than `total_msat`: | ||
| - if the total `amt_to_forward` + total `upfront_fee_to_forward` of this | ||
| HTLC set is equal to or greater than `total_msat`: | ||
| - SHOULD fulfill all HTLCs in the HTLC set | ||
| - otherwise, if the total `amt_to_forward` of this HTLC set is less than | ||
| `total_msat`: | ||
| - otherwise, if the total `amt_to_forward` + total `upfront_fee_to_forward` | ||
| of this HTLC set is less than `total_msat`: | ||
| - MUST NOT fulfill any HTLCs in the HTLC set | ||
| - MUST fail all HTLCs in the HTLC set after some reasonable timeout. | ||
| - SHOULD wait for at least 60 seconds after the initial HTLC. | ||
|
|
@@ -343,6 +359,10 @@ constrained in which paths they can take when retrying payments along specific | |
| paths. However, no individual HTLC may be for less than the difference between | ||
| the total paid and `total_msat`. | ||
|
|
||
| The total `upfront_fee_to_forward` paid to the final node (across failed and | ||
| successful HTLC attempts) is included in the HTLC set total because these | ||
| amounts have been unconditionally pushed to the receiver from the sender. | ||
|
|
||
| The restriction on sending an HTLC once the set is over the agreed total prevents the preimage being released before all | ||
| the partial payments have arrived: that would allow any intermediate | ||
| node to immediately claim any outstanding partial payments. | ||
|
|
@@ -1007,6 +1027,22 @@ the decrypted byte stream. | |
| The complete amount of the multi-part payment was not received within a | ||
| reasonable time. | ||
|
|
||
| 1. type: UPDATE|25 (`upfront_fee_insufficient`) | ||
| 2. data: | ||
| * [`u64`:`upfront_fee`] | ||
| * [`u16`:`len`] | ||
| * [`len*byte`:`channel_update`] | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We do have tlv failures now, so could make use of that. #1021 |
||
|
|
||
| The upfront fee amount was below that required by the outgoing channel from the | ||
| processing node. | ||
|
|
||
| 1. type: 27 (`final_incorrect_upfront_fee`) | ||
| 2. data: | ||
| * [`u64`:`upfront_fee`] | ||
|
|
||
| The final hop's upfront fee in the HTLC doesn't match the value in the onion, | ||
| or does not meet the receiving node's expected upfront fee. | ||
|
|
||
| ### Requirements | ||
|
|
||
| An _erring node_: | ||
|
|
@@ -1069,6 +1105,10 @@ A _forwarding node_ MAY, but a _final node_ MUST NOT: | |
| - if the channel is disabled: | ||
| - report the current channel setting for the outgoing channel. | ||
| - return a `channel_disabled` error. | ||
| - if the HTLC does NOT pay sufficient upfront fee: | ||
| - report the incoming upfront fee amounts and the current channel setting | ||
| for the outgoing chanel. | ||
| - return a `upfront_fee_insufficient` error. | ||
|
|
||
| An _intermediate hop_ MUST NOT, but the _final node_: | ||
| - if the payment hash has already been paid: | ||
|
|
@@ -1098,6 +1138,10 @@ An _intermediate hop_ MUST NOT, but the _final node_: | |
| - MUST return a `final_incorrect_htlc_amount` error. | ||
| - if it returns a `channel_update`: | ||
| - MUST set `short_channel_id` to the `short_channel_id` used by the incoming onion. | ||
| - if the `upfront_fee_msat` from the final node's HTLC is below `upfront_fee_to_forward`: | ||
| - MUST return `final_incorrect_upfront_fee` error. | ||
| - if the `upfront_fee_msat` does NOT pay sufficient fees: | ||
| - MUST return `final_incorrect_upfront_fee` error. | ||
|
|
||
| ### Rationale | ||
|
|
||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This comment was marked as abuse.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.