Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
- Added the canonical `ExpirationTransactionScript` to `miden-standards`, with a delta-independent script root that network accounts can allowlist ([#3051](https://github.com/0xMiden/protocol/pull/3051)).
- [BREAKING] Migrated the `miden-standards` library to a `miden-project.toml` project ([#3107](https://github.com/0xMiden/protocol/pull/3107)).
- [BREAKING] Migrated `miden-protocol` MASM assembly to a `miden-project.toml` project ([#3094](https://github.com/0xMiden/protocol/pull/3094)).
- Added `ExpirationTransactionScript` to standards package and assemble it at build-time ([#3111](https://github.com/0xMiden/protocol/pull/3111)).
- [BREAKING] Replaced `AccountInterface::build_send_notes_script` with a standalone `SendNotesTransactionScript` built against `AccountCodeInterface` ([#3055](https://github.com/0xMiden/protocol/pull/3055)).
- Added an `AccountCode::interface` helper that returns the public `AccountCodeInterface` ([#3080](https://github.com/0xMiden/protocol/pull/3080)).
- [BREAKING] Tightened `AccountStorage::get_map_item` to take a `StorageMapKey` instead of a raw `Word` ([#3080](https://github.com/0xMiden/protocol/pull/3080)).
Expand Down
1 change: 1 addition & 0 deletions crates/miden-standards/asm/standards/mod.masm
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@ pub mod metadata
pub mod note
pub mod note_tag
pub mod notes
pub mod tx_scripts
pub mod wallets
16 changes: 16 additions & 0 deletions crates/miden-standards/asm/standards/tx_scripts/expiration.masm
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
use miden::protocol::tx

#! Set the transaction's expiration delta.
#!
#! Inputs: [[delta, 0, 0, 0], pad(12)]
#! Outputs: [pad(16)]
#!
#! Panics if:
#! - delta is 0 or not a u32 in the range 1..=0xFFFF (ERR_TX_INVALID_EXPIRATION_DELTA).
#!
#! Invocation: call
@transaction_script
pub proc main
exec.tx::update_expiration_block_delta
# => [pad(16)]
end
1 change: 1 addition & 0 deletions crates/miden-standards/asm/standards/tx_scripts/mod.masm
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
pub mod expiration
7 changes: 4 additions & 3 deletions crates/miden-standards/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ const STANDARDS_ERRORS_ARRAY_NAME: &str = "STANDARDS_ERRORS";
// ================================================================================================

/// Read and parse the contents from `./asm`.
/// - Compiles the contents of asm/standards directory into a package. Note scripts are included in
/// this library.
/// - Compiles the contents of asm/standards directory into a package. Note scripts and transaction
/// scripts are included in this library.
/// - Compiles the contents of asm/components directory into individual packages.
fn main() -> Result<()> {
// re-build when the MASM code changes
Expand All @@ -56,7 +56,8 @@ fn main() -> Result<()> {
let source_manager: Arc<dyn SourceManager> = Arc::new(DefaultSourceManager::default());
let assembler = Assembler::new(source_manager.clone()).with_warnings_as_errors(true);

// compile standards library (includes note scripts) and seed it into the registry
// compile standards library (includes note scripts and transaction scripts) and seed it into
// the registry
compile_standards_lib(&source_dir, &target_dir, assembler.clone(), &mut registry)?;

// compile account components
Expand Down
35 changes: 12 additions & 23 deletions crates/miden-standards/src/tx_script/expiration_script.rs
Original file line number Diff line number Diff line change
@@ -1,38 +1,27 @@
use core::num::NonZeroU16;

use miden_protocol::assembly::Path;
use miden_protocol::transaction::{TransactionScript, TransactionScriptRoot};
use miden_protocol::utils::sync::LazyLock;
use miden_protocol::{Felt, Word};

use crate::code_builder::CodeBuilder;
use crate::StandardsLib;

// EXPIRATION TRANSACTION SCRIPT
// CONSTANTS
// ================================================================================================

/// Transaction script that sets the expiration delta.
const EXPIRATION_TX_SCRIPT_SOURCE: &str = "\
use miden::protocol::tx
/// Path to the expiration transaction script procedure in the standards library, assembled from
/// `asm/standards/tx_scripts/expiration.masm`.
const EXPIRATION_TX_SCRIPT_PATH: &str = "::miden::standards::tx_scripts::expiration::main";

#! Set the transaction's expiration delta.
#!
#! Inputs: [[delta, 0, 0, 0], pad(12)]
#! Outputs: [pad(16)]
#!
#! Panics if:
#! - delta is 0 or not a u32 in the range 1..=0xFFFF (ERR_TX_INVALID_EXPIRATION_DELTA).
#!
#! Invocation: call
@transaction_script
pub proc main
exec.tx::update_expiration_block_delta
# => [pad(16)]
end
";
// EXPIRATION TRANSACTION SCRIPT
// ================================================================================================

static EXPIRATION_TX_SCRIPT: LazyLock<TransactionScript> = LazyLock::new(|| {
CodeBuilder::default()
.compile_tx_script(EXPIRATION_TX_SCRIPT_SOURCE)
.expect("canonical expiration tx script should compile")
let standards_lib = StandardsLib::default();
let path = Path::new(EXPIRATION_TX_SCRIPT_PATH);
TransactionScript::from_library_reference(standards_lib.as_ref(), path)
.expect("standards library should contain the expiration tx script procedure")
});

/// The canonical transaction script that sets the transaction's expiration delta to the value
Expand Down
Loading