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

Use non-zero costmodels in Imp tests #4766

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

teodanciu
Copy link
Contributor

@teodanciu teodanciu commented Nov 20, 2024

Description

At the moment, Imp tests are using zeroCostModels with Plutus scripts, which, in essence means that the way we are setting the budget in the redeemers has no impact on script execution.

In this PR, I have switched to using the cost models provided by Plutus for testing.
Making the switch revealed that we weren't computing the budget correctly, but because of the zero cost models, the problem hasn't manifested.
Specifically, the budget (set in the redeemers) depends on the value of the fee, which in turn depends on the value of the redeemers (I think via the size of the transaction).

In master, the order of the fixup is: fixupRedeemers >=> fixupFees ... With non-zero cost models, tests are failing because of unsufficient budget (that doesn't take the fee into account).
In this PR, I'm first computing the fee, maximizing it with respect to the budget (so assuming the maximum budget), then computing the real budget, with a previously computed more realistic fee.
I also added 10% to the fee as a margin, because in some cases it would still go over.

Any suggestions for a more elegant solution are welcome!

Closes #4404

Checklist

  • Commit sequence broadly makes sense and commits have useful messages
  • New tests are added if needed and existing tests are updated
  • All visible changes are prepended to the latest section of a CHANGELOG.md for the affected packages.
    New section is never added with the code changes. (See RELEASING.md)
  • When applicable, versions are updated in .cabal and CHANGELOG.md files according to the
    versioning process.
  • The version bounds in .cabal files for all affected packages are updated.
    If you change the bounds in a cabal file, that package itself must have a version increase. (See RELEASING.md)
  • Code is formatted with fourmolu (use scripts/fourmolize.sh)
  • Cabal files are formatted (use scripts/cabal-format.sh)
  • hie.yaml has been updated (use scripts/gen-hie.sh)
  • Self-reviewed the diff

@teodanciu
Copy link
Contributor Author

Just an initial attempt, investigating now the situation of costmodels in plutus

@teodanciu teodanciu force-pushed the td/nonzero-costmodels-in-tests branch 3 times, most recently from 9fc1a40 to dfdbdae Compare November 29, 2024 19:31
so that we can fixup the redeemers after the fee was computed, in order
to have enough budget for the scripts
in order to cover the things fixed up after the fee was fixed up
@teodanciu teodanciu force-pushed the td/nonzero-costmodels-in-tests branch from dfdbdae to 2d072dc Compare November 29, 2024 19:42
@teodanciu teodanciu marked this pull request as ready for review November 29, 2024 19:58
@teodanciu teodanciu requested a review from a team as a code owner November 29, 2024 19:58
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

Successfully merging this pull request may close these issues.

Switch to using Plutus testingCostModels instead of zero models in Tests
1 participant