cooked-validators
Safe HaskellSafe-Inferred
LanguageHaskell2010

Cooked.Skeleton.Option

Description

This modules provides a variety of options associated with a TxSkel. These options mostly revolves around customizing the default behavior of cooked-validators's transaction generation mechanism.

Synopsis

Data types

type UserConstraints pkh = (ToPubKeyHash pkh, Show pkh, Eq pkh, Typeable pkh) Source #

Set of constraints that need to be satisfied by users in options

data BalanceOutputPolicy Source #

Whether to adjust a potentially existing output to the balancing user with the change during transaction balancing.

Constructors

AdjustExistingOutput

Try to adjust an existing public key output with the change. If no suitable output can be found, create a new change output.

DontAdjustExistingOutput

Do not change the existing outputs, always create a new change output.

data FeePolicy Source #

What fee policy to use in the transaction.

Constructors

AutoFeeComputation

Use automatic fee computation. If balancing is activated, an optimal fee will be computed based on the transaction and existing utxos in the balancing user. Otherwise, the maximum transaction fee will be applied.

ManualFee Integer

Provide a fee to the transaction. If the autobalancing is activated, it will be attempted around this fee, which might lead to failure if it is too low, otherwise, this fee will be given to transaction generation.

Instances

Instances details
Show FeePolicy Source # 
Instance details

Defined in Cooked.Skeleton.Option

Default FeePolicy Source # 
Instance details

Defined in Cooked.Skeleton.Option

Methods

def :: FeePolicy #

Eq FeePolicy Source # 
Instance details

Defined in Cooked.Skeleton.Option

Ord FeePolicy Source # 
Instance details

Defined in Cooked.Skeleton.Option

data BalancingPolicy where Source #

Whether to balance the transaction or not, and which user to use to provide outputs for balancing.

Constructors

BalanceWithFirstSignatory :: BalancingPolicy

Balance with the first signatory of the list of signatories

BalanceWith :: UserConstraints pkh => pkh -> BalancingPolicy

Balance using a given user

DoNotBalance :: BalancingPolicy

Do not perform balancing at all

data BalancingUtxos Source #

Which UTxOs to use when balancing. Note that utxos that are already known by the skeleton being balanced (in the sense of txSkelKnownTxOutRefs, i.e. inputs and reference inputs) will be filtered out during balancing.

Constructors

BalancingUtxosFromBalancingUser

Use all UTxOs containing only a Value (no datum, no staking credential, and no reference script) belonging to the balancing user.

BalancingUtxosFromSet (Set TxOutRef)

Use the provided UTxOs. UTxOs belonging to scripts will be filtered out.

data CollateralUtxos where Source #

Describe which UTxOs to use as collaterals

Constructors

CollateralUtxosFromBalancingUser :: CollateralUtxos

Rely on automated computation with only-value UTxOs from the balancing user. Return collaterals will be sent to this user.

CollateralUtxosFromUser :: UserConstraints pkh => pkh -> CollateralUtxos

Rely on automated computation with only-value UTxOs from a given user. Return collaterals will be sent to this user.

CollateralUtxosFromSet :: UserConstraints pkh => Set TxOutRef -> pkh -> CollateralUtxos

Manually provide a set of candidate UTxOs to be used as collaterals alongside a user to send return collaterals back to.

data TxSkelOpts Source #

Set of options to modify the behavior of generating and validating some transaction.

Constructors

TxSkelOpts 

