Skip to content

Conversation

@sergerad
Copy link
Contributor

@sergerad sergerad commented Jan 8, 2026

Context

The Validator needs to be able to read foreign account data when re-executing network transactions via its TransactionInputsDataStore which implements the DataStore trait.

Blocks 0xMiden/miden-node#1493.

Changes

  • Add TransactionInputs::read_foreign_account_inputs()
  • Add TransactionInputs::read_vault_asset_witnesses()
  • Add TransactionInputs::read_storage_map_witness()
  • Add AccountStorageHeader::from_elements()
  • Add smt_leaf_from_elements(elements: &[Felt], leaf_index: LeafIndex<SMT_DEPTH>) with a TODO to move to crypto SmtLeaf::try_from_elements.

Copy link
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 left some comments inline - the main one is about parsing the account storage header.

To address it, we may need to add something like foreign_account_slot_names field to TransactionInputs and populate it after transaction execution.

@sergerad sergerad requested a review from bobbinth January 11, 2026 04:42
Copy link
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 left some more comments inline - but they are pretty minor.

@sergerad sergerad changed the title feat: Read foreign account inputs from transaction inputs feat: Read foreign account inputs and witnesses from transaction inputs Jan 12, 2026
@sergerad sergerad requested a review from bobbinth January 12, 2026 19:59
// HELPER FUNCTIONS
// ================================================================================================

// TODO(sergerad): Move this fn to crypto SmtLeaf::try_from_elements. Panics will be replaced with
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Will create an issue for this when PR is about to be merged

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
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 left a few comments inline - all should be pretty easy to address.

@sergerad sergerad requested a review from bobbinth January 13, 2026 20:24
Copy link
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.

All looks good! Thank you!

@bobbinth bobbinth merged commit 20014df into next Jan 13, 2026
17 checks passed
@bobbinth bobbinth deleted the sergerad-tx-inputs-foreign-acc-inputs branch January 13, 2026 22:39
Comment on lines +59 to +64
impl TryFrom<Felt> for StorageSlotType {
type Error = AccountError;

fn try_from(value: Felt) -> Result<Self, Self::Error> {
if value == ZERO {
Ok(StorageSlotType::Value)
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we not use impl TryFrom<u8> for StorageSlotType instead?

I think the caller should first let byte = u8::try_from(felt) and then StorageSlotType::try_from(byte). Avoids having to test the impl twice, keeping it up to date in two places, etc.

/// Returns the advice map key where:
/// - the seed for native accounts is stored.
/// - the account header for foreign accounts is stored.
pub fn account_id_map_key(id: AccountId) -> Word {
Copy link
Contributor

Choose a reason for hiding this comment

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

Can this remain private?

afa7789 pushed a commit to afa7789/miden-base that referenced this pull request Jan 15, 2026
afa7789 pushed a commit to afa7789/miden-base that referenced this pull request Jan 15, 2026
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