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 underflow in performance calculation #1035

Merged
merged 2 commits into from
Nov 14, 2019
Merged

Conversation

Anviking
Copy link
Member

@Anviking Anviking commented Nov 14, 2019

Issue Number

Overview

  • I have fixed underflow by converting from EpochNo to Int and back.
  • I made integration tests stronger. ⚠️ Does not catch the bug however, as the current epoch is too high. (needs to be 14 or lower to underflow)

Comments

  • Oops.

@Anviking Anviking self-assigned this Nov 14, 2019
@Anviking Anviking requested a review from KtorZ November 14, 2019 19:24
toInt (EpochNo e) = fromIntegral e

toEp :: Int -> EpochNo
toEp = EpochNo . fromIntegral
Copy link
Member

Choose a reason for hiding this comment

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

Alternatively:

historicalEpochs :: [EpochNo]
historyEpochs 
    | currentEpoch < 14 -> [0..currentEpoch]
    | otherwise         -> [currentEpoch - 14 .. currentEpoch]

?

Copy link
Member Author

@Anviking Anviking Nov 14, 2019

Choose a reason for hiding this comment

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

Neat,

although maybe it is more difficult to see that it is indeed correct

maybe

    historicalEpochs :: [EpochNo]
    historicalEpochs
        | currentEpoch < window = [0..currentEpoch]
        | otherwise             = [currentEpoch - window .. currentEpoch]
      where
        window = 14
    historicalEpochs :: [EpochNo]
    historicalEpochs
        | currentEpoch > window = [currentEpoch - window .. currentEpoch]
        | otherwise             = [0..currentEpoch]
      where
        window = 14

but it still kind of relies on you knowing that currenEpoch and window are non-negative… but the same can probably be argued for the original min solution.

Copy link
Member

Choose a reason for hiding this comment

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

Hmmm. I am not sure to get where you are going to with this? We know currentEpoch is non-negative because it's an EpochNo.

@KtorZ
Copy link
Member

KtorZ commented Nov 14, 2019

bors r+

iohk-bors bot added a commit that referenced this pull request Nov 14, 2019
1031: Test that follow doesn't retry too often r=KtorZ a=Anviking

# Issue Number

#1027 


# Overview

<!-- Detail in a few bullet points the work accomplished in this PR -->

- [x] I have added tests to make sure we retry (and log), but not too much.


# Comments

- The test just hangs *without* the fix `git revert bf8844d` 🤔 I guess some infinite loops happens, but I can't figure out how to fix it. Not sure if we need to fix it, or want this PR anyway.

<!-- 
Don't forget to:

 ✓ Self-review your changes to make sure nothing unexpected slipped through
 ✓ Assign yourself to the PR
 ✓ Assign one or several reviewer(s)
 ✓ Once created, link this PR to its corresponding ticket
 ✓ Acknowledge any changes required to the Wiki
-->


1033: remove race condition from TRANS_DELETE_01 r=KtorZ a=paweljakubas

# Issue Number

<!-- Put here a reference to the issue this PR relates to and which requirements it tackles -->


# Overview

<!-- Detail in a few bullet points the work accomplished in this PR -->

- [x] I have addressed issue of race condition in TRANS_DELETE_01


# Comments

<!-- Additional comments or screenshots to attach if any -->

<!-- 
Don't forget to:

 ✓ Self-review your changes to make sure nothing unexpected slipped through
 ✓ Assign yourself to the PR
 ✓ Assign one or several reviewer(s)
 ✓ Once created, link this PR to its corresponding ticket
 ✓ Acknowledge any changes required to the Wiki
-->


1034: bump version to 2019-11-14 r=KtorZ a=KtorZ

# Issue Number

<!-- Put here a reference to the issue this PR relates to and which requirements it tackles -->

N/A

# Overview

<!-- Detail in a few bullet points the work accomplished in this PR -->

- [ ] I have bumped all version numbers to `2019.11.14` in prevision of the next release.

# Comments

<!-- Additional comments or screenshots to attach if any -->

<!-- 
Don't forget to:

 ✓ Self-review your changes to make sure nothing unexpected slipped through
 ✓ Assign yourself to the PR
 ✓ Assign one or several reviewer(s)
 ✓ Once created, link this PR to its corresponding ticket
 ✓ Acknowledge any changes required to the Wiki
-->


1035: Fix underflow in performance calculation r=KtorZ a=Anviking

# Issue Number

# Overview

<!-- Detail in a few bullet points the work accomplished in this PR -->

- [x] I have fixed underflow by converting from `EpochNo` to `Int` and back.
- [x] I made integration tests stronger. ⚠️ Does not catch the bug however, as the current epoch is too high. (needs to be 14 or lower to underflow)


# Comments

- Oops.

<!-- Additional comments or screenshots to attach if any -->

<!-- 
Don't forget to:

 ✓ Self-review your changes to make sure nothing unexpected slipped through
 ✓ Assign yourself to the PR
 ✓ Assign one or several reviewer(s)
 ✓ Once created, link this PR to its corresponding ticket
 ✓ Acknowledge any changes required to the Wiki
-->


Co-authored-by: Johannes Lund <johannes.lund@iohk.io>
Co-authored-by: KtorZ <matthias.benkort@gmail.com>
Co-authored-by: Pawel Jakubas <pawel.jakubas@iohk.io>
@iohk-bors iohk-bors bot merged commit a1fe6d1 into master Nov 14, 2019
@iohk-bors
Copy link
Contributor

iohk-bors bot commented Nov 14, 2019

Build succeeded

@KtorZ KtorZ deleted the anviking/fix-underflow branch November 14, 2019 20:21
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.

3 participants