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

Update big-arg fixtures after CSL is replaced by CDL #1673

Closed
wants to merge 3 commits into from

Conversation

rmgaray
Copy link
Collaborator

@rmgaray rmgaray commented Feb 4, 2025

This should be merged after (or together) with the WIP branch authored by @marcusbfs that will replace CSL with CDL. I am opening a separate PR for the fixtures update so that it can be evaluated separately why these changes are necessary.

Why is this change necessary

CDL is meant to be a drop-in replacement for CSL, but that doesn't mean its serializing behaviour is exactly the same. In some scenarios, CDL will output CBOR that is slightly different to the one produced by CSL. The reason is that CDL has other (equally valid) defaults when creating certain transaction components.

This doesn't mean that CDL is incompatible with CSL. In particular, CDL guarantees that cbor == cdl.serialize(cdl.deserialize(cbor)) for all CBOR, even for CBOR that was created by another library (the "roundtrip" property). The differences in encoding are seen when the component that is to be serialized is created from scratch using one of CDL's classes, since CDL does not promise to emulate the behavour of CSL's constructors. Example: cdl.TransactionWitnessSet.new(...).to_hex() != csl.TransactionWitnessSet.new(...).to_hex().

The specific change in the big_arg fixtures

In the Test.Ctl.ApplyArgs module a set of different arguments is applied to a variety of scripts. One of these arguments, called big_arg, has changed its encoding with the CDL update. Specifically, the CBOR arrays contained inside the PlutusData now have a definite length encoding vs the indefinite length encoding used before (CBOR spec on this topic).

New big-arg
[
    7,
    121_0([]),
    [121_0([]), h'4d5f'],
    h'4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d',
    {5: 7, h'4d5f': 8},
    102_0([
        102_0,
        [
            7,
            [
                121_0([]),
                h'4d5f',
                h'4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d',
            ],
        ],
    ]),
    126_0([
        [],
        [1],
        {},
        {1: 121_0([]), 2: 123_0([2])},
    ]),
]
Old big-arg:
[_
    7,
    121_0([]),
    [_ 121_0([]), h'4d5f'],
    (_
        h'4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d',
        h'4d',
    ),
    {5: 7, h'4d5f': 8},
    1375_1([_
        7,
        [_
            121_0([]),
            h'4d5f',
            (_
                h'4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d',
                h'4d',
            ),
        ],
    ]),
    126_0([_
        [],
        [_ 1],
        {},
        {1: 121_0([]), 2: 123_0([_ 2])},
    ]),
]

(Notice the underscore after the initial square bracket ([ _ ...) - this is syntax for indefinite length arrays)

When applying the new encoding of big-arg to the same scripts, we obtain very similar applied scripts with:

  1. A different length (which is reflected in the bytearray headers contained inside the script)
  2. A different big-arg (the changes in the array encoding are also seen inside each applied script)

This can be seen if we inspect the diff of an applied script with respect to master:

Git diff
$ git diff master fixtures/scripts/applied/always-fails-big-arg.plutus
diff --git a/fixtures/scripts/applied/always-fails-big-arg.plutus b/fixtures/scripts/applied/always-fails-big-arg.plutus
index 6af8b3a3f..8b7c37e6c 100644
--- a/fixtures/scripts/applied/always-fails-big-arg.plutus
+++ b/fixtures/scripts/applied/always-fails-big-arg.plutus
@@ -1,5 +1,5 @@
 {
     "type": "PlutusScriptV1",
     "description": "",
-    "cborHex": "58ff58fd0100003333333332232322223500400712350023530030014984984800480053010107004c0103d87980004c01089fd87980424d5fff004c01465f58404d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d414dff004c0107a20507424d5f08004c0154d9055f9f079fd87980424d5f5f58404d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d414dffffff004c0114d87e9f809f01ffa0a201d8798002d87b9f02ffff0001"
+    "cborHex": "59010158ff0100003333333332232322223500400712350023530030014984984800480053010107004c0103d87980004c01089fd87980424d5fff004c01465f58404d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d414dff004c0107a20507424d5f08004c0156d8668218669f079fd87980424d5f5f58404d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d414dffffff004c0114d87e9f809f01ffa0a201d8798002d87b9f02ffff0001"
 }

First we see a change in length for the first two bytearray headers (58ff58fd becomes 59010158ff) followed by a change in the big-arg that is stored within the script itself. All updated fixtures contain essentially the same changes.

Pre-review checklist

  • All code has been formatted using our config (make format)
  • Any new API features or modification of existing behavior are covered with tests
  • The template (templates/ctl-scaffold) has been updated
  • The changelog has been updated under the ## Unreleased header, using the appropriate sub-headings (### Added, ### Changed, ### Removed, ### Fixed), and the links to the appropriate issues/PRs have been included

@rmgaray rmgaray changed the title Update big-arg fixtures after CSL replacement by CDL Update big-arg fixtures after CSL is replaced by CDL Feb 4, 2025
@itsfarseen
Copy link
Contributor

This is now fixed in CDL itself.
Ref:
mlabs-haskell/cardano-data-lite#36
mlabs-haskell/cardano-data-lite#37

@rmgaray rmgaray closed this Feb 14, 2025
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