Skip to content
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

Allow querying exported procedures MAST roots from compiled modules #1291

Open
hackaugusto opened this issue Mar 25, 2024 · 6 comments
Open
Labels
enhancement New feature or request

Comments

@hackaugusto
Copy link
Contributor

Currently there is no API to request the MAST root of a given procedure. This results in a lot of hacks to get the MAST root in the miden-base repo for testing. Which is error prone, time consuming, and usually results in a worse development workflow.

We should be able to query the MAST root of any exported procedure via a public API to make testing easier.

@hackaugusto hackaugusto added the enhancement New feature or request label Mar 25, 2024
@bobbinth
Copy link
Contributor

Agreed! I think this would be a part of the spec discussed in 0xPolygonMiden/compiler#129.

@hackaugusto
Copy link
Contributor Author

Agreed! I think this would be a part of the spec discussed in 0xPolygonMiden/compiler#129.

Why should this be blocked by the module spec? a simple get_proc_by_name API to a compiled Module should be enough here.

@bitwalker
Copy link
Contributor

Why should this be blocked by the module spec? a simple get_proc_by_name API to a compiled Module should be enough here.

The issue here is twofold: 1.) We are moving to a model where MAST is our primary artifact, not MASM, so any metadata not provided as part of/with the MAST cannot be assumed to be available; 2.) Currently, MAST has no such metadata associated with it. As it stands, the only reason why that information can be retrieved at all right now, is because we are assembling MASM to MAST and executing it all at once, so the links between the original MASM and the MAST are still available. That won't be the case for much longer, so we need to account for that.

I've brought this up in #1277 as well, but I think there are two ways we should go about this:

1.) Enhance MAST a bit with some additional metadata about a given MAST root. See my comment here for more detail. This doesn't have to be part of the MAST node itself, but would need to be associated with it in some way.
2.) Provide this metadata as part of the package format, i.e. the package provides a map of MAST roots to procedure metadata.

Then, when loading MAST into memory for execution, we also have this metadata available, which can be introspected as needed.

We need this kind of functionality for more than just the specific use case described by this issue, so it's certainly an important issue to solve.

@hackaugusto
Copy link
Contributor Author

hackaugusto commented Mar 25, 2024

@bitwalker thanks for the input. I'm not sure if you're agreeing or disagreeing with me though, so just to clarify: I just want to remove a pain point on developing miden-base, which is the need to manually maintain a list of mast roots, that come from test MASM code, compiled on the fly by the tests. I was trying to make the solution to this simple, and I think this can be handled as an orthogonal problem to the packaging done by the compiler, which would unblock this for me much sooner.

@bitwalker
Copy link
Contributor

I'm 100% agreeing with you that this is needed, just that implementing an API for this isn't quite as straightforward (yet).

However #1277 does implement some infrastructure to help with this issue specifically in regards to testing, though your specific needs may vary. See the definition of one such helper here and an example of how it is used here. You could build a similar set of helpers in miden-base on top of the same primitives I believe.

@hackaugusto
Copy link
Contributor Author

Oh, the linked utility seems great, and it will likely be sufficient for the issue I had. I think we can close this issue once #1277 is merged.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

4 participants
@hackaugusto @bitwalker @bobbinth and others