fix(AggLayer): key faucet registry by (origin_network, origin_token_address)#2860
fix(AggLayer): key faucet registry by (origin_network, origin_token_address)#2860partylikeits1983 wants to merge 7 commits intoagglayerfrom
Conversation
… bridge_out_at_high_num_leaves The new test added on agglayer (#2752) used the old 5-arg ConfigAggBridgeNote::create signature; this PR's signature change (adding origin_network) needed to be threaded through after the merge.
| # Hash the (token address, origin network) pair | ||
| exec.hash_token_address | ||
| # => [TOKEN_ADDR_HASH, faucet_id_suffix, faucet_id_prefix, pad(10)] | ||
| # => [TOKEN_ADDR_HASH, faucet_id_suffix, faucet_id_prefix, pad(8)] |
There was a problem hiding this comment.
since this is a call-able procedure, we should assume auto-padding to 16 elements here
| #! used by `LeafData` and the wrapped-token hash; keying on the address alone would let a CLAIM | ||
| #! for one network resolve to the faucet of another network. |
There was a problem hiding this comment.
The second part "keying on the address alone..." is unnecessary information - it is only relevant in the context of this PR, but once it's merged, it will be confusing to whoever's reading this.
This seems to be a common pattern for LLMs, where they put information into docs which are seemingly contextual, but are really out of context when thinking globally. I'm not really sure how to auto-guard against it
| # Write origin_token_addr[0..3] to local memory for hashing | ||
| loc_storew_le.TOKEN_ADDR_HASH_PTR dropw | ||
| # => [addr4, origin_network] | ||
|
|
||
| # Write addr4 at local offset 4 |
There was a problem hiding this comment.
I think the current split of docs is unnecessary, the previous # Write origin_token_addr[5] to local memory for hashing followed by the two store instructions was sufficient IMO
…gistry-key # Conflicts: # crates/miden-agglayer/SPEC.md # crates/miden-agglayer/asm/agglayer/bridge/bridge_in.masm # crates/miden-testing/tests/agglayer/bridge_in.rs
…ote::create signature The merged agglayer cherry-pick introduced tests that called the 5-argument ConfigAggBridgeNote::create and referenced ClaimDataSource::SimulatedL1ToMiden, neither of which exist on this branch. Pass the origin_network argument and use the renamed L1ToMiden variant so these tests compile.
- register_faucet: correct pad(8) to pad(10) after exec.hash_token_address; callable procs auto-pad the stack to 16, so the annotation must reflect the two zero felts that come up from overflow when hash_token_address consumes 6 felts and produces 4. - lookup_faucet_by_token_address: trim the docblock to drop the contextual "keying on the address alone..." sentence that only made sense in the context of this PR. - hash_token_address: collapse the per-store inline comments back to a single umbrella comment, matching the original's terser style.
Fixes #2799.
Widens the bridge's
token_registry_mapkey fromPoseidon2(origin_token_address[5])toPoseidon2(origin_token_address[5] || origin_network)and threadsorigin_networkthrough theCONFIG_AGG_BRIDGEnote,register_faucet, andlookup_faucet_by_token_address.bridge_in::claimnow loadsorigin_networkfrom the leaf and passes it to the lookup, so a CLAIM proven on one origin network can no longer resolve to a faucet registered for the same address on another network.Two regression tests:
test_config_agg_bridge_distinguishes_origin_network— same token + two networks → two distinct registry entries.test_claim_fails_when_origin_network_unregistered— CLAIM whose(addr, network)pair isn't registered fails withERR_TOKEN_NOT_REGISTERED.SPEC.mdupdated.make test: 805/805 pass.