Open cameel opened 6 years ago
Blueprint updated:
finalize payments
renamed to finalize payment
Blueprint updated on changes done when implementing related issues: https://github.com/golemfactory/concent/issues/567#issuecomment-427200679 https://github.com/golemfactory/concent/issues/568#issuecomment-427686616 https://github.com/golemfactory/concent/issues/565#issuecomment-428177422
Stateless Bankster
Bankster is an intermediate layer between Concent Core and the Ethereum Client (Geth). All communication with the Ethereum Client is performed via Golem's Smart Contracts Interface (SCI) which is used as a library.
This specification describes a limited version of the mechanism that only takes into account deposit status listed on the blockchain. It's not aware of parallel claims made by Concent against the same deposit and may decide that funds are available while they'll actually be gone when the use case finishes. It's stateless - does not store existing claims in the database and check them when processing other claims.
A more complete version that tracks deposit claims is described in #479.
Operations
claim deposit
operationThe purpose of this operation is to check whether the clients participating in a use case have enough funds in their deposits to cover all the costs associated with the use case in the pessimistic scenario.
Concent core performs this operation at the beginning of any use case that may require payment from deposit within a single subtask. Currently those are
ForcedAcceptance
andAdditionalVerification
.ForcedPayment
use case operates on more than one subtask and for that reason requires a separate operation.The funds are checked in anticipation of a future payment but it does not necessarily mean that exactly that amount will be paid out or even that it will actually be paid. The actual amount paid will depend on the outcome of the use case.
Input
concent_use_case
ConcentUseCase
requestor_ethereum_address
provider_ethereum_public_key
. Comes fromTaskToCompute
.provider_ethereum_address
requestor_ethereum_public_key
. Comes fromTaskToCompute
.subtask_cost
TaskToCompute.price
multiplied by maximum task duration. Must be greater than zero.ConcentUseCase
enumForcedAcceptance
AdditionalVerification
ForcedPayment
Output
requestor_has_enough_deposit
True
if requestor currently has enough funds in his deposit to pay.provider_has_enough_deposit
True
if requestor currently has enough funds in his deposit to pay.Sequence of operation
ForcedAcceptance
use case:subtask_cost
.AdditionalVerification
use case:subtask_cost
.requestor_has_enough_deposit
isFalse
.requestor_has_enough_deposit
isTrue
.provider_has_enough_deposit
isFalse
.provider_has_enough_deposit
isTrue
.requestor_has_enough_deposit
andprovider_has_enough_deposit
.finalize payment
operationThis operation tells Bankster to pay out funds from deposit.
Concent Core performs this operation at the end of any use case that may require payment from deposit within a single subtask. Currently those are
ForcedAcceptance
andAdditionalVerification
.ForcedPayment
use case operates on more than one subtask and for that reason requires a separate operation.For each claim, Bankster uses SCI to submit an Ethereum transaction to the Ethereum client which then propagates it to the rest of the network. Hopefully the transaction is included in one of the upcoming blocks on the blockchain.
If there's not enough funds at the moment, the amount to pay is decreased. If there's nothing at all, the claim is discarded without payment.
Input
subtask_d
string
concent_use_case
ConcentUseCase
requestor_ethereum_address
provider_ethereum_public_key
. Comes fromTaskToCompute
.provider_ethereum_address
requestor_ethereum_public_key
. Comes fromTaskToCompute
.subtask_cost
TaskToCompute.price
multiplied by maximum task duration. Must be greater than zero.Output
requestors_claim_payment_info
ClaimPaymentInfo
providers_claim_payment_info
ClaimPaymentInfo
ClaimPaymentInfo
tx_hash
amount_paid
is zero.payment_ts
tx_hash
is empty.amount_paid
amount_pending
Sequence of operation
ForcedAcceptance
use case:subtask_cost
.AdditionalVerification
use case:subtask_cost
.claim_payment_info
is empty. This is valid only for provider, because for requestor in both cases claim is equal tosubtask_cost
, and there is an assumption thatsubtask_cost
must be greater than zero.ClaimPaymentInfo
tx_hash
: emptypayment_ts
: emptyamount_paid
: 0amount_pending
: the full amount claimedClaimPaymentInfo
tx_hash
: hash of the transactionpayment_ts
: timestamp when Concent called SCI to create the transactionamount_paid
: the amount to be paidamount_pending
: full amount claimed minus the amount paidClaimPaymentInfo
objects.settle overdue acceptances
operationThe purpose of this operation is to calculate the total amount that the requestor owes provider for completed computations and transfer that amount from requestor's deposit. The caller is responsible for making sure that the payment is legitimate and should be performed. Bankster simply calculates the amount and executes it.
The provider proves to Concent that the computations were performed and accepted and Concent Core asks Bankster to compare the total value with the amount actually paid by the requestor, either directly or from deposit. If it turns out that the total value of provider's claims was not covered completely, Concent transfers the missing amount from requestor's deposit. If the deposit is not large enough to cover the whole amount, Concent transfers as much as possible. After this operation the provider can no longer claim any other overdue payments that happened before the deposit transfer.
Input
requestor_ethereum_address
provider_ethereum_public_key
. Comes fromTaskToCompute
.provider_ethereum_address
requestor_ethereum_public_key
. Comes fromTaskToCompute
.acceptances
SubtaskResultsAccepted
SubtaskResultsAccepted
golem messages describing each acceptance. The list must contain at least one object.SubtaskAcceptance
subtask
Subtask
payment_ts
payment_ts
timestamp from the acceptance message.amount
Output
requestors_claim_payment_info
ClaimPaymentInfo
Sequence of operation
requestors_claim_payment_info
is empty.ClaimPaymentInfo
tx_hash
: emptypayment_ts
: emptyamount_paid
: 0amount_pending
: the full amount claimedClaimPaymentInfo
tx_hash
: hash of the transactionpayment_ts
: timestamp when Concent called SCI to create the transactionamount_paid
: the amount to be paidamount_pending
: full amount claimed minus the amount paidClaimPaymentInfo
object.