Mavryk_002_PtBoreas_test_helpers.Block
type t = {
hash : Mavryk_base.TzPervasives.Block_hash.t;
header : Mavryk_protocol_002_PtBoreas.Protocol.Alpha_context.Block_header.t;
operations : Mavryk_protocol_002_PtBoreas.Protocol.Alpha_context.Operation.packed
list;
context : Mavryk_protocol_environment.Context.t;
Resulting context
*)constants : Mavryk_protocol_002_PtBoreas.Protocol.Alpha_context.Constants.Parametric.t;
}
type block = t
val rpc_ctxt : t Mavryk_protocol_002_PtBoreas.Environment.RPC_context.simple
type baker_policy =
| By_round of int
| By_account of Mavryk_protocol_002_PtBoreas.Protocol.Alpha_context.public_key_hash
| Excluding of Mavryk_protocol_002_PtBoreas.Protocol.Alpha_context.public_key_hash
list
Policies to select the next baker:
By_round r
selects the baker at round r
By_account pkh
selects the first slot for baker pkh
Excluding pkhs
selects the first baker that doesn't belong to pkhs
Note that bakers can have active consensus keys different from their regular delegate keys. For the By_account pkh
policy, pkh
refers to the baker's delegate key. However, for the Excluding pkhs
policy, pkhs
refer to the baker's active consensus key.
The default baking functions below is to use (blocks) Application
mode. Setting baking_mode
allows to switch to Full_construction
mode.
type Mavryk_base.TzPervasives.error +=
| No_slots_found_for of Mavryk_base.TzPervasives.Signature.Public_key_hash.t
val get_next_baker :
?policy:baker_policy ->
t ->
(Mavryk_protocol_002_PtBoreas.Protocol.Alpha_context.public_key_hash
* Mavryk_protocol_002_PtBoreas.Protocol.Alpha_context.public_key_hash
* int
* Mavryk_base.TzPervasives.Time.Protocol.t)
Mavryk_base.TzPervasives.tzresult
Lwt.t
Returns (account, consensus_key, round, timestamp) of the next baker given a policy, defaults to By_round 0.
module Forge : sig ... end
val check_constants_consistency :
Mavryk_protocol_002_PtBoreas.Protocol.Alpha_context.Constants.Parametric.t ->
unit Mavryk_base.TzPervasives.tzresult Lwt.t
val genesis :
?commitments:
Mavryk_protocol_002_PtBoreas.Protocol.Alpha_context.Commitment.t list ->
?consensus_committee_size:int ->
?consensus_threshold:int ->
?min_proposal_quorum:int32 ->
?bootstrap_contracts:
Mavryk_protocol_002_PtBoreas.Protocol.Alpha_context.Parameters.bootstrap_contract
list ->
?level:int32 ->
?cost_per_byte:Mavryk_protocol_002_PtBoreas.Protocol.Alpha_context.Tez.t ->
?issuance_weights:
Mavryk_protocol_002_PtBoreas.Protocol.Alpha_context.Constants.Parametric.issuance_weights ->
?origination_size:int ->
?blocks_per_cycle:int32 ->
?cycles_per_voting_period:int32 ->
?sc_rollup_arith_pvm_enable:bool ->
?sc_rollup_private_enable:bool ->
?sc_rollup_riscv_pvm_enable:bool ->
?dal_enable:bool ->
?zk_rollup_enable:bool ->
?hard_gas_limit_per_block:
Mavryk_protocol_002_PtBoreas.Protocol.Alpha_context.Gas.Arith.integral ->
?nonce_revelation_threshold:int32 ->
?dal:
Mavryk_protocol_002_PtBoreas.Protocol.Alpha_context.Constants.Parametric.dal ->
?adaptive_issuance:
Mavryk_protocol_002_PtBoreas.Protocol.Alpha_context.Constants.Parametric.adaptive_issuance ->
Mavryk_protocol_002_PtBoreas.Protocol.Alpha_context.Parameters.bootstrap_account
list ->
block Mavryk_base.TzPervasives.tzresult Lwt.t
genesis <opts> accounts
: generates an initial block with the given constants <opts>
and initializes accounts
with their associated amounts.
val genesis_with_parameters :
Mavryk_protocol_002_PtBoreas.Protocol.Alpha_context.Parameters.t ->
block Mavryk_base.TzPervasives.tzresult Lwt.t
val alpha_context :
?commitments:
Mavryk_protocol_002_PtBoreas.Protocol.Alpha_context.Commitment.t list ->
?min_proposal_quorum:int32 ->
?consensus_rights_delay:int ->
Mavryk_protocol_002_PtBoreas.Protocol.Alpha_context.Parameters.bootstrap_account
list ->
Mavryk_protocol_002_PtBoreas.Protocol.Alpha_context.t
Mavryk_base.TzPervasives.tzresult
Lwt.t
alpha_context <opts> accounts
: instantiates an alpha_context with the given constants <opts>
and initializes accounts
with their associated amounts.
val get_application_vstate :
t ->
Mavryk_protocol_002_PtBoreas.Protocol.operation list ->
(Mavryk_protocol_002_PtBoreas.Protocol.validation_state
* Mavryk_protocol_002_PtBoreas.Protocol.application_state)
Mavryk_base.TzPervasives.tzresult
Lwt.t
get_application_vstate pred operations
constructs a protocol validation environment for operations in application mode on top of the given block with the given operations. It's a shortcut for begin_application
val get_construction_vstate :
?policy:baker_policy ->
?timestamp:Mavryk_protocol_002_PtBoreas.Protocol.Alpha_context.Timestamp.time ->
?protocol_data:Mavryk_protocol_002_PtBoreas.Protocol.block_header_data option ->
block ->
(Mavryk_protocol_002_PtBoreas.Protocol.validation_state
* Mavryk_protocol_002_PtBoreas.Protocol.application_state)
Mavryk_base.TzPervasives.tzresult
Lwt.t
get_construction_vstate ?policy ?timestamp ?protocol_data pred
constructs a protocol validation environment for operations in construction mode on top of the given block. The mode is full(baking)/partial(mempool) if protocol_data
given/absent. It's a shortcut for begin_construction
val apply :
Mavryk_protocol_002_PtBoreas.Protocol.Alpha_context.Block_header.block_header ->
?operations:
Mavryk_protocol_002_PtBoreas.Protocol.Alpha_context.Operation.packed list ->
?allow_manager_failures:bool ->
t ->
t Mavryk_base.TzPervasives.tzresult Lwt.t
applies a signed header and its operations to a block and obtains a new block
val bake :
?baking_mode:baking_mode ->
?allow_manager_failures:bool ->
?payload_round:
Mavryk_protocol_002_PtBoreas.Protocol.Alpha_context.Round.t option ->
?locked_round:
Mavryk_protocol_002_PtBoreas.Protocol.Alpha_context.Round.t option ->
?policy:baker_policy ->
?timestamp:Mavryk_protocol_002_PtBoreas.Protocol.Alpha_context.Timestamp.time ->
?operation:
Mavryk_protocol_002_PtBoreas.Protocol.Alpha_context.Operation.packed ->
?operations:
Mavryk_protocol_002_PtBoreas.Protocol.Alpha_context.Operation.packed list ->
?liquidity_baking_toggle_vote:
Mavryk_protocol_002_PtBoreas.Protocol.Alpha_context.Per_block_votes.per_block_vote ->
?adaptive_issuance_vote:
Mavryk_protocol_002_PtBoreas.Protocol.Alpha_context.Per_block_votes.per_block_vote ->
?check_size:bool ->
t ->
t Mavryk_base.TzPervasives.tzresult Lwt.t
bake b
returns a block b'
which has as predecessor block b
. Optional parameter policy
allows to pick the next baker in several ways. If check_size
is true
(the default case), then the function checks that the operations passed as arguments satisfy the size limit of Tezos operations, as defined in the protocol. This function bundles together forge_header
, sign_header
and apply
. These functions should be used instead of bake to craft unusual blocks for testing together with setters for properties of the headers. Setting allow_manager_failures
(default=false), allows baking blocks with manager operation(s) that are valid but that could fail during their application. If this is not set, the block is correctly baked but the operations' application will fail silently. For examples see seed.ml or double_baking.ml
val bake_with_metadata :
?locked_round:
Mavryk_protocol_002_PtBoreas.Protocol.Alpha_context.Round.t option ->
?policy:baker_policy ->
?timestamp:Mavryk_protocol_002_PtBoreas.Protocol.Alpha_context.Timestamp.time ->
?operation:
Mavryk_protocol_002_PtBoreas.Protocol.Alpha_context.Operation.packed ->
?operations:
Mavryk_protocol_002_PtBoreas.Protocol.Alpha_context.Operation.packed list ->
?payload_round:
Mavryk_protocol_002_PtBoreas.Protocol.Alpha_context.Round.t option ->
?check_size:bool ->
?baking_mode:baking_mode ->
?allow_manager_failures:bool ->
?liquidity_baking_toggle_vote:
Mavryk_protocol_002_PtBoreas.Protocol.Alpha_context.Per_block_votes.per_block_vote ->
?adaptive_issuance_vote:
Mavryk_protocol_002_PtBoreas.Protocol.Alpha_context.Per_block_votes.per_block_vote ->
t ->
(t
* (Mavryk_protocol_002_PtBoreas.Protocol.block_header_metadata
* Mavryk_protocol_002_PtBoreas.Protocol.operation_receipt list))
Mavryk_base.TzPervasives.tzresult
Lwt.t
Variant of bake
that returns the block metadata of the baked block. *
val bake_n :
?baking_mode:baking_mode ->
?policy:baker_policy ->
?liquidity_baking_toggle_vote:
Mavryk_protocol_002_PtBoreas.Protocol.Alpha_context.Per_block_votes.per_block_vote ->
?adaptive_issuance_vote:
Mavryk_protocol_002_PtBoreas.Protocol.Alpha_context.Per_block_votes.per_block_vote ->
int ->
t ->
block Mavryk_base.TzPervasives.tzresult Lwt.t
Bakes n
blocks.
val bake_until_level :
?baking_mode:baking_mode ->
?policy:baker_policy ->
?liquidity_baking_toggle_vote:
Mavryk_protocol_002_PtBoreas.Protocol.Alpha_context.Per_block_votes.per_block_vote ->
?adaptive_issuance_vote:
Mavryk_protocol_002_PtBoreas.Protocol.Alpha_context.Per_block_votes.per_block_vote ->
Mavryk_protocol_002_PtBoreas.Protocol.Alpha_context.Raw_level.t ->
t ->
block Mavryk_base.TzPervasives.tzresult Lwt.t
Bakes until the given level is reached.
val bake_n_with_all_balance_updates :
?baking_mode:baking_mode ->
?policy:baker_policy ->
?liquidity_baking_toggle_vote:
Mavryk_protocol_002_PtBoreas.Protocol.Alpha_context.Per_block_votes.per_block_vote ->
?adaptive_issuance_vote:
Mavryk_protocol_002_PtBoreas.Protocol.Alpha_context.Per_block_votes.per_block_vote ->
int ->
t ->
(block
* Mavryk_protocol_002_PtBoreas.Protocol.Alpha_context.Receipt.balance_updates)
Mavryk_base.TzPervasives.tzresult
Lwt.t
Version of bake_n that returns a list of all balance updates included in the metadata of baked blocks. *
val bake_n_with_origination_results :
?baking_mode:baking_mode ->
?policy:baker_policy ->
int ->
t ->
(block
* Mavryk_protocol_002_PtBoreas.Protocol.Alpha_context.Kind.origination
Mavryk_protocol_002_PtBoreas.Protocol.Apply_results.successful_manager_operation_result
list)
Mavryk_base.TzPervasives.tzresult
Lwt.t
Version of bake_n that returns a list of all origination results in the metadata of baked blocks. *
val bake_n_with_liquidity_baking_toggle_ema :
?baking_mode:baking_mode ->
?policy:baker_policy ->
?liquidity_baking_toggle_vote:
Mavryk_protocol_002_PtBoreas.Protocol.Alpha_context.Per_block_votes.per_block_vote ->
?adaptive_issuance_vote:
Mavryk_protocol_002_PtBoreas.Protocol.Alpha_context.Per_block_votes.per_block_vote ->
int ->
t ->
(block
* Mavryk_protocol_002_PtBoreas.Protocol.Alpha_context.Per_block_votes.Liquidity_baking_toggle_EMA.t)
Mavryk_base.TzPervasives.tzresult
Lwt.t
Version of bake_n that returns the liquidity baking toggle EMA after n
blocks. *
val bake_n_with_metadata :
?locked_round:
Mavryk_protocol_002_PtBoreas.Protocol.Alpha_context.Round.t option ->
?policy:baker_policy ->
?timestamp:Mavryk_protocol_002_PtBoreas.Protocol.Alpha_context.Timestamp.time ->
?payload_round:
Mavryk_protocol_002_PtBoreas.Protocol.Alpha_context.Round.t option ->
?check_size:bool ->
?baking_mode:baking_mode ->
?allow_manager_failures:bool ->
?liquidity_baking_toggle_vote:
Mavryk_protocol_002_PtBoreas.Protocol.Per_block_votes_repr.per_block_vote ->
?adaptive_issuance_vote:
Mavryk_protocol_002_PtBoreas.Protocol.Per_block_votes_repr.per_block_vote ->
int ->
block ->
(block
* (Mavryk_protocol_002_PtBoreas.Protocol.block_header_metadata
* Mavryk_protocol_002_PtBoreas.Protocol.operation_receipt list))
Mavryk_base.TzPervasives.tzresult
Lwt.t
Variant of bake_n
that returns the block metadata of the last baked block. n
must be positive, otherwise a single block is baked. *
val get_balance_updates_from_metadata :
(Mavryk_protocol_002_PtBoreas.Protocol.block_header_metadata
* Mavryk_protocol_002_PtBoreas.Protocol.operation_receipt list) ->
Mavryk_protocol_002_PtBoreas.Protocol.Alpha_context.Receipt.balance_updates
val bake_while :
?baking_mode:baking_mode ->
?policy:baker_policy ->
?liquidity_baking_toggle_vote:
Mavryk_protocol_002_PtBoreas.Protocol.Per_block_votes_repr.per_block_vote ->
?adaptive_issuance_vote:
Mavryk_protocol_002_PtBoreas.Protocol.Per_block_votes_repr.per_block_vote ->
?invariant:(block -> unit Mavryk_base.TzPervasives.tzresult Lwt.t) ->
(block -> bool) ->
block ->
block Mavryk_base.TzPervasives.tzresult Lwt.t
Bake blocks while a predicate over the block holds. The returned block is the last one for which the predicate holds; in case the predicate never holds, the input block is returned. When the optional invariant
argument is provided, it is checked on the input block and on each baked block, including the returned one (the last one satisfy the predicate); it is however not checked on the next block (the first one to invalidate the predicate).
val bake_while_with_metadata :
?baking_mode:baking_mode ->
?policy:baker_policy ->
?liquidity_baking_toggle_vote:
Mavryk_protocol_002_PtBoreas.Protocol.Per_block_votes_repr.per_block_vote ->
?adaptive_issuance_vote:
Mavryk_protocol_002_PtBoreas.Protocol.Per_block_votes_repr.per_block_vote ->
?invariant:(block -> unit Mavryk_base.TzPervasives.tzresult Lwt.t) ->
(block ->
Mavryk_protocol_002_PtBoreas.Protocol.block_header_metadata ->
bool) ->
block ->
(block
* (Mavryk_protocol_002_PtBoreas.Protocol.block_header_metadata option
* Mavryk_protocol_002_PtBoreas.Protocol.block_header_metadata))
Mavryk_base.TzPervasives.tzresult
Lwt.t
val current_cycle_of_level :
blocks_per_cycle:int32 ->
current_level:int32 ->
Mavryk_protocol_002_PtBoreas.Protocol.Alpha_context.Cycle.t
val current_cycle :
block ->
Mavryk_protocol_002_PtBoreas.Protocol.Alpha_context.Cycle.t
val last_block_of_cycle : block -> bool
val bake_until_cycle_end :
?baking_mode:baking_mode ->
?policy:baker_policy ->
t ->
t Mavryk_base.TzPervasives.tzresult Lwt.t
Given a block b
at level l
bakes enough blocks to complete a cycle, that is blocks_per_cycle - (l % blocks_per_cycle)
.
val bake_until_cycle_end_with_metadata :
?baking_mode:baking_mode ->
?policy:baker_policy ->
block ->
(block
* Mavryk_protocol_002_PtBoreas.Protocol.block_header_metadata option
* Mavryk_protocol_002_PtBoreas.Protocol.block_header_metadata)
Mavryk_base.TzPervasives.tzresult
Lwt.t
Given a block b
at level l
bakes enough blocks to complete a cycle, that is blocks_per_cycle - (l % blocks_per_cycle)
.
val bake_until_n_cycle_end :
?baking_mode:baking_mode ->
?policy:baker_policy ->
int ->
t ->
t Mavryk_base.TzPervasives.tzresult Lwt.t
Bakes enough blocks to end n
cycles.
val bake_until_n_cycle_end_with_metadata :
?baking_mode:baking_mode ->
?policy:baker_policy ->
int ->
block ->
(block
* Mavryk_protocol_002_PtBoreas.Protocol.block_header_metadata option
* Mavryk_protocol_002_PtBoreas.Protocol.block_header_metadata)
Mavryk_base.TzPervasives.tzresult
Lwt.t
val bake_until_cycle :
?baking_mode:baking_mode ->
?policy:baker_policy ->
Mavryk_protocol_002_PtBoreas.Protocol.Alpha_context.Cycle.t ->
t ->
t Mavryk_base.TzPervasives.tzresult Lwt.t
Bakes enough blocks to reach the cycle.
val prepare_initial_context_params :
?consensus_committee_size:int ->
?consensus_threshold:int ->
?min_proposal_quorum:int32 ->
?level:int32 ->
?cost_per_byte:Mavryk_protocol_002_PtBoreas.Protocol.Alpha_context.Tez.t ->
?issuance_weights:
Mavryk_protocol_002_PtBoreas.Protocol.Alpha_context.Constants.Parametric.issuance_weights ->
?origination_size:int ->
?blocks_per_cycle:int32 ->
?cycles_per_voting_period:int32 ->
?sc_rollup_arith_pvm_enable:bool ->
?sc_rollup_private_enable:bool ->
?sc_rollup_riscv_pvm_enable:bool ->
?dal_enable:bool ->
?zk_rollup_enable:bool ->
?hard_gas_limit_per_block:
Mavryk_protocol_002_PtBoreas.Protocol.Alpha_context.Gas.Arith.integral ->
?nonce_revelation_threshold:int32 ->
?dal:
Mavryk_protocol_002_PtBoreas.Protocol.Alpha_context.Constants.Parametric.dal ->
?adaptive_issuance:
Mavryk_protocol_002_PtBoreas.Protocol.Alpha_context.Constants.Parametric.adaptive_issuance ->
?consensus_rights_delay:int ->
unit ->
(Mavryk_protocol_002_PtBoreas.Protocol.Alpha_context.Constants.Parametric.t
* Mavryk_protocol_002_PtBoreas.Protocol.Alpha_context.Block_header.shell_header
* Mavryk_base.TzPervasives.Block_hash.t,
Mavryk_base.TzPervasives.tztrace)
Stdlib.result
Lwt.t
Common util function to create parameters for initial_context
function
val autostaked_opt :
Mavryk_protocol_002_PtBoreas.Protocol.Alpha_context.public_key_hash ->
Mavryk_protocol_002_PtBoreas.Protocol.block_header_metadata ->
Mavryk_protocol_002_PtBoreas.Protocol.Alpha_context.Tez.t option
autostaked_opt delegate metadata
returns Some amount
if amount
mav have been staked for the given delegate
. None
otherwise.
val autostaked :
?loc:string ->
Mavryk_protocol_002_PtBoreas.Protocol.Alpha_context.public_key_hash ->
Mavryk_protocol_002_PtBoreas.Protocol.block_header_metadata ->
Mavryk_protocol_002_PtBoreas.Protocol.Alpha_context.Tez.t
same as autostaked_opt
but fails in case autostaking didn't provoke a stake operation.