Repository navigation
Conversation
Don't actually build bitcoin yet; just refactor build.rs
For dumb "C polymorphism" reasons we have two structures in the C code named txEnv. We can call the corresponding Rust structures different things, but we need to access them from the C file env.c, which provides some C wrappers for FFI stuff. Since you can't have two different structs with the same name in one compilation unit, split it into two: add depend/bitcoin_env.c holding the Bitcoin txEnv wrappers, alongside the existing depend/env.c for Elements.
This is the more correct trait. When we update the Jet trait we will be forced to pick one, and we will pick Borrow.
Updates to BlockstreamResearch/simplicity#324 This PR does a couple things simultaneously: * Runs vendor-simplicity.sh and update-jets.sh * Updates the `Jet` trait to have associated transaction and environment types, and for the environment to be paramterized by the transaction type. * Changes the Core environment from () to CoreEnv::<Infallible> * Updates some fixed Core CMR/IHR vectors (this update to libsimplicity changes the benchmarks for the Core jets and thus changes these vectors) * Uncomments the commented-out symbols in simplicity-sys/src/c_jets/c_env/bitcoin.rs * Adds the "build bitcoin" lines to simplicity-sys/build.rs The update to the `Jet` trait is a bit noisy but ultimately mechanical: everywhere that we're generic over all J: Jet, we now also have to be generic over all T: Borrow<J::Transaction>, which leads to some extra line noise especially in unit tests where we have assert_* helper functions. The last four points are tiny diffs, thanks to the previous preparatory commits. The use of CoreEnv::<Infallible> as the core environment type is kinda fun. It means that it is impossible to execute any code which attempts to access the transaction in the environment. (No such code exists, since it would be nonsensical, but now we have some assurance that it won't exist by accident in the future.) Unfortunately this mixes mechanical and non-mechanical things in one commit. But the mechanical changes are exclusively in simplicity-sys/depend/ and src/jet/init/ and the non-mechanical changes are exclusively outside of those files, so it should be possible to review this.
Change the JetEnvironment impl for BitcoinEnv and ElementsEnv to be generic over T: Borrow<Transaction> instead of fixed to Arc<Transaction>. Update Policy::satisfy, get_satisfier, execute_successful, execute_unsuccessful, and serialize test helpers to accept ElementsEnv<impl Borrow<Transaction>>. This allows callers to construct environments without Arc overhead (for example, using a plain reference or owned value), and is required so that BitcoinEnv::c_jet_env can return a real CTxEnv from a borrowed transaction.
Now that we've updated the Jet trait to allow the transactions in environments to be arbitrary T: Borrow<Transaction>, we don't need to use Arc everywhere. In many cases we can use normal references.
This is a Rust type which can be used, among other things, to construct the transaction environment needed by C jets. Also provides accessors for the underlying transaction and input index, both of which are used (in the Elements version of this struct) in the policy satisfier.
rust-bitcoin 0.32 removed Witness::taproot_annex. Replace it with an inline BIP341 annex extraction: the last witness element that begins with 0x50 is the annex. This matches the Elements c_env helper and the BIP341 specification.
Replace the unimplemented!() stub in Bitcoin::cmr() with a match table of 32-byte CMR values. Each entry is derived from the canonical primitiveJetNode.inc in libsimplicity. The table covers all jets in the Bitcoin jet set. The cost() method remains a stub pending a separate commit.
This was referenced Oct 5, 2026
Contributor
|
Was this updated with |
Collaborator
|
I cannot accept this unless it was generated with |
Contributor
Author
|
Understood will fix after #385 |
Collaborator
|
85cf694 needs rebase |
apoelstra
added a commit
that referenced
this pull request
Oct 23, 2026
579d1f9 bitcoin: extract annex per BIP341 instead of Witness::taproot_annex (Byron Hambly) 9aa64bb jet: populate annexes in Bitcoin environment (Andrew Poelstra) 61593d5 jet: implement Rust bitcoin environment (Andrew Poelstra) 738f01c jet: drop unnecessary Arcs in environments (Andrew Poelstra) 09220af jet: generalize JetEnvironment impls to use Borrow<T> (Byron Hambly) b5e0cbe simplicity-sys: update libsimplicity to 3f0bb69c (Byron Hambly) f48c90a jet: switch from Deref to Borrow for transaction environments (Andrew Poelstra) 40838c1 simplicity-sys: define bitcoin transaction environment (Andrew Poelstra) 46528e5 simplicity-sys: split env.c into bitcoin_env.c (Byron Hambly) Pull request description: Redux of #331. Covers the same ground: vendoring the bitcoin-env libsimplicity branch and adding the Rust `BitcoinEnv`/`JetEnvironment` plumbing. Why a new branch instead of updating #331: - Vendored libsimplicity rev differs: this PR pins `ba967b1a` (the rev shipped with simplicity-lang 0.9.0, already on `master`); - Symbol version differs as a direct consequence: this PR's C/FFI layer targets `rustsimplicity_0_8_*`. - `CoreEnv::EMPTY` (added in `b0a25c2`) is not needed or referenced by this series and is intentionally omitted. Three additional PRs stack on this one: #386 #387 #388 ACKs for top commit: stringhandler: ACK 579d1f9 apoelstra: ACK 579d1f9; successfully ran local tests Tree-SHA512: b5618d0cbc85d989da0e6423fcc36dce6bfe7379f6519acdf6bc54759cbc967e434e52e03de20041c56753880c30fbbcfa6847ed7f00183a4045dc96732767e3
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.
Depends on #385 (Bitcoin transaction environment).
Replaces the
unimplemented!()stub inBitcoin::cmr()with the fullmatch table of 32-byte Commitment Merkle Root (CMR) values, one entry
per jet in the Bitcoin jet set. Each value is taken directly from the
canonical
primitiveJetNode.incin libsimplicity, so the table is atranscription, not a derivation -- no new CMR computation logic is
introduced here.
Bitcoin::cost()remains a stub; the cost table and the CMR/costself-check tests (which assert this table against
primitiveJetNode.incin code) land in the next PR in the stack.