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

Fix the printing of RawPlutusData #301

Merged
merged 2 commits into from
Feb 17, 2024

Conversation

nielstron
Copy link
Contributor

Some recent change in the codebase led to pretty printing of Raw Plutus Data to invoke a pretty printer. This is problematic for two reasons:

  • OpShin mimiced the behaviour of PyCardano to print RawPlutusData in the most precise way possible
  • The pretty printer re-orders dictionaries (i.e. sorts them). This may lead to the representation of the dictionary not being faithful to the original representation anymore (specifically, could lead to a different CBOR hex)

Another way to tackle this might be to change the behaviour of the pretty printer (inherited from CBORSerializable) to not sort entries in dictionaries anymore (as this could also break CBOR matching)

@codecov-commenter
Copy link

codecov-commenter commented Feb 4, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (df5ba28) 84.51% compared to head (24ed180) 84.51%.
Report is 1 commits behind head on main.

❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #301   +/-   ##
=======================================
  Coverage   84.51%   84.51%           
=======================================
  Files          27       27           
  Lines        3093     3093           
  Branches      758      758           
=======================================
  Hits         2614     2614           
  Misses        358      358           
  Partials      121      121           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@cffls
Copy link
Collaborator

cffls commented Feb 6, 2024

You can also try removing this decorator from the class definition:

# @dataclass(repr=False) <------ this line forces it to the repr from parent class, which uses pretty print.
class RawPlutusData(CBORSerializable):

@nielstron
Copy link
Contributor Author

Yes that did the trick! Thanks

@nielstron nielstron merged commit 58e0cb2 into Python-Cardano:main Feb 17, 2024
11 checks passed
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