Skip to content

Snoop: fixes codegen issue since the recent update of the lib_benchmark.

This MR fixes the codegen issue since the recent update of lib_benchmark.

Issue: ./octez-snoop generate code using solution SOL for inferred models produces no code, failing the match of model names. An example:

$ ./octez-snoop generate code using solution $DIR/lsl_bytes.sol for inferred models --fixed-point snoop/fp.json
Inference model: interpreter
Found codegen models: 174
Skipping model proto/alpha/interpreter/N_IAnd_nat
...
(* Do not edit this file manually. *)
(* This file was automatically generated from the models registered at *)
(* src/<protocol>/lib_benchmarks_proto/interpreter_model.ml. *)
(* If you wish to update a function in this file, *)
(* a. update the corresponding model, or *)
(* b. move the function to michelson_v1_gas_costs.ml and edit it there. *)
[@@@warning "-33"]

module S = Saturation_repr

No code for N_ILsl_bytes, though it is not skipped.

This MR fixes the matching of model names taking the name space into the consideration. The same command now prints out the code:

(* Do not edit this file manually. *)
(* This file was automatically generated from the models registered at *)
(* src/<protocol>/lib_benchmarks_proto/interpreter_model.ml. *)
(* If you wish to update a function in this file, *)
(* a. update the corresponding model, or *)
(* b. move the function to michelson_v1_gas_costs.ml and edit it there. *)
[@@@warning "-33"]

module S = Saturation_repr

(* model proto/alpha/interpreter/N_ILsl_bytes *)
(* fun size1 -> fun size2 -> ((68.7982348671 + (0.118214626136 * size1)) + (0. * size2)) *)
let cost_N_ILsl_bytes size1 size2 =
  let open S.Syntax in
    let size1 = S.safe_int size1 in
    let size2 = S.safe_int size2 in
    let v1 = size1 in
    let v0 = size2 in
    ((S.safe_int 70) +
       ((((v1 lsr 4) + (v1 lsr 5)) + (v1 lsr 6)) + (v1 lsr 7)))
      + (v0 lsr 1023)

(* model proto/alpha/interpreter/N_IHalt *)
(* 13.2017651329 *)
let cost_N_IHalt = let open S.Syntax in S.safe_int 15
Edited by Jun Furuse

Merge request reports