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

Improve witness needed logic #3425

Merged
merged 4 commits into from
May 15, 2023
Merged

Conversation

lehins
Copy link
Collaborator

@lehins lehins commented May 13, 2023

Description

Abstract deciding which certificates require witnesses.

Certificates structure has changed in Conway, because of that old logic,
even with backwards compatibility translation, will not work correctly.
In particular, some new certificates did not require a witness, where
they should have required one. Abstracting the logic by adding
getVKeyWitnessTxCert and getScriptWitnessTxCert to EraTxCert we
can solve this problem with different implemnetation on per era basis.
This also opens up an opportunitiy for deduplication implemented in
a subsequent commit.

Make registration certificates with deposits require witnesses

It was discusses during a meeting that it was an unfortunate requirement
in Shelley to not enforce a witness for staking credential registration.
It was implemented to allow ITIN rewards, which is not a feature anymore.
Therefore this is no longer a necessary requirement and it was decided
to change this by enforcing a wtiness for registration certificates, but
only for the ones that contain a deposit. This would mean that we can
keep backwards compatibility throughout Conway, but in the next era it
will become a proper requirement.

Reduce duplication by consolidatiing two versions of witsVKeyNeeded

Implementations in Shelley and Alonzo were almost identical.

Avoid usage of partial functions

In three different places error call was removed by improving the logic.

Checklist

  • Commit sequence broadly makes sense and commits have useful messages
  • New tests are added if needed and existing tests are updated
  • When applicable, versions are updated in .cabal and CHANGELOG.md files according to the
    versioning process.
  • The version bounds in .cabal files for all affected packages are updated (See RELEASING.md)
  • Any changes are noted in the latest section of a CHANGELOG.md for the affected packages. New section is never added with the code changes. (See RELEASING.md)
  • Code is formatted with fourmolu (use scripts/fourmolize.sh)
  • Cabal files are formatted (use scripts/cabal-format.sh)
  • hie.yaml has been updated (use scripts/gen-hie.sh)
  • Self-reviewed the diff

@JaredCorduan
Copy link
Contributor

nice clean up!

@lehins lehins force-pushed the lehins/improve-witness-needed-logic branch from 47b8dfc to cbf3c57 Compare May 15, 2023 15:15
@lehins lehins marked this pull request as ready for review May 15, 2023 16:43
@lehins lehins force-pushed the lehins/improve-witness-needed-logic branch 2 times, most recently from 7db1dee to db5eac7 Compare May 15, 2023 17:11
Copy link
Contributor

@JaredCorduan JaredCorduan left a comment

Choose a reason for hiding this comment

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

Looks great, much cleaner and safer!

lehins added 4 commits May 15, 2023 21:13
Certificates structure has changed in Conway, because of that old logic,
even with backwards compatibility translation, will not work correctly.
In particular, some new certificates did not require a witness, where
they should have required one. Abstracting the logic by adding
`getVKeyWitnessTxCert` and `getScriptWitnessTxCert` to `EraTxCert` we
can solve this problem with different implemnetation on per era basis.
This also opens up an opportunitiy for deduplication implemented in
a subsequent commit.
It was discusses during a meeting that it was an unfortunate requirement
in Shelley to not enforce a witness for staking credential registration.
It was implemented to allow ITIN rewards, which is not a feature anymore.
Therefore this is no longer a necessary requirement and it was decided
to change this by enforcing a wtiness for registration certificates, but
only for the ones that contain a deposit. This would mean that we can
keep backwards compatibility throughout Conway, but in the next era it
will become a proper requirement.
Implementations in Shelley and Alonzo were almost identical.
@lehins lehins force-pushed the lehins/improve-witness-needed-logic branch from db5eac7 to 6c4c3c7 Compare May 15, 2023 18:14
@lehins lehins enabled auto-merge May 15, 2023 18:14
@lehins lehins merged commit a6a24c1 into master May 15, 2023
@iohk-bors iohk-bors bot deleted the lehins/improve-witness-needed-logic branch May 15, 2023 20:13
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