Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: Convert beacon and backup timers to scheduled jobs #1885

Merged

Conversation

cyrossignol
Copy link
Member

@cyrossignol cyrossignol commented Sep 15, 2020

This refactors the block-spacing-based "timers" for beacon renewals and wallet backups into formal background jobs executed by the scheduler.

Since the -walletbackupinterval configuration option expects the interval as the number of blocks that need to pass between backups, I added a -walletbackupintervalsecs option to allow for specifying the backup interval as a unit of time. This deprecates the old option.

I also added APIs for storage of the last backup timestamp to the wallet so that the backup schedule resumes between node restarts. Before, users that restart the wallet frequently may never see the wallet create a backup because the old interval resets with each launch.

This replaces the block-interval-based delay used to try beacon renewal
with a proper job executed by the scheduler every four hours.
These APIs enable a node to track wallet backup times across restarts.
This replaces the block-interval-based delay used to backup a wallet
with a proper job executed by the scheduler.
This adds an option used to configure the wallet backup interval. It
supercedes the walletbackupinterval option which expects an interval
as the number of blocks that must pass between backups.
@div72
Copy link
Member

div72 commented Sep 15, 2020

Does the config files still need a backup considering the beacon keys aren't in it anymore?

src/backup.cpp Outdated Show resolved Hide resolved
@jamescowens
Copy link
Member

@div72 Yes. I think so. While the beacon keys are not in there, there are important settings that someone might want to know how the wallet was configured at a certain point in time, especially with regards to sidestake entries as one example.

@cyrossignol
Copy link
Member Author

cyrossignol commented Sep 15, 2020

I'm not a big fan of backing up the config files now, but in the last discussion I think we agreed to keep that functionality. We may add a switch to disable that side in the future. The cumulative size of the config file backups is pretty small compared to the wallet backups.

@jamescowens
Copy link
Member

I think I pushed to your repo by accident instead of creating a PR. Sorry about that. I think it is good. I have done some testing, and it seems to be running fine, except the initial RunBackupJob() in init doesn't seem to be running. Maybe this is too early?

@cyrossignol
Copy link
Member Author

The one-shot in init exits early if the last backup time saved to the wallet is sooner than now - interval to avoid delaying start-up every launch if the wallet ran the backup job recently. You can set -walletbackupintervalsecs=60, wait a minute, and start the wallet to test.

@cyrossignol cyrossignol marked this pull request as ready for review September 15, 2020 19:03
This local operation does not need the network-adjusted time.
@jamescowens
Copy link
Member

Yeah, but it didn't run for the first time I ran it with this PR, where the last backup time is zero because it had never been saved before...

@jamescowens
Copy link
Member

It is a small nit anyway. I am going to go ahead and merge.

@jamescowens jamescowens merged commit ac9d3e5 into gridcoin-community:development Sep 15, 2020
@cyrossignol cyrossignol deleted the convert-timers branch September 15, 2020 21:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants