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

Andrew7234/epoch tracking #404

Merged
merged 1 commit into from
May 5, 2023
Merged

Andrew7234/epoch tracking #404

merged 1 commit into from
May 5, 2023

Conversation

Andrew7234
Copy link
Collaborator

@Andrew7234 Andrew7234 commented May 3, 2023

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 is description: 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,

  id   | start_height | end_height
-------+--------------+------------
 13402 |      10 |  19
 13403 |      20 |  29

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.

@Andrew7234 Andrew7234 requested review from aefhm, mitjat and pro-wh as code owners May 3, 2023 23:49
@Andrew7234 Andrew7234 force-pushed the andrew7234/epoch-tracking branch from 4489915 to 2731b1e Compare May 4, 2023 00:20
Copy link
Contributor

@mitjat mitjat left a comment

Choose a reason for hiding this comment

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

Thank you!

storage/migrations/01_consensus.up.sql Outdated Show resolved Hide resolved
analyzer/queries/queries.go Outdated Show resolved Hide resolved
@Andrew7234 Andrew7234 force-pushed the andrew7234/epoch-tracking branch from 23fbf5f to 7151647 Compare May 4, 2023 17:30
Copy link
Contributor

@mitjat mitjat left a comment

Choose a reason for hiding this comment

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

Thank you!
Nit: The commit title is very outdated.

storage/migrations/01_consensus.up.sql Outdated Show resolved Hide resolved
make epoch tracking parallelism-friendly

simplify db query; special-case end_height for current epoch

nit

nit
@Andrew7234 Andrew7234 force-pushed the andrew7234/epoch-tracking branch from 7151647 to 849bf5a Compare May 5, 2023 16:25
@Andrew7234 Andrew7234 enabled auto-merge May 5, 2023 16:26
@Andrew7234 Andrew7234 merged commit 0c2c3e6 into main May 5, 2023
@Andrew7234 Andrew7234 deleted the andrew7234/epoch-tracking branch May 5, 2023 16:31
@csillag csillag mentioned this pull request Dec 20, 2024
10 tasks
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.

2 participants