Skip to content

fix: parse box value and token amount unbounded from the wire#885

Open
mwaddip wants to merge 1 commit into
ergoplatform:developfrom
mwaddip:fix/box-u64-wire-parse
Open

fix: parse box value and token amount unbounded from the wire#885
mwaddip wants to merge 1 commit into
ergoplatform:developfrom
mwaddip:fix/box-u64-wire-parse

Conversation

@mwaddip

@mwaddip mwaddip commented Jun 7, 2026

Copy link
Copy Markdown

The reference impl parses box value and token amounts with getULong() and no range check (ErgoBoxCandidate.parseBodyWithIndexedDigests), storing signed Longs: values in [2^63, 2^64) hydrate and surface as their signed view at eval (SELF.value, R0, tokens(0)._2), and there is no minimum at parse either (min-value-per-byte is a node tx-validation rule, not a deserialization bound).

sigma-rust rejected such boxes at sigma_parse via BoxValue/TokenAmount bounds, so a context box the JVM evaluates could not even deserialize. Parse now constructs directly; bounds stay on the construction API (new/try_from, checked arithmetic) used for tx building.

The issue-#698 on-chain Coll[Box] register constant now parses, as on the JVM. Eval pinned by JVM-blessed byte vectors.

… wire

The reference implementation reads both with getULong() and no range
check (ErgoBoxCandidate.parseBodyWithIndexedDigests), storing them as
signed Longs: values in [2^63, 2^64) hydrate and surface as their
signed (negative) view at eval (SELF.value, R0, SELF.tokens(0)._2),
and there is no minimum at parse either (the min-value-per-byte rule
is a node transaction-validation rule, not a deserialization bound).

sigma-rust rejected such boxes at sigma_parse via BoxValue/TokenAmount
try_from bounds, so a context carrying one could not even be
constructed from bytes where the JVM evaluates it. Parse now constructs
the values directly; bounds stay enforced in the construction API
(new/try_from, checked arithmetic) used for transaction building.

The issue-ergoplatform#698 on-chain Coll[Box] register constant accordingly now
parses (as on the JVM) instead of failing with ValueOutOfBounds; eval
surfaces are pinned by JVM-blessed byte vectors (santa-eval
Box.signed_view_u64).

Co-Authored-By: Claude Opus 4.8 <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