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

Update for PR 6657: fix fundchannel infinite loop with tiny UTXOs #6669

Merged
merged 3 commits into from
Sep 13, 2023

Commits on Sep 13, 2023

  1. tests: test for fundchannel fail with tiny utxo

    Tony Giorgio <tonygiorgio@protonmail.com> says:
    
    Reproduce:
    
    1.  Add 1 600 sat UTXO to a fresh node
    
    2.  Verify the fundchannel command fails with a low fee rate:
    
    ```
    ./lightning-cli fundchannel 0366abc8eb4da61e31a8d2c4520d31cabdf58cc5250f855657397f3dd62493938a 100000 1000
    {
       "code": 301,
       "message": "Could not afford 100000sat using all 1 available UTXOs: 99522sat short"
    }
    ```
    
    3.  Now do the command again, but with a higher fee rate, making the 600 sat UTXO uneconomical:
    
    ```
    ./lightning-cli fundchannel 0366abc8eb4da61e31a8d2c4520d31cabdf58cc5250f855657397f3dd62493938a 100000 10000
    ```
    
    4. Observe the RPC call and the logs. The RPC call will never return, and the logs will stop after this:
    
    ```
    2023-04-16T10:58:45.839Z DEBUG   plugin-spenderp: mfc 34: multiconnect done.
    2023-04-16T10:58:45.839Z DEBUG   plugin-spenderp: mfc 34: 'parsefeerate' done
    2023-04-16T10:58:45.839Z DEBUG   plugin-spenderp: mfc 34: fundpsbt.
    ```
    
    5. Keep CLN running long enough and you'll eventually run OOM.
    rustyrussell committed Sep 13, 2023
    Configuration menu
    Copy the full SHA
    7818d78 View commit details
    Browse the repository at this point in the history
  2. wallet: Exclude uneconomical UTXOs from fundchannel

    If a node has an onchain balance with at least one uneconomical UTXO, the fundchannel RPC call will lock up the node and will eventually crash it with OOM issues if the economical UTXO(s) do not add up to the fundchannel amount. This is because the while loop never exits because it keeps pulling in the same uneconomical UTXOs forever.
    
    Changelog-Fixed: wallet: fundchannel no longer loops forever if the wallet contains insufficient funds, but an uneconomical UTXO.
    TonyGiorgio authored and rustyrussell committed Sep 13, 2023
    Configuration menu
    Copy the full SHA
    56d2f6c View commit details
    Browse the repository at this point in the history
  3. wallet: slightly neaten fundpsbt code.

    We can keep a single array of 'already considered' utxos, with the same
    result as Tony's patch prior.
    
    Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
    rustyrussell committed Sep 13, 2023
    Configuration menu
    Copy the full SHA
    abeeb23 View commit details
    Browse the repository at this point in the history