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['half_pkh'],
|
||||||
commitment['blinded_pkh'],
|
commitment['blinded_pkh'],
|
||||||
str(commitment['amount']))
|
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 ->
|
Delegate_storage.set ctxt contract (Some public_key_hash) >>=? fun ctxt ->
|
||||||
return 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 ->
|
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
|
match ramp_up_cycles with
|
||||||
| None -> return ctxt
|
| None -> return ctxt
|
||||||
| Some cycles ->
|
| Some cycles ->
|
||||||
@ -50,6 +68,17 @@ let init ctxt ?ramp_up_cycles accounts =
|
|||||||
|
|
||||||
let cycle_end ctxt last_cycle =
|
let cycle_end ctxt last_cycle =
|
||||||
let next_cycle = Cycle_repr.succ last_cycle in
|
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
|
Storage.Ramp_up.Security_deposits.get_option ctxt next_cycle >>=? function
|
||||||
| None -> return ctxt
|
| None -> return ctxt
|
||||||
| Some (block_security_deposit, endorsement_security_deposit) ->
|
| Some (block_security_deposit, endorsement_security_deposit) ->
|
||||||
|
@ -10,6 +10,7 @@
|
|||||||
val init:
|
val init:
|
||||||
Raw_context.t ->
|
Raw_context.t ->
|
||||||
?ramp_up_cycles:int ->
|
?ramp_up_cycles:int ->
|
||||||
|
?no_reward_cycles:int ->
|
||||||
Parameters_repr.bootstrap_account list ->
|
Parameters_repr.bootstrap_account list ->
|
||||||
Raw_context.t tzresult Lwt.t
|
Raw_context.t tzresult Lwt.t
|
||||||
|
|
||||||
|
@ -17,6 +17,7 @@ let prepare_first_block ctxt ~level ~timestamp ~fitness =
|
|||||||
Contract_storage.init ctxt >>=? fun ctxt ->
|
Contract_storage.init ctxt >>=? fun ctxt ->
|
||||||
Bootstrap_storage.init ctxt
|
Bootstrap_storage.init ctxt
|
||||||
?ramp_up_cycles:param.security_deposit_ramp_up_cycles
|
?ramp_up_cycles:param.security_deposit_ramp_up_cycles
|
||||||
|
?no_reward_cycles:param.no_reward_cycles
|
||||||
param.bootstrap_accounts >>=? fun ctxt ->
|
param.bootstrap_accounts >>=? fun ctxt ->
|
||||||
Roll_storage.init_first_cycles ctxt >>=? fun ctxt ->
|
Roll_storage.init_first_cycles ctxt >>=? fun ctxt ->
|
||||||
Vote_storage.init 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 ;
|
commitments : (Unclaimed_public_key_hash.t * Commitment_repr.t) list ;
|
||||||
constants : Constants_repr.parametric ;
|
constants : Constants_repr.parametric ;
|
||||||
security_deposit_ramp_up_cycles : int option ;
|
security_deposit_ramp_up_cycles : int option ;
|
||||||
|
no_reward_cycles : int option ;
|
||||||
}
|
}
|
||||||
|
|
||||||
let bootstrap_account_encoding =
|
let bootstrap_account_encoding =
|
||||||
@ -210,19 +211,22 @@ let encoding =
|
|||||||
let open Data_encoding in
|
let open Data_encoding in
|
||||||
conv
|
conv
|
||||||
(fun { bootstrap_accounts ; commitments ; constants ;
|
(fun { bootstrap_accounts ; commitments ; constants ;
|
||||||
security_deposit_ramp_up_cycles } ->
|
security_deposit_ramp_up_cycles ; no_reward_cycles } ->
|
||||||
((bootstrap_accounts, commitments, security_deposit_ramp_up_cycles),
|
((bootstrap_accounts, commitments,
|
||||||
|
security_deposit_ramp_up_cycles, no_reward_cycles),
|
||||||
constants))
|
constants))
|
||||||
(fun ( (bootstrap_accounts, commitments, security_deposit_ramp_up_cycles),
|
(fun ( (bootstrap_accounts, commitments,
|
||||||
|
security_deposit_ramp_up_cycles, no_reward_cycles),
|
||||||
constants) ->
|
constants) ->
|
||||||
{ bootstrap_accounts ; commitments ; constants ;
|
{ bootstrap_accounts ; commitments ; constants ;
|
||||||
security_deposit_ramp_up_cycles})
|
security_deposit_ramp_up_cycles ; no_reward_cycles })
|
||||||
(merge_objs
|
(merge_objs
|
||||||
(obj3
|
(obj4
|
||||||
(req "bootstrap_accounts" (list bootstrap_account_encoding))
|
(req "bootstrap_accounts" (list bootstrap_account_encoding))
|
||||||
(dft "commitments"
|
(dft "commitments"
|
||||||
(list (merge_tups
|
(list (merge_tups
|
||||||
(tup1 Unclaimed_public_key_hash.encoding)
|
(tup1 Unclaimed_public_key_hash.encoding)
|
||||||
Commitment_repr.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)
|
constants_encoding)
|
||||||
|
@ -17,6 +17,7 @@ type t = {
|
|||||||
commitments : (Unclaimed_public_key_hash.t * Commitment_repr.t) list ;
|
commitments : (Unclaimed_public_key_hash.t * Commitment_repr.t) list ;
|
||||||
constants : Constants_repr.parametric ;
|
constants : Constants_repr.parametric ;
|
||||||
security_deposit_ramp_up_cycles : int option ;
|
security_deposit_ramp_up_cycles : int option ;
|
||||||
|
no_reward_cycles : int option ;
|
||||||
}
|
}
|
||||||
|
|
||||||
val encoding: t Data_encoding.t
|
val encoding: t Data_encoding.t
|
||||||
|
@ -431,6 +431,15 @@ module Commitments =
|
|||||||
|
|
||||||
module Ramp_up = struct
|
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 =
|
module Security_deposits =
|
||||||
Make_indexed_data_storage
|
Make_indexed_data_storage
|
||||||
(Make_subcontext(Raw_context)(struct let name = ["ramp_up"; "deposits"] end))
|
(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 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 :
|
module Security_deposits :
|
||||||
Indexed_data_storage
|
Indexed_data_storage
|
||||||
with type key = Cycle_repr.t
|
with type key = Cycle_repr.t
|
||||||
|
Loading…
Reference in New Issue
Block a user