-
Notifications
You must be signed in to change notification settings - Fork 214
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 apparent performance calculation #1006
Conversation
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.
Good catch 👍
Thanks for checking this!
I insist however on the necessity of keeping the value clamped to (0;1).
Also, @Anviking , pointing back to the 3rd point of our QA section in the development process: https://github.com/input-output-hk/cardano-wallet/wiki/Development-Process#qa May you add an actual regression test that illustrate the issue? This can be achieved using the |
00f2941
to
d831c13
Compare
n <- choose (0, 100) | ||
Lovelace <$> frequency | ||
[ (50, return n) | ||
, (25, return $ minLovelace - n) |
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.
What is this supposed to mean 🤔 ? I believe that for Word64
, this will simply loop back to maxBound
. What's the intent behind this?
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.
Hm, oops, that should have been maxBound - n
.
But I will remove this as I needed it to avoid overflow the test that is now not here… Actually maybe it is still needed 🤔
Failing regression tests without the fix:
|
let stake = mkStake [ (poolA, 1), (poolB, 1) ] | ||
let production = mkProduction [ (poolA, 2), (poolB, 0) ] | ||
let performances = calculatePerformance 8 stake production | ||
Map.lookup poolA performances `shouldBe` (Just 0.5) |
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.
😊
For the parameter > S - total number of slots in the epoch we used to sum the total block productions in our `Map PoolId nOfBlocks` map. This is wrong as empty slots are not represented in the map of block productions. Summing the map gives us the number of /blocks/ in the epoch, not number of /slots/.
91bf55c
to
8765169
Compare
bors r+ |
1006: Fix apparent performance calculation r=KtorZ a=Anviking # Issue Number Should probably be a bug. <!-- 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 fixed the way we calculate `S (number of slots in the epoch)`. # Comments ## Comparison Setup: ```bash jormungandr --genesis-block-hash 6a40cf890d84981353457fcab6c892af57ee3c3286b33b530cd46b1af5b0e3a7 \ --rest-listen 127.0.0.1:8080 \ --storage /Users/Johannes/.local/share/cardano-wallet/jormungandr/testnet/chain \ --config ../testnet.yml cardano-wallet-jormungandr serve --genesis-block-hash 6a40cf890d84981353457fcab6c892af57ee3c3286b33b530cd46b1af5b0e3a7 --node-port 8080 ``` ### Previously (uncapped) Using the first commit to show the uncapped apparent performances. ```bash cardano-wallet-jormungandr stake-pool list | jq '.[] | "\(.metrics.controlled_stake.quantity),\(.metrics.produced_blocks.quantity) \(.apparent_performance)"' | tr -d '"' Ok. 10000000000000,2 2.2908997271066665 10000000000000,2 2.2908997271066665 10000000000000,1 1.1454498635533332 10000000000000,1 1.1454498635533332 799999987900,0 0 10000000000000,0 0 8039991840700,0 0 9886999984600,0 0 ``` ### Now (uncapped) ```bash cardano-wallet-jormungandr stake-pool list | jq '.[] | "\(.metrics.controlled_stake.quantity),\(.metrics.produced_blocks.quantity) \(.apparent_performance)"' | tr -d '"' Ok. 10000000000000,2 0.19636283375199998 10000000000000,2 0.19636283375199998 10000000000000,1 0.09818141687599999 10000000000000,1 0.09818141687599999 799999987900,0 0 10000000000000,0 0 8039991840700,0 0 9886999984600,0 0 ``` <!-- 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>
Build succeeded |
Issue Number
Should probably be a bug.
Overview
S (number of slots in the epoch)
.Comments
Comparison
Setup:
Previously (uncapped)
Using the first commit to show the uncapped apparent performances.
Now (uncapped)