diff --git a/.github/workflows/workspace-publish.yml b/.github/workflows/workspace-publish.yml index 7903e80927..20550f8629 100644 --- a/.github/workflows/workspace-publish.yml +++ b/.github/workflows/workspace-publish.yml @@ -34,3 +34,46 @@ jobs: release-branch: ${{ github.event.release.target_commitish }} env: CARGO_REGISTRY_TOKEN: ${{ steps.auth.outputs.token }} + + # Upload the pre-compiled artifacts (miden-protocol.masp) on the + # GitHub release page. + # Used by midenup to speed up installs. + upload-artifacts: + name: upload pre-built miden-protocol library artifacts + if: ${{ github.repository_owner == '0xMiden' }} + permissions: + contents: write + id-token: write + attestations: write + steps: + - name: Checkout repository + uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 + with: + fetch-depth: 0 + ref: ${{ github.event.release.tag_name }} + persist-credentials: false + - uses: ./.github/actions/cleanup-runner + - name: Install Rust + run: | + rustup update --no-self-update + rustc --version + - name: Build packages + run: | + make packages + - name: Prepare artifacts + run: | + mv target/packages/miden-protocol.masp miden-protocol.masp + mv target/packages/standards.masp standards.masp + - name: Attest packages + uses: actions/attest-build-provenance@96278af6caaf10aea03fd8d33a09a777ca52d62f # v3.2.0 + with: + subject-path: | + protocol.masp + standards.masp + - name: Upload packages + env: + RELEASE_TAG: ${{ github.event.release.tag_name }} + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + set -e + gh release upload ${RELEASE_TAG} protocol.masp standards.masp diff --git a/CHANGELOG.md b/CHANGELOG.md index 84af7b48dd..7786717315 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -28,6 +28,7 @@ - Added `tx::get_tx_script_root` kernel procedure returning the root of the executed transaction script (empty word if no script was executed) ([#2816](https://github.com/0xMiden/protocol/pull/2816)). - Added `TransactionScript::from_package()` method to create `TransactionScript` from `miden-mast-package::Package` ([#2779](https://github.com/0xMiden/protocol/pull/2779)). - Re-exported `MIN_STACK_DEPTH` from `miden-processor` ([#2856](https://github.com/0xMiden/protocol/pull/2856)). +- Added `into_package()` method for `ProtocolLib` & `StandardsLib` ([#2859](https://github.com/0xMiden/protocol/pull/2859)). ### Fixes @@ -35,6 +36,9 @@ - Fixed `output_note::add_asset` and `output_note::set_attachment` to no longer accept invalid note indices ([#2824](https://github.com/0xMiden/protocol/pull/2824)). - Fixed auth components to use initial storage state for authentication ([#2677](https://github.com/0xMiden/protocol/issues/2677)). +### Enhancements +- Added binary artifact compilation to the CI to aid `midenup`'s installation speed ([#2859](https://github.com/0xMiden/protocol/pull/2859)). + ## 0.14.5 (2026-04-23) - Fixed note script compilation: all note scripts are now compiled as libraries ([#2822](https://github.com/0xMiden/protocol/pull/2822)). diff --git a/Cargo.lock b/Cargo.lock index 86f4fada84..09cc50f741 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1925,6 +1925,7 @@ dependencies = [ "fs-err", "miden-assembly", "miden-core-lib", + "miden-mast-package", "miden-processor", "miden-protocol", "miden-standards", diff --git a/Makefile b/Makefile index f2ecc7ac48..6e170265a6 100644 --- a/Makefile +++ b/Makefile @@ -146,6 +146,10 @@ build-no-std: ## Build without the standard library build-no-std-testing: ## Build without the standard library. Includes the `testing` feature $(BUILD_GENERATED_FILES_IN_SRC) cargo build --no-default-features --target wasm32-unknown-unknown --workspace --exclude bench-transaction --features testing +.PHONY: packages +packages: ## Builds .masp packages and store them in target/packages + cargo +nightly -Zscript scripts/generate-package.rs + # --- test vectors -------------------------------------------------------------------------------- .PHONY: generate-solidity-test-vectors diff --git a/crates/miden-protocol/src/protocol.rs b/crates/miden-protocol/src/protocol.rs index 8ba96c9392..fa912d570d 100644 --- a/crates/miden-protocol/src/protocol.rs +++ b/crates/miden-protocol/src/protocol.rs @@ -1,5 +1,8 @@ +use alloc::boxed::Box; use alloc::sync::Arc; +use miden_mast_package::{Package, TargetType, Version}; + use crate::assembly::Library; use crate::assembly::mast::MastForest; use crate::utils::serde::Deserializable; @@ -10,6 +13,8 @@ use crate::utils::sync::LazyLock; const PROTOCOL_LIB_BYTES: &[u8] = include_bytes!(concat!(env!("OUT_DIR"), "/assets/protocol.masl")); +const PROTOCOL_PACKAGE_NAME: &str = "protocol"; + // PROTOCOL LIBRARY // ================================================================================================ @@ -21,6 +26,23 @@ impl ProtocolLib { pub fn mast_forest(&self) -> &Arc { self.0.mast_forest() } + + /// Wraps this library into a [`Package`] named `PROTOCOL_PACKAGE_NAME`, + /// versioned with the `miden-protocol` crate's version. + pub fn into_package(self) -> Box { + // The ProtocolLib's version is the same as the crate's as per the miden-protocol's + // Cargo.toml. + let version = Version::parse(env!("CARGO_PKG_VERSION")) + .expect("CARGO_PKG_VERSION must be valid semver"); + + Package::from_library( + PROTOCOL_PACKAGE_NAME.into(), + version, + TargetType::Library, + Arc::new(self.0), + [], + ) + } } impl AsRef for ProtocolLib { diff --git a/crates/miden-standards/Cargo.toml b/crates/miden-standards/Cargo.toml index 29e75e8cbc..17f0896be7 100644 --- a/crates/miden-standards/Cargo.toml +++ b/crates/miden-standards/Cargo.toml @@ -21,8 +21,9 @@ testing = ["dep:rand", "miden-assembly/testing", "miden-protocol/testing"] [dependencies] # Miden dependencies -miden-processor = { workspace = true } -miden-protocol = { workspace = true } +miden-mast-package = { workspace = true } +miden-processor = { workspace = true } +miden-protocol = { workspace = true } # External dependencies bon = { workspace = true } diff --git a/crates/miden-standards/src/standards_lib.rs b/crates/miden-standards/src/standards_lib.rs index effda29a16..7253082258 100644 --- a/crates/miden-standards/src/standards_lib.rs +++ b/crates/miden-standards/src/standards_lib.rs @@ -1,5 +1,7 @@ +use alloc::boxed::Box; use alloc::sync::Arc; +use miden_mast_package::{Package, TargetType, Version}; use miden_protocol::assembly::Library; use miden_protocol::assembly::mast::MastForest; use miden_protocol::utils::serde::Deserializable; @@ -11,6 +13,8 @@ use miden_protocol::utils::sync::LazyLock; const STANDARDS_LIB_BYTES: &[u8] = include_bytes!(concat!(env!("OUT_DIR"), "/assets/standards.masl")); +const STANDARDS_PACKAGE_NAME: &str = "standards"; + // MIDEN STANDARDS LIBRARY // ================================================================================================ @@ -22,6 +26,23 @@ impl StandardsLib { pub fn mast_forest(&self) -> &Arc { self.0.mast_forest() } + + /// Wraps this library into a [`Package`] named `STANDARDS_PACKAGE_NAME`, + /// versioned with the `miden-protocol` crate's version. + pub fn into_package(self) -> Box { + // The ProtocolLib's version is the same as the crate's as per the miden-standards's + // Cargo.toml. + let version = Version::parse(env!("CARGO_PKG_VERSION")) + .expect("CARGO_PKG_VERSION must be valid semver"); + + Package::from_library( + STANDARDS_PACKAGE_NAME.into(), + version, + TargetType::Library, + Arc::new(self.0), + [], + ) + } } impl AsRef for StandardsLib { diff --git a/scripts/generate-package.rs b/scripts/generate-package.rs new file mode 100644 index 0000000000..48cb8d74ef --- /dev/null +++ b/scripts/generate-package.rs @@ -0,0 +1,30 @@ +#!/usr/bin/env cargo + +--- +[dependencies] +miden-protocol = { path = "../crates/miden-protocol" } +miden-standards = { path = "../crates/miden-standards" } +semver = "1" +--- + +use std::env; + +use miden_protocol::ProtocolLib; +use miden_standards::StandardsLib; + +fn main() -> std::io::Result<()> { + // Must be run from the workspace root (CARGO_TARGET_DIR is not set for cargo scripts). + let workspace_root = env::current_dir().expect("could not read PWD"); + let packages_dir = workspace_root.join("target").join("packages"); + std::fs::create_dir_all(&packages_dir)?; + + let protocol_pkg = ProtocolLib::default().into_package(); + protocol_pkg.write_masp_file(&packages_dir)?; + println!("wrote {}.masp to {}", protocol_pkg.name, packages_dir.display()); + + let standards_pkg = StandardsLib::default().into_package(); + standards_pkg.write_masp_file(&packages_dir)?; + println!("wrote {}.masp to {}", standards_pkg.name, packages_dir.display()); + + Ok(()) +}