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

Extended snapshot scheduler to better handle missing and zero params #1220

Merged
merged 3 commits into from
Jun 5, 2023

Conversation

vladtr
Copy link
Contributor

@vladtr vladtr commented May 31, 2023

This PR add differentiation between missing and zero-valued parameters in api request for start, end and spacing of blocks, in particular, as it was observed in original issue making start_block_num assignable to "0" in request or directly in snapshot-schedule.json file, such as:

{
    "snapshot_requests": [
        {
            "snapshot_request_id": "0",
            "snapshot_description": "Hourly snapshots starting from genesis",
            "block_spacing": "7200",
            "start_block_num": "0",
            "end_block_num": "0"
        }
    ]
}

Prior implementation treated zero start as missing value and replaced it with "now" block num

Resolves #1152

@vladtr vladtr linked an issue May 31, 2023 that may be closed by this pull request
@vladtr vladtr marked this pull request as ready for review June 1, 2023 16:11
@vladtr vladtr requested a review from greg7mdp June 1, 2023 16:12
libraries/chain/snapshot_scheduler.cpp Show resolved Hide resolved
libraries/chain/snapshot_scheduler.cpp Outdated Show resolved Hide resolved
snapshot_request_params sri2 = {.block_spacing = 5000, .start_block_num = 100000, .end_block_num = 300000, .snapshot_description = "Example of recurring snapshot 2 that will never happen"};
snapshot_request_params sri3 = {.block_spacing = 2, .start_block_num = 0, .end_block_num = 3, .snapshot_description = "Example of recurring snapshot 3 that will expire"};
snapshot_request_params sri4 = {.start_block_num = 1, .snapshot_description = "One time snapshot on first block"};
snapshot_request_params sri5 = {.block_spacing = 10, .snapshot_description = "Recurring every 10 blocks snapshot starting now"};
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see any new unit tests; do we need to add any more tests to expressly cover the example given in #1152? For example, head block is 6, and then a new request to .block_spacing = 10, .start_block_num = 0, .end_block_num = 0 is made, and then we should have snapshots on blocks 10 & 20, for example.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you, done! Extended tests to run a little longer and check for timings on first 2 snapshots

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Unexpected behavior with scheduled snapshots
4 participants