Skip to content

Replace unwrap() with expect() for StorageSlotName parsing#2451

Merged
mmagician merged 2 commits intommagician-cursor-bridge-out-component-implementation-details-5737from
copilot/sub-pr-2424
Feb 16, 2026
Merged

Replace unwrap() with expect() for StorageSlotName parsing#2451
mmagician merged 2 commits intommagician-cursor-bridge-out-component-implementation-details-5737from
copilot/sub-pr-2424

Conversation

Copy link
Contributor

Copilot AI commented Feb 16, 2026

Addresses review feedback to improve error diagnostics when storage slot name parsing fails.

Changes

  • Replaced 4 instances of .unwrap() with .expect("... should be valid") on StorageSlotName::new() calls in create_bridge_account_builder()
  • Error messages now indicate which specific storage slot name failed parsing

Before/After

// Before
let let_storage_slot_name = StorageSlotName::new("miden::agglayer::let").unwrap();

// After
let let_storage_slot_name = StorageSlotName::new("miden::agglayer::let")
    .expect("LET storage slot name should be valid");

This matches the existing pattern used elsewhere in the file for storage slot name creation.


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI changed the title [WIP] Fix storage slot names in AggLayerBridge contract Replace unwrap() with expect() for StorageSlotName parsing Feb 16, 2026
Copilot AI requested a review from mmagician February 16, 2026 13:01
Co-authored-by: mmagician <8402446+mmagician@users.noreply.github.com>
@mmagician mmagician marked this pull request as ready for review February 16, 2026 15:57
@mmagician mmagician merged commit d94c035 into mmagician-cursor-bridge-out-component-implementation-details-5737 Feb 16, 2026
14 of 15 checks passed
@mmagician mmagician deleted the copilot/sub-pr-2424 branch February 16, 2026 15:57
mmagician added a commit that referenced this pull request Feb 18, 2026
…d update it upon `B2AGG` consumption (#2424)

* chore: unify b2agg note storage layout with claim note

* chore: clarify destinationAddress in CLAIM note

* feat: mem_store_double_word_unaligned

* feat: compute leaf value for bridging out

* chore: update comment about origin network ID

* fix: write_address_to_memory had incorrect address arithmetic

The add.N values should all be add.1 (incrementing the running
pointer by 1 each time), not add.1, add.2, add.3, add.4 which
caused addresses to skip (P, P+1, P+3, P+6, P+10 instead of
P, P+1, P+2, P+3, P+4).

Also includes byte-order fixes (u256_le_to_abi, swap_u32_bytes
for originNetwork and leafType) and test infrastructure for
verifying the root against Solidity vectors.

Status: the MMR root computation via call is verified correct
(test_mmr_append_via_call passes). The write_address_to_memory
fix changed the bridge_out root. Still investigating a remaining
mismatch related to u256_le_to_abi + mem_store_double_word_unaligned
interaction.

Co-authored-by: marti <marti@hungrycats.studio>

* fix: handling of dest address and ID in B2AGG

* feat: reverse_limbs_and_change_byte_endianness

* chore: integrate byte and limb swapping to bridging

* fix: swap origin net ID endianness; rearrange mem writes

Apply suggestions from code review

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* chore: pad mem with zeros after metadata

* feat: store LET frontier in double-word array

* feat: frontier test generation from param"d leaves

* feat: verify computed LER against expected root

* write leaf"s amounts to JSON

* fix: compare LET by elements, rev elements per word

* chore: Replace `unwrap()` with `expect()` for StorageSlotName parsing (#2451)

* Initial plan

* chore: replace unwrap() with expect() for storage slot names

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>

* Update crates/miden-testing/tests/agglayer/bridge_out.rs

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* chore: move (de)ser logic to test_utils

* chore: organize test_utils better

Signed-off-by: Marti <marti@miden.team>

* chore: serialize amounts as strings in mmr test vecs

Signed-off-by: Marti <marti@miden.team>

* test bridge_out frontier persistence across two consumes

Co-authored-by: marti <marti@hungrycats.studio>
Signed-off-by: Marti <marti@miden.team>

* fix bridge_out frontier reload num_leaves endianness

Co-authored-by: marti <marti@hungrycats.studio>
Signed-off-by: Marti <marti@miden.team>

* test bridge_out with shared multi-note helper and 32-leaf case

Co-authored-by: marti <marti@hungrycats.studio>
Signed-off-by: Marti <marti@miden.team>

* refactor bridge_out coverage to direct 32-leaf burn flow

Co-authored-by: marti <marti@hungrycats.studio>
Signed-off-by: Marti <marti@miden.team>

* refactor MMR vectors to seeded per-leaf destinations

Co-authored-by: marti <marti@hungrycats.studio>
Signed-off-by: Marti <marti@miden.team>

* chore: cleanup tests

Signed-off-by: Marti <marti@miden.team>

---------

Signed-off-by: Marti <marti@miden.team>
Co-authored-by: Cursor Agent <cursoragent@cursor.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <198982749+Copilot@users.noreply.github.com>
mmagician added a commit that referenced this pull request Feb 18, 2026
* chore: unify b2agg note storage layout with claim note

* chore: clarify destinationAddress in CLAIM note

* feat: mem_store_double_word_unaligned

* feat: compute leaf value for bridging out

* chore: update comment about origin network ID

* fix: write_address_to_memory had incorrect address arithmetic

The add.N values should all be add.1 (incrementing the running
pointer by 1 each time), not add.1, add.2, add.3, add.4 which
caused addresses to skip (P, P+1, P+3, P+6, P+10 instead of
P, P+1, P+2, P+3, P+4).

Also includes byte-order fixes (u256_le_to_abi, swap_u32_bytes
for originNetwork and leafType) and test infrastructure for
verifying the root against Solidity vectors.

Status: the MMR root computation via call is verified correct
(test_mmr_append_via_call passes). The write_address_to_memory
fix changed the bridge_out root. Still investigating a remaining
mismatch related to u256_le_to_abi + mem_store_double_word_unaligned
interaction.

Co-authored-by: marti <marti@hungrycats.studio>

* fix: handling of dest address and ID in B2AGG

* feat: reverse_limbs_and_change_byte_endianness

* chore: integrate byte and limb swapping to bridging

* fix: swap origin net ID endianness; rearrange mem writes

Apply suggestions from code review

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* chore: pad mem with zeros after metadata

* feat: store LET frontier in double-word array

* feat: frontier test generation from param"d leaves

* feat: verify computed LER against expected root

* write leaf"s amounts to JSON

* fix: compare LET by elements, rev elements per word

* feat: add faucet registry

* chore: CONFIG note docs

* chore: simplify creation of existing agg faucet w/supply

* lint

* chore: TODO on bridge admin validation

* chore: simplify stack operations

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: mmagician <8402446+mmagician@users.noreply.github.com>

* chore: Replace `unwrap()` with `expect()` for StorageSlotName parsing (#2451)

* Initial plan

* chore: replace unwrap() with expect() for storage slot names

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>

* Update crates/miden-testing/tests/agglayer/bridge_out.rs

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* chore: only truncate at the end

* chore: move (de)ser logic to test_utils

* chore: organize test_utils better

Signed-off-by: Marti <marti@miden.team>

* chore: serialize amounts as strings in mmr test vecs

Signed-off-by: Marti <marti@miden.team>

* test bridge_out frontier persistence across two consumes

Co-authored-by: marti <marti@hungrycats.studio>
Signed-off-by: Marti <marti@miden.team>

* fix bridge_out frontier reload num_leaves endianness

Co-authored-by: marti <marti@hungrycats.studio>
Signed-off-by: Marti <marti@miden.team>

* test bridge_out with shared multi-note helper and 32-leaf case

Co-authored-by: marti <marti@hungrycats.studio>
Signed-off-by: Marti <marti@miden.team>

* refactor bridge_out coverage to direct 32-leaf burn flow

Co-authored-by: marti <marti@hungrycats.studio>
Signed-off-by: Marti <marti@miden.team>

* refactor MMR vectors to seeded per-leaf destinations

Co-authored-by: marti <marti@hungrycats.studio>
Signed-off-by: Marti <marti@miden.team>

* chore: cleanup tests

Signed-off-by: Marti <marti@miden.team>

* fix: rustfmt line wrapping + clippy needless_range_loop

Co-authored-by: marti <marti@hungrycats.studio>

* fix: read addr conversion slot in reverse

* chore: use non-zero address

* chore: rename loc const to distinguish

* chore: use loc const in create_burn_note

* chore: bring back doc and inline comments

---------

Signed-off-by: Marti <marti@miden.team>
Co-authored-by: Cursor Agent <cursoragent@cursor.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <198982749+Copilot@users.noreply.github.com>
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.

2 participants