Michelson: do not padd nat-encoded addresses that are now fixed sized
This commit is contained in:
parent
23e1486564
commit
f53cb40915
@ -949,6 +949,11 @@ let signature_size =
|
|||||||
| None -> assert false
|
| None -> assert false
|
||||||
| Some size -> size
|
| Some size -> size
|
||||||
|
|
||||||
|
let address_size =
|
||||||
|
match Data_encoding.Binary.fixed_length Contract.encoding with
|
||||||
|
| None -> assert false
|
||||||
|
| Some size -> size
|
||||||
|
|
||||||
let rec parse_data
|
let rec parse_data
|
||||||
: type a.
|
: type a.
|
||||||
?type_logger: (int -> Script.expr list -> Script.expr list -> unit) ->
|
?type_logger: (int -> Script.expr list -> Script.expr list -> unit) ->
|
||||||
@ -1133,8 +1138,9 @@ let rec parse_data
|
|||||||
(* Addresses *)
|
(* Addresses *)
|
||||||
| Address_t, Int (_, z) (* As unparsed with [O[ptimized]. *) ->
|
| Address_t, Int (_, z) (* As unparsed with [O[ptimized]. *) ->
|
||||||
Lwt.return (Gas.consume ctxt Typecheck_costs.contract) >>=? fun ctxt ->
|
Lwt.return (Gas.consume ctxt Typecheck_costs.contract) >>=? fun ctxt ->
|
||||||
bytes_of_padded_z z >>=? fun bytes ->
|
begin
|
||||||
begin match Data_encoding.Binary.of_bytes Contract.encoding bytes with
|
let bytes = Z.to_bits ~pad_to:address_size z in
|
||||||
|
match Data_encoding.Binary.of_bytes Contract.encoding bytes with
|
||||||
| Some c -> return (c, ctxt)
|
| Some c -> return (c, ctxt)
|
||||||
| None -> fail (error ())
|
| None -> fail (error ())
|
||||||
end
|
end
|
||||||
@ -1147,8 +1153,9 @@ let rec parse_data
|
|||||||
(* Contracts *)
|
(* Contracts *)
|
||||||
| Contract_t ty, Int (loc, z) (* As unparsed with [Optimized]. *) ->
|
| Contract_t ty, Int (loc, z) (* As unparsed with [Optimized]. *) ->
|
||||||
Lwt.return (Gas.consume ctxt Typecheck_costs.contract) >>=? fun ctxt ->
|
Lwt.return (Gas.consume ctxt Typecheck_costs.contract) >>=? fun ctxt ->
|
||||||
bytes_of_padded_z z >>=? fun bytes ->
|
begin
|
||||||
begin match Data_encoding.Binary.of_bytes Contract.encoding bytes with
|
let bytes = Z.to_bits ~pad_to:address_size z in
|
||||||
|
match Data_encoding.Binary.of_bytes Contract.encoding bytes with
|
||||||
| Some c ->
|
| Some c ->
|
||||||
traced (parse_contract ctxt loc ty c) >>=? fun (ctxt, _) ->
|
traced (parse_contract ctxt loc ty c) >>=? fun (ctxt, _) ->
|
||||||
return ((ty, c), ctxt)
|
return ((ty, c), ctxt)
|
||||||
@ -2328,7 +2335,7 @@ let rec unparse_data
|
|||||||
match mode with
|
match mode with
|
||||||
| Optimized ->
|
| Optimized ->
|
||||||
let bytes = Data_encoding.Binary.to_bytes_exn Contract.encoding c in
|
let bytes = Data_encoding.Binary.to_bytes_exn Contract.encoding c in
|
||||||
return (Int (-1, padded_z_of_bytes bytes), ctxt)
|
return (Int (-1, Z.of_bits bytes), ctxt)
|
||||||
| Readable -> return (String (-1, Contract.to_b58check c), ctxt)
|
| Readable -> return (String (-1, Contract.to_b58check c), ctxt)
|
||||||
end
|
end
|
||||||
| Contract_t _, (_, c) ->
|
| Contract_t _, (_, c) ->
|
||||||
@ -2337,7 +2344,7 @@ let rec unparse_data
|
|||||||
match mode with
|
match mode with
|
||||||
| Optimized ->
|
| Optimized ->
|
||||||
let bytes = Data_encoding.Binary.to_bytes_exn Contract.encoding c in
|
let bytes = Data_encoding.Binary.to_bytes_exn Contract.encoding c in
|
||||||
return (Int (-1, padded_z_of_bytes bytes), ctxt)
|
return (Int (-1, Z.of_bits bytes), ctxt)
|
||||||
| Readable -> return (String (-1, Contract.to_b58check c), ctxt)
|
| Readable -> return (String (-1, Contract.to_b58check c), ctxt)
|
||||||
end
|
end
|
||||||
| Signature_t, s ->
|
| Signature_t, s ->
|
||||||
|
Loading…
Reference in New Issue
Block a user