Skip to content

fix(ergotree-ir): Global.powHit returns UnsignedBigInt, not Boolean#877

Open
mwaddip wants to merge 1 commit into
ergoplatform:developfrom
mwaddip:fix/powhit-return-type
Open

fix(ergotree-ir): Global.powHit returns UnsignedBigInt, not Boolean#877
mwaddip wants to merge 1 commit into
ergoplatform:developfrom
mwaddip:fix/powhit-return-type

Conversation

@mwaddip

@mwaddip mwaddip commented Jun 4, 2026

Copy link
Copy Markdown

Global.powHit (the Autolykos-2 hit value) was typed SBoolean in its method descriptor, but it returns a big integer — Scala SGlobalMethods.powHit returns SUnsignedBigInt, and the interpreter's POW_HIT_EVAL_FN already yields Value::UnsignedBigInt.

The mistype broke parse-time type-checking of coll.map(x => Global.powHit(..)).exists((u: UnsignedBigInt) => ..): the mapped collection resolved to Coll[Boolean], so Exists::new rejected the UnsignedBigInt => Boolean predicate ("Invalid condition tpe"). A full node wedges off testnet at canonical block 28,474 (accepted by JVM 6.0.3).

One-line type fix + regression tests (the descriptor, and the real block-28,474 tree parsing end-to-end). Serialization is unaffected — the return type is derived, never on the wire.

powHit computes the Autolykos-2 PoW hit value (a big integer), so its
result type is UnsignedBigInt — matching Scala SGlobalMethods.powHit and
the interpreter's POW_HIT_EVAL_FN, which already yields
Value::UnsignedBigInt. The descriptor mis-declared SBoolean, so
coll.map(x => Global.powHit(..)).exists((u: UnsignedBigInt) => ..) failed
parse-time type-checking ("Invalid condition tpe"), wedging a full node
off testnet at canonical block 28,474.

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