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

Do complete fee tracking. #3329

Merged
merged 8 commits into from
Dec 12, 2019
Merged

Commits on Dec 12, 2019

  1. common: add fee_states state machine for update_fee.

    This uses the same state machine as HTLCs, but they're only
    ever added, not removed.  Since we can only have one in each
    state, we use a simple array; mostly NULL.
    
    We could make this more space-efficient by folding everything into the
    first 5 states, but that would be more complex than just using the
    identical state machine.
    
    One subtlety: we don't send uncommitted fee_states over the wire.
    
    Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
    rustyrussell committed Dec 12, 2019
    Configuration menu
    Copy the full SHA
    5ad0477 View commit details
    Browse the repository at this point in the history
  2. channeld: cleanup: use the channel_feerate() accessor everywhere.

    And also move it to initial_channel, so we can use it there.
    
    This saves churn in the next patch.
    
    Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
    rustyrussell committed Dec 12, 2019
    Configuration menu
    Copy the full SHA
    809003a View commit details
    Browse the repository at this point in the history
  3. channeld: generate revoke_and_ack before telling lightningd about com…

    …mitment.
    
    The `channel_got_commitsig` we send the lightningd also implies we sent
    the revoke_and_ack, as an optimization.  It doesn't currently matter,
    since channel_sending_revoke_and_ack doesn't do anything important to the
    state, but that changes once we start uploading the entire fee_states.
    
    So now we move our state machine *before* sending to lightningd, in
    preparation for sending fee_states too.
    
    Unfortunately, we need to marshall the info to send before we
    increment the state, as lightningd expects that.
    
    Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
    rustyrussell committed Dec 12, 2019
    Configuration menu
    Copy the full SHA
    62670ef View commit details
    Browse the repository at this point in the history
  4. channeld: use fee_states internally.

    This is an intermediary step: we still don't save it to the database,
    but we do use the fee_states struct to track it internally.
    
    Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
    rustyrussell committed Dec 12, 2019
    Configuration menu
    Copy the full SHA
    321118a View commit details
    Browse the repository at this point in the history
  5. channeld: remove changes_pending flags.

    These used to be necessary as we could have feerate changes which
    we couldn't track: now we do, we don't need these flags.
    
    Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
    rustyrussell committed Dec 12, 2019
    Configuration menu
    Copy the full SHA
    0872bea View commit details
    Browse the repository at this point in the history
  6. wallet: add per-channel feerate_state to the database.

    The upgrade here is a bit tricky: we map the two values into the
    feerate_state.  This is trivial if they're both the same, but if
    they're different we don't know exactly what state they're in (this
    being the source of the bug!).
    
    So, we assume that the have received the update and not acked it,
    as that would be the normal case.
    
    Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
    rustyrussell committed Dec 12, 2019
    Configuration menu
    Copy the full SHA
    8cc1a43 View commit details
    Browse the repository at this point in the history
  7. lightningd: save the fee_states into the database.

    This is the final step: we pass the complete fee_states to and from
    channeld.
    
    Changelog-Fixed: "Bad commitment signature" closing channels when we sent back-to-back update_fee messages across multiple reconnects.
    Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
    rustyrussell committed Dec 12, 2019
    Configuration menu
    Copy the full SHA
    abdfd95 View commit details
    Browse the repository at this point in the history
  8. devtools: fix example at top of mkcommit.

    The norm for channels is a 1% reserve.
    
    Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
    rustyrussell committed Dec 12, 2019
    Configuration menu
    Copy the full SHA
    740bb27 View commit details
    Browse the repository at this point in the history