Skip to content
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

Add quiescence negotiation #2680

Merged
merged 25 commits into from
Jul 27, 2023
Merged

Add quiescence negotiation #2680

merged 25 commits into from
Jul 27, 2023

Commits on Jul 24, 2023

  1. Add quiescence protocol

    remyers committed Jul 24, 2023
    Configuration menu
    Copy the full SHA
    e7d08a7 View commit details
    Browse the repository at this point in the history
  2. Updated with suggested initial fixes

     - only use quiescence if both nodes signal the feature
     - reduce timeout to 1 min
     - use message type 2 for `stfu`
     - Use feature bits 34/35 for option_quiesce a per spec
    remyers committed Jul 24, 2023
    Configuration menu
    Copy the full SHA
    9fa2135 View commit details
    Browse the repository at this point in the history
  3. Clean up quiescence feature

    It's not a prototype, it matches the official (in-progress) specification.
    t-bast authored and remyers committed Jul 24, 2023
    Configuration menu
    Copy the full SHA
    98b3286 View commit details
    Browse the repository at this point in the history
  4. Clean up stfu message

    Use a boolean for the `initiator` field.
    t-bast authored and remyers committed Jul 24, 2023
    Configuration menu
    Copy the full SHA
    3e6e4e4 View commit details
    Browse the repository at this point in the history
  5. Rework forbidden splice messages

    Add more traits to the `SpliceStatus` hierarchy, which lets us simplify
    some of the pattern matching used in the `Channel` actor.
    
    Send a `warning` and disconnect if we receive a forbidden message while
    we're splicing, which lets us gracefully deal with buggy peers without
    losing channels.
    t-bast authored and remyers committed Jul 24, 2023
    Configuration menu
    Copy the full SHA
    491487c View commit details
    Browse the repository at this point in the history
  6. Include splicing in the quiescence timeout

    Being quiescent for too long is dangerous, because HTLCs may timeout
    without giving the opportunity to our peer to send us a preimage.
    
    Splicing operations shouldn't take long to complete, so we include that
    in the quiescence timeout, and disconnect if the splice wasn't completed
    in time. This makes sure we replay pending commands and avoid getting
    the channel stuck if the interactive-tx isn't making progress.
    t-bast authored and remyers committed Jul 24, 2023
    Configuration menu
    Copy the full SHA
    26ad317 View commit details
    Browse the repository at this point in the history
  7. Ignore duplicate stfu

    The spec says we must not send duplicate `stfu`, but doesn't have any
    requirement on the receiver. If we receive a duplicate `stfu`, it's
    perfectly fine to just ignore it: the protocol will either correctly
    complete or will be canceled by the quiescence timeout.
    t-bast authored and remyers committed Jul 24, 2023
    Configuration menu
    Copy the full SHA
    8b233f7 View commit details
    Browse the repository at this point in the history
  8. Remove handleSendRevocation

    This function was called in only one place, so it's not avoiding code
    duplication. It could make sense to isolate the logic, but in the case
    of event handlers in the highly critical channel FSM, we usually like to
    inline transition and state changes to make it easier to review the code
    linearly (no need to jump back and forth between function calls).
    
    I also renamed `isIdle` to `isQuiescent` to remove confusion.
    t-bast authored and remyers committed Jul 24, 2023
    Configuration menu
    Copy the full SHA
    b8cec0f View commit details
    Browse the repository at this point in the history
  9. Refactor handleNewSplice and a few nits

    In channel event handlers, we try to leave all the logic that updates the
    current state or data directly in the event handler instead of delegating
    it to helper functions, otherwise it's a bit hard to see all the state
    transitions that can happen when receiving a given message. I changed the
    `handleNewSplice` function to be a pure function instead that just creates
    the `splice_init` message (or returns an error).
    
    I also refactored some nits.
    t-bast authored and remyers committed Jul 24, 2023
    Configuration menu
    Copy the full SHA
    e7c16a9 View commit details
    Browse the repository at this point in the history
  10. Update handling of forbidden messages during a normal splice

     - now returns a warning (and disconnects) instead of force closing
    remyers committed Jul 24, 2023
    Configuration menu
    Copy the full SHA
    464569b View commit details
    Browse the repository at this point in the history
  11. Change so non-initiator is quiescent once they send stfu

     - initiator still remains in the negotiating state until they receive stfu from the non-initiator
     - also, simplify tests for forbidden messages
    remyers committed Jul 24, 2023
    Configuration menu
    Copy the full SHA
    ec26dab View commit details
    Browse the repository at this point in the history
  12. Remove redundant fail malformed htlc tests

     - fail htlc tests are sufficient
    remyers committed Jul 24, 2023
    Configuration menu
    Copy the full SHA
    a42f6cb View commit details
    Browse the repository at this point in the history
  13. Refactored isQuiescent

    remyers committed Jul 24, 2023
    Configuration menu
    Copy the full SHA
    fce95c6 View commit details
    Browse the repository at this point in the history
  14. Configuration menu
    Copy the full SHA
    1fc1c9c View commit details
    Browse the repository at this point in the history
  15. Configuration menu
    Copy the full SHA
    7b40fce View commit details
    Browse the repository at this point in the history
  16. Add tests suggested by t-bast

    remyers committed Jul 24, 2023
    Configuration menu
    Copy the full SHA
    d250f39 View commit details
    Browse the repository at this point in the history

Commits on Jul 26, 2023

  1. Configuration menu
    Copy the full SHA
    a31a96f View commit details
    Browse the repository at this point in the history
  2. Clean up comments

    t-bast authored and remyers committed Jul 26, 2023
    Configuration menu
    Copy the full SHA
    316f770 View commit details
    Browse the repository at this point in the history

Commits on Jul 27, 2023

  1. Group tests and remove unused functions

    This commit contains almost no functional changes, we just group together
    and reorder tests, remove unused code and remove the default value for
    `sendInitialStfu` (which makes tests matrixes easier to read).
    t-bast authored and remyers committed Jul 27, 2023
    Configuration menu
    Copy the full SHA
    be10434 View commit details
    Browse the repository at this point in the history
  2. Test quiescence requested state

    We were missing a test for the case where we request quiescence when we
    still have pending changes to apply.
    t-bast authored and remyers committed Jul 27, 2023
    Configuration menu
    Copy the full SHA
    5704162 View commit details
    Browse the repository at this point in the history
  3. Fix preimage forwarding test

    t-bast authored and remyers committed Jul 27, 2023
    Configuration menu
    Copy the full SHA
    38115be View commit details
    Browse the repository at this point in the history
  4. More concurrent quiescent tests

    t-bast authored and remyers committed Jul 27, 2023
    Configuration menu
    Copy the full SHA
    a5747be View commit details
    Browse the repository at this point in the history
  5. Improve force-close tests

    There are two scenarios to test:
    
    - one of our outgoing HTLC times out
    - one of our incoming HTLC is close to timing out and we have the preimage
    t-bast authored and remyers committed Jul 27, 2023
    Configuration menu
    Copy the full SHA
    1f6af5d View commit details
    Browse the repository at this point in the history
  6. Configuration menu
    Copy the full SHA
    f51710e View commit details
    Browse the repository at this point in the history
  7. Configuration menu
    Copy the full SHA
    7082c4a View commit details
    Browse the repository at this point in the history