-
Notifications
You must be signed in to change notification settings - Fork 125
feat: add Package support in TransactionScript
#2779
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
base: next
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,11 +2,14 @@ use alloc::collections::BTreeMap; | |
| use alloc::sync::Arc; | ||
| use alloc::vec::Vec; | ||
|
|
||
| use miden_assembly::Report; | ||
| use miden_core::mast::MastNodeExt; | ||
| use miden_crypto::merkle::InnerNodeInfo; | ||
| use miden_mast_package::{Package, TargetType}; | ||
|
|
||
| use super::{Felt, Hasher, Word}; | ||
| use crate::account::auth::{PublicKeyCommitment, Signature}; | ||
| use crate::errors::TransactionScriptError; | ||
| use crate::note::{NoteId, NoteRecipient}; | ||
| use crate::utils::serde::{ | ||
| ByteReader, | ||
|
|
@@ -308,6 +311,29 @@ impl TransactionScript { | |
| Self { mast, entrypoint } | ||
| } | ||
|
|
||
| /// Creates a [TransactionScript] from a [`Package`]. | ||
| /// | ||
| /// The package must be an executable (i.e., its target type must be | ||
| /// [`TargetType::TransactionScript`](miden_mast_package::TargetType::TransactionScript)). | ||
| /// | ||
| /// # Errors | ||
| /// Returns an error if the package cannot be converted to an executable program. | ||
| pub fn from_package(package: &Package) -> Result<Self, TransactionScriptError> { | ||
| let package_kind = package.kind; | ||
| if !matches!(package_kind, TargetType::TransactionScript) { | ||
| let err_report = Report::msg(format!( | ||
| "package's kind is {}, expected TransactionScript", | ||
| package_kind | ||
| )); | ||
| return Err(TransactionScriptError::PackageNotTransactionScript(err_report)); | ||
| }; | ||
|
|
||
| let program = | ||
| package.try_into_program().map_err(TransactionScriptError::PackageNotProgram)?; | ||
|
Comment on lines
+323
to
+332
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I believe this will currently fail because This brings up a question of how can we identify the program entrypoint for
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
For context, I originally went with If I'm not mistaken, this behavior changed inside the compiler. Until version However, after compiling (using the latest changes) the I'm not quite sure where this discrepancy stems from.
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
We still compile transaction scripts as an executable. Only the note script and authentication component are compiled as a library with exports marked with
I agree. The transaction script is the only rollup target that is not compiled as a library. It makes sense to compile it as a library and mark an entrypoint with an attribute. |
||
|
|
||
| Ok(TransactionScript::new(program)) | ||
| } | ||
|
|
||
| // PUBLIC ACCESSORS | ||
| // -------------------------------------------------------------------------------------------- | ||
|
|
||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.