Module Tezos_alpha_test_helpers.Op

The operation representation handled most often in test helpers.

Assemble the given signature and contents_list into a packed_operation.

The context argument is used to retrieve the branch.

If the signature option argument is None, then the resulting operation is unsigned.

This function is mainly useful to craft an operation with a missing or invalid signatue. Otherwise, it is often better to use one of the helpers below: they handle the signature internally to directly return well-signed operations.

Information needed on the author of a (pre)attestation: slot (written into the (pre)attestation) and consensus key (required for signing).

val attesting_slot_of_attester : Context.attester -> attesting_slot

Builds an attesting_slot with the attester's consensus key and canonical slot, that is, its first slot.

val get_attesting_slot : attested_block:Block.t -> attesting_slot Tezos_base.TzPervasives.tzresult Lwt.t

Returns the canonical attesting_slot of the first attester returned by Plugin.RPC.Validators.S.validators.

val get_attesting_slot_of_delegate : manager_pkh:Tezos_protocol_alpha.Protocol.Alpha_context.public_key_hash -> attested_block:Block.t -> attesting_slot Tezos_base.TzPervasives.tzresult Lwt.t

Returns the canonical attesting_slot of delegate manager_pkh for attested_block. Fails if it doesn't have any attesting rights for this block.

val get_different_attesting_slot : consensus_pkh_to_avoid: Tezos_protocol_alpha.Protocol.Alpha_context.public_key_hash -> attested_block:Block.t -> attesting_slot Tezos_base.TzPervasives.tzresult Lwt.t

Returns the canonical attesting_slot of the first attester returned by Plugin.RPC.Validators.S.validators whose consensus key is different from consensus_pkh_to_avoid.

val non_canonical_attesting_slot_of_attester : Context.attester -> attesting_slot

Builds an attesting_slot with the attester's consensus key and its second-smallest slot (that is, a non-canonical slot that still belongs to the attester).

val get_non_canonical_attesting_slot : attested_block:Block.t -> attesting_slot Tezos_base.TzPervasives.tzresult Lwt.t

Retrieves the first attester returned by Plugin.RPC.Validators.S.validators and builds a non-canonical attesting_slot for it, where slot is its second-smallest slot.

val default_committee : attested_block:Block.t -> attesting_slot list Tezos_base.TzPervasives.tzresult Lwt.t

Default committee for a (pre)attestations aggregate, that is, the canonical attesting slots of all delegates with attesting rights on attested_block whose consensus keys are BLS keys.

val get_attesting_slot_with_bls_key : attested_block:Block.t -> attesting_slot Tezos_base.TzPervasives.tzresult Lwt.t

Returns the canonical attesting_slot of the first attester returned by Plugin.RPC.Validators.S.validators whose consensus key is a BLS key.

val get_attesting_slot_with_non_bls_key : attested_block:Block.t -> attesting_slot Tezos_base.TzPervasives.tzresult Lwt.t

Returns the canonical attesting_slot of the first attester returned by Plugin.RPC.Validators.S.validators whose consensus key is a non-BLS key.

Returns the canonical attesting_slot corresponding to a RPC.Attestation_rights.delegate_rights.

Create an unpacked attestation that is expected for given Block.t.

Optional parameters allow to specify the attested values: level, round, block_payload_hash, and/or dal_content.

