tweag / cooked-validators

MIT License
39 stars 11 forks source link

Usage oriented test-suite #324

Open gabrielhdt opened 1 year ago

gabrielhdt commented 1 year ago

What is this all about

This PR provide a test suite designed around nominal use cases of Cooked. It ought to contain

Changes

Questionable behaviours revealed so far

The problem with validators checking fees

Because the fee of a transaction is available in its context (see the datatype for contexts), one may write validators that succeed upon some condition over the fee. However, 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$.

See issue #341.