Skip to content

Conversation

@apoelstra
Copy link
Collaborator

Draft until BlockstreamResearch/simplicity#324 merges

This updates libsimplicity to the newest version, which has several changes:

  • new Core benchmarks leading to CMR/IMR changes for Core programs
  • a new Bitcoin jet set and transaction environment
  • several improvements to the Jet trait, which need to happen simultaneously in GenRustJets (from libsimplicity) and here

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.
When we update libsimplicity we will use a new type for the Core environment
rather than directly using (). Then we will need to use CoreEnv::EMPTY as the
value everywhere.

To minimize the later diff, do this change now, where for now we just set
CoreEnv::EMPTY equal to ().
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.
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.
@apoelstra apoelstra marked this pull request as draft December 18, 2025 17:31
@apoelstra
Copy link
Collaborator Author

cc @roconnor-blockstream this is a bit Rust-heavy but I think you can usefully review it.

cc @canndrew

This is a draft but I don't expect it to change other than maybe the commit ID of libsimplicity that I use.

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