-
Notifications
You must be signed in to change notification settings - Fork 213
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
Conversation
lib/core/src/Cardano/Pool/Metrics.hs
Outdated
toInt (EpochNo e) = fromIntegral e | ||
|
||
toEp :: Int -> EpochNo | ||
toEp = EpochNo . fromIntegral |
There was a problem hiding this comment.
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]
?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
.
NOTE: Does not catch the underflow bug as the epochs are too high in the integration tests.
c4dc29e
to
a1fe6d1
Compare
bors r+ |
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>
Build succeeded |
Issue Number
Overview
EpochNo
toInt
and back.Comments