Skip to content

refactor(agglayer): use the standard FungibleFaucet for AggLayer faucets - #3525

Open
Fumuran wants to merge 4 commits into
nextfrom
fumuran-claude/agglayer-standard-faucet
Open

refactor(agglayer): use the standard FungibleFaucet for AggLayer faucets#3525
Fumuran wants to merge 4 commits into
nextfrom
fumuran-claude/agglayer-standard-faucet

Conversation

@Fumuran

@Fumuran Fumuran commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

Summary

Closes #2585.

The agglayer::faucet component was vestigial: it re-exported mint_and_send, receive_and_burn and has_procedure from the standards library, a strict subset of what the standard FungibleFaucet component exports, and AggLayerFaucet was a newtype over FungibleFaucet emitting its storage slots verbatim. The re-exports resolve to the same standards procedures, so the mint/burn MAST roots are unchanged by the swap.

The functional gap was the token name: AggLayerFaucet::new fabricated it from the symbol, leaving the metadata hash preimage abi.encode(name, symbol, decimals) unrecoverable from faucet storage. #2586 needs it to verify the registered hash on-chain.

Changes

  • Removed the miden-agglayer-faucet MASM package, AgglayerFaucetError and the generated FAUCET_CODE_COMMITMENT. Faucet identity now comes from FungibleFaucet::try_from(&Account), which checks the interface rather than a pinned commitment that had to hand-mirror the whole component stack.
  • AggLayerFaucet becomes a stateless namespace: it no longer wraps a FungibleFaucet or validates accounts, but still groups allowed_notes, procedure_roles, fee_manager_role and account_builder, mirroring AggLayerBridge. Call sites are unchanged.
  • account_builder and create_existing_agglayer_faucet take a token name, and the new MetadataHash::from_fungible_faucet derives the registered hash from faucet storage so the two cannot drift.

The component stack, the note allowlist and the asset-callback flag are unchanged. The faucet code commitment changes, and with it faucet account IDs. miden-standards is untouched.

Open questions

  1. TokenName::MAX_BYTES is 32, a policy cap below the 55-byte encoding capacity. Today an operator can work around it by registering a hash over the true long name while storing a shortened one; AggLayer: onchain verification of metadata hash during faucet registration #2586 closes that off, making 32 bytes a hard ceiling on foreign token names. Worth settling before that work starts.
  2. build_fungible_faucet panics via .expect on an invalid token name, matching the existing convention for token_symbol. A name comes from a foreign ERC-20, so a fallible constructor may fit better.
  3. The native-faucet bridge-out test registers a hash over "Native Token" while the MockChainBuilder faucet it targets stores "NATIVE". Harmless today, will fail AggLayer: onchain verification of metadata hash during faucet registration #2586's check.

🤖 Generated with Claude Code

@Fumuran
Fumuran force-pushed the fumuran-claude/agglayer-standard-faucet branch from c73dd18 to 382795a Compare August 17, 2026 15:38
melnikga pushed a commit to walnuthq/miden-base that referenced this pull request Aug 21, 2026
…iden#3630)

Codifies the format settled on while reviewing 0xMiden#3525, and applies the same
discipline to issues. PRs get summary, changes, open questions; issues get
problem, impact, direction. Test plans, command transcripts, per-file
enumeration and process narration come out of both, since CI reports what
passed and the diff or a permalink shows the code.

Carves out what still earns length: correctness arguments, protocol-level
consequences such as a changed commitment, deliberate convention deviations,
and design questions genuinely put to the team.

Sits alongside `concise-changelog-entries`, which applies the same principle to
CHANGELOG lines.

Co-authored-by: Claude (Opus) <noreply@anthropic.com>
…ucets

The dedicated `agglayer::faucet` component had become vestigial: it re-exported
`mint_and_send`, `receive_and_burn` and `has_procedure` from the standards
library, a strict subset of what the standard `FungibleFaucet` component already
exports, and `AggLayerFaucet` was a newtype over `FungibleFaucet` emitting its
storage slots verbatim. The re-exports resolve to the same standards procedures,
so the mint/burn MAST roots are unchanged by the swap and the reflective
faucet-kind detection in the unified MINT/BURN note scripts keeps working.

