Skip to content

bench: add ExpModInteger benchmark script and plutuscall-voltv11-expmod profile#6615

Closed
Russoul wants to merge 4 commits into
fmaste/plutusv3from
russoul/plutus-exp-mod-bench
Closed

bench: add ExpModInteger benchmark script and plutuscall-voltv11-expmod profile#6615
Russoul wants to merge 4 commits into
fmaste/plutusv3from
russoul/plutus-exp-mod-bench

Conversation

@Russoul

@Russoul Russoul commented Jul 10, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Port a fixed-iteration expModInteger benchmark loop into plutus-scripts-bench, decoding a flat (n, a, m) from the redeemer (base a=3, prime modulus m=2^61-1), with e incrementing by 1 per iteration rather than doubling, to keep per-call cost roughly constant across the run and avoid any compiler hoisting of a loop-invariant computation.
  • Each iteration force-evaluates expModInteger a e m (let !_ = ...) rather than checking it against a running expected result — this is a benchmark script, not a correctness test, so there's nothing to carry forward between iterations. Includes the same "redeemer counter must be >= 1000000" sanity check the other benchmark scripts have.
  • Wire the script into getAllScripts/the cabal other-modules list, and add a data/ExpModInteger.redeemer.json + scripts-fallback/ExpModInteger.plutus for tx-generator/calibrate-script resolution.
  • Add a calibrated plutuscall-voltv11-expmod profile (LimitTxPerBlock_4, fee from calibrate-script run ExpModInteger txperblock_4) and register it via wb_profiles.mk.

Calibration and the profile were verified against real local cluster runs (make plutuscall-voltv11-expmod-auto), confirming genuine ExpModInteger transaction submissions with the expected redeemer values. The script and its calibrated txFee were iterated on a few times (inlining helpers, flattening the redeemer, dropping the correctness check), each time re-verified with calibrate-script and a real cluster run.

Note: the redeemer's loop-counter placeholder must not equal 1000000scriptDataModifyNumber's "already found a number to change" check is a before/after equality comparison, so a placeholder that already equals the reset target is a false negative and the reset falls through to the next number instead. Documented inline where this matters.

mgmeier and others added 4 commits July 9, 2026 15:23
…od profile

Ports a fixed-iteration expModInteger loop benchmark into plutus-scripts-bench,
wires it into tx-generator's script/redeemer resolution (data/ and
scripts-fallback/), and adds a calibrated plutuscall-voltv11-expmod profile
(LimitTxPerBlock_4) built off it.
… check

Inline the P/S wrapper types into loose Integers and flatten the redeemer
from a nested (n, (a, m)) to a flat (n, a, m), removing custom IsData
instances. Move interp/seed/next into mkSimpleExpModIntegerPolicyBench's
where clause so the plugin can inline them, and inline the compiled-code
binding into `script`, exporting only `script`.

Drop the expModInteger-vs-expected-result equality check carried over from
plutus-scripts-e2e's correctness tests: this is a benchmark script, not a
correctness test, so it now just force-evaluates expModInteger each
iteration (`let !_ = ...`) instead of threading a running result forward.
Add the same "redeemer counter must be >= 1000000" sanity check the other
benchmark scripts have.

Re-calibrate plutusTypeExpMod's txFee against the simplified script.
The Fermat's-little-theorem/primality justification for e0 = m - 2 stopped
applying once the correctness-check-against-expected-result was dropped;
nothing in the code relies on m being prime anymore.
@mgmeier

mgmeier commented Jul 11, 2026

Copy link
Copy Markdown
Contributor

The changes from this PR have been cherry-picked into #6440 and will be merged as part of that PR.

@mgmeier mgmeier closed this Jul 11, 2026
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.

2 participants