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

Remove duplicate procedures from miden-lib #836

Open
bobbinth opened this issue Aug 23, 2024 · 2 comments
Open

Remove duplicate procedures from miden-lib #836

bobbinth opened this issue Aug 23, 2024 · 2 comments
Assignees
Labels
kernels Related to transaction, batch, or block kernels
Milestone

Comments

@bobbinth
Copy link
Contributor

As a part of migration to the MAST-base program format in #826, we ended up with duplicates of several procedures (here, here, and here). This is because these procedures are needed both by the kernel and by miden-lib, but miden-lib cannot directly reference procedures defined directly in the kernel (it can do so only via syscalls).

We need to find a way to avoid this duplication.

@bobbinth bobbinth added the kernels Related to transaction, batch, or block kernels label Aug 23, 2024
@bobbinth bobbinth added this to the v0.6 milestone Aug 27, 2024
@bobbinth bobbinth modified the milestones: v0.6, v0.7 Oct 28, 2024
@polydez polydez moved this to Todo in Builder's testnet Oct 30, 2024
@Fumuran
Copy link
Contributor

Fumuran commented Dec 2, 2024

To make it clear, now we have this structure:

  • the miden library, which can call kernel procedures only with syscall, and the list of the procedures is severely limited (we don't want to add some utility procedures to the kernel)
  • the api.masm which contains the kernel procedures and can internally call the kernel library
  • the kernel library, containing the procedures which can be used only inside of the kernel (in kernel modules, in api.masm or in main.masm)

The problem is that miden could call the kernel procedures only through the api.masm or, in other words, only by calling kernel procedures, so we can't call a procedure placed in some kernel lib module. On the other hand the kernel procedures could not reach any procedure outside the kernel library, since a kernel is compiled slightly different. So that's why we needed to duplicate those procedures.

Without any modification of the miden-vm I can see the only solution: we could create a new utilities library, which would be placed next to the miden library, but will be imported by default to the both kernel and miden libs on the building stage. This library will contain all the duplicated procedures and should work the same as stdlib, which can be used both in kernel and in miden. This should be possible, since all the duplicated procedures only need a set of constants to work, they don't need any imports.

@bobbinth
Copy link
Contributor Author

bobbinth commented Dec 2, 2024

This should work but there could also be a slightly simpler approach (actually not sure if simpler, maybe just different):

We could move these procedures into a separate module (e.g., utils.masm or shared.masm) and then include this module into both kernel library and miden library at build time.

Though, maybe creating a separate utilities library may be a better idea.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kernels Related to transaction, batch, or block kernels
Projects
Status: Todo
Development

No branches or pull requests

2 participants