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 3 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).

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    120 suites   43m 50s ⏱️
1 280 tests 1 280 ✅ 0 💤 0 ❌
3 832 runs  3 832 ✅ 0 💤 0 ❌

Results for commit 7b41d15.

♻️ 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)

 2 files  11 suites   12m 3s ⏱️
30 tests 29 ✅ 0 💤 1 ❌
31 runs  30 ✅ 0 💤 1 ❌

For more details on these failures, see this check.

Results for commit 7b41d15.

♻️ This comment has been updated with latest results.

@SWvheerden SWvheerden changed the base branch from development to feature-dan2 September 12, 2023 09:27
@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 reopened this Sep 25, 2023
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 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.

None yet

4 participants