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

fix: correct epoch counting #5749

Open
wants to merge 4 commits into
base: feature-dan2
Choose a base branch
from

Conversation

Cifko
Copy link
Contributor

@Cifko Cifko commented Sep 7, 2023

Description

Fix the epoch counting.

Motivation and Context

When the epoch length changed it affected the history as well. E.g. when you have epoch length set to 10 and it's height 1000. then the epoch # is 100. But when there is new consensus constant from 1001 with epoch length 20. Suddenly the epoch is 50.
Now it computes it like this:
When there is an constant change then it's effect is immediate but the epoch skip is prevented.
e.g.

  1. Length is 15 and it's going to change on height 100 to 3. So on height 99 the epoch is 6, on 100 the epoch is 10 (because the current epoch is already of size 10).
  2. Length is 15 and it's going to change on height 100 to 20. So on height 99 the epoch is 6, on 105 (without the change this would be the next epoch height, but with current new constant it's not changed). The epoch is changed on 110 (to 7).

Fixes tari-project/tari-dan#832

How Has This Been Tested?

There is a new test test_epoch_to_height_and_back

What process can a PR reviewer use to test or verify this change?

cargo.exe +stable test --package tari_core --lib -- consensus::consensus_manager::tests::test_epoch_to_height_and_back --exact --nocapture

Breaking Changes

  • None
  • Requires data directory on base node to be deleted
  • Requires hard fork
  • Other - Please specify
    This will break 2nd layer ONLY on chains that have new consensus constants.

@github-actions
Copy link

github-actions bot commented Sep 7, 2023

Test Results (CI)

    3 files    107 suites   34m 52s ⏱️
1 297 tests 1 296 ✅ 0 💤 1 ❌
3 219 runs  3 218 ✅ 0 💤 1 ❌

For more details on these failures, see this check.

Results for commit b6ac656.

♻️ This comment has been updated with latest results.

@ghpbot-tari-project ghpbot-tari-project added P-acks_required Process - Requires more ACKs or utACKs P-reviews_required Process - Requires a review from a lead maintainer to be merged labels Sep 7, 2023
@github-actions
Copy link

github-actions bot commented Sep 7, 2023

Test Results (Integration tests)

32 tests   32 ✅  12m 19s ⏱️
11 suites   0 💤
 2 files     0 ❌

Results for commit b6ac656.

♻️ This comment has been updated with latest results.

@Cifko Cifko force-pushed the correct-epoch-counting branch from 9a7cceb to e5af697 Compare September 7, 2023 08:14
@SWvheerden SWvheerden changed the base branch from development to feature-dan2 September 12, 2023 09:27
@Cifko Cifko force-pushed the correct-epoch-counting branch from e5af697 to 8eb6296 Compare September 25, 2023 08:56
@ghpbot-tari-project ghpbot-tari-project added the CR-too_long Changes Requested - Your PR is too long label Sep 25, 2023
@Cifko Cifko closed this Sep 25, 2023
@Cifko Cifko force-pushed the correct-epoch-counting branch from 8eb6296 to d2a0c8c Compare September 25, 2023 09:03
@Cifko Cifko reopened this Sep 25, 2023
@Cifko Cifko force-pushed the correct-epoch-counting branch from b3c9407 to 25959c5 Compare September 25, 2023 09:20
Copy link
Collaborator

@SWvheerden SWvheerden left a comment

Choose a reason for hiding this comment

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

A few small nits

base_layer/core/src/chain_storage/lmdb_db/lmdb_db.rs Outdated Show resolved Hide resolved
base_layer/core/src/consensus/consensus_manager.rs Outdated Show resolved Hide resolved
base_layer/core/src/consensus/consensus_manager.rs Outdated Show resolved Hide resolved
@Cifko Cifko force-pushed the correct-epoch-counting branch from 38e0c6f to 545dd8c Compare April 16, 2024 04:44
@Cifko Cifko requested a review from a team as a code owner April 16, 2024 04:44
Copy link
Contributor

@hansieodendaal hansieodendaal left a comment

Choose a reason for hiding this comment

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

Looks good (tested). Just some defence-in-depth comments.

Copy link
Contributor

@hansieodendaal hansieodendaal left a comment

Choose a reason for hiding this comment

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

utACK

@ghpbot-tari-project ghpbot-tari-project removed the P-reviews_required Process - Requires a review from a lead maintainer to be merged label Apr 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CR-too_long Changes Requested - Your PR is too long P-acks_required Process - Requires more ACKs or utACKs
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants