-
Notifications
You must be signed in to change notification settings - Fork 168
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Enable compiling modules without library paths #1079
Conversation
I think I've realized why we can't use |
Is it generally correct situation when we have two modules without Library Path which contain functions with the same names? How user is supposed to use and even distinguish these functions? |
We can call them using procedure MAST roots (see here). This is actually how they will be called in the context of the rollup.
I don't think that's needed. As long as two procedures have different MAST roots, we can call them using |
Ok, so we won't have problems with their calls: it will be handled by their unique hashes. Now we will have error in the circular module dependency check since we have But I don't understand why we will have ID collisions: if we have module without Library path, the ID of the local procedures will be |
Maybe it'll work as you described - let me look into this in more detail later today. For now, could we add a test which complies two different |
b4a99e4
to
9da2d4b
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good! Thank you! I left a few minor comments inline.
Overall, I think this approach could work, but I would like to see how the approach with removing id
from NamedProcedure
would look like. I have a feeling that it might be cleaner but I might be wrong. Could you try to implement it in a separate commit?
@Overcastan - could you also see if it would make sense to adopt some tests mentioned in 0xPolygonMiden/miden-base#235 (comment)? I wonder if we still have this bug somewhere. |
I tried to reproduce the bug with cache collision, but I didn't manage to do it - everything worked as it should. I can look at this problem in more detail, but it seems to me that in this case it is better to create a separate issue. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good! Thank you! I left a couple of small comments inline. Once these are addressed, we can merge.
I do prefer this version as I think it is a bit cleaner - but to be honest, they are not that different. So, if you strongly prefer the previous version, we can revert.
#[derive(Clone, Debug)] | ||
pub struct NamedProcedure { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should also update the comment above.
assembly/src/assembler/context.rs
Outdated
let proc_context = self.proc_stack.pop().expect("no procedures"); | ||
|
||
// build an ID for the procedure as follows: | ||
// - for exported procedures: hash("module_path::proc_name") | ||
// - for internal procedures: hash("module_path::proc_index") | ||
let proc_id = if proc_context.is_export { | ||
ProcedureId::from_name(&proc_context.name, &self.path) | ||
} else { | ||
let proc_idx = self.compiled_procs.len() as u16; | ||
ProcedureId::from_index(proc_idx, &self.path) | ||
}; | ||
|
||
let proc = proc_context.into_procedure(proc_id, code); | ||
let proc = proc_context.into_procedure(code); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
very minor nit: I'd probably remove the blank line between these two lines.
b24ec84
to
b5aea22
Compare
I don't have a strong preference — at first I thought that moving out the |
This PR makes it possible to compile
Module
with noLibraryPath
provided. As a result of thisNamedProcedure
now can be created withoutid
.Tasks: