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

Throw an error on identical action-ids in votes of one voter #681

Merged
merged 2 commits into from
Mar 26, 2024

Conversation

smelc
Copy link
Contributor

@smelc smelc commented Mar 26, 2024

Changelog

- description: |
    transaction build{,-raw}: throw an error on identical action-ids in votes 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

Fixes #662

How to trust this PR

  • Run the new test before the main commit: cabal test cardano-cli-test --test-options '-p "/conway transaction build one voter many votes/"'
  • Witness the test fails because the CLI returns ExitSuccess
  • Run the same test after the main commit, witness the test passes: the CLI now fails.

Checklist

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

@smelc
Copy link
Contributor Author

smelc commented Mar 26, 2024

Question to reviewers:

@smelc smelc marked this pull request as draft March 26, 2024 10:33
@smelc smelc force-pushed the smelc/fix-same-action-id-vote-losing branch from 94b628a to e3d3cbd Compare March 26, 2024 10:36
@smelc smelc marked this pull request as ready for review March 26, 2024 10:36
@smelc smelc changed the title Throw an error on identical action-ids in votes files Throw an error on identical action-ids in votes of one voter Mar 26, 2024
@carbolymer
Copy link
Contributor

Question to reviewers:

Yes. Can be done in a separate PR.

@smelc smelc force-pushed the smelc/fix-same-action-id-vote-losing branch from 5f81d19 to 7857ae8 Compare March 26, 2024 13:18
@smelc smelc enabled auto-merge March 26, 2024 13:19
@smelc smelc added this pull request to the merge queue Mar 26, 2024
Merged via the queue into main with commit 644294c Mar 26, 2024
17 checks passed
@smelc smelc deleted the smelc/fix-same-action-id-vote-losing branch March 26, 2024 14:11
@smelc
Copy link
Contributor Author

smelc commented Mar 26, 2024

PR to move mergeVotingProcedures to cardano-api is at IntersectMBO/cardano-api#498

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.

👍

@@ -93,6 +93,7 @@ data TxCmdError
| TxCmdTxUpdateProposalValidationError TxUpdateProposalValidationError
| TxCmdScriptValidityValidationError TxScriptValidityValidationError
| TxCmdProtocolParamsConverstionError ProtocolParametersConversionError
| forall era. TxCmdTxGovDuplicateVotes (TxGovDuplicateVotes era)
Copy link
Contributor

Choose a reason for hiding this comment

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

We could avoid the existential by setting the crypto to StandardCrypto

mapb = L.unVotingProcedures (unVotingProcedures vpsb)
allVoters = Set.union (Map.keysSet mapa) (Map.keysSet mapb)
mergeVotesOfOneVoter acc voter =
Map.union acc <$> case (Map.lookup voter mapa, Map.lookup voter mapb) of
Copy link
Contributor

Choose a reason for hiding this comment

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

We should be able to us differenceWith here.

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.

[FR] - build-raw --vote-file should throw an error for identical action-ids in vote files
3 participants