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

Merged
merged 3 commits into from
Dec 6, 2024

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 teodanciu force-pushed the td/nonzero-costmodels-in-tests branch 4 times, most recently 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
@teodanciu teodanciu force-pushed the td/nonzero-costmodels-in-tests branch from 2d072dc to e6b1b38 Compare December 2, 2024 15:22
Copy link
Collaborator

@lehins lehins left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any suggestions for a more elegant solution are welcome!

I think we could find a fix point by calling fixup functionality until transaction stops changing. This would require some thought about making most fixup functionality to be idempotent.

That being said, we could merge this PR as-is and figure it out in the future. I leave this choice up to you @teodanciu If you decide to postpone this work until later then just make sure you create a ticket about improving fixup functionality

@teodanciu
Copy link
Contributor Author

Merging because I think it does bring value to use realistic costmodels, but agree it should be better! Added an issue for this: #4784

@teodanciu teodanciu enabled auto-merge December 6, 2024 11:39
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 235b66e to b5b8b4a Compare December 6, 2024 13:21
@teodanciu teodanciu merged commit e9f9b18 into master Dec 6, 2024
153 of 154 checks passed
@teodanciu teodanciu deleted the td/nonzero-costmodels-in-tests branch December 6, 2024 15:51
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
2 participants