Skip to content

Commit caa6f20

Browse files
committed
protocol: VM v0.22.1 compatibility fixes
1 parent abd3f78 commit caa6f20

15 files changed

Lines changed: 207 additions & 98 deletions

File tree

Cargo.lock

Lines changed: 121 additions & 20 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/miden-protocol/build.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ fn compile_tx_kernel(source_dir: &Path, target_dir: &Path, build_dir: &str) -> R
168168

169169
let masb_file_path =
170170
target_dir.join("kernel_library").with_extension(Library::LIBRARY_EXTENSION);
171-
test_lib.write_to_file(masb_file_path).into_diagnostic()?;
171+
(*test_lib).write_to_file(masb_file_path).into_diagnostic()?;
172172
}
173173

174174
Ok(assembler)
@@ -284,7 +284,7 @@ fn compile_protocol_lib(
284284
let output_file = target_dir.join("protocol").with_extension(Library::LIBRARY_EXTENSION);
285285
protocol_lib.write_to_file(output_file).into_diagnostic()?;
286286

287-
Ok(protocol_lib)
287+
Ok(Arc::unwrap_or_clone(protocol_lib))
288288
}
289289

290290
// HELPER FUNCTIONS

crates/miden-protocol/src/account/builder/mod.rs

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,7 @@ impl AccountBuilder {
289289

290290
#[cfg(test)]
291291
mod tests {
292-
use std::sync::LazyLock;
292+
use std::sync::{Arc, LazyLock};
293293

294294
use assert_matches::assert_matches;
295295
use miden_assembly::{Assembler, Library};
@@ -312,14 +312,18 @@ mod tests {
312312
";
313313

314314
static CUSTOM_LIBRARY1: LazyLock<Library> = LazyLock::new(|| {
315-
Assembler::default()
316-
.assemble_library([CUSTOM_CODE1])
317-
.expect("code should be valid")
315+
Arc::unwrap_or_clone(
316+
Assembler::default()
317+
.assemble_library([CUSTOM_CODE1])
318+
.expect("code should be valid"),
319+
)
318320
});
319321
static CUSTOM_LIBRARY2: LazyLock<Library> = LazyLock::new(|| {
320-
Assembler::default()
321-
.assemble_library([CUSTOM_CODE2])
322-
.expect("code should be valid")
322+
Arc::unwrap_or_clone(
323+
Assembler::default()
324+
.assemble_library([CUSTOM_CODE2])
325+
.expect("code should be valid"),
326+
)
323327
});
324328

325329
static CUSTOM_COMPONENT1_SLOT_NAME: LazyLock<StorageSlotName> = LazyLock::new(|| {

crates/miden-protocol/src/account/code/mod.rs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -407,6 +407,8 @@ pub(crate) fn procedures_as_elements(procedures: &[AccountProcedureRoot]) -> Vec
407407
#[cfg(test)]
408408
mod tests {
409409

410+
use alloc::sync::Arc;
411+
410412
use assert_matches::assert_matches;
411413
use miden_assembly::Assembler;
412414

@@ -446,7 +448,8 @@ mod tests {
446448

447449
#[test]
448450
fn test_account_code_no_auth_component() {
449-
let library = Assembler::default().assemble_library([CODE]).unwrap();
451+
let library =
452+
Arc::unwrap_or_clone(Assembler::default().assemble_library([CODE]).unwrap());
450453
let metadata = AccountComponentMetadata::new("test::no_auth", AccountType::all());
451454
let component = AccountComponent::new(library, vec![], metadata).unwrap();
452455

@@ -484,7 +487,9 @@ mod tests {
484487
end
485488
";
486489

487-
let library = Assembler::default().assemble_library([code_with_multiple_auth]).unwrap();
490+
let library = Arc::unwrap_or_clone(
491+
Assembler::default().assemble_library([code_with_multiple_auth]).unwrap(),
492+
);
488493
let metadata = AccountComponentMetadata::new("test::multiple_auth", AccountType::all());
489494
let component = AccountComponent::new(library, vec![], metadata).unwrap();
490495

0 commit comments

Comments
 (0)