Skip to content

fix: reject non-pair tuples at eval to match sigma-state consensus#868

Open
mwaddip wants to merge 1 commit into
ergoplatform:developfrom
mwaddip:fix/tuple-arity-jvm-parity
Open

fix: reject non-pair tuples at eval to match sigma-state consensus#868
mwaddip wants to merge 1 commit into
ergoplatform:developfrom
mwaddip:fix/tuple-arity-jvm-parity

Conversation

@mwaddip
Copy link
Copy Markdown

@mwaddip mwaddip commented May 30, 2026

Tuple eval accepted any arity (TupleItems = BoundedVec<2,255>), but sigma-state restricts tuples to exactly 2 at eval — Tuple.eval (values.scala): if (items.length != 2) error("Invalid tuple"), unconditional; the deserializer accepts arity-N. So sigma-rust evaluated arity-≥3 tuples the reference rejects — a consensus accept/reject divergence (accepted here, rejected by sigma-state).

Found vs sigma-state 6.0.3: tree 0086030101020703a413 = Tuple(TrueLeaf, Byte 7, Short 1234) → JVM rejects "Invalid tuple"; sigma-rust accepted Tuple[true, 7, 1234].

Fix: reject items.len() != 2 at eval (before cost, as sigma-state). No compiled script emits flat arity-≥3 tuples, so it can't regress sync. Regression test added.

sigma-state restricts tuples to exactly 2 elements: `Tuple.eval` rejects
`items.length != 2` with "Invalid tuple" (values.scala: "in v5.0 version we
support only tuples of 2 elements to be equivalent with v4.x"). The check is
unconditional (no version gate); sigma-state 6.0.3 is JIT-only and evaluates
every height through it.

sigma-rust models tuples as flat N-ary (`TupleItems = BoundedVec<2,255>`) and
its `Tuple` eval had no arity check, so it accepted arity>=3 tuples the JVM
rejects — a consensus accept/reject divergence: sigma-rust would accept a spend
the JVM rejects (crafter-constructible). Surfaced by the santa eval fixture
`tuple_triple_bool_byte_short` (tree 0086030101020703a413): JVM rejects "Invalid
tuple"; sigma-rust accepted Tuple[true, 7, 1234].

Mirror the JVM: reject `items.len() != 2` at eval. No mainnet block can carry an
arity>=3 tuple (the JVM rejects them), so this cannot regress historical sync.
Regression test added.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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.

1 participant