The consensus slot and signer are the ones from attesting_slot if provided, otherwise the canonical ones for the delegate with manager_pkh if provided (and the function fails if manager_pkh is not the manager key of a delegate with attesting rights at the given Block.t's level); otherwise, they default to the attesting slot returned by get_attesting_slot. The function fails if both attesting_slot and manager_pkh are provided.

Finally, the operation branch can be specified. It defaults to the predecessor of the attested block.

Create an unpacked preattestation that is expected for a given Block.t.

Optional parameters are the same than raw_attestation.

Create a packed attestation that is expected for a given Block.t by packing the result of raw_attestation.

Crafts an Attestations_aggregate operation pointing to the given Block.t. Block context is expected to include at least one delegate with a BLS consensus key, otherwise this function will return an error.

committee defaults to default_committee with dal_content = None for each member.

Other parameters are the same as in raw_attestation.

Same as raw_preattestations_aggregate but returns the packed operation.

Create a packed preattestation that is expected for a given Block.t by packing the result of raw_preattestation.

Crafts a Preattestations_aggregate operation pointing to the given Block.t. Block context is expected to include at least one delegate with a BLS consensus key, otherwise this function will return an error.

committee defaults to default_committee.

Other parameters are the same as in raw_attestation.

Same as raw_preattestations_aggregate but returns the packed operation.

type gas_limit =
  1. | Max
    (*

    Max corresponds to the max_gas_limit_per_operation constant.

    *)
  2. | High
    (*

    High corresponds to 50_000 gas unit which should cover a majority of use-cases. This is the default used when forging manager operations.

    *)
  3. | Low
    (*

    Low corresponds to the gas entry cost of a manager operation

    *)
  4. | Zero
  5. | Custom_gas of Tezos_protocol_alpha.Protocol.Alpha_context.Gas.Arith.integral
val pp_gas_limit : Stdlib.Format.formatter -> gas_limit -> unit

Pretty printer for gas_limit type.

Packs a manager operation into a contents list.

  • parameter force_reveal

    Prepends the operation to reveal source's public key if the latter has not been revealed yet. Disabled by default (i.e., set to false).

  • parameter counter

    Specifies the expected current counter, meaning that the operation's counter will actually be counter + 1. Defaults to the correct current counter for source in the context.

  • parameter fee

    Specifies the fee. Defaults to Tez.zero.

  • parameter gas_limit

    Specifies the gas limit. Defaults to a high limit of around 50_000 gas units.

  • parameter storage_limit

    Specifies the storage limit. Defaults to Z.of_int 60_000.

  • parameter public_key

    The actual source written in the operation will be the hash of public_key. Defaults to the public key that corresponds to the source argument.

  • parameter source

    Used to retrieve defaults values of counter and public_key.

Same as transaction, but with a more generic destination parameter. It is said unsafe because it can construct transactions that will always fail, such as

  • Transaction to the deposit entrypoint of a transaction rollup, as these transactions are necessarily internals.

Optional arguments allow to override defaults:

  • ?force_reveal:bool: prepend the operation to reveal source's public key if the latter has not been revealed yet. Disabled (set to false) by default.

revelation ?fee ?gas_limit ?forge_pkh ?forge_proof ctxt pkh Creates a new Reveal manager_operation to reveal a public key pkh applying to current context ctxt.

Optional arguments allow to override defaults:

  • ?fee:Tez.t: specify a fee, otherwise set to Tez.zero.
  • ?gas_limit:Gas.Arith.integral: force a gas limit, otherwise set to 10000 gas units.
  • ?forge_pkh: use a provided pkh as source, instead of hashing pkh. Useful for forging non-honest reveal operations
  • ?forge_proof: use a provided proof instead of creating a correct proof for pkh. Useful for forging non-honest reveal operations
  • ?storage_limit:Z.t: forces a storage limit, otherwise set to Z.zero

contract_origination ctxt source Create a new contract origination operation, sign it with source and returns it alongside the contract address. The contract address is using the initial origination nonce with the hash of the operation. If this operation is combined with combine_operations then the contract address is false as the nonce is not based on the correct operation hash.

Optional arguments allow to override defaults:

  • ?force_reveal:bool: prepend the operation to reveal source's public key if the latter has not been revealed yet. Disabled (set to false) by default.

Batch a list of (already signed) operations and (re-)sign with the source. No revelation is inserted and the counters are kept as they are unless recompute_counters is set to true (defaults false).

Reveals a seed_nonce that was previously committed at a certain level

Reveals a VDF with a proof of correctness

Craft the contents_list for a Proposals operation.

Invocation: proposals_contents ctxt source ?period proposals.

  • parameter period

    defaults to the index of the current voting period in ctxt.

Craft a Proposals operation.

Invocation: proposals ctxt source ?period proposals.

  • parameter period

    defaults to the index of the current voting period in ctxt.

Craft the contents_list for a Ballot operation.

Invocation: ballot_contents ctxt source ?period proposal ballot.

  • parameter period

    defaults to the index of the current voting period in ctxt.

Craft a Ballot operation.

Invocation: ballot ctxt source ?period proposal ballot.

  • parameter period

    defaults to the index of the current voting period in ctxt.

transfer_ticket allows an implicit account to transfer tickets they owned.

The arguments are:

  • Context.t: the context on which to apply the operation
  • source:Contract.t: the source contract of the operation
  • Tx_rollup.t: the rollup to which the withdrawal pertains
  • Tx_rollup_level.t: the level on which the withdrawal was commited
  • contents:Script.lazy_expr: the contents of the ticket of the withdrawal
  • ty:Script.lazy_expr: the type of the ticket of the withdrawal
  • ticketer:Contract.t: the ticketer of the ticket of the withdrawal
  • Z.t: the quantity of the ticket of the withdrawal
  • destination:Contract.t: the destination contract that should receive the ticket of the withdrawal
  • Entrypoint_repr.t: the entrypoint of the destination contract to which the ticket should be sent

Optional arguments allow to override defaults:

  • ?force_reveal:bool: prepend the operation to reveal source's public key if the latter has not been revealed yet. Disabled (set to false) by default.

sc_rollup_origination ctxt source kind boot_sector originates a new smart contract rollup of some given kind booting using boot_sector.

Optional arguments allow to override defaults:

  • ?force_reveal:bool: prepend the operation to reveal source's public key if the latter has not been revealed yet. Disabled (set to false) by default.

sc_rollup_publish ctxt source rollup commitment tries to publish a commitment to the SCORU. Optional arguments allow to override defaults:

Optional arguments allow to override defaults:

  • ?force_reveal:bool: prepend the operation to reveal source's public key if the latter has not been revealed yet. Disabled (set to false) by default.

sc_rollup_cement ctxt source rollup tries to cement a commitment.

Optional arguments allow to override defaults:

  • ?force_reveal:bool: prepend the operation to reveal source's public key if the latter has not been revealed yet. Disabled (set to false) by default.

sc_rollup_recover_bond ctxt source sc_rollup staker recovers the commitment bond of staker.

zk_rollup_origination ctxt source ~public_parameters ~circuits_info ~init_state ~nb_ops tries to originate a ZK Rollup.

zk_rollup_publish ctxt source ~zk_rollup ~op tries to add an operation to the pending list of a ZK Rollup.

zk_rollup_update ctxt source ~zk_rollup ~update tries to apply an update to a ZK Rollup.

module Micheline = Tezos_micheline.Micheline

Protocol.mode-related helpers

type tested_mode =
  1. | Application
  2. | Construction
  3. | Mempool

Which Protocol.mode to test.

val check_validation_and_application : loc:string -> ?check_after: (Block.block_with_metadata -> unit Tezos_base.TzPervasives.tzresult Lwt.t) -> ?error:(Tezos_protocol_alpha.Environment.Error_monad.error -> bool) -> predecessor:Block.t -> tested_mode -> t -> unit Tezos_base.TzPervasives.tzresult Lwt.t

check_validation_and_application ~loc ?error ~predecessor tested_mode operation tests the validation and application of operation in tested_mode.

  • When tested_mode is Application or Construction, a block containing operation is baked on top of predecessor in the specified mode.

When check_after is provided, it is called on the resulting block. When error is provided, we check that an error identified by error is returned. When neither is provided, we return unit if there the validation and application returned Ok, or the unchanged error. When both are provided, the function fails.

val check_validation_and_application_all_modes_different_outcomes : loc:string -> ?check_after_application: (Block.block_with_metadata -> unit Tezos_base.TzPervasives.tzresult Lwt.t) -> ?check_after_construction: (Block.block_with_metadata -> unit Tezos_base.TzPervasives.tzresult Lwt.t) -> ?check_after_mempool: (Block.block_with_metadata -> unit Tezos_base.TzPervasives.tzresult Lwt.t) -> ?application_error: (Tezos_protocol_alpha.Environment.Error_monad.error -> bool) -> ?construction_error: (Tezos_protocol_alpha.Environment.Error_monad.error -> bool) -> ?mempool_error:(Tezos_protocol_alpha.Environment.Error_monad.error -> bool) -> predecessor:Block.t -> t -> unit Tezos_base.TzPervasives.tzresult Lwt.t

Calls check_validation_and_application on all tested_modes successively, with respective checks or errors.

val check_validation_and_application_all_modes : loc:string -> ?check_after: (Block.block_with_metadata -> unit Tezos_base.TzPervasives.tzresult Lwt.t) -> ?error:(Tezos_protocol_alpha.Environment.Error_monad.error -> bool) -> predecessor:Block.t -> t -> unit Tezos_base.TzPervasives.tzresult Lwt.t

Calls check_validation_and_application on all tested_modes successively, with the same check_after or error provided for each mode.

val set_op_signature : t -> Tezos_protocol_alpha.Protocol.Alpha_context.signature option -> t
val copy_op_signature : src:t -> dst:t -> t