diff --git a/client-libs/kaitai-struct-files/files/alpha__constants.ksy b/client-libs/kaitai-struct-files/files/alpha__constants.ksy index 57b37cddac9161485126b2342f3a872319705a8d..7e9d2b906d8570651a972bbbf60848630baf2454 100644 --- a/client-libs/kaitai-struct-files/files/alpha__constants.ksy +++ b/client-libs/kaitai-struct-files/files/alpha__constants.ksy @@ -363,16 +363,8 @@ seq: type: u1 - id: edge_of_staking_over_delegation type: u1 -- id: adaptive_issuance_launch_ema_threshold - type: s4be - id: adaptive_rewards_params type: adaptive_rewards_params -- id: adaptive_issuance_activation_vote_enable - type: u1 - enum: bool -- id: adaptive_issuance_force_activation - type: u1 - enum: bool - id: direct_ticket_spending_enable type: u1 enum: bool diff --git a/client-libs/kaitai-struct-files/files/alpha__constants__parametric.ksy b/client-libs/kaitai-struct-files/files/alpha__constants__parametric.ksy index af2c8cac106f99468c5eb2381b1bb8ab7a4bf00c..5b20358943250af95624a590ddc13066df7a6cc0 100644 --- a/client-libs/kaitai-struct-files/files/alpha__constants__parametric.ksy +++ b/client-libs/kaitai-struct-files/files/alpha__constants__parametric.ksy @@ -335,16 +335,8 @@ seq: type: u1 - id: edge_of_staking_over_delegation type: u1 -- id: adaptive_issuance_launch_ema_threshold - type: s4be - id: adaptive_rewards_params type: adaptive_rewards_params -- id: adaptive_issuance_activation_vote_enable - type: u1 - enum: bool -- id: adaptive_issuance_force_activation - type: u1 - enum: bool - id: direct_ticket_spending_enable type: u1 enum: bool diff --git a/client-libs/kaitai-struct-files/files/alpha__parameters.ksy b/client-libs/kaitai-struct-files/files/alpha__parameters.ksy index 5b4ef02703a7974b9c0dace50fc9dbf5b8278c39..9695f394f9246ec87ed92af9a1db487430808299 100644 --- a/client-libs/kaitai-struct-files/files/alpha__parameters.ksy +++ b/client-libs/kaitai-struct-files/files/alpha__parameters.ksy @@ -613,16 +613,8 @@ seq: type: u1 - id: edge_of_staking_over_delegation type: u1 -- id: adaptive_issuance_launch_ema_threshold - type: s4be - id: adaptive_rewards_params type: adaptive_rewards_params -- id: adaptive_issuance_activation_vote_enable - type: u1 - enum: bool -- id: adaptive_issuance_force_activation - type: u1 - enum: bool - id: direct_ticket_spending_enable type: u1 enum: bool diff --git a/docs/protocols/alpha.rst b/docs/protocols/alpha.rst index 0a5dc83b8f466c2ffcc3d85bb728af96703a9452..5a3a337f7d4ded204fc758a36f4e26dbc6ea6414 100644 --- a/docs/protocols/alpha.rst +++ b/docs/protocols/alpha.rst @@ -88,4 +88,4 @@ Internal - Removed obsolete feature flags and code related to adaptive issuance activation, auto-staking, and old slashing. (MRs :gl:`!15215`, - :gl:`!15223`) + :gl:`!15223`, :gl:`!15211`) diff --git a/manifest/product_octez.ml b/manifest/product_octez.ml index 17760cafcf5882a64a8f9e6edfe268fa4071cee8..073a9ac04e20694eacbf6797282b559f86de1cd6 100644 --- a/manifest/product_octez.ml +++ b/manifest/product_octez.ml @@ -5641,7 +5641,7 @@ end = struct [ ("test_constants", true); ("test_frozen_bonds", true); - ("test_adaptive_issuance_launch", N.(number >= 018)); + ("test_adaptive_issuance_launch", N.(number >= 018 && number <= 021)); ("test_adaptive_issuance_roundtrip", N.(number == 018)); ("test_scenario_base", N.(number >= 019)); ("test_scenario_stake", N.(number >= 019)); diff --git a/src/proto_alpha/lib_parameters/default_parameters.ml b/src/proto_alpha/lib_parameters/default_parameters.ml index 369848b78fd08d2421c44f9821bd23c760bb2978..448ae60f2356835730b36b6664b3371ce19413f2 100644 --- a/src/proto_alpha/lib_parameters/default_parameters.ml +++ b/src/proto_alpha/lib_parameters/default_parameters.ml @@ -304,7 +304,6 @@ let constants_mainnet : Constants.Parametric.t = { global_limit_of_staking_over_baking = 9; edge_of_staking_over_delegation = 3; - launch_ema_threshold = 0l; adaptive_rewards_params = { issuance_ratio_final_min = Q.(0_25 // 100_00); @@ -321,8 +320,6 @@ let constants_mainnet : Constants.Parametric.t = center_dz = Q.(1 // 2); radius_dz = Q.(1 // 50); }; - activation_vote_enable = true; - force_activation = false; }; (* TODO: https://gitlab.com/tezos/tezos/-/issues/6668 Enable once at least the following is done: diff --git a/src/proto_alpha/lib_protocol/adaptive_issuance_storage.ml b/src/proto_alpha/lib_protocol/adaptive_issuance_storage.ml index e42a33eb7deaffe19c15f046aec45d0e0ac01566..a51df60fa3a0231ff448c8def826ede9d130f066 100644 --- a/src/proto_alpha/lib_protocol/adaptive_issuance_storage.ml +++ b/src/proto_alpha/lib_protocol/adaptive_issuance_storage.ml @@ -370,9 +370,6 @@ let init ctxt = let* ctxt = Storage.Adaptive_issuance.Launch_ema.init ctxt 0l in Storage.Adaptive_issuance.Activation.init ctxt None -let activate ctxt ~cycle = - Storage.Adaptive_issuance.Activation.update ctxt (Some cycle) - let set_adaptive_issuance_enable ctxt = let open Lwt_result_syntax in let+ enable = @@ -402,27 +399,7 @@ let update_ema ctxt ~vote = (Per_block_votes_repr.Adaptive_issuance_launch_EMA.to_int32 new_ema) in let* launch_cycle = launch_cycle ctxt in - let open Constants_storage in - let+ ctxt, launch_cycle = - if - (not (adaptive_issuance_activation_vote_enable ctxt)) - || Per_block_votes_repr.Adaptive_issuance_launch_EMA.( - new_ema < adaptive_issuance_launch_ema_threshold ctxt) - then return (ctxt, launch_cycle) - else - match launch_cycle with - | Some _ -> - (* the feature is already set to launch, do nothing to avoid postponing it. *) - return (ctxt, launch_cycle) - | None -> - (* set the feature to activate in a few cycles *) - let current_cycle = (Level_storage.current ctxt).cycle in - let delay = adaptive_issuance_activation_delay ctxt in - let cycle = safe_cycle_add current_cycle delay in - let+ ctxt = activate ctxt ~cycle in - (ctxt, Some cycle) - in - (ctxt, launch_cycle, new_ema) + return (ctxt, launch_cycle, new_ema) module For_RPC = struct let get_reward_coeff = get_reward_coeff diff --git a/src/proto_alpha/lib_protocol/alpha_context.mli b/src/proto_alpha/lib_protocol/alpha_context.mli index 56d9a7883520392f8160d4b475f47bd8a53a5f04..d44bd62c52dd7511712cda1243c58a69af0e632f 100644 --- a/src/proto_alpha/lib_protocol/alpha_context.mli +++ b/src/proto_alpha/lib_protocol/alpha_context.mli @@ -889,10 +889,7 @@ module Constants : sig type adaptive_issuance = { global_limit_of_staking_over_baking : int; edge_of_staking_over_delegation : int; - launch_ema_threshold : int32; adaptive_rewards_params : adaptive_rewards_params; - activation_vote_enable : bool; - force_activation : bool; } type issuance_weights = { diff --git a/src/proto_alpha/lib_protocol/constants_parametric_repr.ml b/src/proto_alpha/lib_protocol/constants_parametric_repr.ml index e105ec83b31ac813962eda0550505206a8e873f0..cfea2310de7f48a2abe0756cdd4f5e3459a38451 100644 --- a/src/proto_alpha/lib_protocol/constants_parametric_repr.ml +++ b/src/proto_alpha/lib_protocol/constants_parametric_repr.ml @@ -229,10 +229,7 @@ type adaptive_rewards_params = { type adaptive_issuance = { global_limit_of_staking_over_baking : int; edge_of_staking_over_delegation : int; - launch_ema_threshold : int32; adaptive_rewards_params : adaptive_rewards_params; - activation_vote_enable : bool; - force_activation : bool; } type issuance_weights = { @@ -478,38 +475,23 @@ let adaptive_issuance_encoding = (fun { global_limit_of_staking_over_baking; edge_of_staking_over_delegation; - launch_ema_threshold; adaptive_rewards_params; - activation_vote_enable; - force_activation; } -> ( global_limit_of_staking_over_baking, edge_of_staking_over_delegation, - launch_ema_threshold, - adaptive_rewards_params, - activation_vote_enable, - force_activation )) + adaptive_rewards_params )) (fun ( global_limit_of_staking_over_baking, edge_of_staking_over_delegation, - launch_ema_threshold, - adaptive_rewards_params, - activation_vote_enable, - force_activation ) -> + adaptive_rewards_params ) -> { global_limit_of_staking_over_baking; edge_of_staking_over_delegation; - launch_ema_threshold; adaptive_rewards_params; - activation_vote_enable; - force_activation; }) - (obj6 + (obj3 (req "global_limit_of_staking_over_baking" uint8) (req "edge_of_staking_over_delegation" uint8) - (req "adaptive_issuance_launch_ema_threshold" int32) - (req "adaptive_rewards_params" adaptive_rewards_params_encoding) - (req "adaptive_issuance_activation_vote_enable" bool) - (req "adaptive_issuance_force_activation" bool)) + (req "adaptive_rewards_params" adaptive_rewards_params_encoding)) let issuance_weights_encoding = let open Data_encoding in diff --git a/src/proto_alpha/lib_protocol/constants_parametric_repr.mli b/src/proto_alpha/lib_protocol/constants_parametric_repr.mli index 60a1a50fbd15bffd9bb1f3dac29c7b411533baae..2a7576377dbdc26681f62b05c739573c1416a7e6 100644 --- a/src/proto_alpha/lib_protocol/constants_parametric_repr.mli +++ b/src/proto_alpha/lib_protocol/constants_parametric_repr.mli @@ -140,18 +140,8 @@ type adaptive_issuance = { int; edge_of_staking_over_delegation : (* Weight of staking over delegation. *) int; - launch_ema_threshold : (* Threshold of the activation vote *) int32; adaptive_rewards_params : (* Parameters for the reward mechanism *) adaptive_rewards_params; - activation_vote_enable : - (* If set to true, reaching the launch_ema_threshold in the adaptive - issuance activation vote triggers the activation of the adaptive - inflation feature; otherwise the activation vote has no effect. *) - bool; - force_activation : - (* For testing purposes. If set to true, the adaptive issuance feature is - enabled without waiting to reach the launch_ema_threshold.*) - bool; } type issuance_weights = { diff --git a/src/proto_alpha/lib_protocol/constants_storage.ml b/src/proto_alpha/lib_protocol/constants_storage.ml index d765b1c2f2f58d14097600043144b357ed23eb78..4f447b0d7766ee460faa2c4a16593215e665dcf9 100644 --- a/src/proto_alpha/lib_protocol/constants_storage.ml +++ b/src/proto_alpha/lib_protocol/constants_storage.ml @@ -279,18 +279,9 @@ let adaptive_issuance_global_limit_of_staking_over_baking c = let adaptive_issuance_edge_of_staking_over_delegation c = (adaptive_issuance c).edge_of_staking_over_delegation -let adaptive_issuance_launch_ema_threshold c = - (adaptive_issuance c).launch_ema_threshold - let adaptive_issuance_rewards_params c = (adaptive_issuance c).adaptive_rewards_params -let adaptive_issuance_activation_vote_enable c = - (adaptive_issuance c).activation_vote_enable - -let adaptive_issuance_force_activation c = - (adaptive_issuance c).force_activation - let direct_ticket_spending_enable c = (Raw_context.constants c).direct_ticket_spending_enable diff --git a/src/proto_alpha/lib_protocol/constants_storage.mli b/src/proto_alpha/lib_protocol/constants_storage.mli index 2de3bbe766325148c10a1e8371c42cc8b81304c3..1c7cadb64a852305a2d61c4d16595397dfadf7cf 100644 --- a/src/proto_alpha/lib_protocol/constants_storage.mli +++ b/src/proto_alpha/lib_protocol/constants_storage.mli @@ -146,15 +146,9 @@ val adaptive_issuance_global_limit_of_staking_over_baking : Raw_context.t -> int val adaptive_issuance_edge_of_staking_over_delegation : Raw_context.t -> int -val adaptive_issuance_launch_ema_threshold : Raw_context.t -> int32 - -val adaptive_issuance_activation_vote_enable : Raw_context.t -> bool - val adaptive_issuance_rewards_params : Raw_context.t -> Constants_parametric_repr.adaptive_rewards_params -val adaptive_issuance_force_activation : Raw_context.t -> bool - val direct_ticket_spending_enable : Raw_context.t -> bool val allow_tz4_delegate_enable : Raw_context.t -> bool diff --git a/src/proto_alpha/lib_protocol/init_storage.ml b/src/proto_alpha/lib_protocol/init_storage.ml index 07ac19e6136d6eb45c5ab37fdf5f1769e7101ac2..f6bcc8cff67bde941d51d86ef207f3b9f9de68e1 100644 --- a/src/proto_alpha/lib_protocol/init_storage.ml +++ b/src/proto_alpha/lib_protocol/init_storage.ml @@ -280,11 +280,9 @@ let prepare_first_block chain_id ctxt ~typecheck_smart_contract let*! ctxt = Storage.Pending_migration.Balance_updates.add ctxt balance_updates in - if Constants_storage.adaptive_issuance_force_activation ctxt then - let ctxt = Raw_context.set_adaptive_issuance_enable ctxt in - let* ctxt = - let current_cycle = (Level_storage.current ctxt).cycle in - Storage.Adaptive_issuance.Activation.update ctxt (Some current_cycle) - in - return ctxt - else return ctxt + let ctxt = Raw_context.set_adaptive_issuance_enable ctxt in + let* ctxt = + let current_cycle = (Level_storage.current ctxt).cycle in + Storage.Adaptive_issuance.Activation.update ctxt (Some current_cycle) + in + return ctxt diff --git a/src/proto_alpha/lib_protocol/raw_context.ml b/src/proto_alpha/lib_protocol/raw_context.ml index f42782d048f8b4635aae5f318e4a3e48730f4da7..a9c8fe017e66744385f7b1642cc46e0c86a15fee 100644 --- a/src/proto_alpha/lib_protocol/raw_context.ml +++ b/src/proto_alpha/lib_protocol/raw_context.ml @@ -1145,10 +1145,7 @@ let prepare_first_block ~level ~timestamp chain_id ctxt = let ({ global_limit_of_staking_over_baking; edge_of_staking_over_delegation; - launch_ema_threshold; adaptive_rewards_params = _; - activation_vote_enable; - force_activation; } : Previous.adaptive_issuance) = c.adaptive_issuance @@ -1157,10 +1154,7 @@ let prepare_first_block ~level ~timestamp chain_id ctxt = { global_limit_of_staking_over_baking; edge_of_staking_over_delegation; - launch_ema_threshold; adaptive_rewards_params; - activation_vote_enable; - force_activation; } in let issuance_weights = @@ -1436,11 +1430,11 @@ let prepare_first_block ~level ~timestamp chain_id ctxt = let ({ global_limit_of_staking_over_baking = _; edge_of_staking_over_delegation; - launch_ema_threshold; + launch_ema_threshold = _; adaptive_rewards_params = _; - activation_vote_enable; + activation_vote_enable = _; autostaking_enable = _; - force_activation; + force_activation = _; ns_enable = _; } : Previous.adaptive_issuance) = @@ -1450,10 +1444,7 @@ let prepare_first_block ~level ~timestamp chain_id ctxt = { global_limit_of_staking_over_baking = 9; edge_of_staking_over_delegation; - launch_ema_threshold; adaptive_rewards_params; - activation_vote_enable; - force_activation; } in let issuance_weights = diff --git a/src/proto_alpha/lib_protocol/test/helpers/assert.ml b/src/proto_alpha/lib_protocol/test/helpers/assert.ml index a489c8af8d43723ca4c91f55d849fec3ebc618bc..7781d5cc91bfbcb0e70d8d94174e35d8733f7aa0 100644 --- a/src/proto_alpha/lib_protocol/test/helpers/assert.ml +++ b/src/proto_alpha/lib_protocol/test/helpers/assert.ml @@ -165,6 +165,9 @@ let leq_int32 ~loc (a : int32) (b : int32) = let lt_int32 ~loc (a : int32) (b : int32) = lt ~loc Compare.Int32.compare "Int32 comparison" Int32.pp a b +let lt_int64 ~loc (a : int64) (b : int64) = + lt ~loc Compare.Int64.compare "Int64 comparison" Int64.pp a b + (* int64 *) let equal_int64 ~loc (a : int64) (b : int64) = equal ~loc Compare.Int64.( = ) "Int64 aren't equal" Int64.pp a b diff --git a/src/proto_alpha/lib_protocol/test/helpers/block.ml b/src/proto_alpha/lib_protocol/test/helpers/block.ml index 306ceedbc40ab537f62dddc93d7c6c07fa4c0749..3c1726dee472493b8a4b8c2bbd2d79f337444cb8 100644 --- a/src/proto_alpha/lib_protocol/test/helpers/block.ml +++ b/src/proto_alpha/lib_protocol/test/helpers/block.ml @@ -183,6 +183,15 @@ let get_round (b : t) = let+ fitness = from_raw fitness in round fitness) +let block_producer block = + let open Lwt_result_wrap_syntax in + let* ctxt = get_alpha_ctxt block in + let*?@ round = Fitness.round_from_raw block.header.shell.fitness in + let*@ _ctxt, _slot, block_producer = + Stake_distribution.baking_rights_owner ctxt (Level.current ctxt) ~round + in + return block_producer + module Forge = struct type header = { baker : public_key_hash; diff --git a/src/proto_alpha/lib_protocol/test/helpers/block.mli b/src/proto_alpha/lib_protocol/test/helpers/block.mli index 5fdefe5a5efd844bd3b3142c3abf08aa3752f75f..a475ebe62755e2d44666b0653a5bc3e0863da48c 100644 --- a/src/proto_alpha/lib_protocol/test/helpers/block.mli +++ b/src/proto_alpha/lib_protocol/test/helpers/block.mli @@ -75,6 +75,9 @@ val get_next_baker : val get_round : block -> Round.t Environment.Error_monad.tzresult +(** Returns the consensus key that was used to bake the block. *) +val block_producer : block -> Consensus_key.pk tzresult Lwt.t + module Forge : sig val contents : ?proof_of_work_threshold:Int64.t -> diff --git a/src/proto_alpha/lib_protocol/test/helpers/constants_helpers.ml b/src/proto_alpha/lib_protocol/test/helpers/constants_helpers.ml index afc90d9a9e600e822d8efd16fae120848d4d2019..aaa15dcc2554bd988fdc7efe4907b0ecdc8ee2bb 100644 --- a/src/proto_alpha/lib_protocol/test/helpers/constants_helpers.ml +++ b/src/proto_alpha/lib_protocol/test/helpers/constants_helpers.ml @@ -130,15 +130,6 @@ module Set = struct let adaptive_issuance adaptive_issuance (c : t) = {c with adaptive_issuance} module Adaptive_issuance = struct - let activation_vote_enable activation_vote_enable (c : t) = - adaptive_issuance {c.adaptive_issuance with activation_vote_enable} c - - let force_activation force_activation (c : t) = - adaptive_issuance {c.adaptive_issuance with force_activation} c - - let launch_ema_threshold launch_ema_threshold (c : t) = - adaptive_issuance {c.adaptive_issuance with launch_ema_threshold} c - let adaptive_rewards_params adaptive_rewards_params (c : t) = adaptive_issuance {c.adaptive_issuance with adaptive_rewards_params} c diff --git a/src/proto_alpha/lib_protocol/test/helpers/scenario_bake.ml b/src/proto_alpha/lib_protocol/test/helpers/scenario_bake.ml index d6d9cdcb2f621fe7f11570ca3de2f92fdb9d0b14..7554a010a908e698d37519ee7f7c9f1a3049411c 100644 --- a/src/proto_alpha/lib_protocol/test/helpers/scenario_bake.ml +++ b/src/proto_alpha/lib_protocol/test/helpers/scenario_bake.ml @@ -255,6 +255,14 @@ let attest_all_ = (* Does not produce a new block *) let attest_all = exec attest_all_ +let check_ai_launch_cycle_is_zero ~loc block = + let open Lwt_result_syntax in + let* ai_launch_cycle = Context.get_adaptive_issuance_launch_cycle (B block) in + let ai_launch_cycle = WithExceptions.Option.get ~loc ai_launch_cycle in + if not Cycle.(equal ai_launch_cycle root) then + Test.fail ~__LOC__:loc "AI launch cycle should always be zero" ; + return_unit + (** Bake a block, with the given baker and the given operations. *) let bake ?baker : t -> t tzresult Lwt.t = fun (block, state) -> @@ -365,9 +373,7 @@ let bake ?baker : t -> t tzresult Lwt.t = attesters) state in - let* state = - State_ai_flags.AI_Activation.check_activation_cycle block state - in + let* () = check_ai_launch_cycle_is_zero ~loc:__LOC__ block in let* state = State.apply_rewards ~baker:baker_name block state in let new_future_current_cycle = Cycle.succ (Block.current_cycle block) in (* Dawn of a new cycle: apply cycle end operations *) @@ -531,9 +537,6 @@ let wait_cycle_until condition = let to_, done_ = let rec get_names condition = match condition with - | `AI_activation -> ("AI activation", "AI activated") - | `AI_activation_with_votes -> - ("AI activation (with votes)", "AI activated") | `delegate_parameters_activation -> ("delegate parameters activation", "delegate parameters activated") | `right_before_delegate_parameters_activation -> @@ -549,33 +552,6 @@ let wait_cycle_until condition = let condition (init_block, init_state) = let rec stopper condition = match condition with - | `AI_activation -> ( - fun (block, _state) -> - (* Expects the launch cycle to be already set *) - match init_state.State.ai_activation_cycle with - | Some launch_cycle -> - let current_cycle = Block.current_cycle block in - Cycle.(current_cycle >= launch_cycle) - | _ -> - Log.error - "wait_cycle_until `AI_activation: launch cycle not found, \ - aborting." ; - assert false) - | `AI_activation_with_votes -> - fun (block, state) -> - if State_ai_flags.AI_Activation.enabled init_state then - match state.State.ai_activation_cycle with - (* Since AI_activation is enabled, we expect the activation - cycle to be set eventually *) - | Some launch_cycle -> - let current_cycle = Block.current_cycle block in - Cycle.(current_cycle >= launch_cycle) - | _ -> false - else ( - Log.error - "wait_cycle_until `AI_activation_with_votes: AI cannot \ - activate with the current protocol parameters, aborting." ; - assert false) | `delegate_parameters_activation -> fun (block, _state) -> let init_cycle = Block.current_cycle init_block in @@ -608,14 +584,6 @@ let wait_cycle_until condition = --> wait_cycle_f condition --> log ~color:event_color "%s" done_ -(** Wait until AI activates. - Fails if AI is not set to be activated in the future. *) -let wait_ai_activation = - wait_cycle_until `AI_activation - --> exec_unit (fun (block, state) -> - assert (State_ai_flags.AI.enabled block state) ; - Lwt_result_syntax.return_unit) - (** wait delegate_parameters_activation_delay cycles *) let wait_delegate_parameters_activation = wait_cycle_until `delegate_parameters_activation diff --git a/src/proto_alpha/lib_protocol/test/helpers/scenario_begin.ml b/src/proto_alpha/lib_protocol/test/helpers/scenario_begin.ml index fa6d6342028496d3a41f076a98e9582542e38e7e..4335db102ea90c2ffad6350b59a25e001ca0dc03 100644 --- a/src/proto_alpha/lib_protocol/test/helpers/scenario_begin.ml +++ b/src/proto_alpha/lib_protocol/test/helpers/scenario_begin.ml @@ -46,43 +46,6 @@ let start_with_list ~(constants : (string * constants) list) : (Format.asprintf "%s: Cannot build scenarios from empty list" __LOC__) | _ -> fold_tag (fun constants -> start_with ~constants) constants -let activate_ai mode = - match mode with - | `Force -> - log ~color:event_color "Forcing AI activation at initial cycle" - --> set S.Adaptive_issuance.force_activation true - | `Zero_threshold -> - (* Requires to wait until AI is activated *) - log ~color:event_color "Setting ai vote threshold to 0" - --> set S.Adaptive_issuance.force_activation false - --> set S.Adaptive_issuance.launch_ema_threshold 0l - | `With_vote_threshold t -> - (* Requires to wait for the votes to pass the threshold, then - wait some more before AI is activated *) - log ~color:event_color "Setting ai vote threshold to %ld" t - --> set S.Adaptive_issuance.force_activation false - --> set S.Adaptive_issuance.activation_vote_enable true - --> set S.Adaptive_issuance.launch_ema_threshold t - | `Force_and_vote_with_threshold t -> - (* Force should have priority on the vote *) - log - ~color:event_color - "Forcing AI activation at initial cycle, and setting ai vote threshold \ - to %ld" - t - --> set S.Adaptive_issuance.force_activation true - --> set S.Adaptive_issuance.activation_vote_enable true - --> set S.Adaptive_issuance.launch_ema_threshold t - | `No -> - (* AI cannot be activated. *) - log ~color:event_color "Setting AI as impossible to activate" - --> set - S.Adaptive_issuance.launch_ema_threshold - (Int32.succ - Protocol.Per_block_votes_repr.Internal_for_tests.ema_max) - --> set S.Adaptive_issuance.force_activation false - --> set S.Adaptive_issuance.activation_vote_enable false - (** Initializes the constants for testing, with well chosen default values. Recommended over [start] or [start_with] *) let init_constants ?(default = Test) ?(reward_per_block = 0L) @@ -110,19 +73,18 @@ let init_constants ?(default = Test) ?(reward_per_block = 0L) --> set S.minimal_block_delay Protocol.Alpha_context.Period.one_minute --> set S.cost_per_byte Tez.zero --> set S.consensus_threshold 0 - --> (if deactivate_dynamic then - set - S.Adaptive_issuance.Adaptive_rewards_params.max_bonus - (Protocol.Issuance_bonus_repr.max_bonus_parameter_of_Q_exn Q.zero) - else Empty) - --> set S.Adaptive_issuance.force_activation true + --> + if deactivate_dynamic then + set + S.Adaptive_issuance.Adaptive_rewards_params.max_bonus + (Protocol.Issuance_bonus_repr.max_bonus_parameter_of_Q_exn Q.zero) + else Empty (** Initialize the test, given some initial parameters *) let begin_test ?(burn_rewards = false) ?(force_attest_all = false) delegates_name_list : (constants, t) scenarios = exec (fun (constants : constants) -> let open Lwt_result_syntax in - let constants = constants |> S.Adaptive_issuance.force_activation true in let bootstrap = "__bootstrap__" in let delegates_name_list = bootstrap :: delegates_name_list in (* Override threshold value if activate *) @@ -185,12 +147,8 @@ let begin_test ?(burn_rewards = false) ?(force_attest_all = false) pending_operations = []; pending_slashes = []; double_signings = []; - ai_activation_cycle = None; force_attest_all; } in let* () = check_all_balances block state in - let* state = - State_ai_flags.AI_Activation.check_activation_cycle block state - in return (block, state)) diff --git a/src/proto_alpha/lib_protocol/test/helpers/slashing_helpers.ml b/src/proto_alpha/lib_protocol/test/helpers/slashing_helpers.ml index 9334eb6699a2ce711388d94afb8434873f150f9a..6f8f9488a2b677ba3b180b0a878ca9a9c74d2664 100644 --- a/src/proto_alpha/lib_protocol/test/helpers/slashing_helpers.ml +++ b/src/proto_alpha/lib_protocol/test/helpers/slashing_helpers.ml @@ -270,8 +270,39 @@ let apply_slashing_state all_denunciations_to_apply let apply_all_slashes_at_cycle_end current_cycle (block_before_slash : Block.t) (state : State.t) : State.t tzresult Lwt.t = let open Lwt_result_syntax in - let to_slash_later, to_slash_now = - State_ai_flags.Delayed_slashing.partition_slashes state current_cycle + let to_slash_now, to_slash_later = + List.partition + (fun (_, Protocol.Denunciations_repr.{misbehaviour; _}) -> + let misb_cycle = + Block.current_cycle_of_level + ~blocks_per_cycle: + state.constants + .Protocol.Alpha_context.Constants.Parametric.blocks_per_cycle + ~current_level:(Protocol.Raw_level_repr.to_int32 misbehaviour.level) + in + let open Protocol.Alpha_context in + let misb_slashing_cycle = + Cycle.add misb_cycle (Constants.max_slashing_period - 1) + in + if Cycle.(equal misb_slashing_cycle current_cycle) then + (* Slash now *) + true + else if + Cycle.( + misb_slashing_cycle > current_cycle && misb_cycle <= current_cycle) + then (* Slash later *) false + else + Test.fail + ~__LOC__ + "Pending slash for %a (cycle %a) should not exist at the end of \ + cycle %a" + Misbehaviour_repr.pp + misbehaviour + Cycle.pp + misb_cycle + Cycle.pp + current_cycle) + state.pending_slashes in (* Sort to_slash_now by level+round *) let to_slash_now = @@ -280,7 +311,6 @@ let apply_all_slashes_at_cycle_end current_cycle (block_before_slash : Block.t) Denunciations_repr.compare_item_except_hash item1 item2) to_slash_now in - let* state, total_burnt = List.fold_left_es (fun (acc_state, acc_total) x -> diff --git a/src/proto_alpha/lib_protocol/test/helpers/state.ml b/src/proto_alpha/lib_protocol/test/helpers/state.ml index 6e245b1d77cad696202f76d06b84ac95b46571de..aa78f5f87a47da69bc0668850c12659a217b511d 100644 --- a/src/proto_alpha/lib_protocol/test/helpers/state.ml +++ b/src/proto_alpha/lib_protocol/test/helpers/state.ml @@ -32,7 +32,6 @@ type t = { pending_slashes : (Signature.Public_key_hash.t * Protocol.Denunciations_repr.item) list; double_signings : double_signing_state list; - ai_activation_cycle : Protocol.Alpha_context.Cycle.t option; force_attest_all : bool; } diff --git a/src/proto_alpha/lib_protocol/test/helpers/state_ai_flags.ml b/src/proto_alpha/lib_protocol/test/helpers/state_ai_flags.ml deleted file mode 100644 index 2e23e73dc03dfb1349e56298047e7154631ed4d4..0000000000000000000000000000000000000000 --- a/src/proto_alpha/lib_protocol/test/helpers/state_ai_flags.ml +++ /dev/null @@ -1,87 +0,0 @@ -(*****************************************************************************) -(* *) -(* SPDX-License-Identifier: MIT *) -(* Copyright (c) 2024 Nomadic Labs, *) -(* *) -(*****************************************************************************) - -(** This module handles the logic of flags for AI/AS in the [State] *) - -open State - -module AI_Activation = struct - (** This module is responsible for the field [state.ai_activation_cycle], - which depends on three protocol parameters: - [adaptive_issuance.force_activation], [adaptive_issuance.activation_vote_enable], and - [adaptive_issuance.launch_ema_threshold]. *) - - (** AI can be activated with both flags set to false if the threshold is set to 0. - If the vote is enabled, but the threshold is above the maximum EMA, then the vote - cannot trigger the activation. *) - let enabled state = - state.constants.adaptive_issuance.force_activation - || (state.constants.adaptive_issuance.activation_vote_enable - && Compare.Int32.( - state.constants.adaptive_issuance.launch_ema_threshold - <= Protocol.Per_block_votes_repr.Internal_for_tests.ema_max)) - || Compare.Int32.( - state.constants.adaptive_issuance.launch_ema_threshold = 0l) - - let set_activation_cycle block state block_launch_cycle = - let current_cycle = Block.current_cycle block in - let offset = - if state.constants.adaptive_issuance.force_activation then 0 - else - 1 + state.constants.consensus_rights_delay - + Protocol.Constants_repr.max_slashing_period - in - assert ( - Protocol.Alpha_context.Cycle.( - add current_cycle offset = block_launch_cycle)) ; - {state with ai_activation_cycle = Some block_launch_cycle} - - (** Check the activation_cycle is only ever set once. - Run every block *) - let check_activation_cycle block state = - let open Lwt_result_syntax in - let open Protocol.Alpha_context in - let* block_launch_cycle = - Context.get_adaptive_issuance_launch_cycle (B block) - in - match (enabled state, state.ai_activation_cycle, block_launch_cycle) with - | _, None, None -> return state - | true, Some x, Some y -> - (* Activation cycle cannot be changed *) - if Cycle.(x = y) then return state else assert false - | _, Some _, None -> (* Activation cycle cannot be unset *) assert false - | false, _, Some _ -> - (* AI cannot be activated if [enabled] is false *) - assert false - | true, None, Some block_launch_cycle -> - return @@ set_activation_cycle block state block_launch_cycle -end - -module AI = struct - let enabled (block : Block.t) (state : State.t) = - match state.ai_activation_cycle with - | None -> false - | Some activation_cycle -> - let current_cycle = Block.current_cycle block in - Protocol.Alpha_context.Cycle.(current_cycle >= activation_cycle) -end - -module Delayed_slashing = struct - (* Returns a pair, fst is the delayed slashes, snd is the slashes to apply now *) - let partition_slashes state current_cycle = - List.partition - (fun (_, Protocol.Denunciations_repr.{misbehaviour; _}) -> - let cycle = - Block.current_cycle_of_level - ~blocks_per_cycle: - state.constants - .Protocol.Alpha_context.Constants.Parametric.blocks_per_cycle - ~current_level:(Protocol.Raw_level_repr.to_int32 misbehaviour.level) - in - Protocol.Alpha_context.Cycle.(cycle = current_cycle)) - state.pending_slashes -end diff --git a/src/proto_alpha/lib_protocol/test/helpers/state_ai_flags.mli b/src/proto_alpha/lib_protocol/test/helpers/state_ai_flags.mli deleted file mode 100644 index eb9c8fd4ba5a60a7be4b7e49a8dc5ef977ad04c4..0000000000000000000000000000000000000000 --- a/src/proto_alpha/lib_protocol/test/helpers/state_ai_flags.mli +++ /dev/null @@ -1,48 +0,0 @@ -(*****************************************************************************) -(* *) -(* SPDX-License-Identifier: MIT *) -(* Copyright (c) 2024 Nomadic Labs, *) -(* *) -(*****************************************************************************) - -(** This module handles the logic of flags for AI/AS in the [State] *) - -module AI_Activation : sig - (** This module takes care of the flags [force_activation] and - [activation_vote_enable], and updates and check the record field - [ai_activation_cycle] in the state. *) - - (** [AI_Activation] is enabled iff either of the above flags are set to true, - or the vote threshold is set to 0 (regardless of votes). - "Enabled" here means that AI *can* be activated (either by vote - or by force), but does not mean that AI is activated *) - val enabled : State.t -> bool - - (** Checks the [ai_activation_cycle] is set as expected. - Run at the beginning, and after every block to check the activation - cycle is set only once ever. *) - val check_activation_cycle : Block.t -> State.t -> State.t tzresult Lwt.t -end - -module AI : sig - (** This module only checks (for now) if AI is activated or not *) - - (** AI is enabled iff the activation cycle is set and passed *) - val enabled : Block.t -> State.t -> bool -end - -module Delayed_slashing : sig - (** This module takes care of choosing the denunciations that need to be - applied at the end of a cycle. It depends on the flag [ns_enable]. *) - - (** [partition_slashes s cycle] returns a pair [(l1,l2)] of lists of slashes, - partitioned from the [state.pending_slashes]. [l2] is the list of slashes to - apply at the end of the given [cycle], and [l1] is the rest (which should - usually replace [state.pending_slashes]) - *) - val partition_slashes : - State.t -> - Protocol.Alpha_context.Cycle.t -> - (Signature.Public_key_hash.t * Protocol.Denunciations_repr.item) list - * (Signature.Public_key_hash.t * Protocol.Denunciations_repr.item) list -end diff --git a/src/proto_alpha/lib_protocol/test/integration/consensus/test_baking.ml b/src/proto_alpha/lib_protocol/test/integration/consensus/test_baking.ml index 80d4045e214b277933ceca2d24929806a1c03432..d9b13dfcdefbfdd879e9f26eee00124ce15f1b49 100644 --- a/src/proto_alpha/lib_protocol/test/integration/consensus/test_baking.ml +++ b/src/proto_alpha/lib_protocol/test/integration/consensus/test_baking.ml @@ -30,7 +30,9 @@ Component: Protocol (baking) Invocation: dune exec src/proto_alpha/lib_protocol/test/integration/consensus/main.exe \ -- --file test_baking.ml - Subject: Rewards and bakers. Tests based on RPCs. + Subject: Bakers and baking/voting power-related tests, based on RPCs. + Note that more detailed tests on baking rewards can be found + in lib_protocol/test/integration/test_scenario_rewards.ml *) open Protocol @@ -86,75 +88,91 @@ let test_bake_n_cycles n () = let* (_block : block) = Block.bake_until_n_cycle_end ~policy n block in return_unit -(** Check that, after one or two voting periods, the voting power of a baker is - updated according to the rewards it receives for baking the blocks in the - voting periods. Note we consider only one baker. *) +let fold_es n init f = + let open Lwt_result_syntax in + let rec aux k accu = + if k >= n then return accu + else + let* accu = f k accu in + aux (k + 1) accu + in + aux 0 init + +(** Test that: + - [current_voting_power] is updated whenever the baker bakes a + block (because of the rewards it receives). + - [voting_power] is the snapshot of [current_voting_power] at the + start of the current voting period. *) let test_voting_power_cache () = let open Lwt_result_syntax in - let open Block in - let policy = By_round 0 in - let* genesis, _contract = Context.init1 ~consensus_threshold:0 () in - let* csts = Context.get_constants (B genesis) in + let* genesis, delegate1 = Context.init1 ~consensus_threshold:0 () in + let delegate1 = Account.pkh_of_contract_exn delegate1 in + let check_voting_power_update + (previous_current_voting_power, previous_voting_power) block = + let* current_voting_power = + Context.get_current_voting_power (B block) delegate1 + in + let* voting_power = Context.get_voting_power (B block) delegate1 in + let* delegate1_baked_last_block = + let* block_producer = Block.block_producer block in + return (Signature.Public_key_hash.equal block_producer.delegate delegate1) + in + let* voting_period = Context.Vote.get_current_period (B block) in + let is_last_block_of_period = Int32.equal voting_period.remaining 0l in + Log.debug + ~color:Log_helpers.low_debug_color + "@[Checking updates for block at level %ld %sbaked by 'delegate1'@,\ + %a@,\ + current_voting_power: previous=%Ld new=%Ld@,\ + voting_power: previous=%Ld new=%Ld@,\ + @]" + block.header.shell.level + (if delegate1_baked_last_block then "" else "not ") + Voting_period.pp_info + voting_period + previous_current_voting_power + current_voting_power + previous_voting_power + voting_power ; + let* () = + (if delegate1_baked_last_block then Assert.lt_int64 + else Assert.equal_int64) + ~loc:__LOC__ + previous_current_voting_power + current_voting_power + in + let* () = + (* The context gets set up for a new voting period while + applying the last block of the previous period. *) + Assert.equal_int64 + ~loc:__LOC__ + voting_power + (if is_last_block_of_period then current_voting_power + else previous_voting_power) + in + return (current_voting_power, voting_power) + in + let* constants = Context.get_constants (B genesis) in let blocks_per_voting_period = Int32.( - mul - csts.parametric.blocks_per_cycle - csts.parametric.cycles_per_voting_period) - in - let blocks_per_voting_periods n = - Int64.of_int (n * Int32.to_int blocks_per_voting_period) - in - let* baking_reward = Context.get_baking_reward_fixed_portion (B genesis) in - let* bakers = Context.get_bakers (B genesis) in - let baker = WithExceptions.Option.get ~loc:__LOC__ @@ List.hd bakers in - let* full_balance = Context.Delegate.full_balance (B genesis) baker in - let assert_voting_power ~loc n block = - let* voting_power = Context.get_voting_power (B block) baker in - Assert.equal_int64 ~loc n voting_power - in - (* the voting power is the full staking balance *) - let initial_voting_power_at_genesis = Tez.to_mutez full_balance in - let* () = - assert_voting_power ~loc:__LOC__ initial_voting_power_at_genesis genesis + to_int + (mul + constants.parametric.blocks_per_cycle + constants.parametric.cycles_per_voting_period)) + in + let* full_balance = Context.Delegate.full_balance (B genesis) delegate1 in + let initial_voting_power = Tez.to_mutez full_balance in + let* _ = + fold_es + (* We bake a bit more than 3 full voting periods. *) + ((3 * blocks_per_voting_period) + 2) + (genesis, (initial_voting_power, initial_voting_power)) + (fun (_n : int) (block, prev_powers) -> + let* block = Block.bake block in + let* new_powers = check_voting_power_update prev_powers block in + return (block, new_powers)) in - let rewards_after_one_voting_period = - Tez_helpers.(baking_reward *! Int64.pred (blocks_per_voting_periods 1)) - in - let expected_delta_voting_power_after_one_voting_period = - Tez.to_mutez rewards_after_one_voting_period - in - let* block = - Block.bake_n ~policy (Int32.to_int blocks_per_voting_period - 1) genesis - in - let expected_voting_power_after_one_voting_period = - Int64.add - initial_voting_power_at_genesis - expected_delta_voting_power_after_one_voting_period - in - let* () = - assert_voting_power - ~loc:__LOC__ - expected_voting_power_after_one_voting_period - block - in - let rewards_after_two_voting_periods = - Tez_helpers.(baking_reward *! Int64.pred (blocks_per_voting_periods 2)) - in - let expected_delta_voting_power_after_two_voting_periods = - Tez.to_mutez rewards_after_two_voting_periods - in - let* block = - Block.bake_n ~policy (Int32.to_int blocks_per_voting_period) block - in - let expected_voting_power_after_two_voting_periods = - Int64.add - initial_voting_power_at_genesis - expected_delta_voting_power_after_two_voting_periods - in - assert_voting_power - ~loc:__LOC__ - expected_voting_power_after_two_voting_periods - block + return_unit (** test that after baking, one gets the baking reward fixed portion. *) let test_basic_baking_reward () = @@ -463,7 +481,7 @@ let tests = [ Tztest.tztest "cycle" `Quick test_cycle; Tztest.tztest "bake_n_cycles for 12 cycles" `Quick (test_bake_n_cycles 12); - Tztest.tztest "voting_power" `Quick test_voting_power_cache; + Tztest.tztest "voting_power cache" `Quick test_voting_power_cache; Tztest.tztest "the fixed baking reward is given after a bake" `Quick diff --git a/src/proto_alpha/lib_protocol/test/integration/dune b/src/proto_alpha/lib_protocol/test/integration/dune index 158c2544c61d068040b0c80909dc3a8b90594d7d..70dfa73cc2501db032aa43e8e4b289a095ae3d8e 100644 --- a/src/proto_alpha/lib_protocol/test/integration/dune +++ b/src/proto_alpha/lib_protocol/test/integration/dune @@ -31,7 +31,6 @@ (modules test_constants test_frozen_bonds - test_adaptive_issuance_launch test_scenario_base test_scenario_stake test_scenario_rewards diff --git a/src/proto_alpha/lib_protocol/test/integration/test_adaptive_issuance_launch.ml b/src/proto_alpha/lib_protocol/test/integration/test_adaptive_issuance_launch.ml deleted file mode 100644 index cc30a51d40e3973ecb8de3cdd4db6e76cf7e7c93..0000000000000000000000000000000000000000 --- a/src/proto_alpha/lib_protocol/test/integration/test_adaptive_issuance_launch.ml +++ /dev/null @@ -1,569 +0,0 @@ -(*****************************************************************************) -(* *) -(* Open Source License *) -(* Copyright (c) 2023 Nomadic Labs *) -(* *) -(* Permission is hereby granted, free of charge, to any person obtaining a *) -(* copy of this software and associated documentation files (the "Software"),*) -(* to deal in the Software without restriction, including without limitation *) -(* the rights to use, copy, modify, merge, publish, distribute, sublicense, *) -(* and/or sell copies of the Software, and to permit persons to whom the *) -(* Software is furnished to do so, subject to the following conditions: *) -(* *) -(* The above copyright notice and this permission notice shall be included *) -(* in all copies or substantial portions of the Software. *) -(* *) -(* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR*) -(* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *) -(* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL *) -(* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER*) -(* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING *) -(* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER *) -(* DEALINGS IN THE SOFTWARE. *) -(* *) -(*****************************************************************************) - -(** Testing - ------- - Component: Adaptive Issuance, launch vote - Invocation: dune exec src/proto_alpha/lib_protocol/test/integration/main.exe \ - -- --file test_adaptive_issuance_launch.ml - Subject: Test the launch vote feature of Adaptive Issuance. -*) - -open Adaptive_issuance_helpers -module Cycle = Protocol.Alpha_context.Cycle - -let register_test = - Tezt_helpers.register_test_es ~__FILE__ ~file_tags:["ai"; "ai_launch"] - -let assert_level ~loc (blk : Block.t) expected = - let current_level = blk.header.shell.level in - Assert.equal_int32 ~loc current_level expected - -let assert_is_not_yet_set_to_launch ~loc blk = - let open Lwt_result_syntax in - let* launch_cycle_opt = Context.get_adaptive_issuance_launch_cycle (B blk) in - Assert.is_none - ~loc - ~pp:(fun fmt cycle -> - Format.fprintf - fmt - "Activation cycle is set to %a but we expected it to be unset" - Protocol.Alpha_context.Cycle.pp - cycle) - launch_cycle_opt - -let assert_cycle_eq ~loc c1 c2 = - Assert.equal - ~loc - Protocol.Alpha_context.Cycle.( = ) - "cycle equality" - Protocol.Alpha_context.Cycle.pp - c1 - c2 - -let assert_current_cycle ~loc (blk : Block.t) expected = - let current_cycle = Block.current_cycle blk in - assert_cycle_eq ~loc current_cycle expected - -(** Assert that the staking balance is the expected one. *) -let assert_total_frozen_stake ~loc block expected = - let open Lwt_result_syntax in - let* actual = Context.get_total_frozen_stake (B block) in - Assert.equal_tez ~loc actual expected - -(* Assert that the current voting power of a delegate is the expected - one. The expectation is computed based on the expected self-staked, - delegated, and staked tez. The delegate's own liquid balance is - measured. *) -let assert_voting_power ~loc block delegate ~ai_enabled ~expected_staked - ~expected_delegated ~expected_ext_staked = - let open Lwt_result_syntax in - let* balance = Context.Contract.balance (B block) (Implicit delegate) in - let balance = Protocol.Alpha_context.Tez.to_mutez balance in - let expected_liquid = Int64.add balance expected_delegated in - let expected_frozen = Int64.add expected_staked expected_ext_staked in - let* constants = Context.get_constants (B block) in - let edge_of_staking_over_delegation = - Int64.of_int - constants.parametric.adaptive_issuance.edge_of_staking_over_delegation - in - let expected_voting_power = Int64.add expected_frozen expected_liquid in - let expected_baking_power = - if ai_enabled then - Int64.add - expected_frozen - (Int64.div expected_liquid edge_of_staking_over_delegation) - else expected_voting_power - in - let* actual_voting_power = - Context.get_current_voting_power (B block) delegate - in - let* () = Assert.equal_int64 ~loc actual_voting_power expected_voting_power in - let* actual_baking_power = - Context.get_current_baking_power (B block) delegate - in - Assert.equal_int64 ~loc actual_baking_power expected_baking_power - -(* Test that: - - the EMA of the adaptive issuance vote reaches the threshold after the - expected duration, - - the launch cycle is set as soon as the threshold is reached, - - the launch cycle is not reset before it is reached, - - once the launch cycle is reached, staking is allowed, - - staking increases total_frozen_stake. *) -let test_launch threshold expected_vote_duration = - let open Lwt_result_wrap_syntax in - let assert_ema_above_threshold ~loc - (metadata : Protocol.Main.block_header_metadata) = - let ema = - Protocol.Alpha_context.Per_block_votes.Adaptive_issuance_launch_EMA - .to_int32 - metadata.adaptive_issuance_vote_ema - in - Assert.lt_int32 ~loc threshold ema - in - (* Initialize the state with a single delegate. *) - let constants = - let default_constants = Default_parameters.constants_test in - let adaptive_issuance = - { - default_constants.adaptive_issuance with - launch_ema_threshold = threshold; - activation_vote_enable = true; - } - in - let cost_per_byte = Tez_helpers.zero in - let issuance_weights = - { - Default_parameters.constants_test.issuance_weights with - base_total_issued_per_minute = Tez_helpers.zero; - } - in - let consensus_threshold = 0 in - { - default_constants with - consensus_threshold; - adaptive_issuance; - issuance_weights; - cost_per_byte; - } - in - let delay = constants.consensus_rights_delay in - let* block, delegate = Context.init_with_constants1 constants in - let delegate_pkh = Context.Contract.pkh delegate in - let* () = assert_is_not_yet_set_to_launch ~loc:__LOC__ block in - let* () = - assert_total_frozen_stake - ~loc:__LOC__ - block - (Protocol.Alpha_context.Tez.of_mutez_exn 200_000_000_000L) - in - - (* To test that adaptive issuance is active, we test that - staking, a feature only available after the activation, is - allowed. But by default, delegates reject stakers, they must - explicitely set a positive limit_of_staking_over_baking to allow - them. Setting this limit does not immediately take effect but can - be done before the activation. For these reasons, we set it at - the beginning. - - The baking_over_staking_edge indicates the portion of the rewards - sent to the delegate's liquid balance. It's expressed in - billionth, with 0 meaning that everything is frozen and one - billion meaning that everything is liquid. We send all rewards to - the liquid part to ease reasoning about the total frozen - stake. *) - let* block = - let* operation = - set_delegate_parameters - (B block) - delegate - ~parameters: - { - limit_of_staking_over_baking = Q.one; - edge_of_baking_over_staking = Q.one; - } - in - Block.bake ~operation ~adaptive_issuance_vote:Per_block_vote_on block - in - - (* Initialization of a delegator account which will attempt to - stake. *) - let wannabe_staker_account = Account.new_account () in - let wannabe_staker = - Protocol.Alpha_context.Contract.Implicit - Account.(wannabe_staker_account.pkh) - in - - (* To set up the wannabe staker, we need three operations: a - transfer from the delegate to initialize its balance, a - revelation of its public key, and a delegation toward the - delegate. For simplicity we put these operations in different - blocks. *) - let* block = - let* operation = - Op.transaction - (B block) - delegate - wannabe_staker - (Protocol.Alpha_context.Tez.of_mutez_exn 2_000_000_000_000L) - in - Block.bake ~operation ~adaptive_issuance_vote:Per_block_vote_on block - in - let* block = - let* operation = - Op.revelation - ~fee:Protocol.Alpha_context.Tez.zero - (B block) - wannabe_staker_account.pk - in - Block.bake ~operation ~adaptive_issuance_vote:Per_block_vote_on block - in - let* block = - let* operation = - Op.delegation - ~fee:Protocol.Alpha_context.Tez.zero - (B block) - wannabe_staker - (Some delegate_pkh) - in - Block.bake ~operation ~adaptive_issuance_vote:Per_block_vote_on block - in - (* Self-staking most of the remaining balance. *) - let* block = - let* operation = - stake - (B block) - delegate - (Protocol.Alpha_context.Tez.of_mutez_exn 1_800_000_000_000L) - in - Block.bake ~operation ~adaptive_issuance_vote:Per_block_vote_on block - in - - (* We are now ready to activate the feature through by baking many - more blocks voting in favor of the activation until the EMA - threshold is reached. *) - let* () = assert_is_not_yet_set_to_launch ~loc:__LOC__ block in - - let* block, _ = - Block.bake_while_with_metadata - ~adaptive_issuance_vote:Per_block_vote_on - (fun _block metadata -> - let ema = - Protocol.Alpha_context.Per_block_votes.Adaptive_issuance_launch_EMA - .to_int32 - metadata.adaptive_issuance_vote_ema - in - let launch_cycle = metadata.adaptive_issuance_launch_cycle in - let cond = Compare.Int32.(ema < threshold) in - assert ( - if cond then Option.is_none launch_cycle - else Option.is_some launch_cycle) ; - cond) - block - in - (* At this point we are on the last block before the end of the vote. *) - let* () = - assert_level ~loc:__LOC__ block (Int32.pred expected_vote_duration) - in - let* () = assert_is_not_yet_set_to_launch ~loc:__LOC__ block in - (* We bake one more block to end the vote and set the feature to launch. *) - let* block, (metadata, _) = - Block.bake_n_with_metadata ~adaptive_issuance_vote:Per_block_vote_on 1 block - in - let* () = assert_ema_above_threshold ~loc:__LOC__ metadata in - let* () = assert_level ~loc:__LOC__ block expected_vote_duration in - (* At this point the feature is not launched yet, it is simply - planned to be launched. *) - (* We check that the feature is not yet active by attempting a - stake operation. *) - let* () = - let* operation = - stake - (B block) - wannabe_staker - (Protocol.Alpha_context.Tez.of_mutez_exn 10L) - in - let* i = Incremental.begin_construction block in - let*! i = Incremental.add_operation i operation in - Assert.proto_error_with_info - ~loc:__LOC__ - i - "Staking for a delegator while external staking is disabled" - in - let* () = - assert_voting_power - ~loc:__LOC__ - block - delegate_pkh - ~ai_enabled:false - ~expected_staked:2_000_000_000_000L - ~expected_delegated:2_000_000_000_000L - ~expected_ext_staked:0L - in - - let* launch_cycle = get_launch_cycle ~loc:__LOC__ block in - let* () = - (* Check that the block metadata information about the launch cycle - is consistent with the RPC. *) - let* cycle = - Assert.get_some ~loc:__LOC__ metadata.adaptive_issuance_launch_cycle - in - assert_cycle_eq ~loc:__LOC__ launch_cycle cycle - in - (* Bake until the activation. *) - let* block = Block.bake_until_cycle launch_cycle block in - let* block, (metadata, _) = Block.bake_n_with_metadata 1 block in - let* () = assert_ema_above_threshold ~loc:__LOC__ metadata in - (* Check that keeping the EMA above the threshold did not postpone - the activation. *) - let* launch_cycle_bis = get_launch_cycle ~loc:__LOC__ block in - let* () = assert_cycle_eq ~loc:__LOC__ launch_cycle launch_cycle_bis in - (* Check that the current cycle is the one at which the launch is - planned to happen. *) - let* () = assert_current_cycle ~loc:__LOC__ block launch_cycle in - (* At this point, only the delegate has frozen any stake and its - frozen balance is about 2 million tez (it started with 4 million, - sent half to its delegate, and staked the rest). *) - let* () = - assert_total_frozen_stake - ~loc:__LOC__ - block - (Protocol.Alpha_context.Tez.of_mutez_exn 2_000_000_000_000L) - in - let* () = - assert_voting_power - ~loc:__LOC__ - block - delegate_pkh - ~ai_enabled:true - ~expected_staked:2_000_000_000_000L - ~expected_delegated:2_000_000_000_000L - ~expected_ext_staked:0L - in - - (* Test that the wannabe staker is now allowed to stake almost all - its balance. It cannot totally stake it however because this is - considered by the protocol as an attempt to empty the account, and - emptying delegated accounts is forbidden. *) - let* balance = Context.Contract.balance (B block) wannabe_staker in - let*?@ balance_to_stake = Protocol.Alpha_context.Tez.(balance -? one) in - let* operation = stake (B block) wannabe_staker balance_to_stake in - let* block = Block.bake ~operation block in - (* The staking operation leads to an increase of the - total_frozen_stake but only consensus_rights_delay after the - operation. *) - let start_cycle = Block.current_cycle block in - let* block = - Block.bake_while - ~invariant:(fun block -> - assert_total_frozen_stake - ~loc:__LOC__ - block - (Protocol.Alpha_context.Tez.of_mutez_exn 2_000_000_000_000L)) - (fun block -> - let current_cycle = Block.current_cycle block in - Protocol.Alpha_context.Cycle.(current_cycle <= add start_cycle delay)) - block - in - let* block = Block.bake block in - let* () = - assert_total_frozen_stake - ~loc:__LOC__ - block - (Protocol.Alpha_context.Tez.of_mutez_exn 3_999_999_000_000L) - in - let* () = - assert_voting_power - ~loc:__LOC__ - block - delegate_pkh - ~ai_enabled:true - ~expected_staked:2_000_000_000_000L - ~expected_delegated:1_000_000L - ~expected_ext_staked:1_999_999_000_000L - in - return_unit - -(* Test that, with the feature flag unset: - - the EMA of the adaptive issuance vote reaches the threshold after the - expected duration, - - the feature does not activate. *) -let test_does_not_launch_without_feature_flag threshold vote_duration = - let open Lwt_result_wrap_syntax in - let assert_ema_above_threshold ~loc - (metadata : Protocol.Main.block_header_metadata) = - let ema = - Protocol.Alpha_context.Per_block_votes.Adaptive_issuance_launch_EMA - .to_int32 - metadata.adaptive_issuance_vote_ema - in - Assert.lt_int32 ~loc threshold ema - in - (* Initialize the state with a single delegate. *) - let constants = - let default_constants = Default_parameters.constants_test in - let adaptive_issuance = - { - default_constants.adaptive_issuance with - launch_ema_threshold = threshold; - activation_vote_enable = false; - } - in - let consensus_threshold = 0 in - {default_constants with consensus_threshold; adaptive_issuance} - in - let* block, _delegate = Context.init_with_constants1 constants in - let* () = assert_is_not_yet_set_to_launch ~loc:__LOC__ block in - let* () = - assert_total_frozen_stake - ~loc:__LOC__ - block - (Protocol.Alpha_context.Tez.of_mutez_exn 200_000_000_000L) - in - (* Bake many more blocks voting in favor of the activation until the - EMA threshold is reached. *) - let* () = assert_is_not_yet_set_to_launch ~loc:__LOC__ block in - let* block, _ = - Block.bake_while_with_metadata - ~adaptive_issuance_vote:Per_block_vote_on - (fun _block metadata -> - let ema = - Protocol.Alpha_context.Per_block_votes.Adaptive_issuance_launch_EMA - .to_int32 - metadata.adaptive_issuance_vote_ema - in - let launch_cycle = metadata.adaptive_issuance_launch_cycle in - let cond = Compare.Int32.(ema < threshold) in - assert (Option.is_none launch_cycle) ; - cond) - block - in - (* At this point we are on the last block before the end of the vote. *) - let* () = assert_level ~loc:__LOC__ block (Int32.pred vote_duration) in - let* () = assert_is_not_yet_set_to_launch ~loc:__LOC__ block in - (* We bake one more block, this would set the feature to launch if - the vote was taken into account. *) - let* block, (metadata, _) = - Block.bake_n_with_metadata ~adaptive_issuance_vote:Per_block_vote_on 1 block - in - let* () = assert_ema_above_threshold ~loc:__LOC__ metadata in - let* () = assert_level ~loc:__LOC__ block vote_duration in - let* launch_cycle_opt = - Context.get_adaptive_issuance_launch_cycle (B block) - in - let* () = Assert.is_none ~loc:__LOC__ ~pp:Cycle.pp launch_cycle_opt in - let* () = - Assert.is_none - ~loc:__LOC__ - ~pp:Cycle.pp - metadata.adaptive_issuance_launch_cycle - in - return_unit - -(* Test that with force_activation feature flag set, the feature activates - without waiting for the activation vote *) -let test_launch_without_vote () = - let open Lwt_result_wrap_syntax in - (* Initialize the state with a single delegate. *) - let constants = - let default_constants = Default_parameters.constants_test in - let issuance_weights = - { - Default_parameters.constants_test.issuance_weights with - base_total_issued_per_minute = Tez_helpers.zero; - } - in - let adaptive_issuance = - {default_constants.adaptive_issuance with force_activation = true} - in - let consensus_threshold = 0 in - { - default_constants with - consensus_threshold; - issuance_weights; - adaptive_issuance; - } - in - let* block, delegate = Context.init_with_constants1 constants in - let delegate_pkh = Context.Contract.pkh delegate in - let* block = Block.bake block in - - (* AI should be activated and launch cycle is current cycle (0) *) - let* launch_cycle_opt = - Context.get_adaptive_issuance_launch_cycle (B block) - in - let* launch_cycle = Assert.get_some ~loc:__LOC__ launch_cycle_opt in - let* () = Assert.equal_int32 ~loc:__LOC__ (Cycle.to_int32 launch_cycle) 0l in - - let* () = - assert_total_frozen_stake - ~loc:__LOC__ - block - (Protocol.Alpha_context.Tez.of_mutez_exn 200_000_000_000L) - in - (* feature flag is set, AI should be active, let's use the stake function to check *) - let* operation = - stake - (B block) - delegate - (Protocol.Alpha_context.Tez.of_mutez_exn 180_000_000_000L) - in - let* block = Block.bake ~operation block in - (* Wait until total frozen stake is updated *) - let start_cycle = Block.current_cycle block in - let* block = - Block.bake_while - ~invariant:(fun block -> - assert_total_frozen_stake - ~loc:__LOC__ - block - (Protocol.Alpha_context.Tez.of_mutez_exn 200_000_000_000L)) - (fun block -> - let current_cycle = Block.current_cycle block in - Protocol.Alpha_context.Cycle.( - current_cycle <= add start_cycle constants.consensus_rights_delay)) - block - in - let* block = Block.bake block in - - let* () = - assert_total_frozen_stake - ~loc:__LOC__ - block - (Protocol.Alpha_context.Tez.of_mutez_exn 380_000_000_000L) - in - let* () = - assert_voting_power - ~loc:__LOC__ - block - delegate_pkh - ~ai_enabled:true - ~expected_staked:380_000_000_000L - ~expected_delegated:0L - ~expected_ext_staked:0L - in - return_unit - -let () = - register_test - ~title: - "Launch with force_activation feature flag set activates AI immediately" - test_launch_without_vote - -let () = - register_test - ~title:"expected EMA and AI launches (very low threshold, vote enabled)" - @@ fun () -> - test_launch 1000000l (* This means that the threshold is set to 0.05% *) 110l - -let () = - register_test - ~title: - "expected EMA and AI does not launch (very low threshold, vote disabled)" - @@ fun () -> - test_does_not_launch_without_feature_flag - 1000000l (* This means that the threshold is set to 0.05% *) - 110l diff --git a/src/proto_alpha/lib_protocol/test/integration/test_scenario_base.ml b/src/proto_alpha/lib_protocol/test/integration/test_scenario_base.ml index 12a3efe3c281a25a92dcb3d9731000d656de5673..fc26101685fb87350431f073804cc5f1996c8f73 100644 --- a/src/proto_alpha/lib_protocol/test/integration/test_scenario_base.ml +++ b/src/proto_alpha/lib_protocol/test/integration/test_scenario_base.ml @@ -92,7 +92,7 @@ let test_bake_until_next_cycle = in let blocks_per_cycle = 8l in init_constants ~blocks_per_cycle () - --> activate_ai `Force --> begin_test ["delegate"] + --> begin_test ["delegate"] --> List.fold_left (fun acc i -> acc @@ -117,7 +117,7 @@ let test_bake_until_cycle_end = in let blocks_per_cycle = 8l in init_constants ~blocks_per_cycle () - --> activate_ai `Force --> begin_test ["delegate"] + --> begin_test ["delegate"] --> List.fold_left (fun acc i -> acc @@ -142,7 +142,7 @@ let test_bake_until_cycle_end_but_one = in let blocks_per_cycle = 8l in init_constants ~blocks_per_cycle () - --> activate_ai `Force --> begin_test ["delegate"] + --> begin_test ["delegate"] --> List.fold_left (fun acc i -> acc diff --git a/src/proto_alpha/lib_protocol/test/integration/test_scenario_deactivation.ml b/src/proto_alpha/lib_protocol/test/integration/test_scenario_deactivation.ml index 2759671bbb77a5392fefa23d808d7773981ae060..30da0b7baaf62cf307517805e066da1d7e8570ed 100644 --- a/src/proto_alpha/lib_protocol/test/integration/test_scenario_deactivation.ml +++ b/src/proto_alpha/lib_protocol/test/integration/test_scenario_deactivation.ml @@ -74,11 +74,13 @@ let check_grace_period ~loc src_name = grace rpc_grace -(** Test that a delegate gets deactivated after a set period of time if it is not baking. - Test that with AI, the frozen funds stay frozen, and the delegate can still issue AI - operations without reactivating. *) -let test_simple_scenario_with_ai = - init_constants () --> activate_ai `Force +(** Test that a delegate gets deactivated after a set period of time + if it is not baking. + + Test that the frozen funds stay frozen, and the delegate can still + issue staking operations without reactivating. *) +let test_simple_scenario = + init_constants () --> begin_test ["delegate"; "baker"] --> check_balance_field "delegate" `Staked (Tez.of_mutez 200_000_000_000L) --> set_baker "baker" @@ -106,7 +108,7 @@ let test_simple_scenario_with_ai = Test that a delegate can be deactivated while having rights, and test that it can still bake while deactivated, hence reactivating *) let test_baking_deactivation = - init_constants () --> activate_ai `Force + init_constants () --> begin_test ["delegate"; "baker"] --> unstake "delegate" All --> wait_n_cycles_f (fun (_, state) -> @@ -145,7 +147,7 @@ let test_deactivation_timing = let staked_balance_no_change = check_balance_field "delegate" `Staked (Tez.of_mutez 200_000_000_000L) in - init_constants () --> activate_ai `Force + init_constants () --> begin_test ["delegate"; "baker"] --> staked_balance_no_change --> (Tag "Delegate is never active" --> set_baker "baker" @@ -200,7 +202,7 @@ let test_deactivation_timing = let tests = tests_of_scenarios [ - ("Test simple deactivation scenario with ai", test_simple_scenario_with_ai); + ("Test simple deactivation scenario", test_simple_scenario); ( "Test deactivation and reactivation scenarios with baking", test_baking_deactivation ); ("Test deactivation timing", test_deactivation_timing); diff --git a/src/proto_alpha/lib_protocol/test/integration/test_scenario_rewards.ml b/src/proto_alpha/lib_protocol/test/integration/test_scenario_rewards.ml index dc4c7fe5891e8ba96f992cb27a2ef3319ca67b52..8f5e6d32c098fdc4c1cf09c9829c93edac708210 100644 --- a/src/proto_alpha/lib_protocol/test/integration/test_scenario_rewards.ml +++ b/src/proto_alpha/lib_protocol/test/integration/test_scenario_rewards.ml @@ -18,21 +18,10 @@ open State_account open Tez_helpers.Ez_tez open Scenario -(** Test reward distribution without AI and without autostaking. - [State_account.add_*_rewards] ensures the rewards are distributed - correctly, and it is checked at the end of every block. -*) -let test_wait_rewards_no_ai_no_auto = - (* Prime number to always trigger roundings *) - init_constants ~reward_per_block:1_000_000_007L () - --> activate_ai `No - --> begin_test ["delegate1"; "delegate2"; "delegate3"] - --> wait_n_cycles 20 - -(** Tests reward distribution under AI: +(** Tests reward distribution: - with and without stakers (sometimes overstaking); - with different values of edge. *) -let test_wait_rewards_with_ai = +let test_wait_rewards = let set_edge pct = let params = { @@ -43,7 +32,6 @@ let test_wait_rewards_with_ai = set_delegate_params "delegate" params in init_constants ~reward_per_block:1_000_000_007L () - --> activate_ai `Force --> begin_test ["delegate"; "faucet"] --> (Tag "edge = 0" --> set_edge 0. |+ Tag "edge = 0.24" --> set_edge 0.24 @@ -95,10 +83,10 @@ let test_wait_rewards_with_ai = < staked))))) --> set_baker "delegate" --> wait_n_cycles 20 -(** Tests reward distribution under AI for one baker and one staker, +(** Tests reward distribution for one baker and one staker, and different arbitrary events: staking, unstaking, finalizing, slashing *) -let test_wait_rewards_with_ai_staker_variation = +let test_wait_rewards_staker_variation = let set_edge pct = let params = { @@ -109,7 +97,6 @@ let test_wait_rewards_with_ai_staker_variation = set_delegate_params "delegate" params in init_constants ~reward_per_block:1_000_000_007L () - --> activate_ai `Force --> begin_test ["delegate"; "faucet"] --> set_edge 0.24 --> wait_delegate_parameters_activation --> add_account_with_funds @@ -144,7 +131,7 @@ let test_wait_rewards_with_ai_staker_variation = state.State.constants.consensus_rights_delay + 1) --> set_baker "delegate" --> wait_n_cycles 10 -(** Tests reward distribution under AI for one baker and two stakers, +(** Tests reward distribution for one baker and two stakers, and the baker changes its limit parameter while being overstaked. We expect the rewards for the stakers to change accordingly with the limit. *) @@ -159,7 +146,6 @@ let test_overstake_different_limits = set_delegate_params "delegate" params in init_constants ~reward_per_block:1_000_000_007L () - --> activate_ai `Force --> begin_test ["delegate"; "faucet"] --> set_baker "faucet" --> unstake "delegate" (Amount (Tez.of_mutez 190_000_000_000L)) @@ -195,19 +181,17 @@ let test_overstake_different_limits = |+ Tag "limit >= 5" --> set_limit 6.) --> wait_delegate_parameters_activation --> wait_n_cycles 6 -(** Tests that the activation time for AI is as expected: - The expected delay is [consensus_rights_delay] + 1 cycles after activation. *) +(** Tests the activation time for AI: the expected delay is + [consensus_rights_delay] + 1 cycles after activation (which happens + immediately at cycle 0). *) let test_ai_curve_activation_time = let consensus_rights_delay (_, state) = state.State.constants.consensus_rights_delay in init_constants ~reward_per_block:1_000_000_000L ~deactivate_dynamic:true () - --> activate_ai `Zero_threshold --> begin_test ~burn_rewards:true [""] - --> next_block --> save_current_rate (* before AI rate *) - --> wait_ai_activation - (* Rate remains unchanged right after AI activation, we must wait [pc + 1] cycles *) - --> check_rate_evolution Q.equal + --> next_block --> save_current_rate (* initial rate *) + (* Rate remains unchanged for consensus_rights_delay cycles after AI activation *) --> wait_n_cycles_f consensus_rights_delay --> check_rate_evolution Q.equal --> next_cycle @@ -251,9 +235,7 @@ let test_static_decreasing = --> set S.Adaptive_issuance.Adaptive_rewards_params.issuance_ratio_initial_max Q.one - --> activate_ai `Zero_threshold --> begin_test ~burn_rewards:true ["delegate"] - --> next_block --> wait_ai_activation (* We stake about 50% of the total supply *) --> stake "delegate" (Amount (Tez.of_mutez 1_800_000_000_000L)) --> stake "__bootstrap__" (Amount (Tez.of_mutez 1_800_000_000_000L)) @@ -294,7 +276,6 @@ let test_static_timing = --> set S.Adaptive_issuance.Adaptive_rewards_params.issuance_ratio_initial_max Q.one - --> activate_ai `Force --> begin_test ~burn_rewards:true ["delegate"] (* We stake about 50% of the total supply *) --> stake "delegate" (Amount (Tez.of_mutez 1_800_000_000_000L)) @@ -321,7 +302,6 @@ let begin_test_with_rewards_checks ~init_limit = set_delegate_params name params in init_constants ~reward_per_block:1_000_000_000L () - --> activate_ai `Force --> begin_test ["delegate"; "faucet"] --> set_baker "delegate" --> add_account_with_funds @@ -522,10 +502,9 @@ let test_overstake = let tests = tests_of_scenarios @@ [ - ("Test wait rewards no AI no autostake", test_wait_rewards_no_ai_no_auto); - ("Test wait rewards with AI, stakers and edge", test_wait_rewards_with_ai); - ( "Test wait rewards with AI and stake variation events", - test_wait_rewards_with_ai_staker_variation ); + ("Test wait rewards with stakers and edge", test_wait_rewards); + ( "Test wait rewards with stake variation events", + test_wait_rewards_staker_variation ); ("Test ai curve activation time", test_ai_curve_activation_time); ( "Test static rate decreasing with stake ratio increasing", test_static_decreasing ); diff --git a/src/proto_alpha/lib_protocol/test/integration/test_scenario_slashing.ml b/src/proto_alpha/lib_protocol/test/integration/test_scenario_slashing.ml index bea9b82b10644d13f9b282908e7bcbb92e7eabe2..04483fb5d7a09275b5576f7e4ca36767ecc09900 100644 --- a/src/proto_alpha/lib_protocol/test/integration/test_scenario_slashing.ml +++ b/src/proto_alpha/lib_protocol/test/integration/test_scenario_slashing.ml @@ -102,7 +102,6 @@ let test_multiple_misbehaviors = --> make_denunciations () in init_constants ~blocks_per_cycle:24l ~reward_per_block:0L () - --> (Tag "No AI" --> activate_ai `No |+ Tag "Yes AI" --> activate_ai `Force) --> begin_test ["delegate"; "bootstrap1"; "bootstrap2"; "bootstrap3"] --> next_cycle --> (* various make misbehaviors spread over 1 or two cycles *) @@ -193,7 +192,6 @@ let check_has_slots ~loc baker_name = let test_delegate_forbidden = let crd (_, state) = state.State.constants.consensus_rights_delay in init_constants ~blocks_per_cycle:32l () - --> activate_ai `No --> begin_test ["delegate"; "bootstrap1"; "bootstrap2"] --> set_baker "bootstrap1" --> (Tag "Is not forbidden until first denunciation" @@ -248,7 +246,7 @@ let test_delegate_forbidden = --> check_is_forbidden ~loc:__LOC__ "delegate") let test_slash_unstake = - init_constants () --> activate_ai `No + init_constants () --> begin_test ["delegate"; "bootstrap1"; "bootstrap2"] --> set_baker "bootstrap1" --> next_cycle --> unstake "delegate" Half --> next_cycle --> double_bake "delegate" --> make_denunciations () @@ -259,7 +257,6 @@ let test_slash_unstake = let test_slash_monotonous_stake = let scenario ~offending_op ~op ~early_d = init_constants ~blocks_per_cycle:16l () - --> activate_ai `No --> begin_test ["delegate"; "bootstrap1"] --> next_cycle --> loop @@ -315,7 +312,6 @@ let test_slash_monotonous_stake = let test_slash_timing = init_constants ~blocks_per_cycle:8l () - --> activate_ai `No --> begin_test ~force_attest_all:true ["delegate"; "bootstrap1"] --> next_cycle --> (Tag "stake" --> stake "delegate" Half @@ -339,7 +335,7 @@ let test_no_shortcut_for_cheaters = let consensus_rights_delay = Default_parameters.constants_test.consensus_rights_delay in - init_constants () --> activate_ai `Force + init_constants () --> begin_test ["delegate"; "bootstrap1"] --> stake "delegate" (Amount (Tez.of_mutez 1_800_000_000_000L)) --> next_cycle --> double_bake "delegate" --> make_denunciations () @@ -399,7 +395,7 @@ let test_slash_correct_amount_after_stake_from_unstake = ~unstaked_finalizable () in - init_constants () --> activate_ai `Force + init_constants () --> begin_test ["delegate"; "bootstrap1"] --> next_cycle --> unstake "delegate" (Amount tez_to_unstake) @@ -458,8 +454,7 @@ let test_slash_correct_amount_after_stake_from_unstake = (* Test a non-zero request finalizes for a non-zero amount if it hasn't been slashed 100% *) let test_mini_slash = init_constants () - --> (Tag "Yes AI" --> activate_ai `Force --> begin_test ["delegate"; "baker"] - |+ Tag "No AI" --> activate_ai `No --> begin_test ["delegate"; "baker"]) + --> begin_test ["delegate"; "baker"] --> unstake "delegate" (Amount Tez.one_mutez) --> set_baker "baker" --> next_cycle --> (Tag "5% slash" --> double_bake "delegate" --> make_denunciations () @@ -473,7 +468,7 @@ let test_mini_slash = state.constants.consensus_rights_delay + 1) let test_slash_rounding = - init_constants () --> activate_ai `Force + init_constants () --> begin_test ["delegate"; "baker"] --> set_baker "baker" --> unstake "delegate" (Amount (Tez.of_mutez 2L)) @@ -492,7 +487,7 @@ let test_mega_slash = S.max_slashing_per_block (Protocol.Percentage.of_q_bounded ~round:`Down Q.(99 // 100)) --> set S.max_slashing_threshold 0 - --> activate_ai `Force --> set S.blocks_per_cycle 8l + --> set S.blocks_per_cycle 8l --> let delegates = ["delegate"; "baker"; "faucet"; "big_spender"] in begin_test delegates ~force_attest_all:true diff --git a/src/proto_alpha/lib_protocol/test/integration/test_scenario_slashing_stakers.ml b/src/proto_alpha/lib_protocol/test/integration/test_scenario_slashing_stakers.ml index 9e1ee2c472bd7574a633f6388e274e2589a6c553..0814cf27de651cbbb6606453025a5b98008adb54 100644 --- a/src/proto_alpha/lib_protocol/test/integration/test_scenario_slashing_stakers.ml +++ b/src/proto_alpha/lib_protocol/test/integration/test_scenario_slashing_stakers.ml @@ -38,7 +38,6 @@ let never_slashed_delegate2 = "bootstrap3" - 4 delegates - potentialy three stakers (2 delegating to first_slashed_delegate and 1 to never_slashed_delegate1 respectively) - - AI enabled - alternative parameters for first_slashed_delegate and never_slashed_delegate1 *) @@ -76,7 +75,7 @@ let init_with_stakers () = Half |+ Empty in - init_constants () --> activate_ai `Force + init_constants () --> begin_test ~force_attest_all:true [ diff --git a/src/proto_alpha/lib_protocol/test/integration/test_scenario_stake.ml b/src/proto_alpha/lib_protocol/test/integration/test_scenario_stake.ml index 4e1a7fc2e77e5852d370064e75ddc43f0a08ec19..5b6eafccd953d85b5e83e4bd99876353af3834f9 100644 --- a/src/proto_alpha/lib_protocol/test/integration/test_scenario_stake.ml +++ b/src/proto_alpha/lib_protocol/test/integration/test_scenario_stake.ml @@ -45,29 +45,24 @@ let fail_to_stake_with_unfinalizable_unstake_requests ~loc staker ~amount = - staker = delegate - staker != delegate Any scenario that begins with this will be duplicated. - - Also, ensures that AI is activated (sets EMA threshold to zero, - enables activation vote, and waits for AI activation). *) +*) let init_staker_delegate_or_external = let init_params = {limit_of_staking_over_baking = Q.one; edge_of_baking_over_staking = Q.one} in let begin_test ~self_stake = let name = if self_stake then "staker" else "delegate" in - init_constants () - --> Scenario_begin.activate_ai `Force - --> begin_test [name] + init_constants () --> begin_test [name] --> set_delegate_params name init_params in - Tag "AI activated" - --> (Tag "self stake" --> begin_test ~self_stake:true - |+ Tag "external stake" - --> begin_test ~self_stake:false - --> add_account_with_funds - "staker" - ~funder:"delegate" - (Amount (Tez.of_mutez 2_000_000_000_000L)) - --> set_delegate "staker" (Some "delegate")) + (Tag "self stake" --> begin_test ~self_stake:true + |+ Tag "external stake" + --> begin_test ~self_stake:false + --> add_account_with_funds + "staker" + ~funder:"delegate" + (Amount (Tez.of_mutez 2_000_000_000_000L)) + --> set_delegate "staker" (Some "delegate")) --> wait_delegate_parameters_activation let stake_init = @@ -164,7 +159,6 @@ let shorter_roundtrip_for_baker = in init_constants () --> set S.consensus_rights_delay consensus_rights_delay - --> activate_ai `Force --> begin_test ["delegate"; "faucet"] --> stake "delegate" (Amount (Tez.of_mutez 1_800_000_000_000L)) --> set_delegate_params "delegate" init_params @@ -362,7 +356,7 @@ let change_delegate_to_self = let init_params = {limit_of_staking_over_baking = Q.one; edge_of_baking_over_staking = Q.one} in - init_constants () --> activate_ai `Force --> begin_test ["delegate"] + init_constants () --> begin_test ["delegate"] --> set_delegate_params "delegate" init_params --> add_account_with_funds "staker" @@ -414,7 +408,7 @@ let change_delegate = let init_params = {limit_of_staking_over_baking = Q.one; edge_of_baking_over_staking = Q.one} in - init_constants () --> activate_ai `Force + init_constants () --> begin_test ["delegate1"; "delegate2"] --> set_delegate_params "delegate1" init_params --> set_delegate_params "delegate2" init_params @@ -475,7 +469,7 @@ let unset_delegate = let init_params = {limit_of_staking_over_baking = Q.one; edge_of_baking_over_staking = Q.one} in - init_constants () --> activate_ai `Force --> begin_test ["delegate"] + init_constants () --> begin_test ["delegate"] --> set_delegate_params "delegate" init_params --> add_account_with_funds "staker" @@ -513,8 +507,6 @@ let forbid_costaking = --> init_constants ~delegate_parameters_activation_delay:0 () |+ Tag "large delegate parameters delay" --> init_constants ~delegate_parameters_activation_delay:10 ()) - (* Set flags *) - --> activate_ai `Zero_threshold (* Start scenario *) --> begin_test ["delegate"] --> set_delegate_params "delegate" init_params @@ -523,7 +515,7 @@ let forbid_costaking = ~funder:"delegate" (Amount (Tez.of_mutez 2_000_000_000_000L)) --> set_delegate "staker" (Some "delegate") - --> wait_cycle_until (`And (`AI_activation, `delegate_parameters_activation)) + --> wait_cycle_until `delegate_parameters_activation (* try stake in normal conditions *) --> stake "staker" amount (* Change delegate parameters to forbid staking *) @@ -555,9 +547,10 @@ let forbid_costaking = (* Now possible *) --> stake "staker" amount -(* Check that a delegate can be deactivated under AI by unstaking everything, even with stakers. +(* Check that a delegate gets deactivated after it unstakes everything, + even if it has external stakers. Check that such a delegate can reactivate later, and still have their stakers *) -let test_deactivation = +let test_deactivation_after_unstake_all = let init_params = {limit_of_staking_over_baking = Q.one; edge_of_baking_over_staking = Q.one} in @@ -570,7 +563,7 @@ let test_deactivation = in let check_is_deactivated = check_deactivated_status ~expected:true in let check_is_not_deactivated = check_deactivated_status ~expected:false in - init_constants () --> activate_ai `Force + init_constants () --> begin_test ["delegate"; "faucet"] --> stake "delegate" (Amount (Tez.of_mutez 1_800_000_000_000L)) --> set_delegate_params "delegate" init_params @@ -696,7 +689,7 @@ let test_change_delegates = in set_delegate_params name params in - init_constants () --> activate_ai `Force + init_constants () --> begin_test ["delegate1"; "delegate2"; "delegate3"; "faucet"] --> add_account_with_funds "staker" @@ -749,7 +742,8 @@ let tests = ("Test unset delegate", unset_delegate); ("Test forbid costake", forbid_costaking); ("Test stake from unstake", shorter_roundtrip_for_baker); - ("Test deactivation under AI", test_deactivation); + ( "Test deactivation after delegate unstakes everything", + test_deactivation_after_unstake_all ); ("Test change delegates", test_change_delegates); ] diff --git a/src/proto_alpha/lib_protocol/test/unit/test_full_staking_balance_repr.ml b/src/proto_alpha/lib_protocol/test/unit/test_full_staking_balance_repr.ml index 1ce0c29e27164a353177fc02a26b7207daaed663..6fce00da56d18788325e3cb9a67be7a3f776bbda 100644 --- a/src/proto_alpha/lib_protocol/test/unit/test_full_staking_balance_repr.ml +++ b/src/proto_alpha/lib_protocol/test/unit/test_full_staking_balance_repr.ml @@ -586,9 +586,6 @@ let check_staking_balance_level ~check_invariant ~current_level let test_min_delegated_in_cycle () = let open Lwt_result_wrap_syntax in - let constants = - constants |> Constants_helpers.Set.Adaptive_issuance.force_activation true - in let blocks_per_cycle = constants.blocks_per_cycle in let expected_staking_balance ~delegated ~last_modified_level ~previous_min_value ~previous_min_level = @@ -770,9 +767,6 @@ let test_min_delegated_in_cycle () = the next cycle *) let test_min_delegated_rpc_for_last_and_first_blocks () = let open Lwt_result_wrap_syntax in - let constants = - constants |> Constants_helpers.Set.Adaptive_issuance.force_activation true - in let get_staking_balance b ~delegate = let* () = print_min_delegated_in_cycle_rpc b ~delegate in let* staking_balance = get_staking_balance b ~delegate in diff --git a/src/proto_alpha/lib_protocol/test/unit/test_slashing_percentage.ml b/src/proto_alpha/lib_protocol/test/unit/test_slashing_percentage.ml index 5a9c622dd68af95b157c2383740655e69d57153f..9ed8ac8385cd4e6a2278afce740aaec96bf81775 100644 --- a/src/proto_alpha/lib_protocol/test/unit/test_slashing_percentage.ml +++ b/src/proto_alpha/lib_protocol/test/unit/test_slashing_percentage.ml @@ -39,7 +39,6 @@ let raw_context ~max_slashing_threshold ~max_slashing_per_block () = let open Constants_helpers in let constants = Default_parameters.constants_test - |> Set.Adaptive_issuance.force_activation true |> Set.max_slashing_threshold max_slashing_threshold |> Set.max_slashing_per_block max_slashing_per_block in diff --git a/src/proto_alpha/lib_protocol/test/unit/test_staking_operations.ml b/src/proto_alpha/lib_protocol/test/unit/test_staking_operations.ml index 615f00428ddc5c96f3e699ebe0158b228ed9716e..0e535f923cf9302f7ffcd385d92d9e2727b3b134 100644 --- a/src/proto_alpha/lib_protocol/test/unit/test_staking_operations.ml +++ b/src/proto_alpha/lib_protocol/test/unit/test_staking_operations.ml @@ -64,9 +64,6 @@ let bake_set_delegate_parameters_until_activation b ~delegate = let create_delegate_and_staker ~self_delegate_staker ?amount () = let open Lwt_result_syntax in - let constants = - constants |> Constants_helpers.Set.Adaptive_issuance.force_activation true - in let* b, delegate = Context.init_with_constants1 constants in let* b, staker = originate_implicit_unrevealed_account ?amount b delegate in let* b = bake_set_delegate_parameters_until_activation b ~delegate in diff --git a/tezt/tests/adaptive_issuance.ml b/tezt/tests/adaptive_issuance.ml index 4c2818499e8a84e6e2b9d91e7d96a18c6c4c5ed2..79ccaf489c662944c424bbbffefc95388fd9edab 100644 --- a/tezt/tests/adaptive_issuance.ml +++ b/tezt/tests/adaptive_issuance.ml @@ -137,16 +137,25 @@ let wait_for_denunciation_injection node client accuser = if List.mem oph mempool.validated then return oph else Test.fail "the denunciation operation was rejected by the mempool" -let default_overrides = - [ - (* Shorter cycles *) - (["blocks_per_cycle"], `Int blocks_per_cycle); - (["nonce_revelation_threshold"], `Int nonce_revelation_threshold); - (* Activate adaptive issuance feature vote *) - (["adaptive_issuance_activation_vote_enable"], `Bool true); - (* Make adaptive issuance activation faster *) - (["adaptive_issuance_launch_ema_threshold"], `Int 1); - ] +let default_overrides ~protocol = + let common = + [ + (* Shorter cycles *) + (["blocks_per_cycle"], `Int blocks_per_cycle); + (["nonce_revelation_threshold"], `Int nonce_revelation_threshold); + ] + in + if Protocol.(number protocol <= number Quebec) then + [ + (* Activate adaptive issuance feature vote *) + (["adaptive_issuance_activation_vote_enable"], `Bool true); + (* Make adaptive issuance activation faster *) + (["adaptive_issuance_launch_ema_threshold"], `Int 1); + (["adaptive_issuance_force_activation"], `Bool true); + ] + @ common + else (* AI activation feature flags have been removed in protocol R. *) + common let launch_ema_threshold client = let* json = @@ -167,7 +176,7 @@ let init ?(overrides = default_overrides) protocol = let* sandbox_client = Client.init ~endpoint:sandbox_endpoint () in let* parameter_file = let base = Either.Right (protocol, None) in - Protocol.write_parameter_file ~base overrides + Protocol.write_parameter_file ~base (overrides ~protocol) in let* () = Client.activate_protocol ~protocol sandbox_client ~parameter_file in Log.info "Activated protocol." ; @@ -220,11 +229,20 @@ let activate_ai protocol sandbox_client sandbox_endpoint = let test_AI_activation = Protocol.register_test ~__FILE__ - ~supports:Protocol.(From_protocol (number ParisC)) + (* In protocols R+, AI is always immediately active; there is no + feature vote. *) + ~supports:Protocol.(Until_protocol (number Quebec)) ~title:"AI Activation - test AI activation after feature vote" ~tags:["adaptive_issuance"; "staking"] @@ fun protocol -> - let* _proto_hash, endpoint, client, _node = init protocol in + let overrides ~protocol = + (* Remove AI force activation *) + List.filter + (function + | ["adaptive_issuance_force_activation"], _ -> false | _ -> true) + (default_overrides ~protocol) + in + let* _proto_hash, endpoint, client, _node = init ~overrides protocol in let* staking_parameters = Client.RPC.call client @@ -275,22 +293,17 @@ let test_AI_activation = in assert (limit_after = 5000000 && edge_after = 500000000) ; - log_step - 3 - "Check staking is not allowed before AI activation (only for protocols up \ - to Q)" ; + log_step 3 "Check staking is not allowed before AI activation" ; let* () = - if Protocol.(number protocol <= 021) then - let stake = - Client.spawn_stake ~wait:"1" (Tez.of_int 1) ~staker:"bootstrap2" client - in - Process.check_error - ~msg: - (rex - "Manual staking operations are forbidden because staking is \ - currently automated.") - stake - else unit + let stake = + Client.spawn_stake ~wait:"1" (Tez.of_int 1) ~staker:"bootstrap2" client + in + Process.check_error + ~msg: + (rex + "Manual staking operations are forbidden because staking is \ + currently automated.") + stake in log_step 4 "Activate AI" ; @@ -314,19 +327,15 @@ let test_AI_activation = let test_AI_activation_bypass_vote = Protocol.register_test ~__FILE__ - ~supports:Protocol.(From_protocol (number ParisC)) + (* The "adaptive_issuance_force_activation" feature flag no longer + exists in protocols R+ *) + ~supports:Protocol.(Until_protocol (number Quebec)) ~title: "AI Activation - test AI activation with feature flag force_activation \ set" ~tags:["adaptive_issuance"; "staking"] @@ fun protocol -> - let* _proto_hash, endpoint, client, _node = - init - ~overrides: - ((["adaptive_issuance_force_activation"], `Bool true) - :: default_overrides) - protocol - in + let* _proto_hash, endpoint, client, _node = init protocol in let* ai_activated = Client.RPC.call client @@ -498,19 +507,15 @@ let test_staking = ] ~uses:(fun protocol -> [Protocol.accuser protocol]) @@ fun protocol -> - let parameters = - let overrides = - (["adaptive_issuance_force_activation"], `Bool true) :: default_overrides - in - if Protocol.number protocol > Protocol.number Protocol.Quebec then + let overrides ~protocol = + let overrides = default_overrides ~protocol in + if Protocol.(number protocol > number Quebec) then (* TODO: https://gitlab.com/tezos/tezos/-/issues/7576 use a default value for [tolerated_inactivity_period] *) (["tolerated_inactivity_period"], `Int 3) :: overrides else overrides in - let* _proto_hash, endpoint, client_1, node_1 = - init ~overrides:parameters protocol - in + let* _proto_hash, endpoint, client_1, node_1 = init ~overrides protocol in let* eosod = edge_of_staking_over_delegation client_1 in @@ -1463,13 +1468,7 @@ let test_fix_delegated_balance = ~title:"Test protocol fix for delegated balance rpc" ~tags:["rpc"; "delegated_balance"] @@ fun protocol -> - let* _proto_hash, endpoint, client, _node = - init - ~overrides: - ((["adaptive_issuance_force_activation"], `Bool true) - :: default_overrides) - protocol - in + let* _proto_hash, endpoint, client, _node = init protocol in let stake_amount = Tez.of_int 6_000 in let delegate = "bootstrap1" in log_step 1 "Preparing delegator accounts" ; diff --git a/tezt/tests/consensus_key.ml b/tezt/tests/consensus_key.ml index 9822e25f38299d0c3900606559fbfb75c22eb4cb..f2643421b9282519aa465e57add1a348ba46f21c 100644 --- a/tezt/tests/consensus_key.ml +++ b/tezt/tests/consensus_key.ml @@ -98,12 +98,11 @@ let test_update_consensus_key = (["consensus_rights_delay"], `Int consensus_rights_delay); (["cache_sampler_state_cycles"], `Int (consensus_rights_delay + 3)); (["cache_stake_distribution_cycles"], `Int (consensus_rights_delay + 3)); - (["adaptive_issuance_force_activation"], `Bool true); ] @ if Protocol.(number protocol > number Quebec) then [(["allow_tz4_delegate_enable"], `Bool true)] - else [] + else [(["adaptive_issuance_force_activation"], `Bool true)] in let* parameter_file = Protocol.write_parameter_file ~base:(Right (protocol, None)) parameters @@ -638,9 +637,12 @@ let register ?(regression = true) title test = (["consensus_rights_delay"], `Int consensus_rights_delay); (["cache_sampler_state_cycles"], `Int (consensus_rights_delay + 3)); (["cache_stake_distribution_cycles"], `Int (consensus_rights_delay + 3)); - (["adaptive_issuance_force_activation"], `Bool true); ] in + let parameters = + if Protocol.(number protocol > number Quebec) then parameters + else (["adaptive_issuance_force_activation"], `Bool true) :: parameters + in let* parameter_file = Protocol.write_parameter_file ~base:(Right (protocol, None)) parameters in diff --git a/tezt/tests/dal.ml b/tezt/tests/dal.ml index 088c9f3b8839a8ea5d841cc0d94f0fefdecd94b1..a6e3e343267497685bd08a22670ed806d0b5b3f1 100644 --- a/tezt/tests/dal.ml +++ b/tezt/tests/dal.ml @@ -534,7 +534,9 @@ let with_layer1 ?custom_constants ?additional_bootstrap_accounts smart_rollup_timeout_period_in_blocks (* AI is already active on mainnet, so it should be active immediately in tests *) - @ make_bool_parameter ["adaptive_issuance_force_activation"] (Some true) + @ (if Protocol.(number protocol <= number Quebec) then + make_bool_parameter ["adaptive_issuance_force_activation"] (Some true) + else []) @ parameters in @@ -7251,15 +7253,7 @@ let scenario_tutorial_dal_baker = * in this test *) Log.info "Step 2: Running octez node with adaptive issuance" ; - with_layer1 - ~parameters: - [ - (* Force activation of adaptive issuance *) - (["adaptive_issuance_force_activation"], `Bool true); - (["adaptive_issuance_activation_vote_enable"], `Bool false); - ] - ~event_sections_levels:[("prevalidator", `Debug)] - ~protocol + with_layer1 ~event_sections_levels:[("prevalidator", `Debug)] ~protocol @@ fun _parameters _cryptobox node client _key -> Log.info "Step 3: setup a baker account" ; (* Generate the "my_baker" user *) diff --git a/tezt/tests/expected/RPC_test.ml/Alpha- (mode client) RPC regression tests- adaptive_issuance.out b/tezt/tests/expected/RPC_test.ml/Alpha- (mode client) RPC regression tests- adaptive_issuance.out index e30220c2911afccbc20840d7491ccc0c93ad06d1..2d9234d651cceff4f0c071b739f41c7da4465478 100644 --- a/tezt/tests/expected/RPC_test.ml/Alpha- (mode client) RPC regression tests- adaptive_issuance.out +++ b/tezt/tests/expected/RPC_test.ml/Alpha- (mode client) RPC regression tests- adaptive_issuance.out @@ -35,7 +35,7 @@ "80007812" ./octez-client rpc get /chains/main/blocks/head/context/adaptive_issuance_launch_cycle -null +0 ./octez-client rpc get /chains/main/blocks/head/context/issuance/expected_issuance [ { "cycle": 0, "baking_reward_fixed_portion": "333333", 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 3713bbb32e6a5e17b784baa9fc959bdad7ccefe6..77aeae95772c0f3081f74390a278c8f6f460a4cf 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 @@ -26,7 +26,7 @@ "active_staking_parameters": { "limit_of_staking_over_baking_millionth": 0, "edge_of_baking_over_staking_billionth": 1000000000 }, - "pending_staking_parameters": [], "baking_power": "4000000000000", + "pending_staking_parameters": [], "baking_power": "1466666666666", "total_staked": "200000000000", "total_delegated": "3800000000000", "min_delegated_in_current_cycle": { "amount": "3800000000000", diff --git a/tezt/tests/expected/RPC_test.ml/Alpha- (mode client) RPC regression tests- misc_protocol.out b/tezt/tests/expected/RPC_test.ml/Alpha- (mode client) RPC regression tests- misc_protocol.out index 4b8e30747e46809d614b22f8efa479679c222c6d..0c5b5eaee02321a495c0d28a585b33c23cccfe29 100644 --- a/tezt/tests/expected/RPC_test.ml/Alpha- (mode client) RPC regression tests- misc_protocol.out +++ b/tezt/tests/expected/RPC_test.ml/Alpha- (mode client) RPC regression tests- misc_protocol.out @@ -66,7 +66,6 @@ "zk_rollup_max_ticket_payload_size": 2048, "global_limit_of_staking_over_baking": 9, "edge_of_staking_over_delegation": 3, - "adaptive_issuance_launch_ema_threshold": 0, "adaptive_rewards_params": { "issuance_ratio_final_min": { "numerator": "1", "denominator": "400" }, "issuance_ratio_final_max": { "numerator": "1", "denominator": "10" }, @@ -78,8 +77,6 @@ "growth_rate": { "numerator": "1", "denominator": "100" }, "center_dz": { "numerator": "1", "denominator": "2" }, "radius_dz": { "numerator": "1", "denominator": "50" } }, - "adaptive_issuance_activation_vote_enable": true, - "adaptive_issuance_force_activation": false, "direct_ticket_spending_enable": false, "aggregate_attestation": false, "allow_tz4_delegate_enable": true, "all_bakers_attest_enable": false } diff --git a/tezt/tests/expected/RPC_test.ml/Alpha- (mode light) RPC regression tests- adaptive_issuance.out b/tezt/tests/expected/RPC_test.ml/Alpha- (mode light) RPC regression tests- adaptive_issuance.out index 03f89133714933a8b4e96a95ddb0e6a56571ac0b..8883f5ceb76b59192deab8b17e9563b554868cab 100644 --- a/tezt/tests/expected/RPC_test.ml/Alpha- (mode light) RPC regression tests- adaptive_issuance.out +++ b/tezt/tests/expected/RPC_test.ml/Alpha- (mode light) RPC regression tests- adaptive_issuance.out @@ -35,7 +35,7 @@ "80007812" ./octez-client --mode light rpc get /chains/main/blocks/head/context/adaptive_issuance_launch_cycle -null +0 ./octez-client --mode light rpc get /chains/main/blocks/head/context/issuance/expected_issuance [ { "cycle": 0, "baking_reward_fixed_portion": "333333", 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 2ddf0b89bb3049c697473f9efadcabba8f10fd30..0033ab3bc2af477b19c3ca4c5bb6f2f2e095e6aa 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 @@ -26,7 +26,7 @@ "active_staking_parameters": { "limit_of_staking_over_baking_millionth": 0, "edge_of_baking_over_staking_billionth": 1000000000 }, - "pending_staking_parameters": [], "baking_power": "4000000000000", + "pending_staking_parameters": [], "baking_power": "1466666666666", "total_staked": "200000000000", "total_delegated": "3800000000000", "min_delegated_in_current_cycle": { "amount": "3800000000000", diff --git a/tezt/tests/expected/RPC_test.ml/Alpha- (mode light) RPC regression tests- misc_protocol.out b/tezt/tests/expected/RPC_test.ml/Alpha- (mode light) RPC regression tests- misc_protocol.out index 604258e8de4d93aa35058ee0abef4fe9695ddf1a..a52bb3fcdf1862206cd00eff145ac48a2bd5ba57 100644 --- a/tezt/tests/expected/RPC_test.ml/Alpha- (mode light) RPC regression tests- misc_protocol.out +++ b/tezt/tests/expected/RPC_test.ml/Alpha- (mode light) RPC regression tests- misc_protocol.out @@ -66,7 +66,6 @@ "zk_rollup_max_ticket_payload_size": 2048, "global_limit_of_staking_over_baking": 9, "edge_of_staking_over_delegation": 3, - "adaptive_issuance_launch_ema_threshold": 0, "adaptive_rewards_params": { "issuance_ratio_final_min": { "numerator": "1", "denominator": "400" }, "issuance_ratio_final_max": { "numerator": "1", "denominator": "10" }, @@ -78,8 +77,6 @@ "growth_rate": { "numerator": "1", "denominator": "100" }, "center_dz": { "numerator": "1", "denominator": "2" }, "radius_dz": { "numerator": "1", "denominator": "50" } }, - "adaptive_issuance_activation_vote_enable": true, - "adaptive_issuance_force_activation": false, "direct_ticket_spending_enable": false, "aggregate_attestation": false, "allow_tz4_delegate_enable": true, "all_bakers_attest_enable": false } diff --git a/tezt/tests/expected/RPC_test.ml/Alpha- (mode proxy) RPC regression tests- adaptive_issuance.out b/tezt/tests/expected/RPC_test.ml/Alpha- (mode proxy) RPC regression tests- adaptive_issuance.out index 2c36204a6a33a4350ad8ecaef58e8ddd60130c51..cefe6c3349a8135fc5c6a695082cf433883a7a4f 100644 --- a/tezt/tests/expected/RPC_test.ml/Alpha- (mode proxy) RPC regression tests- adaptive_issuance.out +++ b/tezt/tests/expected/RPC_test.ml/Alpha- (mode proxy) RPC regression tests- adaptive_issuance.out @@ -35,7 +35,7 @@ "80007812" ./octez-client --mode proxy rpc get /chains/main/blocks/head/context/adaptive_issuance_launch_cycle -null +0 ./octez-client --mode proxy rpc get /chains/main/blocks/head/context/issuance/expected_issuance [ { "cycle": 0, "baking_reward_fixed_portion": "333333", 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 a3d541a49ba5f8be99142dda06d475b812cf2ebc..c28f0a4f93ea4e54b5df73cf9deb568a0ce0f530 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 @@ -26,7 +26,7 @@ "active_staking_parameters": { "limit_of_staking_over_baking_millionth": 0, "edge_of_baking_over_staking_billionth": 1000000000 }, - "pending_staking_parameters": [], "baking_power": "4000000000000", + "pending_staking_parameters": [], "baking_power": "1466666666666", "total_staked": "200000000000", "total_delegated": "3800000000000", "min_delegated_in_current_cycle": { "amount": "3800000000000", diff --git a/tezt/tests/expected/RPC_test.ml/Alpha- (mode proxy) RPC regression tests- misc_protocol.out b/tezt/tests/expected/RPC_test.ml/Alpha- (mode proxy) RPC regression tests- misc_protocol.out index 3254159df6e9212ecf822bbdd81c6372a3d94ab7..21e4eab6d66b91ddc705d23591f30e0497f673af 100644 --- a/tezt/tests/expected/RPC_test.ml/Alpha- (mode proxy) RPC regression tests- misc_protocol.out +++ b/tezt/tests/expected/RPC_test.ml/Alpha- (mode proxy) RPC regression tests- misc_protocol.out @@ -66,7 +66,6 @@ "zk_rollup_max_ticket_payload_size": 2048, "global_limit_of_staking_over_baking": 9, "edge_of_staking_over_delegation": 3, - "adaptive_issuance_launch_ema_threshold": 0, "adaptive_rewards_params": { "issuance_ratio_final_min": { "numerator": "1", "denominator": "400" }, "issuance_ratio_final_max": { "numerator": "1", "denominator": "10" }, @@ -78,8 +77,6 @@ "growth_rate": { "numerator": "1", "denominator": "100" }, "center_dz": { "numerator": "1", "denominator": "2" }, "radius_dz": { "numerator": "1", "denominator": "50" } }, - "adaptive_issuance_activation_vote_enable": true, - "adaptive_issuance_force_activation": false, "direct_ticket_spending_enable": false, "aggregate_attestation": false, "allow_tz4_delegate_enable": true, "all_bakers_attest_enable": false } diff --git a/tezt/tests/expected/baker_test.ml/Alpha- Baker rewards.out b/tezt/tests/expected/baker_test.ml/Alpha- Baker rewards.out index d4e76ae935f16040156a20dbaae5447f680c9dc4..bbf60a07d917057a06429a30aa7807cd6430b6f2 100644 --- a/tezt/tests/expected/baker_test.ml/Alpha- Baker rewards.out +++ b/tezt/tests/expected/baker_test.ml/Alpha- Baker rewards.out @@ -67,7 +67,7 @@ "contract": "[PUBLIC_KEY_HASH]", "change": "2399999", "origin": "block" } ], "liquidity_baking_toggle_ema": 0, "adaptive_issuance_vote_ema": 0, - "adaptive_issuance_activation_cycle": 5, + "adaptive_issuance_activation_cycle": 0, "implicit_operations_results": [ { "kind": "origination", "balance_updates": diff --git a/tezt/tests/expected/weeklynet.ml/Alpha- weeklynet regression test.out b/tezt/tests/expected/weeklynet.ml/Alpha- weeklynet regression test.out index a4289984e2836bcaf76390515a05f709269c96c1..05c5ce10a7d06253cce674d2088515dff81ea28f 100644 --- a/tezt/tests/expected/weeklynet.ml/Alpha- weeklynet regression test.out +++ b/tezt/tests/expected/weeklynet.ml/Alpha- weeklynet regression test.out @@ -56,7 +56,6 @@ "zk_rollup_max_ticket_payload_size": 2048, "global_limit_of_staking_over_baking": 9, "edge_of_staking_over_delegation": 3, - "adaptive_issuance_launch_ema_threshold": 0, "adaptive_rewards_params": { "issuance_ratio_final_min": { "numerator": "1", "denominator": "400" }, "issuance_ratio_final_max": { "numerator": "1", "denominator": "10" }, @@ -68,7 +67,5 @@ "growth_rate": { "numerator": "1", "denominator": "100" }, "center_dz": { "numerator": "1", "denominator": "2" }, "radius_dz": { "numerator": "1", "denominator": "50" } }, - "adaptive_issuance_activation_vote_enable": true, - "adaptive_issuance_force_activation": false, "direct_ticket_spending_enable": false, "aggregate_attestation": false, "allow_tz4_delegate_enable": false, "all_bakers_attest_enable": false } diff --git a/tezt/tests/operation_size_and_gas.ml b/tezt/tests/operation_size_and_gas.ml index 9a089761ebbad0508dba2f3b37b579cc9ff97752..d6fd5bc2b2352a4c43276ce67b9af524f37811ec 100644 --- a/tezt/tests/operation_size_and_gas.ml +++ b/tezt/tests/operation_size_and_gas.ml @@ -427,7 +427,9 @@ let test_staking_operations = let* parameter_file = Protocol.write_parameter_file ~base:(Left (Protocol.parameter_file protocol)) - [(["adaptive_issuance_force_activation"], `Bool true)] + (if Protocol.(number protocol <= number Quebec) then + [(["adaptive_issuance_force_activation"], `Bool true)] + else []) in Log.info ~color:Log.Color.FG.green "Initialize a node and a client." ; let* node, client = diff --git a/tezt/tests/weeklynet_configs/alpha.json b/tezt/tests/weeklynet_configs/alpha.json index 84264f34cf49b99385e88b4ca31dc061c9cb25f2..04be71a65db7860087129984c2ec721b5f3d2916 100644 --- a/tezt/tests/weeklynet_configs/alpha.json +++ b/tezt/tests/weeklynet_configs/alpha.json @@ -116,7 +116,6 @@ "zk_rollup_max_ticket_payload_size": 2048, "global_limit_of_staking_over_baking": 9, "edge_of_staking_over_delegation": 3, - "adaptive_issuance_launch_ema_threshold": 0, "adaptive_rewards_params": { "issuance_ratio_final_min": { "numerator": "1", @@ -150,8 +149,6 @@ "denominator": "50" } }, - "adaptive_issuance_activation_vote_enable": true, - "adaptive_issuance_force_activation": false, "direct_ticket_spending_enable": false, "aggregate_attestation": false, "allow_tz4_delegate_enable": false,