feat(AggLayer): faucet registry#2426
Conversation
|
Cursor Agent can help with this pull request. Just |
Co-authored-by: marti <marti@hungrycats.studio>
aa8f85a to
25de59f
Compare
There was a problem hiding this comment.
Pull request overview
Implements an AggLayer faucet registry and conversion-metadata flow to validate/convert bridge-out assets, including a new CONFIG_AGG_BRIDGE note path for registering faucets and updated bridge-out logic to use FPI conversion.
Changes:
- Adds faucet conversion metadata storage (origin token address, origin network, scale) and helpers for packing/unpacking it.
- Adds a bridge
faucet_registrymap plusbridge_config::register_faucetand aCONFIG_AGG_BRIDGEnote/script to register faucets. - Updates bridge-out to require faucet registration and to call the faucet via FPI for origin-asset conversion; adds/updates tests and changelog entry.
Reviewed changes
Copilot reviewed 12 out of 12 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| crates/miden-testing/tests/agglayer/mod.rs | Registers the new config_bridge test module. |
| crates/miden-testing/tests/agglayer/config_bridge.rs | Adds test coverage for faucet registration via CONFIG_AGG_BRIDGE. |
| crates/miden-testing/tests/agglayer/bridge_out.rs | Updates bridge-out tests for registry + FPI conversion and adds an unregistered-faucet rejection test. |
| crates/miden-testing/tests/agglayer/bridge_in.rs | Updates faucet creation in bridge-in test to include conversion metadata params. |
| crates/miden-agglayer/src/lib.rs | Exposes ConfigAggBridgeNote, adds conversion-slot/key helpers, and extends bridge/faucet account builders with new storage. |
| crates/miden-agglayer/src/errors/agglayer.rs | Adds new MASM error constants for config note + registry failures. |
| crates/miden-agglayer/src/config_note.rs | Introduces Rust utilities for creating CONFIG_AGG_BRIDGE notes. |
| crates/miden-agglayer/asm/note_scripts/CONFIG_AGG_BRIDGE.masm | New note script that registers faucets by calling bridge_config::register_faucet. |
| crates/miden-agglayer/asm/bridge/bridge_out.masm | Enforces registry allowlist and performs FPI conversion before building the leaf + BURN note. |
| crates/miden-agglayer/asm/bridge/bridge_config.masm | New procedure to set faucet registry sentinel entries in bridge storage. |
| crates/miden-agglayer/asm/bridge/agglayer_faucet.masm | Adds faucet-side helpers and asset_to_origin_asset for FPI conversion. |
| CHANGELOG.md | Documents the new faucet registry + config note + FPI-based conversion. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
1266876 to
8303a1a
Compare
25de59f to
61826f8
Compare
|
@copilot address the nits from the latest PR review from partylikeits1983 |
|
@mmagician I've opened a new pull request, #2440, to work on those changes. Once the pull request is ready, I'll request review from you. |
partylikeits1983
left a comment
There was a problem hiding this comment.
Looks great! However, I do think we should have a check on who can register faucets, but this can be done in a later followup PR.
https://github.com/0xMiden/miden-base/pull/2426/changes#r2804764047
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>
…sor-bridge-out-component-implementation-details-5737
Signed-off-by: Marti <marti@miden.team>
Signed-off-by: Marti <marti@miden.team>
Co-authored-by: marti <marti@hungrycats.studio> Signed-off-by: Marti <marti@miden.team>
Co-authored-by: marti <marti@hungrycats.studio> Signed-off-by: Marti <marti@miden.team>
Co-authored-by: marti <marti@hungrycats.studio> Signed-off-by: Marti <marti@miden.team>
Co-authored-by: marti <marti@hungrycats.studio> Signed-off-by: Marti <marti@miden.team>
Co-authored-by: marti <marti@hungrycats.studio> Signed-off-by: Marti <marti@miden.team>
Signed-off-by: Marti <marti@miden.team>
2698ce5 to
3bfb9d3
Compare
…sor-bridge-out-component-implementation-details-5737
…t-implementation-details-5737
…tails-5737' into mmagician-cursor-agglayer-faucet-registry-5caf Co-authored-by: marti <marti@hungrycats.studio>
Co-authored-by: marti <marti@hungrycats.studio>
dc2f012 to
43e0bb0
Compare
* 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 (0xMiden#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>
Implement the AggLayer faucet registry for bridge asset validation and conversion.
Changes:
Faucet registry and configuration
AgglayerFaucetstores conversion metadata (origin token address, origin network, scale) in two new storage slots (conversion_info_1,conversion_info_2, since the token address takes up 5 elements)faucet_registrystorage map for registered faucets ([prefix, suffix, 0, 0] -> [flag, 0, 0, 0])bridge_config.masmmodule withregister_faucetprocedure (ATM anyone can register a faucet)CONFIG_AGG_BRIDGEnote script to register faucets via issuing a noteCONFIG_AGG_BRIDGEnoteBridging out uses the faucet registry
bridge_outviaB2AGG, the bridge validates the faucet is registered, then callsasset_to_origin_asseton the faucet via FPI to obtain the scaled amount (8 felts), origin token address (5 felts), and origin network (1 felt)agglayer_faucet.masmexposesget_origin_token_address,get_origin_network,get_scale, andasset_to_origin_assethelper procedures, since the data in storage slots (esp. address) is crammed together