Skip to content

fix: AvlTree ops map wrong-tree proofs and failed ops per the reference impl#890

Open
mwaddip wants to merge 2 commits into
ergoplatform:developfrom
mwaddip:fix/avltree-wrong-tree-proof
Open

fix: AvlTree ops map wrong-tree proofs and failed ops per the reference impl#890
mwaddip wants to merge 2 commits into
ergoplatform:developfrom
mwaddip:fix/avltree-wrong-tree-proof

Conversation

@mwaddip

@mwaddip mwaddip commented Jun 7, 2026

Copy link
Copy Markdown

BatchAVLVerifier::new errors on a digest mismatch; every AvlTree method but insertOrUpdate (#886) propagated that as an eval error. The reference verifier construction never throws (CErgoTreeEvaluator.scala): ops fail on the no-tree verifier and each method maps that itself — contains → false (:89); get/getMany raise "Tree proof is incorrect" (:106/:126; no keys → empty coll); insert raises pre-v3, evals to None from v3 (#908 gate, :150; no entries → None); update/remove → None (:183/:240).

Second commit: remove_eval loops with cfor — no break, op results ignored (:240–245) — so a valid proof carrying ops that fail against it evals to None (digest decides); we raised at the first failure.

Pinned per arm by prover-built wrong-tree tests and JVM-blessed vectors.

mwaddip and others added 2 commits June 7, 2026 16:20
… verifier semantics

The reference impl's verifier construction never throws: a proof that
does not match the tree digest yields a verifier with no reconstructed
tree, every op fails, and each method maps that per its own semantics
(CErgoTreeEvaluator): contains → false (failed lookup); get/getMany →
"Tree proof is incorrect" (and getMany with no keys returns the empty
collection — no lookup runs); insert → raise pre-v3 / None from v3
(issue #908), None with no entries; update/remove → None (None digest).

sigma-rust's BatchAVLVerifier::new instead errors at construction on
the digest mismatch, and every method but insertOrUpdate (PR ergoplatform#886)
propagated that as an eval error. Catch it per method; the op loops
and digest inspection already mirrored the reference.

Pinned by prover-built wrong-tree proof tests per method and the
JVM-blessed byte vectors (santa-eval AvlTree.wrong_tree_proof
contains-false/update-none/remove-none, AvlTree.insert_wrong_tree
insert-none).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…e the reference impl

The reference impl's remove_eval loops with cfor — no break, no result
check: a failed remove invalidates the verifier and the None digest
decides the outcome (None). sigma-rust raised "Incorrect remove" at the
first failed op, so a valid proof carrying ops that fail against it
(e.g. removing a key the proof does not commit) errored where the JVM
evaluates to None.

Pinned by a valid-proof/mismatched-op test.

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