Skip to content

Test/fix chest ty decompile val

Rémi requested to merge test/fix-chest-ty-decompile-val into dev

Problem

Fixing a bug where chest and chest_key were not decompiled (interpreter value to michelson_value) correctly because their type were bytes instead of chest/chest_key

this code was failing: https://github.com/smart-chain-fr/Ligolib/blob/main/randomness/src/cameligo/ref.mligo with

Bad stack item 0.
Type bytes is not compatible with type chest_key. 

while this one was OK: https://gitlab.com/ligolang/ligo/blob/dev/src/test/contracts/interpreter_tests/test_timelock.mligo

Not sure why edit: the fact that the contract parameter is wrapped into a sum type (Reveal .. | Nothing ..) did have an effect on how michelson typecheck the inputs ?

Solution

Created a new Literal_chest and Litearal_chest_key case (non reachable by the user) so that we could create them in the interpreter (from bytes) and propagate the correct type in src/passes/17-stacking/compiler_program.ml

let literal_type_prim (l : literal) : string =
  match l with
  | Literal_unit -> "unit"
  | Literal_int _ -> "int"
  | Literal_nat _ -> "nat"
  | Literal_timestamp _ -> "timestamp"
  | Literal_mutez _ -> "mutez"
  | Literal_string _ -> "string"
  | Literal_bytes _ -> "bytes"
  | Literal_address _ -> "address"
  | Literal_signature _ -> "signature"
  | Literal_key _ -> "key"
  | Literal_key_hash _ -> "key_hash"
  | Literal_chain_id _ -> "chain_id"
  | Literal_operation _ -> "operation"
  | Literal_bls12_381_g1 _ -> "bls12_381_g1"
  | Literal_bls12_381_g2 _ -> "bls12_381_g2"
  | Literal_bls12_381_fr _ -> "bls12_381_fr"
  | Literal_chest _ -> "chest"
  | Literal_chest_key _ -> "chest_key"
  • has a changelog entry
Edited by Rémi

Merge request reports

Loading