-
Notifications
You must be signed in to change notification settings - Fork 18
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
One to N payment system for PFS #38
Labels
Contracts 🛂
Requires Smart Contract changes
Comments
palango
added
Enhancement 🌟
New feature or request
Contracts 🛂
Requires Smart Contract changes
and removed
Enhancement 🌟
New feature or request
labels
Jan 22, 2019
This was referenced Jan 22, 2019
karlb
added a commit
to karlb/spec
that referenced
this issue
Jan 29, 2019
This is raiden-network/raiden-services#38 with only few changes. Spefic functions will be documented as the implemenation makes progress.
palango
pushed a commit
to raiden-network/spec
that referenced
this issue
Jan 29, 2019
This is raiden-network/raiden-services#38 with only few changes. Spefic functions will be documented as the implemenation makes progress.
The spec contains the latest information about the PFS payments. Please refer to https://raiden-network-specification.readthedocs.io/en/latest/service_contracts.html#oneton instead of this ticket. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Overview
After discussing different options to pay the PFS, the currently favored approach has the following properties
The concept is based on the idea to use a user's single deposit in the UDC as a security deposit for off-chain payments to all PFSs.
The client sends an IOU consisting of (sender, receiver, amount, expiration, signature) to the PFS with every path finding request. The PFS verifies the IOU and checks that
amount >= prev_amount + pfs_fee
. At any time, the PFS can claim the payment by submitting the IOU on-chain. Afterwards, no further IOU with the same (sender, receiver, expiration) can be claimed.Related:
Requirements
Communication between client and PFS
When requesting a route, the IOU is added as five separate arguments to the existing HTTP query params (https://raiden-network-specification.readthedocs.io/en/latest/pathfinding_service.html#arguments):
The PFS then thoroughly checks the IOU:
amount >= prev_amount + pfs_fee
)expiration_block
far enough in the future to potentially accumulate a reasonable amount of fees and claim the paymentamount
If one of the conditions is not met, a corresponding error message is returned and the client can try to submit a request with a proper IOU or try a different PFS. Otherwise, the PFS returns the requested routes as described in the current spec and saves the latest IOU for this (sender, expiration_block).
Claiming the IOU
A OneToN contract (OTNC) which is trusted by the UDC accepts IOUs (see table above for parameters) and uses the UDC to transfer
amount
fromsender
toreceiver
. The OTNC stores a mappinghash(receiver, sender, expiration_block) => expiration_block
to make sure that each IOU can only be claimed once.To make claims more gas efficient, multiple claims can be done in a single transaction and expired claims can be removed from the storage.
Expiration
Having the field
expiration_block
as part of the IOU serves multiple purposes:sender
andreceiver
fields it identifies a single payment session. Under this identifier, multiple payments are aggregated by continuously increasing theamount
and only a single on-chain transaction is needed to claim the total payment sum. After claiming, the identifier is stored on-chain and used to prevent the receiver from claiming the same payments, again.current_block > expiration_block
), the sender can be sure that he won't have to pay this IOU. So after waiting for expiry, the sender knows that IOUs which have been lost for some reason (e.g. disk failure) won't be redeemed and does not have to prepare for unpredictable claims of very old IOUs.hash(receiver, sender, expiration_block) => expiration_block
mapping which is used to prevent double claims after expiry. This frees blockchain storage and thereby reduces gas costs.Double Spending
Since the same deposit is used for payments to multiple parties, it is possible that the deposit is drained before each party has been paid. This is an accepted trade-off, because the amounts are small and low gas costs are more important, as long as the actual double spending does not reach a high level. To somewhat reduce the risks of double spends, the following precautions are taken:
amount
to give it some safety margin when other parties claim tokensA user and a PFS can theoretically collude to quickly withdraw the complete deposit (via a claim) before other services are paid. This should be unlikely due to the following aspects:
Specification State
First draft, awaiting comments. I plan to move this into the Raiden spec as soon as the discussion dies down and the comments are worked in.
The text was updated successfully, but these errors were encountered: