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

Quick fix for #1561 #1562

Merged

Conversation

Quantumplation
Copy link
Contributor

Context

See #1561

Proposed Solution

This is a quick fix, which matches the conditionals in toCbor to the conditionals in getMapSize; See #1561 and commit message for a more robust approach.

Important Changes Introduced

@AngelCastilloB
Copy link
Member

AngelCastilloB commented Jan 17, 2025

Thanks for the PR @Quantumplation, the fix LGTM. We use conventional commits on the repo since we pull release notes automatically from it, could you rename the first line of the commit to something like:

fix: resolve invalid CBOR serialization for maps in transaction object with falsy elements

Or similar? thanks!

@Quantumplation Quantumplation force-pushed the pi/1561/cbor-issues branch 4 times, most recently from 6445af9 to d1c3dc0 Compare January 17, 2025 04:46
This is a very quick fix for input-output-hk#1561

Because the conditions used in `getMapSize` don't match those used in
`toCbor`, the cbor can end up invalid: for example, the map size could
be written as 8, but then only 7 values are written, if totalCollateral
is 0, for example.

A more robust solution would be to extend CborWriter to maintain a stack
of buffers, and add `startDefiniteLengthMap` and `endDefiniteLengthMap`
methods. However, we're currently blocked by this, so I did the quickest
thing possible.
@Quantumplation
Copy link
Contributor Author

Ok there we go; sorry about the noise, couldn't get the signed commit working because of a mismatched email 😅

Copy link
Member

@AngelCastilloB AngelCastilloB left a comment

Choose a reason for hiding this comment

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

Thanks for the contribution @Quantumplation ❤️ LGTM

@AngelCastilloB
Copy link
Member

Ok there we go; sorry about the noise, couldn't get the signed commit working because of a mismatched email 😅

We need one more review, the team should be getting online in a few hours, once CI is green and we get the additional review, I will merge and cut a new release

@Quantumplation
Copy link
Contributor Author

Thank you Angel! fwiw the reason this came up is because of some work we're doing for the Hydra Doom tournament next week :)

@AngelCastilloB
Copy link
Member

Thank you Angel! fwiw the reason this came up is because of some work we're doing for the Hydra Doom tournament next week :)

Awesome stuff!, I figured as much. I have was looking the other day at the hydra provider yHSJ added to Blaze butaneprotocol/blaze-cardano#230. Really cool, I will try to port this provider to cardano-c when I have some spare time :)

Copy link
Member

@mkazlauskas mkazlauskas left a comment

Choose a reason for hiding this comment

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

Hi, thank you for contribution! ❤️ Would be great to add some unit test. A simplest one is a roundtrip test - would it reproduce #1561?

@Quantumplation
Copy link
Contributor Author

Given that this is time sensitive, and I'm unfamiliar with the codebase, can we merge without the test or could I ask you to write a test for it? I'm happy to follow up, get familiar with the testing framework, and add a test once we've got things shored up and working for our deadline 😅

Copy link
Collaborator

@mirceahasegan mirceahasegan left a comment

Choose a reason for hiding this comment

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

Working on a test. Should be done shortly...

mirceahasegan

This comment was marked as duplicate.

Copy link
Collaborator

@mirceahasegan mirceahasegan left a comment

Choose a reason for hiding this comment

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

Please cherry-pick a few more fixes and the unit tests from bb617b8 @Quantumplation .
I pushed them to this branch pr/Quantumplation/1562-sdk-tests

I will merge the updates separately. Good to go. Fantastic work @Quantumplation 🚀

@mirceahasegan mirceahasegan merged commit 9cab9e7 into input-output-hk:master Jan 17, 2025
9 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.

4 participants