0xMiden / 0xMiden/protocol

AggLayer: Validate faucet existence on registration

Ouverte
#2,709 1 commentaire 0 réactions 0 personnes assignées Voir sur GitHub
agglayer
Langage dominant
Rust
Étoiles
132
Forks
167
Merge moyen
1 j 23 h
PR mergées (30 j)
110

Description

## Description

In the Solidity bridge, token contracts are deployed by the bridge itself via CREATE2 (or set explicitly by the bridge manager for sovereign tokens in [`BridgeL2SovereignChain.sol`](https://github.com/agglayer/agglayer-contracts/blob/main/contracts/v2/sovereignChains/BridgeL2SovereignChain.sol)), so the bridge has direct control over token contract existence and configuration. There is no direct Solidity counterpart to this issue.

In the Miden bridge, the [`register_faucet`](https://github.com/0xMiden/miden-base/blob/next/crates/miden-agglayer/asm/agglayer/bridge/bridge_config.masm) procedure writes the faucet ID to both `faucet_registry_map` and `token_registry_map` without verifying that the faucet account exists on-chain, has the correct code commitment, or is properly configured (correct origin token address, scale, etc.). The procedure receives `faucet_id_suffix` and `faucet_id_prefix` from the [CONFIG_AGG_BRIDGE](https://github.com/0xMiden/miden-base/blob/next/crates/miden-agglayer/asm/note_scripts/CONFIG_AGG_BRIDGE.masm) note storage and directly writes them to the registries with no FPI call or other validation.

## Impact

If the bridge admin makes a typo in the faucet ID, or if an incorrectly configured faucet is registered, the token registry would point to a non-existent or misconfigured faucet. The failure mode depends on the operation:
- Bridge-in claims: the `lookup_faucet_by_token_address` call would return the wrong faucet ID. The MINT note would target a non-existent faucet, failing at the faucet's mint procedure.
- Bridge-out operations: the `convert_asset` procedure performs an FPI call to the faucet's `asset_to_origin_asset`. If the faucet doesn't exist, this FPI call fails. If the faucet exists but has wrong parameters, incorrect conversion data would be returned, producing wrong leaf data.

## Recommended Action

Modify `register_faucet` to perform an FPI call to the faucet (e.g., calling `get_scale`) before writing to the registries. If the faucet doesn't exist or isn't a valid AggLayer faucet, the FPI call will fail and the transaction will panic, preventing invalid registrations. Optionally, also add client-side validation in the Rust helper for early error detection before the note is even created.

## References

- [`bridge_config.masm`](https://github.com/0xMiden/miden-base/blob/next/crates/miden-agglayer/asm/agglayer/bridge/bridge_config.masm) (`register_faucet`)
- [`config_note.rs`](https://github.com/0xMiden/miden-base/blob/next/crates/miden-agglayer/src/config_note.rs)
- [`faucet.rs`](https://github.com/0xMiden/miden-base/blob/next/crates/miden-agglayer/src/faucet.rs)

## Classification

No direct Solidity counterpart. In the Solidity bridge, token contracts are deployed by the bridge itself via CREATE2, so existence is inherently guaranteed. This issue is Miden-specific, arising from the architectural difference where faucets are pre-deployed independently and then registered with the bridge.

Guide de contribution

Ouvrir le guide de contribution

Évaluation

Cette issue n'a pas encore été évaluée.

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.