diff --git a/src/proto_alpha/lib_parameters/default_parameters.ml b/src/proto_alpha/lib_parameters/default_parameters.ml index ba10b85e6249822fe40875e0d5491d51adad3a44..fb85d4b805458cec72ffaa1c655f28daba902209 100644 --- a/src/proto_alpha/lib_parameters/default_parameters.ml +++ b/src/proto_alpha/lib_parameters/default_parameters.ml @@ -104,14 +104,18 @@ let constants_mainnet = let Constants.Generated. { consensus_threshold; - baking_reward_fixed_portion; - baking_reward_bonus_per_slot; - endorsing_reward_per_slot; - liquidity_baking_subsidy; + reward_weights = + { + base_total_rewards_per_minute; + baking_reward_fixed_portion_weight; + baking_reward_bonus_weight; + endorsing_reward_weight; + liquidity_baking_subsidy_weight; + seed_nonce_revelation_tip_weight; + vdf_revelation_tip_weight; + }; } = - Constants.Generated.generate - ~consensus_committee_size - ~blocks_per_minute:{numerator = 60; denominator = block_time} + Constants.Generated.generate ~consensus_committee_size in { Constants.Parametric.preserved_cycles = 5; @@ -134,19 +138,29 @@ let constants_mainnet = - 5: security factor (strictly higher than the ratio between highest CPU clock rate and benchmark machine that is 8.43/2.8 ~= 3 *) vdf_difficulty = 8_000_000_000L; - seed_nonce_revelation_tip = - (match Tez.(one /? 8L) with Ok c -> c | Error _ -> assert false); origination_size = 257; - baking_reward_fixed_portion (* 5_000_000 mutez *); - baking_reward_bonus_per_slot (* 2_143 mutez *); - endorsing_reward_per_slot (* 1_428 mutez *); + reward_weights = + { + base_total_rewards_per_minute; + (* 85.007812 tez/minute *) + baking_reward_fixed_portion_weight; + (* 1/4th of total block rewards *) + baking_reward_bonus_weight; + (* all bonus rewards = fixed rewards *) + endorsing_reward_weight; + (* all baking rewards = all endorsing rewards *) + liquidity_baking_subsidy_weight; + (* 1/16th of block rewards *) + seed_nonce_revelation_tip_weight; + (* 1/20480 of block rewards *) + vdf_revelation_tip_weight; + (* 1/20480 of block rewards *) + }; hard_storage_limit_per_operation = Z.of_int 60_000; cost_per_byte = Tez.of_mutez_exn 250L; quorum_min = 20_00l; quorum_max = 70_00l; min_proposal_quorum = 5_00l; - (* liquidity_baking_subsidy is 1/16th of maximum total rewards for a block *) - liquidity_baking_subsidy (* 1_250_000 mutez *); (* 1/2 window size of 2000 blocks with precision of 1_000_000 for integer computation *) liquidity_baking_toggle_ema_threshold = 1_000_000_000l; @@ -293,17 +307,8 @@ let derive_cryptobox_parameters ~redundancy_factor ~mainnet_constants_divider = let constants_sandbox = let consensus_committee_size = 256 in let block_time = 1 in - let Constants.Generated. - { - consensus_threshold = _; - baking_reward_fixed_portion; - baking_reward_bonus_per_slot; - endorsing_reward_per_slot; - liquidity_baking_subsidy; - } = - Constants.Generated.generate - ~consensus_committee_size - ~blocks_per_minute:{numerator = 60; denominator = block_time} + let Constants.Generated.{consensus_threshold = _; reward_weights} = + Constants.Generated.generate ~consensus_committee_size in { constants_mainnet with @@ -318,6 +323,7 @@ let constants_sandbox = ~redundancy_factor:8 ~mainnet_constants_divider:32; }; + reward_weights; Constants.Parametric.preserved_cycles = 2; blocks_per_cycle = 8l; blocks_per_commitment = 4l; @@ -326,31 +332,18 @@ let constants_sandbox = cycles_per_voting_period = 8l; proof_of_work_threshold = Int64.(sub (shift_left 1L 62) 1L); vdf_difficulty = 50_000L; - liquidity_baking_subsidy; minimal_block_delay = Period.of_seconds_exn (Int64.of_int block_time); delay_increment_per_round = Period.one_second; consensus_committee_size = 256; consensus_threshold = 0; - baking_reward_fixed_portion (* 333_333 mutez *); - baking_reward_bonus_per_slot (* 3_921 mutez *); - endorsing_reward_per_slot (* 2_604 mutez *); max_slashing_period = 2; frozen_deposits_percentage = 5; } let constants_test = let consensus_committee_size = 25 in - let Constants.Generated. - { - consensus_threshold; - baking_reward_fixed_portion; - baking_reward_bonus_per_slot; - endorsing_reward_per_slot; - liquidity_baking_subsidy; - } = - Constants.Generated.generate - ~consensus_committee_size - ~blocks_per_minute:{numerator = 2; denominator = 1} + let Constants.Generated.{consensus_threshold; reward_weights} = + Constants.Generated.generate ~consensus_committee_size in { constants_mainnet with @@ -365,6 +358,7 @@ let constants_test = ~redundancy_factor:4 ~mainnet_constants_divider:64; }; + reward_weights; Constants.Parametric.preserved_cycles = 3; blocks_per_cycle = 12l; blocks_per_commitment = 4l; @@ -374,13 +368,9 @@ let constants_test = proof_of_work_threshold = Int64.(sub (shift_left 1L 62) 1L) (* 1/4 of nonces are accepted *); vdf_difficulty = 50_000L; - liquidity_baking_subsidy; consensus_committee_size; consensus_threshold (* 17 slots *); max_slashing_period = 2; - baking_reward_fixed_portion (* 10 tez *); - baking_reward_bonus_per_slot (* 1.25 tez *); - endorsing_reward_per_slot (* 0.8 tez *); frozen_deposits_percentage = 5 (* not 10 so that multiplication and diff --git a/src/proto_alpha/lib_protocol/TEZOS_PROTOCOL b/src/proto_alpha/lib_protocol/TEZOS_PROTOCOL index f4e52cc12d54c97040fa751438f656e4d7051b6d..68c78822f3cb4dbadf204ccb496d930914be933b 100644 --- a/src/proto_alpha/lib_protocol/TEZOS_PROTOCOL +++ b/src/proto_alpha/lib_protocol/TEZOS_PROTOCOL @@ -157,6 +157,7 @@ "Delegate_consensus_key", "Delegate_storage", "Delegate_sampler", + "Delegate_rewards", "Delegate_missed_endorsements_storage", "Delegate_slashed_deposits_storage", "Delegate_cycles", diff --git a/src/proto_alpha/lib_protocol/alpha_context.ml b/src/proto_alpha/lib_protocol/alpha_context.ml index e3213ecde8ba3b0a54cd84d18b7b1172abedb3c9..d0ec1f30c0daa4868129218673986a053bda1c61 100644 --- a/src/proto_alpha/lib_protocol/alpha_context.ml +++ b/src/proto_alpha/lib_protocol/alpha_context.ml @@ -551,6 +551,7 @@ module Delegate = struct let deactivated = Delegate_activation_storage.is_inactive module Consensus_key = Delegate_consensus_key + module Rewards = Delegate_rewards end module Stake_distribution = struct diff --git a/src/proto_alpha/lib_protocol/alpha_context.mli b/src/proto_alpha/lib_protocol/alpha_context.mli index e5e2fd254562d04caf667f91aac23d66e5a0c12d..8ac38dd6f90bc26199dd8400d495131f995984b5 100644 --- a/src/proto_alpha/lib_protocol/alpha_context.mli +++ b/src/proto_alpha/lib_protocol/alpha_context.mli @@ -842,6 +842,16 @@ module Constants : sig type adaptive_inflation = {enable : bool} + type reward_weights = { + base_total_rewards_per_minute : Tez.t; + baking_reward_fixed_portion_weight : int; + baking_reward_bonus_weight : int; + endorsing_reward_weight : int; + liquidity_baking_subsidy_weight : int; + seed_nonce_revelation_tip_weight : int; + vdf_revelation_tip_weight : int; + } + type t = { preserved_cycles : int; blocks_per_cycle : int32; @@ -854,17 +864,13 @@ module Constants : sig proof_of_work_threshold : int64; minimal_stake : Tez.t; vdf_difficulty : int64; - seed_nonce_revelation_tip : Tez.t; origination_size : int; - baking_reward_fixed_portion : Tez.t; - baking_reward_bonus_per_slot : Tez.t; - endorsing_reward_per_slot : Tez.t; + reward_weights : reward_weights; cost_per_byte : Tez.t; hard_storage_limit_per_operation : Z.t; quorum_min : int32; quorum_max : int32; min_proposal_quorum : int32; - liquidity_baking_subsidy : Tez.t; liquidity_baking_toggle_ema_threshold : int32; max_operations_time_to_live : int; minimal_block_delay : Period.t; @@ -894,14 +900,10 @@ module Constants : sig module Generated : sig type t = { consensus_threshold : int; - baking_reward_fixed_portion : Tez.t; - baking_reward_bonus_per_slot : Tez.t; - endorsing_reward_per_slot : Tez.t; - liquidity_baking_subsidy : Tez.t; + reward_weights : Parametric.reward_weights; } - val generate : - consensus_committee_size:int -> blocks_per_minute:Ratio.t -> t + val generate : consensus_committee_size:int -> t end val parametric : context -> Parametric.t @@ -936,15 +938,9 @@ module Constants : sig val vdf_difficulty : context -> int64 - val seed_nonce_revelation_tip : context -> Tez.t - val origination_size : context -> int - val baking_reward_fixed_portion : context -> Tez.t - - val baking_reward_bonus_per_slot : context -> Tez.t - - val endorsing_reward_per_slot : context -> Tez.t + val reward_weights : context -> Parametric.reward_weights val quorum_min : context -> int32 @@ -952,8 +948,6 @@ module Constants : sig val min_proposal_quorum : context -> int32 - val liquidity_baking_subsidy : context -> Tez.t - val liquidity_baking_toggle_ema_threshold : context -> int32 val minimal_block_delay : context -> Period.t @@ -2624,7 +2618,8 @@ end (** This module re-exports definitions from {!Delegate_storage}, {!Delegate_consensus_key}, {!Delegate_missed_endorsements_storage}, - {!Delegate_slashed_deposits_storage}, {!Delegate_cycles}. *) + {!Delegate_slashed_deposits_storage}, {!Delegate_cycles}, + {!Delegate_rewards}. *) module Delegate : sig val check_not_tz4 : Signature.public_key_hash -> unit tzresult @@ -2739,6 +2734,33 @@ module Delegate : sig (** See {!Stake_storage.prepare_stake_distribution}. *) val prepare_stake_distribution : context -> context tzresult Lwt.t + + module Rewards : sig + val baking_reward_fixed_portion : t -> Tez.t + + val baking_reward_bonus_per_slot : t -> Tez.t + + val endorsing_reward_per_slot : t -> Tez.t + + val liquidity_baking_subsidy : t -> Tez.t + + val seed_nonce_revelation_tip : t -> Tez.t + + val vdf_revelation_tip : t -> Tez.t + + module Internal_for_tests : sig + type reward_kind = + | Baking_reward_fixed_portion + | Baking_reward_bonus_per_slot + | Endorsing_reward_per_slot + | Liquidity_baking_subsidy + | Seed_nonce_revelation_tip + | Vdf_revelation_tip + + val reward_from_constants : + csts:Constants.Parametric.t -> reward_kind:reward_kind -> Tez.t + end + end end (** This module re-exports definitions from {!Voting_period_repr} and diff --git a/src/proto_alpha/lib_protocol/apply.ml b/src/proto_alpha/lib_protocol/apply.ml index eaae79440e065bf0de1fd61ec590009e7ad3d205..13927ad65550a8f9ae7d6e5fc4b2ea821aeaceac 100644 --- a/src/proto_alpha/lib_protocol/apply.ml +++ b/src/proto_alpha/lib_protocol/apply.ml @@ -1917,7 +1917,7 @@ let apply_contents_list (type kind) ctxt chain_id (mode : mode) | Single (Seed_nonce_revelation {level; nonce}) -> let level = Level.from_raw ctxt level in Nonce.reveal ctxt level nonce >>=? fun ctxt -> - let tip = Constants.seed_nonce_revelation_tip ctxt in + let tip = Delegate.Rewards.seed_nonce_revelation_tip ctxt in let contract = Contract.Implicit payload_producer.Consensus_key.delegate in @@ -1926,7 +1926,7 @@ let apply_contents_list (type kind) ctxt chain_id (mode : mode) (ctxt, Single_result (Seed_nonce_revelation_result balance_updates)) | Single (Vdf_revelation {solution}) -> Seed.update_seed ctxt solution >>=? fun ctxt -> - let tip = Constants.seed_nonce_revelation_tip ctxt in + let tip = Delegate.Rewards.vdf_revelation_tip ctxt in let contract = Contract.Implicit payload_producer.Consensus_key.delegate in @@ -2063,7 +2063,9 @@ let apply_liquidity_baking_subsidy ctxt ~toggle_vote = (Z.of_int 20))) in let backtracking_ctxt = ctxt in - (let liquidity_baking_subsidy = Constants.liquidity_baking_subsidy ctxt in + (let liquidity_baking_subsidy = + Delegate.Rewards.liquidity_baking_subsidy ctxt + in (* credit liquidity baking subsidy to CPMM contract *) Token.transfer ~origin:Subsidy @@ -2416,7 +2418,7 @@ let finalize_application ctxt block_data_contents ~round ~predecessor_hash return (ctxt, Some rewards_bonus) else return (ctxt, None) in - let baking_reward = Constants.baking_reward_fixed_portion ctxt in + let baking_reward = Delegate.Rewards.baking_reward_fixed_portion ctxt in let* ctxt, baking_receipts = Delegate.record_baking_activity_and_pay_rewards_and_fees ctxt diff --git a/src/proto_alpha/lib_protocol/baking.ml b/src/proto_alpha/lib_protocol/baking.ml index 3f5e1468a516faf400720f71039ebefdc16ccc32..a2f2c5f3057d7efe2c35a9ef6ec1b2d9ae20f719 100644 --- a/src/proto_alpha/lib_protocol/baking.ml +++ b/src/proto_alpha/lib_protocol/baking.ml @@ -59,7 +59,7 @@ let () = let bonus_baking_reward ctxt ~endorsing_power = let consensus_threshold = Constants.consensus_threshold ctxt in let baking_reward_bonus_per_slot = - Constants.baking_reward_bonus_per_slot ctxt + Delegate.Rewards.baking_reward_bonus_per_slot ctxt in let extra_endorsing_power = endorsing_power - consensus_threshold in error_when diff --git a/src/proto_alpha/lib_protocol/bootstrap_storage.ml b/src/proto_alpha/lib_protocol/bootstrap_storage.ml index 7c3de02badec173dfa832a420e0b505dbc34f574..1cf7b6ace7983228ddfd8ea388c320e02c29debf 100644 --- a/src/proto_alpha/lib_protocol/bootstrap_storage.ml +++ b/src/proto_alpha/lib_protocol/bootstrap_storage.ml @@ -112,9 +112,11 @@ let init ctxt ~typecheck ?no_reward_cycles accounts contracts = Raw_context.patch_constants ctxt (fun c -> { c with - baking_reward_fixed_portion = Tez_repr.zero; - baking_reward_bonus_per_slot = Tez_repr.zero; - endorsing_reward_per_slot = Tez_repr.zero; + reward_weights = + { + c.reward_weights with + base_total_rewards_per_minute = Tez_repr.zero; + }; }) >>= fun ctxt -> (* Store the final reward. *) @@ -123,10 +125,11 @@ let init ctxt ~typecheck ?no_reward_cycles accounts contracts = ctxt (Cycle_repr.of_int32_exn (Int32.of_int cycles)) { - baking_reward_fixed_portion = constants.baking_reward_fixed_portion; - baking_reward_bonus_per_slot = - constants.baking_reward_bonus_per_slot; - endorsing_reward_per_slot = constants.endorsing_reward_per_slot; + (* Hack: we store the rewards here *) + baking_reward_fixed_portion = + constants.reward_weights.base_total_rewards_per_minute; + baking_reward_bonus_per_slot = Tez_repr.zero; + endorsing_reward_per_slot = Tez_repr.zero; })) >|=? fun ctxt -> (ctxt, balance_updates) @@ -134,19 +137,15 @@ let cycle_end ctxt last_cycle = let next_cycle = Cycle_repr.succ last_cycle in Storage.Ramp_up.Rewards.find ctxt next_cycle >>=? function | None -> return ctxt - | Some - Storage.Ramp_up. - { - baking_reward_fixed_portion; - baking_reward_bonus_per_slot; - endorsing_reward_per_slot; - } -> + | Some Storage.Ramp_up.{baking_reward_fixed_portion; _} -> Storage.Ramp_up.Rewards.remove_existing ctxt next_cycle >>=? fun ctxt -> Raw_context.patch_constants ctxt (fun c -> { c with - baking_reward_fixed_portion; - baking_reward_bonus_per_slot; - endorsing_reward_per_slot; + reward_weights = + { + c.reward_weights with + base_total_rewards_per_minute = baking_reward_fixed_portion; + }; }) >|= ok diff --git a/src/proto_alpha/lib_protocol/constants_parametric_repr.ml b/src/proto_alpha/lib_protocol/constants_parametric_repr.ml index c504aeeb7cf9a7cef3555d94e294d8c8de18969d..4a026a96d021910ac0912ea3154b80b8892e9e83 100644 --- a/src/proto_alpha/lib_protocol/constants_parametric_repr.ml +++ b/src/proto_alpha/lib_protocol/constants_parametric_repr.ml @@ -125,6 +125,16 @@ type zk_rollup = { type adaptive_inflation = {enable : bool} +type reward_weights = { + base_total_rewards_per_minute : Tez_repr.t; + baking_reward_fixed_portion_weight : int; + baking_reward_bonus_weight : int; + endorsing_reward_weight : int; + liquidity_baking_subsidy_weight : int; + seed_nonce_revelation_tip_weight : int; + vdf_revelation_tip_weight : int; +} + type t = { preserved_cycles : int; blocks_per_cycle : int32; @@ -137,17 +147,13 @@ type t = { proof_of_work_threshold : int64; minimal_stake : Tez_repr.t; vdf_difficulty : int64; - seed_nonce_revelation_tip : Tez_repr.t; origination_size : int; - baking_reward_fixed_portion : Tez_repr.t; - baking_reward_bonus_per_slot : Tez_repr.t; - endorsing_reward_per_slot : Tez_repr.t; + reward_weights : reward_weights; cost_per_byte : Tez_repr.t; hard_storage_limit_per_operation : Z.t; quorum_min : int32; quorum_max : int32; min_proposal_quorum : int32; - liquidity_baking_subsidy : Tez_repr.t; liquidity_baking_toggle_ema_threshold : int32; max_operations_time_to_live : int; minimal_block_delay : Period_repr.t; @@ -332,6 +338,51 @@ let adaptive_inflation_encoding = (fun adaptive_inflation_enable -> {enable = adaptive_inflation_enable}) (obj1 (req "adaptive_inflation_enable" bool)) +let reward_weights_encoding = + let open Data_encoding in + conv + (fun ({ + base_total_rewards_per_minute; + baking_reward_fixed_portion_weight; + baking_reward_bonus_weight; + endorsing_reward_weight; + liquidity_baking_subsidy_weight; + seed_nonce_revelation_tip_weight; + vdf_revelation_tip_weight; + } : + reward_weights) -> + ( base_total_rewards_per_minute, + baking_reward_fixed_portion_weight, + baking_reward_bonus_weight, + endorsing_reward_weight, + liquidity_baking_subsidy_weight, + seed_nonce_revelation_tip_weight, + vdf_revelation_tip_weight )) + (fun ( base_total_rewards_per_minute, + baking_reward_fixed_portion_weight, + baking_reward_bonus_weight, + endorsing_reward_weight, + liquidity_baking_subsidy_weight, + seed_nonce_revelation_tip_weight, + vdf_revelation_tip_weight ) -> + { + base_total_rewards_per_minute; + baking_reward_fixed_portion_weight; + baking_reward_bonus_weight; + endorsing_reward_weight; + liquidity_baking_subsidy_weight; + seed_nonce_revelation_tip_weight; + vdf_revelation_tip_weight; + }) + (obj7 + (req "base_index_of_total_rewards_per_minute" Tez_repr.encoding) + (req "baking_reward_fixed_weight" int31) + (req "baking_reward_bonus_weight" int31) + (req "endorsing_reward_weight" int31) + (req "liquidity_baking_subsidy_weight" int31) + (req "nonce_revelation_tip_weight" int31) + (req "vdf_revelation_tip_weight" int31)) + let encoding = let open Data_encoding in conv @@ -347,17 +398,13 @@ let encoding = c.proof_of_work_threshold, c.minimal_stake ), ( ( c.vdf_difficulty, - c.seed_nonce_revelation_tip, c.origination_size, - c.baking_reward_fixed_portion, - c.baking_reward_bonus_per_slot, - c.endorsing_reward_per_slot, + c.reward_weights, c.cost_per_byte, c.hard_storage_limit_per_operation, c.quorum_min ), ( ( c.quorum_max, c.min_proposal_quorum, - c.liquidity_baking_subsidy, c.liquidity_baking_toggle_ema_threshold, c.max_operations_time_to_live, c.minimal_block_delay, @@ -388,17 +435,13 @@ let encoding = proof_of_work_threshold, minimal_stake ), ( ( vdf_difficulty, - seed_nonce_revelation_tip, origination_size, - baking_reward_fixed_portion, - baking_reward_bonus_per_slot, - endorsing_reward_per_slot, + reward_weights, cost_per_byte, hard_storage_limit_per_operation, quorum_min ), ( ( quorum_max, min_proposal_quorum, - liquidity_baking_subsidy, liquidity_baking_toggle_ema_threshold, max_operations_time_to_live, minimal_block_delay, @@ -430,17 +473,13 @@ let encoding = proof_of_work_threshold; minimal_stake; vdf_difficulty; - seed_nonce_revelation_tip; origination_size; - baking_reward_fixed_portion; - baking_reward_bonus_per_slot; - endorsing_reward_per_slot; + reward_weights; cost_per_byte; hard_storage_limit_per_operation; quorum_min; quorum_max; min_proposal_quorum; - liquidity_baking_subsidy; liquidity_baking_toggle_ema_threshold; max_operations_time_to_live; minimal_block_delay; @@ -480,21 +519,17 @@ let encoding = (req "proof_of_work_threshold" int64) (req "minimal_stake" Tez_repr.encoding)) (merge_objs - (obj9 + (obj6 (req "vdf_difficulty" int64) - (req "seed_nonce_revelation_tip" Tez_repr.encoding) (req "origination_size" int31) - (req "baking_reward_fixed_portion" Tez_repr.encoding) - (req "baking_reward_bonus_per_slot" Tez_repr.encoding) - (req "endorsing_reward_per_slot" Tez_repr.encoding) + (req "reward_weights" reward_weights_encoding) (req "cost_per_byte" Tez_repr.encoding) (req "hard_storage_limit_per_operation" z) (req "quorum_min" int32)) (merge_objs - (obj9 + (obj8 (req "quorum_max" int32) (req "min_proposal_quorum" int32) - (req "liquidity_baking_subsidy" Tez_repr.encoding) (req "liquidity_baking_toggle_ema_threshold" int32) (req "max_operations_time_to_live" int16) (req "minimal_block_delay" Period_repr.encoding) diff --git a/src/proto_alpha/lib_protocol/constants_parametric_repr.mli b/src/proto_alpha/lib_protocol/constants_parametric_repr.mli index c1f62184dd79c96cdd2586f52b874a3096ffea00..45a3db2b5f30ccef649071ffb41c90bf686bdf7a 100644 --- a/src/proto_alpha/lib_protocol/constants_parametric_repr.mli +++ b/src/proto_alpha/lib_protocol/constants_parametric_repr.mli @@ -140,6 +140,22 @@ type zk_rollup = { type adaptive_inflation = {enable : bool} +type reward_weights = { + (* [base_total_rewards_per_minute] is the total amount of rewards expected to + be distributed every minute *) + base_total_rewards_per_minute : Tez_repr.t; + (* The following fields represent the "weights" of the respective reward kinds. + The actual reward values are computed proportionally from the other weights + as a portion of the [base_total_rewards_per_minute]. See the module + {!Delegate_rewards} for more details *) + baking_reward_fixed_portion_weight : int; + baking_reward_bonus_weight : int; + endorsing_reward_weight : int; + liquidity_baking_subsidy_weight : int; + seed_nonce_revelation_tip_weight : int; + vdf_revelation_tip_weight : int; +} + type t = { preserved_cycles : int; blocks_per_cycle : int32; @@ -152,18 +168,14 @@ type t = { proof_of_work_threshold : int64; minimal_stake : Tez_repr.t; vdf_difficulty : int64; - seed_nonce_revelation_tip : Tez_repr.t; origination_size : int; - baking_reward_fixed_portion : Tez_repr.t; - baking_reward_bonus_per_slot : Tez_repr.t; - endorsing_reward_per_slot : Tez_repr.t; + reward_weights : reward_weights; cost_per_byte : Tez_repr.t; hard_storage_limit_per_operation : Z.t; quorum_min : int32; (* in centile of a percentage *) quorum_max : int32; min_proposal_quorum : int32; - liquidity_baking_subsidy : Tez_repr.t; liquidity_baking_toggle_ema_threshold : int32; max_operations_time_to_live : int; minimal_block_delay : Period_repr.t; diff --git a/src/proto_alpha/lib_protocol/constants_repr.ml b/src/proto_alpha/lib_protocol/constants_repr.ml index d251f38f5e65414ceb3f5639419689765e8d0473..b4faea3ebb6813a62f373c90eac181dff0dd8f84 100644 --- a/src/proto_alpha/lib_protocol/constants_repr.ml +++ b/src/proto_alpha/lib_protocol/constants_repr.ml @@ -346,40 +346,45 @@ let check_constants constants = module Generated = struct type t = { consensus_threshold : int; - baking_reward_fixed_portion : Tez_repr.t; - baking_reward_bonus_per_slot : Tez_repr.t; - endorsing_reward_per_slot : Tez_repr.t; - liquidity_baking_subsidy : Tez_repr.t; + reward_weights : Constants_parametric_repr.reward_weights; } - let generate ~consensus_committee_size ~blocks_per_minute = + let generate ~consensus_committee_size = + (* The weights are expressed in [(256 * 80)]th of the total + reward, because it is the smallest proportion used so far*) let consensus_threshold = (consensus_committee_size * 2 / 3) + 1 in - (* As in previous protocols, we set the maximum total rewards per minute to - be 80 tez. *) - let rewards_per_minute = Tez_repr.(mul_exn one 80) in - let rewards_per_block = - Ratio_repr.( - Tez_repr.( - div_exn - (mul_exn rewards_per_minute blocks_per_minute.denominator) - blocks_per_minute.numerator)) - in - let rewards_half = Tez_repr.(div_exn rewards_per_block 2) in - let rewards_quarter = Tez_repr.(div_exn rewards_per_block 4) in let bonus_committee_size = consensus_committee_size - consensus_threshold in + let base_total_rewards_per_minute = Tez_repr.of_mutez_exn 85_007_812L in + let _reward_parts_whole = 20480 (* = 256 * 80 *) in + let reward_parts_half = 10240 (* = reward_parts_whole / 2 *) in + let reward_parts_quarter = 5120 (* = reward_parts_whole / 4 *) in + let reward_parts_16th = 1280 (* = reward_parts_whole / 16 *) in { consensus_threshold; - baking_reward_fixed_portion = - (if Compare.Int.(bonus_committee_size <= 0) then - (* a fortiori, consensus_committee_size < 4 *) - rewards_half - else rewards_quarter); - baking_reward_bonus_per_slot = - (if Compare.Int.(bonus_committee_size <= 0) then Tez_repr.zero - else Tez_repr.div_exn rewards_quarter bonus_committee_size); - endorsing_reward_per_slot = - Tez_repr.div_exn rewards_half consensus_committee_size; - liquidity_baking_subsidy = Tez_repr.div_exn rewards_per_block 16; + reward_weights = + { + base_total_rewards_per_minute; + (* 85.007812 tez/minute *) + baking_reward_fixed_portion_weight = + (* 1/4 or 1/2 *) + (if Compare.Int.(bonus_committee_size <= 0) then + (* a fortiori, consensus_committee_size < 4 *) + reward_parts_half + else reward_parts_quarter); + baking_reward_bonus_weight = + (* 1/4 or 0 *) + (if Compare.Int.(bonus_committee_size <= 0) then 0 + else reward_parts_quarter); + endorsing_reward_weight = reward_parts_half; + (* 1/2 *) + (* All block (baking + endorsing)rewards sum to 1 ( *256*80 ) *) + liquidity_baking_subsidy_weight = reward_parts_16th; + (* 1/16 *) + seed_nonce_revelation_tip_weight = 1; + (* 1/20480 *) + vdf_revelation_tip_weight = 1; + (* 1/20480 *) + }; } end diff --git a/src/proto_alpha/lib_protocol/constants_repr.mli b/src/proto_alpha/lib_protocol/constants_repr.mli index 18dd739e62eac484bfbda36bed27874f09b8b03e..52c0eede68a9ea3bcaddcaa79d3630ec9832ea0c 100644 --- a/src/proto_alpha/lib_protocol/constants_repr.mli +++ b/src/proto_alpha/lib_protocol/constants_repr.mli @@ -104,16 +104,12 @@ val check_constants : Constants_parametric_repr.t -> unit tzresult module Generated : sig type t = { consensus_threshold : int; - baking_reward_fixed_portion : Tez_repr.t; - baking_reward_bonus_per_slot : Tez_repr.t; - endorsing_reward_per_slot : Tez_repr.t; - liquidity_baking_subsidy : Tez_repr.t; + reward_weights : Constants_parametric_repr.reward_weights; } (* This function is meant to be used just in lib_parameters and in the migration code to be sure that the parameters are consistent. *) - val generate : - consensus_committee_size:int -> blocks_per_minute:Ratio_repr.t -> t + val generate : consensus_committee_size:int -> t end (** For each subcache, a size limit needs to be declared once. However, diff --git a/src/proto_alpha/lib_protocol/constants_storage.ml b/src/proto_alpha/lib_protocol/constants_storage.ml index 9717bda774a2c3a48ff297a1269fbee3e837f18b..dacae7e11584edf107f7613a6e45338af355deec 100644 --- a/src/proto_alpha/lib_protocol/constants_storage.ml +++ b/src/proto_alpha/lib_protocol/constants_storage.ml @@ -76,25 +76,13 @@ let vdf_difficulty c = let constants = Raw_context.constants c in constants.vdf_difficulty -let seed_nonce_revelation_tip c = - let constants = Raw_context.constants c in - constants.seed_nonce_revelation_tip - let origination_size c = let constants = Raw_context.constants c in constants.origination_size -let baking_reward_fixed_portion c = - let constants = Raw_context.constants c in - constants.baking_reward_fixed_portion - -let baking_reward_bonus_per_slot c = +let reward_weights c = let constants = Raw_context.constants c in - constants.baking_reward_bonus_per_slot - -let endorsing_reward_per_slot c = - let constants = Raw_context.constants c in - constants.endorsing_reward_per_slot + constants.reward_weights let quorum_min c = let constants = Raw_context.constants c in @@ -108,10 +96,6 @@ let min_proposal_quorum c = let constants = Raw_context.constants c in constants.min_proposal_quorum -let liquidity_baking_subsidy c = - let constants = Raw_context.constants c in - constants.liquidity_baking_subsidy - let liquidity_baking_toggle_ema_threshold c = let constants = Raw_context.constants c in constants.liquidity_baking_toggle_ema_threshold diff --git a/src/proto_alpha/lib_protocol/constants_storage.mli b/src/proto_alpha/lib_protocol/constants_storage.mli index 91860068b0d58a732d422ac6d5e26d653f36a61c..b899229650468056d4730fac3a4fc3c77d22e222 100644 --- a/src/proto_alpha/lib_protocol/constants_storage.mli +++ b/src/proto_alpha/lib_protocol/constants_storage.mli @@ -56,15 +56,9 @@ val minimal_stake : Raw_context.t -> Tez_repr.t val vdf_difficulty : Raw_context.t -> int64 -val seed_nonce_revelation_tip : Raw_context.t -> Tez_repr.t - val origination_size : Raw_context.t -> int -val baking_reward_fixed_portion : Raw_context.t -> Tez_repr.t - -val baking_reward_bonus_per_slot : Raw_context.t -> Tez_repr.t - -val endorsing_reward_per_slot : Raw_context.t -> Tez_repr.t +val reward_weights : Raw_context.t -> Constants_parametric_repr.reward_weights val quorum_min : Raw_context.t -> int32 @@ -72,8 +66,6 @@ val quorum_max : Raw_context.t -> int32 val min_proposal_quorum : Raw_context.t -> int32 -val liquidity_baking_subsidy : Raw_context.t -> Tez_repr.t - val liquidity_baking_toggle_ema_threshold : Raw_context.t -> int32 val parametric : Raw_context.t -> Constants_parametric_repr.t diff --git a/src/proto_alpha/lib_protocol/delegate_cycles.ml b/src/proto_alpha/lib_protocol/delegate_cycles.ml index dc4b26d3622b203d0f7b9ec0bb1f7d37072f3c80..ce7534e9a216cc0366ac069ef116b78b82761485 100644 --- a/src/proto_alpha/lib_protocol/delegate_cycles.ml +++ b/src/proto_alpha/lib_protocol/delegate_cycles.ml @@ -195,7 +195,7 @@ let delegate_has_revealed_nonces delegate unrevelead_nonces_set = let distribute_endorsing_rewards ctxt last_cycle unrevealed_nonces = let endorsing_reward_per_slot = - Constants_storage.endorsing_reward_per_slot ctxt + Delegate_rewards.endorsing_reward_per_slot ctxt in let unrevealed_nonces_set = List.fold_left diff --git a/src/proto_alpha/lib_protocol/delegate_missed_endorsements_storage.ml b/src/proto_alpha/lib_protocol/delegate_missed_endorsements_storage.ml index e9cd6c1a9991041d80c70d993fd625441db2a464..485cd3eed19392978be04805862eeb04e59cf414 100644 --- a/src/proto_alpha/lib_protocol/delegate_missed_endorsements_storage.ml +++ b/src/proto_alpha/lib_protocol/delegate_missed_endorsements_storage.ml @@ -186,7 +186,7 @@ let participation_info ctxt delegate = Constants_storage.minimal_participation_ratio ctxt in let endorsing_reward_per_slot = - Constants_storage.endorsing_reward_per_slot ctxt + Delegate_rewards.endorsing_reward_per_slot ctxt in let minimal_cycle_activity = expected_cycle_activity * numerator / denominator diff --git a/src/proto_alpha/lib_protocol/delegate_rewards.ml b/src/proto_alpha/lib_protocol/delegate_rewards.ml new file mode 100644 index 0000000000000000000000000000000000000000..7003053be4597ad11e0783dd4e8fefad780fd61f --- /dev/null +++ b/src/proto_alpha/lib_protocol/delegate_rewards.ml @@ -0,0 +1,128 @@ +(*****************************************************************************) +(* *) +(* 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. *) +(* *) +(*****************************************************************************) + +(* Sum weights for normalizing *) +let sum_weights (rewards : Constants_parametric_repr.reward_weights) = + let r = rewards.baking_reward_fixed_portion_weight in + let r = rewards.baking_reward_bonus_weight + r in + let r = rewards.endorsing_reward_weight + r in + let r = rewards.liquidity_baking_subsidy_weight + r in + let r = rewards.seed_nonce_revelation_tip_weight + r in + let r = rewards.vdf_revelation_tip_weight + r in + assert (Compare.Int.(r > 0)) ; + r + +(* [tez_from_weights] returns an amount of rewards in [Tez.t], + given a couple of parameters: + [rewards] describes all the possible rewards, as a record of weights + for each of them. It also gives the (maximum) amount of rewards per minute + expected on the chain + [weight] is one of those reward weights as described in [rewards] + [minimal_block_delay] is the minimum amouht of time between two blocks. *) +let tez_from_weights + ~(reward_weights : Constants_parametric_repr.reward_weights) ~(weight : int) + ~(minimal_block_delay : Period_repr.t) = + let sum_weights = sum_weights reward_weights in + let block_delay = + minimal_block_delay |> Period_repr.to_seconds |> Int64.to_int + in + let weighted_rewards_per_minute = + Tez_repr.mul_exn reward_weights.base_total_rewards_per_minute weight + in + let weighted_rewards_per_block = + Tez_repr.(div_exn (mul_exn weighted_rewards_per_minute block_delay) 60) + in + let normalized_rewards_per_block = + Tez_repr.div_exn weighted_rewards_per_block sum_weights + in + normalized_rewards_per_block + +module Internal_for_tests = struct + type reward_kind = + | Baking_reward_fixed_portion + | Baking_reward_bonus_per_slot + | Endorsing_reward_per_slot + | Liquidity_baking_subsidy + | Seed_nonce_revelation_tip + | Vdf_revelation_tip + + let reward_from_constants ~(csts : Constants_parametric_repr.t) ~reward_kind = + let reward_weights = csts.reward_weights in + let weight = + match reward_kind with + | Baking_reward_fixed_portion -> + reward_weights.baking_reward_fixed_portion_weight + | Baking_reward_bonus_per_slot -> + reward_weights.baking_reward_bonus_weight + | Endorsing_reward_per_slot -> reward_weights.endorsing_reward_weight + | Liquidity_baking_subsidy -> + reward_weights.liquidity_baking_subsidy_weight + | Seed_nonce_revelation_tip -> + (* Seed nonce revelation rewards are given every [blocks_per_commitment](=128)th block *) + let blocks_per_commitment = Int32.to_int csts.blocks_per_commitment in + reward_weights.seed_nonce_revelation_tip_weight + * blocks_per_commitment + | Vdf_revelation_tip -> + (* Vdf revelation rewards are given every [blocks_per_commitment](=128)th block *) + let blocks_per_commitment = Int32.to_int csts.blocks_per_commitment in + reward_weights.vdf_revelation_tip_weight * blocks_per_commitment + in + let minimal_block_delay = csts.minimal_block_delay in + let rewards = + tez_from_weights ~reward_weights ~weight ~minimal_block_delay + in + match reward_kind with + | Baking_reward_bonus_per_slot -> + let bonus_committee_size = + csts.consensus_committee_size - csts.consensus_threshold + in + if Compare.Int.(bonus_committee_size <= 0) then Tez_repr.zero + else Tez_repr.div_exn rewards bonus_committee_size + | Endorsing_reward_per_slot -> + Tez_repr.div_exn rewards csts.consensus_committee_size + | _ -> rewards +end + +open Internal_for_tests + +let reward_from_context ctxt reward_kind = + let csts = Raw_context.constants ctxt in + reward_from_constants ~csts ~reward_kind + +let baking_reward_fixed_portion c = + reward_from_context c Baking_reward_fixed_portion + +let baking_reward_bonus_per_slot c = + reward_from_context c Baking_reward_bonus_per_slot + +let endorsing_reward_per_slot c = + reward_from_context c Endorsing_reward_per_slot + +let liquidity_baking_subsidy c = reward_from_context c Liquidity_baking_subsidy + +let seed_nonce_revelation_tip c = + reward_from_context c Seed_nonce_revelation_tip + +let vdf_revelation_tip c = reward_from_context c Vdf_revelation_tip diff --git a/src/proto_alpha/lib_protocol/delegate_rewards.mli b/src/proto_alpha/lib_protocol/delegate_rewards.mli new file mode 100644 index 0000000000000000000000000000000000000000..0b6bc7572dec1bea52643d854ae3e138c784a8c3 --- /dev/null +++ b/src/proto_alpha/lib_protocol/delegate_rewards.mli @@ -0,0 +1,52 @@ +(*****************************************************************************) +(* *) +(* 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. *) +(* *) +(*****************************************************************************) + +(* These functions return the amount of tez rewarded for each action *) + +val baking_reward_fixed_portion : Raw_context.t -> Tez_repr.t + +val baking_reward_bonus_per_slot : Raw_context.t -> Tez_repr.t + +val endorsing_reward_per_slot : Raw_context.t -> Tez_repr.t + +val liquidity_baking_subsidy : Raw_context.t -> Tez_repr.t + +val seed_nonce_revelation_tip : Raw_context.t -> Tez_repr.t + +val vdf_revelation_tip : Raw_context.t -> Tez_repr.t + +(* For testing purposes *) +module Internal_for_tests : sig + type reward_kind = + | Baking_reward_fixed_portion + | Baking_reward_bonus_per_slot + | Endorsing_reward_per_slot + | Liquidity_baking_subsidy + | Seed_nonce_revelation_tip + | Vdf_revelation_tip + + val reward_from_constants : + csts:Constants_parametric_repr.t -> reward_kind:reward_kind -> Tez_repr.t +end diff --git a/src/proto_alpha/lib_protocol/dune b/src/proto_alpha/lib_protocol/dune index 19a717b6c27acdb4f8715ed1789304fa2f0c65b9..f67e2eb7ffb6e5dbd30711c25f25c4c228c2f9fd 100644 --- a/src/proto_alpha/lib_protocol/dune +++ b/src/proto_alpha/lib_protocol/dune @@ -175,6 +175,7 @@ Delegate_consensus_key Delegate_storage Delegate_sampler + Delegate_rewards Delegate_missed_endorsements_storage Delegate_slashed_deposits_storage Delegate_cycles @@ -454,6 +455,7 @@ delegate_consensus_key.ml delegate_consensus_key.mli delegate_storage.ml delegate_storage.mli delegate_sampler.ml delegate_sampler.mli + delegate_rewards.ml delegate_rewards.mli delegate_missed_endorsements_storage.ml delegate_missed_endorsements_storage.mli delegate_slashed_deposits_storage.ml delegate_slashed_deposits_storage.mli @@ -735,6 +737,7 @@ delegate_consensus_key.ml delegate_consensus_key.mli delegate_storage.ml delegate_storage.mli delegate_sampler.ml delegate_sampler.mli + delegate_rewards.ml delegate_rewards.mli delegate_missed_endorsements_storage.ml delegate_missed_endorsements_storage.mli delegate_slashed_deposits_storage.ml delegate_slashed_deposits_storage.mli @@ -1000,6 +1003,7 @@ delegate_consensus_key.ml delegate_consensus_key.mli delegate_storage.ml delegate_storage.mli delegate_sampler.ml delegate_sampler.mli + delegate_rewards.ml delegate_rewards.mli delegate_missed_endorsements_storage.ml delegate_missed_endorsements_storage.mli delegate_slashed_deposits_storage.ml delegate_slashed_deposits_storage.mli diff --git a/src/proto_alpha/lib_protocol/raw_context.ml b/src/proto_alpha/lib_protocol/raw_context.ml index f205f03a9e531bb1167726089950d899d4530427..76842f1bfefed02efdaf980c726f350773bbbbd9 100644 --- a/src/proto_alpha/lib_protocol/raw_context.ml +++ b/src/proto_alpha/lib_protocol/raw_context.ml @@ -972,7 +972,17 @@ let prepare_first_block ~level ~timestamp ctxt = min_pending_to_process = c.zk_rollup.min_pending_to_process; } in + let adaptive_inflation = Constants_parametric_repr.{enable = false} in + + let reward_weights = + let c_gen = + Constants_repr.Generated.generate + ~consensus_committee_size:c.consensus_committee_size + in + c_gen.reward_weights + in + let constants = Constants_parametric_repr. { @@ -987,19 +997,15 @@ let prepare_first_block ~level ~timestamp ctxt = proof_of_work_threshold = c.proof_of_work_threshold; minimal_stake = c.minimal_stake; vdf_difficulty = c.vdf_difficulty; - seed_nonce_revelation_tip = c.seed_nonce_revelation_tip; origination_size = c.origination_size; max_operations_time_to_live = c.max_operations_time_to_live; - baking_reward_fixed_portion = c.baking_reward_fixed_portion; - baking_reward_bonus_per_slot = c.baking_reward_bonus_per_slot; - endorsing_reward_per_slot = c.endorsing_reward_per_slot; + reward_weights; cost_per_byte = c.cost_per_byte; hard_storage_limit_per_operation = c.hard_storage_limit_per_operation; quorum_min = c.quorum_min; quorum_max = c.quorum_max; min_proposal_quorum = c.min_proposal_quorum; - liquidity_baking_subsidy = c.liquidity_baking_subsidy; liquidity_baking_toggle_ema_threshold = c.liquidity_baking_toggle_ema_threshold; minimal_block_delay = c.minimal_block_delay; diff --git a/src/proto_alpha/lib_protocol/test/helpers/block.ml b/src/proto_alpha/lib_protocol/test/helpers/block.ml index 25916e7445a423b776313a9565d35046ce6178f1..f4a27c7aaf6570fae59dea986484825152b14b2e 100644 --- a/src/proto_alpha/lib_protocol/test/helpers/block.ml +++ b/src/proto_alpha/lib_protocol/test/helpers/block.ml @@ -485,12 +485,10 @@ let validate_bootstrap_accounts (function Exit -> return_unit | exc -> raise exc) let prepare_initial_context_params ?consensus_threshold ?min_proposal_quorum - ?level ?cost_per_byte ?liquidity_baking_subsidy ?endorsing_reward_per_slot - ?baking_reward_bonus_per_slot ?baking_reward_fixed_portion ?origination_size - ?blocks_per_cycle ?cycles_per_voting_period ?sc_rollup_enable - ?sc_rollup_arith_pvm_enable ?dal_enable ?zk_rollup_enable - ?adaptive_inflation_enable ?hard_gas_limit_per_block - ?nonce_revelation_threshold () = + ?level ?cost_per_byte ?reward_weights ?origination_size ?blocks_per_cycle + ?cycles_per_voting_period ?sc_rollup_enable ?sc_rollup_arith_pvm_enable + ?dal_enable ?zk_rollup_enable ?adaptive_inflation_enable + ?hard_gas_limit_per_block ?nonce_revelation_threshold () = let open Tezos_protocol_alpha_parameters in let constants = Default_parameters.constants_test in let min_proposal_quorum = @@ -499,25 +497,8 @@ let prepare_initial_context_params ?consensus_threshold ?min_proposal_quorum let cost_per_byte = Option.value ~default:constants.cost_per_byte cost_per_byte in - let liquidity_baking_subsidy = - Option.value - ~default:constants.liquidity_baking_subsidy - liquidity_baking_subsidy - in - let endorsing_reward_per_slot = - Option.value - ~default:constants.endorsing_reward_per_slot - endorsing_reward_per_slot - in - let baking_reward_bonus_per_slot = - Option.value - ~default:constants.baking_reward_bonus_per_slot - baking_reward_bonus_per_slot - in - let baking_reward_fixed_portion = - Option.value - ~default:constants.baking_reward_fixed_portion - baking_reward_fixed_portion + let reward_weights = + Option.value ~default:constants.reward_weights reward_weights in let origination_size = Option.value ~default:constants.origination_size origination_size @@ -563,15 +544,12 @@ let prepare_initial_context_params ?consensus_threshold ?min_proposal_quorum let constants = { constants with - endorsing_reward_per_slot; - baking_reward_bonus_per_slot; - baking_reward_fixed_portion; + reward_weights; origination_size; blocks_per_cycle; cycles_per_voting_period; min_proposal_quorum; cost_per_byte; - liquidity_baking_subsidy; consensus_threshold; tx_rollup = constants.tx_rollup; sc_rollup = @@ -613,22 +591,18 @@ let prepare_initial_context_params ?consensus_threshold ?min_proposal_quorum (* if no parameter file is passed we check in the current directory where the test is run *) let genesis ?commitments ?consensus_threshold ?min_proposal_quorum - ?bootstrap_contracts ?level ?cost_per_byte ?liquidity_baking_subsidy - ?endorsing_reward_per_slot ?baking_reward_bonus_per_slot - ?baking_reward_fixed_portion ?origination_size ?blocks_per_cycle - ?cycles_per_voting_period ?sc_rollup_enable ?sc_rollup_arith_pvm_enable - ?dal_enable ?zk_rollup_enable ?hard_gas_limit_per_block - ?adaptive_inflation_enable ?nonce_revelation_threshold + ?bootstrap_contracts ?level ?cost_per_byte ?reward_weights ?origination_size + ?blocks_per_cycle ?cycles_per_voting_period ?sc_rollup_enable + ?sc_rollup_arith_pvm_enable ?dal_enable ?zk_rollup_enable + ?hard_gas_limit_per_block ?adaptive_inflation_enable + ?nonce_revelation_threshold (bootstrap_accounts : Parameters.bootstrap_account list) = prepare_initial_context_params ?consensus_threshold ?min_proposal_quorum ?level ?cost_per_byte - ?liquidity_baking_subsidy - ?endorsing_reward_per_slot - ?baking_reward_bonus_per_slot - ?baking_reward_fixed_portion + ?reward_weights ?origination_size ?blocks_per_cycle ?cycles_per_voting_period diff --git a/src/proto_alpha/lib_protocol/test/helpers/block.mli b/src/proto_alpha/lib_protocol/test/helpers/block.mli index 01249bfb2dffacc018ec3d1643edcc4462240bc2..cde54f39b43560dd8215b9c8afa3e1fa605be48e 100644 --- a/src/proto_alpha/lib_protocol/test/helpers/block.mli +++ b/src/proto_alpha/lib_protocol/test/helpers/block.mli @@ -126,10 +126,7 @@ val genesis : ?bootstrap_contracts:Parameters.bootstrap_contract list -> ?level:int32 -> ?cost_per_byte:Tez.t -> - ?liquidity_baking_subsidy:Tez.t -> - ?endorsing_reward_per_slot:Tez.t -> - ?baking_reward_bonus_per_slot:Tez.t -> - ?baking_reward_fixed_portion:Tez.t -> + ?reward_weights:Constants.Parametric.reward_weights -> ?origination_size:int -> ?blocks_per_cycle:int32 -> ?cycles_per_voting_period:int32 -> @@ -286,10 +283,7 @@ val prepare_initial_context_params : ?min_proposal_quorum:int32 -> ?level:int32 -> ?cost_per_byte:Tez.t -> - ?liquidity_baking_subsidy:Tez.t -> - ?endorsing_reward_per_slot:Tez.t -> - ?baking_reward_bonus_per_slot:Tez.t -> - ?baking_reward_fixed_portion:Tez.t -> + ?reward_weights:Constants.Parametric.reward_weights -> ?origination_size:int -> ?blocks_per_cycle:int32 -> ?cycles_per_voting_period:int32 -> diff --git a/src/proto_alpha/lib_protocol/test/helpers/context.ml b/src/proto_alpha/lib_protocol/test/helpers/context.ml index f77a8c04d7688518a6cfb8d5e8da9c5526824a30..c77778c99c0488381986ce6ffe1db22eff6b73e4 100644 --- a/src/proto_alpha/lib_protocol/test/helpers/context.ml +++ b/src/proto_alpha/lib_protocol/test/helpers/context.ml @@ -203,35 +203,58 @@ let default_test_constants = Tezos_protocol_alpha_parameters.Default_parameters.constants_test let get_baking_reward_fixed_portion ctxt = - get_constants ctxt - >>=? fun {Constants.parametric = {baking_reward_fixed_portion; _}; _} -> - return baking_reward_fixed_portion + get_constants ctxt >>=? fun {Constants.parametric = csts; _} -> + return + (Delegate.Rewards.Internal_for_tests.reward_from_constants + ~csts + ~reward_kind:Baking_reward_fixed_portion) let get_bonus_reward ctxt ~endorsing_power = get_constants ctxt - >>=? fun { - Constants.parametric = - {baking_reward_bonus_per_slot; consensus_threshold; _}; - _; - } -> + >>=? fun {Constants.parametric = {consensus_threshold; _} as csts; _} -> + let baking_reward_bonus_per_slot = + Delegate.Rewards.Internal_for_tests.reward_from_constants + ~csts + ~reward_kind:Baking_reward_bonus_per_slot + in let multiplier = max 0 (endorsing_power - consensus_threshold) in return Test_tez.(baking_reward_bonus_per_slot *! Int64.of_int multiplier) let get_endorsing_reward ctxt ~expected_endorsing_power = - get_constants ctxt - >>=? fun {Constants.parametric = {endorsing_reward_per_slot; _}; _} -> + get_constants ctxt >>=? fun {Constants.parametric = csts; _} -> + let endorsing_reward_per_slot = + Delegate.Rewards.Internal_for_tests.reward_from_constants + ~csts + ~reward_kind:Endorsing_reward_per_slot + in Lwt.return (Environment.wrap_tzresult Tez.(endorsing_reward_per_slot *? Int64.of_int expected_endorsing_power)) let get_liquidity_baking_subsidy ctxt = - get_constants ctxt - >>=? fun {Constants.parametric = {liquidity_baking_subsidy; _}; _} -> - return liquidity_baking_subsidy + get_constants ctxt >>=? fun {Constants.parametric = csts; _} -> + return + (Delegate.Rewards.Internal_for_tests.reward_from_constants + ~csts + ~reward_kind:Liquidity_baking_subsidy) let get_liquidity_baking_cpmm_address ctxt = Alpha_services.Liquidity_baking.get_cpmm_address rpc_ctxt ctxt +let get_seed_nonce_revelation_tip ctxt = + get_constants ctxt >>=? fun {Constants.parametric = csts; _} -> + return + (Delegate.Rewards.Internal_for_tests.reward_from_constants + ~csts + ~reward_kind:Seed_nonce_revelation_tip) + +let get_vdf_revelation_tip ctxt = + get_constants ctxt >>=? fun {Constants.parametric = csts; _} -> + return + (Delegate.Rewards.Internal_for_tests.reward_from_constants + ~csts + ~reward_kind:Vdf_revelation_tip) + (* Voting *) module Vote = struct @@ -459,12 +482,10 @@ let tup_get : type a r. (a, r) tup -> a list -> r = let init_gen tup ?rng_state ?commitments ?bootstrap_balances ?bootstrap_delegations ?bootstrap_consensus_keys ?consensus_threshold ?min_proposal_quorum ?bootstrap_contracts ?level ?cost_per_byte - ?liquidity_baking_subsidy ?endorsing_reward_per_slot - ?baking_reward_bonus_per_slot ?baking_reward_fixed_portion ?origination_size - ?blocks_per_cycle ?cycles_per_voting_period ?sc_rollup_enable - ?sc_rollup_arith_pvm_enable ?dal_enable ?zk_rollup_enable - ?adaptive_inflation_enable ?hard_gas_limit_per_block - ?nonce_revelation_threshold () = + ?reward_weights ?origination_size ?blocks_per_cycle + ?cycles_per_voting_period ?sc_rollup_enable ?sc_rollup_arith_pvm_enable + ?dal_enable ?zk_rollup_enable ?adaptive_inflation_enable + ?hard_gas_limit_per_block ?nonce_revelation_threshold () = let n = tup_n tup in Account.generate_accounts ?rng_state n >>?= fun accounts -> let contracts = @@ -484,10 +505,7 @@ let init_gen tup ?rng_state ?commitments ?bootstrap_balances ?bootstrap_contracts ?level ?cost_per_byte - ?liquidity_baking_subsidy - ?endorsing_reward_per_slot - ?baking_reward_bonus_per_slot - ?baking_reward_fixed_portion + ?reward_weights ?origination_size ?blocks_per_cycle ?cycles_per_voting_period diff --git a/src/proto_alpha/lib_protocol/test/helpers/context.mli b/src/proto_alpha/lib_protocol/test/helpers/context.mli index 8002408d5eee09f779c677e2ca9963b6397cd29f..3870687f838e5a4565aee51ac1df2e77837fb4c9 100644 --- a/src/proto_alpha/lib_protocol/test/helpers/context.mli +++ b/src/proto_alpha/lib_protocol/test/helpers/context.mli @@ -108,6 +108,10 @@ 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_seed_nonce_revelation_tip : t -> Tez.t tzresult Lwt.t + +val get_vdf_revelation_tip : t -> Tez.t tzresult Lwt.t + module Vote : sig val get_ballots : t -> Vote.ballots tzresult Lwt.t @@ -270,10 +274,7 @@ type 'accounts init := ?bootstrap_contracts:Parameters.bootstrap_contract list -> ?level:int32 -> ?cost_per_byte:Tez.t -> - ?liquidity_baking_subsidy:Tez.t -> - ?endorsing_reward_per_slot:Tez.t -> - ?baking_reward_bonus_per_slot:Tez.t -> - ?baking_reward_fixed_portion:Tez.t -> + ?reward_weights:Constants.Parametric.reward_weights -> ?origination_size:int -> ?blocks_per_cycle:int32 -> ?cycles_per_voting_period:int32 -> diff --git a/src/proto_alpha/lib_protocol/test/helpers/liquidity_baking_machine.ml b/src/proto_alpha/lib_protocol/test/helpers/liquidity_baking_machine.ml index c0feb9d7e5ab1514bb61e17efea8befb44e67ab2..b14304a68500bd0a63a0d2479cca6aa44cc5c57d 100644 --- a/src/proto_alpha/lib_protocol/test/helpers/liquidity_baking_machine.ml +++ b/src/proto_alpha/lib_protocol/test/helpers/liquidity_baking_machine.ml @@ -379,7 +379,11 @@ end let default_subsidy = let open Tezos_protocol_alpha_parameters in - Tez.to_mutez @@ Default_parameters.constants_test.liquidity_baking_subsidy + let c = Default_parameters.constants_test in + Tez.to_mutez + @@ Delegate.Rewards.Internal_for_tests.reward_from_constants + ~csts:c + ~reward_kind:Liquidity_baking_subsidy let security_deposit = 640_000_000L @@ -853,20 +857,35 @@ module ConcreteBaseMachine : bake ~invariant ~baker:env.holder [op2] env state let init ~invariant ?subsidy accounts_balances = - let liquidity_baking_subsidy = Option.map Tez.of_mutez_exn subsidy in + let liquidity_baking_subsidy = + Option.value ~default:default_subsidy subsidy |> Tez.of_mutez_exn + in + let block_delay = + Period.to_seconds + Tezos_protocol_alpha_parameters.Default_parameters.constants_test + .minimal_block_delay + |> Int64.to_int + in let n, bootstrap_balances = initial_xtz_repartition accounts_balances in Context.init_n n ~consensus_threshold:0 ~bootstrap_balances ~cost_per_byte:Tez.zero - ~endorsing_reward_per_slot:Tez.zero - ~baking_reward_bonus_per_slot:Tez.zero - ~baking_reward_fixed_portion:Tez.zero + ~reward_weights: + { + base_total_rewards_per_minute = + Tez.(div_exn (mul_exn liquidity_baking_subsidy 60) block_delay); + endorsing_reward_weight = 0; + baking_reward_fixed_portion_weight = 0; + baking_reward_bonus_weight = 0; + seed_nonce_revelation_tip_weight = 0; + vdf_revelation_tip_weight = 0; + liquidity_baking_subsidy_weight = 1; + } ~origination_size:0 ~blocks_per_cycle:10_000l ~cycles_per_voting_period:1l - ?liquidity_baking_subsidy () >>= function | blk, holder :: accounts -> 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 02a41c865a12bb26c7d32b1b7505243e994e0e1e..488a91f314cd980f72ca62ab63b67c3faf8d6c45 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 @@ -311,8 +311,8 @@ let test_enough_active_stake_to_bake ~has_active_stake () = () >>=? fun (b0, (account1, _account2)) -> let pkh1 = Context.Contract.pkh account1 in - Context.get_constants (B b0) - >>=? fun Constants.{parametric = {baking_reward_fixed_portion; _}; _} -> + Context.get_baking_reward_fixed_portion (B b0) + >>=? fun baking_reward_fixed_portion -> Block.bake ~policy:(By_account pkh1) b0 >>= fun b1 -> if has_active_stake then b1 >>?= fun b1 -> diff --git a/src/proto_alpha/lib_protocol/test/integration/consensus/test_consensus_key.ml b/src/proto_alpha/lib_protocol/test/integration/consensus/test_consensus_key.ml index 0c89d84b30be6ef186925d2e00112503260ca680..510be2e88f9706c473a206a2174063824dc562ce 100644 --- a/src/proto_alpha/lib_protocol/test/integration/consensus/test_consensus_key.ml +++ b/src/proto_alpha/lib_protocol/test/integration/consensus/test_consensus_key.ml @@ -37,9 +37,11 @@ open Alpha_context let constants = { Default_parameters.constants_test with - endorsing_reward_per_slot = Tez.zero; - baking_reward_bonus_per_slot = Tez.zero; - baking_reward_fixed_portion = Tez.zero; + reward_weights = + { + Default_parameters.constants_test.reward_weights with + base_total_rewards_per_minute = Tez.zero; + }; consensus_threshold = 0; origination_size = 0; } diff --git a/src/proto_alpha/lib_protocol/test/integration/consensus/test_double_baking.ml b/src/proto_alpha/lib_protocol/test/integration/consensus/test_double_baking.ml index 83222fafe1d609159f46339aea23a1661f26997c..c9047155bb616e409e4591cf41495f9d98f15427 100644 --- a/src/proto_alpha/lib_protocol/test/integration/consensus/test_double_baking.ml +++ b/src/proto_alpha/lib_protocol/test/integration/consensus/test_double_baking.ml @@ -205,12 +205,9 @@ let test_valid_double_endorsing_followed_by_double_baking () = let test_payload_producer_gets_evidence_rewards () = Context.init_n ~consensus_threshold:0 10 () >>=? fun (genesis, contracts) -> Context.get_constants (B genesis) - >>=? fun Constants. - { - parametric = - {double_baking_punishment; baking_reward_fixed_portion; _}; - _; - } -> + >>=? fun Constants.{parametric = {double_baking_punishment; _}; _} -> + Context.get_baking_reward_fixed_portion (B genesis) + >>=? fun baking_reward_fixed_portion -> Context.get_first_different_bakers (B genesis) >>=? fun (baker1, baker2) -> let c1_c2 = match contracts with c1 :: c2 :: _ -> (c1, c2) | _ -> assert false diff --git a/src/proto_alpha/lib_protocol/test/integration/consensus/test_double_endorsement.ml b/src/proto_alpha/lib_protocol/test/integration/consensus/test_double_endorsement.ml index 5bad9e140bece651fb67052a88ad9cb61e23ee4f..06378385be48b124c512444792f1468916e05878 100644 --- a/src/proto_alpha/lib_protocol/test/integration/consensus/test_double_endorsement.ml +++ b/src/proto_alpha/lib_protocol/test/integration/consensus/test_double_endorsement.ml @@ -121,7 +121,11 @@ let test_valid_double_endorsement_evidence () = (* Check that [baker] is rewarded with: - baking_reward_fixed_portion for baking and, - half of the frozen_deposits for including the evidence *) - let baking_reward = csts.parametric.baking_reward_fixed_portion in + let baking_reward = + Delegate.Rewards.Internal_for_tests.reward_from_constants + ~csts:csts.parametric + ~reward_kind:Baking_reward_fixed_portion + in let evidence_reward = Test_tez.(frozen_deposits_after /! 2L) in let expected_reward = Test_tez.(baking_reward +! evidence_reward) in Context.Delegate.full_balance (B blk_final) baker @@ -380,9 +384,11 @@ let test_freeze_more_with_low_balance = let constants = { Default_parameters.constants_test with - endorsing_reward_per_slot = Tez.zero; - baking_reward_bonus_per_slot = Tez.zero; - baking_reward_fixed_portion = Tez.zero; + reward_weights = + { + Default_parameters.constants_test.reward_weights with + base_total_rewards_per_minute = Tez.zero; + }; consensus_threshold = 0; origination_size = 0; preserved_cycles = 5; diff --git a/src/proto_alpha/lib_protocol/test/integration/consensus/test_frozen_deposits.ml b/src/proto_alpha/lib_protocol/test/integration/consensus/test_frozen_deposits.ml index 302e2398530d83a5b2a20f004ad9a0638fe706c4..5aa53afbf910f7a669f89bac3e1ceb76ffd843b1 100644 --- a/src/proto_alpha/lib_protocol/test/integration/consensus/test_frozen_deposits.ml +++ b/src/proto_alpha/lib_protocol/test/integration/consensus/test_frozen_deposits.ml @@ -38,9 +38,11 @@ open Test_tez let constants = { Default_parameters.constants_test with - endorsing_reward_per_slot = Tez.zero; - baking_reward_bonus_per_slot = Tez.zero; - baking_reward_fixed_portion = Tez.zero; + reward_weights = + { + Default_parameters.constants_test.reward_weights with + base_total_rewards_per_minute = Tez.zero; + }; consensus_threshold = 0; origination_size = 0; } diff --git a/src/proto_alpha/lib_protocol/test/integration/consensus/test_participation.ml b/src/proto_alpha/lib_protocol/test/integration/consensus/test_participation.ml index b01e0c0d3b210d8d8f383ccb2b22e41ac50221f2..de442a1be1d84e5614d4fb0de0c72ba29dbd91a1 100644 --- a/src/proto_alpha/lib_protocol/test/integration/consensus/test_participation.ml +++ b/src/proto_alpha/lib_protocol/test/integration/consensus/test_participation.ml @@ -137,10 +137,13 @@ let test_participation_rpc () = expected_cycle_activity * numerator / denominator in let allowed_missed_slots = expected_cycle_activity - minimal_cycle_activity in + let endorsing_reward_per_slot = + Alpha_context.Delegate.Rewards.Internal_for_tests.reward_from_constants + ~csts:csts.parametric + ~reward_kind:Endorsing_reward_per_slot + in let expected_endorsing_rewards = - Tez.mul_exn - csts.parametric.endorsing_reward_per_slot - expected_cycle_activity + Tez.mul_exn endorsing_reward_per_slot expected_cycle_activity in Block.bake ~policy:(By_account del1) b0 >>=? fun b1 -> List.fold_left_es diff --git a/src/proto_alpha/lib_protocol/test/integration/consensus/test_seed.ml b/src/proto_alpha/lib_protocol/test/integration/consensus/test_seed.ml index 37c428c24dc53be12cfe61bdc0650fb39a48a5b6..a3662ec9881bad1cb1b2e386eccc80f6bbce185c 100644 --- a/src/proto_alpha/lib_protocol/test/integration/consensus/test_seed.ml +++ b/src/proto_alpha/lib_protocol/test/integration/consensus/test_seed.ml @@ -126,12 +126,12 @@ let test_revelation_early_wrong_right_twice () = let open Assert in let* b, _contracts = Context.init_n ~consensus_threshold:0 5 () in let* csts = Context.get_constants (B b) in - let tip = csts.parametric.seed_nonce_revelation_tip in + let* tip = Context.get_seed_nonce_revelation_tip (B b) in let blocks_per_commitment = Int32.to_int csts.parametric.blocks_per_commitment in - let baking_reward_fixed_portion = - csts.parametric.baking_reward_fixed_portion + let* baking_reward_fixed_portion = + Context.get_baking_reward_fixed_portion (B b) in (* get the pkh of a baker *) let* pkh, _, _, _ = Block.get_next_baker b in @@ -287,10 +287,16 @@ let test_unrevealed () = let constants = { Default_parameters.constants_test with - endorsing_reward_per_slot = Tez.one_mutez; - baking_reward_bonus_per_slot = Tez.zero; - baking_reward_fixed_portion = Tez.zero; - seed_nonce_revelation_tip = Tez.zero; + reward_weights = + { + base_total_rewards_per_minute = Tez.one; + endorsing_reward_weight = 1; + baking_reward_bonus_weight = 0; + baking_reward_fixed_portion_weight = 0; + seed_nonce_revelation_tip_weight = 0; + vdf_revelation_tip_weight = 0; + liquidity_baking_subsidy_weight = 0; + }; consensus_threshold = 0; minimal_participation_ratio = Ratio.{numerator = 0; denominator = 1}; } @@ -372,11 +378,13 @@ let test_early_incorrect_unverified_correct_already_vdf () = let nonce_revelation_threshold = Int32.to_int csts.parametric.nonce_revelation_threshold in - let baking_reward_fixed_portion = - csts.parametric.baking_reward_fixed_portion + let* baking_reward_fixed_portion = + Context.get_baking_reward_fixed_portion (B b) in - let seed_nonce_revelation_tip = csts.parametric.seed_nonce_revelation_tip in - let vdf_nonce_revelation_tip = csts.parametric.seed_nonce_revelation_tip in + let* seed_nonce_revelation_tip = + Context.get_seed_nonce_revelation_tip (B b) + in + let* vdf_nonce_revelation_tip = Context.get_vdf_revelation_tip (B b) in (* get the pkh of a baker *) let* pkh, _, _, _ = Block.get_next_baker b in let id = Alpha_context.Contract.Implicit pkh in diff --git a/src/proto_alpha/lib_protocol/test/integration/operations/test_voting.ml b/src/proto_alpha/lib_protocol/test/integration/operations/test_voting.ml index 91ff5d0be2df7996b214207b55c7b9da8d6db7ee..810870c7a5b88416f1aac2a20a9ccdf2fb0a67b6 100644 --- a/src/proto_alpha/lib_protocol/test/integration/operations/test_voting.ml +++ b/src/proto_alpha/lib_protocol/test/integration/operations/test_voting.ml @@ -259,9 +259,16 @@ let context_init_tup tup ?(blocks_per_cycle = 4l) = ~blocks_per_cycle ~cycles_per_voting_period:1l ~consensus_threshold:0 - ~endorsing_reward_per_slot:Tez.zero - ~baking_reward_bonus_per_slot:Tez.zero - ~baking_reward_fixed_portion:Tez.zero + ~reward_weights: + { + base_total_rewards_per_minute = Tez.zero; + endorsing_reward_weight = 1; + baking_reward_bonus_weight = 1; + baking_reward_fixed_portion_weight = 1; + seed_nonce_revelation_tip_weight = 1; + vdf_revelation_tip_weight = 1; + liquidity_baking_subsidy_weight = 1; + } ~nonce_revelation_threshold:2l (** [context_init n ()] returns [(block, contracts)] where [block] is diff --git a/src/proto_alpha/lib_protocol/test/integration/test_constants.ml b/src/proto_alpha/lib_protocol/test/integration/test_constants.ml index 994de8af62df53779ba31ea651b6c09ba7c4b66d..9330d0d50b7e2407cfe7c456cd4f92eb278d6b64 100644 --- a/src/proto_alpha/lib_protocol/test/integration/test_constants.ml +++ b/src/proto_alpha/lib_protocol/test/integration/test_constants.ml @@ -178,17 +178,32 @@ let test_sc_rollup_max_commitment_storage_size () = 1/16th of the maximum reward. *) let liquidity_baking_subsidy_param () = let constants = Default_parameters.constants_mainnet in - constants.baking_reward_bonus_per_slot + let get_reward = + Protocol.Alpha_context.Delegate.Rewards.Internal_for_tests + .reward_from_constants + ~csts:constants + in + let baking_reward_bonus_per_slot = + get_reward ~reward_kind:Baking_reward_bonus_per_slot + in + baking_reward_bonus_per_slot *? Int64.of_int (constants.consensus_committee_size / 3) >>?= fun baking_reward_bonus -> - constants.baking_reward_fixed_portion +? baking_reward_bonus - >>?= fun baking_rewards -> - constants.endorsing_reward_per_slot - *? Int64.of_int constants.consensus_committee_size + let baking_reward_fixed_portion = + get_reward ~reward_kind:Baking_reward_fixed_portion + in + baking_reward_fixed_portion +? baking_reward_bonus >>?= fun baking_rewards -> + let endorsing_reward_per_slot = + get_reward ~reward_kind:Endorsing_reward_per_slot + in + endorsing_reward_per_slot *? Int64.of_int constants.consensus_committee_size >>?= fun validators_rewards -> baking_rewards +? validators_rewards >>?= fun total_rewards -> total_rewards /? 16L >>?= fun expected_subsidy -> - constants.liquidity_baking_subsidy -? expected_subsidy >>?= fun diff -> + let liquidity_baking_subsidy = + get_reward ~reward_kind:Liquidity_baking_subsidy + in + liquidity_baking_subsidy -? expected_subsidy >>?= fun diff -> let max_diff = 1000 (* mutez *) in Assert.leq_int ~loc:__LOC__ (Int64.to_int (to_mutez diff)) max_diff diff --git a/src/proto_alpha/lib_protocol/test/integration/test_liquidity_baking.ml b/src/proto_alpha/lib_protocol/test/integration/test_liquidity_baking.ml index 248429335df3fa2fdbd301701001606e74f6340d..c779a10d5adaaca874ae28cc3593c4c3815917d2 100644 --- a/src/proto_alpha/lib_protocol/test/integration/test_liquidity_baking.ml +++ b/src/proto_alpha/lib_protocol/test/integration/test_liquidity_baking.ml @@ -293,8 +293,7 @@ let liquidity_baking_storage n () = let liquidity_baking_balance_update () = Context.init1 ~consensus_threshold:0 () >>=? fun (blk, _contract) -> Context.get_liquidity_baking_cpmm_address (B blk) >>=? fun liquidity_baking -> - Context.get_constants (B blk) >>=? fun csts -> - let subsidy = csts.parametric.liquidity_baking_subsidy in + Context.get_liquidity_baking_subsidy (B blk) >>=? fun subsidy -> Block.bake_n_with_all_balance_updates 128 blk >>=? fun (_blk, balance_updates) -> let liquidity_baking_updates = 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 e0345171d5ab61404d39d677b31977fbd2f052f6..61d1ec9e73f79f535d3f355640040c5cbe06e57d 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 @@ -15,13 +15,15 @@ "hard_gas_limit_per_block": "2600000", "proof_of_work_threshold": "4611686018427387903", "minimal_stake": "6000000000", "vdf_difficulty": "50000", - "seed_nonce_revelation_tip": "125000", "origination_size": 257, - "baking_reward_fixed_portion": "333333", - "baking_reward_bonus_per_slot": "3921", - "endorsing_reward_per_slot": "2604", "cost_per_byte": "250", - "hard_storage_limit_per_operation": "60000", "quorum_min": 2000, - "quorum_max": 7000, "min_proposal_quorum": 500, - "liquidity_baking_subsidy": "83333", + "origination_size": 257, + "reward_weights": + { "base_index_of_total_rewards_per_minute": "85007812", + "baking_reward_fixed_weight": 5120, "baking_reward_bonus_weight": 5120, + "endorsing_reward_weight": 10240, + "liquidity_baking_subsidy_weight": 1280, + "nonce_revelation_tip_weight": 1, "vdf_revelation_tip_weight": 1 }, + "cost_per_byte": "250", "hard_storage_limit_per_operation": "60000", + "quorum_min": 2000, "quorum_max": 7000, "min_proposal_quorum": 500, "liquidity_baking_toggle_ema_threshold": 1000000000, "max_operations_time_to_live": 240, "minimal_block_delay": "1", "delay_increment_per_round": "1", "consensus_committee_size": 256, diff --git a/tezt/tests/expected/RPC_test.ml/Alpha- (mode client) RPC regression tests- votes.out b/tezt/tests/expected/RPC_test.ml/Alpha- (mode client) RPC regression tests- votes.out index 7a6be820083aabbe74703acc153e889e34ab2548..aceb75eb281b7565ecb06fb9af9fd16e97505d7a 100644 --- a/tezt/tests/expected/RPC_test.ml/Alpha- (mode client) RPC regression tests- votes.out +++ b/tezt/tests/expected/RPC_test.ml/Alpha- (mode client) RPC regression tests- votes.out @@ -43,7 +43,7 @@ null { "pkh": "[PUBLIC_KEY_HASH]", "ballot": "yay" } ] ./octez-client rpc get /chains/main/blocks/head/votes/ballots -{ "yay": "4000001978209", "nay": "4000000000000", "pass": "4000000000000" } +{ "yay": "4000001679643", "nay": "4000000000000", "pass": "4000000000000" } ./octez-client rpc get /chains/main/blocks/head/votes/current_period { "voting_period": { "index": 1, "kind": "exploration", "start_position": 4 }, @@ -65,7 +65,7 @@ null { "pkh": "[PUBLIC_KEY_HASH]", "voting_power": "4000000000000" }, { "pkh": "[PUBLIC_KEY_HASH]", - "voting_power": "4000001978209" } ] + "voting_power": "4000001679643" } ] ./octez-client rpc get /chains/main/blocks/head/votes/proposals [] @@ -75,4 +75,4 @@ null "position": 1, "remaining": 2 } ./octez-client rpc get /chains/main/blocks/head/votes/total_voting_power -"20000001978209" +"20000001679643" 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 fd9894fe36906ac36606c431302e879d5ee461d2..15abaf5fa647d42beba733f2b110d6dcdf98b6f9 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 @@ -15,13 +15,15 @@ "hard_gas_limit_per_block": "2600000", "proof_of_work_threshold": "4611686018427387903", "minimal_stake": "6000000000", "vdf_difficulty": "50000", - "seed_nonce_revelation_tip": "125000", "origination_size": 257, - "baking_reward_fixed_portion": "333333", - "baking_reward_bonus_per_slot": "3921", - "endorsing_reward_per_slot": "2604", "cost_per_byte": "250", - "hard_storage_limit_per_operation": "60000", "quorum_min": 2000, - "quorum_max": 7000, "min_proposal_quorum": 500, - "liquidity_baking_subsidy": "83333", + "origination_size": 257, + "reward_weights": + { "base_index_of_total_rewards_per_minute": "85007812", + "baking_reward_fixed_weight": 5120, "baking_reward_bonus_weight": 5120, + "endorsing_reward_weight": 10240, + "liquidity_baking_subsidy_weight": 1280, + "nonce_revelation_tip_weight": 1, "vdf_revelation_tip_weight": 1 }, + "cost_per_byte": "250", "hard_storage_limit_per_operation": "60000", + "quorum_min": 2000, "quorum_max": 7000, "min_proposal_quorum": 500, "liquidity_baking_toggle_ema_threshold": 1000000000, "max_operations_time_to_live": 240, "minimal_block_delay": "1", "delay_increment_per_round": "1", "consensus_committee_size": 256, diff --git a/tezt/tests/expected/RPC_test.ml/Alpha- (mode light) RPC regression tests- votes.out b/tezt/tests/expected/RPC_test.ml/Alpha- (mode light) RPC regression tests- votes.out index ed1465430a6d47ecfcd4b17bd84295d5fbfa7872..8baa3dc263188b5593965cdc11cab0961ef74cc1 100644 --- a/tezt/tests/expected/RPC_test.ml/Alpha- (mode light) RPC regression tests- votes.out +++ b/tezt/tests/expected/RPC_test.ml/Alpha- (mode light) RPC regression tests- votes.out @@ -43,7 +43,7 @@ null { "pkh": "[PUBLIC_KEY_HASH]", "ballot": "yay" } ] ./octez-client --mode light rpc get /chains/main/blocks/head/votes/ballots -{ "yay": "4000001978209", "nay": "4000000000000", "pass": "4000000000000" } +{ "yay": "4000001679643", "nay": "4000000000000", "pass": "4000000000000" } ./octez-client --mode light rpc get /chains/main/blocks/head/votes/current_period { "voting_period": { "index": 1, "kind": "exploration", "start_position": 4 }, @@ -65,7 +65,7 @@ null { "pkh": "[PUBLIC_KEY_HASH]", "voting_power": "4000000000000" }, { "pkh": "[PUBLIC_KEY_HASH]", - "voting_power": "4000001978209" } ] + "voting_power": "4000001679643" } ] ./octez-client --mode light rpc get /chains/main/blocks/head/votes/proposals [] @@ -75,4 +75,4 @@ null "position": 1, "remaining": 2 } ./octez-client --mode light rpc get /chains/main/blocks/head/votes/total_voting_power -"20000001978209" +"20000001679643" 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 a25dda5e86d00c333058b1f8b9eb036ea0b96d0b..14e7afae7cb5298df7eae856b03c171e24b78b9b 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 @@ -15,13 +15,15 @@ "hard_gas_limit_per_block": "2600000", "proof_of_work_threshold": "4611686018427387903", "minimal_stake": "6000000000", "vdf_difficulty": "50000", - "seed_nonce_revelation_tip": "125000", "origination_size": 257, - "baking_reward_fixed_portion": "333333", - "baking_reward_bonus_per_slot": "3921", - "endorsing_reward_per_slot": "2604", "cost_per_byte": "250", - "hard_storage_limit_per_operation": "60000", "quorum_min": 2000, - "quorum_max": 7000, "min_proposal_quorum": 500, - "liquidity_baking_subsidy": "83333", + "origination_size": 257, + "reward_weights": + { "base_index_of_total_rewards_per_minute": "85007812", + "baking_reward_fixed_weight": 5120, "baking_reward_bonus_weight": 5120, + "endorsing_reward_weight": 10240, + "liquidity_baking_subsidy_weight": 1280, + "nonce_revelation_tip_weight": 1, "vdf_revelation_tip_weight": 1 }, + "cost_per_byte": "250", "hard_storage_limit_per_operation": "60000", + "quorum_min": 2000, "quorum_max": 7000, "min_proposal_quorum": 500, "liquidity_baking_toggle_ema_threshold": 1000000000, "max_operations_time_to_live": 240, "minimal_block_delay": "1", "delay_increment_per_round": "1", "consensus_committee_size": 256, diff --git a/tezt/tests/expected/RPC_test.ml/Alpha- (mode proxy) RPC regression tests- votes.out b/tezt/tests/expected/RPC_test.ml/Alpha- (mode proxy) RPC regression tests- votes.out index 3ad2df9346049beaf9f572699e055fc21ca28d7c..1bf5d004e2814659860c1ee4a48a8baf08d0760a 100644 --- a/tezt/tests/expected/RPC_test.ml/Alpha- (mode proxy) RPC regression tests- votes.out +++ b/tezt/tests/expected/RPC_test.ml/Alpha- (mode proxy) RPC regression tests- votes.out @@ -43,7 +43,7 @@ null { "pkh": "[PUBLIC_KEY_HASH]", "ballot": "yay" } ] ./octez-client --mode proxy rpc get /chains/main/blocks/head/votes/ballots -{ "yay": "4000001978209", "nay": "4000000000000", "pass": "4000000000000" } +{ "yay": "4000001679643", "nay": "4000000000000", "pass": "4000000000000" } ./octez-client --mode proxy rpc get /chains/main/blocks/head/votes/current_period { "voting_period": { "index": 1, "kind": "exploration", "start_position": 4 }, @@ -65,7 +65,7 @@ null { "pkh": "[PUBLIC_KEY_HASH]", "voting_power": "4000000000000" }, { "pkh": "[PUBLIC_KEY_HASH]", - "voting_power": "4000001978209" } ] + "voting_power": "4000001679643" } ] ./octez-client --mode proxy rpc get /chains/main/blocks/head/votes/proposals [] @@ -75,4 +75,4 @@ null "position": 1, "remaining": 2 } ./octez-client --mode proxy rpc get /chains/main/blocks/head/votes/total_voting_power -"20000001978209" +"20000001679643" diff --git a/tezt/tests/expected/RPC_test.ml/Alpha- (mode proxy_server_data_dir) RPC regression tests- misc_protocol.out b/tezt/tests/expected/RPC_test.ml/Alpha- (mode proxy_server_data_dir) RPC regression tests- misc_protocol.out index f854ccb5c8d9089dc8518734052933d0bf582821..d9e54bf6b1c437807edb55defbf2577ca42fcc5b 100644 --- a/tezt/tests/expected/RPC_test.ml/Alpha- (mode proxy_server_data_dir) RPC regression tests- misc_protocol.out +++ b/tezt/tests/expected/RPC_test.ml/Alpha- (mode proxy_server_data_dir) RPC regression tests- misc_protocol.out @@ -15,13 +15,15 @@ "hard_gas_limit_per_block": "2600000", "proof_of_work_threshold": "4611686018427387903", "minimal_stake": "6000000000", "vdf_difficulty": "50000", - "seed_nonce_revelation_tip": "125000", "origination_size": 257, - "baking_reward_fixed_portion": "333333", - "baking_reward_bonus_per_slot": "3921", - "endorsing_reward_per_slot": "2604", "cost_per_byte": "250", - "hard_storage_limit_per_operation": "60000", "quorum_min": 2000, - "quorum_max": 7000, "min_proposal_quorum": 500, - "liquidity_baking_subsidy": "83333", + "origination_size": 257, + "reward_weights": + { "base_index_of_total_rewards_per_minute": "85007812", + "baking_reward_fixed_weight": 5120, "baking_reward_bonus_weight": 5120, + "endorsing_reward_weight": 10240, + "liquidity_baking_subsidy_weight": 1280, + "nonce_revelation_tip_weight": 1, "vdf_revelation_tip_weight": 1 }, + "cost_per_byte": "250", "hard_storage_limit_per_operation": "60000", + "quorum_min": 2000, "quorum_max": 7000, "min_proposal_quorum": 500, "liquidity_baking_toggle_ema_threshold": 1000000000, "max_operations_time_to_live": 240, "minimal_block_delay": "1", "delay_increment_per_round": "1", "consensus_committee_size": 256, diff --git a/tezt/tests/expected/RPC_test.ml/Alpha- (mode proxy_server_data_dir) RPC regression tests- votes.out b/tezt/tests/expected/RPC_test.ml/Alpha- (mode proxy_server_data_dir) RPC regression tests- votes.out index 8c859f49f493e782f9a23c4cb651162ca4edf574..92b45913298ab40ace37da5ad42cf7f5dd881f91 100644 --- a/tezt/tests/expected/RPC_test.ml/Alpha- (mode proxy_server_data_dir) RPC regression tests- votes.out +++ b/tezt/tests/expected/RPC_test.ml/Alpha- (mode proxy_server_data_dir) RPC regression tests- votes.out @@ -43,7 +43,7 @@ null { "pkh": "[PUBLIC_KEY_HASH]", "ballot": "yay" } ] ./octez-client rpc get /chains/main/blocks/head/votes/ballots -{ "yay": "4000001978209", "nay": "4000000000000", "pass": "4000000000000" } +{ "yay": "4000001679643", "nay": "4000000000000", "pass": "4000000000000" } ./octez-client rpc get /chains/main/blocks/head/votes/current_period { "voting_period": { "index": 1, "kind": "exploration", "start_position": 4 }, @@ -65,7 +65,7 @@ null { "pkh": "[PUBLIC_KEY_HASH]", "voting_power": "4000000000000" }, { "pkh": "[PUBLIC_KEY_HASH]", - "voting_power": "4000001978209" } ] + "voting_power": "4000001679643" } ] ./octez-client rpc get /chains/main/blocks/head/votes/proposals [] @@ -75,4 +75,4 @@ null "position": 2, "remaining": 1 } ./octez-client rpc get /chains/main/blocks/head/votes/total_voting_power -"20000001978209" +"20000001679643" diff --git a/tezt/tests/expected/RPC_test.ml/Alpha- (mode proxy_server_rpc) RPC regression tests- misc_protocol.out b/tezt/tests/expected/RPC_test.ml/Alpha- (mode proxy_server_rpc) RPC regression tests- misc_protocol.out index f854ccb5c8d9089dc8518734052933d0bf582821..d9e54bf6b1c437807edb55defbf2577ca42fcc5b 100644 --- a/tezt/tests/expected/RPC_test.ml/Alpha- (mode proxy_server_rpc) RPC regression tests- misc_protocol.out +++ b/tezt/tests/expected/RPC_test.ml/Alpha- (mode proxy_server_rpc) RPC regression tests- misc_protocol.out @@ -15,13 +15,15 @@ "hard_gas_limit_per_block": "2600000", "proof_of_work_threshold": "4611686018427387903", "minimal_stake": "6000000000", "vdf_difficulty": "50000", - "seed_nonce_revelation_tip": "125000", "origination_size": 257, - "baking_reward_fixed_portion": "333333", - "baking_reward_bonus_per_slot": "3921", - "endorsing_reward_per_slot": "2604", "cost_per_byte": "250", - "hard_storage_limit_per_operation": "60000", "quorum_min": 2000, - "quorum_max": 7000, "min_proposal_quorum": 500, - "liquidity_baking_subsidy": "83333", + "origination_size": 257, + "reward_weights": + { "base_index_of_total_rewards_per_minute": "85007812", + "baking_reward_fixed_weight": 5120, "baking_reward_bonus_weight": 5120, + "endorsing_reward_weight": 10240, + "liquidity_baking_subsidy_weight": 1280, + "nonce_revelation_tip_weight": 1, "vdf_revelation_tip_weight": 1 }, + "cost_per_byte": "250", "hard_storage_limit_per_operation": "60000", + "quorum_min": 2000, "quorum_max": 7000, "min_proposal_quorum": 500, "liquidity_baking_toggle_ema_threshold": 1000000000, "max_operations_time_to_live": 240, "minimal_block_delay": "1", "delay_increment_per_round": "1", "consensus_committee_size": 256, diff --git a/tezt/tests/expected/RPC_test.ml/Alpha- (mode proxy_server_rpc) RPC regression tests- votes.out b/tezt/tests/expected/RPC_test.ml/Alpha- (mode proxy_server_rpc) RPC regression tests- votes.out index 8c859f49f493e782f9a23c4cb651162ca4edf574..92b45913298ab40ace37da5ad42cf7f5dd881f91 100644 --- a/tezt/tests/expected/RPC_test.ml/Alpha- (mode proxy_server_rpc) RPC regression tests- votes.out +++ b/tezt/tests/expected/RPC_test.ml/Alpha- (mode proxy_server_rpc) RPC regression tests- votes.out @@ -43,7 +43,7 @@ null { "pkh": "[PUBLIC_KEY_HASH]", "ballot": "yay" } ] ./octez-client rpc get /chains/main/blocks/head/votes/ballots -{ "yay": "4000001978209", "nay": "4000000000000", "pass": "4000000000000" } +{ "yay": "4000001679643", "nay": "4000000000000", "pass": "4000000000000" } ./octez-client rpc get /chains/main/blocks/head/votes/current_period { "voting_period": { "index": 1, "kind": "exploration", "start_position": 4 }, @@ -65,7 +65,7 @@ null { "pkh": "[PUBLIC_KEY_HASH]", "voting_power": "4000000000000" }, { "pkh": "[PUBLIC_KEY_HASH]", - "voting_power": "4000001978209" } ] + "voting_power": "4000001679643" } ] ./octez-client rpc get /chains/main/blocks/head/votes/proposals [] @@ -75,4 +75,4 @@ null "position": 2, "remaining": 1 } ./octez-client rpc get /chains/main/blocks/head/votes/total_voting_power -"20000001978209" +"20000001679643" diff --git a/tezt/tests/expected/consensus_key.ml/Alpha- Test drain delegate with (baker - delegate - consensus - destination).out b/tezt/tests/expected/consensus_key.ml/Alpha- Test drain delegate with (baker - delegate - consensus - destination).out index 86c4fb92bb2148330aeee7c781d5c80a45b929ad..f8653380a98db1a21f8d6367096929089c72d55e 100644 --- a/tezt/tests/expected/consensus_key.ml/Alpha- Test drain delegate with (baker - delegate - consensus - destination).out +++ b/tezt/tests/expected/consensus_key.ml/Alpha- Test drain delegate with (baker - delegate - consensus - destination).out @@ -44,23 +44,23 @@ This sequence of operations was run: [ { "cycle": 2, "pkh": "[PUBLIC_KEY_HASH]" } ] } ./octez-client rpc get '/chains/main/blocks/head/context/delegates/[PUBLIC_KEY_HASH]' -{ "full_balance": "4000004170240", "current_frozen_deposits": "200000208512", - "frozen_deposits": "200000208512", "staking_balance": "4000004170240", +{ "full_balance": "4000003298113", "current_frozen_deposits": "200000164905", + "frozen_deposits": "200000164905", "staking_balance": "4000003298113", "delegated_contracts": [ "[PUBLIC_KEY_HASH]" ], "delegated_balance": "0", "deactivated": false, "grace_period": 3, "voting_power": "4000000000000", "remaining_proposals": 20, "active_consensus_key": "[PUBLIC_KEY_HASH]" } ./octez-client rpc get '/chains/main/blocks/head/context/delegates/[PUBLIC_KEY_HASH]' -{ "full_balance": "4000004170240", "current_frozen_deposits": "200000208512", - "frozen_deposits": "200000208512", "staking_balance": "4000004170240", +{ "full_balance": "4000003298113", "current_frozen_deposits": "200000164905", + "frozen_deposits": "200000164905", "staking_balance": "4000003298113", "delegated_contracts": [ "[PUBLIC_KEY_HASH]" ], "delegated_balance": "0", "deactivated": false, "grace_period": 3, "voting_power": "4000000000000", "remaining_proposals": 20, "active_consensus_key": "[PUBLIC_KEY_HASH]" } ./octez-client rpc get '/chains/main/blocks/head/context/contracts/[PUBLIC_KEY_HASH]/balance' -"3800003961728" +"3800003133208" ./octez-client rpc get '/chains/main/blocks/head/context/contracts/[PUBLIC_KEY_HASH]/balance' "0" @@ -84,25 +84,25 @@ This sequence of operations was run: Balance updates: [PUBLIC_KEY_HASH] ... -ꜩ0.06425 storage fees ........................... +ꜩ0.06425 - [PUBLIC_KEY_HASH] ... -ꜩ3762003.858504 - [PUBLIC_KEY_HASH] ... +ꜩ3762003.858504 - [PUBLIC_KEY_HASH] ... -ꜩ38000.038974 - [PUBLIC_KEY_HASH] ... +ꜩ38000.038974 + [PUBLIC_KEY_HASH] ... -ꜩ3762003.038269 + [PUBLIC_KEY_HASH] ... +ꜩ3762003.038269 + [PUBLIC_KEY_HASH] ... -ꜩ38000.030689 + [PUBLIC_KEY_HASH] ... +ꜩ38000.030689 ./octez-client rpc get '/chains/main/blocks/head/context/delegates/[PUBLIC_KEY_HASH]' -{ "full_balance": "238000580819", "current_frozen_deposits": "200000208512", - "frozen_deposits": "200000208512", "staking_balance": "238000580819", +{ "full_balance": "238000528927", "current_frozen_deposits": "200000164905", + "frozen_deposits": "200000164905", "staking_balance": "238000528927", "delegated_contracts": [ "[PUBLIC_KEY_HASH]" ], "delegated_balance": "0", "deactivated": false, "grace_period": 4, "voting_power": "4000000000000", "remaining_proposals": 20, "active_consensus_key": "[PUBLIC_KEY_HASH]" } ./octez-client rpc get '/chains/main/blocks/head/context/contracts/[PUBLIC_KEY_HASH]/balance' -"38000372307" +"38000364022" ./octez-client rpc get '/chains/main/blocks/head/context/contracts/[PUBLIC_KEY_HASH]/balance' -"3762003858504" +"3762003038269" ./octez-client rpc get '/chains/main/blocks/head/context/contracts/[PUBLIC_KEY_HASH]/balance' -"3762003858504" +"3762003038269" diff --git a/tezt/tests/expected/consensus_key.ml/Alpha- Test drain delegate with (baker - delegate - consensus -- destination).out b/tezt/tests/expected/consensus_key.ml/Alpha- Test drain delegate with (baker - delegate - consensus -- destination).out index d1d086d28ecb6d82a7c8f2cdc6fa8ca251cb22f5..6f32b44eac2e4554a7f6ef9cd555f3b88f920649 100644 --- a/tezt/tests/expected/consensus_key.ml/Alpha- Test drain delegate with (baker - delegate - consensus -- destination).out +++ b/tezt/tests/expected/consensus_key.ml/Alpha- Test drain delegate with (baker - delegate - consensus -- destination).out @@ -44,23 +44,23 @@ This sequence of operations was run: [ { "cycle": 2, "pkh": "[PUBLIC_KEY_HASH]" } ] } ./octez-client rpc get '/chains/main/blocks/head/context/delegates/[PUBLIC_KEY_HASH]' -{ "full_balance": "4000004170240", "current_frozen_deposits": "200000208512", - "frozen_deposits": "200000208512", "staking_balance": "4000004170240", +{ "full_balance": "4000003298113", "current_frozen_deposits": "200000164905", + "frozen_deposits": "200000164905", "staking_balance": "4000003298113", "delegated_contracts": [ "[PUBLIC_KEY_HASH]" ], "delegated_balance": "0", "deactivated": false, "grace_period": 3, "voting_power": "4000000000000", "remaining_proposals": 20, "active_consensus_key": "[PUBLIC_KEY_HASH]" } ./octez-client rpc get '/chains/main/blocks/head/context/delegates/[PUBLIC_KEY_HASH]' -{ "full_balance": "4000004170240", "current_frozen_deposits": "200000208512", - "frozen_deposits": "200000208512", "staking_balance": "4000004170240", +{ "full_balance": "4000003298113", "current_frozen_deposits": "200000164905", + "frozen_deposits": "200000164905", "staking_balance": "4000003298113", "delegated_contracts": [ "[PUBLIC_KEY_HASH]" ], "delegated_balance": "0", "deactivated": false, "grace_period": 3, "voting_power": "4000000000000", "remaining_proposals": 20, "active_consensus_key": "[PUBLIC_KEY_HASH]" } ./octez-client rpc get '/chains/main/blocks/head/context/contracts/[PUBLIC_KEY_HASH]/balance' -"3800003961728" +"3800003133208" ./octez-client rpc get '/chains/main/blocks/head/context/contracts/[PUBLIC_KEY_HASH]/balance' "0" @@ -84,25 +84,25 @@ This sequence of operations was run: Balance updates: [PUBLIC_KEY_HASH] ... -ꜩ0.06425 storage fees ........................... +ꜩ0.06425 - [PUBLIC_KEY_HASH] ... -ꜩ3762003.858504 - [PUBLIC_KEY_HASH] ... +ꜩ3762003.858504 - [PUBLIC_KEY_HASH] ... -ꜩ38000.038974 - [PUBLIC_KEY_HASH] ... +ꜩ38000.038974 + [PUBLIC_KEY_HASH] ... -ꜩ3762003.038269 + [PUBLIC_KEY_HASH] ... +ꜩ3762003.038269 + [PUBLIC_KEY_HASH] ... -ꜩ38000.030689 + [PUBLIC_KEY_HASH] ... +ꜩ38000.030689 ./octez-client rpc get '/chains/main/blocks/head/context/delegates/[PUBLIC_KEY_HASH]' -{ "full_balance": "238000580819", "current_frozen_deposits": "200000208512", - "frozen_deposits": "200000208512", "staking_balance": "238000580819", +{ "full_balance": "238000528927", "current_frozen_deposits": "200000164905", + "frozen_deposits": "200000164905", "staking_balance": "238000528927", "delegated_contracts": [ "[PUBLIC_KEY_HASH]" ], "delegated_balance": "0", "deactivated": false, "grace_period": 4, "voting_power": "4000000000000", "remaining_proposals": 20, "active_consensus_key": "[PUBLIC_KEY_HASH]" } ./octez-client rpc get '/chains/main/blocks/head/context/contracts/[PUBLIC_KEY_HASH]/balance' -"38000372307" +"38000364022" ./octez-client rpc get '/chains/main/blocks/head/context/contracts/[PUBLIC_KEY_HASH]/balance' "0" ./octez-client rpc get '/chains/main/blocks/head/context/contracts/[PUBLIC_KEY_HASH]/balance' -"3762003858504" +"3762003038269" diff --git a/tezt/tests/expected/consensus_key.ml/Alpha- Test drain delegate with (baker -- delegate - consensus - destination).out b/tezt/tests/expected/consensus_key.ml/Alpha- Test drain delegate with (baker -- delegate - consensus - destination).out index 5b09e461ca8a735c6c155a4c19540a28d5dd6fef..d677c705b0e326108a82bc523c4e59c0ab47d47e 100644 --- a/tezt/tests/expected/consensus_key.ml/Alpha- Test drain delegate with (baker -- delegate - consensus - destination).out +++ b/tezt/tests/expected/consensus_key.ml/Alpha- Test drain delegate with (baker -- delegate - consensus - destination).out @@ -44,23 +44,23 @@ This sequence of operations was run: [ { "cycle": 2, "pkh": "[PUBLIC_KEY_HASH]" } ] } ./octez-client rpc get '/chains/main/blocks/head/context/delegates/[PUBLIC_KEY_HASH]' -{ "full_balance": "4000003836623", "current_frozen_deposits": "200000191831", - "frozen_deposits": "200000191831", "staking_balance": "4000003836623", +{ "full_balance": "4000002964496", "current_frozen_deposits": "200000148224", + "frozen_deposits": "200000148224", "staking_balance": "4000002964496", "delegated_contracts": [ "[PUBLIC_KEY_HASH]" ], "delegated_balance": "0", "deactivated": false, "grace_period": 3, "voting_power": "4000000000000", "remaining_proposals": 20, "active_consensus_key": "[PUBLIC_KEY_HASH]" } ./octez-client rpc get '/chains/main/blocks/head/context/delegates/[PUBLIC_KEY_HASH]' -{ "full_balance": "4000003836623", "current_frozen_deposits": "200000191831", - "frozen_deposits": "200000191831", "staking_balance": "4000003836623", +{ "full_balance": "4000002964496", "current_frozen_deposits": "200000148224", + "frozen_deposits": "200000148224", "staking_balance": "4000002964496", "delegated_contracts": [ "[PUBLIC_KEY_HASH]" ], "delegated_balance": "0", "deactivated": false, "grace_period": 3, "voting_power": "4000000000000", "remaining_proposals": 20, "active_consensus_key": "[PUBLIC_KEY_HASH]" } ./octez-client rpc get '/chains/main/blocks/head/context/contracts/[PUBLIC_KEY_HASH]/balance' -"3800003644792" +"3800002816272" ./octez-client rpc get '/chains/main/blocks/head/context/contracts/[PUBLIC_KEY_HASH]/balance' "0" @@ -84,25 +84,25 @@ This sequence of operations was run: Balance updates: [PUBLIC_KEY_HASH] ... -ꜩ0.06425 storage fees ........................... +ꜩ0.06425 - [PUBLIC_KEY_HASH] ... -ꜩ3762003.544737 - [PUBLIC_KEY_HASH] ... +ꜩ3762003.544737 - [PUBLIC_KEY_HASH] ... -ꜩ38000.035805 - [PUBLIC_KEY_HASH] ... +ꜩ38000.035805 + [PUBLIC_KEY_HASH] ... -ꜩ3762002.724502 + [PUBLIC_KEY_HASH] ... +ꜩ3762002.724502 + [PUBLIC_KEY_HASH] ... -ꜩ38000.02752 + [PUBLIC_KEY_HASH] ... +ꜩ38000.02752 ./octez-client rpc get '/chains/main/blocks/head/context/delegates/[PUBLIC_KEY_HASH]' -{ "full_balance": "238000560969", "current_frozen_deposits": "200000191831", - "frozen_deposits": "200000191831", "staking_balance": "238000560969", +{ "full_balance": "238000509077", "current_frozen_deposits": "200000148224", + "frozen_deposits": "200000148224", "staking_balance": "238000509077", "delegated_contracts": [ "[PUBLIC_KEY_HASH]" ], "delegated_balance": "0", "deactivated": false, "grace_period": 4, "voting_power": "4000000000000", "remaining_proposals": 20, "active_consensus_key": "[PUBLIC_KEY_HASH]" } ./octez-client rpc get '/chains/main/blocks/head/context/contracts/[PUBLIC_KEY_HASH]/balance' -"38000369138" +"38000360853" ./octez-client rpc get '/chains/main/blocks/head/context/contracts/[PUBLIC_KEY_HASH]/balance' -"3762003544737" +"3762002724502" ./octez-client rpc get '/chains/main/blocks/head/context/contracts/[PUBLIC_KEY_HASH]/balance' -"3762003544737" +"3762002724502" diff --git a/tezt/tests/expected/consensus_key.ml/Alpha- Test drain delegate with (baker -- delegate - consensus -- destination).out b/tezt/tests/expected/consensus_key.ml/Alpha- Test drain delegate with (baker -- delegate - consensus -- destination).out index b110ef6d7e2b61872fcea76e1969f8656ac1bf24..998eca0d1ada1a90a93b0334929e5e2a7684d5c6 100644 --- a/tezt/tests/expected/consensus_key.ml/Alpha- Test drain delegate with (baker -- delegate - consensus -- destination).out +++ b/tezt/tests/expected/consensus_key.ml/Alpha- Test drain delegate with (baker -- delegate - consensus -- destination).out @@ -44,23 +44,23 @@ This sequence of operations was run: [ { "cycle": 2, "pkh": "[PUBLIC_KEY_HASH]" } ] } ./octez-client rpc get '/chains/main/blocks/head/context/delegates/[PUBLIC_KEY_HASH]' -{ "full_balance": "4000003836623", "current_frozen_deposits": "200000191831", - "frozen_deposits": "200000191831", "staking_balance": "4000003836623", +{ "full_balance": "4000002964496", "current_frozen_deposits": "200000148224", + "frozen_deposits": "200000148224", "staking_balance": "4000002964496", "delegated_contracts": [ "[PUBLIC_KEY_HASH]" ], "delegated_balance": "0", "deactivated": false, "grace_period": 3, "voting_power": "4000000000000", "remaining_proposals": 20, "active_consensus_key": "[PUBLIC_KEY_HASH]" } ./octez-client rpc get '/chains/main/blocks/head/context/delegates/[PUBLIC_KEY_HASH]' -{ "full_balance": "4000003836623", "current_frozen_deposits": "200000191831", - "frozen_deposits": "200000191831", "staking_balance": "4000003836623", +{ "full_balance": "4000002964496", "current_frozen_deposits": "200000148224", + "frozen_deposits": "200000148224", "staking_balance": "4000002964496", "delegated_contracts": [ "[PUBLIC_KEY_HASH]" ], "delegated_balance": "0", "deactivated": false, "grace_period": 3, "voting_power": "4000000000000", "remaining_proposals": 20, "active_consensus_key": "[PUBLIC_KEY_HASH]" } ./octez-client rpc get '/chains/main/blocks/head/context/contracts/[PUBLIC_KEY_HASH]/balance' -"3800003644792" +"3800002816272" ./octez-client rpc get '/chains/main/blocks/head/context/contracts/[PUBLIC_KEY_HASH]/balance' "0" @@ -84,25 +84,25 @@ This sequence of operations was run: Balance updates: [PUBLIC_KEY_HASH] ... -ꜩ0.06425 storage fees ........................... +ꜩ0.06425 - [PUBLIC_KEY_HASH] ... -ꜩ3762003.544737 - [PUBLIC_KEY_HASH] ... +ꜩ3762003.544737 - [PUBLIC_KEY_HASH] ... -ꜩ38000.035805 - [PUBLIC_KEY_HASH] ... +ꜩ38000.035805 + [PUBLIC_KEY_HASH] ... -ꜩ3762002.724502 + [PUBLIC_KEY_HASH] ... +ꜩ3762002.724502 + [PUBLIC_KEY_HASH] ... -ꜩ38000.02752 + [PUBLIC_KEY_HASH] ... +ꜩ38000.02752 ./octez-client rpc get '/chains/main/blocks/head/context/delegates/[PUBLIC_KEY_HASH]' -{ "full_balance": "238000560969", "current_frozen_deposits": "200000191831", - "frozen_deposits": "200000191831", "staking_balance": "238000560969", +{ "full_balance": "238000509077", "current_frozen_deposits": "200000148224", + "frozen_deposits": "200000148224", "staking_balance": "238000509077", "delegated_contracts": [ "[PUBLIC_KEY_HASH]" ], "delegated_balance": "0", "deactivated": false, "grace_period": 4, "voting_power": "4000000000000", "remaining_proposals": 20, "active_consensus_key": "[PUBLIC_KEY_HASH]" } ./octez-client rpc get '/chains/main/blocks/head/context/contracts/[PUBLIC_KEY_HASH]/balance' -"38000369138" +"38000360853" ./octez-client rpc get '/chains/main/blocks/head/context/contracts/[PUBLIC_KEY_HASH]/balance' "0" ./octez-client rpc get '/chains/main/blocks/head/context/contracts/[PUBLIC_KEY_HASH]/balance' -"3762003544737" +"3762002724502" diff --git a/tezt/tests/expected/consensus_key.ml/Alpha- Test set consensus key - baker is delegate.out b/tezt/tests/expected/consensus_key.ml/Alpha- Test set consensus key - baker is delegate.out index 7d2d21361f08268ac735640356831fff7ce1ab56..c5a903e96fb9cc9c5e7a8a7d09fcead12e5dbec9 100644 --- a/tezt/tests/expected/consensus_key.ml/Alpha- Test set consensus key - baker is delegate.out +++ b/tezt/tests/expected/consensus_key.ml/Alpha- Test set consensus key - baker is delegate.out @@ -44,8 +44,8 @@ This sequence of operations was run: [ { "cycle": 2, "pkh": "[PUBLIC_KEY_HASH]" } ] } ./octez-client rpc get '/chains/main/blocks/head/context/delegates/[PUBLIC_KEY_HASH]' -{ "full_balance": "4000004170240", "current_frozen_deposits": "200000208512", - "frozen_deposits": "200000208512", "staking_balance": "4000004170240", +{ "full_balance": "4000003298113", "current_frozen_deposits": "200000164905", + "frozen_deposits": "200000164905", "staking_balance": "4000003298113", "delegated_contracts": [ "[PUBLIC_KEY_HASH]" ], "delegated_balance": "0", "deactivated": false, "grace_period": 3, "voting_power": "4000000000000", "remaining_proposals": 20, diff --git a/tezt/tests/expected/consensus_key.ml/Alpha- Test set consensus key - baker is not delegate.out b/tezt/tests/expected/consensus_key.ml/Alpha- Test set consensus key - baker is not delegate.out index 18cb7aa2c78f53b30f6b0f5a65ce028f624fd127..b9544d8cbfa5bce7d51c86143c499139101201c4 100644 --- a/tezt/tests/expected/consensus_key.ml/Alpha- Test set consensus key - baker is not delegate.out +++ b/tezt/tests/expected/consensus_key.ml/Alpha- Test set consensus key - baker is not delegate.out @@ -44,8 +44,8 @@ This sequence of operations was run: [ { "cycle": 2, "pkh": "[PUBLIC_KEY_HASH]" } ] } ./octez-client rpc get '/chains/main/blocks/head/context/delegates/[PUBLIC_KEY_HASH]' -{ "full_balance": "4000003836623", "current_frozen_deposits": "200000191831", - "frozen_deposits": "200000191831", "staking_balance": "4000003836623", +{ "full_balance": "4000002964496", "current_frozen_deposits": "200000148224", + "frozen_deposits": "200000148224", "staking_balance": "4000002964496", "delegated_contracts": [ "[PUBLIC_KEY_HASH]" ], "delegated_balance": "0", "deactivated": false, "grace_period": 3, "voting_power": "4000000000000", "remaining_proposals": 20,