feat(bitcoin): implement native introspection jets (InputValue, NumInputs, etc.)#359
Open
Laz1mov wants to merge 1 commit intoBlockstreamResearch:masterfrom
Open
Conversation
Adds native Rust implementation and C-FFI bindings for NumInputs, NumOutputs, InputValue, and InputUtxosHash. Updates BitcoinEnv to hold spent_outputs and current index. Ensures perfect CMR and milli-weight parity with the C reference. Signed-off-by: Laz1m0v <198518978+Laz1m0v@users.noreply.github.com>
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.
Description
This PR implements the critical Bitcoin introspection jets required for Layer 1 covenants to read transaction state without relying on injected witnesses.
It introduces native, zero-panic Rust implementations for
NumInputs,NumOutputs,InputValue, andInputUtxosHash, bridging them securely to the existing FFIc_jet_ptrinterface.Key Contributions
BitcoinEnvto maintain the current input index (ix) and the slice ofspent_outputsnecessary for UTXO inspection.primitiveJetNode.inc).InputUtxosHashperfectly mimics the hierarchical C implementation (combininginputValuesHashandinputScriptsHash)..unwrap()or panics in the execution paths. Memory boundary checks gracefully triggerBitMachineTrapequivalents on out-of-bounds access.Motivation
Projects building on Simplicity (such as the PRECOP canonical engine) require these jets to transition from "trusted witness" topologies to fully deterministic, mathematically verifiable state transitions.
Testing
BitcoinEnvdata.Signed-off-by: Laz1m0v 198518978+Laz1m0v@users.noreply.github.com