From 302cc910023037ff95d1a2b4be47d147da702ef3 Mon Sep 17 00:00:00 2001 From: Mehdi Bouaziz Date: Thu, 8 Jun 2023 13:00:22 +0200 Subject: [PATCH 1/3] Proto/Apply: allow unstake from non-delegates --- src/proto_alpha/lib_protocol/apply.ml | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/proto_alpha/lib_protocol/apply.ml b/src/proto_alpha/lib_protocol/apply.ml index 0c579c9b19a8..67f08b576a10 100644 --- a/src/proto_alpha/lib_protocol/apply.ml +++ b/src/proto_alpha/lib_protocol/apply.ml @@ -239,8 +239,8 @@ let () = (function Invalid_self_transaction_destination -> Some () | _ -> None) (fun () -> Invalid_self_transaction_destination) ; let staking_for_nondelegate_while_costaking_disabled_description = - "As long as co-staking is not enabled, staking and unstaking operations \ - are only allowed from delegates." + "As long as co-staking is not enabled, staking operations are only allowed \ + from delegates." in register_error_kind `Permanent @@ -410,8 +410,6 @@ let apply_unstake ~ctxt ~sender ~amount ~requested_amount ~destination let* delegate_opt = Contract.Delegate.find ctxt sender_contract in match delegate_opt with | None -> tzfail Staking_for_nondelegate_while_costaking_disabled - | Some delegate when Signature.Public_key_hash.(delegate <> sender) -> - tzfail Staking_for_nondelegate_while_costaking_disabled | Some delegate -> let* ctxt, balance_updates = Staking.request_unstake ctxt ~sender_contract ~delegate requested_amount -- GitLab From b7b5ecc7f3908976ae238d487a8446d448b80bb2 Mon Sep 17 00:00:00 2001 From: Mehdi Bouaziz Date: Thu, 8 Jun 2023 13:01:39 +0200 Subject: [PATCH 2/3] Proto/Apply/stake: small rewrite --- src/proto_alpha/lib_protocol/apply.ml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/proto_alpha/lib_protocol/apply.ml b/src/proto_alpha/lib_protocol/apply.ml index 67f08b576a10..a3b95ec5adc9 100644 --- a/src/proto_alpha/lib_protocol/apply.ml +++ b/src/proto_alpha/lib_protocol/apply.ml @@ -361,9 +361,11 @@ let apply_stake ~ctxt ~sender ~amount ~destination ~before_operation = let* delegate_opt = Contract.Delegate.find ctxt contract in match delegate_opt with | None -> tzfail Staking_for_nondelegate_while_costaking_disabled - | Some delegate when Signature.Public_key_hash.(delegate <> sender) -> - tzfail Staking_for_nondelegate_while_costaking_disabled | Some delegate -> + let allowed = Signature.Public_key_hash.(delegate = sender) in + let*? () = + error_unless allowed Staking_for_nondelegate_while_costaking_disabled + in let* ctxt, balance_updates = Staking.stake ctxt ~sender ~delegate amount in -- GitLab From 05bc0971da9aa8cec8e0c75323f769adee4af59d Mon Sep 17 00:00:00 2001 From: Mehdi Bouaziz Date: Thu, 8 Jun 2023 13:04:01 +0200 Subject: [PATCH 3/3] Proto/Apply: allow stake from non-delegates under AI --- src/proto_alpha/lib_protocol/alpha_context.mli | 2 ++ src/proto_alpha/lib_protocol/apply.ml | 5 ++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/proto_alpha/lib_protocol/alpha_context.mli b/src/proto_alpha/lib_protocol/alpha_context.mli index 3acfa6802f07..45be4b372bd5 100644 --- a/src/proto_alpha/lib_protocol/alpha_context.mli +++ b/src/proto_alpha/lib_protocol/alpha_context.mli @@ -1031,6 +1031,8 @@ module Constants : sig val zk_rollup_min_pending_to_process : context -> int + val adaptive_inflation_enable : context -> bool + val freeze_rewards : context -> bool (** All constants: fixed and parametric *) diff --git a/src/proto_alpha/lib_protocol/apply.ml b/src/proto_alpha/lib_protocol/apply.ml index a3b95ec5adc9..aad827114703 100644 --- a/src/proto_alpha/lib_protocol/apply.ml +++ b/src/proto_alpha/lib_protocol/apply.ml @@ -362,7 +362,10 @@ let apply_stake ~ctxt ~sender ~amount ~destination ~before_operation = match delegate_opt with | None -> tzfail Staking_for_nondelegate_while_costaking_disabled | Some delegate -> - let allowed = Signature.Public_key_hash.(delegate = sender) in + let allowed = + Signature.Public_key_hash.(delegate = sender) + || Constants.adaptive_inflation_enable ctxt + in let*? () = error_unless allowed Staking_for_nondelegate_while_costaking_disabled in -- GitLab