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

Remove code repetition in Conway era CDDL #4178

Merged
merged 1 commit into from
Mar 11, 2024

Conversation

iccicci
Copy link
Contributor

@iccicci iccicci commented Mar 7, 2024

Description

protocol_version is defined as a group and always referred nested (alone) inside an array.

I introduced protocol_version_ with the purpose to not change protocol_version definition: I don't know if there are some reasons to keep the definitions unchanged between CDDL versions; if that's not the case and I was too scrupulous, we could simplify this PR removing protocol_version_ and changing protocol_version definition.

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. If you change the bounds in a cabal file, that package itself must have a version increase. (See RELEASING.md)
  • All visible changes are prepended to 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

@teodanciu
Copy link
Contributor

teodanciu commented Mar 7, 2024

I'm not convinced of the benefits of this change.
protocol_version_ name is a little inexpressive, in my opinion, for a singleton list of protocol_version (unless there is some convention I'm not aware of). So whenever it's encountered, it has to be looked up to understand what it is.
Maybe we could find a better name for it?

On the other hand, defining protocol_version itself as a singleton list doesn't seem right either - whereas it would reduce duplication, it can be misleading when reading the types that are referencing it.

But maybe I'm missing something - is this duplication creating problems in some ways that are not obvious? Just curious

@iccicci
Copy link
Contributor Author

iccicci commented Mar 7, 2024

On the other hand, defining protocol_version itself as a singleton list

From this sentence it seems there are no reasons to keep unchanged definitions between eras; if I am correct, I would prefer this option both for shortness and for clarity.

it can be misleading when reading the types that are referencing it.

I can't get the point here. Wouldn't it be just as any other defined type? Could you please elaborate? Thank you

protocol_version_ name is a little inexpressive...
Maybe we could find a better name for it?

For sure! Maybe protocol_version_obj or protocol_sem_ver or any other suggestion will be appreciated.
Anyway, until is possible to change the current definition of protocol_version, I would focus on that option.

is this duplication creating problems in some ways that are not obvious?

In my specific case, I spent more or less one hour trying to understand the reason for this repetition.. and I ended up opening this PR.
In cardano-js-sdk we started a process to make the SDK as compliant as possible to the Ledger: the presence of this repetition reflects in forcing us to replicate the repetition in SDK or to tolerate a discrepancy (if we want to avid the code repetition).

Thank you

Copy link
Collaborator

@lehins lehins left a comment

Choose a reason for hiding this comment

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

I don't know if there are some reasons to keep the definitions unchanged between CDDL versions; if that's not the case and I was too scrupulous, we could simplify this PR removing protocol_version_ and changing protocol_version definition.

I am all in favor of this suggestion.

eras/conway/impl/cddl-files/conway.cddl Outdated Show resolved Hide resolved
@iccicci
Copy link
Contributor Author

iccicci commented Mar 7, 2024

is this duplication creating problems in some ways that are not obvious?

Please let me elaborate my thought about this question.

This document is not an end in itself, it is the refernce for thousands of other projects. For this reason, in my opinion, it should be kept as clear and minimal as possible.

If I may allow one more suggestion, I would move the big comment it has in its middle to a README.md file changing the big comment with a short comment with just a link referencing the section of the chosen README.

@teodanciu
Copy link
Contributor

Thank you for the explanation @iccicci, I concede to the non-indirection approach that you and Alexey suggested, as my concern seems indeed unfounded.

@teodanciu
Copy link
Contributor

Rebased against master

Copy link
Contributor

@teodanciu teodanciu left a comment

Choose a reason for hiding this comment

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

Looks good to me

@teodanciu teodanciu merged commit 983ebe6 into IntersectMBO:master Mar 11, 2024
13 of 17 checks passed
iccicci added a commit to input-output-hk/cardano-js-sdk that referenced this pull request Mar 14, 2024
iccicci added a commit to input-output-hk/cardano-js-sdk that referenced this pull request Mar 18, 2024
iccicci added a commit to input-output-hk/cardano-js-sdk that referenced this pull request Mar 19, 2024
rooooooooob added a commit to dcSpark/cardano-multiplatform-lib that referenced this pull request Mar 28, 2024
SebastienGllmt pushed a commit to dcSpark/cardano-multiplatform-lib that referenced this pull request May 1, 2024
* New Conway.cddl updates (cml-chain/cml-chain-wasm)

Includes:
* IntersectMBO/cardano-ledger#4003
* IntersectMBO/cardano-ledger#4178
* IntersectMBO/cardano-ledger#4055
* IntersectMBO/cardano-ledger#4117
* IntersectMBO/cardano-ledger#4040

TODO:

[ ] need to check how this affects the script data hash and test that
[ ] multi-era

* conway multi-era update + various fixes

* resolve merge conflict

* use conway costmodels for all eras (babbage costmdls found in alonzo on sancho testnet)

* IntoIter for NonemptySet<T>
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.

3 participants