Skip to content

feat: double-word Array abstraction#2299

Merged
mmagician merged 24 commits intonextfrom
mmagician-double-word-array
Feb 2, 2026
Merged

feat: double-word Array abstraction#2299
mmagician merged 24 commits intonextfrom
mmagician-double-word-array

Conversation

@mmagician
Copy link
Collaborator

Similar to #2203, but lets the caller get/set double-words in one go with a convenient interface.
Internally, the words are stored under keys [index, 0, 0, 0] and [index, 1, 0, 0] in the storage map.

In the light of having a double-word array, should we also rename the array to single_word_array? (I would probably leave it as-is, I think simple array is descriptive enough)

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR introduces a double-word array abstraction for Miden, enabling storage and retrieval of two words per index through a convenient interface. The implementation extends the existing single-word array pattern by storing words under keys [index, 0, 0, 0] and [index, 1, 0, 0] in the storage map.

Changes:

  • Added double_word_array.masm implementing get/set operations for double-word array storage
  • Added comprehensive test coverage in test_array.rs to verify double-word array functionality

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
crates/miden-standards/asm/standards/data_structures/double_word_array.masm New MASM module implementing double-word array abstraction with get and set procedures
crates/miden-testing/src/kernel_tests/tx/test_array.rs Added test for double-word array get/set operations with initial and updated values

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Base automatically changed from mmagician-array-via-map to next January 26, 2026 20:39
Copy link
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!

Left some small comments. I think the important part is the padding/call documentation. Also, I did not re-review array.masm even though it appears as new here, not sure why.

Comment on lines 126 to 128
exec.active_account::get_map_item
swapw
# => [VALUE_0, VALUE_1, pad(16)]
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: Not really worth changing, but that swapw could probably be avoided if we loaded VALUE_1 first, and then VALUE_0.

Comment on lines 32 to 33
#! Inputs: [slot_id_prefix, slot_id_suffix, index, VALUE_0, VALUE_1, pad(5)]
#! Outputs: [OLD_VALUE_0, OLD_VALUE_1, pad(8)]
Copy link
Contributor

Choose a reason for hiding this comment

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

These procedures deal with padding and have Invocation: Call, but in the tests in test_array, they are exec-ed. And the array and double-array should be used as libraries rather than account components, right? So, iiuc, I think we should remove the pad comments here and change the doc comment to Invocation: exec. Applies here and in array.masm.

Copy link
Collaborator Author

@mmagician mmagician Feb 1, 2026

Choose a reason for hiding this comment

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

good catch. I refactored both array.masm and double_array.masm to assume exec invocation. I think this was a leftover from how these data structures were meant to be used as components.

feat: make procedures exec; fix stack accordingly

Copy link
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 to me!

Copy link
Contributor

Copilot AI commented Feb 2, 2026

@mmagician I've opened a new pull request, #2385, to work on those changes. Once the pull request is ready, I'll request review from you.

Copilot AI and others added 2 commits February 2, 2026 11:14
* Initial plan

* fix: move double-word array changelog entry to 0.14

Co-authored-by: mmagician <8402446+mmagician@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: mmagician <8402446+mmagician@users.noreply.github.com>
@mmagician mmagician merged commit 5eda196 into next Feb 2, 2026
17 checks passed
@mmagician mmagician deleted the mmagician-double-word-array branch February 2, 2026 13:01
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.

4 participants