Explicit deal settlement - long-term resolution of built-in market cron risk (FIP-0074) #800
Replies: 6 comments 5 replies
-
I am drafting a FIP for this proposal at #805. Implementation is being prototyped in filecoin-project/builtin-actors#1377. |
Beta Was this translation helpful? Give feedback.
-
qq - how would manual deal payment settlement work when a sector is under faulty status? |
Beta Was this translation helpful? Give feedback.
-
Wanted to follow up THIS COMMENT, re: future scenarios and existing proposals. I think Jennifer raises a good point. FWIW, FIPs should be holistic policy documents. They should consider future scenarios and potential impacts/outcomes, but they should not be solely predicated upon them. FIPs should independently introduce good network policy in the present, even as they consider future needs. I don't think it's a problem that this FIP references the potential impacts of direct data onboarding, since the FIP itself does not solely exist in anticipation of a future where direct data onboarding is the norm. |
Beta Was this translation helpful? Give feedback.
-
I'm confused about:
versus
Wouldn't synchronous cleanup remove the no-payment deals as well? |
Beta Was this translation helpful? Give feedback.
-
It would also be possible to do this per storage provider, forcing the storage provider to do their own cleanup e.g., on before submitting any proofs. Although I'm not sure if that's worth it, honestly. |
Beta Was this translation helpful? Give feedback.
-
I have made a gas estimate for manual settlement by inferring it from the gas consumed by cron. Now included in FIP-0074:
Payment settlement, in our very inefficient built-in market actor implementation, is expensive. This is why doing it automatically and for free is a threat to network security. A future market implementation that cares about gas costs will likely do it much better. @raulk suggested gas refunds. I don't think they're likely to be positive in this situation. Also from the FIP:
With market cron currently "only" consuming 1x the entire tipset gas budget, this does raise the possibility of holding off on these changes until we can also implement some optimisations to settlement to reduce the cost. If direct data onboarding is widely adopted, the pressure on the built-in market might be reduced significantly in the near term. However, if it doesn't, we could possibly find ourselves in an emergency situation again. |
Beta Was this translation helpful? Give feedback.
-
Edit: FIP-0074
Background
See prior discussion #638 that led to FIP-0060.
Cron-initiated payments
The built-in cron actor calls the built-in storage market actor at every epoch to perform maintenance (mainly the disbursement of payments) for all active deals. Each deal is scheduled for this maintenance on a 30 day period.
There are currently about 45 million active deals (currently ~520 deals per epoch), a number which is growing quickly. The cost of this level of service is unsustainable. It nearly caused disaster when the update period was 24 hours. Pushing it out to 30 days in FIP-0060 only bought some time to design a more permanent solution. There remains significant risk that this processing could grow beyond the ability of the chain to safely execute it. The cost is also largely redundant for the 98% of deals that specify no payment.
At the end of each epoch, the market actor loads all deals that are scheduled for maintenance. For each deal, the function:
Direct data onboarding
A concurrent proposal is to support skipping the built-in storage market actor for some data onboarding, which provides a cost reduction for arrangements that don’t need payments. As this capability is implemented and adopted, we might expect the number of built-in market deals to decrease even as data onboarding increases.
If and when adopted, this would mitigate the risk significantly. However, the benefit depends on participants’ behavior and we can’t make any guarantees about the extent to which they will adopt the new methods. The built-in market actor might still be expected to host a large number of payment-bearing deals. So we don’t want to rely on direct data onboarding in either the near or long term as a final solution.
Proposal
Remove payment settlement and state clean-up from cron, and provide a new, explicit user message to settle payments. Continue timing out un-activated deals in cron.
New method for settlement
A new externally-invoked method,
MarketActor::SettleDealPayments
, may be invoked by a storage provider (or anyone on their behalf) to settle incremental payments for a specified list of deals. SPs can invoke this to calculate and disburse accrued payments. Settling the final payment for a completed deal also removes the deal metadata from state.This explicit message aligns the gas cost of settling payments with the party deriving the benefit. It also bounds the cost, like most other state transitions, by the block gas limit. Providers might settle payments quite infrequently, reflecting the relatively low utility of doing so, and will prefer periods of low gas demand. Less frequent updates result in a lower system-wide amount of computation performed.
Synchronous clean-up on termination
The existing
MarketActor::OnMinerSectorsTerminate
method is changed to synchronously make a final payment settlement, charge penalties, and clean up state. It behaves as ifSettleDealPayments
was invoked immediately after marking deals as terminated. This replaces the current technique of merely recording the termination epoch and then waiting for cron to do the work.Since sector termination may be invoked by the miner actor’s cron handler, this will sometimes still do work in cron. This may be resolved by future changes to reduce miner actor cron too. Explicit sector termination by the SP will account for the cost of clean up to their gas usage.
No automatic settlement for new deals
When a deal is first published, it is added to the cron queue after its start epoch. If it is not activated prior to that epoch, it is expired and cleaned up in cron. This remains as it works today.
However, when a deal is found to have been newly-activated, it is not re-scheduled for subsequent processing.
Storage providers are not expected to invoke settlement for deals that carry no payment. The metadata for such newly-created but no-payment deals will thus remain in state indefinitely. However, with direct data onboarding, there is little benefit and some cost to involving the built-in market actor in new unpaid deals. We expect relatively few additional unpaid deals to be accumulated after that is possible. Stale blockchain state poses a much lesser risk to blockchain execution than continual processing. If a large amount does accumulate, it could be dealt with independently.
Continue automatic settlement for existing deals
Deals that are already activated prior to this change continue to be settled automatically in cron. Since no new deals are scheduled for automatic settlement, this will result in the cost gradually declining until there are no active deals scheduled. At that point, a future simplification can remove the code for payment settlement and state clean-up from cron.
No migration
The scheme described above involves no state migration. The cron queue will eventually empty itself as existing deals complete and no new ones are scheduled.
Alternatives
Some alternative ideas that seem less favourable than the proposal include:
Beta Was this translation helpful? Give feedback.
All reactions