From 8dfaa1bf90ed2091ba65082ad6b89b286ce9978d Mon Sep 17 00:00:00 2001 From: KtorZ Date: Sat, 24 Aug 2024 18:26:02 +0200 Subject: [PATCH] Fix parsing of v3 cost model Closes #1002. --- crates/uplc/src/machine/cost_model.rs | 356 ++++++++++++++------------ 1 file changed, 194 insertions(+), 162 deletions(-) diff --git a/crates/uplc/src/machine/cost_model.rs b/crates/uplc/src/machine/cost_model.rs index 86eec4d0..5c5d6be5 100644 --- a/crates/uplc/src/machine/cost_model.rs +++ b/crates/uplc/src/machine/cost_model.rs @@ -2741,258 +2741,263 @@ pub fn initialize_cost_model(version: &Language, costs: &[i64]) -> CostModel { } } Language::PlutusV3 => { + assert!( + costs.len() == 251, + "expecting 251 cost parameters, but got {:?}", + costs.len() + ); hashmap! { "add_integer-cpu-arguments-intercept" => costs[0], "add_integer-cpu-arguments-slope" => costs[1], - "add_integer-memory-arguments-intercept" => costs[2], - "add_integer-memory-arguments-slope" => costs[3], + "add_integer-mem-arguments-intercept" => costs[2], + "add_integer-mem-arguments-slope" => costs[3], "append_byte_string-cpu-arguments-intercept" => costs[4], "append_byte_string-cpu-arguments-slope" => costs[5], - "append_byte_string-memory-arguments-intercept" => costs[6], - "append_byte_string-memory-arguments-slope" => costs[7], + "append_byte_string-mem-arguments-intercept" => costs[6], + "append_byte_string-mem-arguments-slope" => costs[7], "append_string-cpu-arguments-intercept" => costs[8], "append_string-cpu-arguments-slope" => costs[9], - "append_string-memory-arguments-intercept" => costs[10], - "append_string-memory-arguments-slope" => costs[11], + "append_string-mem-arguments-intercept" => costs[10], + "append_string-mem-arguments-slope" => costs[11], "b_data-cpu-arguments" => costs[12], - "b_data-memory-arguments" => costs[13], + "b_data-mem-arguments" => costs[13], "blake2b_256-cpu-arguments-intercept" => costs[14], "blake2b_256-cpu-arguments-slope" => costs[15], - "blake2b_256-memory-arguments" => costs[16], + "blake2b_256-mem-arguments" => costs[16], "cek_apply_cost-exBudgetCPU" => costs[17], - "cek_apply_cost-exBudgetMemory" => costs[18], + "cek_apply_cost-exBudgetmem" => costs[18], "cek_builtin_cost-exBudgetCPU" => costs[19], - "cek_builtin_cost-exBudgetMemory" => costs[20], + "cek_builtin_cost-exBudgetmem" => costs[20], "cek_const_cost-exBudgetCPU" => costs[21], - "cek_const_cost-exBudgetMemory" => costs[22], + "cek_const_cost-exBudgetmem" => costs[22], "cek_delay_cost-exBudgetCPU" => costs[23], - "cek_delay_cost-exBudgetMemory" => costs[24], + "cek_delay_cost-exBudgetmem" => costs[24], "cek_force_cost-exBudgetCPU" => costs[25], - "cek_force_cost-exBudgetMemory" => costs[26], + "cek_force_cost-exBudgetmem" => costs[26], "cek_lam_cost-exBudgetCPU" => costs[27], - "cek_lam_cost-exBudgetMemory" => costs[28], + "cek_lam_cost-exBudgetmem" => costs[28], "cek_startup_cost-exBudgetCPU" => costs[29], - "cek_startup_cost-exBudgetMemory" => costs[30], + "cek_startup_cost-exBudgetmem" => costs[30], "cek_var_cost-exBudgetCPU" => costs[31], - "cek_var_cost-exBudgetMemory" => costs[32], + "cek_var_cost-exBudgetmem" => costs[32], "choose_data-cpu-arguments" => costs[33], - "choose_data-memory-arguments" => costs[34], + "choose_data-mem-arguments" => costs[34], "choose_list-cpu-arguments" => costs[35], - "choose_list-memory-arguments" => costs[36], + "choose_list-mem-arguments" => costs[36], "choose_unit-cpu-arguments" => costs[37], - "choose_unit-memory-arguments" => costs[38], + "choose_unit-mem-arguments" => costs[38], "cons_byte_string-cpu-arguments-intercept" => costs[39], "cons_byte_string-cpu-arguments-slope" => costs[40], - "cons_byte_string-memory-arguments-intercept" => costs[41], - "cons_byte_string-memory-arguments-slope" => costs[42], + "cons_byte_string-mem-arguments-intercept" => costs[41], + "cons_byte_string-mem-arguments-slope" => costs[42], "constr_data-cpu-arguments" => costs[43], - "constr_data-memory-arguments" => costs[44], + "constr_data-mem-arguments" => costs[44], "decode_utf8-cpu-arguments-intercept" => costs[45], "decode_utf8-cpu-arguments-slope" => costs[46], - "decode_utf8-memory-arguments-intercept" => costs[47], - "decode_utf8-memory-arguments-slope" => costs[48], + "decode_utf8-mem-arguments-intercept" => costs[47], + "decode_utf8-mem-arguments-slope" => costs[48], "divide_integer-cpu-arguments-constant" => costs[49], - "divide_integer-cpu-arguments-model-arguments-c00" => costs[50], - "divide_integer-cpu-arguments-model-arguments-c01" => costs[51], - "divide_integer-cpu-arguments-model-arguments-c02" => costs[52], - "divide_integer-cpu-arguments-model-arguments-c10" => costs[53], - "divide_integer-cpu-arguments-model-arguments-c11" => costs[54], - "divide_integer-cpu-arguments-model-arguments-c20" => costs[55], - "divide_integer-cpu-arguments-model-arguments-minimum" => costs[56], - "divide_integer-memory-arguments-intercept" => costs[57], - "divide_integer-memory-arguments-minimum" => costs[58], - "divide_integer-memory-arguments-slope" => costs[59], + "divide_integer-cpu-arguments-c00" => costs[50], + "divide_integer-cpu-arguments-c01" => costs[51], + "divide_integer-cpu-arguments-c02" => costs[52], + "divide_integer-cpu-arguments-c10" => costs[53], + "divide_integer-cpu-arguments-c11" => costs[54], + "divide_integer-cpu-arguments-c20" => costs[55], + "divide_integer-cpu-arguments-minimum" => costs[56], + "divide_integer-mem-arguments-intercept" => costs[57], + "divide_integer-mem-arguments-minimum" => costs[58], + "divide_integer-mem-arguments-slope" => costs[59], "encode_utf8-cpu-arguments-intercept" => costs[60], "encode_utf8-cpu-arguments-slope" => costs[61], - "encode_utf8-memory-arguments-intercept" => costs[62], - "encode_utf8-memory-arguments-slope" => costs[63], + "encode_utf8-mem-arguments-intercept" => costs[62], + "encode_utf8-mem-arguments-slope" => costs[63], "equals_byte_string-cpu-arguments-constant" => costs[64], "equals_byte_string-cpu-arguments-intercept" => costs[65], "equals_byte_string-cpu-arguments-slope" => costs[66], - "equals_byte_string-memory-arguments" => costs[67], + "equals_byte_string-mem-arguments" => costs[67], "equals_data-cpu-arguments-intercept" => costs[68], "equals_data-cpu-arguments-slope" => costs[69], - "equals_data-memory-arguments" => costs[70], + "equals_data-mem-arguments" => costs[70], "equals_integer-cpu-arguments-intercept" => costs[71], "equals_integer-cpu-arguments-slope" => costs[72], - "equals_integer-memory-arguments" => costs[73], + "equals_integer-mem-arguments" => costs[73], "equals_string-cpu-arguments-constant" => costs[74], "equals_string-cpu-arguments-intercept" => costs[75], "equals_string-cpu-arguments-slope" => costs[76], - "equals_string-memory-arguments" => costs[77], + "equals_string-mem-arguments" => costs[77], "fst_pair-cpu-arguments" => costs[78], - "fst_pair-memory-arguments" => costs[79], + "fst_pair-mem-arguments" => costs[79], "head_list-cpu-arguments" => costs[80], - "head_list-memory-arguments" => costs[81], + "head_list-mem-arguments" => costs[81], "i_data-cpu-arguments" => costs[82], - "i_data-memory-arguments" => costs[83], + "i_data-mem-arguments" => costs[83], "if_then_else-cpu-arguments" => costs[84], - "if_then_else-memory-arguments" => costs[85], + "if_then_else-mem-arguments" => costs[85], "index_byte_string-cpu-arguments" => costs[86], - "index_byte_string-memory-arguments" => costs[87], + "index_byte_string-mem-arguments" => costs[87], "length_of_byte_string-cpu-arguments" => costs[88], - "length_of_byte_string-memory-arguments" => costs[89], + "length_of_byte_string-mem-arguments" => costs[89], "less_than_byte_string-cpu-arguments-intercept" => costs[90], "less_than_byte_string-cpu-arguments-slope" => costs[91], - "less_than_byte_string-memory-arguments" => costs[92], + "less_than_byte_string-mem-arguments" => costs[92], "less_than_equals_byte_string-cpu-arguments-intercept" => costs[93], "less_than_equals_byte_string-cpu-arguments-slope" => costs[94], - "less_than_equals_byte_string-memory-arguments" => costs[95], + "less_than_equals_byte_string-mem-arguments" => costs[95], "less_than_equals_integer-cpu-arguments-intercept" => costs[96], "less_than_equals_integer-cpu-arguments-slope" => costs[97], - "less_than_equals_integer-memory-arguments" => costs[98], + "less_than_equals_integer-mem-arguments" => costs[98], "less_than_integer-cpu-arguments-intercept" => costs[99], "less_than_integer-cpu-arguments-slope" => costs[100], - "less_than_integer-memory-arguments" => costs[101], + "less_than_integer-mem-arguments" => costs[101], "list_data-cpu-arguments" => costs[102], - "list_data-memory-arguments" => costs[103], + "list_data-mem-arguments" => costs[103], "map_data-cpu-arguments" => costs[104], - "map_data-memory-arguments" => costs[105], + "map_data-mem-arguments" => costs[105], "mk_cons-cpu-arguments" => costs[106], - "mk_cons-memory-arguments" => costs[107], + "mk_cons-mem-arguments" => costs[107], "mk_nil_data-cpu-arguments" => costs[108], - "mk_nil_data-memory-arguments" => costs[109], + "mk_nil_data-mem-arguments" => costs[109], "mk_nil_pair_data-cpu-arguments" => costs[110], - "mk_nil_pair_data-memory-arguments" => costs[111], + "mk_nil_pair_data-mem-arguments" => costs[111], "mk_pair_data-cpu-arguments" => costs[112], - "mk_pair_data-memory-arguments" => costs[113], + "mk_pair_data-mem-arguments" => costs[113], "mod_integer-cpu-arguments-constant" => costs[114], - "mod_integer-cpu-arguments-model-arguments-c00" => costs[115], - "mod_integer-cpu-arguments-model-arguments-c01" => costs[116], - "mod_integer-cpu-arguments-model-arguments-c02" => costs[117], - "mod_integer-cpu-arguments-model-arguments-c10" => costs[118], - "mod_integer-cpu-arguments-model-arguments-c11" => costs[119], - "mod_integer-cpu-arguments-model-arguments-c20" => costs[120], - "mod_integer-cpu-arguments-model-arguments-minimum" => costs[121], - "mod_integer-memory-arguments-intercept" => costs[122], - "mod_integer-memory-arguments-slope" => costs[123], + "mod_integer-cpu-arguments-c00" => costs[115], + "mod_integer-cpu-arguments-c01" => costs[116], + "mod_integer-cpu-arguments-c02" => costs[117], + "mod_integer-cpu-arguments-c10" => costs[118], + "mod_integer-cpu-arguments-c11" => costs[119], + "mod_integer-cpu-arguments-c20" => costs[120], + "mod_integer-cpu-arguments-minimum" => costs[121], + "mod_integer-mem-arguments-intercept" => costs[122], + "mod_integer-mem-arguments-slope" => costs[123], "multiply_integer-cpu-arguments-intercept" => costs[124], "multiply_integer-cpu-arguments-slope" => costs[125], - "multiply_integer-memory-arguments-intercept" => costs[126], - "multiply_integer-memory-arguments-slope" => costs[127], + "multiply_integer-mem-arguments-intercept" => costs[126], + "multiply_integer-mem-arguments-slope" => costs[127], "null_list-cpu-arguments" => costs[128], - "null_list-memory-arguments" => costs[129], + "null_list-mem-arguments" => costs[129], "quotient_integer-cpu-arguments-constant" => costs[130], - "quotient_integer-cpu-arguments-model-arguments-c00" => costs[131], - "quotient_integer-cpu-arguments-model-arguments-c01" => costs[132], - "quotient_integer-cpu-arguments-model-arguments-c02" => costs[133], - "quotient_integer-cpu-arguments-model-arguments-c10" => costs[134], - "quotient_integer-cpu-arguments-model-arguments-c11" => costs[135], - "quotient_integer-cpu-arguments-model-arguments-c20" => costs[136], - "quotient_integer-cpu-arguments-model-arguments-minimum" => costs[137], - "quotient_integer-memory-arguments-intercept" => costs[138], - "quotient_integer-memory-arguments-minimum" => costs[139], - "quotient_integer-memory-arguments-slope" => costs[140], + "quotient_integer-cpu-arguments-c00" => costs[131], + "quotient_integer-cpu-arguments-c01" => costs[132], + "quotient_integer-cpu-arguments-c02" => costs[133], + "quotient_integer-cpu-arguments-c10" => costs[134], + "quotient_integer-cpu-arguments-c11" => costs[135], + "quotient_integer-cpu-arguments-c20" => costs[136], + "quotient_integer-cpu-arguments-minimum" => costs[137], + "quotient_integer-mem-arguments-intercept" => costs[138], + "quotient_integer-mem-arguments-minimum" => costs[139], + "quotient_integer-mem-arguments-slope" => costs[140], "remainder_integer-cpu-arguments-constant" => costs[141], - "remainder_integer-cpu-arguments-model-arguments-c00" => costs[142], - "remainder_integer-cpu-arguments-model-arguments-c01" => costs[143], - "remainder_integer-cpu-arguments-model-arguments-c02" => costs[144], - "remainder_integer-cpu-arguments-model-arguments-c10" => costs[145], - "remainder_integer-cpu-arguments-model-arguments-c11" => costs[146], - "remainder_integer-cpu-arguments-model-arguments-c20" => costs[147], - "remainder_integer-cpu-arguments-model-arguments-minimum" => costs[148], - "remainder_integer-memory-arguments-intercept" => costs[149], - "remainder_integer-memory-arguments-slope" => costs[150], + "remainder_integer-cpu-arguments-c00" => costs[142], + "remainder_integer-cpu-arguments-c01" => costs[143], + "remainder_integer-cpu-arguments-c02" => costs[144], + "remainder_integer-cpu-arguments-c10" => costs[145], + "remainder_integer-cpu-arguments-c11" => costs[146], + "remainder_integer-cpu-arguments-c20" => costs[147], + "remainder_integer-cpu-arguments-minimum" => costs[148], + "remainder_integer-mem-arguments-intercept" => costs[149], + "remainder_integer-mem-arguments-slope" => costs[150], "serialise_data-cpu-arguments-intercept" => costs[151], "serialise_data-cpu-arguments-slope" => costs[152], - "serialise_data-memory-arguments-intercept" => costs[153], - "serialise_data-memory-arguments-slope" => costs[154], + "serialise_data-mem-arguments-intercept" => costs[153], + "serialise_data-mem-arguments-slope" => costs[154], "sha2_256-cpu-arguments-intercept" => costs[155], "sha2_256-cpu-arguments-slope" => costs[156], - "sha2_256-memory-arguments" => costs[157], + "sha2_256-mem-arguments" => costs[157], "sha3_256-cpu-arguments-intercept" => costs[158], "sha3_256-cpu-arguments-slope" => costs[159], - "sha3_256-memory-arguments" => costs[160], + "sha3_256-mem-arguments" => costs[160], "slice_byte_string-cpu-arguments-intercept" => costs[161], "slice_byte_string-cpu-arguments-slope" => costs[162], - "slice_byte_string-memory-arguments-intercept" => costs[163], - "slice_byte_string-memory-arguments-slope" => costs[164], + "slice_byte_string-mem-arguments-intercept" => costs[163], + "slice_byte_string-mem-arguments-slope" => costs[164], "snd_pair-cpu-arguments" => costs[165], - "snd_pair-memory-arguments" => costs[166], + "snd_pair-mem-arguments" => costs[166], "subtract_integer-cpu-arguments-intercept" => costs[167], "subtract_integer-cpu-arguments-slope" => costs[168], - "subtract_integer-memory-arguments-intercept" => costs[169], - "subtract_integer-memory-arguments-slope" => costs[170], + "subtract_integer-mem-arguments-intercept" => costs[169], + "subtract_integer-mem-arguments-slope" => costs[170], "tail_list-cpu-arguments" => costs[171], - "tail_list-memory-arguments" => costs[172], + "tail_list-mem-arguments" => costs[172], "trace-cpu-arguments" => costs[173], - "trace-memory-arguments" => costs[174], + "trace-mem-arguments" => costs[174], "un_b_data-cpu-arguments" => costs[175], - "un_b_data-memory-arguments" => costs[176], + "un_b_data-mem-arguments" => costs[176], "un_constr_data-cpu-arguments" => costs[177], - "un_constr_data-memory-arguments" => costs[178], + "un_constr_data-mem-arguments" => costs[178], "un_i_data-cpu-arguments" => costs[179], - "un_i_data-memory-arguments" => costs[180], + "un_i_data-mem-arguments" => costs[180], "un_list_data-cpu-arguments" => costs[181], - "un_list_data-memory-arguments" => costs[182], + "un_list_data-mem-arguments" => costs[182], "un_map_data-cpu-arguments" => costs[183], - "un_map_data-memory-arguments" => costs[184], + "un_map_data-mem-arguments" => costs[184], "verify_ecdsa_secp256k1_signature-cpu-arguments" => costs[185], - "verify_ecdsa_secp256k1_signature-memory-arguments" => costs[186], + "verify_ecdsa_secp256k1_signature-mem-arguments" => costs[186], "verify_ed25519_signature-cpu-arguments-intercept" => costs[187], "verify_ed25519_signature-cpu-arguments-slope" => costs[188], - "verify_ed25519_signature-memory-arguments" => costs[189], + "verify_ed25519_signature-mem-arguments" => costs[189], "verify_schnorr_secp256k1_signature-cpu-arguments-intercept" => costs[190], "verify_schnorr_secp256k1_signature-cpu-arguments-slope" => costs[191], - "verify_schnorr_secp256k1_signature-memory-arguments" => costs[192], + "verify_schnorr_secp256k1_signature-mem-arguments" => costs[192], "cek_constr_cost-exBudgetCPU" => costs[193], - "cek_constr_cost-exBudgetMemory" => costs[194], + "cek_constr_cost-exBudgetmem" => costs[194], "cek_case_cost-exBudgetCPU" => costs[195], - "cek_case_cost-exBudgetMemory" => costs[196], - "bls12_381_g1_add-cpu-arguments" => costs[197], - "bls12_381_g1_add-memory-arguments" => costs[198], - "bls12_381_g1_compress-cpu-arguments" => costs[199], - "bls12_381_g1_compress-memory-arguments" => costs[200], - "bls12_381_g1_equal-cpu-arguments" => costs[201], - "bls12_381_g1_equal-memory-arguments" => costs[202], - "bls12_381_g1_hash_to_group-cpu-arguments-intercept" => costs[203], - "bls12_381_g1_hash_to_group-cpu-arguments-slope" => costs[204], - "bls12_381_g1_hash_to_group-memory-arguments" => costs[205], - "bls12_381_g1_neg-cpu-arguments" => costs[206], - "bls12_381_g1_neg-memory-arguments" => costs[207], - "bls12_381_g1_scalar_mul-cpu-arguments-intercept" => costs[208], - "bls12_381_g1_scalar_mul-cpu-arguments-slope" => costs[209], - "bls12_381_g1_scalar_mul-memory-arguments" => costs[210], - "bls12_381_g1_uncompress-cpu-arguments" => costs[211], - "bls12_381_g1_uncompress-memory-arguments" => costs[212], - "bls12_381_g2_add-cpu-arguments" => costs[213], - "bls12_381_g2_add-memory-arguments" => costs[214], - "bls12_381_g2_compress-cpu-arguments" => costs[215], - "bls12_381_g2_compress-memory-arguments" => costs[216], - "bls12_381_g2_equal-cpu-arguments" => costs[217], - "bls12_381_g2_equal-memory-arguments" => costs[218], - "bls12_381_g2_hash_to_group-cpu-arguments-intercept" => costs[219], - "bls12_381_g2_hash_to_group-cpu-arguments-slope" => costs[220], - "bls12_381_g2_hash_to_group-memory-arguments" => costs[221], - "bls12_381_g2_neg-cpu-arguments" => costs[222], - "bls12_381_g2_neg-memory-arguments" => costs[223], - "bls12_381_g2_scalar_mul-cpu-arguments-intercept" => costs[224], - "bls12_381_g2_scalar_mul-cpu-arguments-slope" => costs[225], - "bls12_381_g2_scalar_mul-memory-arguments" => costs[226], - "bls12_381_g2_uncompress-cpu-arguments" => costs[227], - "bls12_381_g2_uncompress-memory-arguments" => costs[228], - "bls12_381_final_verify-cpu-arguments" => costs[229], - "bls12_381_final_verify-memory-arguments" => costs[230], - "bls12_381_miller_loop-cpu-arguments" => costs[231], - "bls12_381_miller_loop-memory-arguments" => costs[232], - "bls12_381_mul_ml_result-cpu-arguments" => costs[233], - "bls12_381_mul_ml_result-memory-arguments" => costs[234], + "cek_case_cost-exBudgetmem" => costs[196], + "bls12_381_G1_add-cpu-arguments" => costs[197], + "bls12_381_G1_add-mem-arguments" => costs[198], + "bls12_381_G1_compress-cpu-arguments" => costs[199], + "bls12_381_G1_compress-mem-arguments" => costs[200], + "bls12_381_G1_equal-cpu-arguments" => costs[201], + "bls12_381_G1_equal-mem-arguments" => costs[202], + "bls12_381_G1_hashToGroup-cpu-arguments-intercept" => costs[203], + "bls12_381_G1_hashToGroup-cpu-arguments-slope" => costs[204], + "bls12_381_G1_hashToGroup-mem-arguments" => costs[205], + "bls12_381_G1_neg-cpu-arguments" => costs[206], + "bls12_381_G1_neg-mem-arguments" => costs[207], + "bls12_381_G1_scalarMul-cpu-arguments-intercept" => costs[208], + "bls12_381_G1_scalarMul-cpu-arguments-slope" => costs[209], + "bls12_381_G1_scalarMul-mem-arguments" => costs[210], + "bls12_381_G1_uncompress-cpu-arguments" => costs[211], + "bls12_381_G1_uncompress-mem-arguments" => costs[212], + "bls12_381_G2_add-cpu-arguments" => costs[213], + "bls12_381_G2_add-mem-arguments" => costs[214], + "bls12_381_G2_compress-cpu-arguments" => costs[215], + "bls12_381_G2_compress-mem-arguments" => costs[216], + "bls12_381_G2_equal-cpu-arguments" => costs[217], + "bls12_381_G2_equal-mem-arguments" => costs[218], + "bls12_381_G2_hashToGroup-cpu-arguments-intercept" => costs[219], + "bls12_381_G2_hashToGroup-cpu-arguments-slope" => costs[220], + "bls12_381_G2_hashToGroup-mem-arguments" => costs[221], + "bls12_381_G2_neg-cpu-arguments" => costs[222], + "bls12_381_G2_neg-mem-arguments" => costs[223], + "bls12_381_G2_scalarMul-cpu-arguments-intercept" => costs[224], + "bls12_381_G2_scalarMul-cpu-arguments-slope" => costs[225], + "bls12_381_G2_scalarMul-mem-arguments" => costs[226], + "bls12_381_G2_uncompress-cpu-arguments" => costs[227], + "bls12_381_G2_uncompress-mem-arguments" => costs[228], + "bls12_381_finalVerify-cpu-arguments" => costs[229], + "bls12_381_finalVerify-mem-arguments" => costs[230], + "bls12_381_millerLoop-cpu-arguments" => costs[231], + "bls12_381_millerLoop-mem-arguments" => costs[232], + "bls12_381_mulMlResult-cpu-arguments" => costs[233], + "bls12_381_mulMlResult-mem-arguments" => costs[234], "keccak_256-cpu-arguments-intercept" => costs[235], "keccak_256-cpu-arguments-slope" => costs[236], - "keccak_256-memory-arguments" => costs[237], + "keccak_256-mem-arguments" => costs[237], "blake2b_224-cpu-arguments-intercept" => costs[238], "blake2b_224-cpu-arguments-slope" => costs[239], - "blake2b_224-memory-arguments" => costs[240], - "integer_to_byte_string-cpu-arguments-c0" => costs[241], - "integer_to_byte_string-cpu-arguments-c1" => costs[242], - "integer_to_byte_string-cpu-arguments-c2" => costs[243], - "integer_to_byte_string-memory-arguments-intercept" => costs[244], - "integer_to_byte_string-memory-arguments-slope" => costs[245], - "byte_string_to_integer-cpu-arguments-c0" => costs[246], - "byte_string_to_integer-cpu-arguments-c1" => costs[247], - "byte_string_to_integer-cpu-arguments-c2" => costs[248], - "byte_string_to_integer-memory-arguments-intercept" => costs[249], - "byte_string_to_integer-memory-arguments-slope" => costs[250] + "blake2b_224-mem-arguments-slope" => costs[240], + "integerToByteString-cpu-arguments-c0" => costs[241], + "integerToByteString-cpu-arguments-c1" => costs[242], + "integerToByteString-cpu-arguments-c2" => costs[243], + "integerToByteString-mem-arguments-intercept" => costs[244], + "integerToByteString-mem-arguments-slope" => costs[245], + "byteStringToInteger-cpu-arguments-c0" => costs[246], + "byteStringToInteger-cpu-arguments-c1" => costs[247], + "byteStringToInteger-cpu-arguments-c2" => costs[248], + "byteStringToInteger-mem-arguments-intercept" => costs[249], + "byteStringToInteger-mem-arguments-slope" => costs[250] } } }; @@ -4312,10 +4317,10 @@ pub fn initialize_cost_model(version: &Language, costs: &[i64]) -> CostModel { }), mem: ThreeArguments::LiteralInYorLinearInZ(LinearSize { intercept: *cost_map - .get("integerToByteString-cpu-arguments-intercept") + .get("integerToByteString-mem-arguments-intercept") .unwrap_or(&30000000000), slope: *cost_map - .get("integerToByteString-cpu-arguments-slope") + .get("integerToByteString-mem-arguments-slope") .unwrap_or(&30000000000), }), }, @@ -4333,10 +4338,10 @@ pub fn initialize_cost_model(version: &Language, costs: &[i64]) -> CostModel { }), mem: TwoArguments::LinearInY(LinearSize { intercept: *cost_map - .get("byteStringToInteger-cpu-arguments-intercept") + .get("byteStringToInteger-mem-arguments-intercept") .unwrap_or(&30000000000), slope: *cost_map - .get("byteStringToInteger-cpu-arguments-slope") + .get("byteStringToInteger-mem-arguments-slope") .unwrap_or(&30000000000), }), }, @@ -4631,4 +4636,31 @@ mod tests { assert_eq!(CostModel::v2(), cost_model); } + + #[test] + fn assert_default_cost_model_v3_mainnet_2024_08_24() { + let costs: Vec = vec![ + 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, + ]; + + let cost_model = initialize_cost_model(&Language::PlutusV3, &costs); + + assert_eq!(CostModel::v3(), cost_model); + } }