Skip to content

Light-152 multihop routing#37

Closed
BitfuryLightning wants to merge 2 commits into
lightningnetwork:masterfrom
BitfuryLightning:light_152_multihop_routing
Closed

Light-152 multihop routing#37
BitfuryLightning wants to merge 2 commits into
lightningnetwork:masterfrom
BitfuryLightning:light_152_multihop_routing

Conversation

@BitfuryLightning
Copy link
Copy Markdown
Contributor

A simple implementation of multihop payments.
Integration with routing and path validation.

Add multihop/payment initialisation and
integration with routing.
Path are validated by sending each node
message requesting if it is able to make
HTLC payment. It is implemented in parallel
style, not onion like.
Add comment to make multihop payment to a given address
which integrates routing, path validation and multihop
payment.
Copy link
Copy Markdown
Member

@Roasbeef Roasbeef left a comment

Choose a reason for hiding this comment

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

Thanks for another PR!

As details within the review, I think many parts of this PR can be omitted due to redundancy compared to the latest version of master. Let's discuss the other components such as the pre-send HTLC lock-up and the placement of the sender/receiver protocol within the LN stack.

Comment thread cmd/lncli/commands.go
printRespJson(channels)
}

var SendMultihopPayment = cli.Command{
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I don't think there should be distinct cli nor RPC commands for sending multi-hop payments vs single hop payments. At the time this PR was being put together the onion routing stuff wasn't in place, but it is now so the caller doesn't require any knowledge of the full route, only the final destination.

However, I can see how it might be useful to give the caller full control over the final path which the payment is execute over. So how about we merge this behavior into the existing SendPayment command with an additional argument which provides full "path selection".

Comment thread cmd/lncli/commands.go
if err != nil {
return err
}
if len(p) != 32 {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

With the latest version of master, when sending payments compressed public keys are used, so this should check for a length of 33 instead.

Comment thread cmd/lncli/commands.go

var FindPathCommand = cli.Command{
Name: "findpath",
Description: "finds path from node to some other node",
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think the description should be updated to be a bit more explicit. How about something along the lines of:

"attempts to find a path to the target destination node"

Comment thread cmd/lncli/commands.go
Flags: []cli.Flag{
cli.StringFlag{
Name: "destination",
Usage: "lightningID of destination",
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

In order to be in line with the latest version of master, a compressed public key should be expected instead.

Comment thread cmd/lncli/commands.go
Usage: "lightningID of destination",
},
cli.IntFlag{
Name: "maxpath",
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

To make the arg a bit more explicit, it should be extended a bit to be named maxpathlength.

Comment thread peer.go
// proper wire message. This helepr method is provided in order to aide an
// htlcManager in forwarding packets to the htlcSwitch.
func (p *peer) logEntryToHtlcPkt(pd *lnwallet.PaymentDescriptor) *htlcPacket {
func (p *peer) logEntryToHtlcPkt(pd *lnwallet.PaymentDescriptor, chanPoint *wire.OutPoint) *htlcPacket {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

These changes are unnecessary from the PoV of the latest version of master.

Comment thread rpcserver.go
}, nil
}

func (r *rpcServer) SendMultihopPayment(ctx context.Context, in *lnrpc.MultihopPaymentRequest) (* lnrpc.MultihopPaymentResponse, error){
Copy link
Copy Markdown
Member

@Roasbeef Roasbeef Sep 22, 2016

Choose a reason for hiding this comment

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

As detailed above, I don't think the addition of the RPC is necessary.

Comment thread rpcserver.go
int(in.NumberOfPaths),
1*time.Second,
)
rpcsLog.Info("[FindPath] after FindKSP dest=", hex.EncodeToString([]byte(in.TargetID)))
Copy link
Copy Markdown
Member

@Roasbeef Roasbeef Sep 22, 2016

Choose a reason for hiding this comment

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

Converting to a byte slice, then using EncodeToString seems like it'll lead to an erroneous string being produced. Why not just encode as hex directly? Or if it's already a hex string, then that can be printed as is.

Comment thread rpcserver.go
}
validationStatuses := make([]lnwire.AllowHTLCStatus, len(paths))
if in.Validate {
validationStatuses = r.server.routingMgr.ValidatePathMult(
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

What does ValidatePathMult do?

Comment thread server.go
} else {
srvrLog.Errorf("Can't find peer to send message %v", receiverID)
}
case msg := <- s.paymentManager.chPaymentOut:
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Similarly, I think this fragment can be removed all together from the PoV of the latest state in master.

@Roasbeef
Copy link
Copy Markdown
Member

Also this needs to be rebased on-top of the latest master branch as it diverges significantly.

@Roasbeef
Copy link
Copy Markdown
Member

Closing this PR now as #70 and the state of the current codebase supersedes it. I'll make some issues to salvage certain parts of this PR such as the path querying, since the code has already been written.

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

Successfully merging this pull request may close these issues.

2 participants