types,consensus: Add Capacity field to V2FileContract #220
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This field clarifies some long-standing confusion around the economics of file contracts.
When you pay for storage in a file contract, you are buying that storage for the remainder of the contract duration. This means that, even if you delete some data, you do not get a refund. Why not? Well, mainly, how do you price the refund? If you use the host's current prices, the host can manipulate them in order to minimize the refund. On the other hand, if you use the original price, now you have to keep track of what the original price was -- and not just the price, but also how long each sector was originally stored for. That's a lot metadata, and both the renter and host need to track it accurately, or they'll disagree on the price and stop communicating entirely.
Okay, so we can't do refunds. But we also want a way for renters to get rid of data they don't care about. One way to do that is to overwrite the garbage data with data we do care about. For this to work, though, the renter has to keep track of the garbage sectors, which is annoying. In general, we want to minimize renter-side state (to facilitate light clients), so we shift responsibilities to the host and use cryptography to make sure the host doesn't cheat. So in RHPv4, that's the plan: have the host keep track of the garbage sectors, so that when you upload new data, the host can reuse existing capacity instead of increasing the contract size. This is why we need a capacity field: to ensure that the host doesn't lie about how much capacity is available.
Fixes #217