Skip to content

fix(interpreter): wrap Resolver closures in Arc::new for upstream API change#865

Draft
mwaddip wants to merge 2 commits into
ergoplatform:developfrom
mwaddip:fix/avltree-arc-resolver
Draft

fix(interpreter): wrap Resolver closures in Arc::new for upstream API change#865
mwaddip wants to merge 2 commits into
ergoplatform:developfrom
mwaddip:fix/avltree-arc-resolver

Conversation

@mwaddip
Copy link
Copy Markdown

@mwaddip mwaddip commented May 18, 2026

Adapts the 13 AVLTree::new call sites in ergotree-interpreter (savltree.rs, tree_lookup.rs, create_avl_tree.rs) from bare fn closure to Arc::new(...), matching the Resolver type change in ergoplatform/ergo_avltree_rust#10. Arc not Box because AVLTree: Clone.

Draft. Blocked on #10 merge + ergo_avltree_rust version bump. Locally validated on integration/ergots via [patch.crates-io].

mwaddip and others added 2 commits May 19, 2026 00:37
…ver API

The local fork at ~/projects/ergo_avltree_rust/ (HEAD 879545c) changed
the Resolver type from `fn(&Digest32) -> Node` to
`Arc<dyn Fn(&Digest32) -> Node + Send + Sync>` (fork commit 28862a1) to
support stateful persistence-backed resolvers.

The fork-corrected contains semantics (fork commit 879545c) is the
canonical reference for the ergots TypeScript port's AVL+ verifier, so
ergots' fixture-gen applies [patch.crates-io] to redirect
ergo_avltree_rust to the fork. That redirection forces ergotree-
interpreter to compile against the new Resolver API.

This commit wraps every bare-closure Resolver call site in Arc::new(...)
so ergotree-interpreter compiles cleanly against the fork. Identical to
the migration upstream sigma-rust would need if/when the fork's API
change merges into a future ergo_avltree_rust release.

Affects: savltree.rs (10 sites incl. tests), tree_lookup.rs (2 sites).
No semantic behavior changes — pure type-level adaptation.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
…test

Completes the Arc<dyn Fn> Resolver API-compat fix from ff2c514. The
prior commit wrapped 12 of 13 closure call sites (10 in savltree.rs +
2 in tree_lookup.rs) but missed the test-only site in
create_avl_tree.rs at the eval_create_avl_tree fn.

Adds `use alloc::sync::Arc` and `use ergo_avltree_rust::operation::Digest32`
inside the test mod, then wraps the bare closure in the same
Arc::new(|digest: &Digest32| ...) pattern used everywhere else.

Canonical build environment for integration/ergots is via the
ergots/fixture-gen `[patch.crates-io] ergo_avltree_rust = { path = ... }`
directive which routes to the local fork at ~/projects/ergo_avltree_rust/
(HEAD 879545c). Confirmed clean fixture-gen build (4.63s) with this edit.

Standalone `cargo build` from the worktree fails by design under the
new Resolver API — the integration/ergots branch is incompatible with
crates.io ergo_avltree_rust@0.1.1's bare-fn-pointer API, by intent
(per option A of the prior session's discussion).

Co-Authored-By: Claude Opus 4.7 (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