From 29411086ac39c4119918382157760b92744c81b3 Mon Sep 17 00:00:00 2001 From: Mehdi Bouaziz Date: Mon, 26 Jun 2023 17:30:39 +0200 Subject: [PATCH 1/2] Proto/Entrypoints: optimized encoding for new pseudo-operations --- src/proto_alpha/lib_protocol/entrypoint_repr.ml | 12 ++++++++++++ src/proto_alpha/lib_protocol/entrypoint_repr.mli | 12 ++++++++++++ 2 files changed, 24 insertions(+) diff --git a/src/proto_alpha/lib_protocol/entrypoint_repr.ml b/src/proto_alpha/lib_protocol/entrypoint_repr.ml index 7931a57a42c4..f005430e6b2a 100644 --- a/src/proto_alpha/lib_protocol/entrypoint_repr.ml +++ b/src/proto_alpha/lib_protocol/entrypoint_repr.ml @@ -159,6 +159,14 @@ let remove_delegate = of_string_strict_exn "remove_delegate" let deposit = of_string_strict_exn "deposit" +let stake = of_string_strict_exn "stake" + +let unstake = of_string_strict_exn "unstake" + +let finalize_unstake = of_string_strict_exn "finalize_unstake" + +let set_delegate_parameters = of_string_strict_exn "set_delegate_parameters" + let is_deposit = ( = ) deposit let is_root = ( = ) root @@ -212,6 +220,10 @@ let smart_encoding = builtin_case 3 set_delegate; builtin_case 4 remove_delegate; builtin_case 5 deposit; + builtin_case 6 stake; + builtin_case 7 unstake; + builtin_case 8 finalize_unstake; + builtin_case 9 set_delegate_parameters; case (Tag 255) ~title:"named" diff --git a/src/proto_alpha/lib_protocol/entrypoint_repr.mli b/src/proto_alpha/lib_protocol/entrypoint_repr.mli index cef8b2a63f21..2582bb42396f 100644 --- a/src/proto_alpha/lib_protocol/entrypoint_repr.mli +++ b/src/proto_alpha/lib_protocol/entrypoint_repr.mli @@ -56,6 +56,18 @@ val remove_delegate : t (** Deposit entrypoint "deposit" *) val deposit : t +(** Entrypoint "stake" *) +val stake : t + +(** Entrypoint "unstake" *) +val unstake : t + +(** Entrypoint "finalize_unstake" *) +val finalize_unstake : t + +(** Entrypoint "set_delegate_parameters" *) +val set_delegate_parameters : t + (** Checks whether an entrypoint is the deposit entrypoint *) val is_deposit : t -> bool -- GitLab From cd4ce86eed3e2e3ac64277d19c351b61cfa34945 Mon Sep 17 00:00:00 2001 From: Mehdi Bouaziz Date: Mon, 26 Jun 2023 17:32:23 +0200 Subject: [PATCH 2/2] Proto/Tests: use them --- .../integration/test_adaptive_inflation_launch.ml | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/src/proto_alpha/lib_protocol/test/integration/test_adaptive_inflation_launch.ml b/src/proto_alpha/lib_protocol/test/integration/test_adaptive_inflation_launch.ml index 54debbc98538..bef383bf7284 100644 --- a/src/proto_alpha/lib_protocol/test/integration/test_adaptive_inflation_launch.ml +++ b/src/proto_alpha/lib_protocol/test/integration/test_adaptive_inflation_launch.ml @@ -67,13 +67,9 @@ let assert_current_cycle ~loc (blk : Block.t) expected = assert_cycle_eq ~loc current_cycle expected let stake ctxt contract amount = - let open Lwt_result_wrap_syntax in - let*?@ entrypoint = - Protocol.Alpha_context.Entrypoint.of_string_strict ~loc:0 "stake" - in Op.transaction ctxt - ~entrypoint + ~entrypoint:Protocol.Alpha_context.Entrypoint.stake ~fee:Protocol.Alpha_context.Tez.zero contract contract @@ -81,12 +77,7 @@ let stake ctxt contract amount = let set_delegate_parameters ctxt delegate ~staking_over_baking_limit ~baking_over_staking_edge = - let open Lwt_result_wrap_syntax in - let*?@ entrypoint = - Protocol.Alpha_context.Entrypoint.of_string_strict - ~loc:0 - "set_delegate_parameters" - in + let entrypoint = Protocol.Alpha_context.Entrypoint.set_delegate_parameters in let parameters = Protocol.Alpha_context.Script.lazy_expr (Expr.from_string -- GitLab