From 0ce35211ec93b70ba46e08866ffcd38be4046037 Mon Sep 17 00:00:00 2001 From: Marina Polubelova Date: Tue, 6 Feb 2024 15:53:50 +0100 Subject: [PATCH 1/2] proto: make set_deposits_limit fail when automated staking off --- .../lib_protocol/alpha_context.mli | 4 +++ src/proto_alpha/lib_protocol/apply.ml | 27 +++++++++++++++++++ 2 files changed, 31 insertions(+) diff --git a/src/proto_alpha/lib_protocol/alpha_context.mli b/src/proto_alpha/lib_protocol/alpha_context.mli index f25a8dd2fe90..2edd6be8fdd7 100644 --- a/src/proto_alpha/lib_protocol/alpha_context.mli +++ b/src/proto_alpha/lib_protocol/alpha_context.mli @@ -2508,6 +2508,10 @@ module Staking : sig (** Staking can be either automated or manual. If Adaptive Issuance is enabled, staking must be manual. *) + type staking_automation = Auto_staking | Manual_staking + + val staking_automation : context -> staking_automation + val check_manual_staking_allowed : context -> unit tzresult end diff --git a/src/proto_alpha/lib_protocol/apply.ml b/src/proto_alpha/lib_protocol/apply.ml index 93968cb39244..3f1e7f279653 100644 --- a/src/proto_alpha/lib_protocol/apply.ml +++ b/src/proto_alpha/lib_protocol/apply.ml @@ -33,6 +33,7 @@ open Alpha_context type error += | Faulty_validation_wrong_slot | Set_deposits_limit_on_unregistered_delegate of Signature.Public_key_hash.t + | Set_deposits_limit_when_automated_staking_off | Error_while_taking_fees | Update_consensus_key_on_unregistered_delegate of Signature.Public_key_hash.t | Empty_transaction of Contract.t @@ -79,6 +80,22 @@ let () = | Set_deposits_limit_on_unregistered_delegate c -> Some c | _ -> None) (fun c -> Set_deposits_limit_on_unregistered_delegate c) ; + register_error_kind + `Temporary + ~id:"operation.set_deposits_limit_when_automated_staking_off" + ~title:"Set deposits limit when automated staking off" + ~description: + "Cannot set deposits limit when automated staking is off or Adaptive \ + Issuance is active." + ~pp:(fun ppf () -> + Format.fprintf + ppf + "Cannot set a deposits limit when automated staking off.") + Data_encoding.unit + (function + | Set_deposits_limit_when_automated_staking_off -> Some () | _ -> None) + (fun () -> Set_deposits_limit_when_automated_staking_off) ; + let error_while_taking_fees_description = "There was an error while taking the fees, which should not happen and \ means that the operation's validation was faulty." @@ -1397,6 +1414,16 @@ let apply_manager_operation : is_registered (Set_deposits_limit_on_unregistered_delegate source) in + let is_autostaking_enabled = + match Staking.staking_automation ctxt with + | Manual_staking -> false + | Auto_staking -> true + in + let*? () = + error_unless + is_autostaking_enabled + Set_deposits_limit_when_automated_staking_off + in let*! ctxt = Delegate.set_frozen_deposits_limit ctxt source limit in return ( ctxt, -- GitLab From a3c0c709c331036fe5bbf9e3bd36135ff44a5c26 Mon Sep 17 00:00:00 2001 From: Marina Polubelova Date: Wed, 7 Feb 2024 15:36:32 +0100 Subject: [PATCH 2/2] tezt/tests: check set_deposits_limit is not allowed after AI activation --- tezt/tests/adaptive_issuance.ml | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/tezt/tests/adaptive_issuance.ml b/tezt/tests/adaptive_issuance.ml index 5e05754df7ab..adda0811390e 100644 --- a/tezt/tests/adaptive_issuance.ml +++ b/tezt/tests/adaptive_issuance.ml @@ -594,7 +594,7 @@ let test_staking = client_1 in - log_step 9 "Check set_deposit_limits is not allowed after AI activation" ; + log_step 9 "Check set_deposits_limit is not allowed after AI activation" ; let set_deposits_limit = Client.spawn_set_deposits_limit ~src:Constant.bootstrap1.alias @@ -605,9 +605,8 @@ let test_staking = (* lets bake 2 more blocks and delegate should accept staking *) let* () = bake_n ~endpoint ~protocol client_1 2 in - (* TODO https://gitlab.com/tezos/tezos/-/issues/6613 - set_deposit_limits should fail after AI activation *) - let* () = Process.check set_deposits_limit in + (* set_deposits_limit fails after AI activation *) + let* () = Process.check ~expect_failure:true set_deposits_limit in let* numerator = Client.RPC.call client_1 -- GitLab