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

feat(epoch-sync): adding EpochSyncInfo column and its continuous population #9440

Merged
merged 4 commits into from
Aug 16, 2023

Conversation

posvyatokum
Copy link
Member

First step towards new epoch sync. Everything should be under new_epoch_sync feature.
Design doc: https://docs.google.com/document/d/14Itc9Hs7ewTRmcGANid9UCaYcJzaLzzM7FsvYYIFKDY/edit
Adding EpochSyncInfo column and its population on epoch end in block postprocessing.

@posvyatokum posvyatokum requested a review from a team as a code owner August 16, 2023 09:58
Copy link
Contributor

@nikurt nikurt left a comment

Choose a reason for hiding this comment

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

IIUC, you need a compilation feature, because you create a new column, but you haven't yet implemented the proper migration that populates that column.

chain/chain/src/chain.rs Outdated Show resolved Hide resolved
posvyatokum and others added 2 commits August 16, 2023 14:59
Co-authored-by: nikurt <86772482+nikurt@users.noreply.github.com>
@posvyatokum
Copy link
Member Author

IIUC

Yes.
Including new column depends on this column creation.
EpochSyncInfo creation depends on initial population.
Initial population depends on the actual data we want to write.
Data we want to write depends on actual sync implementation.
So, until the design is polished and proved in action, the compilation feature stays.

@posvyatokum posvyatokum merged commit a5238cc into master Aug 16, 2023
@posvyatokum posvyatokum deleted the epoch-sync-basics branch August 16, 2023 14:55
nikurt pushed a commit to nikurt/nearcore that referenced this pull request Aug 24, 2023
…lation (near#9440)

Adding EpochSyncInfo column and its population on epoch end in block postprocessing.
nikurt pushed a commit that referenced this pull request Aug 28, 2023
…lation (#9440)

Adding EpochSyncInfo column and its population on epoch end in block postprocessing.
github-merge-queue bot pushed a commit that referenced this pull request Nov 2, 2023
#10029
The fix is 10 lines in `chain/chain/src/chain.rs`. Everything else is
for testing.

I don't like this approach, I am fixing a symptom, not the problem. But
it is good enough for now (and possibly forever).
But, just for context, **the problem** is as follows.
We should write `EpochSyncInfo` every time we write `EpochInfo` of a
full epoch.
It is fine not to write `EpochSyncInfo` for genesis epoch of one block
for two reasons:
- Everyone has full genesis epoch on startup
- Next epoch has the same `epoch_id` and therefore it is incorrect to
have that key in DB before the end of first proper epoch

`EpochInfo` is written in function `record_block_info` that is called
from `add_validator_proposals`.
Both function belong to `EpochManager`, and we cannot add
`EpochSyncInfo` generation to `EpochManager`, as it requires headers
(including the last header of an epoch, that is probably not written
into DB during the execution of anything in `EpochManager`). From an
architecture point of view `EpochSyncInfo` generation is a `Chain`
function.

So, I couldn't enforce that `EpochSyncInfo` is tied to `EpochInfo`
generation. But I traced every usage of `add_validator_proposals`, and
we have only two usages that are
-  in `neard`
- not in tests
- not related to genesis epoch

First usage was covered by the commit that introduced `EpochSyncInfo`
#9440.
Second usage is covered with this PR.
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