diff --git a/src/proto_alpha/lib_protocol/alpha_context.mli b/src/proto_alpha/lib_protocol/alpha_context.mli index f25a8dd2fe9069270445fd2741758b14d81954ff..2edd6be8fdd72101e040910beb3f41686932534c 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 93968cb39244af6797b2b218f415d0e24b65d55f..3f1e7f279653b2f3eb48e724ffe4cc40ebf35e70 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, diff --git a/tezt/tests/adaptive_issuance.ml b/tezt/tests/adaptive_issuance.ml index 5e05754df7abe36bb4efab92b076fb59d35509d1..adda0811390ed9bcc729d22c34ded03bff784818 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