Skip to content

Support Plutus V4 CBOR tag in AlonzoScript decoder#5567

Open
Onyinyechi46 wants to merge 1 commit intoIntersectMBO:masterfrom
Onyinyechi46:master
Open

Support Plutus V4 CBOR tag in AlonzoScript decoder#5567
Onyinyechi46 wants to merge 1 commit intoIntersectMBO:masterfrom
Onyinyechi46:master

Conversation

@Onyinyechi46
Copy link

Motivation
The encoder for AlonzoScript uses tag 4 for Plutus V4, but the decoder did not handle tag 4, which can cause valid Plutus V4 scripts to be rejected when decoding.
Description
Add 4 -> decodeAnnPlutus SPlutusV4 to the decodeScript function in eras/alonzo/impl/src/Cardano/Ledger/Alonzo/Scripts.hs so decoding matches the encoder's tags.
Testing
No automated tests were run for this trivial decoder fix.

@Onyinyechi46 Onyinyechi46 requested a review from a team as a code owner February 9, 2026 12:45
@teodanciu
Copy link
Contributor

Could you please also update the non-Annotator version of the decoder? https://github.com/IntersectMBO/cardano-ledger/blob/master/eras/alonzo/impl/testlib/Test/Cardano/Ledger/Alonzo/Binary/Annotator.hs#L300

Also, it would be good to have a more descriptive commit message like
"Add PlutusV4 to AlonzoScript decoder".

@Soupstraw
Copy link
Contributor

We probably don't want it to be decodable before protocol version 12, so there should be some guards to ensure that decoding fails in earlier versions. @lehins

@lehins
Copy link
Collaborator

lehins commented Feb 18, 2026

We probably don't want it to be decodable before protocol version 12, so there should be some guards to ensure that decoding fails in earlier versions. @lehins

@Soupstraw There is one. It is checked for each Language/EraProtVerLow pair here:

guardPlutus :: Language -> Decoder s ()
guardPlutus lang =
let v = case lang of
PlutusV1 -> natVersion @5
PlutusV2 -> natVersion @7
PlutusV3 -> natVersion @9
PlutusV4 -> natVersion @12
in unlessDecoderVersionAtLeast v $
fail (show lang <> " is not supported until " <> show v <> " major protocol version")

It would probably be better to pass this function the actual era and derive the protocol version this way, but for now this is ok and this PR is safe in that perspective

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