fix: reject non-pair tuples at eval to match sigma-state consensus#868
Open
mwaddip wants to merge 1 commit into
Open
fix: reject non-pair tuples at eval to match sigma-state consensus#868mwaddip wants to merge 1 commit into
mwaddip wants to merge 1 commit into
Conversation
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>
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.
Tupleeval 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 acceptedTuple[true, 7, 1234].Fix: reject
items.len() != 2at eval (before cost, as sigma-state). No compiled script emits flat arity-≥3 tuples, so it can't regress sync. Regression test added.