Mavryk_alpha_test_helpers.State_account
State_account
is dedicated to operations in State.t
that would modify an account_state
. This includes any operation like transfer
, stake
, unstake
, set_delegate_parameters
, anything related to slashing or rewards, etc...
include module type of struct include Tez_staking_helpers end
module Cycle = Mavryk_alpha_test_helpers.Tez_staking_helpers.Cycle
module Tez = Tez_staking_helpers.Tez
module Partial_tez = Tez_staking_helpers.Partial_tez
Representation of Tez with non integer values
module Frozen_tez = Tez_staking_helpers.Frozen_tez
Frozen_tez
represents frozen stake and frozen unstaked funds. Properties:
module Unstaked_frozen = Tez_staking_helpers.Unstaked_frozen
Representation of Unstaked frozen deposits
module Unstaked_finalizable = Tez_staking_helpers.Unstaked_finalizable
Representation of unstaked finalizable tez
val tez_to_pseudo :
round:[ `Down | `Up ] ->
Tez.t ->
Z.t ->
Frozen_tez.t ->
Z.t
Pseudotoken helpers
val pseudo_to_partial_tez : Z.t -> Z.t -> Frozen_tez.t -> Q.t
val stake_values_real : Tez.t -> Z.t -> Frozen_tez.t -> Z.t * Q.t
val unstake_values_real : Tez.t -> Z.t -> Frozen_tez.t -> Z.t * Q.t
include module type of struct include Account_helpers end
module CycleMap = Account_helpers.CycleMap
type account_state = Account_helpers.account_state = {
pkh : Mavryk_base.TzPervasives.Signature.Public_key_hash.t;
contract : Mavryk_protocol_alpha.Protocol.Alpha_context.Contract.t;
delegate : string option;
parameters : Adaptive_issuance_helpers.staking_parameters;
liquid : Tez_staking_helpers.Tez.t;
bonds : Tez_staking_helpers.Tez.t;
frozen_deposits : Tez_staking_helpers.Frozen_tez.t;
unstaked_frozen : Tez_staking_helpers.Unstaked_frozen.t;
unstaked_finalizable : Tez_staking_helpers.Unstaked_finalizable.t;
staking_delegator_numerator : Z.t;
staking_delegate_denominator : Z.t;
frozen_rights : Tez_staking_helpers.Tez.t CycleMap.t;
The portion of rights that comes from staking, used for baking/attesting during the specified cycle.
At the end of cycle c
, the current frozen deposits of the delegate (own + co-staked, taking limit_of_staking_over_baking into account) are added to this table for cycle c + consensus_rights_delay + 1
. The table is unmodified if at that time, the account is not a delegate or is a deactivated delegate.
slashed_cycles : Mavryk_alpha_test_helpers.Tez_staking_helpers.Cycle.t list;
last_active_cycle : Mavryk_alpha_test_helpers.Tez_staking_helpers.Cycle.t;
}
Abstract information of accounts
val init_account :
?delegate:string ->
pkh:Mavryk_base.TzPervasives.Signature.Public_key_hash.t ->
contract:Mavryk_protocol_alpha.Protocol.Alpha_context.Contract.t ->
parameters:Adaptive_issuance_helpers.staking_parameters ->
?liquid:Tez_staking_helpers.Tez.t ->
?bonds:Tez_staking_helpers.Tez.t ->
?frozen_deposits:Tez_staking_helpers.Frozen_tez.t ->
?unstaked_frozen:Tez_staking_helpers.Unstaked_frozen.t ->
?unstaked_finalizable:Tez_staking_helpers.Unstaked_finalizable.t ->
?staking_delegator_numerator:Z.t ->
?staking_delegate_denominator:Z.t ->
?frozen_rights:Tez_staking_helpers.Tez.t CycleMap.t ->
?slashed_cycles:Mavryk_alpha_test_helpers.Tez_staking_helpers.Cycle.t list ->
?last_active_cycle:Mavryk_alpha_test_helpers.Tez_staking_helpers.Cycle.cycle ->
unit ->
account_state
type account_map = account_state Mavryk_base.TzPervasives.String.Map.t
type balance = Account_helpers.balance = {
liquid_b : Tez_staking_helpers.Tez.t;
bonds_b : Tez_staking_helpers.Tez.t;
staked_b : Tez_staking_helpers.Partial_tez.t;
unstaked_frozen_b : Tez_staking_helpers.Tez.t;
unstaked_finalizable_b : Tez_staking_helpers.Tez.t;
staking_delegator_numerator_b : Z.t;
staking_delegate_denominator_b : Z.t;
}
Balance returned by RPCs. Partial tez are rounded down
val balance_zero : balance
val balance_of_account :
Mavryk_base.TzPervasives.String.Map.key ->
account_map ->
balance
val balance_pp : Stdlib.Format.formatter -> balance -> unit
val assert_balance_equal :
loc:string ->
string ->
balance ->
balance ->
(unit, Mavryk_base.TzPervasives.tztrace) Stdlib.result Lwt.t
val update_account :
f:('a -> 'b) ->
Mavryk_base.TzPervasives.String.Map.key ->
'c Mavryk_base.TzPervasives.String.Map.t ->
'c Mavryk_base.TzPervasives.String.Map.t
val balance_and_total_balance_of_account :
Mavryk_base.TzPervasives.String.Map.key ->
account_map ->
balance * Tez_staking_helpers.Tez.t
val assert_pseudotokens_consistency :
loc:string ->
balance ->
account_state ->
string ->
account_state Mavryk_base.TzPervasives.String.Map.t ->
unit Mavryk_base.TzPervasives.tzresult Lwt.t
val get_balance_from_context :
Mavryk_alpha_test_helpers__Context.t ->
Mavryk_protocol_alpha.Protocol.Alpha_context.Contract.t ->
(balance * Mavryk_protocol_alpha.Protocol.Alpha_context.Tez.t,
Mavryk_base.TzPervasives.tztrace)
Stdlib.result
Lwt.t
val assert_balance_check :
loc:string ->
Mavryk_alpha_test_helpers__Context.t ->
Mavryk_base.TzPervasives.String.Map.key ->
account_state Mavryk_base.TzPervasives.String.Map.t ->
(unit, Mavryk_base.TzPervasives.tztrace) Stdlib.result Lwt.t
val log_debug_balance :
Mavryk_base.TzPervasives.String.Map.key ->
account_map ->
unit
val log_debug_rpc_balance :
string ->
Mavryk_protocol_alpha.Protocol.Alpha_context.Contract.t ->
Block.t ->
unit Mavryk_base.TzPervasives.tzresult Lwt.t
val log_debug_balance_update :
Mavryk_base.TzPervasives.String.Map.key ->
account_map ->
account_map ->
unit
val current_total_frozen_deposits_with_limits :
account_state ->
Mavryk_protocol_alpha.Protocol.Alpha_context.Tez.t
val add_liquid_rewards :
Tez.t ->
Mavryk_base.TzPervasives.String.Map.key ->
account_state Mavryk_base.TzPervasives.String.Map.t ->
account_state Mavryk_base.TzPervasives.String.Map.t
val stake_from_unstake :
Mavryk_protocol_alpha.Protocol.Alpha_context.Tez.t ->
Cycle.cycle ->
int ->
Mavryk_base.TzPervasives.String.Map.key ->
account_state Mavryk_base.TzPervasives.String.Map.t ->
account_state Mavryk_base.TzPervasives.String.Map.t
* Mavryk_protocol_alpha.Protocol.Alpha_context.Tez.t
val apply_unslashable_f :
Mavryk_protocol_alpha.Protocol.Alpha_context.Cycle.t ->
account_state ->
account_state
val apply_unslashable_for_all :
Mavryk_protocol_alpha.Protocol.Alpha_context.Cycle.t ->
account_state Mavryk_base.TzPervasives.String.Map.t ->
account_state Mavryk_base.TzPervasives.String.Map.t
val compute_future_frozen_rights :
Block.block ->
account_state Mavryk_base.TzPervasives.String.Map.t ->
(account_state Mavryk_base.TzPervasives.String.Map.t,
Mavryk_base.TzPervasives.tztrace)
Stdlib.result
Lwt.t
Compute the staking rights for current_cycle +
consensus_rights_delay + 1
and save them into account.frozen_rights
for each delegate.