Skip to content

fix: Option DATA parser treats any nonzero tag as Some, per JVM getOption#895

Open
mwaddip wants to merge 1 commit into
ergoplatform:developfrom
mwaddip:fix/option-data-nonzero-tag
Open

fix: Option DATA parser treats any nonzero tag as Some, per JVM getOption#895
mwaddip wants to merge 1 commit into
ergoplatform:developfrom
mwaddip:fix/option-data-nonzero-tag

Conversation

@mwaddip

@mwaddip mwaddip commented Jun 8, 2026

Copy link
Copy Markdown

The JVM reads the Option DATA tag through getOption (sigma Extensions.getOption): if (tag != 0) Some(getValue) else None — any nonzero tag byte is Some. Our shared sigma-ser get_option mapped only tag 1 to Some and silently returned None on other nonzero tags without consuming the value bytes, desyncing the stream: a v3 tree carrying an SOption constant with DATA tag 0x02 failed to parse where the JVM evaluates it to Some(5).

Fixes the reader helper to mirror the convention; put_option still writes 0/1, so the write side is unchanged. The only other caller (ergo-p2p peer-spec parsing) aligns with the same scorex reader convention.

Tests: reader tag pins (0/1/2/255) and the corpus constant 28 02 0a, standalone and segregated in a v3 tree.

…tion

The JVM reads the Option DATA tag through getOption (sigma
Extensions.getOption): `if (tag != 0) Some(getValue) else None`. Our
sigma-ser get_option mapped only tag 1 to Some and silently returned None
on any other nonzero tag WITHOUT consuming the value bytes, desyncing the
stream — a v3 tree carrying an SOption constant with DATA tag 0x02 failed
to parse where the JVM evaluates it to Some(5).

Fix the shared reader helper to mirror the convention; put_option still
writes 0/1, so the write side is unchanged. The only other caller
(ergo-p2p peer-spec parsing) aligns with the same scorex reader
convention.

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