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>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
…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
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