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 option to settle payments in SyncSimulatedPaymentSession #16

Open
renepickhardt opened this issue May 12, 2022 · 2 comments
Open

Add option to settle payments in SyncSimulatedPaymentSession #16

renepickhardt opened this issue May 12, 2022 · 2 comments
Assignees
Labels

Comments

@renepickhardt
Copy link
Owner

As realized through discussions with @sebulino in #15 the current lib does only decide if a payment can be delivered or not. In many cases it would be preferable that the liquidity is actually being moved in the OracleChannel and our belief about the uncertainty is updated in both arcs of the UncertaintyChannel where we would also have to set the inflight back to 0.

@sebulino
Copy link
Contributor

sebulino commented May 13, 2022

This is my understanding of what is happening when pickhardt_pay is called on SyncSimulatedPaymentSession:

  • pickhardt_pay is called on the SyncSimulatedPaymentSession
  • a set of payments is created with fee, prob, path and amount
  • payments are then passed to _attempt_payments in same Class
  • _attempt_payments checks/calls send_onion on OracleLightningNetwork.
  • send_onion in OracleLightningNetwork
    • sets keys to
      • either bool success to True and Erring Channel as None
      • or bool success to False and Erring Channel with the respective failing channel
      • (success of the probe is defined by can_foward in OracleChannel Class)
    • calls update_knowledge on UncertaintyChannel which sets new liquidity need, by increasing either minimum or maximum liquidity (subject to condition)

So far no update on OracleChannels in OracleLightningNetwork. This is what would make sense to be added.

@renepickhardt
Copy link
Owner Author

This is a very accurate summary of what is happening! Note that _attempt_payments is having this line:

self._uncertainty_network.allocate_amount_on_path(

This is where we update our belief on the uncertainty network. IF you were to also update the Oracle here all future statistics would be skewed.

Therefor I guess it would be best from the point of view of the simulation to update the OracleChannels after all rounds have been completed. There may be two paths to success:

  1. after the payment loop is completed go through all channels that have inflight and move it to the other side while removing it
  2. if introduce loglevels and make prints in SyncSimulatedPayment Session optional #17 has landed and all the payment paths and statistics of a payment session are in a single data structure one could just go throught that (though it would have to include staistics of all rounds - right now we have stats just for a single round)

It's quite remarkable how involved such a little change would be and how much refactorig would probably be necessary. From the point of view that a siulation may wish to do concurrent tests it is probably better and cleaner to persue the 2nd option. That being said if you have better / other ideas I will be open

sebulino added a commit to sebulino/pickhardtpayments that referenced this issue May 13, 2022
first stub of a method as described in  renepickhardt#16
Still needs to be tested
sebulino added a commit to sebulino/pickhardtpayments that referenced this issue May 30, 2022
first stub of a method as described in  renepickhardt#16
Still needs to be tested
sebulino added a commit to sebulino/pickhardtpayments that referenced this issue Jun 1, 2022
first stub of a method as described in  renepickhardt#16
Still needs to be tested
sebulino added a commit to sebulino/pickhardtpayments that referenced this issue Jun 3, 2022
first stub of a method as described in  renepickhardt#16
Still needs to be tested
sebulino added a commit to sebulino/pickhardtpayments that referenced this issue Jun 3, 2022
first stub of a method as described in  renepickhardt#16
Still needs to be tested
sebulino added a commit to sebulino/pickhardtpayments that referenced this issue Jun 22, 2022
first stub of a method as described in  renepickhardt#16
Still needs to be tested
renepickhardt added a commit that referenced this issue Jun 22, 2022
* add .gitignore

* introduce register payment method on OracleLightningNetwork.py

* adding settlement_payment in OracleLightningNetwork

first stub of a method as described in  #16
Still needs to be tested

* rewriting setter for `actual_liquidity` using properties (python way)

* adjust channels in both directions when payment is made

* Settlement of onions with partial payments only after all onions were routed successfully

* deletion of unused import

* shell for a Payment Class

* Revert "shell for a Payment Class"

This reverts commit 8dffa28.

* shell for a Payment Class for issue #20

* shell for as Attempt Class for issue #20

* Indroduction of Payment and Attempt class, refactoring.

* Introduction of PaymentClass and AttemptClass, refactoring.

* error fixing, semantic changes and refinement of Payment ant Attempt class

* adding types in methods for Attempt and Payment Class and amending relative paths on imports

* initializes fee and probability w/ none (instead of -1) #20

* adjustment of relative paths for modules in import

* extending .gitignore

* correcting tipo for gitignore

* init for documentation

* configuration updated

* correction in filter function for Attempt.Status #24

* changing imports back to initial call

* fixing issues from partial review
#24 (review)

* deleting docs folder and moving _estimate_payment_statistics into attempt class

* deleting docs folder and moving _estimate_payment_statistics into attempt class

* removed doc folder

* adding CHANGELOG

* Cleaning up after Attempt and Payment PR review

* changed filter function in payment to generator

* added setter to OracleChannel and fixed imports in init.py

* Fix typos in documentation

* rewriting setter for `actual_liquidity` using properties (python way)

* Indroduction of Payment and Attempt class, refactoring.

* Introduction of PaymentClass and AttemptClass, refactoring.

* adjustment of relative paths for modules in import

* changing imports back to initial call

* another rebasing hassle ;)

