Skip to content

Conversation

@mmagician
Copy link
Contributor

We eventually want to have double-word arrays & double-word queues. Once we agreed on the structure and where the files live, it's going to be trivial to extend to double-word array. A queue will require an extra storage slot to hold the metadata, though.

Features:

  • add a simple wrapper over storage map, s.t. the map keys are [index, 0, 0, 0]
  • export procedures set(index: Felt, VALUE: Word) -> OLD_VALUE: Word & get(index: Felt) -> VALUE: Word
  • the account component can be built by specifying the underlying storage slot
  • tests that show how other account components have an easy interface for operating on the array

Usage:

use.my_array
use.my_second_array # can hold multiple independent arrays within an account

proc test_get
    push.0
    exec.my_array::get
end

@mmagician mmagician force-pushed the mmagician-array-via-map branch from 505aa25 to 5479b77 Compare December 19, 2025 15:35
@mmagician
Copy link
Contributor Author

@copilot add change log entry for this PR 2203

Copy link
Contributor

Copilot AI commented Dec 19, 2025

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

@mmagician mmagician force-pushed the mmagician-array-via-map branch from 8263624 to b5f4cdb Compare January 5, 2026 10:10
mmagician and others added 2 commits January 5, 2026 10:29
chore: simplify test

chore: be explicit about padding
* Initial plan

* chore: add changelog entry for PR 2203

Co-authored-by: mmagician <[email protected]>

---------

Co-authored-by: copilot-swe-agent[bot] <[email protected]>
Co-authored-by: mmagician <[email protected]>
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 single-word Array account component that provides a simple, reusable array data structure for Miden accounts. The implementation wraps a StorageMap where array indices are mapped to keys of the form [index, 0, 0, 0].

Key changes:

  • Added Array struct with methods for creating arrays with initial elements or from slices
  • Implemented MASM procedures (get and set) for array access with configurable storage slots
  • Added comprehensive unit tests and integration tests demonstrating the component's usage

Reviewed changes

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

Show a summary per file
File Description
crates/miden-standards/src/account/array.rs Core implementation of the Array component with constructors, MASM generation, and conversion to AccountComponent
crates/miden-standards/asm/account_components/array.masm MASM template defining get and set procedures for array operations
crates/miden-standards/src/account/mod.rs Adds array module to the account components public API
crates/miden-testing/src/kernel_tests/tx/test_array.rs Integration test verifying get/set operations work correctly in transaction context
crates/miden-testing/src/kernel_tests/tx/mod.rs Includes the new test module
CHANGELOG.md Documents the addition of the Array component

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

@mmagician mmagician marked this pull request as ready for review January 5, 2026 12:35
@mmagician mmagician requested a review from Copilot January 5, 2026 12:35
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

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


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

partylikeits1983
partylikeits1983 approved these changes Jan 5, 2026
@partylikeits1983
Copy link
Contributor

Looks great! This is a great feature!

When reviewing the implementation, it reminded me of this issue for KEY => vec![] issue I opened: #2085

Comment on lines +1 to +4
# The MASM code template for the Array Account Component.
#
# NOTE: This file is used as a template. The placeholder {{DATA_SLOT}} is substituted
# at construction time with the actual slot name provided by the user.
Copy link
Contributor

Choose a reason for hiding this comment

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

Question: why make this a component rather than just a utility? That is, we could provide the storage slot name as a parameter to get/set procedures and it would work similar to how storage slots/maps work.

Copy link
Contributor

Choose a reason for hiding this comment

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

I agree this would be preferable. One consequence of "templating" is that the Array account component as it is now would not be detectable in an AccountInterface because it doesn't have a stable MAST root. Not sure if it's important for this component, but whenever possible, I think we should avoid "templating".

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.

5 participants