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

create-testnet-data: better UX for supply arguments #581

Merged
merged 5 commits into from
Feb 5, 2024

Conversation

smelc
Copy link
Contributor

@smelc smelc commented Jan 19, 2024

Changelog

- description: |
    create-testnet-data: better UX for supply arguments: have a flag for total supply and delegated supply is a fraction of that.
# uncomment types applicable to the change:
  type:
  # - feature        # introduces a new feature
  - breaking       # the API has changed in a breaking way
  # - compatible     # the API has changed but is non-breaking
  # - optimisation   # measurable performance improvements
  # - improvement    # QoL changes e.g. refactoring
  # - bugfix         # fixes a defect
  # - test           # fixes/modifies tests
  # - maintenance    # not directly related to the code
  # - release        # related to a new release preparation
  # - documentation  # change in code docs, haddocks...

Context

As discussed with @CarlosLopezDeLara, the UI for --supply and --supply-delegated in create-staked was counter-intuitive. As @Jimbo4350 requested here, we can seize the occasion of introducing create-testnet-data to improve.

Corresponding cardano-node PR: IntersectMBO/cardano-node#5646

Fixes #574

How to trust this PR

Checklist

  • Commit sequence broadly makes sense and commits have useful messages
  • NA New tests are added if needed and existing tests are updated. See Running tests for more details
  • Self-reviewed the diff

@smelc smelc force-pushed the smelc/create-testnet-data-rework-supply-arguments branch from 86c135d to f87de12 Compare January 24, 2024 10:59
@smelc smelc force-pushed the smelc/create-testnet-data-rework-supply-arguments branch from f87de12 to af8d6bf Compare January 24, 2024 14:24
@smelc smelc changed the base branch from main to smelc/fix-create-testnet-data-readme-failures January 24, 2024 14:24
@smelc smelc mentioned this pull request Jan 24, 2024
6 tasks
@smelc smelc force-pushed the smelc/fix-create-testnet-data-readme-failures branch from 93f3929 to e83e4ec Compare January 25, 2024 13:16
Base automatically changed from smelc/fix-create-testnet-data-readme-failures to main January 25, 2024 15:10
@smelc smelc force-pushed the smelc/create-testnet-data-rework-supply-arguments branch from af8d6bf to d0c60ea Compare January 26, 2024 08:31
@smelc smelc marked this pull request as ready for review January 29, 2024 09:47
, supply :: !(Maybe Lovelace) -- ^ The number of Lovelace to distribute over initial, non-delegating stake holders.
, supplyDelegated :: !(Maybe Lovelace) -- ^ The number of Lovelace to distribute over delegating stake holders.
, totalSupply :: !(Maybe Lovelace) -- ^ The total number of Lovelace
, delegatedSupply :: !(Maybe Lovelace) -- ^ The number of Lovelace being delegated
Copy link
Contributor

Choose a reason for hiding this comment

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

Much more understandable 👍🏻

Copy link
Contributor

Choose a reason for hiding this comment

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

does total supply indicate total maximum possible supply?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Humm not sure what you mean. totalSupply indicates the entire amount of currency in the testnet being created IIUC.

@smelc smelc force-pushed the smelc/create-testnet-data-rework-supply-arguments branch from 289d218 to 7c7f6cf Compare January 29, 2024 12:57
@@ -660,6 +661,75 @@ runGenesisCreateStakedCmd

-- -------------------------------------------------------------------------------------------------

updateOutputTemplate
Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@carbolymer> It's not duplicated: the code you refer to was previously shared was previously used both by create-staked and create-testnet-data. To keep create-staked's existing behavior, I unshared it, by copying the preexisting version to create-staked's file.

Copy link
Contributor

Choose a reason for hiding this comment

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

