Skip to content

feat: migrate transaction scripts to Library#3173

Merged
PhilippGackstatter merged 9 commits into
nextfrom
tomasarrachea-tx-script-attribute
Jul 3, 2026
Merged

feat: migrate transaction scripts to Library#3173
PhilippGackstatter merged 9 commits into
nextfrom
tomasarrachea-tx-script-attribute

Conversation

@TomasArrachea

@TomasArrachea TomasArrachea commented Jun 30, 2026

Copy link
Copy Markdown
Collaborator

Closes #3093

This PR migrates transaction scripts to the library form and adds a @transaction_script attribute to mark the entrypoint procedure.

@TomasArrachea TomasArrachea force-pushed the tomasarrachea-tx-script-attribute branch from a63c913 to af44cea Compare June 30, 2026 21:39
@TomasArrachea TomasArrachea marked this pull request as ready for review June 30, 2026 21:43

@bobbinth bobbinth left a comment

Copy link
Copy Markdown
Contributor

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 small comments inline.

I would probably merge this PR after #3107 and #3146 are merged.

Comment on lines +343 to 347
// TODO: we can remove this `Program` based constructor once the compiler integrates the
// `@transaction_script` attribute (https://github.com/0xMiden/compiler/issues/1190).
pub fn new(code: Program) -> Self {
Self::from_parts(code.mast_forest().clone(), code.entrypoint())
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Let's do this in a follow up right after this PR. And we should do the same for note scripts.

cc @greenhat for visibility.

Comment on lines +25 to +26
@transaction_script
pub proc main

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Not for this PR, but we should move this out into a package (similar to how we do with notes).

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Yes, this is part of #3111

Comment thread crates/miden-standards/src/tx_script/send_notes_script.rs Outdated

@PhilippGackstatter PhilippGackstatter left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Looks good!

Comment thread crates/miden-protocol/src/transaction/tx_args.rs
Comment thread crates/miden-standards/src/code_builder/mod.rs Outdated

@mmagician mmagician left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

LGTM modulo some refactors (but they could be done as a follow-up if we agree they are desirable)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

At this point NoteScript and TransactionScript share the majority of the struct's implementation code, with the only difference being TRANSACTION_SCRIPT_ATTRIBUTE vs. NOTE_SCRIPT_ATTRIBUTE. We might want to pull this functionality into something more re-usable.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

I think this would make sense. Created #3189 for it, so we avoid growing this PR.

Comment on lines +373 to +382
/// Returns a new [TransactionScript] instantiated from the provided library.
///
/// The library must contain exactly one procedure with the `@transaction_script` attribute,
/// which will be used as the entrypoint.
///
/// # Errors
/// Returns an error if:
/// - The library does not contain a procedure with the `@transaction_script` attribute.
/// - The library contains multiple procedures with the `@transaction_script` attribute.
pub fn from_library(library: &Library) -> Result<Self, TransactionScriptError> {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

To align a bit better with NoteScript, it would make sense to pull out the struct TransactionScript into its own file.

(see also my other comment about NoteScript and TransactionScript code de-dup, as the decision there would affect this refactor, too)

Comment thread crates/miden-standards/src/code_builder/mod.rs Outdated
@TomasArrachea

TomasArrachea commented Jul 2, 2026

Copy link
Copy Markdown
Collaborator Author

Addressed all the comments. Still, we should wait for #3146 to get merged and then rebase.

@TomasArrachea

Copy link
Copy Markdown
Collaborator Author

Addressed all the comments. Still, we should wait for #3146 to get merged and then rebase.

Done! Main change point on the merge was the code builder , where the CodeBuilderNoteScriptSource is generalized into CodeBuilderScriptSource. Still, this might change later for #3193.

@PhilippGackstatter PhilippGackstatter left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Looks good, thanks for the updates!

@PhilippGackstatter PhilippGackstatter added this pull request to the merge queue Jul 3, 2026
Merged via the queue into next with commit 141f668 Jul 3, 2026
20 checks passed
@PhilippGackstatter PhilippGackstatter deleted the tomasarrachea-tx-script-attribute branch July 3, 2026 15:05
Fumuran pushed a commit that referenced this pull request Jul 3, 2026
Resolves conflicts from the transaction-script-to-Library migration (#3173):
the three conflicted test scripts adopt the new `@transaction_script pub proc main`
form but keep our account-context routing (`call.mock_account::*` for the gated
account reads, `call.create_note` for note creation) since a transaction script is
still not an account-procedure context.

Full suite green: 1311 passed, 0 failed.
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.

Convert transaction scripts to libraries with a @transaction_script entrypoint attribute

4 participants