fix: preserve evaluatorMode in Emulator.setSlot and ImmutableEmulator.fromEmulator#315
Merged
Conversation
….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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #314. Two places reconstructed an execution context with a fresh constructor that omitted
evaluatorMode(anddebugScripts), silently reverting to theContextdefaultEvaluatorMode.Validate. Any transaction built to rely onEvaluateAndComputeCost(redeemerExUnitsfilled in by the evaluator) was then rejected after the reconstruction — with no warning.Changes
Emulator.setSlot(JVM + JS): replace the field-by-fieldContext(fee=…, env=…, slotConfig=…)rebuild withctx.copy(env = ctx.env.copy(slot = slot)), soevaluatorModeanddebugScriptssurvive a slot change.EmulatorBase: add a publicevaluatorModeaccessor (the issue noted the mode wasn't exposed).ImmutableEmulator.fromEmulator: carry overemulator.evaluatorModeinstead of defaulting toValidate.Audited the other
Context(...)constructions: the rest build fresh contexts with no prior mode to preserve (JEmulatorinit,Context.testMainnet) or use a differentContexttype (txbuilder), so they are not affected.Tests
EmulatorTest: "setSlot preserves evaluatorMode and debugScripts (issue Emulator.setSlot and ImmutableEmulator.fromEmulator silently drop evaluatorMode (revert to Validate) #314)".ImmutableEmulatorTest:fromEmulatorcarries the mode, and preserves it across a slot advance.Verified
scalusCardanoLedgerJVM+scalusTestkitJVMtests pass andscalusCardanoLedgerJScompiles.Note
EmulatorBase.evaluatorModeis a public-API addition to a trait (concrete default body, so source-compatible). Worth asbt mimapass in CI before release.