Co-authored-by: Sebastian <[email protected]>
Co-authored-by: Rene Pickhardt <[email protected]>
Co-authored-by: nassersaazi <[email protected]>
sebulino added a commit to sebulino/pickhardtpayments that referenced this issue Jun 24, 2022
first stub of a method as described in  renepickhardt#16
Still needs to be tested
renepickhardt pushed a commit that referenced this issue Apr 12, 2023
* introduce register payment method on OracleLightningNetwork.py

* adding settlement_payment in OracleLightningNetwork

first stub of a method as described in  #16
Still needs to be tested

* rewriting setter for `actual_liquidity` using properties (python way)

* adjust channels in both directions when payment is made

* Settlement of onions with partial payments only after all onions were routed successfully

* deletion of unused import

* updating to rene/main

* introducing logging
#17

* refactoring min cost flow solver in Payment Class

* updating the PaymentSession so that the calls to the Payment method are clear.
Balances are still wrong, but pushing this, so that @Lagrang3 can have a look at the PaymenSession structure

* first code cleanup in PaymentSession

* Settlement and Payment completely implemented.
- In UncertaintyNetwork in_flights, minimum and maximum liquidity are adjusted accordingly after result of send_onion.
- In OracleNetwork in_flights are adjusted after changing attempt status to INFLIGHT and SETTLED.
this is a very verbose version, lots of logging everywhere :) ideal for testing and checking if amounts are adjusted correctly in the respective situations

* Verbosity removed.
Verbosity removed, because a lot of the logging of nodes were tied to the specific ChannelGraph.
Checks added, for
- when the OracleNetwork is updated and reverse channels might not be public
- when the UncertaintyNetwork is updated and reverse channels might not exist

* settlement implemented

* adding info on return channel when updating knowledge in UncertaintyNetwork

* settle_payment changed to settle_attempt
the payment iterates over the attempts and for each attempt calls the method (on oracle and uncertainty network). Thus, naming is now correct.

* example fails. logging of channel characteristics added.
currently the example in this commit fails. This might be because the in_flights are not handled correctly and min_liquidity (of max_liquidity?) might be adjusted incorrectly.
to monitor this, I added some logging verbosity for the main sections in the process.

* good example to check the learning of the UncertaintyNetwork
This is an example for the current implementation of learning from successful and unsuccessful onions. for better visualisation it's run on the smaller graph `channels.sample.json` with four nodes. The logfile is very verbose and demonstrates the changes step by step.

* refactoring update_knowledge
now update_knowledge does not need a flag from send_onion and takes the result from the attempt status.

* adding a new example for the simulation
simulation_example.py uses the "small graph" and executes the pickhard payment twice - one successful payment and one failing. The logfile is rather verbose and the change of information in the uncertainty network can nicely be observed.

* Channel balances now randomized again

* catching error if MCF throws infeasible
Added Exception handling if MCF solver throws infeasible.
Also moved to counter for MCF computations, so that failed computations are included.

* adding loglevel to method call to manage verbosity

* corrected update_knowledge method
corrected update_knowledge method and added bits of comments and documentation

* debug message corrected and seed added
There was a call in a debug message that lead to a reference error.
In line with Eduardo's works I added the seed initialisation with the same seed.

* adding debug level in simulation example to pickhard_pay call

* initialization of randomness in OracleNetwork. logging adjusted.

* adding code improvements from master thesis

* adding method for consistency check in uncertainty network

* Raising ValueError if path Argument in Attempt() is not a List of Channels

* redundancy removed when logging errors in update_knowledge method

---------

Co-authored-by: Sebastian <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants