{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE TypeOperators #-}
module PlutusLedgerApi.Test.V3.EvaluationContext
( costModelParamsForTesting
, mCostModel
, clearMachineCostModel
, clearBuiltinCostModel
) where
import PlutusCore.Evaluation.Machine.BuiltinCostModel
import PlutusCore.Evaluation.Machine.ExBudgetingDefaults
import PlutusCore.Evaluation.Machine.MachineParameters
import PlutusLedgerApi.Test.Common.EvaluationContext as Common
import PlutusLedgerApi.V3 qualified as V3
import PlutusPrelude
import UntypedPlutusCore.Evaluation.Machine.Cek.CekMachineCosts
import Data.Int (Int64)
import Data.Map qualified as Map
import Data.Maybe
costModelParamsForTesting :: [(V3.ParamName, Int64)]
costModelParamsForTesting :: [(ParamName, Int64)]
costModelParamsForTesting = Map ParamName Int64 -> [(ParamName, Int64)]
forall k a. Map k a -> [(k, a)]
Map.toList (Map ParamName Int64 -> [(ParamName, Int64)])
-> Map ParamName Int64 -> [(ParamName, Int64)]
forall a b. (a -> b) -> a -> b
$ Maybe (Map ParamName Int64) -> Map ParamName Int64
forall a. HasCallStack => Maybe a -> a
fromJust (Maybe (Map ParamName Int64) -> Map ParamName Int64)
-> Maybe (Map ParamName Int64) -> Map ParamName Int64
forall a b. (a -> b) -> a -> b
$
MCostModel -> Maybe (Map ParamName Int64)
forall p.
(IsParamName p, Ord p) =>
MCostModel -> Maybe (Map p Int64)
Common.extractCostModelParamsLedgerOrder MCostModel
mCostModel
mCostModel :: MCostModel
mCostModel :: MCostModel
mCostModel =
(CostModel CekMachineCosts BuiltinCostModel -> MCostModel
toMCostModel CostModel CekMachineCosts BuiltinCostModel
defaultCekCostModelForTesting) MCostModel -> (MCostModel -> MCostModel) -> MCostModel
forall a b. a -> (a -> b) -> b
& (MBuiltinCostModel -> Identity MBuiltinCostModel)
-> MCostModel -> Identity MCostModel
forall machinecosts builtincosts1 builtincosts2 (f :: * -> *).
Functor f =>
(builtincosts1 -> f builtincosts2)
-> CostModel machinecosts builtincosts1
-> f (CostModel machinecosts builtincosts2)
builtinCostModel ((MBuiltinCostModel -> Identity MBuiltinCostModel)
-> MCostModel -> Identity MCostModel)
-> (MBuiltinCostModel -> MBuiltinCostModel)
-> MCostModel
-> MCostModel
forall s t a b. ASetter s t a b -> (a -> b) -> s -> t
%~ MBuiltinCostModel -> MBuiltinCostModel
forall m. (m ~ MBuiltinCostModel) => m -> m
clearBuiltinCostModel'
clearMachineCostModel :: (m ~ MCekMachineCosts) => m -> m
clearMachineCostModel :: forall m. (m ~ MCekMachineCosts) => m -> m
clearMachineCostModel m
r = m
r
{ cekConstrCost = mempty
, cekCaseCost = mempty
}
clearBuiltinCostModel :: (m ~ MBuiltinCostModel) => m -> m
clearBuiltinCostModel :: forall m. (m ~ MBuiltinCostModel) => m -> m
clearBuiltinCostModel m
r = m
r
{ paramBls12_381_G1_add = mempty
, paramBls12_381_G1_neg = mempty
, paramBls12_381_G1_scalarMul = mempty
, paramBls12_381_G1_equal = mempty
, paramBls12_381_G1_hashToGroup = mempty
, paramBls12_381_G1_compress = mempty
, paramBls12_381_G1_uncompress = mempty
, paramBls12_381_G2_add = mempty
, paramBls12_381_G2_neg = mempty
, paramBls12_381_G2_scalarMul = mempty
, paramBls12_381_G2_equal = mempty
, paramBls12_381_G2_hashToGroup = mempty
, paramBls12_381_G2_compress = mempty
, paramBls12_381_G2_uncompress = mempty
, paramBls12_381_millerLoop = mempty
, paramBls12_381_mulMlResult = mempty
, paramBls12_381_finalVerify = mempty
, paramKeccak_256 = mempty
, paramBlake2b_224 = mempty
, paramAndByteString = mempty
, paramOrByteString = mempty
, paramXorByteString = mempty
, paramComplementByteString = mempty
, paramReadBit = mempty
, paramWriteBits = mempty
, paramReplicateByte = mempty
, paramShiftByteString = mempty
, paramRotateByteString = mempty
, paramCountSetBits = mempty
, paramFindFirstSetBit = mempty
, paramRipemd_160 = mempty
, paramExpModInteger = mempty
}
clearBuiltinCostModel' :: (m ~ MBuiltinCostModel) => m -> m
clearBuiltinCostModel' :: forall m. (m ~ MBuiltinCostModel) => m -> m
clearBuiltinCostModel' m
r = m
r
{
paramExpModInteger = mempty
}