0xMiden / 0xMiden/protocol

AggLayer: Add claim unsetting mechanism

Aperta
#2,703 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub
agglayer
Lingua principale
Rust
Stelle
132
Fork
167
Merge medio
1g 23h
PR unite (30g)
110

Descrizione

## Description

The Solidity sovereign chain bridge ([`BridgeL2SovereignChain.sol`](https://github.com/agglayer/agglayer-contracts/blob/main/contracts/v2/sovereignChains/BridgeL2SovereignChain.sol)) provides `unsetMultipleClaims(uint256[] calldata globalIndexes)`, gated by `onlyGlobalExitRootRemover`. Each unset updates a running hash chain (`unsetGlobalIndexHashChain = efficientKeccak256(unsetGlobalIndexHashChain, globalIndex)`) and calls `_unsetClaimedBitmap(globalIndex)` to XOR the corresponding claim bit back. Claim unsetting is something sovereign chains can opt into, not a hard requirement from the base bridge protocol.

The Miden bridge's claim nullifier system is irreversible. In [`bridge_in.masm`](https://github.com/0xMiden/miden-base/blob/next/crates/miden-agglayer/asm/agglayer/bridge/bridge_in.masm), the `set_and_check_claimed` procedure writes `[1, 0, 0, 0]` to the `CLAIM_NULLIFIERS_SLOT` map under the key `Poseidon2::hash_elements(leaf_index, source_bridge_network)`, and panics if the old value was non-zero. No reverse operation exists to clear a set nullifier.

## Impact

If a claim is processed with incorrect data (e.g., wrong amount due to a bug in the Integration Service), the nullifier is permanently set. The correct claim for that `(leaf_index, source_bridge_network)` pair can never be processed, effectively locking the user's funds with no recovery path.

## Recommended Action

Add an `unset_claim` procedure gated by a trusted role (bridge admin or GER remover) that clears a previously set claim nullifier, allowing the claim to be re-processed. The procedure should verify the nullifier was actually set before clearing it, and maintain a running Keccak-256 hash chain of all unset global indices for auditability.

## References

- [`bridge_in.masm`](https://github.com/0xMiden/miden-base/blob/next/crates/miden-agglayer/asm/agglayer/bridge/bridge_in.masm) (`set_and_check_claimed`, `assert_claim_not_spent`)
- [`bridge.rs`](https://github.com/0xMiden/miden-base/blob/next/crates/miden-agglayer/src/bridge.rs)
- [`BridgeL2SovereignChain.sol`](https://github.com/agglayer/agglayer-contracts/blob/main/contracts/v2/sovereignChains/BridgeL2SovereignChain.sol)

## Classification

This feature is part of the sovereign chain extension (`BridgeL2SovereignChain`), not the base bridge contract. Claim unsetting is something sovereign chains can opt into, not a hard requirement from the base bridge protocol.

Guida per i contributori

Apri la guida per i contributori

Valutazione

Questa issue non è ancora stata valutata.

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.