fix(ergotree-interpreter): reduce atLeast with degenerate bound instead of erroring#880
Open
mwaddip wants to merge 2 commits into
Open
fix(ergotree-interpreter): reduce atLeast with degenerate bound instead of erroring#880mwaddip wants to merge 2 commits into
mwaddip wants to merge 2 commits into
Conversation
…ad of erroring atLeast(bound, children) hard-errored when bound > children.size or bound < 0. The JVM AtLeast.reduce (sigma/ast/trees.scala) reduces these to trivial props: bound <= 0 => TrueProp, bound > size => FalseProp (for any bound, including > 255; the 255 limit is a require on the child count, not the bound). The error guards short-circuited before Cthreshold::reduce, which already encodes this. Reorder to mirror Scala; the u8 conversion now runs only on the valid 1 <= bound <= size path. Wedged testnet sync at block 184,137: a V0 self-replicating contract spends with atLeast(1, Coll[SigmaProp]()) (empty conditions), which must reduce to FalseProp. Adds three regression tests. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…enerate bound `CSigmaDslBuilder.atLeast` (sigma/data/CSigmaDslBuilder.scala) throws on more than 255 children (`MaxChildrenCountForAtLeastOp`) as its first statement, before `AtLeast.reduce`. The cap therefore precedes the degenerate-bound short-circuits: `atLeast(0, 256 props)` must error, not reduce to TrueProp. `ConcreteCollection` carries a u16 count, so >255 children are wire-constructible and reachable. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Author
|
Folded in a closely-related conformance fix on the same op: the 255-children cap.
Added |
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.
atLeast(bound, children)errored whenbound > children.sizeorbound < 0. The JVMAtLeast.reduce(sigma/ast/trees.scala) reduces these to trivial props instead:bound <= 0=> TrueProp,bound > size=> FalseProp (any bound, incl. > 255 — the 255 cap is arequireon the child count, not the bound). The guards short-circuited beforeCthreshold::reduce, which already encodes this; the reorder just lets it run, with the u8 conversion only on the valid1 <= bound <= sizepath.Found via a node syncing testnet: block 184,137 spends a V0 self-replicating contract evaluating
atLeast(1, Coll[SigmaProp]())(empty conditions) — must be FalseProp, not an error. Adds 3 regression tests.