NebulousLabs / Sia

Blockchain-based marketplace for file storage. Project has moved to GitLab: https://gitlab.com/NebulousLabs/Sia
https://sia.tech
MIT License
2.71k stars 442 forks source link

Fix host collateral error when renewing contracts #3160

Open ChrisSchinnerl opened 5 years ago

ChrisSchinnerl commented 5 years ago

I'm not 100% sure if this math makes sense but I'm pretty confident. The comments were a bit misleading since it sounded like basePrice and baseCollateral are already covered by the last contract while they are actually the minimum amount of money that has to be put in the contract to cover the existing data on the host.

In my opinion the hostCollateral should also be the possible max collateral + the baseCollateral. That way we don't end up with a potential underflow later. It's also a bit more correct since baseCollateral is not a subset of the hostCollateral but rather the hostCollateral is the sum of the baseCollateral (collateral for existing data) plus the maxCollateral (the maximum additional collateral that will be put into the contract by the host if the renter spends all of the renterPayout for storage).