aiken-lang / aiken

A modern smart contract platform for Cardano
https://aiken-lang.org
Apache License 2.0
477 stars 94 forks source link

Dict deserialization issue #289

Closed alessandrokonrad closed 1 year ago

alessandrokonrad commented 1 year ago

Trying to access values in a dict that are something else than of the PlutusData type Map leads to deserialization errors during runtime. The code compiles fine although.

Example to reproduce:

type RoyaltyToken {
  policy_id: PolicyId,
  asset_name: AssetName,
}

let m =
  dict.new()
  |> dict.insert(
    #[1, 2, 3],
    RoyaltyToken { policy_id: #[1, 2, 3], asset_name: #[3, 4, 5] },
  )
let r = dict.get(m, #[1, 2, 3])

Error during runtime (Aiken or Haskell Plutus core runtime yield the same result):

Redeemer (Spend, 0): Failed to deserialise PlutusData using UnMapData:

Con(
    Data(
        Constr(
            Constr {
                tag: 121,
                any_constructor: None,
                fields: [
                    BoundedBytes(
                        PlutusBytes(
                            [
                                1,
                                2,
                                3,
                            ],
                        ),
                    ),
                    BoundedBytes(
                        PlutusBytes(
                            [
                                3,
                                4,
                                5,
                            ],
                        ),
                    ),
                ],
            },
        ),
    ),
)

ExBudget {
    mem: 12872168,
    cpu: 9581324425,
}
MicroProofs commented 1 year ago

Closed by #295