diff --git a/src/proto_alpha/lib_client/client_proto_context.ml b/src/proto_alpha/lib_client/client_proto_context.ml index 6349f5a1c23015a23cc9dbdb1985ba7759d2b305..e5a1d39c2a414e4c35116f2580679f2d9fc8673f 100644 --- a/src/proto_alpha/lib_client/client_proto_context.ml +++ b/src/proto_alpha/lib_client/client_proto_context.ml @@ -100,6 +100,9 @@ let get_contract_all_ticket_balances (rpc : #rpc_context) ~chain ~block contract let ticket_balances_encoding = Plugin.RPC.Contract.ticket_balances_encoding +let get_frozen_deposits_limit (rpc : #rpc_context) ~chain ~block delegate = + Alpha_services.Delegate.frozen_deposits_limit rpc (chain, block) delegate + let parse_expression arg = Lwt.return (Micheline_parser.no_parsing_error @@ -453,6 +456,41 @@ let drain_delegate cctxt ~chain ~block ?confirmations ?dry_run ?verbose_signing | Apply_results.Single_and_result ((Drain_delegate _ as op), result) -> return (oph, op, result) +let set_deposits_limit cctxt ~chain ~block ?confirmations ?dry_run + ?verbose_signing ?simulation ?fee contract ~src_pk ~manager_sk + ~fee_parameter limit_opt = + let open Lwt_result_syntax in + let operation = Set_deposits_limit limit_opt in + let operation = + Injection.prepare_manager_operation + ~fee:(Limit.of_option fee) + ~gas_limit:Limit.unknown + ~storage_limit:Limit.unknown + operation + in + let operation = Annotated_manager_operation.Single_manager operation in + let* oph, _, op, result = + Injection.inject_manager_operation + cctxt + ~chain + ~block + ?confirmations + ?dry_run + ?verbose_signing + ?simulation + ~source:contract + ~fee:(Limit.of_option fee) + ~gas_limit:Limit.unknown + ~storage_limit:Limit.unknown + ~src_pk + ~src_sk:manager_sk + ~fee_parameter + operation + in + match Apply_results.pack_contents_list op result with + | Apply_results.Single_and_result ((Manager_operation _ as op), result) -> + return (oph, op, result) + let increase_paid_storage cctxt ~chain ~block ?force ?dry_run ?verbose_signing ?fee ?confirmations ?simulation ~source ~destination ~src_pk ~manager_sk ~fee_parameter ~amount_in_bytes () = diff --git a/src/proto_alpha/lib_client/client_proto_context.mli b/src/proto_alpha/lib_client/client_proto_context.mli index 4eb654f6e646deae4ab16383e187f3e066bc32cf..786f0dfac3450cce79431aec30f1e1be09db5b38 100644 --- a/src/proto_alpha/lib_client/client_proto_context.mli +++ b/src/proto_alpha/lib_client/client_proto_context.mli @@ -162,6 +162,14 @@ val get_contract_all_ticket_balances : val ticket_balances_encoding : (Ticket_token.unparsed_token * Z.t) list Data_encoding.t +(** Calls {!Tezos_protocol_alpha.Protocol.Delegate_services.val-frozen_deposits_limit}. *) +val get_frozen_deposits_limit : + #Protocol_client_context.rpc_context -> + chain:Shell_services.chain -> + block:Shell_services.block -> + Signature.Public_key_hash.t -> + Tez.t option tzresult Lwt.t + (** Calls {!Injection.prepare_manager_operation} with {!Alpha_context.Delegation} [delegate_opt] as operation. *) val build_delegate_operation : @@ -220,6 +228,25 @@ val drain_delegate : unit -> Kind.drain_delegate Injection.result tzresult Lwt.t +(** Calls {!Injection.inject_manager_operation} + with {!Annotated_manager_operation.Single_manager} {!Alpha_context.Set_deposits_limit} [limit_opt] + as operation. *) +val set_deposits_limit : + #Protocol_client_context.full -> + chain:Shell_services.chain -> + block:Shell_services.block -> + ?confirmations:int -> + ?dry_run:bool -> + ?verbose_signing:bool -> + ?simulation:bool -> + ?fee:Tez.tez -> + public_key_hash -> + src_pk:public_key -> + manager_sk:Client_keys.sk_uri -> + fee_parameter:Injection.fee_parameter -> + Tez.t option -> + Kind.set_deposits_limit Kind.manager Injection.result tzresult Lwt.t + (** Calls {!Injection.inject_manager_operation} with {!Annotated_manager_operation.Single_manager} {!Alpha_context.Increase_paid_storage} [{amount_in_bytes; destination}] as operation. *) diff --git a/src/proto_alpha/lib_client/injection.ml b/src/proto_alpha/lib_client/injection.ml index d82472539d744c5b3cd95bd3f2f0c8b00b5b9a0f..0fac51be112a9ca2a3897c46615238df8d984472 100644 --- a/src/proto_alpha/lib_client/injection.ml +++ b/src/proto_alpha/lib_client/injection.ml @@ -345,6 +345,7 @@ let estimated_gas_single (type kind) | Reveal_result {consumed_gas} | Delegation_result {consumed_gas; _} | Register_global_constant_result {consumed_gas; _} + | Set_deposits_limit_result {consumed_gas} | Update_consensus_key_result {consumed_gas; _} | Increase_paid_storage_result {consumed_gas; _} | Transfer_ticket_result {consumed_gas; _} @@ -421,8 +422,9 @@ let estimated_storage_single (type kind) ~origination_size | Sc_rollup_originate_result {size; _} -> Ok size | Zk_rollup_origination_result {storage_size; _} -> Ok storage_size | Transaction_result (Transaction_to_sc_rollup_result _) - | Reveal_result _ | Delegation_result _ | Increase_paid_storage_result _ - | Dal_publish_slot_header_result _ | Sc_rollup_add_messages_result _ + | Reveal_result _ | Delegation_result _ | Set_deposits_limit_result _ + | Increase_paid_storage_result _ | Dal_publish_slot_header_result _ + | Sc_rollup_add_messages_result _ (* The following Sc_rollup operations have zero storage cost because we consider them to be paid in the stake deposit. @@ -502,12 +504,13 @@ let originated_contracts_single (type kind) ( Transaction_to_sc_rollup_result _ | Transaction_to_zk_rollup_result _ ) | Register_global_constant_result _ | Reveal_result _ - | Delegation_result _ | Update_consensus_key_result _ - | Increase_paid_storage_result _ | Transfer_ticket_result _ - | Dal_publish_slot_header_result _ | Sc_rollup_originate_result _ - | Sc_rollup_add_messages_result _ | Sc_rollup_cement_result _ - | Sc_rollup_publish_result _ | Sc_rollup_refute_result _ - | Sc_rollup_timeout_result _ | Sc_rollup_execute_outbox_message_result _ + | Delegation_result _ | Set_deposits_limit_result _ + | Update_consensus_key_result _ | Increase_paid_storage_result _ + | Transfer_ticket_result _ | Dal_publish_slot_header_result _ + | Sc_rollup_originate_result _ | Sc_rollup_add_messages_result _ + | Sc_rollup_cement_result _ | Sc_rollup_publish_result _ + | Sc_rollup_refute_result _ | Sc_rollup_timeout_result _ + | Sc_rollup_execute_outbox_message_result _ | Sc_rollup_recover_bond_result _ | Zk_rollup_origination_result _ | Zk_rollup_publish_result _ | Zk_rollup_update_result _ -> return_nil) @@ -866,7 +869,8 @@ let may_patch_limits (type kind) (cctxt : #Protocol_client_context.full) let safety_guard = match c.operation with | Transaction {destination = Implicit _; _} - | Reveal _ | Delegation _ | Increase_paid_storage _ -> + | Reveal _ | Delegation _ | Set_deposits_limit _ + | Increase_paid_storage _ -> Gas.Arith.zero | _ -> safety_guard in diff --git a/src/proto_alpha/lib_client/operation_result.ml b/src/proto_alpha/lib_client/operation_result.ml index d689cab7b1374fbe284fc13e3d5ad0fe50198950..06b2b4af6c6fee77168ca9d03828874361a7c59c 100644 --- a/src/proto_alpha/lib_client/operation_result.ml +++ b/src/proto_alpha/lib_client/operation_result.ml @@ -214,6 +214,15 @@ let pp_manager_operation_content (type kind) source ppf "Register Global:@,Value: %a" pp_micheline_from_lazy_expr value + | Set_deposits_limit limit_opt -> ( + Format.fprintf + ppf + "Set deposits limit:@,Delegate: %a@," + Contract.pp + source ; + match limit_opt with + | None -> Format.pp_print_string ppf "Unlimited deposits" + | Some limit -> Format.fprintf ppf "Limit: %a" Tez.pp limit) | Increase_paid_storage {amount_in_bytes; destination} -> Format.fprintf ppf @@ -806,6 +815,7 @@ let pp_manager_operation_contents_result ppf op_result = | Origination_result _ -> "origination" | Delegation_result _ -> "delegation" | Register_global_constant_result _ -> "global constant registration" + | Set_deposits_limit_result _ -> "deposits limit modification" | Update_consensus_key_result _ -> "consensus key update" | Increase_paid_storage_result _ -> "paid storage increase" | Transfer_ticket_result _ -> "tickets transfer" @@ -831,6 +841,8 @@ let pp_manager_operation_contents_result ppf op_result = | Delegation_result {consumed_gas; balance_updates} -> pp_consumed_gas ppf consumed_gas ; pp_balance_updates ppf balance_updates + | Set_deposits_limit_result {consumed_gas} -> + pp_consumed_gas ppf consumed_gas | Update_consensus_key_result {consumed_gas} -> pp_consumed_gas ppf consumed_gas | Transaction_result tx -> pp_transaction_result ppf tx diff --git a/src/proto_alpha/lib_client_commands/client_proto_context_commands.ml b/src/proto_alpha/lib_client_commands/client_proto_context_commands.ml index 93f8575e610df731fe0b750f4f2223fa25f20525..4ea45fbc1bcd8515e38529706d924062749f71eb 100644 --- a/src/proto_alpha/lib_client_commands/client_proto_context_commands.ml +++ b/src/proto_alpha/lib_client_commands/client_proto_context_commands.ml @@ -821,6 +821,31 @@ let commands_ro () = .unsigned_encoding_with_legacy_attestation_name) in return_unit); + command + ~group + ~desc:"Get the frozen deposits limit of a delegate." + no_options + (prefixes ["get"; "deposits"; "limit"; "for"] + @@ Client_keys.Public_key_hash.source_param + ~name:"src" + ~desc:"source delegate" + @@ stop) + (fun () delegate (cctxt : Protocol_client_context.full) -> + let open Lwt_result_syntax in + let* deposit = + get_frozen_deposits_limit + cctxt + ~chain:cctxt#chain + ~block:cctxt#block + delegate + in + let*! () = + match deposit with + | None -> cctxt#answer "unlimited" + | Some limit -> + cctxt#answer "%a %s" Tez.pp limit Operation_result.tez_sym + in + return_unit); ] (* ----------------------------------------------------------------------------*) @@ -2726,6 +2751,83 @@ let commands_rw () = ballot in return_unit); + command + ~group + ~desc:"Set the deposits limit of a registered delegate." + (args5 + fee_arg + dry_run_switch + verbose_signing_switch + simulate_switch + fee_parameter_args) + (prefixes ["set"; "deposits"; "limit"; "for"] + @@ Client_keys.Public_key_hash.source_param + ~name:"src" + ~desc:"source contract" + @@ prefix "to" + @@ tez_param + ~name:"deposits limit" + ~desc:"the maximum amount of frozen deposits" + @@ stop) + (fun (fee, dry_run, verbose_signing, simulation, fee_parameter) + mgr + limit + (cctxt : Protocol_client_context.full) -> + let open Lwt_result_syntax in + let* _, src_pk, manager_sk = Client_keys.get_key cctxt mgr in + let* (_ : _ Injection.result) = + set_deposits_limit + cctxt + ~chain:cctxt#chain + ~block:cctxt#block + ?confirmations:cctxt#confirmations + ~dry_run + ~verbose_signing + ~simulation + ~fee_parameter + ?fee + mgr + ~src_pk + ~manager_sk + (Some limit) + in + return_unit); + command + ~group + ~desc:"Remove the deposits limit of a registered delegate." + (args5 + fee_arg + dry_run_switch + verbose_signing_switch + simulate_switch + fee_parameter_args) + (prefixes ["unset"; "deposits"; "limit"; "for"] + @@ Client_keys.Public_key_hash.source_param + ~name:"src" + ~desc:"source contract" + @@ stop) + (fun (fee, dry_run, verbose_signing, simulation, fee_parameter) + mgr + (cctxt : Protocol_client_context.full) -> + let open Lwt_result_syntax in + let* _, src_pk, manager_sk = Client_keys.get_key cctxt mgr in + let* (_ : _ Injection.result) = + set_deposits_limit + cctxt + ~chain:cctxt#chain + ~block:cctxt#block + ?confirmations:cctxt#confirmations + ~dry_run + ~verbose_signing + ~simulation + ~fee_parameter + ?fee + mgr + ~src_pk + ~manager_sk + None + in + return_unit); command ~group ~desc:"Increase the paid storage of a smart contract." diff --git a/src/proto_alpha/lib_protocol/alpha_context.mli b/src/proto_alpha/lib_protocol/alpha_context.mli index 9da78e2cb21ae2e2e8980441d85d17b76ae7a68d..b9d51fd3e62b2b79d8fc1d0b837ce313c9f79ab9 100644 --- a/src/proto_alpha/lib_protocol/alpha_context.mli +++ b/src/proto_alpha/lib_protocol/alpha_context.mli @@ -2177,6 +2177,12 @@ end module Delegate : sig val check_not_tz4 : Signature.public_key_hash -> unit tzresult + val frozen_deposits_limit : + context -> public_key_hash -> Tez.t option tzresult Lwt.t + + val set_frozen_deposits_limit : + context -> public_key_hash -> Tez.t option -> context Lwt.t + val fold : context -> order:[`Sorted | `Undefined] -> @@ -2419,9 +2425,9 @@ module Staking : sig to [delegate]. *) val stake : context -> + amount:[`At_most of Tez.t | `Exactly of Tez.t] -> sender:public_key_hash -> delegate:public_key_hash -> - Tez.t -> (context * Receipt.balance_updates) tzresult Lwt.t (** [request_unstake ctxt ~sender_contract ~delegate amount] records a request @@ -4297,6 +4303,8 @@ module Kind : sig type event = Event_kind + type set_deposits_limit = Set_deposits_limit_kind + type increase_paid_storage = Increase_paid_storage_kind type update_consensus_key = Update_consensus_key_kind @@ -4341,6 +4349,7 @@ module Kind : sig | Delegation_manager_kind : delegation manager | Event_manager_kind : event manager | Register_global_constant_manager_kind : register_global_constant manager + | Set_deposits_limit_manager_kind : set_deposits_limit manager | Increase_paid_storage_manager_kind : increase_paid_storage manager | Update_consensus_key_manager_kind : update_consensus_key manager | Transfer_ticket_manager_kind : transfer_ticket manager @@ -4478,6 +4487,9 @@ and _ manager_operation = value : Script.lazy_expr; } -> Kind.register_global_constant manager_operation + | Set_deposits_limit : + Tez.t option + -> Kind.set_deposits_limit manager_operation | Increase_paid_storage : { amount_in_bytes : Z.t; destination : Contract_hash.t; @@ -4728,6 +4740,8 @@ module Operation : sig val register_global_constant_case : Kind.register_global_constant Kind.manager case + val set_deposits_limit_case : Kind.set_deposits_limit Kind.manager case + val increase_paid_storage_case : Kind.increase_paid_storage Kind.manager case @@ -4783,6 +4797,8 @@ module Operation : sig val register_global_constant_case : Kind.register_global_constant case + val set_deposits_limit_case : Kind.set_deposits_limit case + val increase_paid_storage_case : Kind.increase_paid_storage case val transfer_ticket_case : Kind.transfer_ticket case diff --git a/src/proto_alpha/lib_protocol/apply.ml b/src/proto_alpha/lib_protocol/apply.ml index a8c9e44156be4779862959c95186f3bfaf92c500..780f22f84c522696bbd499a54ac0618eb76e942b 100644 --- a/src/proto_alpha/lib_protocol/apply.ml +++ b/src/proto_alpha/lib_protocol/apply.ml @@ -31,6 +31,7 @@ open Alpha_context type error += | Faulty_validation_wrong_slot + | Set_deposits_limit_on_unregistered_delegate of Signature.Public_key_hash.t | Error_while_taking_fees | Update_consensus_key_on_unregistered_delegate of Signature.Public_key_hash.t | Empty_transaction of Contract.t @@ -62,6 +63,21 @@ let () = Data_encoding.empty (function Faulty_validation_wrong_slot -> Some () | _ -> None) (fun () -> Faulty_validation_wrong_slot) ; + register_error_kind + `Temporary + ~id:"operation.set_deposits_limit_on_unregistered_delegate" + ~title:"Set deposits limit on an unregistered delegate" + ~description:"Cannot set deposits limit on an unregistered delegate." + ~pp:(fun ppf c -> + Format.fprintf + ppf + "Cannot set a deposits limit on the unregistered delegate %a." + Signature.Public_key_hash.pp + c) + Data_encoding.(obj1 (req "delegate" Signature.Public_key_hash.encoding)) + (function + | Set_deposits_limit_on_unregistered_delegate c -> Some c | _ -> None) + (fun c -> Set_deposits_limit_on_unregistered_delegate c) ; let error_while_taking_fees_description = "There was an error while taking the fees, which should not happen and \ @@ -391,7 +407,7 @@ let apply_stake ~ctxt ~sender ~amount ~destination ~before_operation = error_when forbidden Staking_to_delegate_that_refuses_external_staking in let* ctxt, balance_updates = - Staking.stake ctxt ~sender ~delegate amount + Staking.stake ctxt ~amount:(`Exactly amount) ~sender ~delegate in (* Since [delegate] is an already existing delegate, it is already allocated. *) let allocated_destination_contract = false in @@ -1326,6 +1342,19 @@ let apply_manager_operation : } in return (ctxt, result, []) + | Set_deposits_limit limit -> + let*! is_registered = Delegate.registered ctxt source in + let*? () = + error_unless + is_registered + (Set_deposits_limit_on_unregistered_delegate source) + in + let*! ctxt = Delegate.set_frozen_deposits_limit ctxt source limit in + return + ( ctxt, + Set_deposits_limit_result + {consumed_gas = Gas.consumed ~since:ctxt_before_op ~until:ctxt}, + [] ) | Increase_paid_storage {amount_in_bytes; destination} -> let* ctxt = Contract.increase_paid_storage ctxt destination ~amount_in_bytes @@ -1691,7 +1720,8 @@ let burn_manager_storage_fees : size_of_constant = payload.size_of_constant; global_address = payload.global_address; } ) - | Update_consensus_key_result _ -> return (ctxt, storage_limit, smopr) + | Set_deposits_limit_result _ | Update_consensus_key_result _ -> + return (ctxt, storage_limit, smopr) | Increase_paid_storage_result _ -> return (ctxt, storage_limit, smopr) | Transfer_ticket_result payload -> let consumed = payload.paid_storage_size_diff in diff --git a/src/proto_alpha/lib_protocol/apply_results.ml b/src/proto_alpha/lib_protocol/apply_results.ml index 4c43948711b78b1de1900318a40cecf9f376f738..556c7fe66d512e921c6fe93e9a784217274245cf 100644 --- a/src/proto_alpha/lib_protocol/apply_results.ml +++ b/src/proto_alpha/lib_protocol/apply_results.ml @@ -58,6 +58,10 @@ type _ successful_manager_operation_result = global_address : Script_expr_hash.t; } -> Kind.register_global_constant successful_manager_operation_result + | Set_deposits_limit_result : { + consumed_gas : Gas.Arith.fp; + } + -> Kind.set_deposits_limit successful_manager_operation_result | Increase_paid_storage_result : { balance_updates : Receipt.balance_updates; consumed_gas : Gas.Arith.fp; @@ -485,6 +489,21 @@ module Manager_result = struct | Update_consensus_key_result {consumed_gas} -> consumed_gas) ~inj:(fun consumed_gas -> Update_consensus_key_result {consumed_gas}) + let set_deposits_limit_case = + make + ~op_case:Operation.Encoding.Manager_operations.set_deposits_limit_case + ~encoding: + Data_encoding.( + obj1 (dft "consumed_milligas" Gas.Arith.n_fp_encoding Gas.Arith.zero)) + ~select:(function + | Successful_manager_result (Set_deposits_limit_result _ as op) -> + Some op + | _ -> None) + ~kind:Kind.Set_deposits_limit_manager_kind + ~proj:(function + | Set_deposits_limit_result {consumed_gas} -> consumed_gas) + ~inj:(fun consumed_gas -> Set_deposits_limit_result {consumed_gas}) + let increase_paid_storage_case = make ~op_case:Operation.Encoding.Manager_operations.increase_paid_storage_case @@ -886,6 +905,7 @@ let successful_manager_operation_result_encoding : make Manager_result.origination_case; make Manager_result.delegation_case; make Manager_result.update_consensus_key_case; + make Manager_result.set_deposits_limit_case; make Manager_result.increase_paid_storage_case; make Manager_result.sc_rollup_originate_case; ] @@ -973,6 +993,10 @@ let equal_manager_kind : | Kind.Event_manager_kind, Kind.Event_manager_kind -> Some Eq | Kind.Event_manager_kind, _ -> None | Kind.Register_global_constant_manager_kind, _ -> None + | Kind.Set_deposits_limit_manager_kind, Kind.Set_deposits_limit_manager_kind + -> + Some Eq + | Kind.Set_deposits_limit_manager_kind, _ -> None | ( Kind.Increase_paid_storage_manager_kind, Kind.Increase_paid_storage_manager_kind ) -> Some Eq @@ -1576,6 +1600,17 @@ module Encoding = struct Some (op, res) | _ -> None) + let set_deposits_limit_case = + make_manager_case + Operation.Encoding.set_deposits_limit_case + Manager_result.set_deposits_limit_case + (function + | Contents_and_result + ( (Manager_operation {operation = Set_deposits_limit _; _} as op), + res ) -> + Some (op, res) + | _ -> None) + let increase_paid_storage_case = make_manager_case Operation.Encoding.increase_paid_storage_case @@ -1749,6 +1784,7 @@ let common_cases = origination_case; delegation_case; register_global_constant_case; + set_deposits_limit_case; increase_paid_storage_case; update_consensus_key_case; transfer_ticket_case; @@ -2152,6 +2188,32 @@ let kind_equal : } ) -> Some Eq | Manager_operation {operation = Register_global_constant _; _}, _ -> None + | ( Manager_operation {operation = Set_deposits_limit _; _}, + Manager_operation_result + {operation_result = Applied (Set_deposits_limit_result _); _} ) -> + Some Eq + | ( Manager_operation {operation = Set_deposits_limit _; _}, + Manager_operation_result + {operation_result = Backtracked (Set_deposits_limit_result _, _); _} ) + -> + Some Eq + | ( Manager_operation {operation = Set_deposits_limit _; _}, + Manager_operation_result + { + operation_result = + Failed (Alpha_context.Kind.Set_deposits_limit_manager_kind, _); + _; + } ) -> + Some Eq + | ( Manager_operation {operation = Set_deposits_limit _; _}, + Manager_operation_result + { + operation_result = + Skipped Alpha_context.Kind.Set_deposits_limit_manager_kind; + _; + } ) -> + Some Eq + | Manager_operation {operation = Set_deposits_limit _; _}, _ -> None | ( Manager_operation {operation = Increase_paid_storage _; _}, Manager_operation_result {operation_result = Applied (Increase_paid_storage_result _); _} ) -> diff --git a/src/proto_alpha/lib_protocol/apply_results.mli b/src/proto_alpha/lib_protocol/apply_results.mli index 1f8edf1eb8e93d440bb8238df0f3cb9da60ebaf3..4ac991e30ae109e3927e36ce6c818c6f0293846b 100644 --- a/src/proto_alpha/lib_protocol/apply_results.mli +++ b/src/proto_alpha/lib_protocol/apply_results.mli @@ -161,6 +161,10 @@ and _ successful_manager_operation_result = global_address : Script_expr_hash.t; } -> Kind.register_global_constant successful_manager_operation_result + | Set_deposits_limit_result : { + consumed_gas : Gas.Arith.fp; + } + -> Kind.set_deposits_limit successful_manager_operation_result | Increase_paid_storage_result : { balance_updates : Receipt.balance_updates; consumed_gas : Gas.Arith.fp; diff --git a/src/proto_alpha/lib_protocol/delegate_cycles.ml b/src/proto_alpha/lib_protocol/delegate_cycles.ml index 95245cffc5ad204cd6b2777005d1c1ac8a79695c..0bb7262c58661afe7f0600f17dd48b141b0cc203 100644 --- a/src/proto_alpha/lib_protocol/delegate_cycles.ml +++ b/src/proto_alpha/lib_protocol/delegate_cycles.ml @@ -114,9 +114,6 @@ let distribute_attesting_rewards ctxt last_cycle unrevealed_nonces = (ctxt, []) delegates -let maximal_available_for_staking ctxt ~delegate = - Contract_storage.get_balance ctxt (Implicit delegate) - let adjust_frozen_stakes ctxt : (Raw_context.t * Receipt_repr.balance_updates) tzresult Lwt.t = let open Lwt_result_syntax in @@ -134,14 +131,22 @@ let adjust_frozen_stakes ctxt : ctxt full_staking_balance in + let* deposit_limit = + Delegate_storage.frozen_deposits_limit ctxt delegate + in + let optimal_frozen = + match deposit_limit with + | None -> optimal_frozen + | Some deposit_limit -> Tez_repr.min optimal_frozen deposit_limit + in let* ctxt, new_balance_updates = if Tez_repr.(optimal_frozen > own_frozen) then let*? optimal_to_stake = Tez_repr.(optimal_frozen -? own_frozen) in - let* available_to_stake = - maximal_available_for_staking ctxt ~delegate - in - let to_stake = Tez_repr.min optimal_to_stake available_to_stake in - Staking.stake ctxt ~sender:delegate ~delegate to_stake + Staking.stake + ctxt + ~amount:(`At_most optimal_to_stake) + ~sender:delegate + ~delegate else if Tez_repr.(optimal_frozen < own_frozen) then let*? to_unstake = Tez_repr.(own_frozen -? optimal_frozen) in Staking.request_unstake diff --git a/src/proto_alpha/lib_protocol/delegate_services.ml b/src/proto_alpha/lib_protocol/delegate_services.ml index 474e6ad84a855a50ae2690803dd293a5a816abe3..c1dd5c5e1d94cd747afa790903a85d81e89cb080 100644 --- a/src/proto_alpha/lib_protocol/delegate_services.ml +++ b/src/proto_alpha/lib_protocol/delegate_services.ml @@ -113,6 +113,7 @@ type info = { current_frozen_deposits : Tez.t; frozen_deposits : Tez.t; staking_balance : Tez.t; + frozen_deposits_limit : Tez.t option; delegated_contracts : Contract.t list; delegated_balance : Tez.t; total_delegated_stake : Tez.t; @@ -132,6 +133,7 @@ let info_encoding = current_frozen_deposits; frozen_deposits; staking_balance; + frozen_deposits_limit; delegated_contracts; delegated_balance; total_delegated_stake; @@ -146,29 +148,30 @@ let info_encoding = current_frozen_deposits, frozen_deposits, staking_balance, + frozen_deposits_limit, delegated_contracts, delegated_balance, - total_delegated_stake, - staking_denominator, deactivated, grace_period ), - (voting_info, (active_consensus_key, pending_consensus_keys)) )) + ( (total_delegated_stake, staking_denominator), + (voting_info, (active_consensus_key, pending_consensus_keys)) ) )) (fun ( ( full_balance, current_frozen_deposits, frozen_deposits, staking_balance, + frozen_deposits_limit, delegated_contracts, delegated_balance, - total_delegated_stake, - staking_denominator, deactivated, grace_period ), - (voting_info, (active_consensus_key, pending_consensus_keys)) ) -> + ( (total_delegated_stake, staking_denominator), + (voting_info, (active_consensus_key, pending_consensus_keys)) ) ) -> { full_balance; current_frozen_deposits; frozen_deposits; staking_balance; + frozen_deposits_limit; delegated_contracts; delegated_balance; total_delegated_stake; @@ -180,28 +183,31 @@ let info_encoding = pending_consensus_keys; }) (merge_objs - (obj10 + (obj9 (req "full_balance" Tez.encoding) (req "current_frozen_deposits" Tez.encoding) (req "frozen_deposits" Tez.encoding) (req "staking_balance" Tez.encoding) + (opt "frozen_deposits_limit" Tez.encoding) (req "delegated_contracts" (list Contract.encoding)) (req "delegated_balance" Tez.encoding) - (req "total_delegated_stake" Tez.encoding) - (req "staking_denominator" Staking_pseudotoken.For_RPC.encoding) (req "deactivated" bool) (req "grace_period" Cycle.encoding)) (merge_objs - Vote.delegate_info_encoding (obj2 - (req "active_consensus_key" Signature.Public_key_hash.encoding) - (dft - "pending_consensus_keys" - (list - (obj2 - (req "cycle" Cycle.encoding) - (req "pkh" Signature.Public_key_hash.encoding))) - [])))) + (req "total_delegated_stake" Tez.encoding) + (req "staking_denominator" Staking_pseudotoken.For_RPC.encoding)) + (merge_objs + Vote.delegate_info_encoding + (obj2 + (req "active_consensus_key" Signature.Public_key_hash.encoding) + (dft + "pending_consensus_keys" + (list + (obj2 + (req "cycle" Cycle.encoding) + (req "pkh" Signature.Public_key_hash.encoding))) + []))))) let participation_info_encoding = let open Data_encoding in @@ -355,6 +361,15 @@ module S = struct ~output:Tez.encoding RPC_path.(path / "staking_balance") + let frozen_deposits_limit = + RPC_service.get_service + ~description: + "Returns the frozen deposits limit for the given delegate or none if \ + no limit is set." + ~query:RPC_query.empty + ~output:(Data_encoding.option Tez.encoding) + RPC_path.(path / "frozen_deposits_limit") + let delegated_contracts = RPC_service.get_service ~description: @@ -553,6 +568,7 @@ let register () = in let* frozen_deposits = Delegate.initial_frozen_deposits ctxt pkh in let* staking_balance = Delegate.For_RPC.staking_balance ctxt pkh in + let* frozen_deposits_limit = Delegate.frozen_deposits_limit ctxt pkh in let*! delegated_contracts = Delegate.delegated_contracts ctxt pkh in let* delegated_balance = Delegate.For_RPC.delegated_balance ctxt pkh in let* total_delegated_stake = @@ -578,6 +594,7 @@ let register () = current_frozen_deposits; frozen_deposits; staking_balance; + frozen_deposits_limit; delegated_contracts; delegated_balance; total_delegated_stake; @@ -632,6 +649,9 @@ let register () = register1 ~chunked:false S.staking_balance (fun ctxt pkh () () -> let* () = check_delegate_registered ctxt pkh in Delegate.For_RPC.staking_balance ctxt pkh) ; + register1 ~chunked:false S.frozen_deposits_limit (fun ctxt pkh () () -> + let* () = check_delegate_registered ctxt pkh in + Delegate.frozen_deposits_limit ctxt pkh) ; register1 ~chunked:true S.delegated_contracts (fun ctxt pkh () () -> let* () = check_delegate_registered ctxt pkh in let*! contracts = Delegate.delegated_contracts ctxt pkh in @@ -717,6 +737,9 @@ let unstaked_frozen_deposits ctxt block pkh = let staking_balance ctxt block pkh = RPC_context.make_call1 S.staking_balance ctxt block pkh () () +let frozen_deposits_limit ctxt block pkh = + RPC_context.make_call1 S.frozen_deposits_limit ctxt block pkh () () + let delegated_contracts ctxt block pkh = RPC_context.make_call1 S.delegated_contracts ctxt block pkh () () diff --git a/src/proto_alpha/lib_protocol/delegate_services.mli b/src/proto_alpha/lib_protocol/delegate_services.mli index 2bd1d6e2f14e6e55be41320c47d4a5a0ec9ce797..5a9daa6f7e284b0e219ba5bf8b4c675e6f7cc374 100644 --- a/src/proto_alpha/lib_protocol/delegate_services.mli +++ b/src/proto_alpha/lib_protocol/delegate_services.mli @@ -58,6 +58,7 @@ type info = { current_frozen_deposits : Tez.t; frozen_deposits : Tez.t; staking_balance : Tez.t; + frozen_deposits_limit : Tez.t option; delegated_contracts : Contract.t list; delegated_balance : Tez.t; total_delegated_stake : Tez.t; @@ -111,6 +112,12 @@ val staking_balance : Signature.Public_key_hash.t -> Tez.t shell_tzresult Lwt.t +val frozen_deposits_limit : + 'a #RPC_context.simple -> + 'a -> + Signature.Public_key_hash.t -> + Tez.t option shell_tzresult Lwt.t + val delegated_contracts : 'a #RPC_context.simple -> 'a -> diff --git a/src/proto_alpha/lib_protocol/delegate_storage.ml b/src/proto_alpha/lib_protocol/delegate_storage.ml index ece5ee476ce44e534983bff64b89bdc78f2d9d31..884da581994dc7d5faf577fe1363c1840d406ce5 100644 --- a/src/proto_alpha/lib_protocol/delegate_storage.ml +++ b/src/proto_alpha/lib_protocol/delegate_storage.ml @@ -269,6 +269,17 @@ let current_frozen_deposits ctxt delegate = let*? total = Tez_repr.(own_frozen +? staked_frozen) in return total +let frozen_deposits_limit ctxt delegate = + Storage.Contract.Frozen_deposits_limit.find + ctxt + (Contract_repr.Implicit delegate) + +let set_frozen_deposits_limit ctxt delegate limit = + Storage.Contract.Frozen_deposits_limit.add_or_remove + ctxt + (Contract_repr.Implicit delegate) + limit + let spendable_balance ctxt delegate = let contract = Contract_repr.Implicit delegate in Storage.Contract.Spendable_balance.get ctxt contract diff --git a/src/proto_alpha/lib_protocol/delegate_storage.mli b/src/proto_alpha/lib_protocol/delegate_storage.mli index c2e3aab197b71f21b46f16704a81b16dd861458c..69522d8b0eabcacce05425948ee619083d439fda 100644 --- a/src/proto_alpha/lib_protocol/delegate_storage.mli +++ b/src/proto_alpha/lib_protocol/delegate_storage.mli @@ -31,6 +31,7 @@ It also groups "trivial" getters/setters related to delegates. It is responsible for maintaining the following tables: + - {!Storage.Contract.Frozen_deposits_limit} - {!Storage.Delegates} *) @@ -115,6 +116,17 @@ val initial_frozen_deposits_of_previous_cycle : val current_frozen_deposits : Raw_context.t -> Signature.public_key_hash -> Tez_repr.t tzresult Lwt.t +val frozen_deposits_limit : + Raw_context.t -> + Signature.Public_key_hash.t -> + Tez_repr.t option tzresult Lwt.t + +val set_frozen_deposits_limit : + Raw_context.t -> + Signature.Public_key_hash.t -> + Tez_repr.t option -> + Raw_context.t Lwt.t + val spendable_balance : Raw_context.t -> Signature.public_key_hash -> Tez_repr.tez tzresult Lwt.t diff --git a/src/proto_alpha/lib_protocol/operation_repr.ml b/src/proto_alpha/lib_protocol/operation_repr.ml index 1a9681d589cbecd132c61be9eeb87137b3ada9de..657abe2de0c61d48e9cbc2446f59173589240881 100644 --- a/src/proto_alpha/lib_protocol/operation_repr.ml +++ b/src/proto_alpha/lib_protocol/operation_repr.ml @@ -72,6 +72,8 @@ module Kind = struct type event = Event_kind + type set_deposits_limit = Set_deposits_limit_kind + type increase_paid_storage = Increase_paid_storage_kind type update_consensus_key = Update_consensus_key_kind @@ -116,6 +118,7 @@ module Kind = struct | Delegation_manager_kind : delegation manager | Event_manager_kind : event manager | Register_global_constant_manager_kind : register_global_constant manager + | Set_deposits_limit_manager_kind : set_deposits_limit manager | Increase_paid_storage_manager_kind : increase_paid_storage manager | Update_consensus_key_manager_kind : update_consensus_key manager | Transfer_ticket_manager_kind : transfer_ticket manager @@ -320,6 +323,9 @@ and _ manager_operation = value : Script_repr.lazy_expr; } -> Kind.register_global_constant manager_operation + | Set_deposits_limit : + Tez_repr.t option + -> Kind.set_deposits_limit manager_operation | Increase_paid_storage : { amount_in_bytes : Z.t; destination : Contract_hash.t; @@ -407,6 +413,7 @@ let manager_kind : type kind. kind manager_operation -> kind Kind.manager = | Origination _ -> Kind.Origination_manager_kind | Delegation _ -> Kind.Delegation_manager_kind | Register_global_constant _ -> Kind.Register_global_constant_manager_kind + | Set_deposits_limit _ -> Kind.Set_deposits_limit_manager_kind | Increase_paid_storage _ -> Kind.Increase_paid_storage_manager_kind | Update_consensus_key _ -> Kind.Update_consensus_key_manager_kind | Transfer_ticket _ -> Kind.Transfer_ticket_manager_kind @@ -675,7 +682,18 @@ module Encoding = struct inj = (fun value -> Register_global_constant {value}); } - (* Tag 5 was for Set_deposits_limit. *) + let set_deposits_limit_case = + MCase + { + tag = 5; + name = "set_deposits_limit"; + encoding = obj1 (opt "limit" Tez_repr.encoding); + select = + (function + | Manager (Set_deposits_limit _ as op) -> Some op | _ -> None); + proj = (function Set_deposits_limit key -> key); + inj = (fun key -> Set_deposits_limit key); + } let increase_paid_storage_case = MCase @@ -1443,7 +1461,8 @@ module Encoding = struct let register_global_constant_case = make_manager_case 111 Manager_operations.register_global_constant_case - (* 112 was for Set_deposits_limit. *) + let set_deposits_limit_case = + make_manager_case 112 Manager_operations.set_deposits_limit_case let increase_paid_storage_case = make_manager_case 113 Manager_operations.increase_paid_storage_case @@ -1531,6 +1550,7 @@ module Encoding = struct PCase transaction_case; PCase origination_case; PCase delegation_case; + PCase set_deposits_limit_case; PCase increase_paid_storage_case; PCase update_consensus_key_case; PCase drain_delegate_case; @@ -1985,6 +2005,8 @@ let equal_manager_operation_kind : | Delegation _, _ -> None | Register_global_constant _, Register_global_constant _ -> Some Eq | Register_global_constant _, _ -> None + | Set_deposits_limit _, Set_deposits_limit _ -> Some Eq + | Set_deposits_limit _, _ -> None | Increase_paid_storage _, Increase_paid_storage _ -> Some Eq | Increase_paid_storage _, _ -> None | Update_consensus_key _, Update_consensus_key _ -> Some Eq diff --git a/src/proto_alpha/lib_protocol/operation_repr.mli b/src/proto_alpha/lib_protocol/operation_repr.mli index caccb54f0232def7dc2189b3c11c5822364abc50..65201b3ef212b97deacf4083874a8846ad2de038 100644 --- a/src/proto_alpha/lib_protocol/operation_repr.mli +++ b/src/proto_alpha/lib_protocol/operation_repr.mli @@ -106,6 +106,8 @@ module Kind : sig type event = Event_kind + type set_deposits_limit = Set_deposits_limit_kind + type increase_paid_storage = Increase_paid_storage_kind type update_consensus_key = Update_consensus_key_kind @@ -150,6 +152,7 @@ module Kind : sig | Delegation_manager_kind : delegation manager | Event_manager_kind : event manager | Register_global_constant_manager_kind : register_global_constant manager + | Set_deposits_limit_manager_kind : set_deposits_limit manager | Increase_paid_storage_manager_kind : increase_paid_storage manager | Update_consensus_key_manager_kind : update_consensus_key manager | Transfer_ticket_manager_kind : transfer_ticket manager @@ -367,6 +370,12 @@ and _ manager_operation = value : Script_repr.lazy_expr; } -> Kind.register_global_constant manager_operation + (* [Set_deposits_limit] sets an optional limit for frozen deposits + of a contract at a lower value than the maximum limit. When None, + the limit in unset back to the default maximum limit. *) + | Set_deposits_limit : + Tez_repr.t option + -> Kind.set_deposits_limit manager_operation (* [Increase_paid_storage] allows a sender to pay to increase the paid storage of some contract by some amount. *) | Increase_paid_storage : { @@ -719,6 +728,8 @@ module Encoding : sig val register_global_constant_case : Kind.register_global_constant Kind.manager case + val set_deposits_limit_case : Kind.set_deposits_limit Kind.manager case + val increase_paid_storage_case : Kind.increase_paid_storage Kind.manager case val transfer_ticket_case : Kind.transfer_ticket Kind.manager case @@ -777,6 +788,8 @@ module Encoding : sig val register_global_constant_case : Kind.register_global_constant case + val set_deposits_limit_case : Kind.set_deposits_limit case + val increase_paid_storage_case : Kind.increase_paid_storage case val transfer_ticket_case : Kind.transfer_ticket case diff --git a/src/proto_alpha/lib_protocol/staking.ml b/src/proto_alpha/lib_protocol/staking.ml index 84f076a373ccc1146d353f747abb192df327bb8e..e07253d2766905b257cb300915c109fc5fed572a 100644 --- a/src/proto_alpha/lib_protocol/staking.ml +++ b/src/proto_alpha/lib_protocol/staking.ml @@ -109,6 +109,26 @@ let finalize_unstake ctxt contract = in return (ctxt, balance_updates) +let can_stake_from_unstake ctxt ~delegate = + let open Lwt_result_syntax in + let* slashing_history_opt = + Storage.Contract.Slashed_deposits.find + ctxt + (Contract_repr.Implicit delegate) + in + let slashing_history = Option.value slashing_history_opt ~default:[] in + let current_cycle = (Raw_context.current_level ctxt).cycle in + let preserved_cycles = Constants_storage.preserved_cycles ctxt in + let oldest_slashable_cycle = + Cycle_repr.sub current_cycle (preserved_cycles + 1) + |> Option.value ~default:Cycle_repr.root + in + return + @@ not + (List.exists + (fun (x, _) -> Cycle_repr.(x >= oldest_slashable_cycle)) + slashing_history) + let stake_from_unstake_for_delegate ctxt ~delegate ~unfinalizable_requests_opt amount = let open Lwt_result_syntax in @@ -137,25 +157,12 @@ let stake_from_unstake_for_delegate ctxt ~delegate ~unfinalizable_requests_opt | None -> return (ctxt, [], amount) | Some Unstake_requests_storage.{delegate = delegate_requests; requests} -> if Signature.Public_key_hash.(delegate <> delegate_requests) then - (* impossible *) return (ctxt, [], amount) + (* Possible. If reached, stake should not do anything, + so we also set the amount to stake from the liquid part to zero. *) + return (ctxt, [], Tez_repr.zero) else - let* slashing_history_opt = - Storage.Contract.Slashed_deposits.find - ctxt - (Contract_repr.Implicit delegate) - in - let slashing_history = Option.value slashing_history_opt ~default:[] in - let current_cycle = (Raw_context.current_level ctxt).cycle in - let preserved_cycles = Constants_storage.preserved_cycles ctxt in - let oldest_slashable_cycle = - Cycle_repr.sub current_cycle (preserved_cycles + 1) - |> Option.value ~default:Cycle_repr.root - in - if - List.exists - (fun (x, _) -> Cycle_repr.(x >= oldest_slashable_cycle)) - slashing_history - then + let* allowed = can_stake_from_unstake ctxt ~delegate in + if not allowed then (* a slash could have modified the unstaked frozen deposits: cannot stake from unstake *) return (ctxt, [], amount) else @@ -242,13 +249,14 @@ let stake_from_unstake_for_delegate ctxt ~delegate ~unfinalizable_requests_opt in return (ctxt, balance_updates, remaining_amount_to_transfer) -let stake ctxt ~sender ~delegate amount = +let stake ctxt ~(amount : [`At_most of Tez_repr.t | `Exactly of Tez_repr.t]) + ~sender ~delegate = let open Lwt_result_syntax in let check_unfinalizable ctxt Unstake_requests_storage.{delegate = unstake_delegate; requests} = - match requests with - | [] -> return ctxt - | _ :: _ -> + match (requests, amount) with + | [], _ | _ :: _, `At_most _ -> return ctxt + | _ :: _, `Exactly _ -> if Signature.Public_key_hash.(delegate <> unstake_delegate) then tzfail Cannot_stake_with_unfinalizable_unstake_requests_to_another_delegate @@ -258,24 +266,41 @@ let stake ctxt ~sender ~delegate amount = let* ctxt, finalize_balance_updates, unfinalizable_requests_opt = finalize_unstake_and_check ~check_unfinalizable ctxt sender_contract in + let tez_amount = + match amount with `Exactly amount | `At_most amount -> amount + in + (* stake from unstake for eligible delegates *) let* ctxt, stake_balance_updates1, amount_from_liquid = if Signature.Public_key_hash.(sender <> delegate) then - let* ctxt, stake_balance_updates_pseudotoken = - Staking_pseudotokens_storage.stake - ctxt - ~contract:sender_contract - ~delegate - amount - in - return (ctxt, stake_balance_updates_pseudotoken, amount) + return (ctxt, [], tez_amount) else stake_from_unstake_for_delegate ctxt ~delegate ~unfinalizable_requests_opt - amount + tez_amount + in + (* Get amount to transfer from liquid wrt mode *) + let* amount_from_liquid = + match amount with + | `Exactly _ -> return amount_from_liquid + | `At_most _ -> + let* spendable = + Contract_storage.get_balance ctxt (Implicit delegate) + in + return Tez_repr.(min amount_from_liquid spendable) + in + (* Issue pseudotokens for delegators *) + let* ctxt, stake_balance_updates2 = + if Signature.Public_key_hash.(sender <> delegate) then + Staking_pseudotokens_storage.stake + ctxt + ~contract:sender_contract + ~delegate + amount_from_liquid + else return (ctxt, []) in - let+ ctxt, stake_balance_updates2 = + let+ ctxt, stake_balance_updates3 = Token.transfer ctxt (`Contract sender_contract) @@ -284,8 +309,8 @@ let stake ctxt ~sender ~delegate amount = amount_from_liquid in ( ctxt, - stake_balance_updates1 @ stake_balance_updates2 @ finalize_balance_updates - ) + stake_balance_updates1 @ stake_balance_updates2 @ stake_balance_updates3 + @ finalize_balance_updates ) let request_unstake ctxt ~sender_contract ~delegate requested_amount = let open Lwt_result_syntax in diff --git a/src/proto_alpha/lib_protocol/staking.mli b/src/proto_alpha/lib_protocol/staking.mli index a84e022782a64f933ff4b31129a7ddfd96d673a4..a7b0409f4d419e48868f686b08df9bc77a9e6654 100644 --- a/src/proto_alpha/lib_protocol/staking.mli +++ b/src/proto_alpha/lib_protocol/staking.mli @@ -27,9 +27,9 @@ to [delegate]. *) val stake : Raw_context.t -> + amount:[`At_most of Tez_repr.t | `Exactly of Tez_repr.t] -> sender:Signature.Public_key_hash.t -> delegate:Signature.public_key_hash -> - Tez_repr.t -> (Raw_context.t * Receipt_repr.balance_updates) tzresult Lwt.t (** [request_unstake ctxt ~sender_contract ~delegate amount] records a request diff --git a/src/proto_alpha/lib_protocol/test/helpers/block.ml b/src/proto_alpha/lib_protocol/test/helpers/block.ml index db8661f8154fb77e79e521f07a5c735e3aae9a74..1da2ebf89d8664445ce059b0472219a867307413 100644 --- a/src/proto_alpha/lib_protocol/test/helpers/block.ml +++ b/src/proto_alpha/lib_protocol/test/helpers/block.ml @@ -1082,11 +1082,11 @@ let balance_update_of_operation_result : | Protocol.Apply_results.Transaction_result (Transaction_to_sc_rollup_result _) | Reveal_result _ | Update_consensus_key_result _ - | Transfer_ticket_result _ | Dal_publish_slot_header_result _ - | Sc_rollup_originate_result _ | Sc_rollup_add_messages_result _ - | Sc_rollup_cement_result _ | Sc_rollup_publish_result _ - | Sc_rollup_refute_result _ | Sc_rollup_timeout_result _ - | Sc_rollup_execute_outbox_message_result _ + | Set_deposits_limit_result _ | Transfer_ticket_result _ + | Dal_publish_slot_header_result _ | Sc_rollup_originate_result _ + | Sc_rollup_add_messages_result _ | Sc_rollup_cement_result _ + | Sc_rollup_publish_result _ | Sc_rollup_refute_result _ + | Sc_rollup_timeout_result _ | Sc_rollup_execute_outbox_message_result _ | Sc_rollup_recover_bond_result _ | Zk_rollup_origination_result _ | Zk_rollup_publish_result _ | Zk_rollup_update_result _ -> [] @@ -1194,6 +1194,7 @@ let bake_n_with_origination_results ?baking_mode ?policy n b = | Successful_manager_result (Update_consensus_key_result _) | Successful_manager_result (Transaction_result _) | Successful_manager_result (Register_global_constant_result _) + | Successful_manager_result (Set_deposits_limit_result _) | Successful_manager_result (Increase_paid_storage_result _) | Successful_manager_result (Transfer_ticket_result _) | Successful_manager_result (Dal_publish_slot_header_result _) diff --git a/src/proto_alpha/lib_protocol/test/helpers/context.ml b/src/proto_alpha/lib_protocol/test/helpers/context.ml index 026e8249d1a1207ec13398c89caddb76fea42e4b..1798ac389eba04c74de727bf1625b38b7cb6c5b4 100644 --- a/src/proto_alpha/lib_protocol/test/helpers/context.ml +++ b/src/proto_alpha/lib_protocol/test/helpers/context.ml @@ -456,6 +456,7 @@ module Delegate = struct current_frozen_deposits : Tez.t; frozen_deposits : Tez.t; staking_balance : Tez.t; + frozen_deposits_limit : Tez.t option; delegated_contracts : Alpha_context.Contract.t list; delegated_balance : Tez.t; total_delegated_stake : Tez.t; @@ -487,6 +488,9 @@ module Delegate = struct in Staking_pseudotoken.Internal_for_tests.to_z pseudotokens + let frozen_deposits_limit ctxt pkh = + Delegate_services.frozen_deposits_limit rpc_ctxt ctxt pkh + let deactivated ctxt pkh = Delegate_services.deactivated rpc_ctxt ctxt pkh let voting_info ctxt d = Alpha_services.Delegate.voting_info rpc_ctxt ctxt d diff --git a/src/proto_alpha/lib_protocol/test/helpers/context.mli b/src/proto_alpha/lib_protocol/test/helpers/context.mli index a726ac8f6c753f0335a31d9b21572fac875b4cd0..ac109ef496fba5bf9d5466e6b75cf1dd7a5f720f 100644 --- a/src/proto_alpha/lib_protocol/test/helpers/context.mli +++ b/src/proto_alpha/lib_protocol/test/helpers/context.mli @@ -232,6 +232,7 @@ module Delegate : sig current_frozen_deposits : Tez.t; frozen_deposits : Tez.t; staking_balance : Tez.t; + frozen_deposits_limit : Tez.t option; delegated_contracts : Alpha_context.Contract.t list; delegated_balance : Tez.t; total_delegated_stake : Tez.t; @@ -257,6 +258,9 @@ module Delegate : sig val staking_denominator : t -> public_key_hash -> Z.t tzresult Lwt.t + val frozen_deposits_limit : + t -> public_key_hash -> Tez.t option tzresult Lwt.t + val deactivated : t -> public_key_hash -> bool tzresult Lwt.t val voting_info : t -> public_key_hash -> Vote.delegate_info tzresult Lwt.t diff --git a/src/proto_alpha/lib_protocol/test/helpers/op.ml b/src/proto_alpha/lib_protocol/test/helpers/op.ml index 751ba0581bf2066ee8bf5cce6b98e8f9095f2e72..8f0b57bc1d399ab33c346f9c6c8268eead33b631 100644 --- a/src/proto_alpha/lib_protocol/test/helpers/op.ml +++ b/src/proto_alpha/lib_protocol/test/helpers/op.ml @@ -635,6 +635,22 @@ let delegation ?force_reveal ?fee ?gas_limit ?counter ?storage_limit ctxt source let+ account = Context.Contract.manager ctxt source in sign account.sk (Context.branch ctxt) sop +let set_deposits_limit ?force_reveal ?fee ?gas_limit ?storage_limit ?counter + ctxt source limit = + let top = Set_deposits_limit limit in + manager_operation + ?force_reveal + ?fee + ?counter + ?storage_limit + ?gas_limit + ~source + ctxt + top + >>=? fun sop -> + Context.Contract.manager ctxt source >|=? fun account -> + sign account.sk (Context.branch ctxt) sop + let increase_paid_storage ?force_reveal ?counter ?fee ?gas_limit ?storage_limit ctxt ~source ~destination (amount : Z.t) = let open Lwt_result_syntax in diff --git a/src/proto_alpha/lib_protocol/test/helpers/op.mli b/src/proto_alpha/lib_protocol/test/helpers/op.mli index f51dd7318db3909e7e9c7cefa0e9e170d64901a8..cee0f9975ec9d89e3417a4ec89560bb8113e2e9d 100644 --- a/src/proto_alpha/lib_protocol/test/helpers/op.mli +++ b/src/proto_alpha/lib_protocol/test/helpers/op.mli @@ -174,6 +174,17 @@ val delegation : public_key_hash option -> Operation.packed tzresult Lwt.t +val set_deposits_limit : + ?force_reveal:bool -> + ?fee:Tez.tez -> + ?gas_limit:gas_limit -> + ?storage_limit:Z.t -> + ?counter:Manager_counter.t -> + Context.t -> + Contract.t -> + Tez.tez option -> + Operation.packed tzresult Lwt.t + val increase_paid_storage : ?force_reveal:bool -> ?counter:Manager_counter.t -> diff --git a/src/proto_alpha/lib_protocol/test/helpers/operation_generator.ml b/src/proto_alpha/lib_protocol/test/helpers/operation_generator.ml index 43928b5360fa2a44d7e77e4b024276add6826fab..447b5a9caf9338120d89c7e48eb4d6595fdd3c9c 100644 --- a/src/proto_alpha/lib_protocol/test/helpers/operation_generator.ml +++ b/src/proto_alpha/lib_protocol/test/helpers/operation_generator.ml @@ -70,6 +70,7 @@ let manager_kinds = `KTransaction; `KOrigination; `KDelegation; + `KSet_deposits_limit; `KIncrease_paid_storage; `KRegister_global_constant; `KTransfer_ticket; @@ -501,6 +502,11 @@ let generate_increase_paid_storage = let+ destination = random_contract_hash in Increase_paid_storage {amount_in_bytes; destination} +let generate_set_deposits_limit = + let open QCheck2.Gen in + let+ amount_opt = option gen_amount in + Set_deposits_limit amount_opt + let generate_register_global_constant = let value = Script_repr.lazy_expr (Expr.from_string "Pair 1 2") in QCheck2.Gen.pure (Register_global_constant {value}) @@ -600,6 +606,8 @@ let generator_of ?source = function | `KReveal -> generate_manager_operation ?source generate_reveal | `KTransaction -> generate_manager_operation ?source generate_transaction | `KOrigination -> generate_manager_operation ?source generate_origination + | `KSet_deposits_limit -> + generate_manager_operation ?source generate_set_deposits_limit | `KIncrease_paid_storage -> generate_manager_operation ?source generate_increase_paid_storage | `KDelegation -> generate_manager_operation ?source generate_delegation diff --git a/src/proto_alpha/lib_protocol/test/integration/consensus/test_frozen_deposits.ml b/src/proto_alpha/lib_protocol/test/integration/consensus/test_frozen_deposits.ml index a5fc4550f214a9f09e69960dc08062863917ba64..a089cbe67f8ea445474e33c385349b2630a97b4d 100644 --- a/src/proto_alpha/lib_protocol/test/integration/consensus/test_frozen_deposits.ml +++ b/src/proto_alpha/lib_protocol/test/integration/consensus/test_frozen_deposits.ml @@ -28,11 +28,12 @@ Component: Protocol (frozen_deposits) Invocation: dune exec src/proto_alpha/lib_protocol/test/integration/consensus/main.exe \ -- --file test_frozen_deposits.ml - Subject: consistency of frozen deposits + Subject: consistency of frozen deposits and the [set_deposits_limit] operation *) open Protocol open Alpha_context +open Test_tez let constants = { @@ -153,11 +154,8 @@ let test_cannot_bake_with_zero_deposits () = (because the frozen deposits value impacts the active stake and the active stake is the one used to determine baking/attesting rights. *) (* To make account1 have zero deposits, we unstake all its deposits. *) - let* frozen_deposits = - Context.Delegate.current_frozen_deposits (B genesis) account1 - in let* operation = - Adaptive_issuance_helpers.unstake (B genesis) contract1 frozen_deposits + Op.set_deposits_limit (B genesis) contract1 (Some Tez.zero) in let* b = Block.bake ~policy:(By_account account2) ~operation genesis in let expected_number_of_cycles_with_previous_deposit = @@ -171,12 +169,10 @@ let test_cannot_bake_with_zero_deposits () = in let*! b1 = Block.bake ~policy:(By_account account1) b in (* by now, the active stake of account1 is 0 so it no longer has slots, thus it - cannot be a proposer, thus it cannot bake. Precisely, bake fails because - get_next_baker_by_account fails with "No slots found" *) + cannot be a proposer, thus it cannot bake. Precisely, bake fails with error + Validate_errors.Consensus.Zero_frozen_deposits*) let* () = - Assert.error ~loc:__LOC__ b1 (function - | Block.No_slots_found_for _ -> true - | _ -> false) + Assert.proto_error_with_info ~loc:__LOC__ b1 "Zero frozen deposits" in let* b = Block.bake_until_cycle_end ~policy:(By_account account2) b in (* after one cycle is passed, the frozen deposit window has passed @@ -217,7 +213,17 @@ let adjust_staking_towards_limit ~limit ~block ~account ~contract = let test_limit_with_overdelegation () = let open Lwt_result_syntax in - let constants = {constants with limit_of_delegation_over_baking = 9} in + let constants = + { + constants with + adaptive_issuance = + { + Default_parameters.constants_test.adaptive_issuance with + autostaking_enable = false; + }; + limit_of_delegation_over_baking = 9; + } + in let* genesis, contracts = Context.init_with_constants2 constants in let (contract1, account1), (contract2, account2) = get_first_2_accounts_contracts contracts @@ -268,7 +274,16 @@ let test_limit_with_overdelegation () = Op.delegation ~force_reveal:true (B b) new_contract (Some account1) in let* b = Block.bake ~operation:delegation b in - let* b = Block.bake_until_cycle_end ~policy:(By_account account1) b in + (* Overdelegation means that now there isn't enough staking, and the + baker who wants to have its stake close to its defined limit + should adjust it. *) + let* b = + adjust_staking_towards_limit + ~block:b + ~account:account1 + ~contract:contract1 + ~limit + in let expected_new_frozen_deposits = limit in let* frozen_deposits = Context.Delegate.current_frozen_deposits (B b) account1 @@ -384,6 +399,145 @@ let test_may_not_bake_again_after_full_deposit_slash () = let* _ = Block.bake ~policy:(By_account slashed_account) b in return_unit +let test_set_limit balance_percentage () = + let open Lwt_result_syntax in + let* genesis, contracts = Context.init_with_constants2 constants in + let (contract1, account1), (_contract2, account2) = + get_first_2_accounts_contracts contracts + in + let* () = + let* res = Context.Delegate.frozen_deposits_limit (B genesis) account1 in + match res with + | Some _ -> Alcotest.fail "unexpected deposits limit" + | None -> return_unit + in + (* Test deposit consistency before and after first cycle *) + let* full_balance = Context.Delegate.full_balance (B genesis) account1 in + let* frozen_deposits = + Context.Delegate.current_frozen_deposits (B genesis) account1 + in + let expected_deposits = + full_balance /! Int64.of_int (constants.limit_of_delegation_over_baking + 1) + in + let* () = Assert.equal_tez ~loc:__LOC__ frozen_deposits expected_deposits in + (* Bake until end of first cycle *) + let* b = Block.bake_until_cycle_end genesis in + let* full_balance = Context.Delegate.full_balance (B genesis) account1 in + let* frozen_deposits = + Context.Delegate.current_frozen_deposits (B genesis) account1 + in + let expected_deposits = + full_balance /! Int64.of_int (constants.limit_of_delegation_over_baking + 1) + in + let* () = Assert.equal_tez ~loc:__LOC__ frozen_deposits expected_deposits in + (* set deposits limit to balance_percentage out of the balance *) + let limit = + Test_tez.(full_balance *! Int64.of_int balance_percentage /! 100L) + in + let* operation = Op.set_deposits_limit (B genesis) contract1 (Some limit) in + let* b = Block.bake ~policy:(By_account account2) ~operation b in + let* () = + let* frozen_deposits_limit = + Context.Delegate.frozen_deposits_limit (B b) account1 + in + match frozen_deposits_limit with + | Some set_limit -> Assert.equal_tez ~loc:__LOC__ set_limit limit + | None -> Alcotest.fail "unexpected absence of deposits limit" + in + (* the frozen deposits limit affects the active stake at cycle end. *) + let* b = Block.bake_until_cycle_end ~policy:(By_account account2) b in + let* frozen_deposits = + Context.Delegate.current_frozen_deposits (B b) account1 + in + Assert.equal_tez ~loc:__LOC__ frozen_deposits limit + +let test_unset_limit () = + let open Lwt_result_syntax in + let* genesis, contracts = Context.init_with_constants2 constants in + let (contract1, account1), (_contract2, account2) = + get_first_2_accounts_contracts contracts + in + (* set the limit to 0 *) + let* operation = + Op.set_deposits_limit (B genesis) contract1 (Some Tez.zero) + in + let* b = Block.bake ~policy:(By_account account2) ~operation genesis in + let* () = + let* frozen_deposits_limit = + Context.Delegate.frozen_deposits_limit (B b) account1 + in + match frozen_deposits_limit with + | Some set_limit -> Assert.equal_tez ~loc:__LOC__ set_limit Tez.zero + | None -> Alcotest.fail "unexpected absence of deposits limit" + in + let* b = Block.bake_until_cycle_end ~policy:(By_account account2) b in + let* frozen_deposits_at_b = + Context.Delegate.current_frozen_deposits (B b) account1 + in + (* after cycle end, the 0 limit is reflected in the deposit which becomes 0 + itself *) + let* () = Assert.equal_tez ~loc:__LOC__ frozen_deposits_at_b Tez.zero in + (* unset the 0 limit *) + let* operation = Op.set_deposits_limit (B b) contract1 None in + let* b = Block.bake ~policy:(By_account account2) ~operation b in + let* () = + let* frozen_deposits_limit = + Context.Delegate.frozen_deposits_limit (B b) account1 + in + match frozen_deposits_limit with + | Some _ -> Alcotest.fail "unexpected deposits limit" + | None -> return_unit + in + (* removing the 0 limit is visible once the cycle ends *) + let* bfin = Block.bake_until_cycle_end ~policy:(By_account account2) b in + let* frozen_deposits_at_bfin = + Context.Delegate.current_frozen_deposits (B bfin) account1 + in + (* without a limit and with autostaking staking, the new deposit is no more + zero; note that account1 hasn't baked any block. *) + let* () = + Assert.not_equal_tez ~loc:__LOC__ frozen_deposits_at_bfin Tez.zero + in + return_unit + +let test_cannot_bake_with_zero_deposits_limit () = + let open Lwt_result_syntax in + let* genesis, contracts = Context.init_with_constants2 constants in + let (contract1, account1), (_contract2, account2) = + get_first_2_accounts_contracts contracts + in + (* N.B. there is no non-zero frozen deposits value for which one cannot bake: + even with a small deposit one can still bake, though with a smaller probability + (because the frozen deposits value impacts the active stake and the active + stake is the one used to determine baking/endorsing rights. *) + let* operation = + Op.set_deposits_limit (B genesis) contract1 (Some Tez.zero) + in + let* b = Block.bake ~policy:(By_account account2) ~operation genesis in + let expected_number_of_cycles_with_rights_from_previous_deposit = + constants.preserved_cycles + Constants.max_slashing_period - 1 + in + let* b = + Block.bake_until_n_cycle_end + ~policy:(By_account account2) + expected_number_of_cycles_with_rights_from_previous_deposit + b + in + let*! b1 = Block.bake ~policy:(By_account account1) b in + (* by now, the active stake of account1 is 0 so it no longer has slots, thus it + cannot be a proposer, thus it cannot bake. Precisely, bake fails because + get_next_baker_by_account fails with "No slots found" *) + let* () = Assert.error ~loc:__LOC__ b1 (fun _ -> true) in + let* b = Block.bake_until_cycle_end ~policy:(By_account account2) b in + (* after one cycle is passed, the frozen deposit window has passed + and the frozen deposits should now be effectively 0. *) + let* fd = Context.Delegate.current_frozen_deposits (B b) account1 in + let* () = Assert.equal_tez ~loc:__LOC__ fd Tez.zero in + let*! b1 = Block.bake ~policy:(By_account account1) b in + (* don't know why the zero frozen deposits error is not caught here *) + (* Assert.proto_error_with_info ~loc:__LOC__ b1 "Zero frozen deposits" *) + Assert.error ~loc:__LOC__ b1 (fun _ -> true) + let test_deposits_after_stake_removal () = let open Lwt_result_syntax in let* genesis, contracts = Context.init_with_constants2 constants in @@ -723,6 +877,94 @@ let test_frozen_deposits_with_overdelegation () = let* (_ : Block.t) = loop b cycles_to_bake in return_unit +let test_set_limit_with_overdelegation () = + let open Lwt_result_syntax in + let constants = {constants with limit_of_delegation_over_baking = 9} in + let* genesis, contracts = Context.init_with_constants2 constants in + let (contract1, account1), (contract2, account2) = + get_first_2_accounts_contracts contracts + in + (* - [account1] and [account2] will give 80% of their balance to + [new_account] + - [new_account] will overdelegate to [account1] and [account1] will set + its frozen deposits limit to 15% of its stake *) + let* initial_staking_balance = + Context.Delegate.staking_balance (B genesis) account1 + in + let* initial_staking_balance' = + Context.Delegate.staking_balance (B genesis) account2 + in + let amount = Test_tez.(initial_staking_balance *! 8L /! 10L) in + let amount' = Test_tez.(initial_staking_balance' *! 8L /! 10L) in + let limit = Test_tez.(initial_staking_balance *! 15L /! 100L) in + let new_account = (Account.new_account ()).pkh in + let new_contract = Contract.Implicit new_account in + let* transfer1 = + Op.transaction ~force_reveal:true (B genesis) contract1 new_contract amount + in + let* transfer2 = + Op.transaction ~force_reveal:true (B genesis) contract2 new_contract amount' + in + let* b = Block.bake ~operations:[transfer1; transfer2] genesis in + let* set_deposits = Op.set_deposits_limit (B b) contract1 (Some limit) in + let* b = Block.bake ~operation:set_deposits b in + let expected_new_staking_balance = + Test_tez.(initial_staking_balance -! amount) + in + let* new_staking_balance = Context.Delegate.staking_balance (B b) account1 in + let* () = + Assert.equal_tez + ~loc:__LOC__ + new_staking_balance + expected_new_staking_balance + in + let expected_new_staking_balance' = + Test_tez.(initial_staking_balance' -! amount') + in + let* new_staking_balance' = Context.Delegate.staking_balance (B b) account2 in + let* () = + Assert.equal_tez + ~loc:__LOC__ + new_staking_balance' + expected_new_staking_balance' + in + let* delegation = + Op.delegation ~force_reveal:true (B b) new_contract (Some account1) + in + let* b = Block.bake ~operation:delegation b in + (* Finish the cycle. account1's frozen deposits are increased + automatically. *) + let* b = Block.bake_until_cycle_end b in + let expected_new_frozen_deposits = limit in + let* frozen_deposits = + Context.Delegate.current_frozen_deposits (B b) account1 + in + let* () = + Assert.equal_tez ~loc:__LOC__ frozen_deposits expected_new_frozen_deposits + in + let cycles_to_bake = + 2 * (constants.preserved_cycles + Constants.max_slashing_period) + in + let rec loop b n = + if n = 0 then return b + else + let* b = Block.bake_until_cycle_end ~policy:(By_account account1) b in + let* frozen_deposits = + Context.Delegate.current_frozen_deposits (B b) account1 + in + let* () = + Assert.equal_tez + ~loc:__LOC__ + frozen_deposits + expected_new_frozen_deposits + in + loop b (pred n) + in + (* Check that frozen deposits do not change for a sufficient period of + time *) + let* (_b : Block.t) = loop b cycles_to_bake in + return_unit + (** This test fails when [to_cycle] in [Delegate.freeze_deposits] is smaller than [new_cycle + preserved_cycles]. *) let test_error_is_thrown_when_smaller_upper_bound_for_frozen_window () = @@ -782,6 +1024,17 @@ let tests = Tztest. [ tztest "invariants" `Quick test_invariants; + tztest "set deposits limit to 0%" `Quick (test_set_limit 0); + tztest "set deposits limit to 5%" `Quick (test_set_limit 5); + tztest "unset deposits limit" `Quick test_unset_limit; + tztest + "cannot bake with zero deposits limit" + `Quick + test_cannot_bake_with_zero_deposits_limit; + tztest + "may not bake again after full slash" + `Quick + test_may_not_bake_again_after_full_deposit_slash; tztest "deposits after stake removal" `Quick @@ -794,16 +1047,14 @@ let tests = "frozen deposits with delegation" `Quick test_frozen_deposits_with_delegation; - (* Reactivate with set deposit limit in !10449. *) - (*tztest *) - (* "test cannot bake with zero deposits" *) - (* `Quick *) - (* test_cannot_bake_with_zero_deposits; *) - (* Reactivated in !10449.. *) - (* tztest *) - (* "test simulation of limited staking with overdelegation" *) - (* `Quick *) - (* test_limit_with_overdelegation;*) + tztest + "test cannot bake with zero deposits" + `Quick + test_cannot_bake_with_zero_deposits; + tztest + "test simulation of limited staking with overdelegation" + `Quick + test_limit_with_overdelegation; tztest "test cannot bake again after full deposit slash" `Quick @@ -812,6 +1063,10 @@ let tests = "frozen deposits with overdelegation" `Quick test_frozen_deposits_with_overdelegation; + tztest + "set limit with overdelegation" + `Quick + test_set_limit_with_overdelegation; tztest "error is thrown when the frozen window is smaller" `Quick diff --git a/src/proto_alpha/lib_protocol/test/integration/validate/manager_operation_helpers.ml b/src/proto_alpha/lib_protocol/test/integration/validate/manager_operation_helpers.ml index ef6d9ec573b0235af42b238cc47bcc3bf3110964..7c6ba728193e01480cd1f8cbc14484612a277034 100644 --- a/src/proto_alpha/lib_protocol/test/integration/validate/manager_operation_helpers.ml +++ b/src/proto_alpha/lib_protocol/test/integration/validate/manager_operation_helpers.ml @@ -80,6 +80,7 @@ type manager_operation_kind = | K_Delegation | K_Undelegation | K_Self_delegation + | K_Set_deposits_limit | K_Update_consensus_key | K_Increase_paid_storage | K_Reveal @@ -170,6 +171,7 @@ let kind_to_string = function | K_Delegation -> "Delegation" | K_Undelegation -> "Undelegation" | K_Self_delegation -> "Self-delegation" + | K_Set_deposits_limit -> "Set deposits limit" | K_Update_consensus_key -> "Update consensus key" | K_Origination -> "Origination" | K_Register_global_constant -> "Register global constant" @@ -673,6 +675,17 @@ let mk_register_global_constant (oinfos : operation_req) (infos : infos) = ~source:(contract_of (get_source infos)) ~value:(Script_repr.lazy_expr (Expr.from_string "Pair 1 2")) +let mk_set_deposits_limit (oinfos : operation_req) (infos : infos) = + Op.set_deposits_limit + ?force_reveal:oinfos.force_reveal + ?fee:oinfos.fee + ?gas_limit:oinfos.gas_limit + ?storage_limit:oinfos.storage_limit + ?counter:oinfos.counter + (B infos.ctxt.block) + (contract_of (get_source infos)) + None + let mk_update_consensus_key (oinfos : operation_req) (infos : infos) = Op.update_consensus_key ?force_reveal:oinfos.force_reveal @@ -981,6 +994,7 @@ let select_op (op_req : operation_req) (infos : infos) = | K_Delegation -> mk_delegation | K_Undelegation -> mk_undelegation | K_Self_delegation -> mk_self_delegation + | K_Set_deposits_limit -> mk_set_deposits_limit | K_Update_consensus_key -> mk_update_consensus_key | K_Increase_paid_storage -> mk_increase_paid_storage | K_Reveal -> mk_reveal @@ -1346,6 +1360,7 @@ let subjects = K_Delegation; K_Undelegation; K_Self_delegation; + K_Set_deposits_limit; K_Update_consensus_key; K_Increase_paid_storage; K_Reveal; @@ -1365,10 +1380,10 @@ let subjects = ] let is_consumer = function - | K_Update_consensus_key | K_Increase_paid_storage | K_Reveal - | K_Self_delegation | K_Delegation | K_Undelegation | K_Sc_rollup_add_messages - | K_Sc_rollup_origination | K_Sc_rollup_refute | K_Sc_rollup_timeout - | K_Sc_rollup_cement | K_Sc_rollup_publish + | K_Set_deposits_limit | K_Update_consensus_key | K_Increase_paid_storage + | K_Reveal | K_Self_delegation | K_Delegation | K_Undelegation + | K_Sc_rollup_add_messages | K_Sc_rollup_origination | K_Sc_rollup_refute + | K_Sc_rollup_timeout | K_Sc_rollup_cement | K_Sc_rollup_publish | K_Sc_rollup_execute_outbox_message | K_Sc_rollup_recover_bond | K_Dal_publish_slot_header | K_Zk_rollup_origination | K_Zk_rollup_publish | K_Zk_rollup_update -> @@ -1385,8 +1400,9 @@ let revealed_subjects = let is_disabled flags = function | K_Transaction | K_Origination | K_Register_global_constant | K_Delegation - | K_Undelegation | K_Self_delegation | K_Update_consensus_key - | K_Increase_paid_storage | K_Reveal | K_Transfer_ticket -> + | K_Undelegation | K_Self_delegation | K_Set_deposits_limit + | K_Update_consensus_key | K_Increase_paid_storage | K_Reveal + | K_Transfer_ticket -> false | K_Sc_rollup_origination | K_Sc_rollup_publish | K_Sc_rollup_cement | K_Sc_rollup_add_messages | K_Sc_rollup_refute | K_Sc_rollup_timeout diff --git a/src/proto_alpha/lib_protocol/test/integration/validate/test_sanity.ml b/src/proto_alpha/lib_protocol/test/integration/validate/test_sanity.ml index 439db456ea92017532ea4af097969f9e5b3011f8..98b47f13288f011cdd0d2677278e12e44d7f5210 100644 --- a/src/proto_alpha/lib_protocol/test/integration/validate/test_sanity.ml +++ b/src/proto_alpha/lib_protocol/test/integration/validate/test_sanity.ml @@ -63,6 +63,7 @@ let ensure_kind infos kind = | Delegation _, K_Undelegation | Delegation _, K_Self_delegation | Register_global_constant _, K_Register_global_constant + | Set_deposits_limit _, K_Set_deposits_limit | Update_consensus_key _, K_Update_consensus_key | Increase_paid_storage _, K_Increase_paid_storage | Transfer_ticket _, K_Transfer_ticket @@ -80,10 +81,10 @@ let ensure_kind infos kind = | Zk_rollup_update _, K_Zk_rollup_update -> return_unit | ( ( Transaction _ | Origination _ | Register_global_constant _ - | Delegation _ | Update_consensus_key _ | Increase_paid_storage _ - | Reveal _ | Transfer_ticket _ | Sc_rollup_originate _ - | Sc_rollup_publish _ | Sc_rollup_cement _ | Sc_rollup_add_messages _ - | Sc_rollup_refute _ | Sc_rollup_timeout _ + | Delegation _ | Set_deposits_limit _ | Update_consensus_key _ + | Increase_paid_storage _ | Reveal _ | Transfer_ticket _ + | Sc_rollup_originate _ | Sc_rollup_publish _ | Sc_rollup_cement _ + | Sc_rollup_add_messages _ | Sc_rollup_refute _ | Sc_rollup_timeout _ | Sc_rollup_execute_outbox_message _ | Sc_rollup_recover_bond _ | Dal_publish_slot_header _ | Zk_rollup_origination _ | Zk_rollup_publish _ | Zk_rollup_update _ ), diff --git a/src/proto_alpha/lib_protocol/validate.ml b/src/proto_alpha/lib_protocol/validate.ml index e57dc23b4dd0aab30a2edbd1fbe0f55eb0e1a9c6..7a29526578bf8122ef40391c34b366e251a5d729 100644 --- a/src/proto_alpha/lib_protocol/validate.ml +++ b/src/proto_alpha/lib_protocol/validate.ml @@ -2124,7 +2124,8 @@ module Manager = struct return_unit | Delegation (Some pkh) -> Delegate.check_not_tz4 pkh | Update_consensus_key pk -> Delegate.Consensus_key.check_not_tz4 pk - | Delegation None | Increase_paid_storage _ -> return_unit + | Delegation None | Set_deposits_limit _ | Increase_paid_storage _ -> + return_unit | Transfer_ticket {contents; ty; _} -> let* remaining_gas = consume_decoding_gas remaining_gas contents in let* (_ : Gas.Arith.fp) = consume_decoding_gas remaining_gas ty in diff --git a/src/proto_alpha/lib_sc_rollup_node/daemon_helpers.ml b/src/proto_alpha/lib_sc_rollup_node/daemon_helpers.ml index b7148b732a01f1cd84b1373a19cab894561ceced..a1106f5a0b6ef44b05714596bc4602dbd6054cab 100644 --- a/src/proto_alpha/lib_sc_rollup_node/daemon_helpers.ml +++ b/src/proto_alpha/lib_sc_rollup_node/daemon_helpers.ml @@ -323,7 +323,7 @@ let process_l1_operation (type kind) ~catching_up node_ctxt rollup = node_ctxt.Node_context.config.sc_rollup_address) | Dal_publish_slot_header _ -> true | Reveal _ | Transaction _ | Origination _ | Delegation _ - | Update_consensus_key _ | Register_global_constant _ + | Update_consensus_key _ | Register_global_constant _ | Set_deposits_limit _ | Increase_paid_storage _ | Transfer_ticket _ | Sc_rollup_originate _ | Zk_rollup_origination _ | Zk_rollup_publish _ | Zk_rollup_update _ -> false diff --git a/tezt/tests/deposits_limit.ml b/tezt/tests/deposits_limit.ml index a2e9eeb61a6c9e3e684cff8eed96afc9558e07d7..630e90e90ef217285ae4d338a7bda8963280b6f1 100644 --- a/tezt/tests/deposits_limit.ml +++ b/tezt/tests/deposits_limit.ml @@ -34,7 +34,6 @@ let test_set_deposits_limit = ~__FILE__ ~title:"set deposits limit" ~tags:["deposits_limit"] - ~supports:Protocol.(Until_protocol (number Nairobi)) @@ fun protocol -> let* _, client = Client.init_with_protocol ~protocol `Client () in let src = Constant.bootstrap1.alias in @@ -47,7 +46,6 @@ let test_unset_deposits_limit = ~__FILE__ ~title:"unset deposits limit" ~tags:["deposits_limit"] - ~supports:Protocol.(Until_protocol (number Nairobi)) @@ fun protocol -> let* _, client = Client.init_with_protocol ~protocol `Client () in let src = Constant.bootstrap1.alias in diff --git a/tezt/tests/expected/RPC_test.ml/Alpha- (mode client) RPC regression tests- delegates.out b/tezt/tests/expected/RPC_test.ml/Alpha- (mode client) RPC regression tests- delegates.out index d2c658c332c7653e0e61de729f3969ab79adfdbf..9528e8733acd2976f3a538cd33066f7e3751a26d 100644 --- a/tezt/tests/expected/RPC_test.ml/Alpha- (mode client) RPC regression tests- delegates.out +++ b/tezt/tests/expected/RPC_test.ml/Alpha- (mode client) RPC regression tests- delegates.out @@ -20,8 +20,8 @@ { "full_balance": "4000000000000", "current_frozen_deposits": "200000000000", "frozen_deposits": "200000000000", "staking_balance": "4000000000000", "delegated_contracts": [ "[PUBLIC_KEY_HASH]" ], - "delegated_balance": "0", "total_delegated_stake": "0", - "staking_denominator": "0", "deactivated": false, "grace_period": 5, + "delegated_balance": "0", "deactivated": false, "grace_period": 5, + "total_delegated_stake": "0", "staking_denominator": "0", "voting_power": "4000000000000", "remaining_proposals": 20, "active_consensus_key": "[PUBLIC_KEY_HASH]" } diff --git a/tezt/tests/expected/RPC_test.ml/Alpha- (mode light) RPC regression tests- delegates.out b/tezt/tests/expected/RPC_test.ml/Alpha- (mode light) RPC regression tests- delegates.out index 305ebe8b50b7d2b332b26637e3780f9d14348aff..06e165d99971f2df9d72c9bf89d319e620b9a572 100644 --- a/tezt/tests/expected/RPC_test.ml/Alpha- (mode light) RPC regression tests- delegates.out +++ b/tezt/tests/expected/RPC_test.ml/Alpha- (mode light) RPC regression tests- delegates.out @@ -20,8 +20,8 @@ { "full_balance": "4000000000000", "current_frozen_deposits": "200000000000", "frozen_deposits": "200000000000", "staking_balance": "4000000000000", "delegated_contracts": [ "[PUBLIC_KEY_HASH]" ], - "delegated_balance": "0", "total_delegated_stake": "0", - "staking_denominator": "0", "deactivated": false, "grace_period": 5, + "delegated_balance": "0", "deactivated": false, "grace_period": 5, + "total_delegated_stake": "0", "staking_denominator": "0", "voting_power": "4000000000000", "remaining_proposals": 20, "active_consensus_key": "[PUBLIC_KEY_HASH]" } diff --git a/tezt/tests/expected/RPC_test.ml/Alpha- (mode proxy) RPC regression tests- delegates.out b/tezt/tests/expected/RPC_test.ml/Alpha- (mode proxy) RPC regression tests- delegates.out index 141835afb4c4c674ed2704eff83e68ec0e8e9426..0e3cf04b9ddac76e7b86dfe8dde40402fef1328c 100644 --- a/tezt/tests/expected/RPC_test.ml/Alpha- (mode proxy) RPC regression tests- delegates.out +++ b/tezt/tests/expected/RPC_test.ml/Alpha- (mode proxy) RPC regression tests- delegates.out @@ -20,8 +20,8 @@ { "full_balance": "4000000000000", "current_frozen_deposits": "200000000000", "frozen_deposits": "200000000000", "staking_balance": "4000000000000", "delegated_contracts": [ "[PUBLIC_KEY_HASH]" ], - "delegated_balance": "0", "total_delegated_stake": "0", - "staking_denominator": "0", "deactivated": false, "grace_period": 5, + "delegated_balance": "0", "deactivated": false, "grace_period": 5, + "total_delegated_stake": "0", "staking_denominator": "0", "voting_power": "4000000000000", "remaining_proposals": 20, "active_consensus_key": "[PUBLIC_KEY_HASH]" } diff --git a/tezt/tests/expected/RPC_test.ml/Alpha- (mode proxy_server_data_dir) RPC regression tests- delegates.out b/tezt/tests/expected/RPC_test.ml/Alpha- (mode proxy_server_data_dir) RPC regression tests- delegates.out index d2c658c332c7653e0e61de729f3969ab79adfdbf..9528e8733acd2976f3a538cd33066f7e3751a26d 100644 --- a/tezt/tests/expected/RPC_test.ml/Alpha- (mode proxy_server_data_dir) RPC regression tests- delegates.out +++ b/tezt/tests/expected/RPC_test.ml/Alpha- (mode proxy_server_data_dir) RPC regression tests- delegates.out @@ -20,8 +20,8 @@ { "full_balance": "4000000000000", "current_frozen_deposits": "200000000000", "frozen_deposits": "200000000000", "staking_balance": "4000000000000", "delegated_contracts": [ "[PUBLIC_KEY_HASH]" ], - "delegated_balance": "0", "total_delegated_stake": "0", - "staking_denominator": "0", "deactivated": false, "grace_period": 5, + "delegated_balance": "0", "deactivated": false, "grace_period": 5, + "total_delegated_stake": "0", "staking_denominator": "0", "voting_power": "4000000000000", "remaining_proposals": 20, "active_consensus_key": "[PUBLIC_KEY_HASH]" } diff --git a/tezt/tests/expected/RPC_test.ml/Alpha- (mode proxy_server_rpc) RPC regression tests- delegates.out b/tezt/tests/expected/RPC_test.ml/Alpha- (mode proxy_server_rpc) RPC regression tests- delegates.out index d2c658c332c7653e0e61de729f3969ab79adfdbf..9528e8733acd2976f3a538cd33066f7e3751a26d 100644 --- a/tezt/tests/expected/RPC_test.ml/Alpha- (mode proxy_server_rpc) RPC regression tests- delegates.out +++ b/tezt/tests/expected/RPC_test.ml/Alpha- (mode proxy_server_rpc) RPC regression tests- delegates.out @@ -20,8 +20,8 @@ { "full_balance": "4000000000000", "current_frozen_deposits": "200000000000", "frozen_deposits": "200000000000", "staking_balance": "4000000000000", "delegated_contracts": [ "[PUBLIC_KEY_HASH]" ], - "delegated_balance": "0", "total_delegated_stake": "0", - "staking_denominator": "0", "deactivated": false, "grace_period": 5, + "delegated_balance": "0", "deactivated": false, "grace_period": 5, + "total_delegated_stake": "0", "staking_denominator": "0", "voting_power": "4000000000000", "remaining_proposals": 20, "active_consensus_key": "[PUBLIC_KEY_HASH]" } diff --git a/tezt/tests/expected/consensus_key.ml/Alpha- Test drain delegate with (baker - delegate - consensus - destination).out b/tezt/tests/expected/consensus_key.ml/Alpha- Test drain delegate with (baker - delegate - consensus - destination).out index ec31d3c9824e786f040ac2b2b86ff1de16688029..f8c49a647634b8b2a87c143c1edeeec69a581768 100644 --- a/tezt/tests/expected/consensus_key.ml/Alpha- Test drain delegate with (baker - delegate - consensus - destination).out +++ b/tezt/tests/expected/consensus_key.ml/Alpha- Test drain delegate with (baker - delegate - consensus - destination).out @@ -29,8 +29,8 @@ This sequence of operations was run: { "full_balance": "4000000000000", "current_frozen_deposits": "200000000000", "frozen_deposits": "200000000000", "staking_balance": "4000000000000", "delegated_contracts": [ "[PUBLIC_KEY_HASH]" ], - "delegated_balance": "0", "total_delegated_stake": "0", - "staking_denominator": "0", "deactivated": false, "grace_period": 3, + "delegated_balance": "0", "deactivated": false, "grace_period": 3, + "total_delegated_stake": "0", "staking_denominator": "0", "voting_power": "4000000000000", "remaining_proposals": 20, "active_consensus_key": "[PUBLIC_KEY_HASH]" } @@ -38,8 +38,8 @@ This sequence of operations was run: { "full_balance": "4000000333333", "current_frozen_deposits": "200000000000", "frozen_deposits": "200000000000", "staking_balance": "4000000333333", "delegated_contracts": [ "[PUBLIC_KEY_HASH]" ], - "delegated_balance": "0", "total_delegated_stake": "0", - "staking_denominator": "0", "deactivated": false, "grace_period": 3, + "delegated_balance": "0", "deactivated": false, "grace_period": 3, + "total_delegated_stake": "0", "staking_denominator": "0", "voting_power": "4000000000000", "remaining_proposals": 20, "active_consensus_key": "[PUBLIC_KEY_HASH]", "pending_consensus_keys": @@ -49,8 +49,8 @@ This sequence of operations was run: { "full_balance": "4000003298113", "current_frozen_deposits": "200000164906", "frozen_deposits": "200000000000", "staking_balance": "4000003298113", "delegated_contracts": [ "[PUBLIC_KEY_HASH]" ], - "delegated_balance": "0", "total_delegated_stake": "0", - "staking_denominator": "0", "deactivated": false, "grace_period": 3, + "delegated_balance": "0", "deactivated": false, "grace_period": 3, + "total_delegated_stake": "0", "staking_denominator": "0", "voting_power": "4000000000000", "remaining_proposals": 20, "active_consensus_key": "[PUBLIC_KEY_HASH]" } @@ -58,8 +58,8 @@ This sequence of operations was run: { "full_balance": "4000003298113", "current_frozen_deposits": "200000164906", "frozen_deposits": "200000000000", "staking_balance": "4000003298113", "delegated_contracts": [ "[PUBLIC_KEY_HASH]" ], - "delegated_balance": "0", "total_delegated_stake": "0", - "staking_denominator": "0", "deactivated": false, "grace_period": 3, + "delegated_balance": "0", "deactivated": false, "grace_period": 3, + "total_delegated_stake": "0", "staking_denominator": "0", "voting_power": "4000000000000", "remaining_proposals": 20, "active_consensus_key": "[PUBLIC_KEY_HASH]" } @@ -98,8 +98,8 @@ This sequence of operations was run: { "full_balance": "238000528928", "current_frozen_deposits": "200000164906", "frozen_deposits": "200000000000", "staking_balance": "238000528928", "delegated_contracts": [ "[PUBLIC_KEY_HASH]" ], - "delegated_balance": "0", "total_delegated_stake": "0", - "staking_denominator": "0", "deactivated": false, "grace_period": 4, + "delegated_balance": "0", "deactivated": false, "grace_period": 4, + "total_delegated_stake": "0", "staking_denominator": "0", "voting_power": "4000000000000", "remaining_proposals": 20, "active_consensus_key": "[PUBLIC_KEY_HASH]" } diff --git a/tezt/tests/expected/consensus_key.ml/Alpha- Test drain delegate with (baker - delegate - consensus -- destination).out b/tezt/tests/expected/consensus_key.ml/Alpha- Test drain delegate with (baker - delegate - consensus -- destination).out index bd419bc192d162c454939563701a3d35fc93fc18..0e5abdf4f22bb8c230b78ad35a660fe616d0053b 100644 --- a/tezt/tests/expected/consensus_key.ml/Alpha- Test drain delegate with (baker - delegate - consensus -- destination).out +++ b/tezt/tests/expected/consensus_key.ml/Alpha- Test drain delegate with (baker - delegate - consensus -- destination).out @@ -29,8 +29,8 @@ This sequence of operations was run: { "full_balance": "4000000000000", "current_frozen_deposits": "200000000000", "frozen_deposits": "200000000000", "staking_balance": "4000000000000", "delegated_contracts": [ "[PUBLIC_KEY_HASH]" ], - "delegated_balance": "0", "total_delegated_stake": "0", - "staking_denominator": "0", "deactivated": false, "grace_period": 3, + "delegated_balance": "0", "deactivated": false, "grace_period": 3, + "total_delegated_stake": "0", "staking_denominator": "0", "voting_power": "4000000000000", "remaining_proposals": 20, "active_consensus_key": "[PUBLIC_KEY_HASH]" } @@ -38,8 +38,8 @@ This sequence of operations was run: { "full_balance": "4000000333333", "current_frozen_deposits": "200000000000", "frozen_deposits": "200000000000", "staking_balance": "4000000333333", "delegated_contracts": [ "[PUBLIC_KEY_HASH]" ], - "delegated_balance": "0", "total_delegated_stake": "0", - "staking_denominator": "0", "deactivated": false, "grace_period": 3, + "delegated_balance": "0", "deactivated": false, "grace_period": 3, + "total_delegated_stake": "0", "staking_denominator": "0", "voting_power": "4000000000000", "remaining_proposals": 20, "active_consensus_key": "[PUBLIC_KEY_HASH]", "pending_consensus_keys": @@ -49,8 +49,8 @@ This sequence of operations was run: { "full_balance": "4000003298113", "current_frozen_deposits": "200000164906", "frozen_deposits": "200000000000", "staking_balance": "4000003298113", "delegated_contracts": [ "[PUBLIC_KEY_HASH]" ], - "delegated_balance": "0", "total_delegated_stake": "0", - "staking_denominator": "0", "deactivated": false, "grace_period": 3, + "delegated_balance": "0", "deactivated": false, "grace_period": 3, + "total_delegated_stake": "0", "staking_denominator": "0", "voting_power": "4000000000000", "remaining_proposals": 20, "active_consensus_key": "[PUBLIC_KEY_HASH]" } @@ -58,8 +58,8 @@ This sequence of operations was run: { "full_balance": "4000003298113", "current_frozen_deposits": "200000164906", "frozen_deposits": "200000000000", "staking_balance": "4000003298113", "delegated_contracts": [ "[PUBLIC_KEY_HASH]" ], - "delegated_balance": "0", "total_delegated_stake": "0", - "staking_denominator": "0", "deactivated": false, "grace_period": 3, + "delegated_balance": "0", "deactivated": false, "grace_period": 3, + "total_delegated_stake": "0", "staking_denominator": "0", "voting_power": "4000000000000", "remaining_proposals": 20, "active_consensus_key": "[PUBLIC_KEY_HASH]" } @@ -98,8 +98,8 @@ This sequence of operations was run: { "full_balance": "238000528928", "current_frozen_deposits": "200000164906", "frozen_deposits": "200000000000", "staking_balance": "238000528928", "delegated_contracts": [ "[PUBLIC_KEY_HASH]" ], - "delegated_balance": "0", "total_delegated_stake": "0", - "staking_denominator": "0", "deactivated": false, "grace_period": 4, + "delegated_balance": "0", "deactivated": false, "grace_period": 4, + "total_delegated_stake": "0", "staking_denominator": "0", "voting_power": "4000000000000", "remaining_proposals": 20, "active_consensus_key": "[PUBLIC_KEY_HASH]" } diff --git a/tezt/tests/expected/consensus_key.ml/Alpha- Test drain delegate with (baker -- delegate - consensus - destination).out b/tezt/tests/expected/consensus_key.ml/Alpha- Test drain delegate with (baker -- delegate - consensus - destination).out index e70f9077d949e6af4351f77741ed5faf60f508f4..9fd4b853d619785f2dcc42ded9eca8ed4c78cb62 100644 --- a/tezt/tests/expected/consensus_key.ml/Alpha- Test drain delegate with (baker -- delegate - consensus - destination).out +++ b/tezt/tests/expected/consensus_key.ml/Alpha- Test drain delegate with (baker -- delegate - consensus - destination).out @@ -29,8 +29,8 @@ This sequence of operations was run: { "full_balance": "4000000000000", "current_frozen_deposits": "200000000000", "frozen_deposits": "200000000000", "staking_balance": "4000000000000", "delegated_contracts": [ "[PUBLIC_KEY_HASH]" ], - "delegated_balance": "0", "total_delegated_stake": "0", - "staking_denominator": "0", "deactivated": false, "grace_period": 3, + "delegated_balance": "0", "deactivated": false, "grace_period": 3, + "total_delegated_stake": "0", "staking_denominator": "0", "voting_power": "4000000000000", "remaining_proposals": 20, "active_consensus_key": "[PUBLIC_KEY_HASH]" } @@ -38,8 +38,8 @@ This sequence of operations was run: { "full_balance": "3999999999716", "current_frozen_deposits": "200000000000", "frozen_deposits": "200000000000", "staking_balance": "3999999999716", "delegated_contracts": [ "[PUBLIC_KEY_HASH]" ], - "delegated_balance": "0", "total_delegated_stake": "0", - "staking_denominator": "0", "deactivated": false, "grace_period": 3, + "delegated_balance": "0", "deactivated": false, "grace_period": 3, + "total_delegated_stake": "0", "staking_denominator": "0", "voting_power": "4000000000000", "remaining_proposals": 20, "active_consensus_key": "[PUBLIC_KEY_HASH]", "pending_consensus_keys": @@ -49,8 +49,8 @@ This sequence of operations was run: { "full_balance": "4000002964496", "current_frozen_deposits": "200000148225", "frozen_deposits": "200000000000", "staking_balance": "4000002964496", "delegated_contracts": [ "[PUBLIC_KEY_HASH]" ], - "delegated_balance": "0", "total_delegated_stake": "0", - "staking_denominator": "0", "deactivated": false, "grace_period": 3, + "delegated_balance": "0", "deactivated": false, "grace_period": 3, + "total_delegated_stake": "0", "staking_denominator": "0", "voting_power": "4000000000000", "remaining_proposals": 20, "active_consensus_key": "[PUBLIC_KEY_HASH]" } @@ -58,8 +58,8 @@ This sequence of operations was run: { "full_balance": "4000002964496", "current_frozen_deposits": "200000148225", "frozen_deposits": "200000000000", "staking_balance": "4000002964496", "delegated_contracts": [ "[PUBLIC_KEY_HASH]" ], - "delegated_balance": "0", "total_delegated_stake": "0", - "staking_denominator": "0", "deactivated": false, "grace_period": 3, + "delegated_balance": "0", "deactivated": false, "grace_period": 3, + "total_delegated_stake": "0", "staking_denominator": "0", "voting_power": "4000000000000", "remaining_proposals": 20, "active_consensus_key": "[PUBLIC_KEY_HASH]" } @@ -98,8 +98,8 @@ This sequence of operations was run: { "full_balance": "238000509078", "current_frozen_deposits": "200000148225", "frozen_deposits": "200000000000", "staking_balance": "238000509078", "delegated_contracts": [ "[PUBLIC_KEY_HASH]" ], - "delegated_balance": "0", "total_delegated_stake": "0", - "staking_denominator": "0", "deactivated": false, "grace_period": 4, + "delegated_balance": "0", "deactivated": false, "grace_period": 4, + "total_delegated_stake": "0", "staking_denominator": "0", "voting_power": "4000000000000", "remaining_proposals": 20, "active_consensus_key": "[PUBLIC_KEY_HASH]" } diff --git a/tezt/tests/expected/consensus_key.ml/Alpha- Test drain delegate with (baker -- delegate - consensus -- destination).out b/tezt/tests/expected/consensus_key.ml/Alpha- Test drain delegate with (baker -- delegate - consensus -- destination).out index 48749a41b404106fecf7da741517c30b3aa8e950..dabfcdcd03217aea2fc39654d6af2c1b1b0637e0 100644 --- a/tezt/tests/expected/consensus_key.ml/Alpha- Test drain delegate with (baker -- delegate - consensus -- destination).out +++ b/tezt/tests/expected/consensus_key.ml/Alpha- Test drain delegate with (baker -- delegate - consensus -- destination).out @@ -29,8 +29,8 @@ This sequence of operations was run: { "full_balance": "4000000000000", "current_frozen_deposits": "200000000000", "frozen_deposits": "200000000000", "staking_balance": "4000000000000", "delegated_contracts": [ "[PUBLIC_KEY_HASH]" ], - "delegated_balance": "0", "total_delegated_stake": "0", - "staking_denominator": "0", "deactivated": false, "grace_period": 3, + "delegated_balance": "0", "deactivated": false, "grace_period": 3, + "total_delegated_stake": "0", "staking_denominator": "0", "voting_power": "4000000000000", "remaining_proposals": 20, "active_consensus_key": "[PUBLIC_KEY_HASH]" } @@ -38,8 +38,8 @@ This sequence of operations was run: { "full_balance": "3999999999716", "current_frozen_deposits": "200000000000", "frozen_deposits": "200000000000", "staking_balance": "3999999999716", "delegated_contracts": [ "[PUBLIC_KEY_HASH]" ], - "delegated_balance": "0", "total_delegated_stake": "0", - "staking_denominator": "0", "deactivated": false, "grace_period": 3, + "delegated_balance": "0", "deactivated": false, "grace_period": 3, + "total_delegated_stake": "0", "staking_denominator": "0", "voting_power": "4000000000000", "remaining_proposals": 20, "active_consensus_key": "[PUBLIC_KEY_HASH]", "pending_consensus_keys": @@ -49,8 +49,8 @@ This sequence of operations was run: { "full_balance": "4000002964496", "current_frozen_deposits": "200000148225", "frozen_deposits": "200000000000", "staking_balance": "4000002964496", "delegated_contracts": [ "[PUBLIC_KEY_HASH]" ], - "delegated_balance": "0", "total_delegated_stake": "0", - "staking_denominator": "0", "deactivated": false, "grace_period": 3, + "delegated_balance": "0", "deactivated": false, "grace_period": 3, + "total_delegated_stake": "0", "staking_denominator": "0", "voting_power": "4000000000000", "remaining_proposals": 20, "active_consensus_key": "[PUBLIC_KEY_HASH]" } @@ -58,8 +58,8 @@ This sequence of operations was run: { "full_balance": "4000002964496", "current_frozen_deposits": "200000148225", "frozen_deposits": "200000000000", "staking_balance": "4000002964496", "delegated_contracts": [ "[PUBLIC_KEY_HASH]" ], - "delegated_balance": "0", "total_delegated_stake": "0", - "staking_denominator": "0", "deactivated": false, "grace_period": 3, + "delegated_balance": "0", "deactivated": false, "grace_period": 3, + "total_delegated_stake": "0", "staking_denominator": "0", "voting_power": "4000000000000", "remaining_proposals": 20, "active_consensus_key": "[PUBLIC_KEY_HASH]" } @@ -98,8 +98,8 @@ This sequence of operations was run: { "full_balance": "238000509078", "current_frozen_deposits": "200000148225", "frozen_deposits": "200000000000", "staking_balance": "238000509078", "delegated_contracts": [ "[PUBLIC_KEY_HASH]" ], - "delegated_balance": "0", "total_delegated_stake": "0", - "staking_denominator": "0", "deactivated": false, "grace_period": 4, + "delegated_balance": "0", "deactivated": false, "grace_period": 4, + "total_delegated_stake": "0", "staking_denominator": "0", "voting_power": "4000000000000", "remaining_proposals": 20, "active_consensus_key": "[PUBLIC_KEY_HASH]" } diff --git a/tezt/tests/expected/consensus_key.ml/Alpha- Test register with consensus key.out b/tezt/tests/expected/consensus_key.ml/Alpha- Test register with consensus key.out index 54d39cd5d8759dd3a83e603c84cd36d16ce8c7d6..3259d73cdb5f6f99d7099fc284c4f83d01cd6415 100644 --- a/tezt/tests/expected/consensus_key.ml/Alpha- Test register with consensus key.out +++ b/tezt/tests/expected/consensus_key.ml/Alpha- Test register with consensus key.out @@ -64,8 +64,8 @@ This sequence of operations was run: { "full_balance": "999999999385", "current_frozen_deposits": "0", "frozen_deposits": "0", "staking_balance": "999999999385", "delegated_contracts": [ "[PUBLIC_KEY_HASH]" ], - "delegated_balance": "0", "total_delegated_stake": "0", - "staking_denominator": "0", "deactivated": false, "grace_period": 3, + "delegated_balance": "0", "deactivated": false, "grace_period": 3, + "total_delegated_stake": "0", "staking_denominator": "0", "active_consensus_key": "[PUBLIC_KEY_HASH]", "pending_consensus_keys": [ { "cycle": 2, "pkh": "[PUBLIC_KEY_HASH]" } ] } @@ -77,6 +77,6 @@ This sequence of operations was run: { "full_balance": "999999999385", "current_frozen_deposits": "49999999970", "frozen_deposits": "0", "staking_balance": "999999999385", "delegated_contracts": [ "[PUBLIC_KEY_HASH]" ], - "delegated_balance": "0", "total_delegated_stake": "0", - "staking_denominator": "0", "deactivated": false, "grace_period": 3, + "delegated_balance": "0", "deactivated": false, "grace_period": 3, + "total_delegated_stake": "0", "staking_denominator": "0", "active_consensus_key": "[PUBLIC_KEY_HASH]" } diff --git a/tezt/tests/expected/consensus_key.ml/Alpha- Test set consensus key - baker is delegate.out b/tezt/tests/expected/consensus_key.ml/Alpha- Test set consensus key - baker is delegate.out index bd1aafcc1ff82fa89606ece89e0452eeae875e5f..3a0d2ea180d012e196d6ab8005cf7c0198cb01db 100644 --- a/tezt/tests/expected/consensus_key.ml/Alpha- Test set consensus key - baker is delegate.out +++ b/tezt/tests/expected/consensus_key.ml/Alpha- Test set consensus key - baker is delegate.out @@ -29,8 +29,8 @@ This sequence of operations was run: { "full_balance": "4000000000000", "current_frozen_deposits": "200000000000", "frozen_deposits": "200000000000", "staking_balance": "4000000000000", "delegated_contracts": [ "[PUBLIC_KEY_HASH]" ], - "delegated_balance": "0", "total_delegated_stake": "0", - "staking_denominator": "0", "deactivated": false, "grace_period": 3, + "delegated_balance": "0", "deactivated": false, "grace_period": 3, + "total_delegated_stake": "0", "staking_denominator": "0", "voting_power": "4000000000000", "remaining_proposals": 20, "active_consensus_key": "[PUBLIC_KEY_HASH]" } @@ -38,8 +38,8 @@ This sequence of operations was run: { "full_balance": "4000000333333", "current_frozen_deposits": "200000000000", "frozen_deposits": "200000000000", "staking_balance": "4000000333333", "delegated_contracts": [ "[PUBLIC_KEY_HASH]" ], - "delegated_balance": "0", "total_delegated_stake": "0", - "staking_denominator": "0", "deactivated": false, "grace_period": 3, + "delegated_balance": "0", "deactivated": false, "grace_period": 3, + "total_delegated_stake": "0", "staking_denominator": "0", "voting_power": "4000000000000", "remaining_proposals": 20, "active_consensus_key": "[PUBLIC_KEY_HASH]", "pending_consensus_keys": @@ -49,7 +49,7 @@ This sequence of operations was run: { "full_balance": "4000003298113", "current_frozen_deposits": "200000164906", "frozen_deposits": "200000000000", "staking_balance": "4000003298113", "delegated_contracts": [ "[PUBLIC_KEY_HASH]" ], - "delegated_balance": "0", "total_delegated_stake": "0", - "staking_denominator": "0", "deactivated": false, "grace_period": 3, + "delegated_balance": "0", "deactivated": false, "grace_period": 3, + "total_delegated_stake": "0", "staking_denominator": "0", "voting_power": "4000000000000", "remaining_proposals": 20, "active_consensus_key": "[PUBLIC_KEY_HASH]" } diff --git a/tezt/tests/expected/consensus_key.ml/Alpha- Test set consensus key - baker is not delegate.out b/tezt/tests/expected/consensus_key.ml/Alpha- Test set consensus key - baker is not delegate.out index fcf568c027217ccb1400569065dafda53afc6e59..c4a3c8433dfe1079a59be327373ddd3a0711cbd6 100644 --- a/tezt/tests/expected/consensus_key.ml/Alpha- Test set consensus key - baker is not delegate.out +++ b/tezt/tests/expected/consensus_key.ml/Alpha- Test set consensus key - baker is not delegate.out @@ -29,8 +29,8 @@ This sequence of operations was run: { "full_balance": "4000000000000", "current_frozen_deposits": "200000000000", "frozen_deposits": "200000000000", "staking_balance": "4000000000000", "delegated_contracts": [ "[PUBLIC_KEY_HASH]" ], - "delegated_balance": "0", "total_delegated_stake": "0", - "staking_denominator": "0", "deactivated": false, "grace_period": 3, + "delegated_balance": "0", "deactivated": false, "grace_period": 3, + "total_delegated_stake": "0", "staking_denominator": "0", "voting_power": "4000000000000", "remaining_proposals": 20, "active_consensus_key": "[PUBLIC_KEY_HASH]" } @@ -38,8 +38,8 @@ This sequence of operations was run: { "full_balance": "3999999999716", "current_frozen_deposits": "200000000000", "frozen_deposits": "200000000000", "staking_balance": "3999999999716", "delegated_contracts": [ "[PUBLIC_KEY_HASH]" ], - "delegated_balance": "0", "total_delegated_stake": "0", - "staking_denominator": "0", "deactivated": false, "grace_period": 3, + "delegated_balance": "0", "deactivated": false, "grace_period": 3, + "total_delegated_stake": "0", "staking_denominator": "0", "voting_power": "4000000000000", "remaining_proposals": 20, "active_consensus_key": "[PUBLIC_KEY_HASH]", "pending_consensus_keys": @@ -49,7 +49,7 @@ This sequence of operations was run: { "full_balance": "4000002964496", "current_frozen_deposits": "200000148225", "frozen_deposits": "200000000000", "staking_balance": "4000002964496", "delegated_contracts": [ "[PUBLIC_KEY_HASH]" ], - "delegated_balance": "0", "total_delegated_stake": "0", - "staking_denominator": "0", "deactivated": false, "grace_period": 3, + "delegated_balance": "0", "deactivated": false, "grace_period": 3, + "total_delegated_stake": "0", "staking_denominator": "0", "voting_power": "4000000000000", "remaining_proposals": 20, "active_consensus_key": "[PUBLIC_KEY_HASH]" } diff --git a/tezt/tests/expected/deposits_limit.ml/Alpha- set deposits limit.out b/tezt/tests/expected/deposits_limit.ml/Alpha- set deposits limit.out new file mode 100644 index 0000000000000000000000000000000000000000..8ac64a759156d64f8e6245177a1ac64667dede16 --- /dev/null +++ b/tezt/tests/expected/deposits_limit.ml/Alpha- set deposits limit.out @@ -0,0 +1,26 @@ +Node is bootstrapped. +Estimated gas: 168.052 units (will add 0 for safety) +Estimated storage: no bytes added +Operation successfully injected in the node. +Operation hash is 'oogPg9fm3Wo8Fub69ehKvyhmefv442MSvvKME7awo3zvZVAsuTo' +NOT waiting for the operation to be included. +Use command + octez-client wait for oogPg9fm3Wo8Fub69ehKvyhmefv442MSvvKME7awo3zvZVAsuTo to be included --confirmations 1 --branch BLockGenesisGenesisGenesisGenesisGenesisf79b5d1CoW2 +and/or an external block explorer to make sure that it has been included. +This sequence of operations was run: + Manager signed operations: + From: tz1KqTpEZ7Yob7QbPE4Hy4Wo8fHG8LhKxZSx + Fee to the baker: ꜩ0.000247 + Expected counter: 1 + Gas limit: 169 + Storage limit: 0 bytes + Balance updates: + tz1KqTpEZ7Yob7QbPE4Hy4Wo8fHG8LhKxZSx ... -ꜩ0.000247 + payload fees(the block proposer) ....... +ꜩ0.000247 + Set deposits limit: + Delegate: tz1KqTpEZ7Yob7QbPE4Hy4Wo8fHG8LhKxZSx + Limit: 1000 + This deposits limit modification was successfully applied + Consumed gas: 167.986 + + diff --git a/tezt/tests/expected/deposits_limit.ml/Alpha- unset deposits limit.out b/tezt/tests/expected/deposits_limit.ml/Alpha- unset deposits limit.out new file mode 100644 index 0000000000000000000000000000000000000000..fc4436f54195c0977d349be25721b7af5f50b9ec --- /dev/null +++ b/tezt/tests/expected/deposits_limit.ml/Alpha- unset deposits limit.out @@ -0,0 +1,26 @@ +Node is bootstrapped. +Estimated gas: 167.886 units (will add 0 for safety) +Estimated storage: no bytes added +Operation successfully injected in the node. +Operation hash is 'oo1PJ41t8u2VYdoeFVgREH9LKKtASE141H3wWRmKRbuBcshW3hR' +NOT waiting for the operation to be included. +Use command + octez-client wait for oo1PJ41t8u2VYdoeFVgREH9LKKtASE141H3wWRmKRbuBcshW3hR to be included --confirmations 1 --branch BLockGenesisGenesisGenesisGenesisGenesisf79b5d1CoW2 +and/or an external block explorer to make sure that it has been included. +This sequence of operations was run: + Manager signed operations: + From: tz1KqTpEZ7Yob7QbPE4Hy4Wo8fHG8LhKxZSx + Fee to the baker: ꜩ0.000242 + Expected counter: 1 + Gas limit: 168 + Storage limit: 0 bytes + Balance updates: + tz1KqTpEZ7Yob7QbPE4Hy4Wo8fHG8LhKxZSx ... -ꜩ0.000242 + payload fees(the block proposer) ....... +ꜩ0.000242 + Set deposits limit: + Delegate: tz1KqTpEZ7Yob7QbPE4Hy4Wo8fHG8LhKxZSx + Unlimited deposits + This deposits limit modification was successfully applied + Consumed gas: 167.820 + +