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

Read and write VotingProcedures files instead of VotingEntry files #203

Conversation

newhoggy
Copy link
Contributor

@newhoggy newhoggy commented Aug 24, 2023

Changelog

- description: |
    Read and write `VotingProcedures` files instead of `VotingEntry` files
# 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

Using VotingProcedures as the serialisation types allows us to use ledger's serialisation rather than our own.

This PR converts the IO code to use VotingProcedures. The conversion is not complete because TxBodyContent still has a TxVotes member.

A subsequent PR in cardano-api will switch that out.

Checklist

  • Commit sequence broadly makes sense and commits have useful messages
  • The change log section in the PR description has been filled in
  • New tests are added if needed and existing tests are updated. These may include:
    • golden tests
    • property tests
    • round trip tests
    • integration tests
      See Running tests for more details
  • The version bounds in .cabal files are updated
  • CI passes. See note on CI. The following CI checks are required:
    • Code is linted with hlint. See .github/workflows/check-hlint.yml to get the hlint version
    • Code is formatted with stylish-haskell. See .github/workflows/stylish-haskell.yml to get the stylish-haskell version
    • Code builds on Linux, MacOS and Windows for ghc-8.10.7 and ghc-9.2.7
  • The changelog section in the PR is updated to describe the change
  • Self-reviewed the diff

@newhoggy newhoggy marked this pull request as ready for review August 24, 2023 12:10
@newhoggy newhoggy force-pushed the newhoggy/write-voting-procedures-files-instead-of-voting-entry-files branch 2 times, most recently from f51b4f6 to 620ab70 Compare August 24, 2023 12:56
@newhoggy newhoggy changed the title Write voting procedures files instead of voting entry files Read and write VotingProcedures files instead of VotingEntry files Aug 24, 2023
@newhoggy newhoggy force-pushed the newhoggy/write-voting-procedures-files-instead-of-voting-entry-files branch from 620ab70 to f13871d Compare August 24, 2023 13:05
$ Ledger.VotingProcedures
$ Map.unionWith (Map.unionWith const)
(Ledger.unVotingProcedures (unVotingProcedures vpsa))
(Ledger.unVotingProcedures (unVotingProcedures vpsb))
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The above three functions can be moved into cardano-api. Having it here proves it works and is useful.

Copy link
Contributor

@Jimbo4350 Jimbo4350 Aug 24, 2023

Choose a reason for hiding this comment

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

We can leave them here in this PR but we should move them to cardano-api so others can use them without depending on cardano-cli.

@newhoggy newhoggy force-pushed the newhoggy/write-voting-procedures-files-instead-of-voting-entry-files branch 2 times, most recently from 585ba7d to c634daa Compare August 24, 2023 13:08
Ledger.DRepVoter cred ->
VoterDRep (VotingCredential cred)
Ledger.StakePoolVoter kh ->
VoterSpo (StakePoolKeyHash kh)
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 can be deleted when votingProceduresToTxVotes is deleted.

Copy link
Contributor

Choose a reason for hiding this comment

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

This can be deleted in a follow up PR 👍

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.

LGTM! 👍

@@ -31,41 +32,34 @@ runGovernanceCreateVoteCmd
-> ExceptT GovernanceCmdError IO ()
runGovernanceCreateVoteCmd anyEra vChoice vType (govActionTxId, govActionIndex) votingStakeCred oFp = do
Copy link
Contributor

@Jimbo4350 Jimbo4350 Aug 24, 2023

Choose a reason for hiding this comment

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

We should deprecate this command (in a separate PR) as we are maintaining two vote creation commands and this one doesn't allow vote creation for DReps or committee members.

let voter = Ledger.DRepVoter (unVotingCredential votingCred)
govActIdentifier = createGovernanceActionId govActionTxId govActionIndex
voteProcedure = createVotingProcedure sbe vChoice Nothing
votingProcedures = singletonVotingProcedures sbe voter govActIdentifier (unVotingProcedure voteProcedure)
Copy link
Contributor

Choose a reason for hiding this comment

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

Not for this PR but there is no reason why we shouldn't allow multiple voting files to be added to a tx.

$ Ledger.VotingProcedures
$ Map.unionWith (Map.unionWith const)
(Ledger.unVotingProcedures (unVotingProcedures vpsa))
(Ledger.unVotingProcedures (unVotingProcedures vpsb))
Copy link
Contributor

@Jimbo4350 Jimbo4350 Aug 24, 2023

Choose a reason for hiding this comment

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

We can leave them here in this PR but we should move them to cardano-api so others can use them without depending on cardano-cli.

Ledger.DRepVoter cred ->
VoterDRep (VotingCredential cred)
Ledger.StakePoolVoter kh ->
VoterSpo (StakePoolKeyHash kh)
Copy link
Contributor

Choose a reason for hiding this comment

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

This can be deleted in a follow up PR 👍

@newhoggy newhoggy force-pushed the newhoggy/write-voting-procedures-files-instead-of-voting-entry-files branch from c634daa to ae987a9 Compare August 25, 2023 14:29
@newhoggy newhoggy force-pushed the newhoggy/write-voting-procedures-files-instead-of-voting-entry-files branch from ae987a9 to 89af843 Compare August 25, 2023 14:36
@newhoggy newhoggy requested review from a team as code owners August 25, 2023 14:36
@newhoggy newhoggy force-pushed the newhoggy/write-voting-procedures-files-instead-of-voting-entry-files branch from 89af843 to fc76402 Compare August 25, 2023 14:45
@newhoggy newhoggy added this pull request to the merge queue Aug 25, 2023
Merged via the queue into main with commit 2e5538a Aug 25, 2023
19 checks passed
@newhoggy newhoggy deleted the newhoggy/write-voting-procedures-files-instead-of-voting-entry-files branch August 25, 2023 15:18
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.

None yet

2 participants