diff --git a/frontend-wasm/src/intrinsics/felt.rs b/frontend-wasm/src/intrinsics/felt.rs index 057a84df..9f643754 100644 --- a/frontend-wasm/src/intrinsics/felt.rs +++ b/frontend-wasm/src/intrinsics/felt.rs @@ -20,6 +20,11 @@ pub(crate) fn convert_felt_intrinsics( let inst = builder.ins().cast(args[0], Felt, span); vec![inst] } + "from_u32_unchecked" => { + assert_eq!(args.len(), 1, "{} takes exactly one argument", func_id); + let inst = builder.ins().bitcast(args[0], Felt, span); + vec![inst] + } "as_u64" => { assert_eq!(args.len(), 1, "{} takes exactly one argument", func_id); // we're casting to i64 instead of u64 because Wasm doesn't have u64 diff --git a/midenc-debug/src/exec/executor.rs b/midenc-debug/src/exec/executor.rs index 03284efd..01051a04 100644 --- a/midenc-debug/src/exec/executor.rs +++ b/midenc-debug/src/exec/executor.rs @@ -9,7 +9,7 @@ use miden_assembly::Library as CompiledLibrary; use miden_core::{Program, StackInputs, Word}; use miden_package::{ Dependency, DependencyName, DependencyResolution, DependencyResolver, LocalResolution, - MemDependencyResolverByDigest, SystemLibraryId, + MastArtifact, MemDependencyResolverByDigest, SystemLibraryId, }; use miden_processor::{ AdviceInputs, ContextId, ExecutionError, Felt, MastForest, MemAdviceProvider, Process, @@ -35,17 +35,23 @@ pub struct Executor { stack: StackInputs, advice: AdviceInputs, libraries: Vec>, + dependency_resolver: MemDependencyResolverByDigest, } impl Executor { /// Construct an executor with the given arguments on the operand stack pub fn new(args: Vec) -> Self { + let mut resolver = MemDependencyResolverByDigest::default(); + resolver.add(*STDLIB.digest(), STDLIB.clone().into()); + resolver.add(*BASE.digest(), BASE.clone().into()); Self { stack: StackInputs::new(args).expect("invalid stack inputs"), advice: AdviceInputs::default(), libraries: Default::default(), + dependency_resolver: resolver, } } + /// Construct the executor with the given inputs and adds dependencies from the given package pub fn for_package( package: &miden_package::Package, args: Vec, @@ -57,25 +63,35 @@ impl Executor { package.name, DisplayHex::new(&package.digest().as_bytes()) ); - let mut exec = Self::new(args); + exec.with_dependencies(&package.manifest.dependencies)?; + log::debug!("executor created"); + Ok(exec) + } - let mut resolver = MemDependencyResolverByDigest::default(); - resolver.add(*STDLIB.digest(), STDLIB.clone().into()); - resolver.add(*BASE.digest(), BASE.clone().into()); + /// Adds dependencies to the executor + pub fn with_dependencies(&mut self, dependencies: &[Dependency]) -> Result<&mut Self, Report> { + use midenc_hir::formatter::DisplayHex; - for dep in &package.manifest.dependencies { - match resolver.resolve(dep) { + for dep in dependencies { + match self.dependency_resolver.resolve(dep) { Some(resolution) => { log::debug!("dependency {:?} resolved to {:?}", dep, resolution); + log::debug!("loading library from package dependency: {:?}", dep); match resolution { DependencyResolution::Local(LocalResolution::Library(lib)) => { let library = lib.as_ref(); - log::debug!("loading library from package dependency: {:?}", dep); - exec.with_mast_forest(lib.mast_forest().clone()); + self.with_mast_forest(lib.mast_forest().clone()); } - DependencyResolution::Local(LocalResolution::Package(_)) => { - todo!("local package dependencies are not yet supported in executor") + DependencyResolution::Local(LocalResolution::Package(pkg)) => { + if let MastArtifact::Library(lib) = &pkg.mast { + self.with_mast_forest(lib.mast_forest().clone()); + } else { + Err(Report::msg(format!( + "expected package {} to contain library", + pkg.name + )))?; + } } } } @@ -85,10 +101,10 @@ impl Executor { log::debug!("executor created"); - Ok(exec) + Ok(self) } - /// Set the contents of memory for the shadow stack frame of the entrypoint + /// Set the contents of memory for the shadow stack frame of the entrypint pub fn with_advice_inputs(&mut self, advice: AdviceInputs) -> &mut Self { self.advice.extend(advice); self @@ -290,6 +306,10 @@ impl Executor { let out = self.execute(program, session); out.parse_result().expect("invalid result") } + + pub fn dependency_resolver_mut(&mut self) -> &mut MemDependencyResolverByDigest { + &mut self.dependency_resolver + } } #[track_caller] diff --git a/sdk/stdlib-sys/src/intrinsics/felt.rs b/sdk/stdlib-sys/src/intrinsics/felt.rs index a1abd333..3fba8e49 100644 --- a/sdk/stdlib-sys/src/intrinsics/felt.rs +++ b/sdk/stdlib-sys/src/intrinsics/felt.rs @@ -7,6 +7,9 @@ extern "C" { #[link_name = "from-u64-unchecked"] fn extern_from_u64_unchecked(value: u64) -> Felt; + #[link_name = "from-u32-unchecked"] + fn extern_from_u32_unchecked(value: u32) -> Felt; + #[link_name = "as_u64"] fn extern_as_u64(felt: Felt) -> u64; @@ -68,9 +71,11 @@ extern "C" { macro_rules! felt { // Trigger a compile-time error if the value is not a constant ($value:literal) => {{ - const VALUE: u64 = $value as u64; - assert!(VALUE <= Felt::M, "Invalid Felt value, must be >= 0 and <= 2^64 - 2^32 + 1"); - Felt::from_u64_unchecked(VALUE) + // const VALUE: u64 = $value as u64; + // assert!(VALUE <= Felt::M, "Invalid Felt value, must be >= 0 and <= 2^64 - 2^32 + 1"); + // Temporarily switch to `from_u32_unchecked` to use `bitcast` and avoid checks. + const VALUE: u32 = $value as u32; + Felt::from_u32_unchecked(VALUE) }}; } @@ -94,6 +99,11 @@ impl Felt { unsafe { extern_from_u64_unchecked(value) } } + #[inline(always)] + pub fn from_u32_unchecked(value: u32) -> Self { + unsafe { extern_from_u32_unchecked(value) } + } + #[inline(always)] pub fn new(value: u64) -> Result { if value > Self::M { diff --git a/sdk/stdlib-sys/src/stdlib/mem.rs b/sdk/stdlib-sys/src/stdlib/mem.rs index e3a794dc..ed5c1b9a 100644 --- a/sdk/stdlib-sys/src/stdlib/mem.rs +++ b/sdk/stdlib-sys/src/stdlib/mem.rs @@ -3,7 +3,10 @@ extern crate alloc; use alloc::vec::Vec; -use crate::intrinsics::{Felt, Word}; +use crate::{ + felt, + intrinsics::{Felt, Word}, +}; #[link(wasm_import_module = "miden:core-import/stdlib-mem@1.0.0")] extern "C" { @@ -96,7 +99,7 @@ pub fn pipe_double_words_to_memory(num_words: Felt) -> (Word, Vec) { let end_ptr = unsafe { write_ptr.add(num_words_in_felts) }; // Place for returned C, B, A, write_ptr let mut ret_area = ::core::mem::MaybeUninit::::uninit(); - let zero = Felt::from_u64_unchecked(0); + let zero = felt!(0); unsafe { extern_pipe_double_words_to_memory( zero, diff --git a/tests/integration/expected/rust_sdk/cross_ctx_account.masm b/tests/integration/expected/rust_sdk/cross_ctx_account.masm index 5217b54a..4992ec4d 100644 --- a/tests/integration/expected/rust_sdk/cross_ctx_account.masm +++ b/tests/integration/expected/rust_sdk/cross_ctx_account.masm @@ -409,16 +409,7 @@ end export."miden:cross-ctx-account/foo@1.0.0#process-felt" - exec."wit_bindgen_rt::run_ctors_once" - push.0.1 - dup.1 - dup.1 - push.4294967295.1 - exec.::std::math::u64::lt - assert - mul.4294967296 - add - add + exec."wit_bindgen_rt::run_ctors_once" push.3 add end diff --git a/tests/integration/expected/rust_sdk/cross_ctx_account.wat b/tests/integration/expected/rust_sdk/cross_ctx_account.wat index 7e0aac95..af61b90b 100644 --- a/tests/integration/expected/rust_sdk/cross_ctx_account.wat +++ b/tests/integration/expected/rust_sdk/cross_ctx_account.wat @@ -17,13 +17,13 @@ (instance (type (;0;) (func (param "a" float32) (param "b" float32) (result float32))) (export (;0;) "add" (func (type 0))) - (type (;1;) (func (param "a" u64) (result float32))) - (export (;1;) "from-u64-unchecked" (func (type 1))) + (type (;1;) (func (param "a" u32) (result float32))) + (export (;1;) "from-u32-unchecked" (func (type 1))) ) ) (import "miden:core-import/intrinsics-felt@1.0.0" (instance (;2;) (type 2))) (core module (;0;) - (type (;0;) (func (param i64) (result f32))) + (type (;0;) (func (param i32) (result f32))) (type (;1;) (func (param f32 f32) (result f32))) (type (;2;) (func (result i32))) (type (;3;) (func)) @@ -31,7 +31,7 @@ (type (;5;) (func (param i32 i32 i32 i32) (result i32))) (type (;6;) (func (param f32) (result f32))) (type (;7;) (func (param i32 i32 i32) (result i32))) - (import "miden:core-import/intrinsics-felt@1.0.0" "from-u64-unchecked" (func $miden_stdlib_sys::intrinsics::felt::extern_from_u64_unchecked (;0;) (type 0))) + (import "miden:core-import/intrinsics-felt@1.0.0" "from-u32-unchecked" (func $miden_stdlib_sys::intrinsics::felt::extern_from_u32_unchecked (;0;) (type 0))) (import "miden:core-import/intrinsics-felt@1.0.0" "add" (func $miden_stdlib_sys::intrinsics::felt::extern_add (;1;) (type 1))) (import "miden:core-import/intrinsics-mem@1.0.0" "heap-base" (func $miden_sdk_alloc::heap_base (;2;) (type 2))) (func $__wasm_call_ctors (;3;) (type 3)) @@ -66,8 +66,8 @@ (func $miden:cross-ctx-account/foo@1.0.0#process-felt (;7;) (type 6) (param f32) (result f32) call $wit_bindgen_rt::run_ctors_once local.get 0 - i64.const 1 - call $miden_stdlib_sys::intrinsics::felt::extern_from_u64_unchecked + i32.const 3 + call $miden_stdlib_sys::intrinsics::felt::extern_from_u32_unchecked call $miden_stdlib_sys::intrinsics::felt::extern_add ) (func $cabi_realloc_wit_bindgen_0_28_0 (;8;) (type 5) (param i32 i32 i32 i32) (result i32) @@ -206,11 +206,11 @@ ) (alias export 2 "add" (func (;0;))) (core func (;0;) (canon lower (func 0))) - (alias export 2 "from-u64-unchecked" (func (;1;))) + (alias export 2 "from-u32-unchecked" (func (;1;))) (core func (;1;) (canon lower (func 1))) (core instance (;0;) (export "add" (func 0)) - (export "from-u64-unchecked" (func 1)) + (export "from-u32-unchecked" (func 1)) ) (alias export 1 "heap-base" (func (;2;))) (core func (;2;) (canon lower (func 2))) diff --git a/tests/integration/expected/rust_sdk/cross_ctx_note.masm b/tests/integration/expected/rust_sdk/cross_ctx_note.masm index 6afb6316..df8870df 100644 --- a/tests/integration/expected/rust_sdk/cross_ctx_note.masm +++ b/tests/integration/expected/rust_sdk/cross_ctx_note.masm @@ -411,23 +411,9 @@ end export."miden:base/note-script@1.0.0#note-script" exec."wit_bindgen_rt::run_ctors_once" - push.0.7 - dup.1 - dup.1 - push.4294967295.1 - exec.::std::math::u64::lt - assert - mul.4294967296 - add + push.7 exec.::miden:cross-ctx-account/foo@1.0.0::"process-felt" - push.0.10 - dup.1 - dup.1 - push.4294967295.1 - exec.::std::math::u64::lt - assert - mul.4294967296 - add + push.10 assert_eq end diff --git a/tests/integration/expected/rust_sdk/cross_ctx_note.wat b/tests/integration/expected/rust_sdk/cross_ctx_note.wat index d88055d4..e51fd955 100644 --- a/tests/integration/expected/rust_sdk/cross_ctx_note.wat +++ b/tests/integration/expected/rust_sdk/cross_ctx_note.wat @@ -25,15 +25,15 @@ (import "miden:core-import/intrinsics-mem@1.0.0" (instance (;2;) (type 3))) (type (;4;) (instance - (type (;0;) (func (param "a" u64) (result float32))) - (export (;0;) "from-u64-unchecked" (func (type 0))) + (type (;0;) (func (param "a" u32) (result float32))) + (export (;0;) "from-u32-unchecked" (func (type 0))) (type (;1;) (func (param "a" float32) (param "b" float32))) (export (;1;) "assert-eq" (func (type 1))) ) ) (import "miden:core-import/intrinsics-felt@1.0.0" (instance (;3;) (type 4))) (core module (;0;) - (type (;0;) (func (param i64) (result f32))) + (type (;0;) (func (param i32) (result f32))) (type (;1;) (func (param f32) (result f32))) (type (;2;) (func (param f32 f32))) (type (;3;) (func (result i32))) @@ -41,7 +41,7 @@ (type (;5;) (func (param i32 i32) (result i32))) (type (;6;) (func (param i32 i32 i32 i32) (result i32))) (type (;7;) (func (param i32 i32 i32) (result i32))) - (import "miden:core-import/intrinsics-felt@1.0.0" "from-u64-unchecked" (func $miden_stdlib_sys::intrinsics::felt::extern_from_u64_unchecked (;0;) (type 0))) + (import "miden:core-import/intrinsics-felt@1.0.0" "from-u32-unchecked" (func $miden_stdlib_sys::intrinsics::felt::extern_from_u32_unchecked (;0;) (type 0))) (import "miden:cross-ctx-account/foo@1.0.0" "process-felt" (func $cross_ctx_note::bindings::miden::cross_ctx_account::foo::process_felt::wit_import (;1;) (type 1))) (import "miden:core-import/intrinsics-felt@1.0.0" "assert-eq" (func $miden_stdlib_sys::intrinsics::felt::extern_assert_eq (;2;) (type 2))) (import "miden:core-import/intrinsics-mem@1.0.0" "heap-base" (func $miden_sdk_alloc::heap_base (;3;) (type 3))) @@ -76,11 +76,11 @@ ) (func $miden:base/note-script@1.0.0#note-script (;8;) (type 4) call $wit_bindgen_rt::run_ctors_once - i64.const 7 - call $miden_stdlib_sys::intrinsics::felt::extern_from_u64_unchecked + i32.const 7 + call $miden_stdlib_sys::intrinsics::felt::extern_from_u32_unchecked call $cross_ctx_note::bindings::miden::cross_ctx_account::foo::process_felt::wit_import - i64.const 10 - call $miden_stdlib_sys::intrinsics::felt::extern_from_u64_unchecked + i32.const 10 + call $miden_stdlib_sys::intrinsics::felt::extern_from_u32_unchecked call $miden_stdlib_sys::intrinsics::felt::extern_assert_eq ) (func $cabi_realloc_wit_bindgen_0_28_0 (;9;) (type 6) (param i32 i32 i32 i32) (result i32) @@ -217,12 +217,12 @@ (elem (;0;) (i32.const 1) func $cross_ctx_note::bindings::__link_custom_section_describing_imports $cabi_realloc) (data $.rodata (;0;) (i32.const 1048576) "\01\00\00\00\01\00\00\00\01\00\00\00\01\00\00\00\01\00\00\00\01\00\00\00\01\00\00\00\01\00\00\00\01\00\00\00\02\00\00\00") ) - (alias export 3 "from-u64-unchecked" (func (;0;))) + (alias export 3 "from-u32-unchecked" (func (;0;))) (core func (;0;) (canon lower (func 0))) (alias export 3 "assert-eq" (func (;1;))) (core func (;1;) (canon lower (func 1))) (core instance (;0;) - (export "from-u64-unchecked" (func 0)) + (export "from-u32-unchecked" (func 0)) (export "assert-eq" (func 1)) ) (alias export 1 "process-felt" (func (;2;))) diff --git a/tests/integration/expected/rust_sdk_account_test/miden_sdk_account_test.hir b/tests/integration/expected/rust_sdk_account_test/miden_sdk_account_test.hir index d1c17a1f..64a41d2d 100644 --- a/tests/integration/expected/rust_sdk_account_test/miden_sdk_account_test.hir +++ b/tests/integration/expected/rust_sdk_account_test/miden_sdk_account_test.hir @@ -43,8 +43,8 @@ (block 0 (let (v1 felt) (const.felt 0)) (let (v2 felt) (exec #miden_base_sys::bindings::account::get_id)) - (let (v3 i64) (const.i64 42)) - (let (v4 felt) (cast v3)) + (let (v3 i32) (const.i32 42)) + (let (v4 felt) (bitcast v3)) (let (v5 felt) (add.unchecked v4 v2)) (br (block 1 v5))) @@ -63,14 +63,14 @@ (let (v7 i32) (band v5 v6)) (let (v8 (ptr i32)) (global.symbol #__stack_pointer)) (store v8 v7) - (let (v9 i64) (const.i64 1)) - (let (v10 felt) (cast v9)) - (let (v11 i64) (const.i64 2)) - (let (v12 felt) (cast v11)) - (let (v13 i64) (const.i64 3)) - (let (v14 felt) (cast v13)) - (let (v15 i64) (const.i64 4)) - (let (v16 felt) (cast v15)) + (let (v9 i32) (const.i32 1)) + (let (v10 felt) (bitcast v9)) + (let (v11 i32) (const.i32 2)) + (let (v12 felt) (bitcast v11)) + (let (v13 i32) (const.i32 3)) + (let (v14 felt) (bitcast v13)) + (let (v15 i32) (const.i32 4)) + (let (v16 felt) (bitcast v15)) (let (v17 u32) (bitcast v7)) (let (v18 u32) (add.checked v17 12)) (let (v19 u32) (mod.unchecked v18 4)) @@ -1300,8 +1300,8 @@ (assertz 250 v18) (let (v19 (ptr i32)) (inttoptr v17)) (let (v20 i32) (load v19)) - (let (v21 i64) (const.i64 0)) - (let (v22 felt) (cast v21)) + (let (v21 i32) (const.i32 0)) + (let (v22 felt) (bitcast v21)) (let (v23 i32) (const.i32 4)) (let (v24 u32) (bitcast v23)) (let (v25 i32) (shl.wrapping v12 v24)) diff --git a/tests/integration/expected/rust_sdk_account_test/miden_sdk_account_test.wat b/tests/integration/expected/rust_sdk_account_test/miden_sdk_account_test.wat index af033cea..5dbc9cf4 100644 --- a/tests/integration/expected/rust_sdk_account_test/miden_sdk_account_test.wat +++ b/tests/integration/expected/rust_sdk_account_test/miden_sdk_account_test.wat @@ -1,5 +1,5 @@ (module $miden_sdk_account_test.wasm - (type (;0;) (func (param i64) (result f32))) + (type (;0;) (func (param i32) (result f32))) (type (;1;) (func (param f32 f32) (result f32))) (type (;2;) (func (param f32) (result i64))) (type (;3;) (func (param f32 f32) (result i32))) @@ -7,26 +7,26 @@ (type (;5;) (func (param f32))) (type (;6;) (func (param f32) (result f32))) (type (;7;) (func (param f32 f32))) - (type (;8;) (func (param i32 i32 i32 i32 i32 i32 i32 i32 i32))) - (type (;9;) (func (param i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32))) - (type (;10;) (func (param f32 f32 f32 f32 f32 f32 f32 f32))) - (type (;11;) (func (result i32))) - (type (;12;) (func (result f32))) - (type (;13;) (func (param f32 f32 f32 f32 i32))) - (type (;14;) (func (param i32) (result i32))) - (type (;15;) (func (param f32 f32 f32 f32 f32 f32 f32 f32 f32 f32) (result f32))) - (type (;16;) (func (param f32 i32 i32))) - (type (;17;) (func (param f32 f32 f32 f32 f32 f32 f32 f32 f32 f32 f32 f32 i32 i32 i32))) - (type (;18;) (func (param i32 i32 i32) (result i32))) - (type (;19;) (func (param i32 i32))) - (type (;20;) (func (param i32 f32))) - (type (;21;) (func (param i32) (result f32))) + (type (;8;) (func (param i64) (result f32))) + (type (;9;) (func (param i32 i32 i32 i32 i32 i32 i32 i32 i32))) + (type (;10;) (func (param i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32))) + (type (;11;) (func (param f32 f32 f32 f32 f32 f32 f32 f32))) + (type (;12;) (func (result i32))) + (type (;13;) (func (result f32))) + (type (;14;) (func (param f32 f32 f32 f32 i32))) + (type (;15;) (func (param i32) (result i32))) + (type (;16;) (func (param f32 f32 f32 f32 f32 f32 f32 f32 f32 f32) (result f32))) + (type (;17;) (func (param f32 i32 i32))) + (type (;18;) (func (param f32 f32 f32 f32 f32 f32 f32 f32 f32 f32 f32 f32 i32 i32 i32))) + (type (;19;) (func (param i32 i32 i32) (result i32))) + (type (;20;) (func (param i32 i32))) + (type (;21;) (func (param i32 f32))) (type (;22;) (func (param i32 f32 f32 i32) (result f32))) (type (;23;) (func (param i32 i32) (result i32))) (type (;24;) (func (param i32))) (type (;25;) (func (param i32 i32 i32))) (type (;26;) (func)) - (import "miden:core-import/intrinsics-felt@1.0.0" "from-u64-unchecked" (func $miden_stdlib_sys::intrinsics::felt::extern_from_u64_unchecked (;0;) (type 0))) + (import "miden:core-import/intrinsics-felt@1.0.0" "from-u32-unchecked" (func $miden_stdlib_sys::intrinsics::felt::extern_from_u32_unchecked (;0;) (type 0))) (import "miden:core-import/intrinsics-felt@1.0.0" "add" (func $miden_stdlib_sys::intrinsics::felt::extern_add (;1;) (type 1))) (import "miden:core-import/intrinsics-felt@1.0.0" "as_u64" (func $miden_stdlib_sys::intrinsics::felt::extern_as_u64 (;2;) (type 2))) (import "miden:core-import/intrinsics-felt@1.0.0" "gt" (func $miden_stdlib_sys::intrinsics::felt::extern_gt (;3;) (type 3))) @@ -44,19 +44,20 @@ (import "miden:core-import/intrinsics-felt@1.0.0" "mul" (func $miden_stdlib_sys::intrinsics::felt::extern_mul (;15;) (type 1))) (import "miden:core-import/intrinsics-felt@1.0.0" "div" (func $miden_stdlib_sys::intrinsics::felt::extern_div (;16;) (type 1))) (import "miden:core-import/intrinsics-felt@1.0.0" "assert-eq" (func $miden_stdlib_sys::intrinsics::felt::extern_assert_eq (;17;) (type 7))) - (import "miden:core-import/intrinsics-felt@1.0.0" "neg" (func $miden_stdlib_sys::intrinsics::felt::extern_neg (;18;) (type 6))) - (import "miden:core-import/stdlib-crypto-hashes-blake3@1.0.0" "hash-one-to-one" (func $miden_stdlib_sys::stdlib::crypto::hashes::extern_blake3_hash_1to1 (;19;) (type 8))) - (import "miden:core-import/stdlib-crypto-hashes-blake3@1.0.0" "hash-two-to-one" (func $miden_stdlib_sys::stdlib::crypto::hashes::extern_blake3_hash_2to1 (;20;) (type 9))) - (import "miden:core-import/stdlib-crypto-dsa-rpo-falcon@1.0.0" "rpo-falcon512-verify" (func $miden_stdlib_sys::stdlib::crypto::dsa::extern_rpo_falcon512_verify (;21;) (type 10))) - (import "miden:core-import/intrinsics-mem@1.0.0" "heap-base" (func $miden_sdk_alloc::heap_base (;22;) (type 11))) - (import "miden:core-import/account@1.0.0" "get-id" (func $miden_base_sys::bindings::account::extern_account_get_id (;23;) (type 12))) - (import "miden:core-import/account@1.0.0" "add-asset" (func $miden_base_sys::bindings::account::extern_account_add_asset (;24;) (type 13))) - (import "miden:core-import/account@1.0.0" "remove-asset" (func $miden_base_sys::bindings::account::extern_account_remove_asset (;25;) (type 13))) - (import "miden:core-import/note@1.0.0" "get-inputs" (func $miden_base_sys::bindings::note::extern_note_get_inputs (;26;) (type 14))) - (import "miden:core-import/tx@1.0.0" "create-note" (func $miden_base_sys::bindings::tx::extern_tx_create_note (;27;) (type 15))) - (import "miden:core-import/stdlib-mem@1.0.0" "pipe-words-to-memory" (func $miden_stdlib_sys::stdlib::mem::extern_pipe_words_to_memory (;28;) (type 16))) - (import "miden:core-import/stdlib-mem@1.0.0" "pipe-double-words-to-memory" (func $miden_stdlib_sys::stdlib::mem::extern_pipe_double_words_to_memory (;29;) (type 17))) - (func $core::alloc::global::GlobalAlloc::alloc_zeroed (;30;) (type 18) (param i32 i32 i32) (result i32) + (import "miden:core-import/intrinsics-felt@1.0.0" "from-u64-unchecked" (func $miden_stdlib_sys::intrinsics::felt::extern_from_u64_unchecked (;18;) (type 8))) + (import "miden:core-import/intrinsics-felt@1.0.0" "neg" (func $miden_stdlib_sys::intrinsics::felt::extern_neg (;19;) (type 6))) + (import "miden:core-import/stdlib-crypto-hashes-blake3@1.0.0" "hash-one-to-one" (func $miden_stdlib_sys::stdlib::crypto::hashes::extern_blake3_hash_1to1 (;20;) (type 9))) + (import "miden:core-import/stdlib-crypto-hashes-blake3@1.0.0" "hash-two-to-one" (func $miden_stdlib_sys::stdlib::crypto::hashes::extern_blake3_hash_2to1 (;21;) (type 10))) + (import "miden:core-import/stdlib-crypto-dsa-rpo-falcon@1.0.0" "rpo-falcon512-verify" (func $miden_stdlib_sys::stdlib::crypto::dsa::extern_rpo_falcon512_verify (;22;) (type 11))) + (import "miden:core-import/intrinsics-mem@1.0.0" "heap-base" (func $miden_sdk_alloc::heap_base (;23;) (type 12))) + (import "miden:core-import/account@1.0.0" "get-id" (func $miden_base_sys::bindings::account::extern_account_get_id (;24;) (type 13))) + (import "miden:core-import/account@1.0.0" "add-asset" (func $miden_base_sys::bindings::account::extern_account_add_asset (;25;) (type 14))) + (import "miden:core-import/account@1.0.0" "remove-asset" (func $miden_base_sys::bindings::account::extern_account_remove_asset (;26;) (type 14))) + (import "miden:core-import/note@1.0.0" "get-inputs" (func $miden_base_sys::bindings::note::extern_note_get_inputs (;27;) (type 15))) + (import "miden:core-import/tx@1.0.0" "create-note" (func $miden_base_sys::bindings::tx::extern_tx_create_note (;28;) (type 16))) + (import "miden:core-import/stdlib-mem@1.0.0" "pipe-words-to-memory" (func $miden_stdlib_sys::stdlib::mem::extern_pipe_words_to_memory (;29;) (type 17))) + (import "miden:core-import/stdlib-mem@1.0.0" "pipe-double-words-to-memory" (func $miden_stdlib_sys::stdlib::mem::extern_pipe_double_words_to_memory (;30;) (type 18))) + (func $core::alloc::global::GlobalAlloc::alloc_zeroed (;31;) (type 19) (param i32 i32 i32) (result i32) block ;; label = @1 local.get 0 local.get 1 @@ -72,16 +73,16 @@ end local.get 1 ) - (func $get_wallet_magic_number (;31;) (type 12) (result f32) + (func $get_wallet_magic_number (;32;) (type 13) (result f32) (local f32) call $miden_base_sys::bindings::account::get_id local.set 0 - i64.const 42 - call $miden_stdlib_sys::intrinsics::felt::extern_from_u64_unchecked + i32.const 42 + call $miden_stdlib_sys::intrinsics::felt::extern_from_u32_unchecked local.get 0 call $miden_stdlib_sys::intrinsics::felt::extern_add ) - (func $test_add_asset (;32;) (type 12) (result f32) + (func $test_add_asset (;33;) (type 13) (result f32) (local i32 i32 f32 f32 f32) global.get $__stack_pointer local.tee 0 @@ -91,18 +92,18 @@ i32.and local.tee 1 global.set $__stack_pointer - i64.const 1 - call $miden_stdlib_sys::intrinsics::felt::extern_from_u64_unchecked + i32.const 1 + call $miden_stdlib_sys::intrinsics::felt::extern_from_u32_unchecked local.set 2 - i64.const 2 - call $miden_stdlib_sys::intrinsics::felt::extern_from_u64_unchecked + i32.const 2 + call $miden_stdlib_sys::intrinsics::felt::extern_from_u32_unchecked local.set 3 - i64.const 3 - call $miden_stdlib_sys::intrinsics::felt::extern_from_u64_unchecked + i32.const 3 + call $miden_stdlib_sys::intrinsics::felt::extern_from_u32_unchecked local.set 4 local.get 1 - i64.const 4 - call $miden_stdlib_sys::intrinsics::felt::extern_from_u64_unchecked + i32.const 4 + call $miden_stdlib_sys::intrinsics::felt::extern_from_u32_unchecked f32.store offset=12 local.get 1 local.get 4 @@ -125,7 +126,7 @@ global.set $__stack_pointer local.get 2 ) - (func $test_felt_ops_smoke (;33;) (type 1) (param f32 f32) (result f32) + (func $test_felt_ops_smoke (;34;) (type 1) (param f32 f32) (result f32) (local i64) local.get 0 call $miden_stdlib_sys::intrinsics::felt::extern_as_u64 @@ -214,7 +215,7 @@ local.get 0 call $miden_stdlib_sys::intrinsics::felt::extern_neg ) - (func $note_script (;34;) (type 12) (result f32) + (func $note_script (;35;) (type 13) (result f32) (local i32 f32 i32 i32) global.get $__stack_pointer i32.const 16 @@ -263,7 +264,7 @@ br 0 (;@1;) end ) - (func $test_blake3_hash_1to1 (;35;) (type 19) (param i32 i32) + (func $test_blake3_hash_1to1 (;36;) (type 20) (param i32 i32) (local i32 i32) global.get $__stack_pointer local.tee 2 @@ -316,7 +317,7 @@ local.get 2 global.set $__stack_pointer ) - (func $test_blake3_hash_2to1 (;36;) (type 19) (param i32 i32) + (func $test_blake3_hash_2to1 (;37;) (type 20) (param i32 i32) local.get 1 i32.load align=1 local.get 1 @@ -352,7 +353,7 @@ local.get 0 call $miden_stdlib_sys::stdlib::crypto::hashes::extern_blake3_hash_2to1 ) - (func $test_rpo_falcon512_verify (;37;) (type 19) (param i32 i32) + (func $test_rpo_falcon512_verify (;38;) (type 20) (param i32 i32) local.get 0 f32.load local.get 0 @@ -371,17 +372,17 @@ f32.load offset=12 call $miden_stdlib_sys::stdlib::crypto::dsa::extern_rpo_falcon512_verify ) - (func $test_pipe_words_to_memory (;38;) (type 20) (param i32 f32) + (func $test_pipe_words_to_memory (;39;) (type 21) (param i32 f32) local.get 0 local.get 1 call $miden_stdlib_sys::stdlib::mem::pipe_words_to_memory ) - (func $test_pipe_double_words_to_memory (;39;) (type 20) (param i32 f32) + (func $test_pipe_double_words_to_memory (;40;) (type 21) (param i32 f32) local.get 0 local.get 1 call $miden_stdlib_sys::stdlib::mem::pipe_double_words_to_memory ) - (func $test_remove_asset (;40;) (type 21) (param i32) (result f32) + (func $test_remove_asset (;41;) (type 0) (param i32) (result f32) (local i32 i32 f32) global.get $__stack_pointer local.tee 1 @@ -401,26 +402,26 @@ global.set $__stack_pointer local.get 3 ) - (func $test_create_note (;41;) (type 22) (param i32 f32 f32 i32) (result f32) + (func $test_create_note (;42;) (type 22) (param i32 f32 f32 i32) (result f32) local.get 0 local.get 1 local.get 2 local.get 3 call $miden_base_sys::bindings::tx::create_note ) - (func $__rust_alloc (;42;) (type 23) (param i32 i32) (result i32) + (func $__rust_alloc (;43;) (type 23) (param i32 i32) (result i32) i32.const 1048576 local.get 1 local.get 0 call $::alloc ) - (func $__rust_alloc_zeroed (;43;) (type 23) (param i32 i32) (result i32) + (func $__rust_alloc_zeroed (;44;) (type 23) (param i32 i32) (result i32) i32.const 1048576 local.get 1 local.get 0 call $core::alloc::global::GlobalAlloc::alloc_zeroed ) - (func $::alloc (;44;) (type 18) (param i32 i32 i32) (result i32) + (func $::alloc (;45;) (type 19) (param i32 i32 i32) (result i32) (local i32 i32) block ;; label = @1 local.get 1 @@ -488,10 +489,10 @@ end unreachable ) - (func $miden_base_sys::bindings::account::get_id (;45;) (type 12) (result f32) + (func $miden_base_sys::bindings::account::get_id (;46;) (type 13) (result f32) call $miden_base_sys::bindings::account::extern_account_get_id ) - (func $miden_base_sys::bindings::account::add_asset (;46;) (type 19) (param i32 i32) + (func $miden_base_sys::bindings::account::add_asset (;47;) (type 20) (param i32 i32) local.get 1 f32.load local.get 1 @@ -503,7 +504,7 @@ local.get 0 call $miden_base_sys::bindings::account::extern_account_add_asset ) - (func $miden_base_sys::bindings::account::remove_asset (;47;) (type 19) (param i32 i32) + (func $miden_base_sys::bindings::account::remove_asset (;48;) (type 20) (param i32 i32) local.get 1 f32.load local.get 1 @@ -515,7 +516,7 @@ local.get 0 call $miden_base_sys::bindings::account::extern_account_remove_asset ) - (func $miden_base_sys::bindings::note::get_inputs (;48;) (type 24) (param i32) + (func $miden_base_sys::bindings::note::get_inputs (;49;) (type 24) (param i32) (local i32 i32 i32) global.get $__stack_pointer i32.const 16 @@ -562,7 +563,7 @@ i32.add global.set $__stack_pointer ) - (func $miden_base_sys::bindings::tx::create_note (;49;) (type 22) (param i32 f32 f32 i32) (result f32) + (func $miden_base_sys::bindings::tx::create_note (;50;) (type 22) (param i32 f32 f32 i32) (result f32) local.get 0 f32.load local.get 0 @@ -583,7 +584,7 @@ f32.load offset=12 call $miden_base_sys::bindings::tx::extern_tx_create_note ) - (func $alloc::vec::Vec::with_capacity (;50;) (type 19) (param i32 i32) + (func $alloc::vec::Vec::with_capacity (;51;) (type 20) (param i32 i32) (local i32 i32) global.get $__stack_pointer i32.const 16 @@ -628,7 +629,7 @@ i32.add global.set $__stack_pointer ) - (func $alloc::raw_vec::RawVec::try_allocate_in (;51;) (type 25) (param i32 i32 i32) + (func $alloc::raw_vec::RawVec::try_allocate_in (;52;) (type 25) (param i32 i32 i32) (local i32) block ;; label = @1 block ;; label = @2 @@ -702,7 +703,7 @@ local.get 1 i32.store ) - (func $miden_stdlib_sys::stdlib::mem::pipe_words_to_memory (;52;) (type 20) (param i32 f32) + (func $miden_stdlib_sys::stdlib::mem::pipe_words_to_memory (;53;) (type 21) (param i32 f32) (local i32 i32) global.get $__stack_pointer local.tee 2 @@ -767,7 +768,7 @@ local.get 2 global.set $__stack_pointer ) - (func $miden_stdlib_sys::stdlib::mem::pipe_double_words_to_memory (;53;) (type 20) (param i32 f32) + (func $miden_stdlib_sys::stdlib::mem::pipe_double_words_to_memory (;54;) (type 21) (param i32 f32) (local i32 i32 i32 i32) global.get $__stack_pointer local.tee 2 @@ -790,8 +791,8 @@ local.get 3 i32.load offset=24 local.set 5 - i64.const 0 - call $miden_stdlib_sys::intrinsics::felt::extern_from_u64_unchecked + i32.const 0 + call $miden_stdlib_sys::intrinsics::felt::extern_from_u32_unchecked local.tee 1 local.get 1 local.get 1 @@ -861,68 +862,68 @@ local.get 2 global.set $__stack_pointer ) - (func $dummy (;54;) (type 26)) - (func $__wasm_call_dtors (;55;) (type 26) + (func $dummy (;55;) (type 26)) + (func $__wasm_call_dtors (;56;) (type 26) call $dummy call $dummy ) - (func $alloc::raw_vec::handle_error (;56;) (type 19) (param i32 i32) + (func $alloc::raw_vec::handle_error (;57;) (type 20) (param i32 i32) unreachable ) - (func $get_wallet_magic_number.command_export (;57;) (type 12) (result f32) + (func $get_wallet_magic_number.command_export (;58;) (type 13) (result f32) call $get_wallet_magic_number call $__wasm_call_dtors ) - (func $test_add_asset.command_export (;58;) (type 12) (result f32) + (func $test_add_asset.command_export (;59;) (type 13) (result f32) call $test_add_asset call $__wasm_call_dtors ) - (func $test_felt_ops_smoke.command_export (;59;) (type 1) (param f32 f32) (result f32) + (func $test_felt_ops_smoke.command_export (;60;) (type 1) (param f32 f32) (result f32) local.get 0 local.get 1 call $test_felt_ops_smoke call $__wasm_call_dtors ) - (func $note_script.command_export (;60;) (type 12) (result f32) + (func $note_script.command_export (;61;) (type 13) (result f32) call $note_script call $__wasm_call_dtors ) - (func $test_blake3_hash_1to1.command_export (;61;) (type 19) (param i32 i32) + (func $test_blake3_hash_1to1.command_export (;62;) (type 20) (param i32 i32) local.get 0 local.get 1 call $test_blake3_hash_1to1 call $__wasm_call_dtors ) - (func $test_blake3_hash_2to1.command_export (;62;) (type 19) (param i32 i32) + (func $test_blake3_hash_2to1.command_export (;63;) (type 20) (param i32 i32) local.get 0 local.get 1 call $test_blake3_hash_2to1 call $__wasm_call_dtors ) - (func $test_rpo_falcon512_verify.command_export (;63;) (type 19) (param i32 i32) + (func $test_rpo_falcon512_verify.command_export (;64;) (type 20) (param i32 i32) local.get 0 local.get 1 call $test_rpo_falcon512_verify call $__wasm_call_dtors ) - (func $test_pipe_words_to_memory.command_export (;64;) (type 20) (param i32 f32) + (func $test_pipe_words_to_memory.command_export (;65;) (type 21) (param i32 f32) local.get 0 local.get 1 call $test_pipe_words_to_memory call $__wasm_call_dtors ) - (func $test_pipe_double_words_to_memory.command_export (;65;) (type 20) (param i32 f32) + (func $test_pipe_double_words_to_memory.command_export (;66;) (type 21) (param i32 f32) local.get 0 local.get 1 call $test_pipe_double_words_to_memory call $__wasm_call_dtors ) - (func $test_remove_asset.command_export (;66;) (type 21) (param i32) (result f32) + (func $test_remove_asset.command_export (;67;) (type 0) (param i32) (result f32) local.get 0 call $test_remove_asset call $__wasm_call_dtors ) - (func $test_create_note.command_export (;67;) (type 22) (param i32 f32 f32 i32) (result f32) + (func $test_create_note.command_export (;68;) (type 22) (param i32 f32 f32 i32) (result f32) local.get 0 local.get 1 local.get 2 diff --git a/tests/integration/src/rust_masm_tests/rust_sdk.rs b/tests/integration/src/rust_masm_tests/rust_sdk.rs index f2ac1d6b..a1d734fb 100644 --- a/tests/integration/src/rust_masm_tests/rust_sdk.rs +++ b/tests/integration/src/rust_masm_tests/rust_sdk.rs @@ -1,11 +1,17 @@ -use std::{collections::BTreeMap, env, path::PathBuf}; +use std::{collections::BTreeMap, env, path::PathBuf, sync::Arc}; use expect_test::expect_file; use miden_core::crypto::hash::RpoDigest; +use miden_package::Package; +use midenc_debug::Executor; use midenc_frontend_wasm::WasmTranslationConfig; -use midenc_hir::{InterfaceFunctionIdent, InterfaceIdent, Symbol}; +use midenc_hir::{ + FunctionIdent, Ident, InterfaceFunctionIdent, InterfaceIdent, SourceSpan, Symbol, +}; -use crate::{cargo_proj::project, compiler_test::sdk_crate_path, CompilerTest}; +use crate::{ + cargo_proj::project, compiler_test::sdk_crate_path, CompilerTest, CompilerTestBuilder, +}; #[test] fn account() { @@ -166,7 +172,8 @@ fn rust_sdk_cross_ctx_note() { let _ = env_logger::builder().is_test(true).try_init(); let config = WasmTranslationConfig::default(); - let mut test = CompilerTest::rust_source_cargo_miden( + + let mut builder = CompilerTestBuilder::rust_source_cargo_miden( "../rust-apps-wasm/rust-sdk/cross-ctx-note", config, [ @@ -175,13 +182,34 @@ fn rust_sdk_cross_ctx_note() { "-l".into(), "base".into(), "--link-library".into(), - masp_path.into_os_string().into_string().unwrap().into(), + masp_path.clone().into_os_string().into_string().unwrap().into(), ], ); + builder.with_entrypoint(FunctionIdent { + // module: Ident::new(Symbol::intern("miden:base/note-script@1.0.0"), SourceSpan::default()), + module: Ident::new(Symbol::intern("cross_ctx_note"), SourceSpan::default()), + // function: Ident::new(Symbol::intern("note-script"), SourceSpan::default()), + function: Ident::new( + Symbol::intern("miden:base/note-script@1.0.0#note-script"), + SourceSpan::default(), + ), + }); + let mut test = builder.build(); let artifact_name = test.artifact_name().to_string(); test.expect_wasm(expect_file![format!("../../expected/rust_sdk/{artifact_name}.wat")]); test.expect_ir(expect_file![format!("../../expected/rust_sdk/{artifact_name}.hir")]); test.expect_masm(expect_file![format!("../../expected/rust_sdk/{artifact_name}.masm")]); - // TODO: run it in the VM (outpit is checked via assert_eq! in the note code) + // Run it in the VM (output is checked via assert_eq in the note code) + let package = test.compiled_package(); + + let mut exec = Executor::new(vec![]); + let account_package = + Arc::new(Package::read_from_bytes(std::fs::read(masp_path).unwrap()).unwrap()); + + exec.dependency_resolver_mut() + .add(account_package.digest(), account_package.into()); + exec.with_dependencies(&package.manifest.dependencies).unwrap(); + + let trace = exec.execute(&package.unwrap_program(), &test.session); } diff --git a/tests/rust-apps-wasm/rust-sdk/basic-wallet/src/bindings.rs b/tests/rust-apps-wasm/rust-sdk/basic-wallet/src/bindings.rs index f51ea85f..55d58f5c 100644 --- a/tests/rust-apps-wasm/rust-sdk/basic-wallet/src/bindings.rs +++ b/tests/rust-apps-wasm/rust-sdk/basic-wallet/src/bindings.rs @@ -62,6 +62,25 @@ pub mod miden { } } #[allow(unused_unsafe, clippy::all)] + pub fn from_u32_unchecked(a: u32) -> f32 { + unsafe { + #[cfg(target_arch = "wasm32")] + #[link( + wasm_import_module = "miden:core-import/intrinsics-felt@1.0.0" + )] + extern "C" { + #[link_name = "from-u32-unchecked"] + fn wit_import(_: i32) -> f32; + } + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32) -> f32 { + unreachable!() + } + let ret = wit_import(_rt::as_i32(&a)); + ret + } + } + #[allow(unused_unsafe, clippy::all)] pub fn assert_eq(a: f32, b: f32) { unsafe { #[cfg(target_arch = "wasm32")] @@ -592,8 +611,8 @@ pub(crate) use __export_basic_wallet_world_impl as export; #[cfg(target_arch = "wasm32")] #[link_section = "component-type:wit-bindgen:0.31.0:miden:basic-wallet@1.0.0:basic-wallet-world:encoded world"] #[doc(hidden)] -pub static __WIT_BINDGEN_COMPONENT_TYPE: [u8; 1863] = *b"\ -\0asm\x0d\0\x01\0\0\x19\x16wit-component-encoding\x04\0\x07\xbe\x0d\x01A\x02\x01\ +pub static __WIT_BINDGEN_COMPONENT_TYPE: [u8; 1894] = *b"\ +\0asm\x0d\0\x01\0\0\x19\x16wit-component-encoding\x04\0\x07\xdd\x0d\x01A\x02\x01\ A\x17\x01B\x1f\x01r\x01\x05innerv\x04\0\x04felt\x03\0\0\x01o\x04\x01\x01\x01\x01\ \x01r\x01\x05inner\x02\x04\0\x04word\x03\0\x03\x01r\x01\x05inner\x01\x04\0\x0aac\ count-id\x03\0\x05\x01r\x01\x05inner\x04\x04\0\x09recipient\x03\0\x07\x01r\x01\x05\ @@ -605,36 +624,37 @@ orage-root\x03\0\x15\x01r\x01\x05inner\x04\x04\0\x11account-code-root\x03\0\x17\ r\x01\x05inner\x04\x04\0\x10vault-commitment\x03\0\x19\x01r\x01\x05inner\x01\x04\ \0\x07note-id\x03\0\x1b\x01r\x01\x05inner\x01\x04\0\x09note-type\x03\0\x1d\x03\x01\ \x1bmiden:base/core-types@1.0.0\x05\0\x01B\x02\x01@\0\0z\x04\0\x09heap-base\x01\0\ -\x03\x01&miden:core-import/intrinsics-mem@1.0.0\x05\x01\x01B\x08\x01@\x02\x01av\x01\ +\x03\x01&miden:core-import/intrinsics-mem@1.0.0\x05\x01\x01B\x0a\x01@\x02\x01av\x01\ bv\0v\x04\0\x03add\x01\0\x01@\x02\x01av\x01bv\0\x7f\x04\0\x02eq\x01\x01\x01@\x01\ -\x01aw\0v\x04\0\x12from-u64-unchecked\x01\x02\x01@\x02\x01av\x01bv\x01\0\x04\0\x09\ -assert-eq\x01\x03\x03\x01'miden:core-import/intrinsics-felt@1.0.0\x05\x02\x01B\x02\ -\x01@\x09\x02a0z\x02a1z\x02a2z\x02a3z\x02a4z\x02a5z\x02a6z\x02a7z\x0aresult-ptrz\ -\x01\0\x04\0\x0fhash-one-to-one\x01\0\x03\x013miden:core-import/stdlib-crypto-ha\ -shes-blake3@1.0.0\x05\x03\x01B\x05\x01@\x05\x06asset0v\x06asset1v\x06asset2v\x06\ -asset3v\x0aresult-ptrz\x01\0\x04\0\x09add-asset\x01\0\x04\0\x0cremove-asset\x01\0\ -\x01@\0\0v\x04\0\x06get-id\x01\x01\x03\x01\x1fmiden:core-import/account@1.0.0\x05\ -\x04\x01B\x03\x01@\x01\x03ptrz\0z\x04\0\x0aget-inputs\x01\0\x04\0\x0aget-assets\x01\ -\0\x03\x01\x1cmiden:core-import/note@1.0.0\x05\x05\x01B\x02\x01@\x0a\x06asset0v\x06\ -asset1v\x06asset2v\x06asset3v\x03tagv\x09note-typev\x0arecipient0v\x0arecipient1\ -v\x0arecipient2v\x0arecipient3v\0v\x04\0\x0bcreate-note\x01\0\x03\x01\x1amiden:c\ -ore-import/tx@1.0.0\x05\x06\x02\x03\0\0\x0acore-asset\x02\x03\0\0\x03tag\x02\x03\ -\0\0\x09recipient\x02\x03\0\0\x09note-type\x02\x03\0\0\x04felt\x01B\x0e\x02\x03\x02\ -\x01\x07\x04\0\x0acore-asset\x03\0\0\x02\x03\x02\x01\x08\x04\0\x03tag\x03\0\x02\x02\ -\x03\x02\x01\x09\x04\0\x09recipient\x03\0\x04\x02\x03\x02\x01\x0a\x04\0\x09note-\ -type\x03\0\x06\x02\x03\x02\x01\x0b\x04\0\x04felt\x03\0\x08\x01@\x01\x0acore-asse\ -t\x01\x01\0\x04\0\x0dreceive-asset\x01\x0a\x01@\x04\x0acore-asset\x01\x03tag\x03\ -\x09note-type\x07\x09recipient\x05\x01\0\x04\0\x0asend-asset\x01\x0b\x04\x01%mid\ -en:basic-wallet/basic-wallet@1.0.0\x05\x0c\x01B\x14\x02\x03\x02\x01\x07\x04\0\x0a\ -core-asset\x03\0\0\x02\x03\x02\x01\x08\x04\0\x03tag\x03\0\x02\x02\x03\x02\x01\x09\ -\x04\0\x09recipient\x03\0\x04\x02\x03\x02\x01\x0a\x04\0\x09note-type\x03\0\x06\x02\ -\x03\x02\x01\x0b\x04\0\x04felt\x03\0\x08\x01@\x02\x01a\x09\x01b\x09\0\x09\x04\0\x14\ -test-felt-intrinsics\x01\x0a\x01p}\x01@\x01\x05input\x0b\0\x0b\x04\0\x0btest-std\ -lib\x01\x0c\x01p\x09\x01@\x01\x05input\x0d\0\x0d\x04\0\x11process-list-felt\x01\x0e\ -\x01@\x01\x05input\x01\0\x01\x04\0\x12process-core-asset\x01\x0f\x04\x01\x1cmide\ -n:basic-wallet/aux@1.0.0\x05\x0d\x04\x01+miden:basic-wallet/basic-wallet-world@1\ -.0.0\x04\0\x0b\x18\x01\0\x12basic-wallet-world\x03\0\0\0G\x09producers\x01\x0cpr\ -ocessed-by\x02\x0dwit-component\x070.216.0\x10wit-bindgen-rust\x060.31.0"; +\x01aw\0v\x04\0\x12from-u64-unchecked\x01\x02\x01@\x01\x01ay\0v\x04\0\x12from-u3\ +2-unchecked\x01\x03\x01@\x02\x01av\x01bv\x01\0\x04\0\x09assert-eq\x01\x04\x03\x01\ +'miden:core-import/intrinsics-felt@1.0.0\x05\x02\x01B\x02\x01@\x09\x02a0z\x02a1z\ +\x02a2z\x02a3z\x02a4z\x02a5z\x02a6z\x02a7z\x0aresult-ptrz\x01\0\x04\0\x0fhash-on\ +e-to-one\x01\0\x03\x013miden:core-import/stdlib-crypto-hashes-blake3@1.0.0\x05\x03\ +\x01B\x05\x01@\x05\x06asset0v\x06asset1v\x06asset2v\x06asset3v\x0aresult-ptrz\x01\ +\0\x04\0\x09add-asset\x01\0\x04\0\x0cremove-asset\x01\0\x01@\0\0v\x04\0\x06get-i\ +d\x01\x01\x03\x01\x1fmiden:core-import/account@1.0.0\x05\x04\x01B\x03\x01@\x01\x03\ +ptrz\0z\x04\0\x0aget-inputs\x01\0\x04\0\x0aget-assets\x01\0\x03\x01\x1cmiden:cor\ +e-import/note@1.0.0\x05\x05\x01B\x02\x01@\x0a\x06asset0v\x06asset1v\x06asset2v\x06\ +asset3v\x03tagv\x09note-typev\x0arecipient0v\x0arecipient1v\x0arecipient2v\x0are\ +cipient3v\0v\x04\0\x0bcreate-note\x01\0\x03\x01\x1amiden:core-import/tx@1.0.0\x05\ +\x06\x02\x03\0\0\x0acore-asset\x02\x03\0\0\x03tag\x02\x03\0\0\x09recipient\x02\x03\ +\0\0\x09note-type\x02\x03\0\0\x04felt\x01B\x0e\x02\x03\x02\x01\x07\x04\0\x0acore\ +-asset\x03\0\0\x02\x03\x02\x01\x08\x04\0\x03tag\x03\0\x02\x02\x03\x02\x01\x09\x04\ +\0\x09recipient\x03\0\x04\x02\x03\x02\x01\x0a\x04\0\x09note-type\x03\0\x06\x02\x03\ +\x02\x01\x0b\x04\0\x04felt\x03\0\x08\x01@\x01\x0acore-asset\x01\x01\0\x04\0\x0dr\ +eceive-asset\x01\x0a\x01@\x04\x0acore-asset\x01\x03tag\x03\x09note-type\x07\x09r\ +ecipient\x05\x01\0\x04\0\x0asend-asset\x01\x0b\x04\x01%miden:basic-wallet/basic-\ +wallet@1.0.0\x05\x0c\x01B\x14\x02\x03\x02\x01\x07\x04\0\x0acore-asset\x03\0\0\x02\ +\x03\x02\x01\x08\x04\0\x03tag\x03\0\x02\x02\x03\x02\x01\x09\x04\0\x09recipient\x03\ +\0\x04\x02\x03\x02\x01\x0a\x04\0\x09note-type\x03\0\x06\x02\x03\x02\x01\x0b\x04\0\ +\x04felt\x03\0\x08\x01@\x02\x01a\x09\x01b\x09\0\x09\x04\0\x14test-felt-intrinsic\ +s\x01\x0a\x01p}\x01@\x01\x05input\x0b\0\x0b\x04\0\x0btest-stdlib\x01\x0c\x01p\x09\ +\x01@\x01\x05input\x0d\0\x0d\x04\0\x11process-list-felt\x01\x0e\x01@\x01\x05inpu\ +t\x01\0\x01\x04\0\x12process-core-asset\x01\x0f\x04\x01\x1cmiden:basic-wallet/au\ +x@1.0.0\x05\x0d\x04\x01+miden:basic-wallet/basic-wallet-world@1.0.0\x04\0\x0b\x18\ +\x01\0\x12basic-wallet-world\x03\0\0\0G\x09producers\x01\x0cprocessed-by\x02\x0d\ +wit-component\x070.216.0\x10wit-bindgen-rust\x060.31.0"; #[inline(never)] #[doc(hidden)] pub fn __link_custom_section_describing_imports() { diff --git a/tests/rust-apps-wasm/rust-sdk/cross-ctx-account/src/bindings.rs b/tests/rust-apps-wasm/rust-sdk/cross-ctx-account/src/bindings.rs index 112e7c54..3e329ec9 100644 --- a/tests/rust-apps-wasm/rust-sdk/cross-ctx-account/src/bindings.rs +++ b/tests/rust-apps-wasm/rust-sdk/cross-ctx-account/src/bindings.rs @@ -62,6 +62,25 @@ pub mod miden { } } #[allow(unused_unsafe, clippy::all)] + pub fn from_u32_unchecked(a: u32) -> f32 { + unsafe { + #[cfg(target_arch = "wasm32")] + #[link( + wasm_import_module = "miden:core-import/intrinsics-felt@1.0.0" + )] + extern "C" { + #[link_name = "from-u32-unchecked"] + fn wit_import(_: i32) -> f32; + } + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32) -> f32 { + unreachable!() + } + let ret = wit_import(_rt::as_i32(&a)); + ret + } + } + #[allow(unused_unsafe, clippy::all)] pub fn assert_eq(a: f32, b: f32) { unsafe { #[cfg(target_arch = "wasm32")] @@ -349,8 +368,8 @@ pub(crate) use __export_foo_world_impl as export; #[cfg(target_arch = "wasm32")] #[link_section = "component-type:wit-bindgen:0.31.0:miden:cross-ctx-account@1.0.0:foo-world:encoded world"] #[doc(hidden)] -pub static __WIT_BINDGEN_COMPONENT_TYPE: [u8; 1390] = *b"\ -\0asm\x0d\0\x01\0\0\x19\x16wit-component-encoding\x04\0\x07\xee\x09\x01A\x02\x01\ +pub static __WIT_BINDGEN_COMPONENT_TYPE: [u8; 1421] = *b"\ +\0asm\x0d\0\x01\0\0\x19\x16wit-component-encoding\x04\0\x07\x8d\x0a\x01A\x02\x01\ A\x11\x01B\x1f\x01r\x01\x05innerv\x04\0\x04felt\x03\0\0\x01o\x04\x01\x01\x01\x01\ \x01r\x01\x05inner\x02\x04\0\x04word\x03\0\x03\x01r\x01\x05inner\x01\x04\0\x0aac\ count-id\x03\0\x05\x01r\x01\x05inner\x04\x04\0\x09recipient\x03\0\x07\x01r\x01\x05\ @@ -362,24 +381,25 @@ orage-root\x03\0\x15\x01r\x01\x05inner\x04\x04\0\x11account-code-root\x03\0\x17\ r\x01\x05inner\x04\x04\0\x10vault-commitment\x03\0\x19\x01r\x01\x05inner\x01\x04\ \0\x07note-id\x03\0\x1b\x01r\x01\x05inner\x01\x04\0\x09note-type\x03\0\x1d\x03\x01\ \x1bmiden:base/core-types@1.0.0\x05\0\x01B\x02\x01@\0\0z\x04\0\x09heap-base\x01\0\ -\x03\x01&miden:core-import/intrinsics-mem@1.0.0\x05\x01\x01B\x08\x01@\x02\x01av\x01\ +\x03\x01&miden:core-import/intrinsics-mem@1.0.0\x05\x01\x01B\x0a\x01@\x02\x01av\x01\ bv\0v\x04\0\x03add\x01\0\x01@\x02\x01av\x01bv\0\x7f\x04\0\x02eq\x01\x01\x01@\x01\ -\x01aw\0v\x04\0\x12from-u64-unchecked\x01\x02\x01@\x02\x01av\x01bv\x01\0\x04\0\x09\ -assert-eq\x01\x03\x03\x01'miden:core-import/intrinsics-felt@1.0.0\x05\x02\x01B\x02\ -\x01@\x09\x02a0z\x02a1z\x02a2z\x02a3z\x02a4z\x02a5z\x02a6z\x02a7z\x0aresult-ptrz\ -\x01\0\x04\0\x0fhash-one-to-one\x01\0\x03\x013miden:core-import/stdlib-crypto-ha\ -shes-blake3@1.0.0\x05\x03\x01B\x05\x01@\x05\x06asset0v\x06asset1v\x06asset2v\x06\ -asset3v\x0aresult-ptrz\x01\0\x04\0\x09add-asset\x01\0\x04\0\x0cremove-asset\x01\0\ -\x01@\0\0v\x04\0\x06get-id\x01\x01\x03\x01\x1fmiden:core-import/account@1.0.0\x05\ -\x04\x01B\x03\x01@\x01\x03ptrz\0z\x04\0\x0aget-inputs\x01\0\x04\0\x0aget-assets\x01\ -\0\x03\x01\x1cmiden:core-import/note@1.0.0\x05\x05\x01B\x02\x01@\x0a\x06asset0v\x06\ -asset1v\x06asset2v\x06asset3v\x03tagv\x09note-typev\x0arecipient0v\x0arecipient1\ -v\x0arecipient2v\x0arecipient3v\0v\x04\0\x0bcreate-note\x01\0\x03\x01\x1amiden:c\ -ore-import/tx@1.0.0\x05\x06\x02\x03\0\0\x04felt\x01B\x04\x02\x03\x02\x01\x07\x04\ -\0\x04felt\x03\0\0\x01@\x01\x05input\x01\0\x01\x04\0\x0cprocess-felt\x01\x02\x04\ -\x01!miden:cross-ctx-account/foo@1.0.0\x05\x08\x04\x01'miden:cross-ctx-account/f\ -oo-world@1.0.0\x04\0\x0b\x0f\x01\0\x09foo-world\x03\0\0\0G\x09producers\x01\x0cp\ -rocessed-by\x02\x0dwit-component\x070.216.0\x10wit-bindgen-rust\x060.31.0"; +\x01aw\0v\x04\0\x12from-u64-unchecked\x01\x02\x01@\x01\x01ay\0v\x04\0\x12from-u3\ +2-unchecked\x01\x03\x01@\x02\x01av\x01bv\x01\0\x04\0\x09assert-eq\x01\x04\x03\x01\ +'miden:core-import/intrinsics-felt@1.0.0\x05\x02\x01B\x02\x01@\x09\x02a0z\x02a1z\ +\x02a2z\x02a3z\x02a4z\x02a5z\x02a6z\x02a7z\x0aresult-ptrz\x01\0\x04\0\x0fhash-on\ +e-to-one\x01\0\x03\x013miden:core-import/stdlib-crypto-hashes-blake3@1.0.0\x05\x03\ +\x01B\x05\x01@\x05\x06asset0v\x06asset1v\x06asset2v\x06asset3v\x0aresult-ptrz\x01\ +\0\x04\0\x09add-asset\x01\0\x04\0\x0cremove-asset\x01\0\x01@\0\0v\x04\0\x06get-i\ +d\x01\x01\x03\x01\x1fmiden:core-import/account@1.0.0\x05\x04\x01B\x03\x01@\x01\x03\ +ptrz\0z\x04\0\x0aget-inputs\x01\0\x04\0\x0aget-assets\x01\0\x03\x01\x1cmiden:cor\ +e-import/note@1.0.0\x05\x05\x01B\x02\x01@\x0a\x06asset0v\x06asset1v\x06asset2v\x06\ +asset3v\x03tagv\x09note-typev\x0arecipient0v\x0arecipient1v\x0arecipient2v\x0are\ +cipient3v\0v\x04\0\x0bcreate-note\x01\0\x03\x01\x1amiden:core-import/tx@1.0.0\x05\ +\x06\x02\x03\0\0\x04felt\x01B\x04\x02\x03\x02\x01\x07\x04\0\x04felt\x03\0\0\x01@\ +\x01\x05input\x01\0\x01\x04\0\x0cprocess-felt\x01\x02\x04\x01!miden:cross-ctx-ac\ +count/foo@1.0.0\x05\x08\x04\x01'miden:cross-ctx-account/foo-world@1.0.0\x04\0\x0b\ +\x0f\x01\0\x09foo-world\x03\0\0\0G\x09producers\x01\x0cprocessed-by\x02\x0dwit-c\ +omponent\x070.216.0\x10wit-bindgen-rust\x060.31.0"; #[inline(never)] #[doc(hidden)] pub fn __link_custom_section_describing_imports() { diff --git a/tests/rust-apps-wasm/rust-sdk/cross-ctx-account/src/lib.rs b/tests/rust-apps-wasm/rust-sdk/cross-ctx-account/src/lib.rs index 6add6ea3..18b6e311 100644 --- a/tests/rust-apps-wasm/rust-sdk/cross-ctx-account/src/lib.rs +++ b/tests/rust-apps-wasm/rust-sdk/cross-ctx-account/src/lib.rs @@ -31,6 +31,6 @@ impl foo::Guest for MyFoo { fn process_felt(input: Felt) -> Felt { // TODO: load increment from the global variable to test rodata initialization on fresh // context creation - input + felt!(1) + input + felt!(3) } } diff --git a/tests/rust-apps-wasm/rust-sdk/cross-ctx-note/src/bindings.rs b/tests/rust-apps-wasm/rust-sdk/cross-ctx-note/src/bindings.rs index 479e2906..57655e6e 100644 --- a/tests/rust-apps-wasm/rust-sdk/cross-ctx-note/src/bindings.rs +++ b/tests/rust-apps-wasm/rust-sdk/cross-ctx-note/src/bindings.rs @@ -62,6 +62,25 @@ pub mod miden { } } #[allow(unused_unsafe, clippy::all)] + pub fn from_u32_unchecked(a: u32) -> f32 { + unsafe { + #[cfg(target_arch = "wasm32")] + #[link( + wasm_import_module = "miden:core-import/intrinsics-felt@1.0.0" + )] + extern "C" { + #[link_name = "from-u32-unchecked"] + fn wit_import(_: i32) -> f32; + } + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32) -> f32 { + unreachable!() + } + let ret = wit_import(_rt::as_i32(&a)); + ret + } + } + #[allow(unused_unsafe, clippy::all)] pub fn assert_eq(a: f32, b: f32) { unsafe { #[cfg(target_arch = "wasm32")] @@ -374,8 +393,8 @@ pub(crate) use __export_cross_ctx_note_world_impl as export; #[cfg(target_arch = "wasm32")] #[link_section = "component-type:wit-bindgen:0.31.0:miden:cross-ctx-note@1.0.0:cross-ctx-note-world:encoded world"] #[doc(hidden)] -pub static __WIT_BINDGEN_COMPONENT_TYPE: [u8; 1466] = *b"\ -\0asm\x0d\0\x01\0\0\x19\x16wit-component-encoding\x04\0\x07\xaf\x0a\x01A\x02\x01\ +pub static __WIT_BINDGEN_COMPONENT_TYPE: [u8; 1497] = *b"\ +\0asm\x0d\0\x01\0\0\x19\x16wit-component-encoding\x04\0\x07\xce\x0a\x01A\x02\x01\ A\x13\x01B\x1f\x01r\x01\x05innerv\x04\0\x04felt\x03\0\0\x01o\x04\x01\x01\x01\x01\ \x01r\x01\x05inner\x02\x04\0\x04word\x03\0\x03\x01r\x01\x05inner\x01\x04\0\x0aac\ count-id\x03\0\x05\x01r\x01\x05inner\x04\x04\0\x09recipient\x03\0\x07\x01r\x01\x05\ @@ -389,24 +408,24 @@ r\x01\x05inner\x04\x04\0\x10vault-commitment\x03\0\x19\x01r\x01\x05inner\x01\x04 \x1bmiden:base/core-types@1.0.0\x05\0\x02\x03\0\0\x04felt\x01B\x04\x02\x03\x02\x01\ \x01\x04\0\x04felt\x03\0\0\x01@\x01\x05input\x01\0\x01\x04\0\x0cprocess-felt\x01\ \x02\x03\x01!miden:cross-ctx-account/foo@1.0.0\x05\x02\x01B\x02\x01@\0\0z\x04\0\x09\ -heap-base\x01\0\x03\x01&miden:core-import/intrinsics-mem@1.0.0\x05\x03\x01B\x08\x01\ +heap-base\x01\0\x03\x01&miden:core-import/intrinsics-mem@1.0.0\x05\x03\x01B\x0a\x01\ @\x02\x01av\x01bv\0v\x04\0\x03add\x01\0\x01@\x02\x01av\x01bv\0\x7f\x04\0\x02eq\x01\ -\x01\x01@\x01\x01aw\0v\x04\0\x12from-u64-unchecked\x01\x02\x01@\x02\x01av\x01bv\x01\ -\0\x04\0\x09assert-eq\x01\x03\x03\x01'miden:core-import/intrinsics-felt@1.0.0\x05\ -\x04\x01B\x02\x01@\x09\x02a0z\x02a1z\x02a2z\x02a3z\x02a4z\x02a5z\x02a6z\x02a7z\x0a\ -result-ptrz\x01\0\x04\0\x0fhash-one-to-one\x01\0\x03\x013miden:core-import/stdli\ -b-crypto-hashes-blake3@1.0.0\x05\x05\x01B\x05\x01@\x05\x06asset0v\x06asset1v\x06\ -asset2v\x06asset3v\x0aresult-ptrz\x01\0\x04\0\x09add-asset\x01\0\x04\0\x0cremove\ --asset\x01\0\x01@\0\0v\x04\0\x06get-id\x01\x01\x03\x01\x1fmiden:core-import/acco\ -unt@1.0.0\x05\x06\x01B\x03\x01@\x01\x03ptrz\0z\x04\0\x0aget-inputs\x01\0\x04\0\x0a\ -get-assets\x01\0\x03\x01\x1cmiden:core-import/note@1.0.0\x05\x07\x01B\x02\x01@\x0a\ -\x06asset0v\x06asset1v\x06asset2v\x06asset3v\x03tagv\x09note-typev\x0arecipient0\ -v\x0arecipient1v\x0arecipient2v\x0arecipient3v\0v\x04\0\x0bcreate-note\x01\0\x03\ -\x01\x1amiden:core-import/tx@1.0.0\x05\x08\x01B\x02\x01@\0\x01\0\x04\0\x0bnote-s\ -cript\x01\0\x04\x01\x1cmiden:base/note-script@1.0.0\x05\x09\x04\x01/miden:cross-\ -ctx-note/cross-ctx-note-world@1.0.0\x04\0\x0b\x1a\x01\0\x14cross-ctx-note-world\x03\ -\0\0\0G\x09producers\x01\x0cprocessed-by\x02\x0dwit-component\x070.216.0\x10wit-\ -bindgen-rust\x060.31.0"; +\x01\x01@\x01\x01aw\0v\x04\0\x12from-u64-unchecked\x01\x02\x01@\x01\x01ay\0v\x04\ +\0\x12from-u32-unchecked\x01\x03\x01@\x02\x01av\x01bv\x01\0\x04\0\x09assert-eq\x01\ +\x04\x03\x01'miden:core-import/intrinsics-felt@1.0.0\x05\x04\x01B\x02\x01@\x09\x02\ +a0z\x02a1z\x02a2z\x02a3z\x02a4z\x02a5z\x02a6z\x02a7z\x0aresult-ptrz\x01\0\x04\0\x0f\ +hash-one-to-one\x01\0\x03\x013miden:core-import/stdlib-crypto-hashes-blake3@1.0.\ +0\x05\x05\x01B\x05\x01@\x05\x06asset0v\x06asset1v\x06asset2v\x06asset3v\x0aresul\ +t-ptrz\x01\0\x04\0\x09add-asset\x01\0\x04\0\x0cremove-asset\x01\0\x01@\0\0v\x04\0\ +\x06get-id\x01\x01\x03\x01\x1fmiden:core-import/account@1.0.0\x05\x06\x01B\x03\x01\ +@\x01\x03ptrz\0z\x04\0\x0aget-inputs\x01\0\x04\0\x0aget-assets\x01\0\x03\x01\x1c\ +miden:core-import/note@1.0.0\x05\x07\x01B\x02\x01@\x0a\x06asset0v\x06asset1v\x06\ +asset2v\x06asset3v\x03tagv\x09note-typev\x0arecipient0v\x0arecipient1v\x0arecipi\ +ent2v\x0arecipient3v\0v\x04\0\x0bcreate-note\x01\0\x03\x01\x1amiden:core-import/\ +tx@1.0.0\x05\x08\x01B\x02\x01@\0\x01\0\x04\0\x0bnote-script\x01\0\x04\x01\x1cmid\ +en:base/note-script@1.0.0\x05\x09\x04\x01/miden:cross-ctx-note/cross-ctx-note-wo\ +rld@1.0.0\x04\0\x0b\x1a\x01\0\x14cross-ctx-note-world\x03\0\0\0G\x09producers\x01\ +\x0cprocessed-by\x02\x0dwit-component\x070.216.0\x10wit-bindgen-rust\x060.31.0"; #[inline(never)] #[doc(hidden)] pub fn __link_custom_section_describing_imports() { diff --git a/tests/rust-apps-wasm/rust-sdk/p2id-note/src/bindings.rs b/tests/rust-apps-wasm/rust-sdk/p2id-note/src/bindings.rs index d687c2cf..1b4f8224 100644 --- a/tests/rust-apps-wasm/rust-sdk/p2id-note/src/bindings.rs +++ b/tests/rust-apps-wasm/rust-sdk/p2id-note/src/bindings.rs @@ -299,6 +299,25 @@ pub mod miden { } } #[allow(unused_unsafe, clippy::all)] + pub fn from_u32_unchecked(a: u32) -> f32 { + unsafe { + #[cfg(target_arch = "wasm32")] + #[link( + wasm_import_module = "miden:core-import/intrinsics-felt@1.0.0" + )] + extern "C" { + #[link_name = "from-u32-unchecked"] + fn wit_import(_: i32) -> f32; + } + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32) -> f32 { + unreachable!() + } + let ret = wit_import(_rt::as_i32(&a)); + ret + } + } + #[allow(unused_unsafe, clippy::all)] pub fn assert_eq(a: f32, b: f32) { unsafe { #[cfg(target_arch = "wasm32")] @@ -585,8 +604,8 @@ pub(crate) use __export_p2id_world_impl as export; #[cfg(target_arch = "wasm32")] #[link_section = "component-type:wit-bindgen:0.31.0:miden:p2id@1.0.0:p2id-world:encoded world"] #[doc(hidden)] -pub static __WIT_BINDGEN_COMPONENT_TYPE: [u8; 1896] = *b"\ -\0asm\x0d\0\x01\0\0\x19\x16wit-component-encoding\x04\0\x07\xe7\x0d\x01A\x02\x01\ +pub static __WIT_BINDGEN_COMPONENT_TYPE: [u8; 1927] = *b"\ +\0asm\x0d\0\x01\0\0\x19\x16wit-component-encoding\x04\0\x07\x86\x0e\x01A\x02\x01\ A\x19\x01B\x1f\x01r\x01\x05innerv\x04\0\x04felt\x03\0\0\x01o\x04\x01\x01\x01\x01\ \x01r\x01\x05inner\x02\x04\0\x04word\x03\0\x03\x01r\x01\x05inner\x01\x04\0\x0aac\ count-id\x03\0\x05\x01r\x01\x05inner\x04\x04\0\x09recipient\x03\0\x07\x01r\x01\x05\ @@ -612,23 +631,24 @@ g\x03\0\x02\x02\x03\x02\x01\x03\x04\0\x09recipient\x03\0\x04\x02\x03\x02\x01\x04 st-stdlib\x01\x0c\x01p\x09\x01@\x01\x05input\x0d\0\x0d\x04\0\x11process-list-fel\ t\x01\x0e\x01@\x01\x05input\x01\0\x01\x04\0\x12process-core-asset\x01\x0f\x03\x01\ \x1cmiden:basic-wallet/aux@1.0.0\x05\x07\x01B\x02\x01@\0\0z\x04\0\x09heap-base\x01\ -\0\x03\x01&miden:core-import/intrinsics-mem@1.0.0\x05\x08\x01B\x08\x01@\x02\x01a\ +\0\x03\x01&miden:core-import/intrinsics-mem@1.0.0\x05\x08\x01B\x0a\x01@\x02\x01a\ v\x01bv\0v\x04\0\x03add\x01\0\x01@\x02\x01av\x01bv\0\x7f\x04\0\x02eq\x01\x01\x01\ -@\x01\x01aw\0v\x04\0\x12from-u64-unchecked\x01\x02\x01@\x02\x01av\x01bv\x01\0\x04\ -\0\x09assert-eq\x01\x03\x03\x01'miden:core-import/intrinsics-felt@1.0.0\x05\x09\x01\ -B\x02\x01@\x09\x02a0z\x02a1z\x02a2z\x02a3z\x02a4z\x02a5z\x02a6z\x02a7z\x0aresult\ --ptrz\x01\0\x04\0\x0fhash-one-to-one\x01\0\x03\x013miden:core-import/stdlib-cryp\ -to-hashes-blake3@1.0.0\x05\x0a\x01B\x05\x01@\x05\x06asset0v\x06asset1v\x06asset2\ -v\x06asset3v\x0aresult-ptrz\x01\0\x04\0\x09add-asset\x01\0\x04\0\x0cremove-asset\ -\x01\0\x01@\0\0v\x04\0\x06get-id\x01\x01\x03\x01\x1fmiden:core-import/account@1.\ -0.0\x05\x0b\x01B\x03\x01@\x01\x03ptrz\0z\x04\0\x0aget-inputs\x01\0\x04\0\x0aget-\ -assets\x01\0\x03\x01\x1cmiden:core-import/note@1.0.0\x05\x0c\x01B\x02\x01@\x0a\x06\ -asset0v\x06asset1v\x06asset2v\x06asset3v\x03tagv\x09note-typev\x0arecipient0v\x0a\ -recipient1v\x0arecipient2v\x0arecipient3v\0v\x04\0\x0bcreate-note\x01\0\x03\x01\x1a\ -miden:core-import/tx@1.0.0\x05\x0d\x01B\x02\x01@\0\x01\0\x04\0\x0bnote-script\x01\ -\0\x04\x01\x1cmiden:base/note-script@1.0.0\x05\x0e\x04\x01\x1bmiden:p2id/p2id-wo\ -rld@1.0.0\x04\0\x0b\x10\x01\0\x0ap2id-world\x03\0\0\0G\x09producers\x01\x0cproce\ -ssed-by\x02\x0dwit-component\x070.216.0\x10wit-bindgen-rust\x060.31.0"; +@\x01\x01aw\0v\x04\0\x12from-u64-unchecked\x01\x02\x01@\x01\x01ay\0v\x04\0\x12fr\ +om-u32-unchecked\x01\x03\x01@\x02\x01av\x01bv\x01\0\x04\0\x09assert-eq\x01\x04\x03\ +\x01'miden:core-import/intrinsics-felt@1.0.0\x05\x09\x01B\x02\x01@\x09\x02a0z\x02\ +a1z\x02a2z\x02a3z\x02a4z\x02a5z\x02a6z\x02a7z\x0aresult-ptrz\x01\0\x04\0\x0fhash\ +-one-to-one\x01\0\x03\x013miden:core-import/stdlib-crypto-hashes-blake3@1.0.0\x05\ +\x0a\x01B\x05\x01@\x05\x06asset0v\x06asset1v\x06asset2v\x06asset3v\x0aresult-ptr\ +z\x01\0\x04\0\x09add-asset\x01\0\x04\0\x0cremove-asset\x01\0\x01@\0\0v\x04\0\x06\ +get-id\x01\x01\x03\x01\x1fmiden:core-import/account@1.0.0\x05\x0b\x01B\x03\x01@\x01\ +\x03ptrz\0z\x04\0\x0aget-inputs\x01\0\x04\0\x0aget-assets\x01\0\x03\x01\x1cmiden\ +:core-import/note@1.0.0\x05\x0c\x01B\x02\x01@\x0a\x06asset0v\x06asset1v\x06asset\ +2v\x06asset3v\x03tagv\x09note-typev\x0arecipient0v\x0arecipient1v\x0arecipient2v\ +\x0arecipient3v\0v\x04\0\x0bcreate-note\x01\0\x03\x01\x1amiden:core-import/tx@1.\ +0.0\x05\x0d\x01B\x02\x01@\0\x01\0\x04\0\x0bnote-script\x01\0\x04\x01\x1cmiden:ba\ +se/note-script@1.0.0\x05\x0e\x04\x01\x1bmiden:p2id/p2id-world@1.0.0\x04\0\x0b\x10\ +\x01\0\x0ap2id-world\x03\0\0\0G\x09producers\x01\x0cprocessed-by\x02\x0dwit-comp\ +onent\x070.216.0\x10wit-bindgen-rust\x060.31.0"; #[inline(never)] #[doc(hidden)] pub fn __link_custom_section_describing_imports() { diff --git a/tests/rust-apps-wasm/rust-sdk/wit-sdk/miden-core-import.wit b/tests/rust-apps-wasm/rust-sdk/wit-sdk/miden-core-import.wit index 386d8b29..dfb49747 100644 --- a/tests/rust-apps-wasm/rust-sdk/wit-sdk/miden-core-import.wit +++ b/tests/rust-apps-wasm/rust-sdk/wit-sdk/miden-core-import.wit @@ -13,6 +13,7 @@ interface intrinsics-felt { add: func(a: f32, b: f32) -> f32; eq: func(a: f32, b: f32) -> bool; from-u64-unchecked: func(a: u64) -> f32; + from-u32-unchecked: func(a: u32) -> f32; assert-eq: func(a: f32, b: f32); } @@ -74,4 +75,4 @@ world all { import note; import tx; -} \ No newline at end of file +}