diff --git a/src/proto_alpha/lib_protocol/adaptive_inflation_services.ml b/src/proto_alpha/lib_protocol/adaptive_inflation_services.ml index 9ea2d75c5261f66d6d91ae827af3791b144135ff..ae51999b4504774754060bdf5146f7a193612689 100644 --- a/src/proto_alpha/lib_protocol/adaptive_inflation_services.ml +++ b/src/proto_alpha/lib_protocol/adaptive_inflation_services.ml @@ -76,6 +76,16 @@ module S = struct ~query:RPC_query.empty ~output:Tez.encoding RPC_path.(path / "rewards_per_minute") + + let launch_cycle = + RPC_service.get_service + ~description: + "Returns the cycle at which the launch of the Adaptive Inflation \ + feature is set to happen. A result of None means that the feature is \ + not yet set to launch." + ~query:RPC_query.empty + ~output:(Data_encoding.option Cycle.encoding) + RPC_path.(context_path / "adaptive_inflation_launch_cycle") end let q_to_float_string q = @@ -127,7 +137,9 @@ let register () = current_yearly_rate_value ~formatter:(fun x -> x) ctxt) ; register0 ~chunked:false S.current_rewards_per_minute (fun ctxt () () -> let* f = current_rewards_per_minute ctxt in - return (Tez.of_mutez_exn (Q.to_int64 f))) + return (Tez.of_mutez_exn (Q.to_int64 f))) ; + register0 ~chunked:false S.launch_cycle (fun ctxt () () -> + Adaptive_inflation.launch_cycle ctxt) let total_supply ctxt block = RPC_context.make_call0 S.total_supply ctxt block () () @@ -143,3 +155,6 @@ let current_yearly_rate_exact ctxt block = let current_rewards_per_minute ctxt block = RPC_context.make_call0 S.current_rewards_per_minute ctxt block () () + +let launch_cycle ctxt block = + RPC_context.make_call0 S.launch_cycle ctxt block () () diff --git a/src/proto_alpha/lib_protocol/adaptive_inflation_services.mli b/src/proto_alpha/lib_protocol/adaptive_inflation_services.mli index 651aa92f8c3153df141eedb3038c19943598a07b..bf9af6235016144b11e735e37f0f967ec9954204 100644 --- a/src/proto_alpha/lib_protocol/adaptive_inflation_services.mli +++ b/src/proto_alpha/lib_protocol/adaptive_inflation_services.mli @@ -39,4 +39,7 @@ val current_yearly_rate_exact : val current_rewards_per_minute : 'a #RPC_context.simple -> 'a -> Tez.t shell_tzresult Lwt.t +val launch_cycle : + 'a #RPC_context.simple -> 'a -> Cycle.t option shell_tzresult Lwt.t + val register : unit -> unit diff --git a/src/proto_alpha/lib_protocol/adaptive_inflation_storage.ml b/src/proto_alpha/lib_protocol/adaptive_inflation_storage.ml index ab2c1823fe619b2617a17b465c70d61f3e4563a6..0b6940d510ab383178f39fb55bed9a6241918df0 100644 --- a/src/proto_alpha/lib_protocol/adaptive_inflation_storage.ml +++ b/src/proto_alpha/lib_protocol/adaptive_inflation_storage.ml @@ -219,6 +219,8 @@ let update_ema ctxt ~vote = let activate ctxt ~cycle = Storage.Adaptive_inflation.Activation.init ctxt cycle +let launch_cycle ctxt = Storage.Adaptive_inflation.Activation.find ctxt + module For_RPC = struct let get_reward_coeff = get_reward_coeff end diff --git a/src/proto_alpha/lib_protocol/adaptive_inflation_storage.mli b/src/proto_alpha/lib_protocol/adaptive_inflation_storage.mli index 6054df5c9482bf2359dbe2e1e08a9cf0ab03267a..2551ad0c88bee7ff769d39932c541b0e48c0ac1d 100644 --- a/src/proto_alpha/lib_protocol/adaptive_inflation_storage.mli +++ b/src/proto_alpha/lib_protocol/adaptive_inflation_storage.mli @@ -53,15 +53,17 @@ val update_ema : the adaptive inflation feature gets activated. If this function is never called, then the context does not contain the cycle for the feature activation, which implies the feature is inactive. - - In practice, it means that you may call - [Storage.Adaptive_inflation.Activation.find ctxt] to get the value - of the cycle at which the feature is activated, and if that call - returns [None], then it means the feature has not been - voted to be activated (yet). *) +*) val activate : Raw_context.t -> cycle:Cycle_repr.t -> Raw_context.t tzresult Lwt.t +(** [launch_cycle ctxt] reads from the context the cycle at which + the adaptive inflation feature is set to activate. + + If this function returns [None], then it means the feature has not been + voted to be activated (yet). *) +val launch_cycle : Raw_context.t -> Cycle_repr.t option tzresult Lwt.t + module For_RPC : sig (** [get_reward_coeff ctxt cycle] reads the reward coeff for the given cycle from the storage. diff --git a/src/proto_alpha/lib_protocol/alpha_context.mli b/src/proto_alpha/lib_protocol/alpha_context.mli index 7e3390098e291da989fc47babb8872882710c966..e6034415b832a8747e2baaa3dd9d7ce2f2545590 100644 --- a/src/proto_alpha/lib_protocol/alpha_context.mli +++ b/src/proto_alpha/lib_protocol/alpha_context.mli @@ -4789,6 +4789,8 @@ module Adaptive_inflation : sig context -> vote:Toggle_votes.toggle_vote -> (context * Toggle_votes.Adaptive_inflation_launch_EMA.t) tzresult Lwt.t + + val launch_cycle : context -> Cycle.t option tzresult Lwt.t end (** This module re-exports definitions from {!Ticket_storage}. *) diff --git a/src/proto_alpha/lib_protocol/test/helpers/context.ml b/src/proto_alpha/lib_protocol/test/helpers/context.ml index 888f979b8dcfd489119879773480358b2b2bdeb4..07d05906175a2cbde9b97376bfe431e12f20e1b5 100644 --- a/src/proto_alpha/lib_protocol/test/helpers/context.ml +++ b/src/proto_alpha/lib_protocol/test/helpers/context.ml @@ -241,6 +241,9 @@ let get_liquidity_baking_subsidy ctxt = let get_liquidity_baking_cpmm_address ctxt = Alpha_services.Liquidity_baking.get_cpmm_address rpc_ctxt ctxt +let get_adaptive_inflation_launch_cycle ctxt = + Adaptive_inflation_services.launch_cycle rpc_ctxt ctxt + let get_seed_nonce_revelation_tip ctxt = get_constants ctxt >>=? fun {Constants.parametric = csts; _} -> return diff --git a/src/proto_alpha/lib_protocol/test/helpers/context.mli b/src/proto_alpha/lib_protocol/test/helpers/context.mli index 5a787671ed653fb36dcbc4c7c464109923137004..bc011b463bb94396a42ad753b3565bc345001820 100644 --- a/src/proto_alpha/lib_protocol/test/helpers/context.mli +++ b/src/proto_alpha/lib_protocol/test/helpers/context.mli @@ -108,6 +108,8 @@ val get_liquidity_baking_subsidy : t -> Tez.t tzresult Lwt.t val get_liquidity_baking_cpmm_address : t -> Contract_hash.t tzresult Lwt.t +val get_adaptive_inflation_launch_cycle : t -> Cycle.t option tzresult Lwt.t + val get_seed_nonce_revelation_tip : t -> Tez.t tzresult Lwt.t val get_vdf_revelation_tip : t -> Tez.t tzresult Lwt.t