input-output-hk / input-output-hk/PlutusCoreBlaster

[Bug]: CEK machine's Case-on-constants is not gated behind a protocol version, unlike upstream

Open
#32 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Lean
Stars
14
Forks
6
Avg merge
4d 8h
Merged PRs (30d)
2

Description

## Description

`Case` on a scrutinee that reduces to a non-`VConstr` constant (e.g. matching on a bare `Integer`/`Bool`/etc. rather than a `Constr`-built value) was only ever valid on-chain starting with the Van Rossem hard fork (protocol version 11); before that, evaluating such a term should fail the same way it would if `case`-on-constants didn't exist at all. `step` in `PlutusCore/UPLC/CekMachine.lean` previously handled all `CaseScrutinee` branches unconditionally, with no protocol-version check, so it always accepted case-on-constants regardless of which protocol version it's asked to emulate. This makes the machine's evaluation behavior diverge from the ledger for any script evaluated against a protocol version older than Van Rossem that uses this construct.

## Steps to Reproduce

```lean
import PlutusCore.UPLC.CekMachine

open PlutusCore.UPLC.CekMachine
open PlutusCore.Default

-- `case 5 [t0, t1]` -- Case scrutinizing a bare constant, not a Constr value.
-- Evaluate under a pre-Van-Rossem protocol version.
#eval cekExecuteProgram someCaseOnConstantTerm .plutusV3 .preConway []
```

## Expected Behavior

Under `.preConway` / `.postConwayPreVanRossem`, evaluating a `Case` whose scrutinee reduces to a non-`VConstr` constant should behave as an evaluation failure (mirroring the ledger/Haskell reference, which does not support this construct before Van Rossem).

## Actual Behavior

The CEK `step` function has no protocol-version awareness for this case at all, so case-on-constants is accepted unconditionally at every protocol version, including ones where it should not be.

## Lean Version

v4.24.0

## Z3 Version

N/A (no SMT tactics involved)

Contributor guide

No contributing guide indexed for this repository

Research direction

Start in PlutusCore/UPLC/CekMachine.lean at the step function's CaseScrutinee handling, then run the provided cekExecuteProgram example under .preConway and compare it with Van Rossem-era protocol versions. Done means non-VConstr constant cases fail before Van Rossem while remaining supported afterward.

Written by the indexing model from the issue text.

Assessment

Domain
compilers
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Clearly specified
Newbie friendliness
72/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.