Skip to content

fix: preserve evaluatorMode in Emulator.setSlot and ImmutableEmulator.fromEmulator#315

Merged
rssh merged 2 commits into
masterfrom
fix/preserve-evaluator-mode-314
Jun 25, 2026
Merged

fix: preserve evaluatorMode in Emulator.setSlot and ImmutableEmulator.fromEmulator#315
rssh merged 2 commits into
masterfrom
fix/preserve-evaluator-mode-314

Conversation

@rssh

@rssh rssh commented Jun 24, 2026

Copy link
Copy Markdown
Collaborator

Summary

Fixes #314. Two places reconstructed an execution context with a fresh constructor that omitted evaluatorMode (and debugScripts), silently reverting to the Context default EvaluatorMode.Validate. Any transaction built to rely on EvaluateAndComputeCost (redeemer ExUnits filled in by the evaluator) was then rejected after the reconstruction — with no warning.

Changes

  • Emulator.setSlot (JVM + JS): replace the field-by-field Context(fee=…, env=…, slotConfig=…) rebuild with ctx.copy(env = ctx.env.copy(slot = slot)), so evaluatorMode and debugScripts survive a slot change.
  • EmulatorBase: add a public evaluatorMode accessor (the issue noted the mode wasn't exposed).
  • ImmutableEmulator.fromEmulator: carry over emulator.evaluatorMode instead of defaulting to Validate.

Audited the other Context(...) constructions: the rest build fresh contexts with no prior mode to preserve (JEmulator init, Context.testMainnet) or use a different Context type (txbuilder), so they are not affected.

Tests

Verified scalusCardanoLedgerJVM + scalusTestkitJVM tests pass and scalusCardanoLedgerJS compiles.

Note

EmulatorBase.evaluatorMode is a public-API addition to a trait (concrete default body, so source-compatible). Worth a sbt mima pass in CI before release.

rssh added 2 commits June 24, 2026 15:15
….fromEmulator

Emulator.setSlot (JVM and JS) rebuilt the Context with a fresh
constructor that omitted evaluatorMode and debugScripts, silently
reverting to the Context default EvaluatorMode.Validate. Switch to
ctx.copy(...) so both fields survive a slot change.

ImmutableEmulator.fromEmulator dropped the source mode for the same
reason. Expose EmulatorBase.evaluatorMode and carry it over in
fromEmulator.

Fixes valid transactions built for EvaluateAndComputeCost being
rejected after a slot advance (e.g. via ContractScalaCheckCommands).

Closes #314
UplcCli.uplcToFlat ignored the subprocess exit code, so a failed or
killed 'uplc convert' (e.g. OOM under CI memory pressure) silently
returned truncated stdout that the flat-encoding conformance test then
reported as an encoding mismatch. Capture stdout as raw bytes, capture
stderr, and throw on a non-zero exit code (mirroring evalFlat).

ProgramFlatTest now dumps the full failing program on mismatch (version,
first-diff offset, untruncated plutus/scalus hex, and the AST) so a
flaky failure is reproducible rather than truncated by assert's diff.
@rssh rssh merged commit 42afa1c into master Jun 25, 2026
3 of 4 checks passed
@rssh rssh deleted the fix/preserve-evaluator-mode-314 branch June 25, 2026 09:06
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.

Emulator.setSlot and ImmutableEmulator.fromEmulator silently drop evaluatorMode (revert to Validate)

1 participant