Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fee probing #341

Open
gabrielhdt opened this issue Apr 12, 2023 · 0 comments
Open

Fee probing #341

gabrielhdt opened this issue Apr 12, 2023 · 0 comments
Assignees

Comments

@gabrielhdt
Copy link
Contributor

Symptoms

The fee available in the context of validation is not always the fee applied on the transaction.

Reproduce

To see this bug, you need a validator whose behaviour depends on the fee.

For an example, see the tests at

where the validator checkFeeBetween succeeds if the fee is in some given range.

  • the test case "3 Ada is the upper bound" shows that if the upper bound is lower than 3A, the validator fails. So the fee is greater or equal to 3A
  • the test case "350 000 Lovelaces is the lower bound" shows that if the lower bound is greater than 350 000 Lovelaces, the validator fails. Therefore the fee is lower or equal to 350k Lovelaces.

Are there several fees? Some explanations later on.

Expected behaviour

One should be able to reduce that range to a single value, the value of the fee itself, which is supposed to be deterministic and unique per transaction.

Some explanations

Because the value of the fee depends on the complexity of the validator, the latter has to be run to compute the former. This leads to a fixpoint algorithm:

  1. set the fee to some arbitrary value $f_0$
  2. run the validator using that value and evaluate the cost of running the validator(s)
  3. fix the fee to $f_1$ and re-iterate until the fee has stabilised.

Therefore, the validator is run in several contexts which differ at least by their fee value. In particular, validators are always run at least once with $f_0$ so one cannot write a validator that succeeds if and only if the transaction it is run in has fees strictly smaller than $f_0$.

From our tests, we can deduce that $f_0$ is either close to 3Ada and the final fee is close to 350,000 Lovelaces (so the fee decreases through iterations of the algorithm); or $f_0$ is close to 350,000 Lovelaces and the final fee is close to 3 Ada, which is less probable since the transaction is a light one.

Environment
Cooked v2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants