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: correctly compute set of credentials delegating votes to a drep in conway genesis #943

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

smelc
Copy link
Contributor

@smelc smelc commented Oct 17, 2024

Changelog

- description: |
    create-testnet-data: correctly compute set of credentials delegating votes to a drep in conway genesis
# 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
  # - refactoring    # QoL changes
  - 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

There was uncertainty (see this thread on Slack and here on GitHub) when fixing some part of create-testnet-data when writing #940. Because we wanted to merge 940 fast, we proceeded leaving an incorrect value in create-testnet-data's conway genesis, in the presence of dreps; because we needed to synchronize with the ledger team to understand what to do.

This PR corrects the incorrect value.

How to trust this PR

Here is a before and after comparison of the conway genesis created by create-testnet-data:

image

On the left, one can see that the delegators fields of the initialDReps are all left empty. But this is incorrect: the field delegs (above in the screenshot) show that indeed there are votes delegations happening.

On the right, you can see that the delegators fields are populated with values corresponding to the ones in delegs ✔️

Checklist

  • Commit sequence broadly makes sense and commits have useful messages
  • Self-reviewed the diff

:: [(VerificationKey StakeKey, VerificationKey DRepKey)]
-> ListMap (L.Credential L.Staking L.StandardCrypto) (L.Delegatee L.StandardCrypto)
-- The credential, to the drep it delegates to
delegs :: [(L.Credential L.Staking L.StandardCrypto, VerificationKey DRepKey)]
delegs =
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Note to @palas: this new delegs value is like the old cgDelegs one, except that it doesn't hardcode applying some constructors right away in nested positions. This allows to use delegs at the source for computing cgDelegs and cgInitialDReps. This is important to make sure we are consistent between the two.

@smelc smelc force-pushed the smelc/fix-create-testnet-data-conway-genesis-vote-delegation branch from 14c29a8 to 1a46427 Compare October 17, 2024 18:36
Copy link
Contributor

@Jimbo4350 Jimbo4350 left a comment

Choose a reason for hiding this comment

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

Great work. The screenshot was perfection 👌.

@Jimbo4350 Jimbo4350 self-requested a review October 17, 2024 19:54
)
map
(first verificationKeytoStakeCredential)
(zip stakingKeys (case dRepKeys of [] -> []; _ -> cycle dRepKeys))
Copy link
Contributor

Choose a reason for hiding this comment

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

This is problematic and thankfully it showed up in the tests:

/out/conway-genesis.json
        149 ┃ 
        150 ┃     length (cgInitialDReps conwayGenesis) H.=== numDReps
            ┃     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
            ┃     │ ━━━ Failed (- lhs) (+ rhs) ━━━
            ┃     │ - 4
            ┃     │ + 5
        151 ┃ 
        152 ┃     length (cgDelegs conwayGenesis) H.=== numStakeDelegs

We have: numStakeDelegs = 4 and

numDReps :: Int
numDReps = 5

Because we use zip the 5th drep is ignored because there is no stake key to delegate to it. We must therefore take into consideration dreps with no delegators.

@Jimbo4350 Jimbo4350 force-pushed the smelc/fix-create-testnet-data-conway-genesis-vote-delegation branch from c35b0a8 to 667ea29 Compare October 17, 2024 20:16
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.

2 participants