Compute fees via tezos-client in morley-client
Clarification and motivation
We have Morley.Client.Util.calcFees
that we use to calculate appropriate fees for a transaction. First of all, the formula we are using there is not correct. In includes minimalTezPerGas * consumedGas
where minimalTezPerGas = 1
. However, tezos-client
multiplies consumed gas by 0.1
. So we unnecessarily compute too high fees.
Even if we fix the formula, it may still become wrong at some point, because Tezos developers may change it and reference implementation may use different fees. A more robust solution seems to be to simulate a transaction by running tezos-client
in dry-run mode and using the fees that it computes. We need to parse its output for that, but we currently parse its output in several places anyway.
Note that tezos-client
does not support running more than one transaction while our API provides such functionality (to run multiple transactions in batch). So apparently in order to compute fees for a batch we need to run tezos-client
multiple times. One of the main advantages of batch transfers is that they allows to make transactions faster which is useful for our tests. I. e. we can test scenarios with many transactions quite quickly. However, if we dry-run tezos-client
for each transaction, it may slow things down substantially. So I think we should measure how efficient this change it.
Acceptance criteria
- Make it possible to compute fees by running
tezos-client
in dry-run mode instead of usingcalcFees
. - Compare how significantly it slows down batch transfers involving 10+ transactions.
- If not very significantly, I think we can always use
tezos-client
. If significantly, we can let the user decide whether to usetezos-client
or hardcoded formula. In this casecalcFees
should be fixed to matchtezos-client
behavior.