feat(agglayer): add faucet deregistration#2838
Open
partylikeits1983 wants to merge 4 commits intoagglayerfrom
Open
feat(agglayer): add faucet deregistration#2838partylikeits1983 wants to merge 4 commits intoagglayerfrom
partylikeits1983 wants to merge 4 commits intoagglayerfrom
Conversation
Adds a bridge-admin-gated `deregister_faucet` MASM procedure that clears a faucet from both the `faucet_registry_map` and `token_registry_map`, asserting the faucet is currently registered before clearing. Wired through a new `DEREGISTER_AGG_BRIDGE` note script and a `DeregisterAggBridgeNote` Rust builder. After deregistration, in-flight B2AGG and CLAIM notes referencing the cleared faucet will fail their existing registration checks. - bridge_config.masm: new `deregister_faucet` proc reusing `assert_sender_is_bridge_admin`, `assert_faucet_registered`, and `hash_token_address`. - components/bridge.masm: re-export `deregister_faucet`. - note_scripts/DEREGISTER_AGG_BRIDGE.masm: new note script mirroring CONFIG_AGG_BRIDGE's 7-felt storage layout. - src/deregister_note.rs: new `DeregisterAggBridgeNote` builder. - tests/agglayer/config_bridge.rs: round-trip test verifying both maps are cleared, plus negative tests for `ERR_FAUCET_NOT_REGISTERED` and `ERR_SENDER_NOT_BRIDGE_ADMIN`. - SPEC.md, CHANGELOG.md: documentation updates.
a6017ce to
6c7c155
Compare
…ucet # Conflicts: # crates/miden-agglayer/src/errors/agglayer.rs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #2705.
Adds a bridge-admin-gated
deregister_faucetMASM procedure that clears a faucet from both thefaucet_registry_mapandtoken_registry_map, asserting the faucet is currently registered before clearing. Wired through a newDEREGISTER_AGG_BRIDGEnote script andDeregisterAggBridgeNoteRust builder.After a faucet is deregistered, any in-flight
B2AGGnotes hitERR_FAUCET_NOT_REGISTEREDinbridge_out'sassert_faucet_registered, and any in-flightCLAIMnotes hitERR_TOKEN_NOT_REGISTEREDinlookup_faucet_by_token_address. The bridge admin should drain or warn users about pending notes before deregistering.Changes
bridge_config.masm: newpub proc deregister_faucetthat callsassert_sender_is_bridge_admin, thenassert_faucet_registered(so a typoed faucet ID panics rather than silently no-ops), then writes[0,0,0,0]tofaucet_registry_map(key[0,0,suffix,prefix]) and totoken_registry_map(keyPoseidon2::hash_elements(origin_token_addr[5])). Reuses the existingassert_sender_is_bridge_admin,assert_faucet_registered, andhash_token_addresshelpers — no new helpers added.components/bridge.masm: re-exportderegister_faucet.asm/note_scripts/DEREGISTER_AGG_BRIDGE.masm: new note script mirroringCONFIG_AGG_BRIDGE's 7-felt storage layout (origin_token_addr[5],faucet_id_suffix,faucet_id_prefix).src/deregister_note.rs: newDeregisterAggBridgeNote::{script, script_root, create}builder, mirroringConfigAggBridgeNote.SPEC.md: new §3.1 entry forbridge_config::deregister_faucet, new §4.4 entry for theDEREGISTER_AGG_BRIDGEnote (subsequent §4.x renumbered + cross-refs updated), §7.1 mentions deregistration as the inverse op with the in-flight-note caveat.CHANGELOG.md: newUnreleasedFeatures entry.Tests
Three new tests in
crates/miden-testing/tests/agglayer/config_bridge.rs:test_deregister_agg_bridge_clears_both_registries— register, then deregister; assertsfaucet_registry_map[key] == [0;4]andtoken_registry_map[hash] == [0;4].test_deregister_agg_bridge_fails_when_not_registered— submitDEREGISTER_AGG_BRIDGEwith no prior register; expectsERR_FAUCET_NOT_REGISTERED.test_deregister_agg_bridge_fails_when_sender_not_admin— register first (so the panic comes from the auth check, not the registration check), then submit deregister from a non-admin wallet; expectsERR_SENDER_NOT_BRIDGE_ADMIN.