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

Off-by-one when forcing feerates in the tests #3595

Open
cdecker opened this issue Mar 17, 2020 · 0 comments
Open

Off-by-one when forcing feerates in the tests #3595

cdecker opened this issue Mar 17, 2020 · 0 comments

Comments

@cdecker
Copy link
Member

cdecker commented Mar 17, 2020

Issue and Steps to Reproduce

@m-schmoock identified an issue with forcing feerates:

Also I think there might be an off by one in current (master) implementation, see https://github.com/ElementsProject/lightning/pull/3572/files/7d1f8416e1af8bf9579914db46da6ce5b5cb394a#diff-e6fd9e4a383e2ab7819a6292c1edf70bR2357 for my remark in the testcase.

The code this refers to is this:

def test_lockup_drain(node_factory, bitcoind):
    """Try to get channel into a state where funder can't afford fees on additional HTLC, so fundee can't add HTLC"""
    l1, l2 = node_factory.line_graph(2, opts={'may_reconnect': True})

    # l1 sends all the money to l2 until even 1 msat can't get through.
    total = l1.drain(l2)

    # Even if feerate now increases 1.5x (22500), l2 should be able to send
    # non-dust HTLC to l1.
    l1.force_feerates(22500)
    l2.pay(l1, total // 2)

    # reset fees and send all back again
    l1.force_feerates(15000)
    l1.drain(l2)

    # But if feerate increase just a little more, l2 should not be able to send
    # non-fust HTLC to l1
    l1.force_feerates(22502)  # TODO: Why does 22501 fail? off by one in C code?
    with pytest.raises(RpcError, match=r".*Capacity exceeded.*"):
        l2.pay(l1, total // 2)

My best guess is that there is a rounding due to the feerate smoothing.

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

No branches or pull requests

1 participant