renterd
renterd copied to clipboard
Improve ephemeral account drift
This PR proposes a series of small changes in an attempt to fix (or improve) the drift we see in production. I have not been able to reproduce (meaningful) negative drift in a test locally and found debugging it on production quite challenging because you want to caveman debug both sides ideally. The following changes definitely improve things, but we'll need to keep following it up.
- [x] plug leaks where we weren't withdrawing money from the EA even though we paid for things like PT updates
- [x] pessimistically withdraw money from the account in
DownloadSector
(host only refunds storage revenue on failure) - [x] sync newly created accounts (avoids funding already funded accounts)
- [x] reset drift in production (fresh start allows for better follow up)
I considered syncing the account balance when we fund an account. I went back and fourth on that several times but eventually removed it because it more or less makes requiresSync
obsolete. The benefit though would be that you are certain the account has 1SC in it after you fund it, while at the same time keeping track of drift. So drift would still build up, but at the very least you have an account with 1SC and you never run into unexpected insufficient balance errors...