Host has reached its collateral budget and cannot accept the file contract
MeijeSibbel opened this issue · 5 comments
https://github.com/storewise/s3-gateway/issues/228
We started seeing these errors in our logs recently;
Are hosts starting to run out of their collateral with all the uploads going on? Is there a way make the host accept the contract even when the collateral budget is reached?
Unfortunately the host's collateral budget is an internal metric, so the only way for the renter to determine the budget would be to try forming contracts over and over again with slightly less collateral each time.
Is there a function exposed in us
that allows us to retry forming contracts with less collateral? How would we go about doing this?
I don't think I'm willing to expose that functionality, since a) you can't determine the amount of collateral to use without guessing, b) decreasing the collateral is disadvantageous for the renter, and c) you would likely only be able to form one more contract before completely exhausting the host's budget anyway.
However, you can certainly modify the behavior in your fork. Here's where collateral is calculated; you can divide the result by 10, or set it to a flat 1 SC, or override it with an argument to FormContract
, etc.
Although we still get this error in the logs;
The recent commits suppressed this issue issue significantly. Moreover since this mostly depends on the host setting a proper collateral value, there isn't much more we can do except advise the hosts. Therefore let close this.
@lukechampine for reference, what is the min-collateral/max-collateral us
expects the hosts to set? Just so we can advise hosts moving forward what value they should set for their operation.
The total collateral is calculated as settings.Collateral * contract size * duration
, capped at settings.MaxCollateral
. So as a general guide, hosts should allocate enough coins towards their collateral budget that all of their storage could be used for settings.MaxDuration
blocks.
However, settings.MaxCollateral
is a per-contract setting, and contracts don't actually need to use any storage. If a host's collateral budget is MaxCollateral * 25
, then they can form at least 25 contracts, but potentially many more than that if most contracts aren't using MaxCollateral
.
To put some numbers on this, say I have 10 TB of storage and I want to charge 50 SC / TB / month. The collateral should be 3-5x the storage cost, so we'll say 200 SC / TB / month. We'll also use the standard MaxDuration
of six months. If one contract used all 10 TB for six months, that would amount to 12 KS of collateral. Now, we have two options. We could set our MaxCollateral
to 12 KS, in which case contracts will never hit that limit. The downside of this is that renters might create big contracts, each requiring 12 KS of collateral, but never actually store data. Thus, we need to estimate the minimum number of contracts we want, say 25, and multiply our MaxCollateral
by that to get our target collateral budget. The other option is to use a lower MaxCollateral
. This means our collateral budget can be proportionally smaller (or alternatively, that we can support more contracts), but the downside is that large renters may refuse to form contracts with us because we aren't putting up enough collateral.
To summarize: take your total storage, multiply by your storage price, multiply that by 3-5x to get your collateral, multiply that by your MaxDuration
, and use that as your baseline MaxCollateral
; finally, reduce your MaxCollateral
if necessary so that you have 5-20x in your budget:
fromSettings := settings.TotalStorage * settings.Collateral * settings.MaxDuration
fromBudget := settings.CollateralBudget / minimumContracts
settings.MaxCollateral = min(fromSettings, fromBudget)