From bae14fa952a445b7a38c9e5ccb1fc60ba3a62a0b Mon Sep 17 00:00:00 2001 From: Tomas Szejnfeld Sirkis Date: Fri, 6 Mar 2026 12:02:51 -0300 Subject: [PATCH 1/2] Refactor script compilation in decoder and script_utils --- bitcoin-script-riscv/Cargo.toml | 6 ++--- bitcoin-script-riscv/src/riscv/decoder.rs | 6 ++--- .../src/riscv/script_utils.rs | 23 +++++++++---------- 3 files changed, 17 insertions(+), 18 deletions(-) diff --git a/bitcoin-script-riscv/Cargo.toml b/bitcoin-script-riscv/Cargo.toml index eb0f77a..c3e2fc5 100644 --- a/bitcoin-script-riscv/Cargo.toml +++ b/bitcoin-script-riscv/Cargo.toml @@ -8,10 +8,10 @@ edition = "2021" [dependencies] bitcoin-script-stack = { git = "https://github.com/FairgateLabs/rust-bitcoin-script-stack", features = [ "interactive", -], branch = "v2" } -bitcoin-script-functions = { git = "https://github.com/FairgateLabs/rust-bitcoin-script-functions" } +], branch = "merge-bitvm" } +bitcoin-script-functions = { git = "https://github.com/FairgateLabs/rust-bitcoin-script-functions", branch = "merge-bitvm" } bitcoin = "=0.32.6" -bitcoin-script = { git = "https://github.com/FairgateLabs/rust-bitcoin-script", branch = "bitvmx" } +bitcoin-script = { git = "https://github.com/FairgateLabs/rust-bitcoin-script", branch = "merge-bitvm" } riscv-decode = "0.2.1" thiserror = "1.0.61" bitvmx-cpu-definitions = { path = "../definitions" } diff --git a/bitcoin-script-riscv/src/riscv/decoder.rs b/bitcoin-script-riscv/src/riscv/decoder.rs index 93ee454..b067b8d 100644 --- a/bitcoin-script-riscv/src/riscv/decoder.rs +++ b/bitcoin-script-riscv/src/riscv/decoder.rs @@ -67,7 +67,7 @@ pub fn mask_4bit(stack: &mut StackTracker) -> StackVariable { 0x8 OP_SUB OP_ENDIF - }, + }.compile(), 1, true, 0, @@ -124,7 +124,7 @@ pub fn decode_i_type( OP_1 OP_ENDIF OP_VERIFY - }, + }.compile(), 1, false, 0, @@ -190,7 +190,7 @@ pub fn decode_b_type( 0 OP_TOALTSTACK ENDIF - }, + }.compile(), 1, false, 1, diff --git a/bitcoin-script-riscv/src/riscv/script_utils.rs b/bitcoin-script-riscv/src/riscv/script_utils.rs index 0328204..f0cfe15 100644 --- a/bitcoin-script-riscv/src/riscv/script_utils.rs +++ b/bitcoin-script-riscv/src/riscv/script_utils.rs @@ -1,7 +1,6 @@ use bitcoin_script_stack::stack::{StackTracker, StackVariable}; -pub use bitcoin_script::{define_pushable, script}; -define_pushable!(); +pub use bitcoin_script::script; pub use bitcoin::ScriptBuf as Script; use bitvmx_cpu_definitions::memory::{Chunk, MemoryAccessType, SectionDefinition}; @@ -58,7 +57,7 @@ pub fn nib_to_bin(stack: &mut StackTracker) { 0 OP_ENDIF OP_TOALTSTACK - }, + }.compile(), 1, false, 1, @@ -180,7 +179,7 @@ pub fn if_greater(stack: &mut StackTracker, than: u8, then: u8, else_: u8) -> St OP_ELSE { else_} OP_ENDIF - }, + }.compile(), 1, true, 0, @@ -200,7 +199,7 @@ pub fn if_less(stack: &mut StackTracker, than: u8, then: u8, else_: u8) -> Stack OP_ELSE { else_} OP_ENDIF - }, + }.compile(), 1, true, 0, @@ -226,7 +225,7 @@ pub fn sub_1_if_positive(stack: &mut StackTracker) -> StackVariable { 0 OP_ENDIF OP_TOALTSTACK - }, + }.compile(), 0, true, 0, @@ -249,7 +248,7 @@ pub fn choose(stack: &mut StackTracker) -> StackVariable { OP_ROLL OP_SWAP OP_DROP - }, + }.compile(), 3, true, 0, @@ -689,7 +688,7 @@ pub fn is_lower_than( { -n } OP_ENDIF OP_ENDIF - }, + }.compile(), 3, true, 0, @@ -718,7 +717,7 @@ pub fn is_lower_than( { -n } OP_ENDIF OP_ENDIF - }, + }.compile(), 3, true, 0, @@ -767,7 +766,7 @@ pub fn mask_value( OP_DROP 0 OP_ENDIF - }, + }.compile(), 2, true, 0, @@ -850,7 +849,7 @@ pub fn left_rotate( for _ in 0..4 { OP_2DROP } - }, + }.compile(), 17, false, 8, @@ -1077,7 +1076,7 @@ pub fn mulh( stack.op_rot(); //a1 b1 b1 a1 stack.op_add(); //a1 b1 a1+b1 stack - .custom(script! { 1 OP_EQUAL }, 1, true, 0, "result_neg") + .custom(script! { 1 OP_EQUAL }.compile(), 1, true, 0, "result_neg") .unwrap(); stack.to_altstack(); //a1 b1 | a1+b1 } From b2cc4567670d97f3195a06b8d2f730aabf10473f Mon Sep 17 00:00:00 2001 From: Tomas Szejnfeld Sirkis Date: Fri, 6 Mar 2026 14:40:06 -0300 Subject: [PATCH 2/2] Go back to main branch --- bitcoin-script-riscv/Cargo.toml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/bitcoin-script-riscv/Cargo.toml b/bitcoin-script-riscv/Cargo.toml index c3e2fc5..bb81540 100644 --- a/bitcoin-script-riscv/Cargo.toml +++ b/bitcoin-script-riscv/Cargo.toml @@ -8,10 +8,10 @@ edition = "2021" [dependencies] bitcoin-script-stack = { git = "https://github.com/FairgateLabs/rust-bitcoin-script-stack", features = [ "interactive", -], branch = "merge-bitvm" } -bitcoin-script-functions = { git = "https://github.com/FairgateLabs/rust-bitcoin-script-functions", branch = "merge-bitvm" } +], branch = "v2" } +bitcoin-script-functions = { git = "https://github.com/FairgateLabs/rust-bitcoin-script-functions"} bitcoin = "=0.32.6" -bitcoin-script = { git = "https://github.com/FairgateLabs/rust-bitcoin-script", branch = "merge-bitvm" } +bitcoin-script = { git = "https://github.com/FairgateLabs/rust-bitcoin-script", branch = "bitvmx" } riscv-decode = "0.2.1" thiserror = "1.0.61" bitvmx-cpu-definitions = { path = "../definitions" }