Skip to content

Commit

Permalink
Merge pull request #133 from blockfrost/srk/costModelsTests
Browse files Browse the repository at this point in the history
Cost models test fix, use for numbered epoch as well
  • Loading branch information
sorki authored Nov 3, 2023
2 parents 05ec27e + 28ab1cd commit dc63ea4
Show file tree
Hide file tree
Showing 2 changed files with 343 additions and 8 deletions.
4 changes: 2 additions & 2 deletions src/routes/epochs/number/parameters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import * as QueryTypes from '../../../types/queries/epochs.js';
import * as ResponseTypes from '../../../types/responses/epochs.js';
import { getDbSync } from '../../../utils/database.js';
import { handle400Custom, handle404 } from '../../../utils/error-handler.js';
import { sortKeysInObject } from '../../../utils/string-utils.js';
import { costModelsMap } from '../../../utils/cost-models-map.js';
import { validatePositiveInRangeSignedInt } from '../../../utils/validation.js';

async function route(fastify: FastifyInstance) {
Expand Down Expand Up @@ -36,7 +36,7 @@ async function route(fastify: FastifyInstance) {
}

if (rows[0].cost_models) {
rows[0].cost_models = sortKeysInObject(rows[0].cost_models);
rows[0].cost_models = costModelsMap(rows[0].cost_models);
}

return reply.send(rows[0]);
Expand Down
347 changes: 341 additions & 6 deletions test/unit/fixtures/epochs.fixtures.ts
Original file line number Diff line number Diff line change
Expand Up @@ -341,12 +341,8 @@ const query_epoch_number_parameters_regular = {
min_pool_cost: '340000000',
nonce: '701241ce057d391aa92b8d88ffcdff361539cb12ea2a5bba4e5f95d66948ffe3',
cost_models: {
PlutusV1: {
'addInteger-memory-arguments-intercept': 1,
'addInteger-memory-arguments-slope': 1,
'addInteger-cpu-arguments-intercept': 205665,
'addInteger-cpu-arguments-slope': 812,
},
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, 57996947, 18975, 10 ],
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, 57996947, 18975, 10, 38887044, 32947, 10 ],
},
price_mem: 0.001,
price_step: 0.01,
Expand Down Expand Up @@ -388,6 +384,345 @@ const response_epoch_number_parameters_regular = {
'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,
'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': 57996947,
'verifyEd25519Signature-cpu-arguments-slope': 18975,
'verifyEd25519Signature-memory-arguments': 10
},
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,
'verifySchnorrSecp256k1Signature-memory-arguments': 10
},
},
price_mem: 0.001,
Expand Down

0 comments on commit dc63ea4

Please sign in to comment.