Skip to content

Commit 3581727

Browse files
committed
fix: on Library deserialization, use unchecked constructor for procedure names
The checked constructor fits when parsing MASM code. The Miden package contains the export names crafted according to the Wasm CM naming scheme i.e. `namespace:package/interface@version#function`. Discovered in 0xMiden/compiler#347 when parsing the Miden package file of the basic wallet account code.
1 parent ce26595 commit 3581727

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
- [BREAKING] `DYNCALL` operation fixed, and now expects a memory address pointing to the procedure hash (#1535).
2727
- Permit child `MastNodeId`s to exceed the `MastNodeId`s of their parents (#1542).
2828
- Make `miden-prover::prove()` method conditionally asynchronous (#1563).
29+
- Don't validate export names on `Library` deserialization (#1554)
2930

3031
#### Fixes
3132

assembly/src/library/mod.rs

+6-4
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,19 @@
11
use alloc::{
22
collections::{BTreeMap, BTreeSet},
3-
string::{String, ToString},
3+
string::String,
44
sync::Arc,
55
vec::Vec,
66
};
77

88
use vm_core::{
99
crypto::hash::RpoDigest,
10+
debuginfo::Span,
1011
mast::{MastForest, MastNodeId},
1112
utils::{ByteReader, ByteWriter, Deserializable, DeserializationError, Serializable},
1213
Kernel,
1314
};
1415

15-
use crate::ast::{ProcedureName, QualifiedProcedureName};
16+
use crate::ast::{Ident, ProcedureName, QualifiedProcedureName};
1617

1718
mod error;
1819
mod module;
@@ -180,8 +181,9 @@ impl Deserializable for Library {
180181
for _ in 0..num_exports {
181182
let proc_module = source.read()?;
182183
let proc_name: String = source.read()?;
183-
let proc_name = ProcedureName::new(proc_name)
184-
.map_err(|err| DeserializationError::InvalidValue(err.to_string()))?;
184+
let proc_name = ProcedureName::new_unchecked(Ident::new_unchecked(Span::unknown(
185+
Arc::from(proc_name),
186+
)));
185187
let proc_name = QualifiedProcedureName::new(proc_module, proc_name);
186188
let proc_node_id = MastNodeId::from_u32_safe(source.read_u32()?, &mast_forest)?;
187189

0 commit comments

Comments
 (0)