From 7d37b65a763028e8584d8f4c83669b2754b5c89c Mon Sep 17 00:00:00 2001 From: stringhandler Date: Wed, 6 May 2026 17:17:23 +0200 Subject: [PATCH] chore: update rust-simplicity dependency to git master and adapt to new API Switch to later master branch of rust-simplicity, which removes the `Jet` type parameter from nodes and renames broken lock distance/ duration jets. Update all call sites to match the new API and deprecate example files that use the renamed jets. --- Cargo.lock | 28 +--------- Cargo.toml | 3 +- .../{ => deprecated}/escrow_with_delay.simf | 2 +- .../escrow_with_delay.timeout.wit | 0 .../{ => deprecated}/last_will.inherit.wit | 0 examples/{ => deprecated}/last_will.simf | 2 +- .../presigned_vault.complete.wit | 0 .../{ => deprecated}/presigned_vault.simf | 2 +- src/compile/mod.rs | 8 +-- src/jet.rs | 16 +++--- src/lib.rs | 10 ++-- src/named.rs | 51 +++++++++---------- src/pattern.rs | 3 +- src/tracker.rs | 22 ++++---- 14 files changed, 62 insertions(+), 85 deletions(-) rename examples/{ => deprecated}/escrow_with_delay.simf (97%) rename examples/{ => deprecated}/escrow_with_delay.timeout.wit (100%) rename examples/{ => deprecated}/last_will.inherit.wit (100%) rename examples/{ => deprecated}/last_will.simf (96%) rename examples/{ => deprecated}/presigned_vault.complete.wit (100%) rename examples/{ => deprecated}/presigned_vault.simf (96%) diff --git a/Cargo.lock b/Cargo.lock index 5686d7ad..4e6f9944 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -507,18 +507,6 @@ dependencies = [ "getrandom", ] -[[package]] -name = "regex" -version = "1.9.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "697061221ea1b4a94a624f67d0ae2bfe4e22b8a17b6a192afb11046542cc8c47" -dependencies = [ - "aho-corasick", - "memchr", - "regex-automata", - "regex-syntax", -] - [[package]] name = "regex-automata" version = "0.3.8" @@ -542,15 +530,6 @@ version = "1.0.15" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1ad4cc8da4ef723ed60bced201181d83791ad433213d8c24efffda1eec85d741" -[[package]] -name = "santiago" -version = "1.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "de36022292bc2086eb8f55bffa460fef3475e4459b478820711f4c421feb87ec" -dependencies = [ - "regex", -] - [[package]] name = "secp256k1" version = "0.29.1" @@ -633,8 +612,7 @@ checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64" [[package]] name = "simplicity-lang" version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "70e57bd4d84853974a212eab24ed89da54f49fbccf5e33e93bcd29f0a6591cd5" +source = "git+https://github.com/BlockstreamResearch/rust-simplicity.git?branch=master#fe1f88837a18a048cfe2a0b5961f8039a05118e2" dependencies = [ "bitcoin", "bitcoin_hashes", @@ -644,15 +622,13 @@ dependencies = [ "ghost-cell", "hex-conservative", "miniscript", - "santiago", "simplicity-sys", ] [[package]] name = "simplicity-sys" version = "0.6.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e3401ee7331f183a5458c0f5a4b3d5d00bde0fd12e2e03728c537df34efae289" +source = "git+https://github.com/BlockstreamResearch/rust-simplicity.git?branch=master#fe1f88837a18a048cfe2a0b5961f8039a05118e2" dependencies = [ "bitcoin_hashes", "cc", diff --git a/Cargo.toml b/Cargo.toml index 6216826b..74eca37a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -32,7 +32,8 @@ docs = [] base64 = "0.21.2" serde = { version = "1.0.188", features = ["derive"], optional = true } serde_json = { version = "1.0.105", optional = true } -simplicity-lang = { version = "0.7.0" } +# simplicity-lang = { version = "0.7.0" } +simplicity-lang = { git="https://github.com/BlockstreamResearch/rust-simplicity.git", branch="master" } miniscript = "12.3.1" either = "1.12.0" itertools = "0.13.0" diff --git a/examples/escrow_with_delay.simf b/examples/deprecated/escrow_with_delay.simf similarity index 97% rename from examples/escrow_with_delay.simf rename to examples/deprecated/escrow_with_delay.simf index 67dd3d3e..8a11a54a 100644 --- a/examples/escrow_with_delay.simf +++ b/examples/deprecated/escrow_with_delay.simf @@ -51,7 +51,7 @@ fn timeout_spend(sender_sig: Signature) { let sender_pk: Pubkey = 0x79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798; // 1 * G checksig(sender_pk, sender_sig); let timeout: Distance = 1000; - jet::check_lock_distance(timeout); + jet::broken_do_not_use_check_lock_distance(timeout); } fn main() { diff --git a/examples/escrow_with_delay.timeout.wit b/examples/deprecated/escrow_with_delay.timeout.wit similarity index 100% rename from examples/escrow_with_delay.timeout.wit rename to examples/deprecated/escrow_with_delay.timeout.wit diff --git a/examples/last_will.inherit.wit b/examples/deprecated/last_will.inherit.wit similarity index 100% rename from examples/last_will.inherit.wit rename to examples/deprecated/last_will.inherit.wit diff --git a/examples/last_will.simf b/examples/deprecated/last_will.simf similarity index 96% rename from examples/last_will.simf rename to examples/deprecated/last_will.simf index 01007b07..9790a1cf 100644 --- a/examples/last_will.simf +++ b/examples/deprecated/last_will.simf @@ -24,7 +24,7 @@ fn recursive_covenant() { fn inherit_spend(inheritor_sig: Signature) { let days_180: Distance = 25920; - jet::check_lock_distance(days_180); + jet::broken_do_not_use_check_lock_distance(days_180); let inheritor_pk: Pubkey = 0x79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798; // 1 * G checksig(inheritor_pk, inheritor_sig); } diff --git a/examples/presigned_vault.complete.wit b/examples/deprecated/presigned_vault.complete.wit similarity index 100% rename from examples/presigned_vault.complete.wit rename to examples/deprecated/presigned_vault.complete.wit diff --git a/examples/presigned_vault.simf b/examples/deprecated/presigned_vault.simf similarity index 96% rename from examples/presigned_vault.simf rename to examples/deprecated/presigned_vault.simf index acd2ee28..d1a836e4 100644 --- a/examples/presigned_vault.simf +++ b/examples/deprecated/presigned_vault.simf @@ -23,7 +23,7 @@ fn checksig(pk: Pubkey, sig: Signature) { fn complete_spend(hot_sig: Signature) { let timeout: Distance = 1000; - jet::check_lock_distance(timeout); + jet::broken_do_not_use_check_lock_distance(timeout); let hot_pk: Pubkey = 0x79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798; // 1 * G checksig(hot_pk, hot_sig); } diff --git a/src/compile/mod.rs b/src/compile/mod.rs index 9f8dffb4..f2dd5def 100644 --- a/src/compile/mod.rs +++ b/src/compile/mod.rs @@ -26,7 +26,7 @@ use crate::value::StructuralValue; use crate::witness::Arguments; use crate::Value; -type ProgNode<'brand> = Arc>; +type ProgNode<'brand> = Arc>; /// Each SimplicityHL expression expects an _input value_. /// A SimplicityHL expression is translated into a Simplicity expression @@ -263,7 +263,7 @@ impl Program { &self, arguments: Arguments, include_debug_symbols: bool, - ) -> Result>, RichError> { + ) -> Result, RichError> { types::Context::with_context(|ctx| { let mut scope = Scope::new( ctx, @@ -379,7 +379,7 @@ impl Call { match self.name() { CallName::Jet(name) => { - let jet = ProgNode::jet(scope.ctx(), *name); + let jet = ProgNode::jet(scope.ctx(), &*name); scope.with_debug_symbol(args, &jet, self) } CallName::UnwrapLeft(..) => { @@ -410,7 +410,7 @@ impl Call { args.comp(&body).with_span(self) } CallName::Assert => { - let jet = ProgNode::jet(scope.ctx(), Elements::Verify); + let jet = ProgNode::jet(scope.ctx(), &Elements::Verify); scope.with_debug_symbol(args, &jet, self) } CallName::Panic => { diff --git a/src/jet.rs b/src/jet.rs index 209bc577..613976b4 100644 --- a/src/jet.rs +++ b/src/jet.rs @@ -450,12 +450,12 @@ pub fn source_type(jet: Elements) -> Vec { * Time locks */ Elements::CheckLockTime => vec![Time.into()], - Elements::CheckLockDistance => vec![Distance.into()], - Elements::CheckLockDuration => vec![Duration.into()], + Elements::BrokenDoNotUseCheckLockDistance => vec![Distance.into()], + Elements::BrokenDoNotUseCheckLockDuration => vec![Duration.into()], Elements::CheckLockHeight => vec![Height.into()], Elements::TxLockTime - | Elements::TxLockDistance - | Elements::TxLockDuration + | Elements::BrokenDoNotUseTxLockDistance + | Elements::BrokenDoNotUseTxLockDuration | Elements::TxLockHeight | Elements::TxIsFinal => vec![], /* @@ -956,13 +956,13 @@ pub fn target_type(jet: Elements) -> AliasedType { * Time locks */ Elements::CheckLockTime - | Elements::CheckLockDistance - | Elements::CheckLockDuration + | Elements::BrokenDoNotUseCheckLockDistance + | Elements::BrokenDoNotUseCheckLockDuration | Elements::CheckLockHeight => AliasedType::unit(), Elements::TxIsFinal => bool(), Elements::TxLockTime => Time.into(), - Elements::TxLockDistance => Distance.into(), - Elements::TxLockDuration => Duration.into(), + Elements::BrokenDoNotUseTxLockDistance => Distance.into(), + Elements::BrokenDoNotUseTxLockDuration => Duration.into(), Elements::TxLockHeight => Height.into(), /* * Issuance diff --git a/src/lib.rs b/src/lib.rs index 0f0d2e00..6232c249 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -29,7 +29,7 @@ mod witness; use std::sync::Arc; use simplicity::jet::elements::ElementsEnv; -use simplicity::{jet::Elements, CommitNode, RedeemNode}; +use simplicity::{CommitNode, RedeemNode}; pub extern crate either; pub extern crate simplicity; @@ -174,7 +174,7 @@ impl TemplateProgram { /// A SimplicityHL program, compiled to Simplicity. #[derive(Clone, Debug)] pub struct CompiledProgram { - simplicity: Arc>, + simplicity: Arc, witness_types: WitnessTypes, debug_symbols: DebugSymbols, parameter_types: Parameters, @@ -218,7 +218,7 @@ impl CompiledProgram { } /// Access the Simplicity target code, without witness data. - pub fn commit(&self) -> Arc> { + pub fn commit(&self) -> Arc { named::forget_names(&self.simplicity) } @@ -275,7 +275,7 @@ pub struct AbiMeta { /// A SimplicityHL program, compiled to Simplicity and satisfied with witness data. #[derive(Clone, Debug, PartialEq, Eq)] pub struct SatisfiedProgram { - simplicity: Arc>, + simplicity: Arc, debug_symbols: DebugSymbols, } @@ -298,7 +298,7 @@ impl SatisfiedProgram { } /// Access the Simplicity target code, including witness data. - pub fn redeem(&self) -> &Arc> { + pub fn redeem(&self) -> &Arc { &self.simplicity } diff --git a/src/named.rs b/src/named.rs index 8330655f..7a7d054e 100644 --- a/src/named.rs +++ b/src/named.rs @@ -1,7 +1,6 @@ use std::sync::Arc; use simplicity::dag::{InternalSharing, PostOrderIterItem}; -use simplicity::jet::Jet; use simplicity::node::{ self, Converter, CoreConstructible, Inner, NoDisconnect, NoWitness, Node, WitnessConstructible, }; @@ -22,7 +21,6 @@ impl node::Marker for WithNames { // we don't use disconnect in this library right now, so punt on it for now. type Disconnect = NoDisconnect; type SharingId = M::SharingId; - type Jet = M::Jet; fn compute_sharing_id(cmr: Cmr, cached_data: &Self::CachedData) -> Option { M::compute_sharing_id(cmr, cached_data) @@ -56,17 +54,17 @@ impl Nullable for NoDisconnect { /// [`simplicity::ConstructNode`] with named witness nodes. /// /// Nodes other than witness don't have names. -pub type ConstructNode<'brand, J> = Node>>; +pub type ConstructNode<'brand> = Node>>; /// [`simplicity::CommitNode`] with named witness nodes. /// /// Nodes other than witness don't have names. -pub type CommitNode = Node>>; +pub type CommitNode = Node>; // FIXME: The following methods cannot be implemented for simplicity::node::Node because that is a foreign type -pub fn finalize_types( - node: &Node>>, -) -> Result>>>, types::Error> { +pub fn finalize_types<'brand>( + node: &Node>>, +) -> Result>>, types::Error> { // We finalize all types but don't bother to set the root source and target // to unit. This is a bit annoying to do, and anyway these types will already // be unit by construction. @@ -82,11 +80,11 @@ fn translate( ) -> Result>>, E> where M: node::Marker, - N: node::Marker, + N: node::Marker, N::Witness: Nullable, F: FnMut( &Node>, - Inner<&N::CachedData, N::Jet, &NoDisconnect, &WitnessName>, + Inner<&N::CachedData, &NoDisconnect, &WitnessName>, ) -> Result, { struct Translator(F); @@ -94,11 +92,11 @@ where impl Converter, WithNames> for Translator where M: node::Marker, - N: node::Marker, + N: node::Marker, N::Witness: Nullable, F: FnMut( &Node>, - Inner<&N::CachedData, N::Jet, &NoDisconnect, &WitnessName>, + Inner<&N::CachedData, &NoDisconnect, &WitnessName>, ) -> Result, { type Error = E; @@ -123,7 +121,7 @@ where fn convert_data( &mut self, data: &PostOrderIterItem<&Node>>, - inner: Inner<&Arc>>, N::Jet, &NoDisconnect, &WitnessName>, + inner: Inner<&Arc>>, &NoDisconnect, &WitnessName>, ) -> Result { let new_inner = inner.map(|node| node.cached_data()); self.0(data.node, new_inner) @@ -170,7 +168,7 @@ where fn convert_data( &mut self, data: &PostOrderIterItem<&Node>>, - _: Inner<&Arc>, M::Jet, &M::Disconnect, &M::Witness>, + _: Inner<&Arc>, &M::Disconnect, &M::Witness>, ) -> Result { Ok(data.node.cached_data().clone()) } @@ -194,20 +192,20 @@ where /// It is the responsibility of the caller to ensure that the given witness `values` match the /// types in the construct `node`. This can be done by calling [`WitnessValues::is_consistent`] /// on the original SimplicityHL program before it is compiled to Simplicity. -pub fn populate_witnesses( - node: &CommitNode, +pub fn populate_witnesses( + node: &CommitNode, values: WitnessValues, -) -> Result>, String> { +) -> Result, String> { struct Populator { values: WitnessValues, } - impl Converter>, node::Redeem> for Populator { + impl Converter, node::Redeem> for Populator { type Error = String; fn convert_witness( &mut self, - _: &PostOrderIterItem<&CommitNode>, + _: &PostOrderIterItem<&CommitNode>, witness: &WitnessName, ) -> Result { match self.values.get(witness) { @@ -218,23 +216,22 @@ pub fn populate_witnesses( fn convert_disconnect( &mut self, - _: &PostOrderIterItem<&CommitNode>, - _: Option<&Arc>>, + _: &PostOrderIterItem<&CommitNode>, + _: Option<&Arc>, _: &NoDisconnect, - ) -> Result>, Self::Error> { + ) -> Result, Self::Error> { unreachable!("SimplicityHL does not use disconnect right now") } fn convert_data( &mut self, - data: &PostOrderIterItem<&CommitNode>, + data: &PostOrderIterItem<&CommitNode>, inner: Inner< - &Arc>, - J, - &Arc>, + &Arc, + &Arc, &simplicity::Value, >, - ) -> Result>, Self::Error> { + ) -> Result, Self::Error> { let inner = inner .map(|node| node.cached_data()) .map_disconnect(|node| node.cached_data()) @@ -253,7 +250,7 @@ pub fn populate_witnesses( // This awkward construction is required by rust-simplicity to implement WitnessConstructible // for Node>. See // https://docs.rs/simplicity-lang/latest/simplicity/node/trait.WitnessConstructible.html#foreign-impls -impl<'brand, J: Jet> WitnessConstructible<'brand, WitnessName> for node::ConstructData<'brand, J> { +impl<'brand> WitnessConstructible<'brand, WitnessName> for node::ConstructData<'brand> { fn witness(inference_context: &types::Context<'brand>, _: WitnessName) -> Self { WitnessConstructible::>::witness(inference_context, None) } diff --git a/src/pattern.rs b/src/pattern.rs index b1a1f4f1..1cd6e4d2 100644 --- a/src/pattern.rs +++ b/src/pattern.rs @@ -443,7 +443,6 @@ impl From<&Pattern> for BasePattern { mod tests { use super::*; use crate::named; - use simplicity::jet::Elements; #[test] fn translate_pattern() { @@ -468,7 +467,7 @@ mod tests { for (target, expected_expr) in target_expr { simplicity::types::Context::with_context(|ctx| { let expr = env - .translate::>>(&ctx, &target) + .translate::>(&ctx, &target) .unwrap(); assert_eq!(expected_expr, expr.as_ref().display_expr().to_string()); }); diff --git a/src/tracker.rs b/src/tracker.rs index 69a2c6bb..1d682d7a 100644 --- a/src/tracker.rs +++ b/src/tracker.rs @@ -174,7 +174,7 @@ impl<'a> DefaultTracker<'a> { /// Handles jet node execution by decoding arguments and results. fn handle_jet( &mut self, - node: &RedeemNode, + node: &RedeemNode, jet: Elements, input: &FrameIter, output: &NodeOutput, @@ -214,7 +214,7 @@ impl<'a> DefaultTracker<'a> { /// Parses the result of a jet execution from the output frame. fn parse_jet_result( - node: &RedeemNode, + node: &RedeemNode, jet: Elements, output: &NodeOutput, ) -> Option { @@ -249,7 +249,7 @@ impl<'a> DefaultTracker<'a> { /// Handles debug node execution by resolving symbols and decoding values. fn handle_debug( &mut self, - node: &RedeemNode, + node: &RedeemNode, input: &FrameIter, cmr: &simplicity::Cmr, ) { @@ -291,9 +291,9 @@ impl<'a> DefaultTracker<'a> { } } -impl PruneTracker for DefaultTracker<'_> { +impl PruneTracker for DefaultTracker<'_> { fn contains_left(&self, ihr: Ihr) -> bool { - if PruneTracker::::contains_left(&self.inner, ihr) { + if PruneTracker::contains_left(&self.inner, ihr) { return true; } @@ -305,7 +305,7 @@ impl PruneTracker for DefaultTracker<'_> { } fn contains_right(&self, ihr: Ihr) -> bool { - if PruneTracker::::contains_right(&self.inner, ihr) { + if PruneTracker::contains_right(&self.inner, ihr) { return true; } @@ -317,10 +317,14 @@ impl PruneTracker for DefaultTracker<'_> { } } -impl ExecTracker for DefaultTracker<'_> { - fn visit_node(&mut self, node: &RedeemNode, input: FrameIter, output: NodeOutput) { +impl ExecTracker for DefaultTracker<'_> { + fn visit_node(&mut self, node: &RedeemNode, input: FrameIter, output: NodeOutput) { match node.inner() { - Inner::Jet(jet) => self.handle_jet(node, *jet, &input, &output), + Inner::Jet(jet) => { + if let Some(&elements_jet) = jet.as_any().downcast_ref::() { + self.handle_jet(node, elements_jet, &input, &output); + } + } Inner::AssertL(_, cmr) => self.handle_debug(node, &input, cmr), _ => {} }