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 #1002

Draft
wants to merge 1 commit into
base: next
Choose a base branch
from

Conversation

Fumuran
Copy link
Contributor

@Fumuran Fumuran commented Dec 3, 2024

This PR moves the duplicate masm procedures to the new utils library.

Closes: #836

@Fumuran Fumuran force-pushed the andrew-remove-duplicate-procedures branch 2 times, most recently from 1c545f6 to 787743f Compare December 5, 2024 15:57
@Fumuran Fumuran force-pushed the andrew-remove-duplicate-procedures branch from 787743f to b6267d9 Compare December 5, 2024 16:05
@Fumuran
Copy link
Contributor Author

Fumuran commented Dec 5, 2024

This solution implements the whole new utils library. Not sure that this is the best approach, it may be that creation of the just one utils.masm file will be better.

@Fumuran Fumuran requested a review from bobbinth December 5, 2024 16:08
Copy link
Contributor

@bobbinth bobbinth left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you! Looks good. I left a few comment inline, but basically, there are two properties I'd like to retain:

  1. Ideally, we won't need to add a new library to the list of libraries that we need to load into the executor and transaction kernel assembler.
  2. Also, we should try to avoid changing the public interface of the modules in miden-lib (would should be able to just re-export procedures from the modules in which they were previously defined).

We could have achieved both of these if we had vendored library support in the assembler, but without it, I think we may need to rely on adding the MASM file with common utilities to tx kernel and miden lib libraries manually at build time.

#! Output: [max_inputs_per_note]
#!
#! - max_inputs_per_note is the max inputs per note.
export.get_max_inputs_per_note
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a reason not to re-export the same procedure from here? For example, like:

export.utils::note::get_max_inputs_per_note

#! Outputs: [fungible_asset_max_amount]
#!
#! fungible_asset_max_amount is the maximum amount of a fungible asset.
export.get_fungible_asset_max_amount
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same question as above: is there a reason we can't just re-export this procedure from utils?

Comment on lines -469 to -472
proc.type
u32split swap drop push.ACCOUNT_TYPE_U32MASK u32and
# => [acct_type]
end
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same comment as above.

Comment on lines +16 to +17
#[derive(Clone)]
pub struct UtilsLib(Library);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's add a brief doc-comment explaining what this library contain.

Comment on lines +52 to +54
// load utils lib MAST forest
let utils_lib_forest = UtilsLib::default().mast_forest().clone();
store.insert(utils_lib_forest);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure I like that we now need to care about another library. Ideally, we'd just vendor the utils library into the miden library at compile time, but unfortunately, Miden assembler does not yet support vendoring. So, maybe trying the approach with a single MASM file is worth it.

cc @plafer, @bitwalker for another use case for vendored library.

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

Successfully merging this pull request may close these issues.

2 participants