Aggregator Payment FRC #947
honghaoq
started this conversation in
Filecoin Virtual Machine
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Introduction
This proposal extends the
I*DataAggregator
standard (see this FRC) with a newIAggregatorPayment
interface for aggregators to handle payment, and provides its reference implementation. In the aggregator deal standard FRC, we defined a submit and complete workflow for deal making onchain, in this standard, we extends it by adding reference for end to end payment handling methods, includingestimateFee
,submit (payable)
,complete
,withdraw
functions, along with balance and allowance update.Standardizing these interfaces and functions for payment handling allows various aggregators to offer a set of uniform methods to process payment for paid storage deals. This enhances community portability across different aggregators and promotes compatibility among tools and libraries.
Note that this standard applies toward both offchain aggregator (where deal aggregation and CommPa computation happens entirely offchain) and onchain aggregator (where deal aggregation happens offchain but CommPa computation happens onchain), as shown in the specification below.
Motivation / Context
This standard makes it possible for aggregator to take payments from client deals onchain, and distributes the fund toward aggregator and/or storage provider providing the service. This standard helps facilitate the adoption trend of paid deals, which is crucial for aggregators and storage providers to become long-term, self-sustainable businesses.
The main audience of this standard are: 1) clients that want to make payment directly via smart contract for paid aggregation and storage deals; and 2) aggregators that want to leverage onchain primitives to aggregate data and process deal payment from clients. Note that this FRC can be built on both FVM mainnet as well as IPC subnets.
Specification
IAggregatorPayment
Interface for payment handlingOutlined below is the
IAggregatorPayment
interface with functions extending theI*DataAggregator
standard to handle payment processing in smart contract:To enable aggregators with payment handling, we expect teams to implement the payment functions in
IAggregatorPayment
along with the payable submit and complete functions in theI*DataAggregator
interface mentioned in the aggregator deal standard FRC. Here we show thesubmit (payable)
andcomplete
functions needed to handle payment for offchain data aggregator and onchain data aggregator respectively.IOffchainDataAggregator
interface with submit payableThe
IAggregatorPayment
interface works with theIOffchainDataAggregator
standard in the aggregator deal standard FRC. It tightly follows the submit-complete two-step deal making process, and make it compatible for handling payments onchain. Here is the updatedIOffchainDataAggregator
interface to support payment handling.More details about the
IOffchainDataAggregator
interface can be found in this FRC, and a reference implementation to offchain data aggregator with onchain payment processing is available here.IOnchainDataAggregator
interface with submit payableSimilarly. for building onchain aggregators (aggregators that compute CommPa within smart contract onchain), the
IAggregatorPayment
interface would be implemented along with theIOnchainDataAggregator
interface for payment processing. Here thesubmit
function needs to be a payable function.More details about IOnchainDataAggregator interface with onchain_complete function can be found in the aggregator deal standard FRC.
Reference Implementation
A reference implementation of an offchain aggregator with payment handling enabled can be found here.
Rationale
A full-fledge data aggregator with payment handling will implement the
IAggregatorPayment
interface along with theI*DataAggregator
interface andIDataAggregatorEnumerable
Interface (as defined in the aggregator deal standard FRC with the following functions:estimateFee():
the first step for making a paid deal is to get price quote,estimateFee
function allows client to estimate pricing based on the amount of data and storage deal term they need to make, pricing calculation would be implemented based on different aggregators’ pricing models;submit():
after getting price quote, client can submit the deal request to aggregator and add fund with the payablesubmit
function. For aggregator running RaaS, it should makesubmitRaaS
function payable, details ofsubmitRaaS
can be found in this FRC.complete():
after receiving the deal requests, aggregator will perform data aggregation and check if data size matches with the provided fee, if the check passes and deal is made successfully, aggregator will call back to contract with thecomplete
function to update deal information and allowance for aggregator/storage provider. For aggregator running onchain aggregator service, it would useonchain_complete
function instead, as defined in this FRC, the payment processing interface and workflow are the same.withdraw():
after deal is made successfully and allowance is updated, aggregator/storage provider can use thewithdraw
function to collect their portion of the fee from client. User can also withdraw the fund with this method if the deal is not made.Essentially, this extends the two-step submit and complete deal-making workflow with payment handling properties. The updated workflow diagram with payment handling is shown in the diagram below:
Backwards Compatibility
This proposal introduces a new standard and does not alter or disrupt existing interfaces or implementations. However, aggregators wishing to conform to this standard for onchain payment handling will need to adopt this interface.
Test Cases
Testing for the implementation of the onchain payment interfaces should focus on:
Security Considerations
Since it does not introduce Filecoin protocol level changes, there is no protocol level security concerns at this time.
Handling malicious fund withdraw behavior: there is a possibility where client adds fund and then withdraws while aggregator is making deal or after deal is made, in which case aggregator/Storage Provider won’t get paid afterwards since fund is withdrawn. Clients do need to be able to withdraw fund themselves in case aggregator/SP not taking actions, but to protect payment for aggregator/SP, we recommend to only change client's allowance after request submitted to lock that fund for 7 days (lock period up to aggregators to define). This would give aggregator 7 days to process the deal, if it doesn't happen, then the fund is unlocked (revert allowance back) so user can withdraw. If the deal goes through, then allowance is updated so aggregator/SP can get paid. Since this requires a mapping of clients and request time to lock/unlock fund, we recommend implementing it on IPC if there is cost concern.
Copyright Waiver
Copyright and related rights waived via CC0.
Beta Was this translation helpful? Give feedback.
All reactions