Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
63 commits
Select commit Hold shift + click to select a range
46143c8
feat: add Solidity<>Miden address type conversion functions
partylikeits1983 Jan 9, 2026
3c84da6
fix: formatting
partylikeits1983 Jan 9, 2026
c71d9df
refactor: rm unnecessary indirection
partylikeits1983 Jan 9, 2026
779ab24
refactor: use crypto util functions
partylikeits1983 Jan 9, 2026
a8238b6
refactor: implement suggestions & refactor
partylikeits1983 Jan 9, 2026
5dd9c85
refactor: update logic & comments to little endian
partylikeits1983 Jan 9, 2026
99bcee7
Update crates/miden-agglayer/src/utils.rs
partylikeits1983 Jan 9, 2026
2d0a89a
refactor: improve EthAddress representation clarity and MASM alignment
partylikeits1983 Jan 9, 2026
3d45e7f
refactor: simplify ethereum_address_to_account_id proc
partylikeits1983 Jan 9, 2026
43cbcf3
fix: clippy
partylikeits1983 Jan 9, 2026
049e8be
fix: lint doc check
partylikeits1983 Jan 9, 2026
99161e3
refactor: use u32assert2
partylikeits1983 Jan 9, 2026
3dc29f6
refactor: simplify from_account_id() & u32 check
partylikeits1983 Jan 9, 2026
4c6289d
revert: undo drop addr4 in ethereum_address_to_account_id
partylikeits1983 Jan 9, 2026
a5f3309
Merge branch 'ajl-solidity-type-conversions' into ajl-agglayer-get-le…
partylikeits1983 Jan 12, 2026
576f907
feat: init getLeafValue() test
partylikeits1983 Jan 12, 2026
a8e35d3
feat: implement AdviceMap key based getLeafValue procedure
partylikeits1983 Jan 12, 2026
a1a1c3d
Update crates/miden-agglayer/src/eth_address.rs
partylikeits1983 Jan 13, 2026
359b3ef
refactor: update test name
partylikeits1983 Jan 13, 2026
1264d24
refactor: rename to EthAddressFormat
partylikeits1983 Jan 13, 2026
2288c0d
refactor: rearrange EthAddressFormat
partylikeits1983 Jan 13, 2026
d9c309a
refactor: rename file to eth_address_format
partylikeits1983 Jan 13, 2026
393ee03
Merge branch 'agglayer' into ajl-solidity-type-conversions
partylikeits1983 Jan 14, 2026
3c3c29e
fix: update script roots
partylikeits1983 Jan 14, 2026
a926316
Merge branch 'ajl-solidity-type-conversions' into ajl-agglayer-get-le…
mmagician Jan 14, 2026
af29827
chore: pipe words to memory
mmagician Jan 14, 2026
d6b9954
refactor: add stack comments
partylikeits1983 Jan 14, 2026
f9f2d57
chore: pipe words to memory instead of manual `adv_loadw`
partylikeits1983 Jan 14, 2026
d61f836
refactor: deduplicate execute_program_with_default_host
partylikeits1983 Jan 14, 2026
d51bed1
feat: add hardcoded expected hash to test
partylikeits1983 Jan 14, 2026
1388770
fix: verify hash matches commitment
mmagician Jan 15, 2026
f200752
fix: put data under correct key in advice map
mmagician Jan 15, 2026
fc9ff91
chore: refresh Cargo.lock file
bobbinth Jan 17, 2026
0aef40d
chore: increment crate versions to v0.14.0
bobbinth Jan 17, 2026
1a3b8a3
chore: fix documentation links
bobbinth Jan 17, 2026
8ebdc7b
chore: merge agglayer
partylikeits1983 Jan 19, 2026
2dfa097
Merge branch 'next' into agglayer
mmagician Jan 20, 2026
1567d89
fix: rm redundant file
partylikeits1983 Jan 20, 2026
c1aec4d
Merge branch 'agglayer' into ajl-agglayer-get-leaf-value
partylikeits1983 Jan 21, 2026
193c618
Merge pull request #2262 from 0xMiden/ajl-agglayer-get-leaf-value
partylikeits1983 Jan 21, 2026
a36bc67
`CLAIM` note followup: helper functions & refactoring (#2270)
partylikeits1983 Jan 22, 2026
2d2cb9b
wip: u256 to felt scaling procedure
partylikeits1983 Jan 23, 2026
dd83b50
fix: rustfmt
partylikeits1983 Jan 23, 2026
cb920e7
Merge branch 'next' into agglayer
mmagician Jan 23, 2026
4c5ccae
feat: implement Keccak-based MMR frontier (#2245)
Fumuran Jan 23, 2026
66bf679
feat(AggLayer): Solidity compatibility tests for MMR frontier code (#…
mmagician Jan 23, 2026
05e323c
Merge branch 'agglayer' into ajl-u256-felt-downscale-procedure
partylikeits1983 Jan 23, 2026
7f6e334
refactor: pass quotient via stack
partylikeits1983 Jan 23, 2026
ea546bb
refactor: procedure comments
partylikeits1983 Jan 23, 2026
60ab0ae
feat(AggLayer): add `leafType` param to `CLAIM` note (#2290)
mmagician Jan 23, 2026
2f5283a
refactor: modify tests & use assertz
partylikeits1983 Jan 23, 2026
4991976
Merge branch 'agglayer' into ajl-u256-felt-downscale-procedure
partylikeits1983 Jan 23, 2026
329397e
refactor: cleanup test helper inputs
partylikeits1983 Jan 23, 2026
04d29e3
refactor: cleanup tests
partylikeits1983 Jan 23, 2026
6644bb6
wip: add quotient to claim note
partylikeits1983 Jan 23, 2026
570e92b
feat: add inline sanity check test
partylikeits1983 Jan 23, 2026
33611f6
Merge branch 'ajl-u256-felt-downscale-procedure' into ajl-add-scale-d…
partylikeits1983 Jan 23, 2026
87100a1
feat: tie in scaling in CLAIM note
partylikeits1983 Jan 23, 2026
98c21a5
refactor: cleanup test
partylikeits1983 Jan 23, 2026
d75ce0f
feat: add check to assert origin token addresses match
partylikeits1983 Jan 23, 2026
89e75e9
chore: merge ajl-u256-felt-downscale-procedure
partylikeits1983 Jan 23, 2026
a35183d
refactor: cleanup unecessary changes
partylikeits1983 Jan 23, 2026
b22cb15
refator: simplify and rename to verify_u256_to_native_amount_conversion
partylikeits1983 Jan 25, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[submodule "crates/miden-agglayer/solidity-compat/lib/forge-std"]
path = crates/miden-agglayer/solidity-compat/lib/forge-std
url = https://github.com/foundry-rs/forge-std
[submodule "crates/miden-agglayer/solidity-compat/lib/agglayer-contracts"]
path = crates/miden-agglayer/solidity-compat/lib/agglayer-contracts
url = https://github.com/agglayer/agglayer-contracts
2 changes: 2 additions & 0 deletions .taplo.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
exclude = ["crates/miden-agglayer/solidity-compat/lib/*"]

[formatting]
align_entries = true
column_width = 120
Expand Down
7 changes: 5 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,15 @@
- [BREAKING] Refactored storage slots to be accessed by names instead of indices ([#1987](https://github.com/0xMiden/miden-base/pull/1987), [#2025](https://github.com/0xMiden/miden-base/pull/2025), [#2149](https://github.com/0xMiden/miden-base/pull/2149), [#2150](https://github.com/0xMiden/miden-base/pull/2150), [#2153](https://github.com/0xMiden/miden-base/pull/2153), [#2154](https://github.com/0xMiden/miden-base/pull/2154), [#2160](https://github.com/0xMiden/miden-base/pull/2160), [#2161](https://github.com/0xMiden/miden-base/pull/2161), [#2170](https://github.com/0xMiden/miden-base/pull/2170)).
- [BREAKING] Allowed account components to share identical account code procedures ([#2164](https://github.com/0xMiden/miden-base/pull/2164)).
- Add `AccountId::parse()` helper function to parse both hex and bech32 formats ([#2223](https://github.com/0xMiden/miden-base/pull/2223)).
- Add Keccak-based MMR frontier structure to the Agglayer library ([#2245](https://github.com/0xMiden/miden-base/pull/2245)).
- Add `read_foreign_account_inputs()`, `read_vault_asset_witnesses()`, and `read_storage_map_witness()` for `TransactionInputs` ([#2246](https://github.com/0xMiden/miden-base/pull/2246)).
- [BREAKING] Introduced `NoteAttachment` as part of `NoteMetadata` and remove `aux` and `execution_hint` ([#2249](https://github.com/0xMiden/miden-base/pull/2249), [#2252](https://github.com/0xMiden/miden-base/pull/2252), [#2260](https://github.com/0xMiden/miden-base/pull/2260), [#2268](https://github.com/0xMiden/miden-base/pull/2268), [#2279](https://github.com/0xMiden/miden-base/pull/2279)).
- [BREAKING] Introduce `NoteAttachment` as part of `NoteMetadata` and remove `aux` and `execution_hint` ([#2249](https://github.com/0xMiden/miden-base/pull/2249), [#2252](https://github.com/0xMiden/miden-base/pull/2252), [#2260](https://github.com/0xMiden/miden-base/pull/2260), [#2268](https://github.com/0xMiden/miden-base/pull/2268), [#2279](https://github.com/0xMiden/miden-base/pull/2279)).
- Introduce standard `NetworkAccountTarget` attachment for use in network transactions which replaces `NoteTag::NetworkAccount` ([#2257](https://github.com/0xMiden/miden-base/pull/2257)).
- Add a foundry test suite for verifying AggLayer contracts compatibility ([#2312](https://github.com/0xMiden/miden-base/pull/2312)).
- Added `AccountSchemaCommitment` component to expose account storage schema commitments ([#2253](https://github.com/0xMiden/miden-base/pull/2253)).
- Introduced standard `NetworkAccountTarget` attachment for use in network transactions which replaces `NoteTag::NetworkAccount` ([#2257](https://github.com/0xMiden/miden-base/pull/2257)).
- Added an `AccountBuilder` extension trait to help build the schema commitment; added `AccountComponentMetadata` to `AccountComponent` ([#2269](https://github.com/0xMiden/miden-base/pull/2269)).
- Added `miden::standards::access::ownable` standard module for component ownership management, and integrated it into the `network_fungible` faucet (including new tests). ([#2228](https://github.com/0xMiden/miden-base/pull/2228)).
- [BREAKING] Add `leaf_value` to `CLAIM` note inputs ([#2290](https://github.com/0xMiden/miden-base/pull/2290)).

### Changes

Expand Down
4 changes: 4 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,13 @@ build-no-std: ## Build without the standard library
build-no-std-testing: ## Build without the standard library. Includes the `testing` feature
$(BUILD_GENERATED_FILES_IN_SRC) cargo build --no-default-features --target wasm32-unknown-unknown --workspace --exclude bench-transaction --features testing

# --- test vectors --------------------------------------------------------------------------------

.PHONY: generate-solidity-test-vectors
generate-solidity-test-vectors: ## Regenerate Solidity MMR test vectors using Foundry
cd crates/miden-agglayer/solidity-compat && forge test -vv --match-test test_generateVectors
cd crates/miden-agglayer/solidity-compat && forge test -vv --match-test test_generateCanonicalZeros

# --- benchmarking --------------------------------------------------------------------------------

.PHONY: bench-tx
Expand Down
3 changes: 3 additions & 0 deletions _typos.toml
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
[default]
extend-ignore-identifiers-re = [".*1st.*", ".*2nd.*", ".*3rd.*"]

[files]
extend-exclude = ["crates/miden-agglayer/solidity-compat/lib"]
4 changes: 4 additions & 0 deletions crates/miden-agglayer/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ miden-protocol = { workspace = true }
miden-standards = { workspace = true }
miden-utils-sync = { workspace = true }

# External dependencies
primitive-types = { workspace = true }

[dev-dependencies]
miden-agglayer = { features = ["testing"], path = "." }

Expand All @@ -35,6 +38,7 @@ fs-err = { workspace = true }
miden-assembly = { workspace = true }
miden-core = { workspace = true }
miden-core-lib = { workspace = true }
miden-crypto = { workspace = true }
miden-protocol = { features = ["testing"], workspace = true }
miden-standards = { workspace = true }
regex = { version = "1.11" }
Expand Down
162 changes: 142 additions & 20 deletions crates/miden-agglayer/asm/bridge/agglayer_faucet.masm
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
use miden::agglayer::bridge_in
use miden::agglayer::asset_conversion
use miden::agglayer::eth_address
use miden::protocol::active_account
use miden::protocol::active_note
use miden::standards::faucets
use miden::protocol::note
use miden::protocol::tx
use miden::core::mem
use miden::core::word


# CONSTANTS
Expand All @@ -14,8 +16,14 @@ use miden::core::mem
# The slot in this component's storage layout where the bridge account ID is stored.
const BRIDGE_ID_SLOT = word("miden::agglayer::faucet")

# The slots where origin token address and scaling factor are stored
# AGGFAUCET_METADATA_SLOT_0: [tok0, tok1, tok2, tok3]
# AGGFAUCET_METADATA_SLOT_1: [tok4, scaling_factor, 0, 0]
const AGGFAUCET_METADATA_SLOT_0 = word("miden::agglayer::aggfaucet_metadata_0")
const AGGFAUCET_METADATA_SLOT_1 = word("miden::agglayer::aggfaucet_metadata_1")
Comment on lines 16 to +23
Copy link
Contributor

Choose a reason for hiding this comment

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

A few comments on this:

  • Would it not be more convenient to store the token address as 8 felts (each holding a u32 value)? I'm assuming here that this would allow us to re-use the native serialization of the AggLayer format.
  • I would probably separate token address from other metadata as I'm imagining we'd need more metadata for the faucet. Or are we using basic fungible faucet metadata slot for that?
  • For slot names, we should make the convention consistent. Specifically, I'd use miden::agglayer::faucet as the namespace and then add slot names within that namespace.
  • I would also maybe provide a high level description of the storage layout for the whole faucet, and after that would declare all constants (would make it a bit easier to read.

Overall, for slots, I'd probably have something like this:

const BRIDGE_ID_SLOT = word("miden::agglayer::faucet::bridge_account_id")
const FAUCET_METADATA = word("miden::agglayer::faucet::metadata")
const TOKEN_ADDRESS_SLOT_0 = word("miden::agglayer::faucet::token_address_0")
const TOKEN_ADDRESS_SLOT_1 = word("miden::agglayer::faucet::token_address_1")

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah - scratch the first point above. Token address is only 20 bytes, so, we already have u32 representation - and we don't need more than 5 elements for them.


const PROOF_DATA_WORD_LEN = 134
const LEAF_DATA_WORD_LEN = 6
const LEAF_DATA_WORD_LEN = 8
const OUTPUT_NOTE_DATA_WORD_LEN = 2

const PROOF_DATA_START_PTR = 0
Expand All @@ -31,8 +39,23 @@ const CLAIM_NOTE_DATA_MEM_ADDR = 712
const OUTPUT_NOTE_INPUTS_MEM_ADDR = 0
const OUTPUT_NOTE_TAG_MEM_ADDR = 574
const OUTPUT_NOTE_SERIAL_NUM_MEM_ADDR = 568
const OUTPUT_NOTE_ASSET_AMOUNT_MEM_ADDR_0 = 548
const OUTPUT_NOTE_ASSET_AMOUNT_MEM_ADDR_1 = 552
const OUTPUT_NOTE_SCALED_AMOUNT_MEM_ADDR = 575
const OUTPUT_NOTE_ASSET_AMOUNT_MEM_ADDR_0 = 552
const OUTPUT_NOTE_ASSET_AMOUNT_MEM_ADDR_1 = 556

const ORIGIN_TOKEN_ADDRESS_0 = 541
const ORIGIN_TOKEN_ADDRESS_1 = 542
const ORIGIN_TOKEN_ADDRESS_2 = 543
const ORIGIN_TOKEN_ADDRESS_3 = 544
const ORIGIN_TOKEN_ADDRESS_4 = 545

const DESTINATION_ADDRESS_0 = 547
const DESTINATION_ADDRESS_1 = 548
const DESTINATION_ADDRESS_2 = 549
const DESTINATION_ADDRESS_3 = 550
const DESTINATION_ADDRESS_4 = 551

const SCALED_ASSET_AMOUNT_MEM_ADDR = 575

# P2ID output note constants
const P2ID_SCRIPT_ROOT = [13362761878458161062, 15090726097241769395, 444910447169617901, 3558201871398422326]
Expand All @@ -46,6 +69,7 @@ const P2ID_OUTPUT_NOTE_AMOUNT_MEM_PTR = 611
# =================================================================================================

const ERR_INVALID_CLAIM_PROOF = "invalid claim proof"
const ERR_ORIGIN_ADDRESSES_MISMATCH = "origin token addresses do not match"

#! Inputs: [PROOF_DATA_KEY, LEAF_DATA_KEY]
#! Outputs: []
Expand All @@ -57,6 +81,10 @@ const ERR_INVALID_CLAIM_PROOF = "invalid claim proof"
#!
#! Invocation: exec
proc validate_claim
# Check origin token address matches storage origin address
exec.assert_origin_address_eq_storage_address
# => [PROOF_DATA_KEY, LEAF_DATA_KEY]

# Get bridge_in::check_claim_proof procedure MAST root
procref.bridge_in::check_claim_proof
# => [BRIDGE_PROC_MAST_ROOT]
Expand All @@ -81,11 +109,82 @@ proc validate_claim
# => []
end


#! Verifies that the origin token address from the claim matches the stored origin token address.
#!
#! This procedure loads the origin token address from the claim data in memory and compares it
#! against the origin token address stored in the faucet's metadata storage slots. All 5 u32
#! limbs of the address must match exactly.
#!
#! Inputs: []
#! Outputs: []
#!
#! Panics if:
#! - any of the 5 u32 limbs of the origin token address do not match.
#!
#! Invocation: exec
proc assert_origin_address_eq_storage_address
mem_load.ORIGIN_TOKEN_ADDRESS_0
mem_load.ORIGIN_TOKEN_ADDRESS_1
mem_load.ORIGIN_TOKEN_ADDRESS_2
mem_load.ORIGIN_TOKEN_ADDRESS_3
mem_load.ORIGIN_TOKEN_ADDRESS_4
# => [ORIGIN_TOKEN_ADDRESS_CLAIM[5]]
Copy link
Contributor

Choose a reason for hiding this comment

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

Relying on memory layout in this way feels a bit fragile to me. I'd try to make this procedure a bit more stateless. One approach is to pass in the memory pointer to where the token address is stored as an input - i.e., something like:

#! Inputs:  [token_address_ptr]
#! Outputs: []
proc assert_origin_address_eq_storage_address
    padw dup.4 mem_loadw_be
    movup.4 add.4 mem_load

    ...
end

This would take a few more cycles, but I don't think that's an issue.


exec.get_origin_token_address
# => [ORIGIN_TOKEN_ADDRESS[5], ORIGIN_TOKEN_ADDRESS_CLAIM[5]]

movup.5 assert_eq.err=ERR_ORIGIN_ADDRESSES_MISMATCH
movup.4 assert_eq.err=ERR_ORIGIN_ADDRESSES_MISMATCH
movup.3 assert_eq.err=ERR_ORIGIN_ADDRESSES_MISMATCH
movup.2 assert_eq.err=ERR_ORIGIN_ADDRESSES_MISMATCH
assert_eq.err=ERR_ORIGIN_ADDRESSES_MISMATCH
# => []
end

#! Reads the origin token address from the aggfaucet metadata storage slots.
#!
#! Inputs: []
#! Outputs: [origin_token_addr[0], origin_token_addr[1], origin_token_addr[2], origin_token_addr[3], origin_token_addr[4]]
#!
#! Invocation: exec
proc get_origin_token_address
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe not for this PR, but I'd make this procedure a part of the public interface. Since public interface procedures need to be invoked via the call instruction, we'd need to have two procedures:

  • This one, which I'd rename into something like get_origin_token_address_internal.
  • The public procedure which would handle the padding and then call this procedure.

Comment on lines +145 to +151
Copy link
Collaborator

Choose a reason for hiding this comment

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

These changes don't seem related to how CLAIM note handles scaling down - ideally would have been a separate PR

# Get first word: [tok1, tok2, tok3, tok4]
push.AGGFAUCET_METADATA_SLOT_0[0..2]
exec.active_account::get_item
# => [tok1, tok2, tok3, tok4]

# Get second word: [0, 0, scaling_factor, tok0]
push.AGGFAUCET_METADATA_SLOT_1[0..2]
exec.active_account::get_item
drop drop drop
# => [tok0, tok1, tok2, tok3, tok4]
end

#! Reads the scaling factor from the aggfaucet metadata storage slot.
#!
#! Inputs: []
#! Outputs: [scaling_factor]
#!
#! Invocation: exec
proc get_scaling_factor
# Get second word: [tok4, scaling_factor, 0, 0]
push.AGGFAUCET_METADATA_SLOT_1[0..2]
exec.active_account::get_item
# => [ 0, 0, scaling_factor, tok4]

drop drop swap drop
# => [scaling_factor]
end

# Inputs: []
# Outputs: [U256[0], U256[1]]
proc get_raw_claim_amount
padw mem_loadw_be.OUTPUT_NOTE_ASSET_AMOUNT_MEM_ADDR_0
padw mem_loadw_be.OUTPUT_NOTE_ASSET_AMOUNT_MEM_ADDR_1
exec.word::reverse

padw mem_loadw_be.OUTPUT_NOTE_ASSET_AMOUNT_MEM_ADDR_0
exec.word::reverse
end

# Inputs: [U256[0], U256[1]]
Expand All @@ -94,12 +193,6 @@ proc scale_down_amount
repeat.7 drop end
end

# Inputs: []
# Outputs: [prefix, suffix]
proc get_destination_account_id
mem_load.543 mem_load.544
end

# Inputs: [PROOF_DATA_KEY, LEAF_DATA_KEY, OUTPUT_NOTE_DATA_KEY]
# Outputs: []
proc batch_pipe_double_words
Expand Down Expand Up @@ -128,6 +221,27 @@ proc batch_pipe_double_words
exec.mem::pipe_double_words_preimage_to_memory drop
end

#! Extracts the destination account ID as address[5] from memory.
#!
#! This procedure reads the destination address from the leaf data and converts it from
#! Ethereum address format to AccountId format (prefix, suffix).
#!
#! Inputs: []
#! Outputs: [prefix, suffix]
#!
#! Invocation: exec
proc get_destination_account_id_data
mem_load.DESTINATION_ADDRESS_4
mem_load.DESTINATION_ADDRESS_3
mem_load.DESTINATION_ADDRESS_2
mem_load.DESTINATION_ADDRESS_1
mem_load.DESTINATION_ADDRESS_0
# => [address[5]]

exec.eth_address::to_account_id
# => [prefix, suffix]
end

#! Builds a P2ID output note for the claim recipient.
#!
#! This procedure expects the claim data to be already written to memory via batch_pipe_double_words.
Expand All @@ -149,15 +263,16 @@ proc build_p2id_output_note
push.P2ID_NOTE_NUM_STORAGE_ITEMS
# => [note_num_storage_items, SERIAL_NUM, SCRIPT_ROOT]

exec.get_destination_account_id
# => [account_id_prefix, account_id_suffix, note_num_storage_items, SERIAL_NUM, SCRIPT_ROOT]

mem_store.0 mem_store.1
# => [note_num_storage_items, SERIAL_NUM, SCRIPT_ROOT]

push.OUTPUT_NOTE_INPUTS_MEM_ADDR
# => [storage_ptr = 0, note_num_storage_items, SERIAL_NUM, SCRIPT_ROOT]

exec.get_destination_account_id_data
# => [prefix, suffix]

# Write destination account id into memory
mem_store.1 mem_store.0
# => []

exec.note::build_recipient
# => [RECIPIENT]

Expand All @@ -167,11 +282,17 @@ proc build_p2id_output_note
mem_load.OUTPUT_NOTE_TAG_MEM_ADDR
# => [tag, RECIPIENT]

mem_load.SCALED_ASSET_AMOUNT_MEM_ADDR
# => [amount, scale_exp, tag, RECIPIENT]

exec.get_scaling_factor
# => [scale_exp, tag, RECIPIENT]

exec.get_raw_claim_amount
# => [AMOUNT[1], AMOUNT[0], tag, note_type, RECIPIENT]
# => [AMOUNT[0], AMOUNT[1], amount, scale_exp, tag, note_type, RECIPIENT]

# TODO: implement scale down logic; stubbed out for now
exec.asset_conversion::scale_u256_to_native_amount
# Check that provided bridge amount is valid conversion from EVM amount
exec.asset_conversion::verify_u256_to_native_amount_conversion
# => [amount, tag, note_type, RECIPIENT]

exec.faucets::distribute
Expand Down Expand Up @@ -208,12 +329,13 @@ end
#! destinationAddress[5], // Destination address (5 felts, address as 5 u32 felts)
#! amount[8], // Amount of tokens (8 felts, uint256 as 8 u32 felts)
#! metadata[8], // ABI encoded metadata (8 felts, fixed size)
#! EMPTY_WORD // padding
#! ],
#! OUTPUT_NOTE_DATA_KEY => [
#! output_p2id_serial_num[4], // P2ID note serial number (4 felts, Word)
#! agglayer_faucet_account_id[2], // Agglayer faucet account ID (2 felts, prefix and suffix)
#! output_note_tag[1], // P2ID output note tag
#! scaled_bridged_amount[1], // Scaled bridged amount (quotient from amount / 10^scale_exp)
#! padding[1], // padding (1 felt)
#! ]
#! }
#!
Expand Down
Loading
Loading