Use the snapshot cycle first block level to get the block. #596
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.
With short cycles, the current level might be in a different cycle, causing the RPC to fail.
Analysis: I am trying to make tezos-reward-distributor work with private Tezos chains. During testing, I set my blocks_per_cycle to 8 (instead of the normal 8192). This makes testing much quicker, as one only needs to wait a few minutes to get enough blocks baked to do a distribution. But I noticed that requests were failing. One such failing request was to
http://my-private-tezos-node/chains/main/blocks/14396/context/selected_snapshot?cycle=1795
I noticed that block 14396 should not be in cycle 1795 (with a cycle length of 8). This led me to this funny bit of code.Solution: For a parameter named
snapshot_cycle_first_block_level
, use a variable namedsnapshot_cycle_first_block_level
notcurrent_cycle
Performed tests: After this change, tezos-reward-distributor gets further in distributing rewards (it still doesn't work, but that might be a config issue on my side).
Work effort: 3 hours (mostly spent learning what any of this code was doing, and figuring out how to get reasonable error messages -- see #597).