Fields

  • txSkelOptAutoSlotIncrease :: Bool

    Whether to increase the slot counter automatically on transaction submission. This is useful for modelling transactions that could be submitted in parallel in reality, so there should be no explicit ordering of what comes first.

    Default is True.

  • txSkelOptModTx :: Tx ConwayEra -> Tx ConwayEra

    Applies an arbitrary modification to a transaction after it has been potentially adjusted and balanced. The name of this option contains unsafe to draw attention to the fact that modifying a transaction at that stage might make it invalid. Still, this offers a hook for being able to alter a transaction in unforeseen ways. It is mostly used to test contracts that have been written for custom PABs.

    One interesting use of this function is to observe a transaction just before it is being sent for validation, with

    txSkelOptModTx = [RawModTx Debug.Trace.traceShowId]

    The leftmost function in the list is applied first.

    Default is [].

  • txSkelOptBalancingPolicy :: BalancingPolicy

    Whether to balance the transaction or not, and which user should provide/reclaim the missing and surplus value.

    If you decide to set txSkelOptBalance = DoNotBalance you will have trouble satisfying the balancing equation by hand unless you use ManualFee.

    Default is BalanceWithFirstSignatory

  • txSkelOptFeePolicy :: FeePolicy

    The fee to use when balancing the transaction

    Default is AutoFeeComputation

  • txSkelOptBalanceOutputPolicy :: BalanceOutputPolicy

    The BalanceOutputPolicy to apply when balancing the transaction.

    Default is AdjustExistingOutput.

  • txSkelOptBalancingUtxos :: BalancingUtxos

    Which UTxOs to use during balancing. This can either be a precise list, or rely on automatic searches for utxos with values only belonging to the balancing user.

    Default is BalancingUtxosFromBalancingUser.

  • txSkelOptModParams :: Params -> Params

    Apply an arbitrary modification to the protocol parameters that are used to balance and submit the transaction. This is obviously a very unsafe thing to do if you want to preserve compatibility with the actual chain. It is useful mainly for testing purposes, when you might want to use extremely big transactions or transactions that exhaust the maximum execution budget. Such a thing could be accomplished with

    txSkelOptModParams = Just $ ModParams increaseTransactionLimits

    for example.

    Default is Nothing.

  • txSkelOptCollateralUtxos :: CollateralUtxos

    Which utxos to use as collaterals. They can be given manually, or computed automatically from a given, or the balancing, user.

    Default is CollateralUtxosFromBalancingUser

  • txSkelOptDeferPhase2FailuresDuringBalancing :: Bool

    Whether to defer validation failures occurring during balancing (specifically during the computation of execution units) to the actual later submission of the transaction.

    When set to False: the phase 2 validation failures will be caught as early as possible, typically during balancing when the execution units are computed. This will shortcut the whole balancing process which iterates the body generation, and thus increase performances (by 40%). As a result, the balanced TxSkel will never be computed and thus will be absent from the log, which is the only downside.

    When set to True: the phase 2 validation erros will be ignored during the balancing process. This will result in a worst performance (40%), but will allow the log to display a balanced version of the failing TxSkel, which might be useful. Only use this when debugging complicated phase 2 failures which require a precise view of the balanced TxSkel sent for validation.

    Default is False

  • txSkelOptMaxNbOfBalancingUtxos :: Maybe Integer

    The optional maximum number of Utxos that can be used during balancing. The algorithm which selects Utxos when permorming balancing is greedy. In the default use case where the are only a few wallets and Utxos (the most common case for testing purpose), this is fine. However, if the amount of candidate Utxos is big (let's say, bigger than 15), this is problematic. Use this option to limit the number of Utxos that can be used during the balancing process.

    Alternatively, this can also be used to pilot balancing in some way. For instance, setting this option to Just 1 will result in a single Utxo added in the inputs of the transaction, if such a Utxo exist.

    Default is Nothing

Instances

Instances details
Show TxSkelOpts Source #

Showing TxSkelOpts is possible as long as we ignore modifications to the generated transaction and the parameters.

Instance details

Defined in Cooked.Skeleton.Option

PrettyCookedList TxSkelOpts Source #

Pretty-print a list of transaction skeleton options, only printing an option if its value is non-default.

Instance details

Defined in Cooked.Pretty.Skeleton

Default TxSkelOpts Source # 
Instance details

Defined in Cooked.Skeleton.Option

Methods

def :: TxSkelOpts #

Eq TxSkelOpts Source #

Comparing TxSkelOpts is possible as long as we ignore modifications to the generated transaction and the parameters.

Instance details

Defined in Cooked.Skeleton.Option

PrettyCookedList (TxSkelOpts, [TxSkelSignatory]) Source #

Prints a list of pubkeys with a flag next to the balancing user

Instance details

Defined in Cooked.Pretty.Skeleton

Optics

txSkelOptModTxL :: Lens' TxSkelOpts (Tx ConwayEra -> Tx ConwayEra) Source #

A lens to get or set the Cardano transaction modifications option

txSkelOptAutoSlotIncreaseL :: Lens' TxSkelOpts Bool Source #

A lens to get or set the automatic slot increase option

txSkelOptBalancingPolicyL :: Lens' TxSkelOpts BalancingPolicy Source #

A lens to get or set the balancing policy option

txSkelOptBalanceOutputPolicyL :: Lens' TxSkelOpts BalanceOutputPolicy Source #

A lens to get or set the handling of balancing outputs option

txSkelOptFeePolicyL :: Lens' TxSkelOpts FeePolicy Source #

A lens to get or set the fee policy option

txSkelOptBalancingUtxosL :: Lens' TxSkelOpts BalancingUtxos Source #

A lens to get or set the balancing utxos option

txSkelOptModParamsL :: Lens' TxSkelOpts (Params -> Params) Source #

A lens to get or set the changes to protocol parameters option

txSkelOptCollateralUtxosL :: Lens' TxSkelOpts CollateralUtxos Source #

A lens to get or set the collateral utxos option

txSkelOptDeferPhase2FailuresDuringBalancingL :: Lens' TxSkelOpts Bool Source #

A lens to get or set the deferring of the failures option

txSkelOptMaxNbOfBalancingUtxosL :: Lens' TxSkelOpts (Maybe Integer) Source #

A lens to get or set the max nb of balancing Utxos option

Utilities

txSkelOptAddModTx :: (Tx ConwayEra -> Tx ConwayEra) -> TxSkelOpts -> TxSkelOpts Source #

Appends a transaction modification to the given TxSkelOpts

txSkelOptAddModParams :: (Params -> Params) -> TxSkelOpts -> TxSkelOpts Source #

Appends a parameters modification to the given TxSkelOpts