-
Notifications
You must be signed in to change notification settings - Fork 16
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
create-testnet-data: fix computation of not-delegated amount #638
Conversation
e331fb2
to
309a844
Compare
bs <- liftIO $ LBS.readFile $ outputDir </> "genesis.json" | ||
genesis :: ShelleyGenesis StandardCrypto <- Aeson.throwDecode bs |
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.
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.
Done and learnt about readJsonFileOk
👍
@@ -622,7 +621,8 @@ updateOutputTemplate | |||
totalSupply = fromIntegral $ maybe maximumLovelaceSupply unLovelace mTotalSupply | |||
|
|||
delegCoinRaw, nonDelegCoinRaw :: Integer | |||
delegCoinRaw = case mDelegatedSupply of Nothing -> 0; Just (Lovelace amountDeleg) -> totalSupply - amountDeleg | |||
delegCoinRaw = maybe 0 unLovelace mDelegatedSupply |
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.
👍🏻
let L.Coin onlyHolderCoin = snd $ initialFunds !! 0 | ||
|
||
-- The check below may seem weird, but we cannot do a very precise check | ||
-- on balances, because of the treasury "stealing" some of the money. |
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 do you mean by that? I thought that treasury starts empty, and gets filled with time from reserves.
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.
-- of --total-supply above. | ||
-- https://github.com/IntersectMBO/cardano-cli/issues/631 | ||
|
||
H.assert $ fromIntegral onlyHolderCoin > totalSupply `div` 2 |
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.
Can you replace it with assertWith
? assertWith
logs the value on failure.
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.
Done 👍 Thanks, I didn't know about assertWith
🙏
c710969
to
7890add
Compare
7890add
to
7efe1ee
Compare
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.
👍
propertyOnce $ moduleWorkspace "tmp" $ \tempDir -> do | ||
|
||
let outputDir = tempDir </> "out" | ||
totalSupply :: Int = 2000000000000 -- 2*10^12 |
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.
We need to start using NumericUnderscores
more
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.
Actually we do now for this file on main
🎉
|
||
let initialFunds = ListMap.toList $ L.sgInitialFunds genesis | ||
|
||
(length initialFunds) H.=== 1 |
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.
Some commentary would be useful here. Eg "This checks that there is actually only one funded address"
We can also introduce a variable e.g let fundedAddresses = 1
to make this even more clear.
-- The check below may seem weird, but we cannot do a very precise check | ||
-- on balances, because of the treasury "stealing" some of the money. | ||
-- Nevertheless, this check catches a confusion between delegated and | ||
-- non-delegated coins, by virtue of --delegated-supply being a fourth |
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.
This comment needs to be updated as #631 is closed
Changelog
Context
Fixes #631
How to trust this PR
cabal test cardano-cli-golden --test-options '-p "/golden create testnet data deleg non deleg/"'
) before the fix, witness the test failscardano-node
locallycardano-node
: Test of https://github.com/IntersectMBO/cardano-cli/pull/638, DO NOT MERGE cardano-node#5712Checklist