There's a lot of similar code, like utilities in where. Especially this funds distribution part:

                                distribute (nonDelegCoin - subtractForTreasury) nUtxoAddrsNonDeleg  utxoAddrsNonDeleg
                                ++
                                distribute (delegCoin - subtractForTreasury)    nUtxoAddrsDeleg     utxoAddrsDeleg
                                ++
                                mkStuffedUtxo stuffedUtxoAddrs

Can you de-duplicate parts of this function?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Since we don't want to change behavior of create-staked and don't plan on improving it, I am more in favor of duplicating, so that we have ours hand more free for changing create-testnet-data in the future; if you don't mind.

Copy link
Contributor

Choose a reason for hiding this comment

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

I'm in favour of de-duplicating. I'm un-requesting changes. @Jimbo4350 your call.

Copy link
Contributor

Choose a reason for hiding this comment

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

Let's focus on create-testnet-data for now. Benchmarking depends on create-staked. We can revisit in the future and clean it up. I would rename it to something create testnet data specific though.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This function is not exported by the module, so I think its name doesn't need to be create-testnet-data specific.

Comment on lines +10 to +11
[--total-supply LOVELACE]
[--delegated-supply LOVELACE]
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
[--total-supply LOVELACE]
[--delegated-supply LOVELACE]
[--supply-total LOVELACE]
[--supply-delegated LOVELACE]

I think supply prefix may be more intuitive. I'm not sure - current version is fine too.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Actually I agree with you, but I chose to stay consistent with the existing flags, e.g. in --drep-keys, --utxo-keys, and --genesis-keys; the prefix is the disambiguation. By having --supply-total and --supply-delegated, I stick to this convention 🤷

Copy link
Contributor

@carbolymer carbolymer left a comment

Choose a reason for hiding this comment

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

@carbolymer carbolymer dismissed their stale review January 29, 2024 15:28

Not blocking on de-duplication

delegCoin = maybe 0 fromIntegral amountDeleg
totalSupply, nonDelegCoin, delegCoin :: Integer
-- if --total-supply is not specified, supply comes from the template passed to this function:
totalSupply = fromIntegral (maybe maximumLovelaceSupply unLovelace mTotalSupply)
Copy link
Contributor

Choose a reason for hiding this comment

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

Why not modify: sgMaxLovelaceSupply = fromIntegral $ nonDelegCoin + delegCoin
to sgMaxLovelaceSupply = totalSupply

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good catch, done 👍

@@ -660,6 +661,75 @@ runGenesisCreateStakedCmd

-- -------------------------------------------------------------------------------------------------

updateOutputTemplate
Copy link
Contributor

Choose a reason for hiding this comment

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

Let's focus on create-testnet-data for now. Benchmarking depends on create-staked. We can revisit in the future and clean it up. I would rename it to something create testnet data specific though.

@Jimbo4350 Jimbo4350 self-requested a review February 1, 2024 22:21
nonDelegCoin = totalSupply - delegCoin
totalSupply = maybe maximumLovelaceSupply unLovelace mTotalSupply
totalSupply', delegCoin, nonDelegCoin :: Integer
totalSupply' = fromIntegral totalSupply
Copy link
Contributor

Choose a reason for hiding this comment

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

I would remove totalSupply' and call fromIntegral within the definitions of other variables.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done 👍

@smelc smelc force-pushed the smelc/create-testnet-data-rework-supply-arguments branch from d3e6c97 to 303afd8 Compare February 2, 2024 19:25
@smelc smelc force-pushed the smelc/create-testnet-data-rework-supply-arguments branch from 303afd8 to 8c399c9 Compare February 5, 2024 09:47
@smelc smelc enabled auto-merge February 5, 2024 09:47
@smelc smelc added this pull request to the merge queue Feb 5, 2024
Merged via the queue into main with commit 67e410a Feb 5, 2024
14 checks passed
@smelc smelc deleted the smelc/create-testnet-data-rework-supply-arguments branch February 5, 2024 10:23
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.

create-testnet-data/create-staked: Augment documentation of --supply and --supply-delegated flags
3 participants