Skip to content

feat(kernel): expose tx script root via public kernel procedure#2816

Open
partylikeits1983 wants to merge 6 commits intonextfrom
ajl-kernel-tx-script-root
Open

feat(kernel): expose tx script root via public kernel procedure#2816
partylikeits1983 wants to merge 6 commits intonextfrom
ajl-kernel-tx-script-root

Conversation

@partylikeits1983
Copy link
Copy Markdown
Contributor

@partylikeits1983 partylikeits1983 commented Apr 22, 2026

Summary

Changes

  • lib/memory.masm: new get_tx_script_root word getter (mirrors get_tx_script_args).
  • lib/tx.masm: re-export as tx::get_script_root.
  • api.masm: new tx_get_script_root public kernel procedure.
  • kernel_proc_offsets.masm: new TX_GET_SCRIPT_ROOT_OFFSET=51.
  • protocol/tx.masm: new user-facing tx::get_script_root wrapper.
  • Tests in miden-testing: script set returns expected root, no script returns zero word.

Closes #2813. Part of the #2797 fix chain (this unblocks #2814, which unblocks #2815).

Adds tx_get_script_root to the transaction kernel API so that MASM auth
code can read the executed tx script root (zero word if no script ran).
Required by the upcoming NetworkAccount auth component (#2814).

- lib/memory.masm: new get_tx_script_root word getter
- lib/tx.masm: re-export as tx::get_script_root
- api.masm: new tx_get_script_root public kernel procedure
- kernel_proc_offsets.masm: new TX_GET_SCRIPT_ROOT_OFFSET=51
- protocol/tx.masm: new user-facing tx::get_script_root wrapper
- tests: returns expected root when script is set, zero word otherwise

Part of #2813, related to #2797.
@partylikeits1983 partylikeits1983 marked this pull request as draft April 22, 2026 21:03
@partylikeits1983 partylikeits1983 self-assigned this Apr 22, 2026
@partylikeits1983 partylikeits1983 added the kernels Related to transaction, batch, or block kernels label Apr 22, 2026
@partylikeits1983 partylikeits1983 added the pr-from-maintainers PRs that come from internal contributors or integration partners. They should be given priority label Apr 23, 2026
@partylikeits1983 partylikeits1983 marked this pull request as ready for review April 23, 2026 18:25
Copy link
Copy Markdown
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.

Looks good! Thank you! I reviewed primarily non-test code and left a coupe of small comments inline.

Comment thread crates/miden-protocol/asm/kernels/transaction/lib/tx.masm Outdated
Comment thread crates/miden-protocol/asm/protocol/kernel_proc_offsets.masm Outdated
Comment thread crates/miden-protocol/asm/protocol/tx.masm Outdated
…` in identifiers

Keep `tx_script` in the names to match the well-defined concept, per
review on #2816. Renames:
- kernel lib `tx::get_script_root` -> `tx::get_tx_script_root`
- kernel api proc `tx_get_script_root` -> `tx_get_tx_script_root`
- offset const `TX_GET_SCRIPT_ROOT_OFFSET` -> `TX_GET_TX_SCRIPT_ROOT_OFFSET`
- user-facing wrapper `tx::get_script_root` -> `tx::get_tx_script_root`

Updates call sites and the CHANGELOG entry accordingly.
Copy link
Copy Markdown
Contributor

@PhilippGackstatter PhilippGackstatter left a comment

Choose a reason for hiding this comment

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

Looks good!

Comment on lines +324 to +331
#! Returns the transaction script root, or the zero word if no transaction script was executed.
#!
#! Inputs: []
#! Outputs: [TX_SCRIPT_ROOT]
#!
#! Where:
#! - TX_SCRIPT_ROOT is the root of the transaction script executed in this transaction, or the zero
#! word if no transaction script was executed.
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.

Nit: We usually call it "empty word" rather than "zero word".

Ok(())
}

/// Tests that `tx::get_tx_script_root` returns the zero word when no transaction script is
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.

Suggested change
/// Tests that `tx::get_tx_script_root` returns the zero word when no transaction script is
/// Tests that `tx::get_tx_script_root` returns the empty word when no transaction script is

Comment thread CHANGELOG.md
- [BREAKING] Added cycle counts to notes returned by `NoteConsumptionInfo` and removed public fields from related types ([#2772](https://github.com/0xMiden/miden-base/issues/2772)).
- [BREAKING] Removed unused `payback_attachment` from `SwapNoteStorage` and `attachment` from `MintNoteStorage` ([#2789](https://github.com/0xMiden/protocol/pull/2789)).
- Automatically enable `concurrent` feature in `miden-tx` for `std` context ([#2791](https://github.com/0xMiden/protocol/pull/2791)).
- Added `tx::get_tx_script_root` kernel procedure returning the root of the executed transaction script (zero word if no script was executed) ([#2816](https://github.com/0xMiden/protocol/pull/2816)).
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.

Suggested change
- Added `tx::get_tx_script_root` kernel procedure returning the root of the executed transaction script (zero word if no script was executed) ([#2816](https://github.com/0xMiden/protocol/pull/2816)).
- 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)).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kernels Related to transaction, batch, or block kernels pr-from-maintainers PRs that come from internal contributors or integration partners. They should be given priority

Projects

None yet

Development

Successfully merging this pull request may close these issues.

kernel: add public procedure to expose tx script root

3 participants