Skip to content

Absolute Time Lock Limit#1941

Closed
johng wants to merge 9 commits into
lightningnetwork:masterfrom
johng:jg-absolute-time-lock-limit
Closed

Absolute Time Lock Limit#1941
johng wants to merge 9 commits into
lightningnetwork:masterfrom
johng:jg-absolute-time-lock-limit

Conversation

@johng
Copy link
Copy Markdown
Contributor

@johng johng commented Sep 19, 2018

As per #1513 I've added a field to queryroutes and sendpayment which limits the maximum total time funds can be locked in htlcs along a given route.

The main changes involve replacing the maximum fee parameter with a struct which contains both restrictions.

@Roasbeef Roasbeef added enhancement Improvements to existing features / behaviour rpc Related to the RPC interface routing payments Related to invoices/payments P3 might get fixed, nice to have needs review PR needs review by regular contributors labels Sep 21, 2018
@Roasbeef Roasbeef requested a review from joostjager October 17, 2018 03:15
Copy link
Copy Markdown
Contributor

@joostjager joostjager left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Useful functionality to have and implemented the right way (inside findPath). I've left comments in the code.

General remarks:

  • For messages, see the contributor guidelines. We prefix the messages with the subsystem (see history of master branch).

  • Commits should be organized in either independent sets of changes or logic sets that build on top of eachother, ideally each one successfully compiling/running. For this PR, you could think of a commit structure and order like this (not to be taken literally as commit messages):

    • change final_cltv_delta default
    • naming test cases
    • move InsufficentCapacity Test into table driven test
    • QueryRoutes improvements to help texts
    • create PathRestrictions struct (with just fee limit)
    • add max_cltv_delay field for sendpayment and queryroutes
    • disqualify routes violating the max cltv in newRoute
    • take max cltv into account during path finding
      (add unit test changes/additions to the commit to which they apply)

Comment thread lnrpc/rpc.proto Outdated
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changing ids in protos in not a good idea. People may have applications built against a previous version.

Comment thread lnrpc/rpc.proto Outdated
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same comment on ids

Comment thread routing/pathfind_test.go Outdated
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment incorrect

Comment thread cmd/lncli/commands.go Outdated
Comment thread routing/errors.go Outdated
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Check sentence, maximum time lock for a route.

Comment thread routing/pathfind_test.go Outdated
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it dangerous / do we cast somewhere to int?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't do any casting from uints to ints. If we do in the future that will cause issues if the limit is sufficiently large but should be picked up by the test cases

Comment thread routing/pathfind_test.go Outdated
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this test case is still valuable. It covers a specific detail on fees.

Comment thread routing/pathfind_test.go Outdated
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If think the default expectedFailure (if not specified in the testcase) is ErrNoPathFound. So what happens here is that if an unexpected error occurs and it happens to be ErrNoPathFound, the test will pass?

Comment thread routing/pathfind_test.go Outdated
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Check name

Comment thread cmd/lncli/commands.go Outdated
@joostjager
Copy link
Copy Markdown
Contributor

I haven't looked at the code changes themselves yet, but the commit structure is not yet what it should be. You should use git rebase to get it right. Commits that fix problems that were introduced in earlier commits that are also part of this PR should be squashed together.

The end result should be a set of commits that build on top of each other and it should look like it was done first time right.

@joostjager
Copy link
Copy Markdown
Contributor

The branch needs to be rebased onto master as well to fix conflicts.

@johng
Copy link
Copy Markdown
Contributor Author

johng commented Oct 29, 2018 via email

@joostjager
Copy link
Copy Markdown
Contributor

Breaking it up logically makes reviewing quicker, because it is easier to assess unrelated changes separately. Reviewing before clean up means that a second review (albeit shorted) is needed after clean up.

Also, when people look at a particular change in the future (after merge), they are directed to a logical commit of which that change was part. This helps to understand the intention of the change.

In this PR, there are so many commits, that is probably easier to start with all changes in the working directory and then stage and commit bit by bit (see structure that I suggested earlier). So rebuild the commit structure from scratch rather than trying to transform the current commits into the intended structure.

@johng johng force-pushed the jg-absolute-time-lock-limit branch from bedae19 to 5b9e74c Compare October 30, 2018 20:23
@johng johng force-pushed the jg-absolute-time-lock-limit branch 3 times, most recently from 5fb07e3 to 4dd60a6 Compare November 4, 2018 13:57
@joostjager
Copy link
Copy Markdown
Contributor

There are some commits from others in the diff now that don't belong in this PR.

Also, not all of the changes that you first had are in?

W/r to commit structure, the idea is to group the changes functionally. Like in the example breakdown I gave above. So "giving test cases a name" is a commit that can exist in isolation. Also it is preferred to have commits building successfully.

@johng johng force-pushed the jg-absolute-time-lock-limit branch from 4dd60a6 to 613dc86 Compare November 5, 2018 22:11
@johng johng force-pushed the jg-absolute-time-lock-limit branch from 613dc86 to 74df400 Compare November 5, 2018 22:25
Copy link
Copy Markdown
Contributor

@halseth halseth left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe this PR solves what it set out to to, namely making it possible to specify a max cltv in order to avoid funds getting locked up for a long time.

However, this is not the optimal solution, as there might still be cases where a path does exist to the target with a satisfactory CLTV limit, but since it is not the cheapest one, it won't be found. To support this would be a non-trivial change to the shortest path algorithm though, so it is out of scope for this PR.

Comment thread routing/heap.go Outdated
Comment thread routing/pathfind.go Outdated
Comment thread routing/pathfind.go
Comment thread routing/pathfind.go Outdated
Comment thread routing/pathfind.go Outdated
Comment thread routing/pathfind_test.go Outdated
Comment thread routing/pathfind_test.go Outdated
Comment thread routing/pathfind_test.go Outdated
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is a bit hard to see what are the actual test additions here. Ideally the commits would be structured like

  1. Modify the test data, any necessary refactoring and existing tests to work with this data.
  2. Add the new tests.

Comment thread routing/pathfind_test.go Outdated
Comment thread cmd/lncli/commands.go Outdated
@johng johng force-pushed the jg-absolute-time-lock-limit branch 3 times, most recently from 8d46f6d to e0bcb88 Compare November 13, 2018 20:24
@joostjager
Copy link
Copy Markdown
Contributor

No recent activity on this PR. I reworked the changes on top of the current master branch, but unfortunately not much of the code remained.

#2640

@wpaulino
Copy link
Copy Markdown
Contributor

Thanks for getting this started @johng! Superseded by #2640.

@wpaulino wpaulino closed this Feb 14, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement Improvements to existing features / behaviour needs review PR needs review by regular contributors P3 might get fixed, nice to have payments Related to invoices/payments routing rpc Related to the RPC interface

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants