Skip to content

fix(AggLayer): key faucet registry by (origin_network, origin_token_address)#2860

Open
partylikeits1983 wants to merge 7 commits intoagglayerfrom
ajl-fix-faucet-registry-key
Open

fix(AggLayer): key faucet registry by (origin_network, origin_token_address)#2860
partylikeits1983 wants to merge 7 commits intoagglayerfrom
ajl-fix-faucet-registry-key

Conversation

@partylikeits1983
Copy link
Copy Markdown
Contributor

Fixes #2799.

Widens the bridge's token_registry_map key from Poseidon2(origin_token_address[5]) to Poseidon2(origin_token_address[5] || origin_network) and threads origin_network through the CONFIG_AGG_BRIDGE note, register_faucet, and lookup_faucet_by_token_address. bridge_in::claim now loads origin_network from 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 with ERR_TOKEN_NOT_REGISTERED.

SPEC.md updated. make test: 805/805 pass.

@partylikeits1983 partylikeits1983 added the agglayer PRs or issues related to AggLayer bridging integration label May 1, 2026
@partylikeits1983 partylikeits1983 added the pr-from-maintainers PRs that come from internal contributors or integration partners. They should be given priority label May 1, 2026
… 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.
@partylikeits1983 partylikeits1983 marked this pull request as ready for review May 1, 2026 18:52
Copy link
Copy Markdown
Collaborator

@mmagician mmagician left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

# 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)]
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

since this is a call-able procedure, we should assume auto-padding to 16 elements here

Comment on lines +203 to +204
#! 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.
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Comment on lines +249 to +253
# 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
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agglayer PRs or issues related to AggLayer bridging integration pr-from-maintainers PRs that come from internal contributors or integration partners. They should be given priority

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants