dcSpark / cardano-multiplatform-lib

Rust implementation of Cardano
MIT License
98 stars 36 forks source link

Possibly incorrect min_fee calculation. #354

Open Bromel777 opened 2 months ago

Bromel777 commented 2 months ago

Hi, I'm trying to calculate min_fee for this tx by calling min_fee(true), the result is less than real. Tx hash84a800838258201a2548ca9a2d9fb35a16c3da5c760b7704002c14339844647415f2e9bb5e59a5008258202b03bb18f6cfd952fca26c9e2114226c6ea3c5ab91d73be4e56227a55d1c010e0082582030d954068e79dfd28694fa897672ece76a4ba65524ee8aa5b32e1918eb93079a000183a3005839309dee0659686c3ab807895c929e3284c11222affd710b09be690f924db2f6abf60ccde92eae1a2f4fdf65f2eaf6208d872c6f0e597cc10b0701821b0000000288f93cd0a3581cd9bb181e3bb7993a343d6cdc7c1b96080243ff935ae18808432c0a44a14a4e4557205343524950541a0f8cd1fe581c6e917b8b965078a39804a6313e5be73535612421acd70aa83f0ec200a15820712764b20fe9746c5e6c0a576ffd0fb8a3ca136773a8cb8db02fc3fb0937b6e71b7fffffff9b8b1550581cd8eb52caf3289a2880288b23141ce3d2a7025dcf76f26fd5659add06a15820ddae4822e3183bcd3f1527cbcd723b3e57f5dd4774587f2e53c1d7052813575801028201d818590111d8799fd8799f581cd8eb52caf3289a2880288b23141ce3d2a7025dcf76f26fd5659add065820ddae4822e3183bcd3f1527cbcd723b3e57f5dd4774587f2e53c1d70528135758ffd8799f4040ffd8799f581cd9bb181e3bb7993a343d6cdc7c1b96080243ff935ae18808432c0a444a4e455720534352495054ffd8799f581c6e917b8b965078a39804a6313e5be73535612421acd70aa83f0ec2005820712764b20fe9746c5e6c0a576ffd0fb8a3ca136773a8cb8db02fc3fb0937b6e7ff1a000182b81864190fa0009fd8799fd87a9f581ce5619f78d716cc24ea924e4412d83353ae390edd9905ecc6d5c85c2bffffff00581c75c4570eb625ae881b32a34c52b159f6f3f3f2c7aaabf5bac4688133ffa200583900719bee424a97b58b3dca88fe5da6feac6494aa7226f975f3506c5b257846f6bb07f5b2825885e4502679e699b4e60a0c4609a46bc35454cd01821a001a7f25a1581cd9bb181e3bb7993a343d6cdc7c1b96080243ff935ae18808432c0a44a14a4e455720534352495054195c98a200583900719bee424a97b58b3dca88fe5da6feac6494aa7226f975f3506c5b257846f6bb07f5b2825885e4502679e699b4e60a0c4609a46bc35454cd01821a001b37e7a1581cd9bb181e3bb7993a343d6cdc7c1b96080243ff935ae18808432c0a44a14a4e455720534352495054195c93021a0008d89405a1581df096f5c1bee23481335ff4aece32fe1dfa1aa40a944a66d2d6edc9a9a5000b58203aa61c76f6cf133bac54787dbd0e381f3628d197a5cc61d6cb380eb3ab65440a0d81825820204619c402f17d83be5cdf7728514053a948f46ab44cf193957c720ba1b53328000e81581c5cb2c968e5d1c7197a6ce7615967310a375545d9bc65063a964335b21283825820a85dbebcf7a9c27a2548191e6516b12140ec744c142248355ddeef8652ab071f00825820d676064bdbc3aa59bcf266506cd6d6bcf246d9874e7f21089fccca2e36b3064e0082582077fc5b1688a79dd5b9bdba5981b7403b519690dda4f1471fffa78151bbefe0f501a20081825820d39f6e2677e23ac35da0a65bef78ae5cfdf34eb57c4059d4d7f31aa9ccdb8eff5840adf9788ac6d4201fb4e2547de0b7f9a8cad1b71b7681e5512deb095649105d16f0cc05d9694cde090a200b99b0d494cd86a2ed9c969cb6b642bd904750eac3050584840000d879820200821a0009eb101a0f7f4900840001d87a80821a000298101a03dfd240840002d87a80821a000298101a03dfd24084030080821a000f42401a160dc080f5f6 Value from min_fee(true) is 579732 Value from attempt to submit tx manually by Cardano-cli 592007

Bromel777 commented 2 months ago

next cost models used

let ops_v1 = [
        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, 228465, 122, 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, 228465, 122, 0, 1, 1,
        90434, 519, 0, 1, 74433, 32, 85848, 228465, 122, 0, 1, 1, 85848, 228465, 122, 0, 1, 1, 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, 53384111, 14333, 10,
    ];

  let ops_v2 = [
      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, 228465, 122, 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, 228465, 122, 0, 1, 1,
      90434, 519, 0, 1, 74433, 32, 85848, 228465, 122, 0, 1, 1, 85848, 228465, 122, 0, 1, 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,
  ];

  let ops_v3 = [
      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,
  ];
rooooooooob commented 2 months ago

Can you provide more info about the scripts used in those reference inputs? (size is the relevant thing here)

From where are they all being used? I'm guessing they aren't just used to spend utxos?

Could you share your tx-builder-related code?

rooooooooob commented 1 month ago

@Bromel777 can you check to see if #359 fixes this?