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

Add support for multihop payments #132

Merged
merged 11 commits into from
Oct 20, 2022
Merged

Add support for multihop payments #132

merged 11 commits into from
Oct 20, 2022

Conversation

lalexgap
Copy link
Contributor

@lalexgap lalexgap commented Oct 11, 2022

Adds support for "multihop" (multiple intermediaries) payments. There is a new parameternumOfIntermediaries that can be used to specify the number of intermediaries to use when creating a virtual channel.

Right now every participant has a ledger channel with every hub, meaning that the multihop payments are a bit superfluous (since participants could pay anyone in one hop). In the future we might want to look at making a more complicated ledger network which would require the multhop virtual channels.

A successful 60 second test run with 5 hops and 10 concurrency can be seen here

Caveats

@lalexgap lalexgap changed the title Add a MultiHop test case Add a Multihop test case Oct 11, 2022
selected[i] = shuffled[i]
}

// TODO: Virtual defunding seems to fail if intermediaries are not in "order".
Copy link
Contributor Author

Choose a reason for hiding this comment

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

To co-ordinate who initiates the ledger channel between two hubs I've introduced a simple rule: The participant with the lowest sequence number of the two hubs is responsible for creating the ledger channel.

It seems that the intermediaries need to passed in the correct order, based on the ledger initiator (I think?).
Since we use the sequence number to determine who initiates ledger channels we can just sort the intermediaries we pass in by their sequence number.

If I don't do this I get this error:

[0m panic: 0xA73B1683e0FCD74CEFF77aA5A90cAE1cF52d1c0F, error in run loop: signed proposal is not addressed to a known ledger connection {Signature:{R:[92 99 4 159 107 148 113 183 88 34 206 249 199 58 188 66 200 68 183 34 223 59 233 114 212 234 215 169 34 23 226 41] S:[123 131 214 254 250 117 65 42 222 212 113 236 31 15 36 251 243 88 198 162 117 13 215 51 6 198 227 98 105 176 200 126] V:28} Proposal:{LedgerID:0x1db0ab987f97ca8d2d21845016ebe74996102fb884b78c77efb88739a0b069c0 ToAdd:{Guarantee:{amount:<nil> target:[0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0] left:[0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0] right:[0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0]} LeftDeposit:<nil>} ToRemove:{Target:0x6d8536f70e580266089f52475b49a95d97bed033b94a516b02a16803242e24f2 LeftAmount:+9999995628}} TurnNum:4}

Copy link
Contributor

Choose a reason for hiding this comment

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

Let's get an issue open to track this.

@lalexgap lalexgap marked this pull request as ready for review October 11, 2022 22:37
@lalexgap lalexgap changed the title Add a Multihop test case Add support for multihop payments Oct 12, 2022
@lalexgap lalexgap force-pushed the multi-hop branch 3 times, most recently from 2cdd2b0 to f7cc2dc Compare October 13, 2022 18:31
@lalexgap lalexgap added the 🇵🇹 Lisbon Tasks and issues we should attempt to resolve before we go to Lisbon label Oct 13, 2022
@lalexgap lalexgap self-assigned this Oct 13, 2022
Copy link
Contributor

@geoknee geoknee left a comment

Choose a reason for hiding this comment

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

Thanks @lalexgap, it looks like this work is throwing up some important bugs in go-nitro that we should go and chase down.

I think we will want to think about network topologies and which scenarios we would like to investigate in particular.

// Close all the ledger channels with the hub
oIds := []protocols.ObjectiveId{}
for _, ledgerId := range ledgerIds {
runEnv.RecordMessage("Closing ledger %s", utils.Abbreviate(ledgerId))
Copy link
Contributor

Choose a reason for hiding this comment

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

Why drop this?

Copy link
Contributor Author

@lalexgap lalexgap Oct 20, 2022

Choose a reason for hiding this comment

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

I was cleaning up some debug log statements and got a little overzealous. I may leave this out though, as I found it a bit spammy.

Comment on lines +177 to +178
// We wait to allow hubs to finish processing messages and close out their channels.
// The duration we wait is based on the payment test duration and the amount of concurrent jobs.
Copy link
Contributor

Choose a reason for hiding this comment

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

Let's have an issue to track this? I agree with @NiloCK that the issues should live in go-nitro repo.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think we could use statechannels/go-nitro#883

selected[i] = shuffled[i]
}

// TODO: Virtual defunding seems to fail if intermediaries are not in "order".
Copy link
Contributor

Choose a reason for hiding this comment

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

Let's get an issue open to track this.

@lalexgap lalexgap deleted the multi-hop branch October 20, 2022 17:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🇵🇹 Lisbon Tasks and issues we should attempt to resolve before we go to Lisbon
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants