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
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
### Features

- [BREAKING] Refactor storage slots to be accessed by names instead of indices ([#1987](https://github.com/0xMiden/miden-base/pull/1987)).
- [BREAKING] Refactor storage slots to be accessed by names instead of indices ([#1987](https://github.com/0xMiden/miden-base/pull/1987), [#2025](https://github.com/0xMiden/miden-base/pull/2025), [#2149](https://github.com/0xMiden/miden-base/pull/2149)).
- [BREAKING] Refactor storage slots to be accessed by names instead of indices ([#1987](https://github.com/0xMiden/miden-base/pull/1987), [#2025](https://github.com/0xMiden/miden-base/pull/2025), [#2149](https://github.com/0xMiden/miden-base/pull/2149), [#2150](https://github.com/0xMiden/miden-base/pull/2150)).

## 0.12.2 (unreleased)
- Add proc-macro `WordWrapper` to ease implementation of `Word`-wrapping types ([#2071](https://github.com/0xMiden/miden-base/pull/2108)).
Expand Down
4 changes: 2 additions & 2 deletions crates/miden-lib/src/account/auth/ecdsa_k256_keccak.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use miden_objects::account::auth::PublicKeyCommitment;
use miden_objects::account::{AccountComponent, NamedStorageSlot, StorageSlotName};
use miden_objects::account::{AccountComponent, StorageSlot, StorageSlotName};
use miden_objects::utils::sync::LazyLock;

use crate::account::components::ecdsa_k256_keccak_library;
Expand Down Expand Up @@ -42,7 +42,7 @@ impl From<AuthEcdsaK256Keccak> for AccountComponent {
fn from(ecdsa: AuthEcdsaK256Keccak) -> Self {
AccountComponent::new(
ecdsa_k256_keccak_library(),
vec![NamedStorageSlot::with_value(
vec![StorageSlot::with_value(
AuthEcdsaK256Keccak::public_key_slot().clone(),
ecdsa.pub_key.into(),
)],
Expand Down
8 changes: 4 additions & 4 deletions crates/miden-lib/src/account/auth/ecdsa_k256_keccak_acl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ use miden_objects::account::auth::PublicKeyCommitment;
use miden_objects::account::{
AccountCode,
AccountComponent,
NamedStorageSlot,
StorageMap,
StorageSlot,
StorageSlotName,
};
use miden_objects::utils::sync::LazyLock;
Expand Down Expand Up @@ -177,14 +177,14 @@ impl From<AuthEcdsaK256KeccakAcl> for AccountComponent {
let mut storage_slots = Vec::with_capacity(3);

// Public key slot
storage_slots.push(NamedStorageSlot::with_value(
storage_slots.push(StorageSlot::with_value(
AuthEcdsaK256KeccakAcl::public_key_slot().clone(),
ecdsa.pub_key.into(),
));

// Config slot
let num_procs = ecdsa.config.auth_trigger_procedures.len() as u32;
storage_slots.push(NamedStorageSlot::with_value(
storage_slots.push(StorageSlot::with_value(
AuthEcdsaK256KeccakAcl::config_slot().clone(),
Word::from([
num_procs,
Expand All @@ -205,7 +205,7 @@ impl From<AuthEcdsaK256KeccakAcl> for AccountComponent {
.map(|(i, proc_root)| (Word::from([i as u32, 0, 0, 0]), *proc_root));

// Safe to unwrap because we know that the map keys are unique.
storage_slots.push(NamedStorageSlot::with_map(
storage_slots.push(StorageSlot::with_map(
AuthEcdsaK256KeccakAcl::tracked_procedure_roots_slot().clone(),
StorageMap::with_entries(map_entries).unwrap(),
));
Expand Down
10 changes: 5 additions & 5 deletions crates/miden-lib/src/account/auth/ecdsa_k256_keccak_multisig.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use alloc::collections::BTreeSet;
use alloc::vec::Vec;

use miden_objects::account::auth::PublicKeyCommitment;
use miden_objects::account::{AccountComponent, NamedStorageSlot, StorageMap, StorageSlotName};
use miden_objects::account::{AccountComponent, StorageMap, StorageSlot, StorageSlotName};
use miden_objects::utils::sync::LazyLock;
use miden_objects::{AccountError, Word};

Expand Down Expand Up @@ -155,7 +155,7 @@ impl From<AuthEcdsaK256KeccakMultisig> for AccountComponent {

// Threshold config slot (value: [threshold, num_approvers, 0, 0])
let num_approvers = multisig.config.approvers().len() as u32;
storage_slots.push(NamedStorageSlot::with_value(
storage_slots.push(StorageSlot::with_value(
AuthEcdsaK256KeccakMultisig::threshold_config_slot().clone(),
Word::from([multisig.config.default_threshold(), num_approvers, 0, 0]),
));
Expand All @@ -169,14 +169,14 @@ impl From<AuthEcdsaK256KeccakMultisig> for AccountComponent {
.map(|(i, pub_key)| (Word::from([i as u32, 0, 0, 0]), (*pub_key).into()));

// Safe to unwrap because we know that the map keys are unique.
storage_slots.push(NamedStorageSlot::with_map(
storage_slots.push(StorageSlot::with_map(
AuthEcdsaK256KeccakMultisig::approver_public_keys_slot().clone(),
StorageMap::with_entries(map_entries).unwrap(),
));

// Executed transactions slot (map)
let executed_transactions = StorageMap::default();
storage_slots.push(NamedStorageSlot::with_map(
storage_slots.push(StorageSlot::with_map(
AuthEcdsaK256KeccakMultisig::executed_transactions_slot().clone(),
executed_transactions,
));
Expand All @@ -190,7 +190,7 @@ impl From<AuthEcdsaK256KeccakMultisig> for AccountComponent {
.map(|(proc_root, threshold)| (*proc_root, Word::from([*threshold, 0, 0, 0]))),
)
.unwrap();
storage_slots.push(NamedStorageSlot::with_map(
storage_slots.push(StorageSlot::with_map(
AuthEcdsaK256KeccakMultisig::procedure_thresholds_slot().clone(),
proc_threshold_roots,
));
Expand Down
4 changes: 2 additions & 2 deletions crates/miden-lib/src/account/auth/rpo_falcon_512.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use miden_objects::account::auth::PublicKeyCommitment;
use miden_objects::account::{AccountComponent, NamedStorageSlot, StorageSlotName};
use miden_objects::account::{AccountComponent, StorageSlot, StorageSlotName};
use miden_objects::utils::sync::LazyLock;

use crate::account::components::rpo_falcon_512_library;
Expand Down Expand Up @@ -46,7 +46,7 @@ impl From<AuthRpoFalcon512> for AccountComponent {
fn from(falcon: AuthRpoFalcon512) -> Self {
AccountComponent::new(
rpo_falcon_512_library(),
vec![NamedStorageSlot::with_value(
vec![StorageSlot::with_value(
AuthRpoFalcon512::public_key_slot().clone(),
falcon.pub_key.into(),
)],
Expand Down
8 changes: 4 additions & 4 deletions crates/miden-lib/src/account/auth/rpo_falcon_512_acl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ use miden_objects::account::auth::PublicKeyCommitment;
use miden_objects::account::{
AccountCode,
AccountComponent,
NamedStorageSlot,
StorageMap,
StorageSlot,
StorageSlotName,
};
use miden_objects::utils::sync::LazyLock;
Expand Down Expand Up @@ -178,14 +178,14 @@ impl From<AuthRpoFalcon512Acl> for AccountComponent {
let mut storage_slots = Vec::with_capacity(3);

// Public key slot
storage_slots.push(NamedStorageSlot::with_value(
storage_slots.push(StorageSlot::with_value(
AuthRpoFalcon512Acl::public_key_slot().clone(),
falcon.pub_key.into(),
));

// Config slot
let num_procs = falcon.config.auth_trigger_procedures.len() as u32;
storage_slots.push(NamedStorageSlot::with_value(
storage_slots.push(StorageSlot::with_value(
AuthRpoFalcon512Acl::config_slot().clone(),
Word::from([
num_procs,
Expand All @@ -206,7 +206,7 @@ impl From<AuthRpoFalcon512Acl> for AccountComponent {
.map(|(i, proc_root)| (Word::from([i as u32, 0, 0, 0]), *proc_root));

// Safe to unwrap because we know that the map keys are unique.
storage_slots.push(NamedStorageSlot::with_map(
storage_slots.push(StorageSlot::with_map(
AuthRpoFalcon512Acl::tracked_procedure_roots_slot().clone(),
StorageMap::with_entries(map_entries).unwrap(),
));
Expand Down
10 changes: 5 additions & 5 deletions crates/miden-lib/src/account/auth/rpo_falcon_512_multisig.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use alloc::collections::BTreeSet;
use alloc::vec::Vec;

use miden_objects::account::auth::PublicKeyCommitment;
use miden_objects::account::{AccountComponent, NamedStorageSlot, StorageMap, StorageSlotName};
use miden_objects::account::{AccountComponent, StorageMap, StorageSlot, StorageSlotName};
use miden_objects::utils::sync::LazyLock;
use miden_objects::{AccountError, Word};

Expand Down Expand Up @@ -155,7 +155,7 @@ impl From<AuthRpoFalcon512Multisig> for AccountComponent {

// Threshold config slot (value: [threshold, num_approvers, 0, 0])
let num_approvers = multisig.config.approvers().len() as u32;
storage_slots.push(NamedStorageSlot::with_value(
storage_slots.push(StorageSlot::with_value(
AuthRpoFalcon512Multisig::threshold_config_slot().clone(),
Word::from([multisig.config.default_threshold(), num_approvers, 0, 0]),
));
Expand All @@ -169,14 +169,14 @@ impl From<AuthRpoFalcon512Multisig> for AccountComponent {
.map(|(i, pub_key)| (Word::from([i as u32, 0, 0, 0]), (*pub_key).into()));

// Safe to unwrap because we know that the map keys are unique.
storage_slots.push(NamedStorageSlot::with_map(
storage_slots.push(StorageSlot::with_map(
AuthRpoFalcon512Multisig::approver_public_keys_slot().clone(),
StorageMap::with_entries(map_entries).unwrap(),
));

// Executed transactions slot (map)
let executed_transactions = StorageMap::default();
storage_slots.push(NamedStorageSlot::with_map(
storage_slots.push(StorageSlot::with_map(
AuthRpoFalcon512Multisig::executed_transactions_slot().clone(),
executed_transactions,
));
Expand All @@ -190,7 +190,7 @@ impl From<AuthRpoFalcon512Multisig> for AccountComponent {
.map(|(proc_root, threshold)| (*proc_root, Word::from([*threshold, 0, 0, 0]))),
)
.unwrap();
storage_slots.push(NamedStorageSlot::with_map(
storage_slots.push(StorageSlot::with_map(
AuthRpoFalcon512Multisig::procedure_thresholds_slot().clone(),
proc_threshold_roots,
));
Expand Down
8 changes: 3 additions & 5 deletions crates/miden-lib/src/account/faucets/basic_fungible.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use miden_objects::account::{
AccountStorage,
AccountStorageMode,
AccountType,
NamedStorageSlot,
StorageSlot,
StorageSlotName,
};
use miden_objects::asset::{FungibleAsset, TokenSymbol};
Expand Down Expand Up @@ -201,10 +201,8 @@ impl From<BasicFungibleFaucet> for AccountComponent {
faucet.symbol.into(),
Felt::ZERO,
]);
let storage_slot = NamedStorageSlot::with_value(
BasicFungibleFaucet::metadata_slot_name().clone(),
metadata,
);
let storage_slot =
StorageSlot::with_value(BasicFungibleFaucet::metadata_slot_name().clone(), metadata);

AccountComponent::new(basic_fungible_faucet_library(), vec![storage_slot])
.expect("basic fungible faucet component should satisfy the requirements of a valid account component")
Expand Down
6 changes: 3 additions & 3 deletions crates/miden-lib/src/account/faucets/network_fungible.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use miden_objects::account::{
AccountStorage,
AccountStorageMode,
AccountType,
NamedStorageSlot,
StorageSlot,
StorageSlotName,
};
use miden_objects::asset::TokenSymbol;
Expand Down Expand Up @@ -226,8 +226,8 @@ impl From<NetworkFungibleFaucet> for AccountComponent {
.into();

let metadata_slot =
NamedStorageSlot::with_value(NetworkFungibleFaucet::metadata_slot().clone(), metadata);
let owner_slot = NamedStorageSlot::with_value(
StorageSlot::with_value(NetworkFungibleFaucet::metadata_slot().clone(), metadata);
let owner_slot = StorageSlot::with_value(
NetworkFungibleFaucet::owner_config_slot().clone(),
owner_account_id_word,
);
Expand Down
6 changes: 3 additions & 3 deletions crates/miden-lib/src/account/interface/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use alloc::vec::Vec;

use assert_matches::assert_matches;
use miden_objects::account::auth::PublicKeyCommitment;
use miden_objects::account::{AccountBuilder, AccountComponent, AccountType, NamedStorageSlot};
use miden_objects::account::{AccountBuilder, AccountComponent, AccountType, StorageSlot};
use miden_objects::assembly::diagnostics::NamedSource;
use miden_objects::assembly::{Assembler, DefaultSourceManager};
use miden_objects::asset::{FungibleAsset, NonFungibleAsset, TokenSymbol};
Expand Down Expand Up @@ -676,7 +676,7 @@ trait AccountComponentExt {
fn compile_with_path(
source_code: impl ToString,
assembler: Assembler,
storage_slots: Vec<NamedStorageSlot>,
storage_slots: Vec<StorageSlot>,
library_path: impl AsRef<str>,
) -> Result<AccountComponent, AccountError>;
}
Expand All @@ -697,7 +697,7 @@ impl AccountComponentExt for AccountComponent {
fn compile_with_path(
source_code: impl ToString,
assembler: Assembler,
storage_slots: Vec<NamedStorageSlot>,
storage_slots: Vec<StorageSlot>,
library_path: impl AsRef<str>,
) -> Result<Self, AccountError> {
let source = NamedSource::new(library_path, source_code.to_string());
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use alloc::vec::Vec;

use miden_objects::account::{AccountCode, AccountComponent, AccountStorage, NamedStorageSlot};
use miden_objects::account::{AccountCode, AccountComponent, AccountStorage, StorageSlot};

use crate::testing::mock_account_code::MockAccountCodeExt;

Expand All @@ -18,7 +18,7 @@ use crate::testing::mock_account_code::MockAccountCodeExt;
///
/// [account_lib]: crate::testing::mock_account_code::MockAccountCodeExt::mock_account_library
pub struct MockAccountComponent {
storage_slots: Vec<NamedStorageSlot>,
storage_slots: Vec<StorageSlot>,
}

impl MockAccountComponent {
Expand All @@ -35,14 +35,14 @@ impl MockAccountComponent {
/// # Panics
///
/// Panics if the number of slots exceeds [`AccountStorage::MAX_NUM_STORAGE_SLOTS`].
pub fn with_slots(storage_slots: Vec<NamedStorageSlot>) -> Self {
pub fn with_slots(storage_slots: Vec<StorageSlot>) -> Self {
Self::new(storage_slots)
}

// HELPERS
// --------------------------------------------------------------------------------------------

fn new(storage_slots: Vec<NamedStorageSlot>) -> Self {
fn new(storage_slots: Vec<StorageSlot>) -> Self {
debug_assert!(
storage_slots.len() <= AccountStorage::MAX_NUM_STORAGE_SLOTS,
"too many storage slots passed to MockAccountComponent"
Expand Down
4 changes: 2 additions & 2 deletions crates/miden-lib/src/testing/mock_account.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ use miden_objects::account::{
AccountId,
AccountStorage,
AccountType,
NamedStorageSlot,
StorageMap,
StorageSlot,
};
use miden_objects::asset::{AssetVault, NonFungibleAsset};
use miden_objects::testing::constants::{self};
Expand Down Expand Up @@ -72,7 +72,7 @@ pub trait MockAccountExt {
let asset = NonFungibleAsset::mock(&constants::NON_FUNGIBLE_ASSET_DATA_2);
let non_fungible_storage_map =
StorageMap::with_entries([(asset.vault_key().into(), asset.into())]).unwrap();
let storage = AccountStorage::new(vec![NamedStorageSlot::with_map(
let storage = AccountStorage::new(vec![StorageSlot::with_map(
AccountStorage::faucet_metadata_slot().clone(),
non_fungible_storage_map,
)])
Expand Down
8 changes: 4 additions & 4 deletions crates/miden-objects/src/account/builder/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@ mod tests {
use miden_processor::MastNodeExt;

use super::*;
use crate::account::{NamedStorageSlot, StorageSlotName};
use crate::account::{StorageSlot, StorageSlotName};
use crate::testing::noop_auth_component::NoopAuthComponent;

const CUSTOM_CODE1: &str = "
Expand Down Expand Up @@ -339,7 +339,7 @@ mod tests {

AccountComponent::new(
CUSTOM_LIBRARY1.clone(),
vec![NamedStorageSlot::with_value(CUSTOM_COMPONENT1_SLOT_NAME.clone(), value)],
vec![StorageSlot::with_value(CUSTOM_COMPONENT1_SLOT_NAME.clone(), value)],
)
.expect("component should be valid")
.with_supports_all_types()
Expand All @@ -360,8 +360,8 @@ mod tests {
AccountComponent::new(
CUSTOM_LIBRARY2.clone(),
vec![
NamedStorageSlot::with_value(CUSTOM_COMPONENT2_SLOT_NAME0.clone(), value0),
NamedStorageSlot::with_value(CUSTOM_COMPONENT2_SLOT_NAME1.clone(), value1),
StorageSlot::with_value(CUSTOM_COMPONENT2_SLOT_NAME0.clone(), value0),
StorageSlot::with_value(CUSTOM_COMPONENT2_SLOT_NAME1.clone(), value1),
],
)
.expect("component should be valid")
Expand Down
Loading