Skip to content

Commit

Permalink
Fix PlutusDebugInfo deserialization
Browse files Browse the repository at this point in the history
  • Loading branch information
lehins committed Mar 27, 2023
1 parent 2cc8e1a commit 7305198
Showing 1 changed file with 10 additions and 15 deletions.
25 changes: 10 additions & 15 deletions eras/alonzo/impl/src/Cardano/Ledger/Alonzo/TxInfo.hs
Expand Up @@ -598,35 +598,30 @@ instance
EncCBOR (PlutusDebugLang l)
where
encCBOR (PlutusDebugLang slang costModel exUnits sbs pData protVer) =
let tag =
case slang of
SPlutusV1 -> 0
SPlutusV2 -> 1
in encode $
Sum PlutusDebugLang tag
!> To slang
!> E encodeCostModel costModel
!> To exUnits
!> To sbs
!> To pData
!> To protVer
encode $
Sum (PlutusDebugLang slang) (fromIntegral (fromEnum (fromSLanguage slang)))
!> E encodeCostModel costModel
!> To exUnits
!> To sbs
!> To pData
!> To protVer

instance
forall (l :: Language).
(Typeable l, IsLanguage l) =>
DecCBOR (PlutusDebugLang l)
where
decCBOR = decodeRecordSum "PlutusDebugLang" $ \tag -> do
let lang = fromSLanguage $ isLanguage @l
let slang = isLanguage @l
lang = fromSLanguage slang
when (fromEnum lang /= fromIntegral tag) $ fail $ "Unexpected language: " <> show tag
slang <- decCBOR
costModel <- decodeCostModelFailHard lang
exUnits <- decCBOR
sbs <- decCBOR
pData <- decCBOR
protVer <- decCBOR
-- We need to return a tuple here, with the size of the tag in bytes.
pure $ (1, PlutusDebugLang slang costModel exUnits sbs pData protVer)
pure $ (6, PlutusDebugLang slang costModel exUnits sbs pData protVer)

data PlutusDebug where
PlutusDebug :: (IsLanguage l, Typeable l) => PlutusDebugLang l -> PlutusDebug
Expand Down

0 comments on commit 7305198

Please sign in to comment.