Alpha: allow to deactivate rewards for a few initial cycles
This commit is contained in:
parent
126ee13ba7
commit
07a631316a
@ -130,4 +130,7 @@ if __name__ == '__main__':
|
||||
[ (commitment['half_pkh'],
|
||||
commitment['blinded_pkh'],
|
||||
str(commitment['amount']))
|
||||
for commitment in commitments if commitment['amount'] > 0]}, f, indent=1)
|
||||
for commitment in commitments if commitment['amount'] > 0]
|
||||
"no_rewards_cycles": 7,
|
||||
"security_deposit_ramp_up_cycles": 64
|
||||
}, f, indent=1)
|
||||
|
@ -17,8 +17,26 @@ let init_account ctxt (account: Parameters_repr.bootstrap_account) =
|
||||
Delegate_storage.set ctxt contract (Some public_key_hash) >>=? fun ctxt ->
|
||||
return ctxt
|
||||
|
||||
let init ctxt ?ramp_up_cycles accounts =
|
||||
let init ctxt ?ramp_up_cycles ?no_reward_cycles accounts =
|
||||
fold_left_s init_account ctxt accounts >>=? fun ctxt ->
|
||||
begin
|
||||
match no_reward_cycles with
|
||||
| None -> return ctxt
|
||||
| Some cycles ->
|
||||
(* Store pending ramp ups. *)
|
||||
let constants = Raw_context.constants ctxt in
|
||||
(* Start without reward *)
|
||||
Raw_context.patch_constants ctxt
|
||||
(fun c ->
|
||||
{ c with
|
||||
block_reward = Tez_repr.zero ;
|
||||
endorsement_reward = Tez_repr.zero }) >>= fun ctxt ->
|
||||
(* Store the final reward. *)
|
||||
Storage.Ramp_up.Rewards.init ctxt
|
||||
(Cycle_repr.of_int32_exn (Int32.of_int cycles))
|
||||
(constants.block_reward,
|
||||
constants.endorsement_reward)
|
||||
end >>=? fun ctxt ->
|
||||
match ramp_up_cycles with
|
||||
| None -> return ctxt
|
||||
| Some cycles ->
|
||||
@ -50,6 +68,17 @@ let init ctxt ?ramp_up_cycles accounts =
|
||||
|
||||
let cycle_end ctxt last_cycle =
|
||||
let next_cycle = Cycle_repr.succ last_cycle in
|
||||
begin
|
||||
Storage.Ramp_up.Rewards.get_option ctxt next_cycle >>=? function
|
||||
| None -> return ctxt
|
||||
| Some (block_reward, endorsement_reward) ->
|
||||
Storage.Ramp_up.Rewards.delete ctxt next_cycle >>=? fun ctxt ->
|
||||
Raw_context.patch_constants ctxt
|
||||
(fun c ->
|
||||
{ c with block_reward ;
|
||||
endorsement_reward }) >>= fun ctxt ->
|
||||
return ctxt
|
||||
end >>=? fun ctxt ->
|
||||
Storage.Ramp_up.Security_deposits.get_option ctxt next_cycle >>=? function
|
||||
| None -> return ctxt
|
||||
| Some (block_security_deposit, endorsement_security_deposit) ->
|
||||
|
@ -10,6 +10,7 @@
|
||||
val init:
|
||||
Raw_context.t ->
|
||||
?ramp_up_cycles:int ->
|
||||
?no_reward_cycles:int ->
|
||||
Parameters_repr.bootstrap_account list ->
|
||||
Raw_context.t tzresult Lwt.t
|
||||
|
||||
|
@ -17,6 +17,7 @@ let prepare_first_block ctxt ~level ~timestamp ~fitness =
|
||||
Contract_storage.init ctxt >>=? fun ctxt ->
|
||||
Bootstrap_storage.init ctxt
|
||||
?ramp_up_cycles:param.security_deposit_ramp_up_cycles
|
||||
?no_reward_cycles:param.no_reward_cycles
|
||||
param.bootstrap_accounts >>=? fun ctxt ->
|
||||
Roll_storage.init_first_cycles ctxt >>=? fun ctxt ->
|
||||
Vote_storage.init ctxt >>=? fun ctxt ->
|
||||
|
@ -17,6 +17,7 @@ type t = {
|
||||
commitments : (Unclaimed_public_key_hash.t * Commitment_repr.t) list ;
|
||||
constants : Constants_repr.parametric ;
|
||||
security_deposit_ramp_up_cycles : int option ;
|
||||
no_reward_cycles : int option ;
|
||||
}
|
||||
|
||||
let bootstrap_account_encoding =
|
||||
@ -210,19 +211,22 @@ let encoding =
|
||||
let open Data_encoding in
|
||||
conv
|
||||
(fun { bootstrap_accounts ; commitments ; constants ;
|
||||
security_deposit_ramp_up_cycles } ->
|
||||
((bootstrap_accounts, commitments, security_deposit_ramp_up_cycles),
|
||||
security_deposit_ramp_up_cycles ; no_reward_cycles } ->
|
||||
((bootstrap_accounts, commitments,
|
||||
security_deposit_ramp_up_cycles, no_reward_cycles),
|
||||
constants))
|
||||
(fun ( (bootstrap_accounts, commitments, security_deposit_ramp_up_cycles),
|
||||
(fun ( (bootstrap_accounts, commitments,
|
||||
security_deposit_ramp_up_cycles, no_reward_cycles),
|
||||
constants) ->
|
||||
{ bootstrap_accounts ; commitments ; constants ;
|
||||
security_deposit_ramp_up_cycles})
|
||||
security_deposit_ramp_up_cycles ; no_reward_cycles })
|
||||
(merge_objs
|
||||
(obj3
|
||||
(obj4
|
||||
(req "bootstrap_accounts" (list bootstrap_account_encoding))
|
||||
(dft "commitments"
|
||||
(list (merge_tups
|
||||
(tup1 Unclaimed_public_key_hash.encoding)
|
||||
Commitment_repr.encoding)) [])
|
||||
(opt "security_deposit_ramp_up_cycles" int31))
|
||||
(opt "security_deposit_ramp_up_cycles" int31)
|
||||
(opt "no_reward_cycles" int31))
|
||||
constants_encoding)
|
||||
|
@ -17,6 +17,7 @@ type t = {
|
||||
commitments : (Unclaimed_public_key_hash.t * Commitment_repr.t) list ;
|
||||
constants : Constants_repr.parametric ;
|
||||
security_deposit_ramp_up_cycles : int option ;
|
||||
no_reward_cycles : int option ;
|
||||
}
|
||||
|
||||
val encoding: t Data_encoding.t
|
||||
|
@ -431,6 +431,15 @@ module Commitments =
|
||||
|
||||
module Ramp_up = struct
|
||||
|
||||
module Rewards =
|
||||
Make_indexed_data_storage
|
||||
(Make_subcontext(Raw_context)(struct let name = ["ramp_up"; "rewards"] end))
|
||||
(Cycle_repr.Index)
|
||||
(Make_value(struct
|
||||
type t = Tez_repr.t * Tez_repr.t
|
||||
let encoding = Data_encoding.tup2 Tez_repr.encoding Tez_repr.encoding
|
||||
end))
|
||||
|
||||
module Security_deposits =
|
||||
Make_indexed_data_storage
|
||||
(Make_subcontext(Raw_context)(struct let name = ["ramp_up"; "deposits"] end))
|
||||
|
@ -268,6 +268,12 @@ module Commitments : Indexed_data_storage
|
||||
|
||||
module Ramp_up : sig
|
||||
|
||||
module Rewards :
|
||||
Indexed_data_storage
|
||||
with type key = Cycle_repr.t
|
||||
and type value = Tez_repr.t * Tez_repr.t (* baking * endorsement *)
|
||||
and type t := Raw_context.t
|
||||
|
||||
module Security_deposits :
|
||||
Indexed_data_storage
|
||||
with type key = Cycle_repr.t
|
||||
|
Loading…
Reference in New Issue
Block a user