From 6632c4c452ab90652911921cb191286e57f59b47 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Hurlin?= Date: Tue, 14 Jan 2025 14:53:14 +0100 Subject: [PATCH 1/4] Plutus cost model size: add tests of validation --- cardano-api/src/Cardano/Api.hs | 1 + .../Test/Cardano/Api/Genesis.hs | 58 ++++ .../files/input/genesis/pv1-array-165.json | 169 ++++++++++ .../files/input/genesis/pv1-array-166.json | 170 ++++++++++ .../files/input/genesis/pv1-map-165.json | 172 ++++++++++ .../files/input/genesis/pv1-map-166.json | 173 ++++++++++ .../files/input/genesis/pv2-array-174.json | 178 +++++++++++ .../files/input/genesis/pv2-array-175.json | 179 +++++++++++ .../files/input/genesis/pv2-array-185.json | 189 +++++++++++ .../files/input/genesis/pv2-map-174.json | 178 +++++++++++ .../files/input/genesis/pv3-array-296.json | 300 +++++++++++++++++ .../files/input/genesis/pv3-array-297.json | 301 ++++++++++++++++++ .../files/input/genesis/pv3-map-296.json | 300 +++++++++++++++++ .../files/input/genesis/pv3-map-297.json | 301 ++++++++++++++++++ 14 files changed, 2669 insertions(+) create mode 100644 cardano-api/test/cardano-api-test/files/input/genesis/pv1-array-165.json create mode 100644 cardano-api/test/cardano-api-test/files/input/genesis/pv1-array-166.json create mode 100644 cardano-api/test/cardano-api-test/files/input/genesis/pv1-map-165.json create mode 100644 cardano-api/test/cardano-api-test/files/input/genesis/pv1-map-166.json create mode 100644 cardano-api/test/cardano-api-test/files/input/genesis/pv2-array-174.json create mode 100644 cardano-api/test/cardano-api-test/files/input/genesis/pv2-array-175.json create mode 100644 cardano-api/test/cardano-api-test/files/input/genesis/pv2-array-185.json create mode 100644 cardano-api/test/cardano-api-test/files/input/genesis/pv2-map-174.json create mode 100644 cardano-api/test/cardano-api-test/files/input/genesis/pv3-array-296.json create mode 100644 cardano-api/test/cardano-api-test/files/input/genesis/pv3-array-297.json create mode 100644 cardano-api/test/cardano-api-test/files/input/genesis/pv3-map-296.json create mode 100644 cardano-api/test/cardano-api-test/files/input/genesis/pv3-map-297.json diff --git a/cardano-api/src/Cardano/Api.hs b/cardano-api/src/Cardano/Api.hs index 4ca9994569..af6d1c938c 100644 --- a/cardano-api/src/Cardano/Api.hs +++ b/cardano-api/src/Cardano/Api.hs @@ -622,6 +622,7 @@ module Cardano.Api , ExecutionUnits (..) , ExecutionUnitPrices (..) , CostModel (..) + , CostModels (..) , toAlonzoCostModel , fromAlonzoCostModel , toAlonzoCostModels diff --git a/cardano-api/test/cardano-api-test/Test/Cardano/Api/Genesis.hs b/cardano-api/test/cardano-api-test/Test/Cardano/Api/Genesis.hs index cb2bf380c2..332c017bc7 100644 --- a/cardano-api/test/cardano-api-test/Test/Cardano/Api/Genesis.hs +++ b/cardano-api/test/cardano-api-test/Test/Cardano/Api/Genesis.hs @@ -8,6 +8,7 @@ module Test.Cardano.Api.Genesis ) where +import qualified Cardano.Api as Api (CostModels (..)) import Cardano.Api.Eon.ShelleyBasedEra import Cardano.Api.Eras import Cardano.Api.Genesis @@ -23,6 +24,7 @@ import qualified PlutusLedgerApi.V2 as V2 import qualified Codec.CBOR.Decoding as CBOR import qualified Codec.CBOR.Encoding as CBOR import qualified Codec.CBOR.Write as CBOR +import qualified Data.Aeson as Aeson import qualified Data.ByteString.Lazy as LBS import Data.Either import Data.Int (Int64) @@ -177,8 +179,61 @@ encodeCborInEraCostModels aeo = CBOR.toLazyByteString . toEraCbor' toEraCbor' :: L.CostModels -> CBOR.Encoding toEraCbor' = alonzoEraOnwardsConstraints aeo $ L.toEraCBOR @(ShelleyLedgerEra era) +prop_plutus_costmodel_sizes :: Property +prop_plutus_costmodel_sizes = H.propertyOnce $ do + -- PV1 tests + -- Exact expected number of parameters + testWorks "./test/cardano-api-test/files/input/genesis/pv1-array-166.json" PlutusScriptV1 166 + testWorks "./test/cardano-api-test/files/input/genesis/pv1-map-166.json" PlutusScriptV1 166 + -- TODO This file loads fine, whereas it shouldn't + -- _testFails "./test/cardano-api-test/files/input/genesis/pv1-array-165.json" + _testFails "./test/cardano-api-test/files/input/genesis/pv1-map-165.json" + + -- PV2 tests + -- Babbage has 175 PV2 parameters: + testWorks "./test/cardano-api-test/files/input/genesis/pv2-array-175.json" PlutusScriptV2 175 + -- Conway has 185 PV2 parameters: + testWorks "./test/cardano-api-test/files/input/genesis/pv2-array-185.json" PlutusScriptV2 185 + -- TODO This file loads fine, whereas it shouldn't + -- _testFails "./test/cardano-api-test/files/input/genesis/pv2-array-174.json" + _testFails "./test/cardano-api-test/files/input/genesis/pv2-map-174.json" + + -- PV3 tests + testWorks "./test/cardano-api-test/files/input/genesis/pv3-array-297.json" PlutusScriptV3 297 + -- TODO This file loads fine, whereas it shouldn't + -- _testFails "./test/cardano-api-test/files/input/genesis/pv3-array-296.json" + testWorks "./test/cardano-api-test/files/input/genesis/pv3-map-297.json" PlutusScriptV3 297 + _testFails "./test/cardano-api-test/files/input/genesis/pv3-map-296.json" + where + testWorks filepath whichPlutusVersion expectedSize = do + genesisBs <- H.lbsReadFile filepath + let decoded :: Either String Api.CostModels = Aeson.eitherDecode genesisBs + case decoded of + Left err -> do + H.annotateShow err + H.assert False + Right (Api.CostModels cms) -> do + case M.lookup (AnyPlutusScriptVersion whichPlutusVersion) cms of + Nothing -> do + H.note_ $ show whichPlutusVersion <> " cost model not found in " <> filepath + H.assert False + Just (CostModel model) -> do + length model H.=== expectedSize + pure () + _testFails filepath = do + genesisBs <- H.lbsReadFile filepath + let decoded :: Either String Api.CostModels = Aeson.eitherDecode genesisBs + case decoded of + Left _err -> do + pure () + Right _ -> do + H.note_ $ "Decoding of " <> filepath <> " succeeded, whereas it was expected to fail!" + H.assert False + -- * List all test cases +-- Execute me with: +-- @cabal test cardano-api-test --test-options '-p "/Test.Cardano.Api.Genesis/"'@ tests :: TestTree tests = testGroup @@ -210,4 +265,7 @@ tests = , testProperty "Make sure that last 10 PlutusV2 cost model parameters are the ones we expect" prop_verify_plutus_v2_costmodel + , testProperty + "Make sure that Plutus cost model sizes are validated correctly" + prop_plutus_costmodel_sizes ] diff --git a/cardano-api/test/cardano-api-test/files/input/genesis/pv1-array-165.json b/cardano-api/test/cardano-api-test/files/input/genesis/pv1-array-165.json new file mode 100644 index 0000000000..d381d065a1 --- /dev/null +++ b/cardano-api/test/cardano-api-test/files/input/genesis/pv1-array-165.json @@ -0,0 +1,169 @@ +{ + "PlutusV1": [ + 812, + 1, + 1, + 1000, + 571, + 0, + 1, + 1000, + 24177, + 4, + 1, + 1000, + 32, + 117366, + 10475, + 4, + 23000, + 100, + 23000, + 100, + 23000, + 100, + 23000, + 100, + 23000, + 100, + 23000, + 100, + 100, + 100, + 23000, + 100, + 19537, + 32, + 175354, + 32, + 46417, + 4, + 221973, + 511, + 0, + 1, + 89141, + 32, + 497525, + 14068, + 4, + 2, + 196500, + 453240, + 220, + 0, + 1, + 1, + 1000, + 28662, + 4, + 2, + 245000, + 216773, + 62, + 1, + 1060367, + 12586, + 1, + 208512, + 421, + 1, + 187000, + 1000, + 52998, + 1, + 80436, + 32, + 43249, + 32, + 1000, + 32, + 80556, + 1, + 57667, + 4, + 1000, + 10, + 197145, + 156, + 1, + 197145, + 156, + 1, + 204924, + 473, + 1, + 208896, + 511, + 1, + 52467, + 32, + 64832, + 32, + 65493, + 32, + 22558, + 32, + 16563, + 32, + 76511, + 32, + 196500, + 453240, + 220, + 0, + 1, + 1, + 69522, + 11687, + 0, + 1, + 60091, + 32, + 196500, + 453240, + 220, + 0, + 1, + 1, + 196500, + 453240, + 220, + 0, + 1, + 1, + 806990, + 30482, + 4, + 1927926, + 82523, + 4, + 265318, + 0, + 4, + 0, + 85931, + 32, + 205665, + 812, + 1, + 1, + 41182, + 32, + 212342, + 32, + 31220, + 32, + 32696, + 32, + 43357, + 32, + 32247, + 32, + 38314, + 32, + 9462713, + 1021, + 10 + ] +} diff --git a/cardano-api/test/cardano-api-test/files/input/genesis/pv1-array-166.json b/cardano-api/test/cardano-api-test/files/input/genesis/pv1-array-166.json new file mode 100644 index 0000000000..22b24f7d48 --- /dev/null +++ b/cardano-api/test/cardano-api-test/files/input/genesis/pv1-array-166.json @@ -0,0 +1,170 @@ +{ + "PlutusV1": [ + 205665, + 812, + 1, + 1, + 1000, + 571, + 0, + 1, + 1000, + 24177, + 4, + 1, + 1000, + 32, + 117366, + 10475, + 4, + 23000, + 100, + 23000, + 100, + 23000, + 100, + 23000, + 100, + 23000, + 100, + 23000, + 100, + 100, + 100, + 23000, + 100, + 19537, + 32, + 175354, + 32, + 46417, + 4, + 221973, + 511, + 0, + 1, + 89141, + 32, + 497525, + 14068, + 4, + 2, + 196500, + 453240, + 220, + 0, + 1, + 1, + 1000, + 28662, + 4, + 2, + 245000, + 216773, + 62, + 1, + 1060367, + 12586, + 1, + 208512, + 421, + 1, + 187000, + 1000, + 52998, + 1, + 80436, + 32, + 43249, + 32, + 1000, + 32, + 80556, + 1, + 57667, + 4, + 1000, + 10, + 197145, + 156, + 1, + 197145, + 156, + 1, + 204924, + 473, + 1, + 208896, + 511, + 1, + 52467, + 32, + 64832, + 32, + 65493, + 32, + 22558, + 32, + 16563, + 32, + 76511, + 32, + 196500, + 453240, + 220, + 0, + 1, + 1, + 69522, + 11687, + 0, + 1, + 60091, + 32, + 196500, + 453240, + 220, + 0, + 1, + 1, + 196500, + 453240, + 220, + 0, + 1, + 1, + 806990, + 30482, + 4, + 1927926, + 82523, + 4, + 265318, + 0, + 4, + 0, + 85931, + 32, + 205665, + 812, + 1, + 1, + 41182, + 32, + 212342, + 32, + 31220, + 32, + 32696, + 32, + 43357, + 32, + 32247, + 32, + 38314, + 32, + 9462713, + 1021, + 10 + ] +} diff --git a/cardano-api/test/cardano-api-test/files/input/genesis/pv1-map-165.json b/cardano-api/test/cardano-api-test/files/input/genesis/pv1-map-165.json new file mode 100644 index 0000000000..66f905d51c --- /dev/null +++ b/cardano-api/test/cardano-api-test/files/input/genesis/pv1-map-165.json @@ -0,0 +1,172 @@ +{ + "PlutusV1": { + "addInteger-cpu-arguments-intercept": 205665, + "addInteger-cpu-arguments-slope": 812, + "addInteger-memory-arguments-intercept": 1, + "addInteger-memory-arguments-slope": 1, + "appendByteString-cpu-arguments-intercept": 1000, + "appendByteString-cpu-arguments-slope": 571, + "appendByteString-memory-arguments-intercept": 0, + "appendByteString-memory-arguments-slope": 1, + "appendString-cpu-arguments-intercept": 1000, + "appendString-cpu-arguments-slope": 24177, + "appendString-memory-arguments-intercept": 4, + "appendString-memory-arguments-slope": 1, + "bData-cpu-arguments": 1000, + "bData-memory-arguments": 32, + "blake2b-cpu-arguments-intercept": 117366, + "blake2b-cpu-arguments-slope": 10475, + "blake2b-memory-arguments": 4, + "cekApplyCost-exBudgetCPU": 23000, + "cekApplyCost-exBudgetMemory": 100, + "cekBuiltinCost-exBudgetCPU": 23000, + "cekBuiltinCost-exBudgetMemory": 100, + "cekConstCost-exBudgetCPU": 23000, + "cekConstCost-exBudgetMemory": 100, + "cekDelayCost-exBudgetCPU": 23000, + "cekDelayCost-exBudgetMemory": 100, + "cekForceCost-exBudgetCPU": 23000, + "cekForceCost-exBudgetMemory": 100, + "cekLamCost-exBudgetCPU": 23000, + "cekLamCost-exBudgetMemory": 100, + "cekStartupCost-exBudgetCPU": 100, + "cekStartupCost-exBudgetMemory": 100, + "cekVarCost-exBudgetCPU": 23000, + "cekVarCost-exBudgetMemory": 100, + "chooseData-cpu-arguments": 19537, + "chooseData-memory-arguments": 32, + "chooseList-cpu-arguments": 175354, + "chooseList-memory-arguments": 32, + "chooseUnit-cpu-arguments": 46417, + "chooseUnit-memory-arguments": 4, + "consByteString-cpu-arguments-intercept": 221973, + "consByteString-cpu-arguments-slope": 511, + "consByteString-memory-arguments-intercept": 0, + "consByteString-memory-arguments-slope": 1, + "constrData-cpu-arguments": 89141, + "constrData-memory-arguments": 32, + "decodeUtf8-cpu-arguments-intercept": 497525, + "decodeUtf8-cpu-arguments-slope": 14068, + "decodeUtf8-memory-arguments-intercept": 4, + "decodeUtf8-memory-arguments-slope": 2, + "divideInteger-cpu-arguments-constant": 196500, + "divideInteger-cpu-arguments-model-arguments-intercept": 453240, + "divideInteger-cpu-arguments-model-arguments-slope": 220, + "divideInteger-memory-arguments-intercept": 0, + "divideInteger-memory-arguments-minimum": 1, + "divideInteger-memory-arguments-slope": 1, + "encodeUtf8-cpu-arguments-intercept": 1000, + "encodeUtf8-cpu-arguments-slope": 28662, + "encodeUtf8-memory-arguments-intercept": 4, + "encodeUtf8-memory-arguments-slope": 2, + "equalsByteString-cpu-arguments-constant": 245000, + "equalsByteString-cpu-arguments-intercept": 216773, + "equalsByteString-cpu-arguments-slope": 62, + "equalsByteString-memory-arguments": 1, + "equalsData-cpu-arguments-intercept": 1060367, + "equalsData-cpu-arguments-slope": 12586, + "equalsData-memory-arguments": 1, + "equalsInteger-cpu-arguments-intercept": 208512, + "equalsInteger-cpu-arguments-slope": 421, + "equalsInteger-memory-arguments": 1, + "equalsString-cpu-arguments-constant": 187000, + "equalsString-cpu-arguments-intercept": 1000, + "equalsString-cpu-arguments-slope": 52998, + "equalsString-memory-arguments": 1, + "fstPair-cpu-arguments": 80436, + "fstPair-memory-arguments": 32, + "headList-cpu-arguments": 43249, + "headList-memory-arguments": 32, + "iData-cpu-arguments": 1000, + "iData-memory-arguments": 32, + "ifThenElse-cpu-arguments": 80556, + "ifThenElse-memory-arguments": 1, + "indexByteString-cpu-arguments": 57667, + "indexByteString-memory-arguments": 4, + "lengthOfByteString-cpu-arguments": 1000, + "lengthOfByteString-memory-arguments": 10, + "lessThanByteString-cpu-arguments-intercept": 197145, + "lessThanByteString-cpu-arguments-slope": 156, + "lessThanByteString-memory-arguments": 1, + "lessThanEqualsByteString-cpu-arguments-intercept": 197145, + "lessThanEqualsByteString-cpu-arguments-slope": 156, + "lessThanEqualsByteString-memory-arguments": 1, + "lessThanEqualsInteger-cpu-arguments-intercept": 204924, + "lessThanEqualsInteger-cpu-arguments-slope": 473, + "lessThanEqualsInteger-memory-arguments": 1, + "lessThanInteger-cpu-arguments-intercept": 208896, + "lessThanInteger-cpu-arguments-slope": 511, + "lessThanInteger-memory-arguments": 1, + "listData-cpu-arguments": 52467, + "listData-memory-arguments": 32, + "mapData-cpu-arguments": 64832, + "mapData-memory-arguments": 32, + "mkCons-cpu-arguments": 65493, + "mkCons-memory-arguments": 32, + "mkNilData-cpu-arguments": 22558, + "mkNilData-memory-arguments": 32, + "mkNilPairData-cpu-arguments": 16563, + "mkNilPairData-memory-arguments": 32, + "mkPairData-cpu-arguments": 76511, + "mkPairData-memory-arguments": 32, + "modInteger-cpu-arguments-constant": 196500, + "modInteger-cpu-arguments-model-arguments-intercept": 453240, + "modInteger-cpu-arguments-model-arguments-slope": 220, + "modInteger-memory-arguments-intercept": 0, + "modInteger-memory-arguments-minimum": 1, + "modInteger-memory-arguments-slope": 1, + "multiplyInteger-cpu-arguments-intercept": 69522, + "multiplyInteger-cpu-arguments-slope": 11687, + "multiplyInteger-memory-arguments-intercept": 0, + "multiplyInteger-memory-arguments-slope": 1, + "nullList-cpu-arguments": 60091, + "nullList-memory-arguments": 32, + "quotientInteger-cpu-arguments-constant": 196500, + "quotientInteger-cpu-arguments-model-arguments-intercept": 453240, + "quotientInteger-cpu-arguments-model-arguments-slope": 220, + "quotientInteger-memory-arguments-intercept": 0, + "quotientInteger-memory-arguments-minimum": 1, + "quotientInteger-memory-arguments-slope": 1, + "remainderInteger-cpu-arguments-constant": 196500, + "remainderInteger-cpu-arguments-model-arguments-intercept": 453240, + "remainderInteger-cpu-arguments-model-arguments-slope": 220, + "remainderInteger-memory-arguments-intercept": 0, + "remainderInteger-memory-arguments-minimum": 1, + "remainderInteger-memory-arguments-slope": 1, + "sha2_256-cpu-arguments-intercept": 806990, + "sha2_256-cpu-arguments-slope": 30482, + "sha2_256-memory-arguments": 4, + "sha3_256-cpu-arguments-intercept": 1927926, + "sha3_256-cpu-arguments-slope": 82523, + "sha3_256-memory-arguments": 4, + "sliceByteString-cpu-arguments-intercept": 265318, + "sliceByteString-cpu-arguments-slope": 0, + "sliceByteString-memory-arguments-intercept": 4, + "sliceByteString-memory-arguments-slope": 0, + "sndPair-cpu-arguments": 85931, + "sndPair-memory-arguments": 32, + "subtractInteger-cpu-arguments-intercept": 205665, + "subtractInteger-cpu-arguments-slope": 812, + "subtractInteger-memory-arguments-intercept": 1, + "subtractInteger-memory-arguments-slope": 1, + "tailList-cpu-arguments": 41182, + "tailList-memory-arguments": 32, + "trace-cpu-arguments": 212342, + "trace-memory-arguments": 32, + "unBData-cpu-arguments": 31220, + "unBData-memory-arguments": 32, + "unConstrData-cpu-arguments": 32696, + "unConstrData-memory-arguments": 32, + "unIData-cpu-arguments": 43357, + "unIData-memory-arguments": 32, + "unListData-cpu-arguments": 32247, + "unListData-memory-arguments": 32, + "unMapData-cpu-arguments": 38314, + "unMapData-memory-arguments": 32, + "verifyEd25519Signature-cpu-arguments-intercept": 9462713, + "verifyEd25519Signature-cpu-arguments-slope": 1021, + "verifyEd25519Signature-memory-arguments": 10, + "verifySignature-cpu-arguments-intercept": 3345831, + "verifySignature-cpu-arguments-slope": 1, + } +} diff --git a/cardano-api/test/cardano-api-test/files/input/genesis/pv1-map-166.json b/cardano-api/test/cardano-api-test/files/input/genesis/pv1-map-166.json new file mode 100644 index 0000000000..0d51e4067b --- /dev/null +++ b/cardano-api/test/cardano-api-test/files/input/genesis/pv1-map-166.json @@ -0,0 +1,173 @@ +{ + "PlutusV1": { + "addInteger-cpu-arguments-intercept": 205665, + "addInteger-cpu-arguments-slope": 812, + "addInteger-memory-arguments-intercept": 1, + "addInteger-memory-arguments-slope": 1, + "appendByteString-cpu-arguments-intercept": 1000, + "appendByteString-cpu-arguments-slope": 571, + "appendByteString-memory-arguments-intercept": 0, + "appendByteString-memory-arguments-slope": 1, + "appendString-cpu-arguments-intercept": 1000, + "appendString-cpu-arguments-slope": 24177, + "appendString-memory-arguments-intercept": 4, + "appendString-memory-arguments-slope": 1, + "bData-cpu-arguments": 1000, + "bData-memory-arguments": 32, + "blake2b-cpu-arguments-intercept": 117366, + "blake2b-cpu-arguments-slope": 10475, + "blake2b-memory-arguments": 4, + "cekApplyCost-exBudgetCPU": 23000, + "cekApplyCost-exBudgetMemory": 100, + "cekBuiltinCost-exBudgetCPU": 23000, + "cekBuiltinCost-exBudgetMemory": 100, + "cekConstCost-exBudgetCPU": 23000, + "cekConstCost-exBudgetMemory": 100, + "cekDelayCost-exBudgetCPU": 23000, + "cekDelayCost-exBudgetMemory": 100, + "cekForceCost-exBudgetCPU": 23000, + "cekForceCost-exBudgetMemory": 100, + "cekLamCost-exBudgetCPU": 23000, + "cekLamCost-exBudgetMemory": 100, + "cekStartupCost-exBudgetCPU": 100, + "cekStartupCost-exBudgetMemory": 100, + "cekVarCost-exBudgetCPU": 23000, + "cekVarCost-exBudgetMemory": 100, + "chooseData-cpu-arguments": 19537, + "chooseData-memory-arguments": 32, + "chooseList-cpu-arguments": 175354, + "chooseList-memory-arguments": 32, + "chooseUnit-cpu-arguments": 46417, + "chooseUnit-memory-arguments": 4, + "consByteString-cpu-arguments-intercept": 221973, + "consByteString-cpu-arguments-slope": 511, + "consByteString-memory-arguments-intercept": 0, + "consByteString-memory-arguments-slope": 1, + "constrData-cpu-arguments": 89141, + "constrData-memory-arguments": 32, + "decodeUtf8-cpu-arguments-intercept": 497525, + "decodeUtf8-cpu-arguments-slope": 14068, + "decodeUtf8-memory-arguments-intercept": 4, + "decodeUtf8-memory-arguments-slope": 2, + "divideInteger-cpu-arguments-constant": 196500, + "divideInteger-cpu-arguments-model-arguments-intercept": 453240, + "divideInteger-cpu-arguments-model-arguments-slope": 220, + "divideInteger-memory-arguments-intercept": 0, + "divideInteger-memory-arguments-minimum": 1, + "divideInteger-memory-arguments-slope": 1, + "encodeUtf8-cpu-arguments-intercept": 1000, + "encodeUtf8-cpu-arguments-slope": 28662, + "encodeUtf8-memory-arguments-intercept": 4, + "encodeUtf8-memory-arguments-slope": 2, + "equalsByteString-cpu-arguments-constant": 245000, + "equalsByteString-cpu-arguments-intercept": 216773, + "equalsByteString-cpu-arguments-slope": 62, + "equalsByteString-memory-arguments": 1, + "equalsData-cpu-arguments-intercept": 1060367, + "equalsData-cpu-arguments-slope": 12586, + "equalsData-memory-arguments": 1, + "equalsInteger-cpu-arguments-intercept": 208512, + "equalsInteger-cpu-arguments-slope": 421, + "equalsInteger-memory-arguments": 1, + "equalsString-cpu-arguments-constant": 187000, + "equalsString-cpu-arguments-intercept": 1000, + "equalsString-cpu-arguments-slope": 52998, + "equalsString-memory-arguments": 1, + "fstPair-cpu-arguments": 80436, + "fstPair-memory-arguments": 32, + "headList-cpu-arguments": 43249, + "headList-memory-arguments": 32, + "iData-cpu-arguments": 1000, + "iData-memory-arguments": 32, + "ifThenElse-cpu-arguments": 80556, + "ifThenElse-memory-arguments": 1, + "indexByteString-cpu-arguments": 57667, + "indexByteString-memory-arguments": 4, + "lengthOfByteString-cpu-arguments": 1000, + "lengthOfByteString-memory-arguments": 10, + "lessThanByteString-cpu-arguments-intercept": 197145, + "lessThanByteString-cpu-arguments-slope": 156, + "lessThanByteString-memory-arguments": 1, + "lessThanEqualsByteString-cpu-arguments-intercept": 197145, + "lessThanEqualsByteString-cpu-arguments-slope": 156, + "lessThanEqualsByteString-memory-arguments": 1, + "lessThanEqualsInteger-cpu-arguments-intercept": 204924, + "lessThanEqualsInteger-cpu-arguments-slope": 473, + "lessThanEqualsInteger-memory-arguments": 1, + "lessThanInteger-cpu-arguments-intercept": 208896, + "lessThanInteger-cpu-arguments-slope": 511, + "lessThanInteger-memory-arguments": 1, + "listData-cpu-arguments": 52467, + "listData-memory-arguments": 32, + "mapData-cpu-arguments": 64832, + "mapData-memory-arguments": 32, + "mkCons-cpu-arguments": 65493, + "mkCons-memory-arguments": 32, + "mkNilData-cpu-arguments": 22558, + "mkNilData-memory-arguments": 32, + "mkNilPairData-cpu-arguments": 16563, + "mkNilPairData-memory-arguments": 32, + "mkPairData-cpu-arguments": 76511, + "mkPairData-memory-arguments": 32, + "modInteger-cpu-arguments-constant": 196500, + "modInteger-cpu-arguments-model-arguments-intercept": 453240, + "modInteger-cpu-arguments-model-arguments-slope": 220, + "modInteger-memory-arguments-intercept": 0, + "modInteger-memory-arguments-minimum": 1, + "modInteger-memory-arguments-slope": 1, + "multiplyInteger-cpu-arguments-intercept": 69522, + "multiplyInteger-cpu-arguments-slope": 11687, + "multiplyInteger-memory-arguments-intercept": 0, + "multiplyInteger-memory-arguments-slope": 1, + "nullList-cpu-arguments": 60091, + "nullList-memory-arguments": 32, + "quotientInteger-cpu-arguments-constant": 196500, + "quotientInteger-cpu-arguments-model-arguments-intercept": 453240, + "quotientInteger-cpu-arguments-model-arguments-slope": 220, + "quotientInteger-memory-arguments-intercept": 0, + "quotientInteger-memory-arguments-minimum": 1, + "quotientInteger-memory-arguments-slope": 1, + "remainderInteger-cpu-arguments-constant": 196500, + "remainderInteger-cpu-arguments-model-arguments-intercept": 453240, + "remainderInteger-cpu-arguments-model-arguments-slope": 220, + "remainderInteger-memory-arguments-intercept": 0, + "remainderInteger-memory-arguments-minimum": 1, + "remainderInteger-memory-arguments-slope": 1, + "sha2_256-cpu-arguments-intercept": 806990, + "sha2_256-cpu-arguments-slope": 30482, + "sha2_256-memory-arguments": 4, + "sha3_256-cpu-arguments-intercept": 1927926, + "sha3_256-cpu-arguments-slope": 82523, + "sha3_256-memory-arguments": 4, + "sliceByteString-cpu-arguments-intercept": 265318, + "sliceByteString-cpu-arguments-slope": 0, + "sliceByteString-memory-arguments-intercept": 4, + "sliceByteString-memory-arguments-slope": 0, + "sndPair-cpu-arguments": 85931, + "sndPair-memory-arguments": 32, + "subtractInteger-cpu-arguments-intercept": 205665, + "subtractInteger-cpu-arguments-slope": 812, + "subtractInteger-memory-arguments-intercept": 1, + "subtractInteger-memory-arguments-slope": 1, + "tailList-cpu-arguments": 41182, + "tailList-memory-arguments": 32, + "trace-cpu-arguments": 212342, + "trace-memory-arguments": 32, + "unBData-cpu-arguments": 31220, + "unBData-memory-arguments": 32, + "unConstrData-cpu-arguments": 32696, + "unConstrData-memory-arguments": 32, + "unIData-cpu-arguments": 43357, + "unIData-memory-arguments": 32, + "unListData-cpu-arguments": 32247, + "unListData-memory-arguments": 32, + "unMapData-cpu-arguments": 38314, + "unMapData-memory-arguments": 32, + "verifyEd25519Signature-cpu-arguments-intercept": 9462713, + "verifyEd25519Signature-cpu-arguments-slope": 1021, + "verifyEd25519Signature-memory-arguments": 10, + "verifySignature-cpu-arguments-intercept": 3345831, + "verifySignature-cpu-arguments-slope": 1, + "verifySignature-memory-arguments": 1 + } +} diff --git a/cardano-api/test/cardano-api-test/files/input/genesis/pv2-array-174.json b/cardano-api/test/cardano-api-test/files/input/genesis/pv2-array-174.json new file mode 100644 index 0000000000..8c3bfe5ffb --- /dev/null +++ b/cardano-api/test/cardano-api-test/files/input/genesis/pv2-array-174.json @@ -0,0 +1,178 @@ +{ + "PlutusV2": [ + 812, + 1, + 1, + 1000, + 571, + 0, + 1, + 1000, + 24177, + 4, + 1, + 1000, + 32, + 117366, + 10475, + 4, + 23000, + 100, + 23000, + 100, + 23000, + 100, + 23000, + 100, + 23000, + 100, + 23000, + 100, + 100, + 100, + 23000, + 100, + 19537, + 32, + 175354, + 32, + 46417, + 4, + 221973, + 511, + 0, + 1, + 89141, + 32, + 497525, + 14068, + 4, + 2, + 196500, + 453240, + 220, + 0, + 1, + 1, + 1000, + 28662, + 4, + 2, + 245000, + 216773, + 62, + 1, + 1060367, + 12586, + 1, + 208512, + 421, + 1, + 187000, + 1000, + 52998, + 1, + 80436, + 32, + 43249, + 32, + 1000, + 32, + 80556, + 1, + 57667, + 4, + 1000, + 10, + 197145, + 156, + 1, + 197145, + 156, + 1, + 204924, + 473, + 1, + 208896, + 511, + 1, + 52467, + 32, + 64832, + 32, + 65493, + 32, + 22558, + 32, + 16563, + 32, + 76511, + 32, + 196500, + 453240, + 220, + 0, + 1, + 1, + 69522, + 11687, + 0, + 1, + 60091, + 32, + 196500, + 453240, + 220, + 0, + 1, + 1, + 196500, + 453240, + 220, + 0, + 1, + 1, + 1159724, + 392670, + 0, + 2, + 806990, + 30482, + 4, + 1927926, + 82523, + 4, + 265318, + 0, + 4, + 0, + 85931, + 32, + 205665, + 812, + 1, + 1, + 41182, + 32, + 212342, + 32, + 31220, + 32, + 32696, + 32, + 43357, + 32, + 32247, + 32, + 38314, + 32, + 35892428, + 10, + 9462713, + 1021, + 10, + 38887044, + 32947, + 10 + ] +} diff --git a/cardano-api/test/cardano-api-test/files/input/genesis/pv2-array-175.json b/cardano-api/test/cardano-api-test/files/input/genesis/pv2-array-175.json new file mode 100644 index 0000000000..73ab34c881 --- /dev/null +++ b/cardano-api/test/cardano-api-test/files/input/genesis/pv2-array-175.json @@ -0,0 +1,179 @@ +{ + "PlutusV2": [ + 205665, + 812, + 1, + 1, + 1000, + 571, + 0, + 1, + 1000, + 24177, + 4, + 1, + 1000, + 32, + 117366, + 10475, + 4, + 23000, + 100, + 23000, + 100, + 23000, + 100, + 23000, + 100, + 23000, + 100, + 23000, + 100, + 100, + 100, + 23000, + 100, + 19537, + 32, + 175354, + 32, + 46417, + 4, + 221973, + 511, + 0, + 1, + 89141, + 32, + 497525, + 14068, + 4, + 2, + 196500, + 453240, + 220, + 0, + 1, + 1, + 1000, + 28662, + 4, + 2, + 245000, + 216773, + 62, + 1, + 1060367, + 12586, + 1, + 208512, + 421, + 1, + 187000, + 1000, + 52998, + 1, + 80436, + 32, + 43249, + 32, + 1000, + 32, + 80556, + 1, + 57667, + 4, + 1000, + 10, + 197145, + 156, + 1, + 197145, + 156, + 1, + 204924, + 473, + 1, + 208896, + 511, + 1, + 52467, + 32, + 64832, + 32, + 65493, + 32, + 22558, + 32, + 16563, + 32, + 76511, + 32, + 196500, + 453240, + 220, + 0, + 1, + 1, + 69522, + 11687, + 0, + 1, + 60091, + 32, + 196500, + 453240, + 220, + 0, + 1, + 1, + 196500, + 453240, + 220, + 0, + 1, + 1, + 1159724, + 392670, + 0, + 2, + 806990, + 30482, + 4, + 1927926, + 82523, + 4, + 265318, + 0, + 4, + 0, + 85931, + 32, + 205665, + 812, + 1, + 1, + 41182, + 32, + 212342, + 32, + 31220, + 32, + 32696, + 32, + 43357, + 32, + 32247, + 32, + 38314, + 32, + 35892428, + 10, + 9462713, + 1021, + 10, + 38887044, + 32947, + 10 + ] +} diff --git a/cardano-api/test/cardano-api-test/files/input/genesis/pv2-array-185.json b/cardano-api/test/cardano-api-test/files/input/genesis/pv2-array-185.json new file mode 100644 index 0000000000..27cfcaa241 --- /dev/null +++ b/cardano-api/test/cardano-api-test/files/input/genesis/pv2-array-185.json @@ -0,0 +1,189 @@ +{ + "PlutusV2": [ + 205665, + 812, + 1, + 1, + 1000, + 571, + 0, + 1, + 1000, + 24177, + 4, + 1, + 1000, + 32, + 117366, + 10475, + 4, + 23000, + 100, + 23000, + 100, + 23000, + 100, + 23000, + 100, + 23000, + 100, + 23000, + 100, + 100, + 100, + 23000, + 100, + 19537, + 32, + 175354, + 32, + 46417, + 4, + 221973, + 511, + 0, + 1, + 89141, + 32, + 497525, + 14068, + 4, + 2, + 196500, + 453240, + 220, + 0, + 1, + 1, + 1000, + 28662, + 4, + 2, + 245000, + 216773, + 62, + 1, + 1060367, + 12586, + 1, + 208512, + 421, + 1, + 187000, + 1000, + 52998, + 1, + 80436, + 32, + 43249, + 32, + 1000, + 32, + 80556, + 1, + 57667, + 4, + 1000, + 10, + 197145, + 156, + 1, + 197145, + 156, + 1, + 204924, + 473, + 1, + 208896, + 511, + 1, + 52467, + 32, + 64832, + 32, + 65493, + 32, + 22558, + 32, + 16563, + 32, + 76511, + 32, + 196500, + 453240, + 220, + 0, + 1, + 1, + 69522, + 11687, + 0, + 1, + 60091, + 32, + 196500, + 453240, + 220, + 0, + 1, + 1, + 196500, + 453240, + 220, + 0, + 1, + 1, + 1159724, + 392670, + 0, + 2, + 806990, + 30482, + 4, + 1927926, + 82523, + 4, + 265318, + 0, + 4, + 0, + 85931, + 32, + 205665, + 812, + 1, + 1, + 41182, + 32, + 212342, + 32, + 31220, + 32, + 32696, + 32, + 43357, + 32, + 32247, + 32, + 38314, + 32, + 35892428, + 10, + 9462713, + 1021, + 10, + 38887044, + 32947, + 10, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0 + ] +} diff --git a/cardano-api/test/cardano-api-test/files/input/genesis/pv2-map-174.json b/cardano-api/test/cardano-api-test/files/input/genesis/pv2-map-174.json new file mode 100644 index 0000000000..404a42b9b8 --- /dev/null +++ b/cardano-api/test/cardano-api-test/files/input/genesis/pv2-map-174.json @@ -0,0 +1,178 @@ +{ + "PlutusV2": { + "addInteger-cpu-arguments-intercept": 205665, + "addInteger-cpu-arguments-slope": 812, + "addInteger-memory-arguments-intercept": 1, + "addInteger-memory-arguments-slope": 1, + "appendByteString-cpu-arguments-intercept": 1000, + "appendByteString-cpu-arguments-slope": 571, + "appendByteString-memory-arguments-intercept": 0, + "appendByteString-memory-arguments-slope": 1, + "appendString-cpu-arguments-intercept": 1000, + "appendString-cpu-arguments-slope": 24177, + "appendString-memory-arguments-intercept": 4, + "appendString-memory-arguments-slope": 1, + "bData-cpu-arguments": 1000, + "bData-memory-arguments": 32, + "blake2b_256-cpu-arguments-intercept": 117366, + "blake2b_256-cpu-arguments-slope": 10475, + "blake2b_256-memory-arguments": 4, + "cekApplyCost-exBudgetCPU": 23000, + "cekApplyCost-exBudgetMemory": 100, + "cekBuiltinCost-exBudgetCPU": 23000, + "cekBuiltinCost-exBudgetMemory": 100, + "cekConstCost-exBudgetCPU": 23000, + "cekConstCost-exBudgetMemory": 100, + "cekDelayCost-exBudgetCPU": 23000, + "cekDelayCost-exBudgetMemory": 100, + "cekForceCost-exBudgetCPU": 23000, + "cekForceCost-exBudgetMemory": 100, + "cekLamCost-exBudgetCPU": 23000, + "cekLamCost-exBudgetMemory": 100, + "cekStartupCost-exBudgetCPU": 100, + "cekStartupCost-exBudgetMemory": 100, + "cekVarCost-exBudgetCPU": 23000, + "cekVarCost-exBudgetMemory": 100, + "chooseData-cpu-arguments": 19537, + "chooseData-memory-arguments": 32, + "chooseList-cpu-arguments": 175354, + "chooseList-memory-arguments": 32, + "chooseUnit-cpu-arguments": 46417, + "chooseUnit-memory-arguments": 4, + "consByteString-cpu-arguments-intercept": 221973, + "consByteString-cpu-arguments-slope": 511, + "consByteString-memory-arguments-intercept": 0, + "consByteString-memory-arguments-slope": 1, + "constrData-cpu-arguments": 89141, + "constrData-memory-arguments": 32, + "decodeUtf8-cpu-arguments-intercept": 497525, + "decodeUtf8-cpu-arguments-slope": 14068, + "decodeUtf8-memory-arguments-intercept": 4, + "decodeUtf8-memory-arguments-slope": 2, + "divideInteger-cpu-arguments-constant": 196500, + "divideInteger-cpu-arguments-model-arguments-intercept": 453240, + "divideInteger-cpu-arguments-model-arguments-slope": 220, + "divideInteger-memory-arguments-intercept": 0, + "divideInteger-memory-arguments-minimum": 1, + "divideInteger-memory-arguments-slope": 1, + "encodeUtf8-cpu-arguments-intercept": 1000, + "encodeUtf8-cpu-arguments-slope": 28662, + "encodeUtf8-memory-arguments-intercept": 4, + "encodeUtf8-memory-arguments-slope": 2, + "equalsByteString-cpu-arguments-constant": 245000, + "equalsByteString-cpu-arguments-intercept": 216773, + "equalsByteString-cpu-arguments-slope": 62, + "equalsByteString-memory-arguments": 1, + "equalsData-cpu-arguments-intercept": 1060367, + "equalsData-cpu-arguments-slope": 12586, + "equalsData-memory-arguments": 1, + "equalsInteger-cpu-arguments-intercept": 208512, + "equalsInteger-cpu-arguments-slope": 421, + "equalsInteger-memory-arguments": 1, + "equalsString-cpu-arguments-constant": 187000, + "equalsString-cpu-arguments-intercept": 1000, + "equalsString-cpu-arguments-slope": 52998, + "equalsString-memory-arguments": 1, + "fstPair-cpu-arguments": 80436, + "fstPair-memory-arguments": 32, + "headList-cpu-arguments": 43249, + "headList-memory-arguments": 32, + "iData-cpu-arguments": 1000, + "iData-memory-arguments": 32, + "ifThenElse-cpu-arguments": 80556, + "ifThenElse-memory-arguments": 1, + "indexByteString-cpu-arguments": 57667, + "indexByteString-memory-arguments": 4, + "lengthOfByteString-cpu-arguments": 1000, + "lengthOfByteString-memory-arguments": 10, + "lessThanByteString-cpu-arguments-intercept": 197145, + "lessThanByteString-cpu-arguments-slope": 156, + "lessThanByteString-memory-arguments": 1, + "lessThanEqualsByteString-cpu-arguments-intercept": 197145, + "lessThanEqualsByteString-cpu-arguments-slope": 156, + "lessThanEqualsByteString-memory-arguments": 1, + "lessThanEqualsInteger-cpu-arguments-intercept": 204924, + "lessThanEqualsInteger-cpu-arguments-slope": 473, + "lessThanEqualsInteger-memory-arguments": 1, + "lessThanInteger-cpu-arguments-intercept": 208896, + "lessThanInteger-cpu-arguments-slope": 511, + "lessThanInteger-memory-arguments": 1, + "listData-cpu-arguments": 52467, + "listData-memory-arguments": 32, + "mapData-cpu-arguments": 64832, + "mapData-memory-arguments": 32, + "mkCons-cpu-arguments": 65493, + "mkCons-memory-arguments": 32, + "mkNilData-cpu-arguments": 22558, + "mkNilData-memory-arguments": 32, + "mkNilPairData-cpu-arguments": 16563, + "mkNilPairData-memory-arguments": 32, + "mkPairData-cpu-arguments": 76511, + "mkPairData-memory-arguments": 32, + "modInteger-cpu-arguments-constant": 196500, + "modInteger-cpu-arguments-model-arguments-intercept": 453240, + "modInteger-cpu-arguments-model-arguments-slope": 220, + "modInteger-memory-arguments-intercept": 0, + "modInteger-memory-arguments-minimum": 1, + "modInteger-memory-arguments-slope": 1, + "multiplyInteger-cpu-arguments-intercept": 69522, + "multiplyInteger-cpu-arguments-slope": 11687, + "multiplyInteger-memory-arguments-intercept": 0, + "multiplyInteger-memory-arguments-slope": 1, + "nullList-cpu-arguments": 60091, + "nullList-memory-arguments": 32, + "quotientInteger-cpu-arguments-constant": 196500, + "quotientInteger-cpu-arguments-model-arguments-intercept": 453240, + "quotientInteger-cpu-arguments-model-arguments-slope": 220, + "quotientInteger-memory-arguments-intercept": 0, + "quotientInteger-memory-arguments-minimum": 1, + "quotientInteger-memory-arguments-slope": 1, + "remainderInteger-cpu-arguments-constant": 196500, + "remainderInteger-cpu-arguments-model-arguments-intercept": 453240, + "remainderInteger-cpu-arguments-model-arguments-slope": 220, + "remainderInteger-memory-arguments-intercept": 0, + "remainderInteger-memory-arguments-minimum": 1, + "remainderInteger-memory-arguments-slope": 1, + "serialiseData-cpu-arguments-intercept": 1159724, + "serialiseData-cpu-arguments-slope": 392670, + "serialiseData-memory-arguments-intercept": 0, + "serialiseData-memory-arguments-slope": 2, + "sha2_256-cpu-arguments-intercept": 806990, + "sha2_256-cpu-arguments-slope": 30482, + "sha2_256-memory-arguments": 4, + "sha3_256-cpu-arguments-intercept": 1927926, + "sha3_256-cpu-arguments-slope": 82523, + "sha3_256-memory-arguments": 4, + "sliceByteString-cpu-arguments-intercept": 265318, + "sliceByteString-cpu-arguments-slope": 0, + "sliceByteString-memory-arguments-intercept": 4, + "sliceByteString-memory-arguments-slope": 0, + "sndPair-cpu-arguments": 85931, + "sndPair-memory-arguments": 32, + "subtractInteger-cpu-arguments-intercept": 205665, + "subtractInteger-cpu-arguments-slope": 812, + "subtractInteger-memory-arguments-intercept": 1, + "subtractInteger-memory-arguments-slope": 1, + "tailList-cpu-arguments": 41182, + "tailList-memory-arguments": 32, + "trace-cpu-arguments": 212342, + "trace-memory-arguments": 32, + "unBData-cpu-arguments": 31220, + "unBData-memory-arguments": 32, + "unConstrData-cpu-arguments": 32696, + "unConstrData-memory-arguments": 32, + "unIData-cpu-arguments": 43357, + "unIData-memory-arguments": 32, + "unListData-cpu-arguments": 32247, + "unListData-memory-arguments": 32, + "unMapData-cpu-arguments": 38314, + "unMapData-memory-arguments": 32, + "verifyEcdsaSecp256k1Signature-cpu-arguments": 35892428, + "verifyEcdsaSecp256k1Signature-memory-arguments": 10, + "verifyEd25519Signature-cpu-arguments-intercept": 57996947, + "verifyEd25519Signature-cpu-arguments-slope": 18975, + "verifyEd25519Signature-memory-arguments": 10, + "verifySchnorrSecp256k1Signature-cpu-arguments-intercept": 38887044, + "verifySchnorrSecp256k1Signature-cpu-arguments-slope": 32947, + } +} diff --git a/cardano-api/test/cardano-api-test/files/input/genesis/pv3-array-296.json b/cardano-api/test/cardano-api-test/files/input/genesis/pv3-array-296.json new file mode 100644 index 0000000000..a977dd3646 --- /dev/null +++ b/cardano-api/test/cardano-api-test/files/input/genesis/pv3-array-296.json @@ -0,0 +1,300 @@ +{ + "PlutusV3": [ + 100788, + 420, + 1, + 1, + 1000, + 173, + 0, + 1, + 1000, + 59957, + 4, + 1, + 11183, + 32, + 201305, + 8356, + 4, + 16000, + 100, + 16000, + 100, + 16000, + 100, + 16000, + 100, + 16000, + 100, + 16000, + 100, + 100, + 100, + 16000, + 100, + 94375, + 32, + 132994, + 32, + 61462, + 4, + 72010, + 178, + 0, + 1, + 22151, + 32, + 91189, + 769, + 4, + 2, + 85848, + 123203, + 7305, + -900, + 1716, + 549, + 57, + 85848, + 0, + 1, + 1, + 1000, + 42921, + 4, + 2, + 24548, + 29498, + 38, + 1, + 898148, + 27279, + 1, + 51775, + 558, + 1, + 39184, + 1000, + 60594, + 1, + 141895, + 32, + 83150, + 32, + 15299, + 32, + 76049, + 1, + 13169, + 4, + 22100, + 10, + 28999, + 74, + 1, + 28999, + 74, + 1, + 43285, + 552, + 1, + 44749, + 541, + 1, + 33852, + 32, + 68246, + 32, + 72362, + 32, + 7243, + 32, + 7391, + 32, + 11546, + 32, + 85848, + 123203, + 7305, + -900, + 1716, + 549, + 57, + 85848, + 0, + 1, + 90434, + 519, + 0, + 1, + 74433, + 32, + 85848, + 123203, + 7305, + -900, + 1716, + 549, + 57, + 85848, + 0, + 1, + 1, + 85848, + 123203, + 7305, + -900, + 1716, + 549, + 57, + 85848, + 0, + 1, + 955506, + 213312, + 0, + 2, + 270652, + 22588, + 4, + 1457325, + 64566, + 4, + 20467, + 1, + 4, + 0, + 141992, + 32, + 100788, + 420, + 1, + 1, + 81663, + 32, + 59498, + 32, + 20142, + 32, + 24588, + 32, + 20744, + 32, + 25933, + 32, + 24623, + 32, + 43053543, + 10, + 53384111, + 14333, + 10, + 43574283, + 26308, + 10, + 16000, + 100, + 16000, + 100, + 962335, + 18, + 2780678, + 6, + 442008, + 1, + 52538055, + 3756, + 18, + 267929, + 18, + 76433006, + 8868, + 18, + 52948122, + 18, + 1995836, + 36, + 3227919, + 12, + 901022, + 1, + 166917843, + 4307, + 36, + 284546, + 36, + 158221314, + 26549, + 36, + 74698472, + 36, + 333849714, + 1, + 254006273, + 72, + 2174038, + 72, + 2261318, + 64571, + 4, + 207616, + 8310, + 4, + 1293828, + 28716, + 63, + 0, + 1, + 1006041, + 43623, + 251, + 0, + 1, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0 + ] +} diff --git a/cardano-api/test/cardano-api-test/files/input/genesis/pv3-array-297.json b/cardano-api/test/cardano-api-test/files/input/genesis/pv3-array-297.json new file mode 100644 index 0000000000..42898f5c3b --- /dev/null +++ b/cardano-api/test/cardano-api-test/files/input/genesis/pv3-array-297.json @@ -0,0 +1,301 @@ +{ + "PlutusV3": [ + 100788, + 420, + 1, + 1, + 1000, + 173, + 0, + 1, + 1000, + 59957, + 4, + 1, + 11183, + 32, + 201305, + 8356, + 4, + 16000, + 100, + 16000, + 100, + 16000, + 100, + 16000, + 100, + 16000, + 100, + 16000, + 100, + 100, + 100, + 16000, + 100, + 94375, + 32, + 132994, + 32, + 61462, + 4, + 72010, + 178, + 0, + 1, + 22151, + 32, + 91189, + 769, + 4, + 2, + 85848, + 123203, + 7305, + -900, + 1716, + 549, + 57, + 85848, + 0, + 1, + 1, + 1000, + 42921, + 4, + 2, + 24548, + 29498, + 38, + 1, + 898148, + 27279, + 1, + 51775, + 558, + 1, + 39184, + 1000, + 60594, + 1, + 141895, + 32, + 83150, + 32, + 15299, + 32, + 76049, + 1, + 13169, + 4, + 22100, + 10, + 28999, + 74, + 1, + 28999, + 74, + 1, + 43285, + 552, + 1, + 44749, + 541, + 1, + 33852, + 32, + 68246, + 32, + 72362, + 32, + 7243, + 32, + 7391, + 32, + 11546, + 32, + 85848, + 123203, + 7305, + -900, + 1716, + 549, + 57, + 85848, + 0, + 1, + 90434, + 519, + 0, + 1, + 74433, + 32, + 85848, + 123203, + 7305, + -900, + 1716, + 549, + 57, + 85848, + 0, + 1, + 1, + 85848, + 123203, + 7305, + -900, + 1716, + 549, + 57, + 85848, + 0, + 1, + 955506, + 213312, + 0, + 2, + 270652, + 22588, + 4, + 1457325, + 64566, + 4, + 20467, + 1, + 4, + 0, + 141992, + 32, + 100788, + 420, + 1, + 1, + 81663, + 32, + 59498, + 32, + 20142, + 32, + 24588, + 32, + 20744, + 32, + 25933, + 32, + 24623, + 32, + 43053543, + 10, + 53384111, + 14333, + 10, + 43574283, + 26308, + 10, + 16000, + 100, + 16000, + 100, + 962335, + 18, + 2780678, + 6, + 442008, + 1, + 52538055, + 3756, + 18, + 267929, + 18, + 76433006, + 8868, + 18, + 52948122, + 18, + 1995836, + 36, + 3227919, + 12, + 901022, + 1, + 166917843, + 4307, + 36, + 284546, + 36, + 158221314, + 26549, + 36, + 74698472, + 36, + 333849714, + 1, + 254006273, + 72, + 2174038, + 72, + 2261318, + 64571, + 4, + 207616, + 8310, + 4, + 1293828, + 28716, + 63, + 0, + 1, + 1006041, + 43623, + 251, + 0, + 1, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0 + ] +} diff --git a/cardano-api/test/cardano-api-test/files/input/genesis/pv3-map-296.json b/cardano-api/test/cardano-api-test/files/input/genesis/pv3-map-296.json new file mode 100644 index 0000000000..724218cff0 --- /dev/null +++ b/cardano-api/test/cardano-api-test/files/input/genesis/pv3-map-296.json @@ -0,0 +1,300 @@ +{ + "PlutusV3": { + "addInteger-cpu-arguments-slope": 0, + "addInteger-memory-arguments-intercept": 0, + "addInteger-memory-arguments-slope": 0, + "appendByteString-cpu-arguments-intercept": 0, + "appendByteString-cpu-arguments-slope": 0, + "appendByteString-memory-arguments-intercept": 0, + "appendByteString-memory-arguments-slope": 0, + "appendString-cpu-arguments-intercept": 0, + "appendString-cpu-arguments-slope": 0, + "appendString-memory-arguments-intercept": 0, + "appendString-memory-arguments-slope": 0, + "bData-cpu-arguments": 0, + "bData-memory-arguments": 0, + "blake2b_256-cpu-arguments-intercept": 0, + "blake2b_256-cpu-arguments-slope": 0, + "blake2b_256-memory-arguments": 0, + "cekApplyCost-exBudgetCPU": 0, + "cekApplyCost-exBudgetMemory": 0, + "cekBuiltinCost-exBudgetCPU": 0, + "cekBuiltinCost-exBudgetMemory": 0, + "cekConstCost-exBudgetCPU": 0, + "cekConstCost-exBudgetMemory": 0, + "cekDelayCost-exBudgetCPU": 0, + "cekDelayCost-exBudgetMemory": 0, + "cekForceCost-exBudgetCPU": 0, + "cekForceCost-exBudgetMemory": 0, + "cekLamCost-exBudgetCPU": 0, + "cekLamCost-exBudgetMemory": 0, + "cekStartupCost-exBudgetCPU": 0, + "cekStartupCost-exBudgetMemory": 0, + "cekVarCost-exBudgetCPU": 0, + "cekVarCost-exBudgetMemory": 0, + "chooseData-cpu-arguments": 0, + "chooseData-memory-arguments": 0, + "chooseList-cpu-arguments": 0, + "chooseList-memory-arguments": 0, + "chooseUnit-cpu-arguments": 0, + "chooseUnit-memory-arguments": 0, + "consByteString-cpu-arguments-intercept": 0, + "consByteString-cpu-arguments-slope": 0, + "consByteString-memory-arguments-intercept": 0, + "consByteString-memory-arguments-slope": 0, + "constrData-cpu-arguments": 0, + "constrData-memory-arguments": 0, + "decodeUtf8-cpu-arguments-intercept": 0, + "decodeUtf8-cpu-arguments-slope": 0, + "decodeUtf8-memory-arguments-intercept": 0, + "decodeUtf8-memory-arguments-slope": 0, + "divideInteger-cpu-arguments-constant": 0, + "divideInteger-cpu-arguments-model-arguments-c00": 0, + "divideInteger-cpu-arguments-model-arguments-c01": 0, + "divideInteger-cpu-arguments-model-arguments-c02": 0, + "divideInteger-cpu-arguments-model-arguments-c10": 0, + "divideInteger-cpu-arguments-model-arguments-c11": 0, + "divideInteger-cpu-arguments-model-arguments-c20": 0, + "divideInteger-cpu-arguments-model-arguments-minimum": 0, + "divideInteger-memory-arguments-intercept": 0, + "divideInteger-memory-arguments-minimum": 0, + "divideInteger-memory-arguments-slope": 0, + "encodeUtf8-cpu-arguments-intercept": 0, + "encodeUtf8-cpu-arguments-slope": 0, + "encodeUtf8-memory-arguments-intercept": 0, + "encodeUtf8-memory-arguments-slope": 0, + "equalsByteString-cpu-arguments-constant": 0, + "equalsByteString-cpu-arguments-intercept": 0, + "equalsByteString-cpu-arguments-slope": 0, + "equalsByteString-memory-arguments": 0, + "equalsData-cpu-arguments-intercept": 0, + "equalsData-cpu-arguments-slope": 0, + "equalsData-memory-arguments": 0, + "equalsInteger-cpu-arguments-intercept": 0, + "equalsInteger-cpu-arguments-slope": 0, + "equalsInteger-memory-arguments": 0, + "equalsString-cpu-arguments-constant": 0, + "equalsString-cpu-arguments-intercept": 0, + "equalsString-cpu-arguments-slope": 0, + "equalsString-memory-arguments": 0, + "fstPair-cpu-arguments": 0, + "fstPair-memory-arguments": 0, + "headList-cpu-arguments": 0, + "headList-memory-arguments": 0, + "iData-cpu-arguments": 0, + "iData-memory-arguments": 0, + "ifThenElse-cpu-arguments": 0, + "ifThenElse-memory-arguments": 0, + "indexByteString-cpu-arguments": 0, + "indexByteString-memory-arguments": 0, + "lengthOfByteString-cpu-arguments": 0, + "lengthOfByteString-memory-arguments": 0, + "lessThanByteString-cpu-arguments-intercept": 0, + "lessThanByteString-cpu-arguments-slope": 0, + "lessThanByteString-memory-arguments": 0, + "lessThanEqualsByteString-cpu-arguments-intercept": 0, + "lessThanEqualsByteString-cpu-arguments-slope": 0, + "lessThanEqualsByteString-memory-arguments": 0, + "lessThanEqualsInteger-cpu-arguments-intercept": 0, + "lessThanEqualsInteger-cpu-arguments-slope": 0, + "lessThanEqualsInteger-memory-arguments": 0, + "lessThanInteger-cpu-arguments-intercept": 0, + "lessThanInteger-cpu-arguments-slope": 0, + "lessThanInteger-memory-arguments": 0, + "listData-cpu-arguments": 0, + "listData-memory-arguments": 0, + "mapData-cpu-arguments": 0, + "mapData-memory-arguments": 0, + "mkCons-cpu-arguments": 0, + "mkCons-memory-arguments": 0, + "mkNilData-cpu-arguments": 0, + "mkNilData-memory-arguments": 0, + "mkNilPairData-cpu-arguments": 0, + "mkNilPairData-memory-arguments": 0, + "mkPairData-cpu-arguments": 0, + "mkPairData-memory-arguments": 0, + "modInteger-cpu-arguments-constant": 0, + "modInteger-cpu-arguments-model-arguments-c00": 0, + "modInteger-cpu-arguments-model-arguments-c01": 0, + "modInteger-cpu-arguments-model-arguments-c02": 0, + "modInteger-cpu-arguments-model-arguments-c10": 0, + "modInteger-cpu-arguments-model-arguments-c11": 0, + "modInteger-cpu-arguments-model-arguments-c20": 0, + "modInteger-cpu-arguments-model-arguments-minimum": 0, + "modInteger-memory-arguments-intercept": 0, + "modInteger-memory-arguments-slope": 0, + "multiplyInteger-cpu-arguments-intercept": 0, + "multiplyInteger-cpu-arguments-slope": 0, + "multiplyInteger-memory-arguments-intercept": 0, + "multiplyInteger-memory-arguments-slope": 0, + "nullList-cpu-arguments": 0, + "nullList-memory-arguments": 0, + "quotientInteger-cpu-arguments-constant": 0, + "quotientInteger-cpu-arguments-model-arguments-c00": 0, + "quotientInteger-cpu-arguments-model-arguments-c01": 0, + "quotientInteger-cpu-arguments-model-arguments-c02": 0, + "quotientInteger-cpu-arguments-model-arguments-c10": 0, + "quotientInteger-cpu-arguments-model-arguments-c11": 0, + "quotientInteger-cpu-arguments-model-arguments-c20": 0, + "quotientInteger-cpu-arguments-model-arguments-minimum": 0, + "quotientInteger-memory-arguments-intercept": 0, + "quotientInteger-memory-arguments-minimum": 0, + "quotientInteger-memory-arguments-slope": 0, + "remainderInteger-cpu-arguments-constant": 0, + "remainderInteger-cpu-arguments-model-arguments-c00": 0, + "remainderInteger-cpu-arguments-model-arguments-c01": 0, + "remainderInteger-cpu-arguments-model-arguments-c02": 0, + "remainderInteger-cpu-arguments-model-arguments-c10": 0, + "remainderInteger-cpu-arguments-model-arguments-c11": 0, + "remainderInteger-cpu-arguments-model-arguments-c20": 0, + "remainderInteger-cpu-arguments-model-arguments-minimum": 0, + "remainderInteger-memory-arguments-intercept": 0, + "remainderInteger-memory-arguments-slope": 0, + "serialiseData-cpu-arguments-intercept": 0, + "serialiseData-cpu-arguments-slope": 0, + "serialiseData-memory-arguments-intercept": 0, + "serialiseData-memory-arguments-slope": 0, + "sha2_256-cpu-arguments-intercept": 0, + "sha2_256-cpu-arguments-slope": 0, + "sha2_256-memory-arguments": 0, + "sha3_256-cpu-arguments-intercept": 0, + "sha3_256-cpu-arguments-slope": 0, + "sha3_256-memory-arguments": 0, + "sliceByteString-cpu-arguments-intercept": 0, + "sliceByteString-cpu-arguments-slope": 0, + "sliceByteString-memory-arguments-intercept": 0, + "sliceByteString-memory-arguments-slope": 0, + "sndPair-cpu-arguments": 0, + "sndPair-memory-arguments": 0, + "subtractInteger-cpu-arguments-intercept": 0, + "subtractInteger-cpu-arguments-slope": 0, + "subtractInteger-memory-arguments-intercept": 0, + "subtractInteger-memory-arguments-slope": 0, + "tailList-cpu-arguments": 0, + "tailList-memory-arguments": 0, + "trace-cpu-arguments": 0, + "trace-memory-arguments": 0, + "unBData-cpu-arguments": 0, + "unBData-memory-arguments": 0, + "unConstrData-cpu-arguments": 0, + "unConstrData-memory-arguments": 0, + "unIData-cpu-arguments": 0, + "unIData-memory-arguments": 0, + "unListData-cpu-arguments": 0, + "unListData-memory-arguments": 0, + "unMapData-cpu-arguments": 0, + "unMapData-memory-arguments": 0, + "verifyEcdsaSecp256k1Signature-cpu-arguments": 0, + "verifyEcdsaSecp256k1Signature-memory-arguments": 0, + "verifyEd25519Signature-cpu-arguments-intercept": 0, + "verifyEd25519Signature-cpu-arguments-slope": 0, + "verifyEd25519Signature-memory-arguments": 0, + "verifySchnorrSecp256k1Signature-cpu-arguments-intercept": 0, + "verifySchnorrSecp256k1Signature-cpu-arguments-slope": 0, + "verifySchnorrSecp256k1Signature-memory-arguments": 0, + "cekConstrCost-exBudgetCPU": 0, + "cekConstrCost-exBudgetMemory": 0, + "cekCaseCost-exBudgetCPU": 0, + "cekCaseCost-exBudgetMemory": 0, + "bls12_381_G1_add-cpu-arguments": 0, + "bls12_381_G1_add-memory-arguments": 0, + "bls12_381_G1_compress-cpu-arguments": 0, + "bls12_381_G1_compress-memory-arguments": 0, + "bls12_381_G1_equal-cpu-arguments": 0, + "bls12_381_G1_equal-memory-arguments": 0, + "bls12_381_G1_hashToGroup-cpu-arguments-intercept": 0, + "bls12_381_G1_hashToGroup-cpu-arguments-slope": 0, + "bls12_381_G1_hashToGroup-memory-arguments": 0, + "bls12_381_G1_neg-cpu-arguments": 0, + "bls12_381_G1_neg-memory-arguments": 0, + "bls12_381_G1_scalarMul-cpu-arguments-intercept": 0, + "bls12_381_G1_scalarMul-cpu-arguments-slope": 0, + "bls12_381_G1_scalarMul-memory-arguments": 0, + "bls12_381_G1_uncompress-cpu-arguments": 0, + "bls12_381_G1_uncompress-memory-arguments": 0, + "bls12_381_G2_add-cpu-arguments": 0, + "bls12_381_G2_add-memory-arguments": 0, + "bls12_381_G2_compress-cpu-arguments": 0, + "bls12_381_G2_compress-memory-arguments": 0, + "bls12_381_G2_equal-cpu-arguments": 0, + "bls12_381_G2_equal-memory-arguments": 0, + "bls12_381_G2_hashToGroup-cpu-arguments-intercept": 0, + "bls12_381_G2_hashToGroup-cpu-arguments-slope": 0, + "bls12_381_G2_hashToGroup-memory-arguments": 0, + "bls12_381_G2_neg-cpu-arguments": 0, + "bls12_381_G2_neg-memory-arguments": 0, + "bls12_381_G2_scalarMul-cpu-arguments-intercept": 0, + "bls12_381_G2_scalarMul-cpu-arguments-slope": 0, + "bls12_381_G2_scalarMul-memory-arguments": 0, + "bls12_381_G2_uncompress-cpu-arguments": 0, + "bls12_381_G2_uncompress-memory-arguments": 0, + "bls12_381_finalVerify-cpu-arguments": 0, + "bls12_381_finalVerify-memory-arguments": 0, + "bls12_381_millerLoop-cpu-arguments": 0, + "bls12_381_millerLoop-memory-arguments": 0, + "bls12_381_mulMlResult-cpu-arguments": 0, + "bls12_381_mulMlResult-memory-arguments": 0, + "keccak_256-cpu-arguments-intercept": 0, + "keccak_256-cpu-arguments-slope": 0, + "keccak_256-memory-arguments": 0, + "blake2b_224-cpu-arguments-intercept": 0, + "blake2b_224-cpu-arguments-slope": 0, + "blake2b_224-memory-arguments": 0, + "integerToByteString-cpu-arguments-c0": 0, + "integerToByteString-cpu-arguments-c1": 0, + "integerToByteString-cpu-arguments-c2": 0, + "integerToByteString-memory-arguments-intercept": 0, + "integerToByteString-memory-arguments-slope": 0, + "byteStringToInteger-cpu-arguments-c0": 0, + "byteStringToInteger-cpu-arguments-c1": 0, + "byteStringToInteger-cpu-arguments-c2": 0, + "byteStringToInteger-memory-arguments-intercept": 0, + "byteStringToInteger-memory-arguments-slope": 0, + "andByteString-cpu-arguments-intercept": 0, + "andByteString-cpu-arguments-slope1": 0, + "andByteString-cpu-arguments-slope2": 0, + "andByteString-memory-arguments-intercept": 0, + "andByteString-memory-arguments-slope": 0, + "orByteString-cpu-arguments-intercept": 0, + "orByteString-cpu-arguments-slope1": 0, + "orByteString-cpu-arguments-slope2": 0, + "orByteString-memory-arguments-intercept": 0, + "orByteString-memory-arguments-slope": 0, + "xorByteString-cpu-arguments-intercept": 0, + "xorByteString-cpu-arguments-slope1": 0, + "xorByteString-cpu-arguments-slope2": 0, + "xorByteString-memory-arguments-intercept": 0, + "xorByteString-memory-arguments-slope": 0, + "complementByteString-cpu-arguments-intercept": 0, + "complementByteString-cpu-arguments-slope": 0, + "complementByteString-memory-arguments-intercept": 0, + "complementByteString-memory-arguments-slope": 0, + "readBit-cpu-arguments": 0, + "readBit-memory-arguments": 0, + "writeBits-cpu-arguments-intercept": 0, + "writeBits-cpu-arguments-slope": 0, + "writeBits-memory-arguments-intercept": 0, + "writeBits-memory-arguments-slope": 0, + "replicateByte-cpu-arguments-intercept": 0, + "replicateByte-cpu-arguments-slope": 0, + "replicateByte-memory-arguments-intercept": 0, + "replicateByte-memory-arguments-slope": 0, + "shiftByteString-cpu-arguments-intercept": 0, + "shiftByteString-cpu-arguments-slope": 0, + "shiftByteString-memory-arguments-intercept": 0, + "shiftByteString-memory-arguments-slope": 0, + "rotateByteString-cpu-arguments-intercept": 0, + "rotateByteString-cpu-arguments-slope": 0, + "rotateByteString-memory-arguments-intercept": 0, + "rotateByteString-memory-arguments-slope": 0, + "countSetBits-cpu-arguments-intercept": 0, + "countSetBits-cpu-arguments-slope": 0, + "countSetBits-memory-arguments": 0, + "findFirstSetBit-cpu-arguments-intercept": 0, + "findFirstSetBit-cpu-arguments-slope": 0, + "findFirstSetBit-memory-arguments": 0, + "ripemd_160-cpu-arguments-intercept": 0, + "ripemd_160-cpu-arguments-slope": 0, + "ripemd_160-memory-arguments": 0 + } +} diff --git a/cardano-api/test/cardano-api-test/files/input/genesis/pv3-map-297.json b/cardano-api/test/cardano-api-test/files/input/genesis/pv3-map-297.json new file mode 100644 index 0000000000..b3c1f6150a --- /dev/null +++ b/cardano-api/test/cardano-api-test/files/input/genesis/pv3-map-297.json @@ -0,0 +1,301 @@ +{ + "PlutusV3": { + "addInteger-cpu-arguments-intercept": 0, + "addInteger-cpu-arguments-slope": 0, + "addInteger-memory-arguments-intercept": 0, + "addInteger-memory-arguments-slope": 0, + "appendByteString-cpu-arguments-intercept": 0, + "appendByteString-cpu-arguments-slope": 0, + "appendByteString-memory-arguments-intercept": 0, + "appendByteString-memory-arguments-slope": 0, + "appendString-cpu-arguments-intercept": 0, + "appendString-cpu-arguments-slope": 0, + "appendString-memory-arguments-intercept": 0, + "appendString-memory-arguments-slope": 0, + "bData-cpu-arguments": 0, + "bData-memory-arguments": 0, + "blake2b_256-cpu-arguments-intercept": 0, + "blake2b_256-cpu-arguments-slope": 0, + "blake2b_256-memory-arguments": 0, + "cekApplyCost-exBudgetCPU": 0, + "cekApplyCost-exBudgetMemory": 0, + "cekBuiltinCost-exBudgetCPU": 0, + "cekBuiltinCost-exBudgetMemory": 0, + "cekConstCost-exBudgetCPU": 0, + "cekConstCost-exBudgetMemory": 0, + "cekDelayCost-exBudgetCPU": 0, + "cekDelayCost-exBudgetMemory": 0, + "cekForceCost-exBudgetCPU": 0, + "cekForceCost-exBudgetMemory": 0, + "cekLamCost-exBudgetCPU": 0, + "cekLamCost-exBudgetMemory": 0, + "cekStartupCost-exBudgetCPU": 0, + "cekStartupCost-exBudgetMemory": 0, + "cekVarCost-exBudgetCPU": 0, + "cekVarCost-exBudgetMemory": 0, + "chooseData-cpu-arguments": 0, + "chooseData-memory-arguments": 0, + "chooseList-cpu-arguments": 0, + "chooseList-memory-arguments": 0, + "chooseUnit-cpu-arguments": 0, + "chooseUnit-memory-arguments": 0, + "consByteString-cpu-arguments-intercept": 0, + "consByteString-cpu-arguments-slope": 0, + "consByteString-memory-arguments-intercept": 0, + "consByteString-memory-arguments-slope": 0, + "constrData-cpu-arguments": 0, + "constrData-memory-arguments": 0, + "decodeUtf8-cpu-arguments-intercept": 0, + "decodeUtf8-cpu-arguments-slope": 0, + "decodeUtf8-memory-arguments-intercept": 0, + "decodeUtf8-memory-arguments-slope": 0, + "divideInteger-cpu-arguments-constant": 0, + "divideInteger-cpu-arguments-model-arguments-c00": 0, + "divideInteger-cpu-arguments-model-arguments-c01": 0, + "divideInteger-cpu-arguments-model-arguments-c02": 0, + "divideInteger-cpu-arguments-model-arguments-c10": 0, + "divideInteger-cpu-arguments-model-arguments-c11": 0, + "divideInteger-cpu-arguments-model-arguments-c20": 0, + "divideInteger-cpu-arguments-model-arguments-minimum": 0, + "divideInteger-memory-arguments-intercept": 0, + "divideInteger-memory-arguments-minimum": 0, + "divideInteger-memory-arguments-slope": 0, + "encodeUtf8-cpu-arguments-intercept": 0, + "encodeUtf8-cpu-arguments-slope": 0, + "encodeUtf8-memory-arguments-intercept": 0, + "encodeUtf8-memory-arguments-slope": 0, + "equalsByteString-cpu-arguments-constant": 0, + "equalsByteString-cpu-arguments-intercept": 0, + "equalsByteString-cpu-arguments-slope": 0, + "equalsByteString-memory-arguments": 0, + "equalsData-cpu-arguments-intercept": 0, + "equalsData-cpu-arguments-slope": 0, + "equalsData-memory-arguments": 0, + "equalsInteger-cpu-arguments-intercept": 0, + "equalsInteger-cpu-arguments-slope": 0, + "equalsInteger-memory-arguments": 0, + "equalsString-cpu-arguments-constant": 0, + "equalsString-cpu-arguments-intercept": 0, + "equalsString-cpu-arguments-slope": 0, + "equalsString-memory-arguments": 0, + "fstPair-cpu-arguments": 0, + "fstPair-memory-arguments": 0, + "headList-cpu-arguments": 0, + "headList-memory-arguments": 0, + "iData-cpu-arguments": 0, + "iData-memory-arguments": 0, + "ifThenElse-cpu-arguments": 0, + "ifThenElse-memory-arguments": 0, + "indexByteString-cpu-arguments": 0, + "indexByteString-memory-arguments": 0, + "lengthOfByteString-cpu-arguments": 0, + "lengthOfByteString-memory-arguments": 0, + "lessThanByteString-cpu-arguments-intercept": 0, + "lessThanByteString-cpu-arguments-slope": 0, + "lessThanByteString-memory-arguments": 0, + "lessThanEqualsByteString-cpu-arguments-intercept": 0, + "lessThanEqualsByteString-cpu-arguments-slope": 0, + "lessThanEqualsByteString-memory-arguments": 0, + "lessThanEqualsInteger-cpu-arguments-intercept": 0, + "lessThanEqualsInteger-cpu-arguments-slope": 0, + "lessThanEqualsInteger-memory-arguments": 0, + "lessThanInteger-cpu-arguments-intercept": 0, + "lessThanInteger-cpu-arguments-slope": 0, + "lessThanInteger-memory-arguments": 0, + "listData-cpu-arguments": 0, + "listData-memory-arguments": 0, + "mapData-cpu-arguments": 0, + "mapData-memory-arguments": 0, + "mkCons-cpu-arguments": 0, + "mkCons-memory-arguments": 0, + "mkNilData-cpu-arguments": 0, + "mkNilData-memory-arguments": 0, + "mkNilPairData-cpu-arguments": 0, + "mkNilPairData-memory-arguments": 0, + "mkPairData-cpu-arguments": 0, + "mkPairData-memory-arguments": 0, + "modInteger-cpu-arguments-constant": 0, + "modInteger-cpu-arguments-model-arguments-c00": 0, + "modInteger-cpu-arguments-model-arguments-c01": 0, + "modInteger-cpu-arguments-model-arguments-c02": 0, + "modInteger-cpu-arguments-model-arguments-c10": 0, + "modInteger-cpu-arguments-model-arguments-c11": 0, + "modInteger-cpu-arguments-model-arguments-c20": 0, + "modInteger-cpu-arguments-model-arguments-minimum": 0, + "modInteger-memory-arguments-intercept": 0, + "modInteger-memory-arguments-slope": 0, + "multiplyInteger-cpu-arguments-intercept": 0, + "multiplyInteger-cpu-arguments-slope": 0, + "multiplyInteger-memory-arguments-intercept": 0, + "multiplyInteger-memory-arguments-slope": 0, + "nullList-cpu-arguments": 0, + "nullList-memory-arguments": 0, + "quotientInteger-cpu-arguments-constant": 0, + "quotientInteger-cpu-arguments-model-arguments-c00": 0, + "quotientInteger-cpu-arguments-model-arguments-c01": 0, + "quotientInteger-cpu-arguments-model-arguments-c02": 0, + "quotientInteger-cpu-arguments-model-arguments-c10": 0, + "quotientInteger-cpu-arguments-model-arguments-c11": 0, + "quotientInteger-cpu-arguments-model-arguments-c20": 0, + "quotientInteger-cpu-arguments-model-arguments-minimum": 0, + "quotientInteger-memory-arguments-intercept": 0, + "quotientInteger-memory-arguments-minimum": 0, + "quotientInteger-memory-arguments-slope": 0, + "remainderInteger-cpu-arguments-constant": 0, + "remainderInteger-cpu-arguments-model-arguments-c00": 0, + "remainderInteger-cpu-arguments-model-arguments-c01": 0, + "remainderInteger-cpu-arguments-model-arguments-c02": 0, + "remainderInteger-cpu-arguments-model-arguments-c10": 0, + "remainderInteger-cpu-arguments-model-arguments-c11": 0, + "remainderInteger-cpu-arguments-model-arguments-c20": 0, + "remainderInteger-cpu-arguments-model-arguments-minimum": 0, + "remainderInteger-memory-arguments-intercept": 0, + "remainderInteger-memory-arguments-slope": 0, + "serialiseData-cpu-arguments-intercept": 0, + "serialiseData-cpu-arguments-slope": 0, + "serialiseData-memory-arguments-intercept": 0, + "serialiseData-memory-arguments-slope": 0, + "sha2_256-cpu-arguments-intercept": 0, + "sha2_256-cpu-arguments-slope": 0, + "sha2_256-memory-arguments": 0, + "sha3_256-cpu-arguments-intercept": 0, + "sha3_256-cpu-arguments-slope": 0, + "sha3_256-memory-arguments": 0, + "sliceByteString-cpu-arguments-intercept": 0, + "sliceByteString-cpu-arguments-slope": 0, + "sliceByteString-memory-arguments-intercept": 0, + "sliceByteString-memory-arguments-slope": 0, + "sndPair-cpu-arguments": 0, + "sndPair-memory-arguments": 0, + "subtractInteger-cpu-arguments-intercept": 0, + "subtractInteger-cpu-arguments-slope": 0, + "subtractInteger-memory-arguments-intercept": 0, + "subtractInteger-memory-arguments-slope": 0, + "tailList-cpu-arguments": 0, + "tailList-memory-arguments": 0, + "trace-cpu-arguments": 0, + "trace-memory-arguments": 0, + "unBData-cpu-arguments": 0, + "unBData-memory-arguments": 0, + "unConstrData-cpu-arguments": 0, + "unConstrData-memory-arguments": 0, + "unIData-cpu-arguments": 0, + "unIData-memory-arguments": 0, + "unListData-cpu-arguments": 0, + "unListData-memory-arguments": 0, + "unMapData-cpu-arguments": 0, + "unMapData-memory-arguments": 0, + "verifyEcdsaSecp256k1Signature-cpu-arguments": 0, + "verifyEcdsaSecp256k1Signature-memory-arguments": 0, + "verifyEd25519Signature-cpu-arguments-intercept": 0, + "verifyEd25519Signature-cpu-arguments-slope": 0, + "verifyEd25519Signature-memory-arguments": 0, + "verifySchnorrSecp256k1Signature-cpu-arguments-intercept": 0, + "verifySchnorrSecp256k1Signature-cpu-arguments-slope": 0, + "verifySchnorrSecp256k1Signature-memory-arguments": 0, + "cekConstrCost-exBudgetCPU": 0, + "cekConstrCost-exBudgetMemory": 0, + "cekCaseCost-exBudgetCPU": 0, + "cekCaseCost-exBudgetMemory": 0, + "bls12_381_G1_add-cpu-arguments": 0, + "bls12_381_G1_add-memory-arguments": 0, + "bls12_381_G1_compress-cpu-arguments": 0, + "bls12_381_G1_compress-memory-arguments": 0, + "bls12_381_G1_equal-cpu-arguments": 0, + "bls12_381_G1_equal-memory-arguments": 0, + "bls12_381_G1_hashToGroup-cpu-arguments-intercept": 0, + "bls12_381_G1_hashToGroup-cpu-arguments-slope": 0, + "bls12_381_G1_hashToGroup-memory-arguments": 0, + "bls12_381_G1_neg-cpu-arguments": 0, + "bls12_381_G1_neg-memory-arguments": 0, + "bls12_381_G1_scalarMul-cpu-arguments-intercept": 0, + "bls12_381_G1_scalarMul-cpu-arguments-slope": 0, + "bls12_381_G1_scalarMul-memory-arguments": 0, + "bls12_381_G1_uncompress-cpu-arguments": 0, + "bls12_381_G1_uncompress-memory-arguments": 0, + "bls12_381_G2_add-cpu-arguments": 0, + "bls12_381_G2_add-memory-arguments": 0, + "bls12_381_G2_compress-cpu-arguments": 0, + "bls12_381_G2_compress-memory-arguments": 0, + "bls12_381_G2_equal-cpu-arguments": 0, + "bls12_381_G2_equal-memory-arguments": 0, + "bls12_381_G2_hashToGroup-cpu-arguments-intercept": 0, + "bls12_381_G2_hashToGroup-cpu-arguments-slope": 0, + "bls12_381_G2_hashToGroup-memory-arguments": 0, + "bls12_381_G2_neg-cpu-arguments": 0, + "bls12_381_G2_neg-memory-arguments": 0, + "bls12_381_G2_scalarMul-cpu-arguments-intercept": 0, + "bls12_381_G2_scalarMul-cpu-arguments-slope": 0, + "bls12_381_G2_scalarMul-memory-arguments": 0, + "bls12_381_G2_uncompress-cpu-arguments": 0, + "bls12_381_G2_uncompress-memory-arguments": 0, + "bls12_381_finalVerify-cpu-arguments": 0, + "bls12_381_finalVerify-memory-arguments": 0, + "bls12_381_millerLoop-cpu-arguments": 0, + "bls12_381_millerLoop-memory-arguments": 0, + "bls12_381_mulMlResult-cpu-arguments": 0, + "bls12_381_mulMlResult-memory-arguments": 0, + "keccak_256-cpu-arguments-intercept": 0, + "keccak_256-cpu-arguments-slope": 0, + "keccak_256-memory-arguments": 0, + "blake2b_224-cpu-arguments-intercept": 0, + "blake2b_224-cpu-arguments-slope": 0, + "blake2b_224-memory-arguments": 0, + "integerToByteString-cpu-arguments-c0": 0, + "integerToByteString-cpu-arguments-c1": 0, + "integerToByteString-cpu-arguments-c2": 0, + "integerToByteString-memory-arguments-intercept": 0, + "integerToByteString-memory-arguments-slope": 0, + "byteStringToInteger-cpu-arguments-c0": 0, + "byteStringToInteger-cpu-arguments-c1": 0, + "byteStringToInteger-cpu-arguments-c2": 0, + "byteStringToInteger-memory-arguments-intercept": 0, + "byteStringToInteger-memory-arguments-slope": 0, + "andByteString-cpu-arguments-intercept": 0, + "andByteString-cpu-arguments-slope1": 0, + "andByteString-cpu-arguments-slope2": 0, + "andByteString-memory-arguments-intercept": 0, + "andByteString-memory-arguments-slope": 0, + "orByteString-cpu-arguments-intercept": 0, + "orByteString-cpu-arguments-slope1": 0, + "orByteString-cpu-arguments-slope2": 0, + "orByteString-memory-arguments-intercept": 0, + "orByteString-memory-arguments-slope": 0, + "xorByteString-cpu-arguments-intercept": 0, + "xorByteString-cpu-arguments-slope1": 0, + "xorByteString-cpu-arguments-slope2": 0, + "xorByteString-memory-arguments-intercept": 0, + "xorByteString-memory-arguments-slope": 0, + "complementByteString-cpu-arguments-intercept": 0, + "complementByteString-cpu-arguments-slope": 0, + "complementByteString-memory-arguments-intercept": 0, + "complementByteString-memory-arguments-slope": 0, + "readBit-cpu-arguments": 0, + "readBit-memory-arguments": 0, + "writeBits-cpu-arguments-intercept": 0, + "writeBits-cpu-arguments-slope": 0, + "writeBits-memory-arguments-intercept": 0, + "writeBits-memory-arguments-slope": 0, + "replicateByte-cpu-arguments-intercept": 0, + "replicateByte-cpu-arguments-slope": 0, + "replicateByte-memory-arguments-intercept": 0, + "replicateByte-memory-arguments-slope": 0, + "shiftByteString-cpu-arguments-intercept": 0, + "shiftByteString-cpu-arguments-slope": 0, + "shiftByteString-memory-arguments-intercept": 0, + "shiftByteString-memory-arguments-slope": 0, + "rotateByteString-cpu-arguments-intercept": 0, + "rotateByteString-cpu-arguments-slope": 0, + "rotateByteString-memory-arguments-intercept": 0, + "rotateByteString-memory-arguments-slope": 0, + "countSetBits-cpu-arguments-intercept": 0, + "countSetBits-cpu-arguments-slope": 0, + "countSetBits-memory-arguments": 0, + "findFirstSetBit-cpu-arguments-intercept": 0, + "findFirstSetBit-cpu-arguments-slope": 0, + "findFirstSetBit-memory-arguments": 0, + "ripemd_160-cpu-arguments-intercept": 0, + "ripemd_160-cpu-arguments-slope": 0, + "ripemd_160-memory-arguments": 0 + } +} From 1b71664d574a9933734e05c3348a9b1d27d41ac6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Hurlin?= Date: Wed, 15 Jan 2025 14:14:52 +0100 Subject: [PATCH 2/4] ProtocolParameters.hs: add function to validate cost model size --- .../Cardano/Api/ProtocolParameters.hs | 51 +++++++++++++++++++ 1 file changed, 51 insertions(+) diff --git a/cardano-api/internal/Cardano/Api/ProtocolParameters.hs b/cardano-api/internal/Cardano/Api/ProtocolParameters.hs index 9290ae35be..b901a36702 100644 --- a/cardano-api/internal/Cardano/Api/ProtocolParameters.hs +++ b/cardano-api/internal/Cardano/Api/ProtocolParameters.hs @@ -136,6 +136,9 @@ import qualified Cardano.Ledger.Plutus.Language as Plutus import qualified Cardano.Ledger.Shelley.API as Ledger import Cardano.Slotting.Slot (EpochNo (..)) import PlutusLedgerApi.Common (CostModelApplyError) +import qualified PlutusLedgerApi.V1.ParamName as PlutusV1 +import qualified PlutusLedgerApi.V2.ParamName as PlutusV2 +import qualified PlutusLedgerApi.V3.ParamName as PlutusV3 import Control.Monad import Data.Aeson (FromJSON (..), ToJSON (..), object, withObject, (.!=), (.:), (.:?), @@ -1051,6 +1054,40 @@ toAlonzoCostModel (CostModel m) l = first (PpceInvalidCostModel (CostModel m)) $ fromAlonzoCostModel :: Alonzo.CostModel -> CostModel fromAlonzoCostModel m = CostModel $ Alonzo.getCostModelParams m +validateCostModelSize + :: Maybe (ShelleyBasedEra era) + -> Plutus.Language + -> [Int64] + -> Either CostModelNotEnoughParametersError CostModel +validateCostModelSize mSbe lang model + | actual < expected = Left $ CostModelNotEnoughParametersError lang expected actual + | actual == expected = Right $ CostModel model + | otherwise = + -- Since the number of parameters can increase in future versions of the Plutus language, + -- we are fine having too many parameters. This allows for easier testing. + Right $ CostModel model + where + actual = length model + expected = languageToMinimumParameterCount lang + allValues :: forall a. (Bounded a, Enum a) => [a] + allValues = [minBound :: a .. maxBound] + languageToMinimumParameterCount :: Plutus.Language -> Int + languageToMinimumParameterCount = \case + Plutus.PlutusV1 -> length $ allValues @PlutusV1.ParamName -- 166 + Plutus.PlutusV2 -> + let nParamNames = length $ allValues @PlutusV2.ParamName -- 185 + in case mSbe of + Nothing -> + -- We don't know the era, so we can't know the exact number of parameters that is expected, + -- so we need to be lenient + nParamNames - 10 + Just sbe -> + caseShelleyToBabbageOrConwayEraOnwards + (const $ nParamNames - 10) -- Ten parameters were added to V2 in Conway, need to remove them here + (const nParamNames) + sbe + Plutus.PlutusV3 -> length $ allValues @PlutusV3.ParamName -- 297 + -- ---------------------------------------------------------------------------- -- Proposals embedded in transactions to update protocol parameters -- @@ -1853,6 +1890,11 @@ data ProtocolParametersConversionError | PpceMissingParameter !ProtocolParameterName deriving (Eq, Show, Data) +-- | @CostModelNotEnoughParametersError lang minimum actual@ is returned when the observed number of +-- protocol parameters for @lang@ is @actual@ and that number is below the @minimum@ expected number of parameters. +data CostModelNotEnoughParametersError + = CostModelNotEnoughParametersError Plutus.Language Int Int + type ProtocolParameterName = String type ProtocolParameterVersion = Natural @@ -1867,3 +1909,12 @@ instance Error ProtocolParametersConversionError where "Invalid cost model: " <> pretty @Text (display err) <> " Cost model: " <> pshow cm PpceMissingParameter name -> "Missing parameter: " <> pretty name + +instance Error CostModelNotEnoughParametersError where + prettyError (CostModelNotEnoughParametersError lang minimum' actual) = + "Not enough parameters for language " + <> pretty (Plutus.languageToText lang) + <> ". Expected at least " + <> pretty minimum' + <> " parameters but got " + <> pretty actual From cd620686bcc022586b52e3e86c8a79ef3ce1fb72 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Hurlin?= Date: Wed, 15 Jan 2025 16:29:27 +0100 Subject: [PATCH 3/4] ProtocolParameters.hs: propagate new error behavior --- .../Cardano/Api/ProtocolParameters.hs | 226 +++++++++++------- 1 file changed, 134 insertions(+), 92 deletions(-) diff --git a/cardano-api/internal/Cardano/Api/ProtocolParameters.hs b/cardano-api/internal/Cardano/Api/ProtocolParameters.hs index b901a36702..7f64731b44 100644 --- a/cardano-api/internal/Cardano/Api/ProtocolParameters.hs +++ b/cardano-api/internal/Cardano/Api/ProtocolParameters.hs @@ -54,6 +54,7 @@ module Cardano.Api.ProtocolParameters -- * Errors , ProtocolParametersError (..) , ProtocolParametersConversionError (..) + , CostModelNotEnoughParametersError (..) -- * PraosNonce , PraosNonce @@ -143,14 +144,14 @@ import qualified PlutusLedgerApi.V3.ParamName as PlutusV3 import Control.Monad import Data.Aeson (FromJSON (..), ToJSON (..), object, withObject, (.!=), (.:), (.:?), (.=)) -import Data.Bifunctor (bimap, first) +import Data.Bifunctor (first) import Data.ByteString (ByteString) import Data.Data (Data) import Data.Either.Combinators (maybeToRight) import Data.Int (Int64) import Data.Map.Strict (Map) import qualified Data.Map.Strict as Map -import Data.Maybe (isJust) +import Data.Maybe (fromMaybe, isJust) import Data.Maybe.Strict (StrictMaybe (..)) import Data.String (IsString) import Data.Text (Text) @@ -1006,7 +1007,11 @@ newtype CostModels = CostModels {unCostModels :: Map AnyPlutusScriptVersion Cost deriving (Eq, Show) instance FromJSON CostModels where - parseJSON v = CostModels . fromAlonzoCostModels <$> parseJSON v + parseJSON v = do + pModels <- parseJSON v + case fromAlonzoCostModels pModels of + Left err -> fail $ displayError err + Right costModels -> return $ CostModels costModels instance ToJSON CostModels where toJSON (CostModels costModels) = @@ -1030,12 +1035,15 @@ toAlonzoCostModels m = do fromAlonzoCostModels :: Plutus.CostModels - -> Map AnyPlutusScriptVersion CostModel + -> Either CostModelNotEnoughParametersError (Map AnyPlutusScriptVersion CostModel) fromAlonzoCostModels cModels = - fromList - . map (bimap fromAlonzoScriptLanguage fromAlonzoCostModel) - $ toList - $ Plutus.costModelsValid cModels + case Map.toList errs of + [] -> Right $ Map.mapKeys fromAlonzoScriptLanguage models -- All models are valid + ((_, err) : _) -> Left err -- Take first error + where + (errs, models) = Map.mapEither id entries + entries :: Map Plutus.Language (Either CostModelNotEnoughParametersError CostModel) + entries = Map.map fromAlonzoCostModel $ Plutus.costModelsValid cModels toAlonzoScriptLanguage :: AnyPlutusScriptVersion -> Plutus.Language toAlonzoScriptLanguage (AnyPlutusScriptVersion PlutusScriptV1) = Plutus.PlutusV1 @@ -1051,8 +1059,11 @@ toAlonzoCostModel :: CostModel -> Plutus.Language -> Either ProtocolParametersConversionError Alonzo.CostModel toAlonzoCostModel (CostModel m) l = first (PpceInvalidCostModel (CostModel m)) $ Alonzo.mkCostModel l m -fromAlonzoCostModel :: Alonzo.CostModel -> CostModel -fromAlonzoCostModel m = CostModel $ Alonzo.getCostModelParams m +fromAlonzoCostModel :: Alonzo.CostModel -> Either CostModelNotEnoughParametersError CostModel +fromAlonzoCostModel m = validateCostModelSize Nothing lang params + where + params = Alonzo.getCostModelParams m + lang = Alonzo.getCostModelLanguage m validateCostModelSize :: Maybe (ShelleyBasedEra era) @@ -1076,14 +1087,15 @@ validateCostModelSize mSbe lang model Plutus.PlutusV1 -> length $ allValues @PlutusV1.ParamName -- 166 Plutus.PlutusV2 -> let nParamNames = length $ allValues @PlutusV2.ParamName -- 185 + lessTen = nParamNames - 10 in case mSbe of Nothing -> -- We don't know the era, so we can't know the exact number of parameters that is expected, -- so we need to be lenient - nParamNames - 10 + lessTen Just sbe -> caseShelleyToBabbageOrConwayEraOnwards - (const $ nParamNames - 10) -- Ten parameters were added to V2 in Conway, need to remove them here + (const lessTen) -- Ten parameters were added to V2 in Conway, need to remove them here (const nParamNames) sbe Plutus.PlutusV3 -> length $ allValues @PlutusV3.ParamName -- 297 @@ -1346,9 +1358,9 @@ fromLedgerUpdate => Ledger.EraCrypto ledgerera ~ StandardCrypto => ShelleyBasedEra era -> Ledger.Update ledgerera - -> UpdateProposal + -> Either CostModelNotEnoughParametersError UpdateProposal fromLedgerUpdate sbe (Ledger.Update ppup epochno) = - UpdateProposal (fromLedgerProposedPPUpdates sbe ppup) epochno + UpdateProposal <$> fromLedgerProposedPPUpdates sbe ppup <*> pure epochno fromLedgerProposedPPUpdates :: forall era ledgerera @@ -1356,22 +1368,31 @@ fromLedgerProposedPPUpdates => Ledger.EraCrypto ledgerera ~ StandardCrypto => ShelleyBasedEra era -> Ledger.ProposedPPUpdates ledgerera - -> Map (Hash GenesisKey) ProtocolParametersUpdate -fromLedgerProposedPPUpdates sbe = - Map.map (fromLedgerPParamsUpdate sbe) - . Map.mapKeysMonotonic GenesisKeyHash - . (\(Ledger.ProposedPPUpdates ppup) -> ppup) + -> Either + CostModelNotEnoughParametersError + (Map (Hash GenesisKey) ProtocolParametersUpdate) +fromLedgerProposedPPUpdates sbe (Ledger.ProposedPPUpdates ppus) = + case Map.toList errs of + [] -> Right maps + ((_, err) : _) -> Left err + where + (errs, maps) = + Map.map (fromLedgerPParamsUpdate sbe) ppus + & Map.mapKeysMonotonic GenesisKeyHash + & Map.mapEither id fromLedgerPParamsUpdate :: ShelleyBasedEra era -> Ledger.PParamsUpdate (ShelleyLedgerEra era) - -> ProtocolParametersUpdate -fromLedgerPParamsUpdate ShelleyBasedEraShelley = fromShelleyPParamsUpdate -fromLedgerPParamsUpdate ShelleyBasedEraAllegra = fromShelleyPParamsUpdate -fromLedgerPParamsUpdate ShelleyBasedEraMary = fromShelleyPParamsUpdate -fromLedgerPParamsUpdate ShelleyBasedEraAlonzo = fromAlonzoPParamsUpdate -fromLedgerPParamsUpdate ShelleyBasedEraBabbage = fromBabbagePParamsUpdate -fromLedgerPParamsUpdate ShelleyBasedEraConway = fromConwayPParamsUpdate + -> Either CostModelNotEnoughParametersError ProtocolParametersUpdate +fromLedgerPParamsUpdate era ppu = + case era of + ShelleyBasedEraShelley -> pure $ fromShelleyPParamsUpdate ppu + ShelleyBasedEraAllegra -> pure $ fromShelleyPParamsUpdate ppu + ShelleyBasedEraMary -> pure $ fromShelleyPParamsUpdate ppu + ShelleyBasedEraAlonzo -> fromAlonzoPParamsUpdate ppu + ShelleyBasedEraBabbage -> fromBabbagePParamsUpdate ppu + ShelleyBasedEraConway -> fromConwayPParamsUpdate ppu fromShelleyCommonPParamsUpdate :: EraPParams ledgerera @@ -1431,64 +1452,75 @@ fromShelleyPParamsUpdate ppu = fromAlonzoCommonPParamsUpdate :: AlonzoEraPParams ledgerera => PParamsUpdate ledgerera - -> ProtocolParametersUpdate + -> Either CostModelNotEnoughParametersError ProtocolParametersUpdate fromAlonzoCommonPParamsUpdate ppu = - (fromShelleyCommonPParamsUpdate ppu) - { protocolUpdateCostModels = - maybe - mempty - fromAlonzoCostModels - (strictMaybeToMaybe (ppu ^. ppuCostModelsL)) - , protocolUpdatePrices = - fromAlonzoPrices - <$> strictMaybeToMaybe (ppu ^. ppuPricesL) - , protocolUpdateMaxTxExUnits = - fromAlonzoExUnits - <$> strictMaybeToMaybe (ppu ^. ppuMaxTxExUnitsL) - , protocolUpdateMaxBlockExUnits = - fromAlonzoExUnits - <$> strictMaybeToMaybe (ppu ^. ppuMaxBlockExUnitsL) - , protocolUpdateMaxValueSize = strictMaybeToMaybe (ppu ^. ppuMaxValSizeL) - , protocolUpdateCollateralPercent = strictMaybeToMaybe (ppu ^. ppuCollateralPercentageL) - , protocolUpdateMaxCollateralInputs = strictMaybeToMaybe (ppu ^. ppuMaxCollateralInputsL) - , protocolUpdateUTxOCostPerByte = Nothing - } + case costModels of + Left err -> Left err + Right mCostModelMap -> + Right $ + (fromShelleyCommonPParamsUpdate ppu) + { protocolUpdateCostModels = fromMaybe mempty mCostModelMap + , protocolUpdatePrices = + fromAlonzoPrices + <$> strictMaybeToMaybe (ppu ^. ppuPricesL) + , protocolUpdateMaxTxExUnits = + fromAlonzoExUnits + <$> strictMaybeToMaybe (ppu ^. ppuMaxTxExUnitsL) + , protocolUpdateMaxBlockExUnits = + fromAlonzoExUnits + <$> strictMaybeToMaybe (ppu ^. ppuMaxBlockExUnitsL) + , protocolUpdateMaxValueSize = strictMaybeToMaybe (ppu ^. ppuMaxValSizeL) + , protocolUpdateCollateralPercent = strictMaybeToMaybe (ppu ^. ppuCollateralPercentageL) + , protocolUpdateMaxCollateralInputs = strictMaybeToMaybe (ppu ^. ppuMaxCollateralInputsL) + , protocolUpdateUTxOCostPerByte = Nothing + } + where + mCostModels :: Maybe (Plutus.CostModels) + mCostModels = strictMaybeToMaybe (ppu ^. ppuCostModelsL) + costModels + :: Either + CostModelNotEnoughParametersError + (Maybe (Map AnyPlutusScriptVersion CostModel)) + costModels = sequence $ fromAlonzoCostModels <$> mCostModels fromAlonzoPParamsUpdate :: Ledger.Crypto crypto => PParamsUpdate (Ledger.AlonzoEra crypto) - -> ProtocolParametersUpdate + -> Either CostModelNotEnoughParametersError ProtocolParametersUpdate fromAlonzoPParamsUpdate ppu = - (fromAlonzoCommonPParamsUpdate ppu) - { protocolUpdateProtocolVersion = - (\(Ledger.ProtVer a b) -> (Ledger.getVersion a, b)) - <$> strictMaybeToMaybe (ppu ^. ppuProtocolVersionL) - } + (fromAlonzoCommonPParamsUpdate ppu) <&> \ppu' -> + ppu' + { protocolUpdateProtocolVersion = + (\(Ledger.ProtVer a b) -> (Ledger.getVersion a, b)) + <$> strictMaybeToMaybe (ppu ^. ppuProtocolVersionL) + } fromBabbageCommonPParamsUpdate :: BabbageEraPParams ledgerera => PParamsUpdate ledgerera - -> ProtocolParametersUpdate + -> Either CostModelNotEnoughParametersError ProtocolParametersUpdate fromBabbageCommonPParamsUpdate ppu = - (fromAlonzoCommonPParamsUpdate ppu) - { protocolUpdateUTxOCostPerByte = unCoinPerByte <$> strictMaybeToMaybe (ppu ^. ppuCoinsPerUTxOByteL) - } + (fromAlonzoCommonPParamsUpdate ppu) <&> \ppu' -> + ppu' + { protocolUpdateUTxOCostPerByte = unCoinPerByte <$> strictMaybeToMaybe (ppu ^. ppuCoinsPerUTxOByteL) + } fromBabbagePParamsUpdate :: Ledger.Crypto crypto => PParamsUpdate (Ledger.BabbageEra crypto) - -> ProtocolParametersUpdate + -> Either CostModelNotEnoughParametersError ProtocolParametersUpdate fromBabbagePParamsUpdate ppu = - (fromBabbageCommonPParamsUpdate ppu) - { protocolUpdateProtocolVersion = - (\(Ledger.ProtVer a b) -> (Ledger.getVersion a, b)) - <$> strictMaybeToMaybe (ppu ^. ppuProtocolVersionL) - } + (fromBabbageCommonPParamsUpdate ppu) <&> \ppu' -> + ppu' + { protocolUpdateProtocolVersion = + (\(Ledger.ProtVer a b) -> (Ledger.getVersion a, b)) + <$> strictMaybeToMaybe (ppu ^. ppuProtocolVersionL) + } fromConwayPParamsUpdate :: BabbageEraPParams ledgerera => PParamsUpdate ledgerera - -> ProtocolParametersUpdate + -> Either CostModelNotEnoughParametersError ProtocolParametersUpdate fromConwayPParamsUpdate = fromBabbageCommonPParamsUpdate -- ---------------------------------------------------------------------------- @@ -1666,13 +1698,15 @@ toConwayPParams = toBabbagePParams fromLedgerPParams :: ShelleyBasedEra era -> Ledger.PParams (ShelleyLedgerEra era) - -> ProtocolParameters -fromLedgerPParams ShelleyBasedEraShelley = fromShelleyPParams -fromLedgerPParams ShelleyBasedEraAllegra = fromShelleyPParams -fromLedgerPParams ShelleyBasedEraMary = fromShelleyPParams -fromLedgerPParams ShelleyBasedEraAlonzo = fromExactlyAlonzoPParams -fromLedgerPParams ShelleyBasedEraBabbage = fromBabbagePParams -fromLedgerPParams ShelleyBasedEraConway = fromConwayPParams + -> Either CostModelNotEnoughParametersError ProtocolParameters +fromLedgerPParams sbe pp = + case sbe of + ShelleyBasedEraShelley -> pure $ fromShelleyPParams pp + ShelleyBasedEraAllegra -> pure $ fromShelleyPParams pp + ShelleyBasedEraMary -> pure $ fromShelleyPParams pp + ShelleyBasedEraAlonzo -> fromExactlyAlonzoPParams pp + ShelleyBasedEraBabbage -> fromBabbagePParams pp + ShelleyBasedEraConway -> fromConwayPParams pp {-# DEPRECATED fromShelleyCommonPParams @@ -1737,18 +1771,23 @@ fromShelleyPParams pp = fromAlonzoPParams :: AlonzoEraPParams ledgerera => PParams ledgerera - -> ProtocolParameters + -> Either CostModelNotEnoughParametersError ProtocolParameters fromAlonzoPParams pp = - (fromShelleyCommonPParams pp) - { protocolParamCostModels = fromAlonzoCostModels $ pp ^. ppCostModelsL - , protocolParamDecentralization = Just . Ledger.unboundRational $ pp ^. ppDG - , protocolParamPrices = Just . fromAlonzoPrices $ pp ^. ppPricesL - , protocolParamMaxTxExUnits = Just . fromAlonzoExUnits $ pp ^. ppMaxTxExUnitsL - , protocolParamMaxBlockExUnits = Just . fromAlonzoExUnits $ pp ^. ppMaxBlockExUnitsL - , protocolParamMaxValueSize = Just $ pp ^. ppMaxValSizeL - , protocolParamCollateralPercent = Just $ pp ^. ppCollateralPercentageL - , protocolParamMaxCollateralInputs = Just $ pp ^. ppMaxCollateralInputsL - } + ppCostModels <&> \costModels -> + base + { protocolParamCostModels = costModels + , protocolParamDecentralization = Just . Ledger.unboundRational $ pp ^. ppDG + , protocolParamPrices = Just . fromAlonzoPrices $ pp ^. ppPricesL + , protocolParamMaxTxExUnits = Just . fromAlonzoExUnits $ pp ^. ppMaxTxExUnitsL + , protocolParamMaxBlockExUnits = Just . fromAlonzoExUnits $ pp ^. ppMaxBlockExUnitsL + , protocolParamMaxValueSize = Just $ pp ^. ppMaxValSizeL + , protocolParamCollateralPercent = Just $ pp ^. ppCollateralPercentageL + , protocolParamMaxCollateralInputs = Just $ pp ^. ppMaxCollateralInputsL + } + where + base = fromShelleyCommonPParams pp + ppCostModels :: Either CostModelNotEnoughParametersError (Map AnyPlutusScriptVersion CostModel) + ppCostModels = fromAlonzoCostModels $ pp ^. ppCostModelsL {-# DEPRECATED fromExactlyAlonzoPParams @@ -1757,11 +1796,12 @@ fromAlonzoPParams pp = fromExactlyAlonzoPParams :: (AlonzoEraPParams ledgerera, Ledger.ExactEra Ledger.AlonzoEra ledgerera) => PParams ledgerera - -> ProtocolParameters + -> Either CostModelNotEnoughParametersError ProtocolParameters fromExactlyAlonzoPParams pp = - (fromAlonzoPParams pp) - { protocolParamUTxOCostPerByte = Just . unCoinPerWord $ pp ^. ppCoinsPerUTxOWordL - } + (fromAlonzoPParams pp) <&> \pp' -> + pp' + { protocolParamUTxOCostPerByte = Just . unCoinPerWord $ pp ^. ppCoinsPerUTxOWordL + } {-# DEPRECATED fromBabbagePParams @@ -1770,12 +1810,13 @@ fromExactlyAlonzoPParams pp = fromBabbagePParams :: BabbageEraPParams ledgerera => PParams ledgerera - -> ProtocolParameters + -> Either CostModelNotEnoughParametersError ProtocolParameters fromBabbagePParams pp = - (fromAlonzoPParams pp) - { protocolParamUTxOCostPerByte = Just . unCoinPerByte $ pp ^. ppCoinsPerUTxOByteL - , protocolParamDecentralization = Nothing - } + (fromAlonzoPParams pp) <&> \pp' -> + pp' + { protocolParamUTxOCostPerByte = Just . unCoinPerByte $ pp ^. ppCoinsPerUTxOByteL + , protocolParamDecentralization = Nothing + } {-# DEPRECATED fromConwayPParams @@ -1784,7 +1825,7 @@ fromBabbagePParams pp = fromConwayPParams :: BabbageEraPParams ledgerera => PParams ledgerera - -> ProtocolParameters + -> Either CostModelNotEnoughParametersError ProtocolParameters fromConwayPParams = fromBabbagePParams {-# DEPRECATED @@ -1894,6 +1935,7 @@ data ProtocolParametersConversionError -- protocol parameters for @lang@ is @actual@ and that number is below the @minimum@ expected number of parameters. data CostModelNotEnoughParametersError = CostModelNotEnoughParametersError Plutus.Language Int Int + deriving Show type ProtocolParameterName = String From 2a1154b5d0091684d06e948beee0a7efa304be9b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Hurlin?= Date: Wed, 15 Jan 2025 18:05:34 +0100 Subject: [PATCH 4/4] Adapt callers outside ProtocolParameters --- .../internal/Cardano/Api/Governance/Poll.hs | 18 +++-- cardano-api/internal/Cardano/Api/Tx/Body.hs | 70 +++++++++---------- 2 files changed, 46 insertions(+), 42 deletions(-) diff --git a/cardano-api/internal/Cardano/Api/Governance/Poll.hs b/cardano-api/internal/Cardano/Api/Governance/Poll.hs index 7e4063e5c2..2d58e06b8a 100644 --- a/cardano-api/internal/Cardano/Api/Governance/Poll.hs +++ b/cardano-api/internal/Cardano/Api/Governance/Poll.hs @@ -7,7 +7,6 @@ {-# LANGUAGE ScopedTypeVariables #-} {-# LANGUAGE TypeApplications #-} {-# LANGUAGE TypeFamilies #-} -{-# LANGUAGE ViewPatterns #-} -- | An API for driving on-chain poll for SPOs. -- @@ -37,8 +36,10 @@ module Cardano.Api.Governance.Poll ) where +import Cardano.Api.Pretty +import Cardano.Api.Error +import Cardano.Api.ProtocolParameters import Cardano.Api.Eon.ShelleyBasedEra -import Cardano.Api.Eras import Cardano.Api.Hash import Cardano.Api.HasTypeProxy import Cardano.Api.Keys.Shelley @@ -58,6 +59,7 @@ import Cardano.Ledger.Crypto (HASH, StandardCrypto) import Control.Arrow (left) import Control.Monad (foldM, when) +import Data.Bifunctor (first) import Data.Either.Combinators (maybeToRight) import Data.Function ((&)) import qualified Data.Map.Strict as Map @@ -279,6 +281,7 @@ data GovernancePollError | ErrGovernancePollUnauthenticated | ErrGovernancePollMalformedAnswer DecoderError | ErrGovernancePollInvalidAnswer GovernancePollInvalidAnswerError + | ErrGovernancePollCostModelNotEnoughParameters CostModelNotEnoughParametersError deriving Show data GovernancePollInvalidAnswerError = GovernancePollInvalidAnswerError @@ -331,6 +334,9 @@ renderGovernancePollError err = | (ix, answer) <- invalidAnswerAcceptableAnswers invalidAnswer ] ] + ErrGovernancePollCostModelNotEnoughParameters err' -> + -- TODO can be simplified? + Text.pack $ docToString $ prettyError err' -- | Verify a poll against a given transaction and returns the signatories -- (verification key only) when valid. @@ -341,12 +347,14 @@ verifyPollAnswer :: GovernancePoll -> InAnyShelleyBasedEra Tx -> Either GovernancePollError [Hash PaymentKey] -verifyPollAnswer poll (InAnyShelleyBasedEra _era (getTxBody -> TxBody body)) = do - answer <- extractPollAnswer (txMetadata body) +verifyPollAnswer poll (InAnyShelleyBasedEra _era tx) = do + content <- first ErrGovernancePollCostModelNotEnoughParameters $ getTxBodyContent body + answer <- extractPollAnswer (txMetadata content) answer `hasMatchingHash` hashGovernancePoll poll answer `isAmongAcceptableChoices` govPollAnswers poll - extraKeyWitnesses (txExtraKeyWits body) + extraKeyWitnesses (txExtraKeyWits content) where + body = getTxBody tx extractPollAnswer = \case TxMetadataNone -> Left ErrGovernancePollNoAnswer diff --git a/cardano-api/internal/Cardano/Api/Tx/Body.hs b/cardano-api/internal/Cardano/Api/Tx/Body.hs index 2627375931..2696616c35 100644 --- a/cardano-api/internal/Cardano/Api/Tx/Body.hs +++ b/cardano-api/internal/Cardano/Api/Tx/Body.hs @@ -14,14 +14,12 @@ {-# LANGUAGE TypeApplications #-} {-# LANGUAGE TypeFamilies #-} {-# LANGUAGE TypeOperators #-} -{-# LANGUAGE ViewPatterns #-} -- | Transaction bodies module Cardano.Api.Tx.Body ( parseTxId -- * Transaction bodies - , TxBody (.., TxBody) , createTransactionBody , createAndValidateTransactionBody , TxBodyContent (..) @@ -2148,12 +2146,8 @@ createAndValidateTransactionBody -> Either TxBodyError (TxBody era) createAndValidateTransactionBody = makeShelleyTransactionBody -pattern TxBody :: TxBodyContent ViewTx era -> TxBody era -pattern TxBody txbodycontent <- (getTxBodyContent -> txbodycontent) - -{-# COMPLETE TxBody #-} - -getTxBodyContent :: TxBody era -> TxBodyContent ViewTx era +getTxBodyContent + :: TxBody era -> Either CostModelNotEnoughParametersError (TxBodyContent ViewTx era) getTxBodyContent = \case ShelleyTxBody sbe body _scripts scriptdata mAux scriptValidity -> fromLedgerTxBody sbe scriptValidity body scriptdata mAux @@ -2164,34 +2158,36 @@ fromLedgerTxBody -> Ledger.TxBody (ShelleyLedgerEra era) -> TxBodyScriptData era -> Maybe (L.TxAuxData (ShelleyLedgerEra era)) - -> TxBodyContent ViewTx era + -> Either CostModelNotEnoughParametersError (TxBodyContent ViewTx era) fromLedgerTxBody sbe scriptValidity body scriptdata mAux = - TxBodyContent - { txIns = fromLedgerTxIns sbe body - , txInsCollateral = fromLedgerTxInsCollateral sbe body - , txInsReference = fromLedgerTxInsReference sbe body - , txOuts = fromLedgerTxOuts sbe body scriptdata - , txTotalCollateral = fromLedgerTxTotalCollateral sbe body - , txReturnCollateral = fromLedgerTxReturnCollateral sbe body - , txFee = fromLedgerTxFee sbe body - , txValidityLowerBound = fromLedgerTxValidityLowerBound sbe (A.TxBody body) - , txValidityUpperBound = fromLedgerTxValidityUpperBound sbe (A.TxBody body) - , txWithdrawals = fromLedgerTxWithdrawals sbe body - , txCertificates = fromLedgerTxCertificates sbe body - , txUpdateProposal = maybeFromLedgerTxUpdateProposal sbe body - , txMintValue = fromLedgerTxMintValue sbe body - , txExtraKeyWits = fromLedgerTxExtraKeyWitnesses sbe body - , txProtocolParams = ViewTx - , txMetadata - , txAuxScripts - , txScriptValidity = scriptValidity - , txProposalProcedures = fromLedgerProposalProcedures sbe body - , txVotingProcedures = fromLedgerVotingProcedures sbe body - , txCurrentTreasuryValue = fromLedgerCurrentTreasuryValue sbe body - , txTreasuryDonation = fromLedgerTreasuryDonation sbe body - } + txUpdateProposal <&> \txup -> + TxBodyContent + { txIns = fromLedgerTxIns sbe body + , txInsCollateral = fromLedgerTxInsCollateral sbe body + , txInsReference = fromLedgerTxInsReference sbe body + , txOuts = fromLedgerTxOuts sbe body scriptdata + , txTotalCollateral = fromLedgerTxTotalCollateral sbe body + , txReturnCollateral = fromLedgerTxReturnCollateral sbe body + , txFee = fromLedgerTxFee sbe body + , txValidityLowerBound = fromLedgerTxValidityLowerBound sbe (A.TxBody body) + , txValidityUpperBound = fromLedgerTxValidityUpperBound sbe (A.TxBody body) + , txWithdrawals = fromLedgerTxWithdrawals sbe body + , txCertificates = fromLedgerTxCertificates sbe body + , txUpdateProposal = txup + , txMintValue = fromLedgerTxMintValue sbe body + , txExtraKeyWits = fromLedgerTxExtraKeyWitnesses sbe body + , txProtocolParams = ViewTx + , txMetadata + , txAuxScripts + , txScriptValidity = scriptValidity + , txProposalProcedures = fromLedgerProposalProcedures sbe body + , txVotingProcedures = fromLedgerVotingProcedures sbe body + , txCurrentTreasuryValue = fromLedgerCurrentTreasuryValue sbe body + , txTreasuryDonation = fromLedgerTreasuryDonation sbe body + } where (txMetadata, txAuxScripts) = fromLedgerTxAuxiliaryData sbe mAux + txUpdateProposal = maybeFromLedgerTxUpdateProposal sbe body fromLedgerProposalProcedures :: ShelleyBasedEra era @@ -2544,15 +2540,15 @@ maybeFromLedgerTxUpdateProposal :: () => ShelleyBasedEra era -> Ledger.TxBody (ShelleyLedgerEra era) - -> TxUpdateProposal era + -> Either CostModelNotEnoughParametersError (TxUpdateProposal era) maybeFromLedgerTxUpdateProposal sbe body = caseShelleyToBabbageOrConwayEraOnwards ( \w -> case body ^. L.updateTxBodyL of - SNothing -> TxUpdateProposalNone - SJust p -> TxUpdateProposal w (fromLedgerUpdate sbe p) + SNothing -> pure TxUpdateProposalNone + SJust p -> TxUpdateProposal w <$> (fromLedgerUpdate sbe p) ) - (const TxUpdateProposalNone) + (const $ pure TxUpdateProposalNone) sbe fromLedgerTxMintValue