interledger-deprecated / ilp-kit

Everything needed to create a ledger and connect it to the Interledger
https://interledgerjs.github.io/ilp-kit/apidoc/
74 stars 39 forks source link

Question about settlement in ILP kit #491

Open phongtt3 opened 6 years ago

phongtt3 commented 6 years ago

Can you please explain the concept, why and when we need a settlement method between peer?

I already setup my own 3 instances of ILP kit:

A peer to B B peer to C

When i make payment from A to C, the 2 values in B's peer screen is changed, that described IOUs between B-A and B-C are changes?

Which Sequence Diagram are implemented on ILP-KIT, Atomic Mode Sequence Diagram or Universal Mode Sequence Diagram. it's so hard to understand, my started point is from https://interledger.org/interledger.pdf and i thought i can simulate one of two sequence diagram above when i play with ILP-KIT. Thank you kindly read through my question and pls don't scold me if i have any misunderstandings

michielbdejong commented 6 years ago

Hi Tran, thanks for your interest in our work, and welcome to the project! :)

It's Universal Mode minus the Proposal phase (so just prepare and execute). That pdf file is quite old, we're working on a new whitepaper that explains only the way Interledger currently works.

The settlement method is when you use a non-Interledger payment to change the balance of the account ("IOU") between A and B or between B and C, when the balance gets too far from the middle.

In ILPv4 (version 4 of the Interledger protocol), these settlements play a big role, and some peers will even settle automatically after each Interledger payment (probably using a payment channel in that case). ilp-kit has not been updated yet to operate in that way, though, so it still has a "settle" button which the ilp-kit's owner has to click! :)

Another way for the balance to go back to zero is when multiple Interledger payments cancel each other out (netting).

Hope this helps, and let us know if you have any further questions! :)

phongtt3 commented 6 years ago

Thank for your answer, but how can I manually add connector in ILP kit and still make routing/quoting happened? (without add peers)

Example: ILP kit A: add connector (plugin-bells account) for A, and B1 ILP kit B: add connector for A1, B, C1 ILP kit C: add connector for B1, C

I already added some account with idea above, the payment between A<->B and B<->C is good, but can't make payment between A<->C.

Pls help because settlement method is non-interledger payment, I really want to see the Universal Mode. My expected when make payment from A to C as picture bellow:

untitled diagram

phongtt3 commented 6 years ago

So, after payment from A to C completed, we don't need to settlement anything because real money is moved.

michielbdejong commented 6 years ago

Sure, "real" money is moved within each ilp-kit and between each pair of ilp-kits. But there is always a maximum to how much money can move to the right before some money has to move to the left again, right? You can't move money in one direction indefinitely. Think of it as lakes of water, connected by rivers. Water can flow through the rivers, but it cannot flow indefinitely, because the source lake will dry up. Then you need "rain" (settlement) again to fill up the source lake.

phongtt3 commented 6 years ago

thank, i do understand the concept, but for example, i have enough money for connector, how i can add connector to env.list file, pls tell me the way to add connector (real account) to each ilp kit and make the routing and quoting happened. Curently i meet "no quote found" error when i try to pay from A to C

hungnk01498 commented 6 years ago

Hello @michielbdejong , I just build 3 ILP-KIT same as above: KIT1 - KIT2- KIT3. KIT1 peer with KIT2 KIT2 peer with KIT3

My CONNECTOR_LEDGERS setting: KIT1 CONNECTOR_LEDGERS={"us.usd.ilp-kit-1.":{"currency":"USD","plugin":"ilp-plugin-bells","options":{"account":"https://ilp-kit-1.com/ledger/accounts/connector","username":"connector","password":"1EmlyUgtizIhfflgQmiP87ti1"}}}

KIT2 CONNECTOR_LEDGERS={"jp.jpy.ilp-kit-2.":{"currency":"JPY","plugin":"ilp-plugin-bells","options":{"account":"https://ilp-kit-2.com/ledger/accounts/connector","username":"connector","password":"1EmlyUgtizIhfflgQmiP87ti1"}}}

KIT3 CONNECTOR_LEDGERS={"ripple.xrp.ilp-kit-3.":{"currency":"XRP","plugin":"ilp-plugin-bells","options":{"account":"https://ilp-kit-3.com/ledger/accounts/connector","username":"connector","password":"1EmlyUgtizIhfflgQmiP87ti1"}}} then, I tried to send money from user1 in KIT1 to user2 in KIT3 with route KIT1 => KIT2 => KIT3 and output was like that: In KIT1's db had a transfer records: user1 send money to KIT1 connector account In KIT3's db had a transfer records: KIT3 connector account send money to user2

and in KIT2's db had nothing. No transfer records.

I read white paper, in the Universal Mode, when you send money with route more than 2 ledger like that, in every ledger must perform prepare and execute, right? So, I thought that in KIT2's db should have a transfer records like connector1 send money to connector2... but had nothing. Maybe, my connector setting is failed. May you show me how to set the connector to make it work or some doc can guide me to set ?

Thank you very much.

16

michielbdejong commented 6 years ago

I think the database only logs transfers that go via the five-bells-ledger component of ilp-kit, and for your KIT2 the money comes in and goes out over peer relationships, so it doesn't touch that ilp-kit's five-bells-ledger.

phongtt3 commented 6 years ago

So, can I configure money always come via plugin-bell or ilp-plugin-mini-accounts instead of peer relationships? And still using ilp-kit.

sharafian commented 6 years ago

What is it you're aiming to do?

If you're mainly trying to get familiar with the ILP stack, we'd recommend you use ILP Connector instead of ILP Kit, because it's more up-to-date and doesn't have as many bugs.

Currently, ILP Kit is deprecated and we aren't planning to directly update it to ILPv4 (the architecture doesn't make as much sense with the new ILP stack).

If you want to do this on ILP Kit anyways, It's possible to configure the ILP Kit to peer over five bells ledgers instead of the UI-based peering flow. You would just add something like the snippet below to the kit 1 connector's CONNECTOR_LEDGERS:

"us.usd.ilp-kit-2.": {
  "currency": "USD",
  "plugin": "ilp-plugin-bells",
  "options": {
    "account": "https://ilp-kit-2.com/ledger/accounts/kit1connector","username":"kit1connector","password":"password"}}
  }
}

Basically you're adding an account on kit 2. You would have to register an account for the kit 1 connector on kit 2's ledger. You would do the same thing to add a kit 3 account to the kit 2 connector. You would also want to remove the peering relationships in the UI to ensure that these payments are routed over the ledgers.