Critically, `AggLayerFaucet::new` fabricated the token name from the symbol,
which left the AggLayer metadata hash preimage `abi.encode(name, symbol,
decimals)` unrecoverable from faucet storage. The builders now take a real token
name, which is what #2586 needs to verify the registered hash on-chain.

- Remove the `miden-agglayer-faucet` MASM package, `asm/agglayer/faucet/`,
  `src/faucet.rs`, `AggLayerFaucet`, `AgglayerFaucetError` and the build.rs-
  generated `FAUCET_CODE_COMMITMENT`. Faucet identity is now established through
  `FungibleFaucet::try_from(&Account)`, which checks the interface rather than a
  commitment that had to hand-mirror the component stack.
- `AggLayerFaucet::account_builder` / `::allowed_notes` become the free functions
  `agglayer_faucet_account_builder` / `agglayer_faucet_allowed_notes`, since the
  type they hung off no longer exists. The account's component stack is otherwise
  unchanged: Ownable2Step for the owner-gated mint and burn policies, RBAC plus
  `Authority::RbacControlled` for authority-gated configuration, the token policy
  manager, and `ConstantFeeManager`.
- Add `MetadataHash::from_fungible_faucet` so call sites derive the registered
  hash from the faucet's own stored metadata instead of repeating three literals.

The faucet code commitment changes.

Closes #2585

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@Fumuran
Fumuran force-pushed the fumuran-claude/agglayer-standard-faucet branch from 382795a to 5920451 Compare August 25, 2026 21:16
- Keep `AggLayerFaucet` as a stateless namespace instead of moving its
  associated functions out to free functions in `lib.rs`. The type no
  longer wraps a `FungibleFaucet` or validates accounts, but
  `allowed_notes`, `procedure_roles`, `fee_manager_role` and
  `account_builder` stay grouped under it, mirroring `AggLayerBridge`.
- Rename `agglayer_faucet_metadata` to `build_fungible_faucet`: it
  returns the `FungibleFaucet` component, not a metadata value.
- Drop `test_metadata_hash_from_fungible_faucet_matches_token_info`,
  which compared `from_fungible_faucet` against the `from_token_info`
  it forwards to. The same redundant assertion is removed from
  `agglayer_faucet_is_a_bridge_owned_fungible_faucet`, where the
  field-by-field checks above it already cover the round-trip.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Comment thread crates/miden-agglayer/src/eth_types/metadata_hash.rs Outdated
Comment thread crates/miden-agglayer/src/lib.rs Outdated
Comment thread crates/miden-agglayer/src/lib.rs Outdated
Comment thread crates/miden-agglayer/src/eth_types/metadata_hash.rs Outdated
Comment thread crates/miden-agglayer/src/faucet.rs Outdated
Comment thread crates/miden-agglayer/build.rs Outdated
Comment thread crates/miden-agglayer/SPEC.md Outdated
Comment thread CHANGELOG.md Outdated
- Reword the `AggLayerFaucet` doc to say what it is: a stateless helper
  holding deployment configuration, explicitly not an `AccountComponent`.
- Trim `MetadataHash::from_fungible_faucet`'s doc to the suggested line.
- Drop the `generate_agglayer_constants` note explaining why the faucet
  has no code commitment.
- Cut SPEC 3.2 down to what is distinctive about an AggLayer faucet -
  bridge ownership, `owner_only` mint/burn, the note allowlist and the
  token name - instead of enumerating standard `FungibleFaucet`
  procedures and accessors. The old text also claimed the allowlist was
  limited to MINT and BURN, which has not been true since #3632.
- Shorten the CHANGELOG entry to the suggested wording and point it at
  this PR rather than the issue.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@Fumuran
Fumuran marked this pull request as ready for review August 26, 2026 15:44
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.

AggLayer: use FungibleFaucet in favor of a dedicated AggLayer faucet

2 participants