Skip to content

Conversation

carbolymer
Copy link
Contributor

@carbolymer carbolymer commented Aug 22, 2025

Changelog

- description: |
    Use raw bytes representation instead of CBOR for CIP-129 identifier serialisation
# 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
  # - refactoring    # QoL changes
   - 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:

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

@carbolymer carbolymer self-assigned this Aug 22, 2025
@carbolymer carbolymer force-pushed the mgalazyn/fix/fix-cip129-credential-serialistaion branch 2 times, most recently from 8208b60 to 925d98f Compare August 26, 2025 12:52
@carbolymer carbolymer marked this pull request as ready for review August 26, 2025 12:57
@carbolymer carbolymer force-pushed the mgalazyn/fix/fix-cip129-credential-serialistaion branch 2 times, most recently from 4913e52 to cdc3dcd Compare August 26, 2025 13:10
@carbolymer carbolymer changed the title Fix cip129 cred serialisation Use raw bytes representation instead of CBOR for CIP-129 identifier serialisation Aug 26, 2025
instance Cip129 (Credential L.ColdCommitteeRole) where
cip129Bech32PrefixFor _ = unsafeHumanReadablePartFromText "cc_cold"
cip129Bech32PrefixesPermitted AsColdCommitteeCredential = ["cc_cold"]

cip129HeaderHexByte =
Copy link
Contributor

Choose a reason for hiding this comment

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

This should remain. It's explicit and it can be re-used instead of inlining it.

Copy link
Contributor Author

@carbolymer carbolymer Aug 28, 2025

Choose a reason for hiding this comment

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

It's not a very useful class field (?). You still have to duplicate the constants when serialising - there's no easy way to have a two-way mapping between headers to type constructors.

Copy link
Contributor

Choose a reason for hiding this comment

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

I prefer explicit over inlining here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've pushed a commit reusing headers instead of inlining them.


-- | CIP-129 decoding errors
data Cip129EncodingError
= CeeTypeDecodingError TypeRep BS.ByteString
Copy link
Contributor

Choose a reason for hiding this comment

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

What does Cee stand for?

Copy link
Contributor Author

@carbolymer carbolymer Aug 28, 2025

Choose a reason for hiding this comment

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

"Cip Encoding Error". I guess I could use C129ee but it felt too long and not bringing any additional information over Cee.

Copy link
Contributor

Choose a reason for hiding this comment

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

Why not just use Cip129 as the prefix? Cee is ambiguous.

@carbolymer carbolymer force-pushed the mgalazyn/fix/fix-cip129-credential-serialistaion branch 2 times, most recently from 0339def to 7da9b03 Compare September 2, 2025 10:43
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.

LGTM but read my comment. I think your prior changes were significantly more elegant and we can make the inlining more palatable by defining constants for the header bytes.

-- no decoded response, try codec
(_, Nothing) ->
\case
RawCodec Cip129RawCodec{decodeRaw} ->
Copy link
Contributor

Choose a reason for hiding this comment

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

This is a departure from the simplicity of the changes you made in the previous commit. It looks like you were trying to include the ability to define the Cip129 GovActionId instance and that's where the trouble begins because it doesn't have a header byte like the other items in Cip129.

In that case, I would stick with your prior commit's changes and just implement values (with haddocks) for the header bytes and reuse those values in the same inlining fashion.

@carbolymer carbolymer force-pushed the mgalazyn/fix/fix-cip129-credential-serialistaion branch 3 times, most recently from a3e0b4a to 3b484d7 Compare September 3, 2025 15:05
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.

Nice 👍

@carbolymer carbolymer force-pushed the mgalazyn/fix/fix-cip129-credential-serialistaion branch from 3b484d7 to 0a36317 Compare September 3, 2025 15:31
@carbolymer carbolymer enabled auto-merge September 3, 2025 15:32
@carbolymer carbolymer added this pull request to the merge queue Sep 3, 2025
Merged via the queue into master with commit 84635ee Sep 3, 2025
29 checks passed
@carbolymer carbolymer deleted the mgalazyn/fix/fix-cip129-credential-serialistaion branch September 3, 2025 16:18
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