[5.0] treat a end_block_num=0
as "forever" in snapshot scheduler for compatibility with leap 4.0 behavior
#2402
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.
leap 5's snapshot scheduling implementation changed the meaning of
end_block_num=0
which breaks both requests that previously worked and any previously scheduled snapshots with that value (the scheduled snapshots will effectively be removed upon upgrade to leap5).In leap4 requests were submitted as
leap/plugins/producer_plugin/include/eosio/producer_plugin/producer_plugin.hpp
Lines 85 to 89 in 01dab51
This has the important behavior that if a request does not specify
end_block_num
it remains 0 and is written out tosnapshot-schedule.json
with"end_block_num":0
. I believe what happens then is thatend_block_num=0
gets treated as "forever" by it not being removed from the scheduled list here,leap/plugins/producer_plugin/include/eosio/producer_plugin/snapshot_scheduler.hpp
Lines 94 to 99 in 01dab51
But leap5 changes things up. There is an additional indirection on the requests,
leap/libraries/chain/include/eosio/chain/snapshot_scheduler.hpp
Lines 47 to 54 in 0242caa
before the similar
snapshot_request_information
is used,leap/libraries/chain/include/eosio/chain/snapshot_scheduler.hpp
Lines 40 to 45 in 0242caa
So, importantly, in 5.0 if the request does not specify the
optional<uint32_t> end_block_num
then it is set to UINT32_MAX,leap/plugins/producer_plugin/producer_plugin.cpp
Lines 1538 to 1544 in 0242caa
And then leap5's schedule pruning does not treat
end_block_num=0
as special because it expects "forever requests" to beend_block_num=UINT32_MAX
; so anyend_block_num=0
requests (be it new ones arriving on RPC, or old ones read from the JSON file) just get removed immediately.leap/libraries/chain/snapshot_scheduler.cpp
Lines 30 to 31 in 0242caa
So this PR replaces
end_block_num=0
withend_block_num=UINT32_MAX
both,snapshot-schedule.json
entries withend_block_num=0
, andschedule_snapshot
RPC request, so that behavior with requests that worked in leap4 remain the same in leap5Resolves #2261