Skip to content

feat(AggLayer): add leafType param to CLAIM note#2290

Merged
mmagician merged 3 commits intoagglayerfrom
mmagician-add-leaf-type
Jan 23, 2026
Merged

feat(AggLayer): add leafType param to CLAIM note#2290
mmagician merged 3 commits intoagglayerfrom
mmagician-add-leaf-type

Conversation

@mmagician
Copy link
Copy Markdown
Collaborator

As per the description in #2276, we were missing leafType. As a result of adding this, I've slightly restructured the note input data as well. The full list of interconnected changes is as follows:

  • CLAIM note should carry a leaf_type, which is set to 0u32 for asset transfers, and 1u32 for message passing
  • remove extra padding word from the end of leaf data, instead pad 3 x Felt::ZERO after leaf_type
  • fix LEAF_DATA_WORD_LEN from 6 to 8 words (=32 Felts)
  • when loading AccountId in get_destination_account_id, use constants instead of hardcoded values

@mmagician mmagician changed the base branch from next to agglayer January 16, 2026 10:51
@mmagician mmagician force-pushed the mmagician-add-leaf-type branch 2 times, most recently from 2e892d4 to c940064 Compare January 16, 2026 11:00
Copy link
Copy Markdown
Member

@partylikeits1983 partylikeits1983 left a comment

Choose a reason for hiding this comment

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

Looks good, but instead of setting the leafValue as a parameter to the CLAIM note, it should be a constant that we pass when we call get_leaf_value. This mirrors more closely the agglayer solidity contracts.

See how _LEAF_TYPE_ASSET is a constant that is passed to getLeafValue: https://github.com/agglayer/agglayer-contracts/blob/e468f9b0967334403069aa650d9f1164b1731ebb/contracts/v2/previousVersions/pessimistic/PolygonZkEVMBridgeV2Pessimistic.sol#L479

The CLAIM note inputs should match pretty much 1:1 the data of this function call:

https://github.com/agglayer/agglayer-contracts/blob/e468f9b0967334403069aa650d9f1164b1731ebb/contracts/v2/previousVersions/pessimistic/PolygonZkEVMBridgeV2Pessimistic.sol#L454-L464

@mmagician
Copy link
Copy Markdown
Collaborator Author

@partylikeits1983 Agreed! Thanks for pointing this out.

(btw, let's make sure we reference the right AggLayer contracts: https://github.com/agglayer/agglayer-contracts/blob/e468f9b0967334403069aa650d9f1164b1731ebb/contracts/v2/PolygonZkEVMBridgeV2.sol#L55, instead of "previousVersions")

@mmagician
Copy link
Copy Markdown
Collaborator Author

@partylikeits1983 I ended up implementing something halfway, where the create_claim_note helper doesn't include leafType, but the rest remains unchanged. The reason is that it's very convenient to pass leafType already in CLAIM inputs, because:

  • the note inputs get placed in advice map as part of write_claim_data_into_advice_map_by_key under LEAF_DATA_KEY
  • this propagates all the way to get_leaf_value, where we take everything under this key and hash with keccak

So we could in theory not put leafType under LEAF_DATA_KEY, but this would mean we have to inject it some time before get_leaf_value (which should take leafType as a parameter). The only place this injection could happen efficiently (i.e. without re-hashing the data to place it under a new FULL_LEAF_DATA_KEY) is as part of writing note inputs to advice map in write_claim_data_into_advice_map_by_key, but I don't think this would be very clean.

LMK if you find another place to inject it.

@mmagician mmagician added the agglayer PRs or issues related to AggLayer bridging integration label Jan 21, 2026
@mmagician mmagician requested a review from bobbinth January 22, 2026 15:52
@mmagician mmagician force-pushed the mmagician-add-leaf-type branch from afa04a1 to 998c6cd Compare January 23, 2026 09:43
@mmagician
Copy link
Copy Markdown
Collaborator Author

@partylikeits1983 since the recent CLAIM note refactoring edited too many of the places that this PR touched, I ended up rebasing and re-doing the commits almost entirely. Hence the force push.

Copy link
Copy Markdown
Member

@partylikeits1983 partylikeits1983 left a comment

Choose a reason for hiding this comment

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

Looks good! Makes sense to put the leaf type as part of the CLAIM note inputs

@mmagician mmagician merged commit 60ab0ae into agglayer Jan 23, 2026
17 checks passed
@mmagician mmagician deleted the mmagician-add-leaf-type branch January 23, 2026 17:50
mmagician added a commit that referenced this pull request Jan 24, 2026
* feat: add leafType param

fix after merge

* changelog
mmagician added a commit that referenced this pull request Jan 27, 2026
* feat: add leafType param

fix after merge

* changelog
mmagician added a commit that referenced this pull request Jan 27, 2026
* feat: add leafType param

fix after merge

* changelog
mmagician added a commit that referenced this pull request Jan 27, 2026
* feat: add leafType param

fix after merge

* changelog
mmagician added a commit that referenced this pull request Jan 27, 2026
* feat: add leafType param

fix after merge

* changelog
mmagician added a commit that referenced this pull request Jan 27, 2026
* feat: add leafType param

fix after merge

* changelog
mmagician added a commit that referenced this pull request Jan 27, 2026
* feat: add leafType param

fix after merge

* changelog
partylikeits1983 pushed a commit that referenced this pull request Feb 12, 2026
* feat: add leafType param

fix after merge

* changelog
afa7789 pushed a commit to afa7789/miden-base that referenced this pull request Mar 9, 2026
* feat: add leafType param

fix after merge

* changelog
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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants