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.
The task:
Currently, we
INSERT INTO oasis_3.epochs (id, start_height) VALUES (current_epoch, current_height) ON CONFLICT DO NOTHING
to get the earliest height as epoch start; similar order-reliant trick for end_height. Basically, we want to do the following for each block instead:start[curr_epoch] = min(old_value, curr_height); end[curr_epoch-1] = min(old_value, curr_height-1)
This PR:
Note: I believe the prior epoch tracking logic was slightly incorrect. Our openapi spec states that the
end_height
isdescription: The (inclusive) height at which this epoch ended. Omitted if the epoch is still active.
However, the prior code set the db end_height as the exclusive upper bound. This PR will now set the `end_height to be the inclusive upper bound as described. Eg,
I'm not quite sure which is more idiomatic, comments are welcome.
Test plan: light testing ran locally with e2e_regression tests over 601 blocks. Further verification is needed once we are able to run multiple parallel consensus analyzers.
Todo:
investigate if/how we use epoch end_height in the rest of the indexer logic.