Skip to content

Commit

Permalink
fix: on Library deserialization, use unchecked constructor for proced…
Browse files Browse the repository at this point in the history
…ure names (#1554)

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 0xPolygonMiden/compiler#347
when parsing the Miden package file of the basic wallet account code.
  • Loading branch information
greenhat authored Nov 4, 2024
1 parent 60a5f37 commit e3fa9ec
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
- [BREAKING] `DYNCALL` operation fixed, and now expects a memory address pointing to the procedure hash (#1535).
- Permit child `MastNodeId`s to exceed the `MastNodeId`s of their parents (#1542).
- Make `miden-prover::prove()` method conditionally asynchronous (#1563).
- Don't validate export names on `Library` deserialization (#1554)

#### Fixes

Expand Down
10 changes: 6 additions & 4 deletions assembly/src/library/mod.rs
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
use alloc::{
collections::{BTreeMap, BTreeSet},
string::{String, ToString},
string::String,
sync::Arc,
vec::Vec,
};

use vm_core::{
crypto::hash::RpoDigest,
debuginfo::Span,
mast::{MastForest, MastNodeId},
utils::{ByteReader, ByteWriter, Deserializable, DeserializationError, Serializable},
Kernel,
};

use crate::ast::{ProcedureName, QualifiedProcedureName};
use crate::ast::{Ident, ProcedureName, QualifiedProcedureName};

mod error;
mod module;
Expand Down Expand Up @@ -180,8 +181,9 @@ impl Deserializable for Library {
for _ in 0..num_exports {
let proc_module = source.read()?;
let proc_name: String = source.read()?;
let proc_name = ProcedureName::new(proc_name)
.map_err(|err| DeserializationError::InvalidValue(err.to_string()))?;
let proc_name = ProcedureName::new_unchecked(Ident::new_unchecked(Span::unknown(
Arc::from(proc_name),
)));
let proc_name = QualifiedProcedureName::new(proc_module, proc_name);
let proc_node_id = MastNodeId::from_u32_safe(source.read_u32()?, &mast_forest)?;

Expand Down

0 comments on commit e3fa9ec

Please sign in to comment.