Skip to content

fix: AvlTree digest is variable-length; updateDigest stores any-length Coll[Byte]#894

Open
mwaddip wants to merge 1 commit into
ergoplatform:developfrom
mwaddip:fix/avltree-updatedigest-anylength
Open

fix: AvlTree digest is variable-length; updateDigest stores any-length Coll[Byte]#894
mwaddip wants to merge 1 commit into
ergoplatform:developfrom
mwaddip:fix/avltree-updatedigest-anylength

Conversation

@mwaddip

@mwaddip mwaddip commented Jun 7, 2026

Copy link
Copy Markdown

The reference AvlTreeData.digest is a Coll[Byte] (variable-length) and CAvlTree.updateDigest stores any-length bytes with no length check. sigma-rust used a fixed ADDigest (33 bytes), so updateDigest rejected other lengths — a consensus split: tree.updateDigest(shortColl) succeeds on the reference interpreter but errored here.

AvlTreeData.digest becomes Vec<u8>; updateDigest stores the bytes verbatim. Serialization mirrors the reference AvlTreeData.serializer: the digest is written raw (putBytes) and the parser reads exactly 33 bytes (getBytes(DigestSize)) — wire-identical for normal trees; a non-33 digest exists only in memory (cannot round-trip, same as the reference). CreateAvlTree keeps its 33-byte validation.

Found via SANTA conformance testing.

…h Coll[Byte]

The reference `AvlTreeData.digest` is a `Coll[Byte]` (variable-length), and
`CAvlTree.updateDigest` stores whatever bytes it is given with no length check.
sigma-rust used a fixed `ADDigest` (33 bytes) and `updateDigest` rejected any
other length via `ADDigest::try_from` — a consensus split: a script calling
`tree.updateDigest(shortColl)` succeeds on the reference interpreter but errored
here.

Change `AvlTreeData.digest` to `Vec<u8>`; `updateDigest` now stores the bytes
verbatim, matching the reference. Serialization mirrors the JVM
`AvlTreeData.serializer`: the digest is written raw (`putBytes`) and the parser
reads exactly 33 bytes (`getBytes(DigestSize)`), so the wire format is
byte-identical for normal trees and a non-33 digest exists only in memory (it
cannot round-trip, same as the reference impl). CreateAvlTree keeps its 33-byte
validation, unchanged.

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