feat(AggLayer bridge-out e2e #1): process bridging-out data and load LeafData to memory#2425
Conversation
LeafData to memory
1266876 to
8303a1a
Compare
4bf984c to
e8c4306
Compare
The add.N values should all be add.1 (incrementing the running pointer by 1 each time), not add.1, add.2, add.3, add.4 which caused addresses to skip (P, P+1, P+3, P+6, P+10 instead of P, P+1, P+2, P+3, P+4). Also includes byte-order fixes (u256_le_to_abi, swap_u32_bytes for originNetwork and leafType) and test infrastructure for verifying the root against Solidity vectors. Status: the MMR root computation via call is verified correct (test_mmr_append_via_call passes). The write_address_to_memory fix changed the bridge_out root. Still investigating a remaining mismatch related to u256_le_to_abi + mem_store_double_word_unaligned interaction. Co-authored-by: marti <marti@hungrycats.studio>
Apply suggestions from code review Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
8303a1a to
c011f8d
Compare
LeafData to memoryLeafData to memory
| pub proc reverse_limbs_and_change_byte_endianness | ||
| # reverse the felts within each word | ||
| # [a, b, c, d, e, f, g, h] -> [h, g, f, e, d, c, b, a] | ||
| exec.word::reverse | ||
| swapw | ||
| exec.word::reverse | ||
|
|
||
| # change the byte endianness of each felt | ||
| repeat.8 | ||
| exec.utils::swap_u32_bytes | ||
| movdn.7 | ||
| end | ||
|
|
||
| # => [RESULT_U256[0], RESULT_U256[1]] | ||
| end |
There was a problem hiding this comment.
Very important procedure to convert from big endian limbs, little endian byte order, to little endian limbs big endian byte order.
I wonder if this procedure should be in the VM standard library?
| # TODO construct metadata hash | ||
| padw padw |
There was a problem hiding this comment.
This is part of B2AGG NoteStorage right?. Is it difficult to load these values here? Or is this for a follow up PR?
There was a problem hiding this comment.
Metadata can be constructed directly inside this procedure. I opened a tracking issue: #2453
| #! | ||
| #! Inputs: [WORD_1, WORD_2, ptr] | ||
| #! Outputs: [] | ||
| pub proc mem_store_double_word_unaligned( |
There was a problem hiding this comment.
Also make me wonder, shouldn't this be a VM std procedure? But lets do this later once everything is working end to end.
partylikeits1983
left a comment
There was a problem hiding this comment.
Looks great! Super useful procedures here! reverse_limbs_and_change_byte_endianness is super valuable.
LeafData to memoryLeafData to memory
…ry (0xMiden#2425) * chore: unify b2agg note storage layout with claim note * chore: clarify destinationAddress in CLAIM note * feat: mem_store_double_word_unaligned * feat: compute leaf value for bridging out * chore: update comment about origin network ID * fix: write_address_to_memory had incorrect address arithmetic The add.N values should all be add.1 (incrementing the running pointer by 1 each time), not add.1, add.2, add.3, add.4 which caused addresses to skip (P, P+1, P+3, P+6, P+10 instead of P, P+1, P+2, P+3, P+4). Also includes byte-order fixes (u256_le_to_abi, swap_u32_bytes for originNetwork and leafType) and test infrastructure for verifying the root against Solidity vectors. Status: the MMR root computation via call is verified correct (test_mmr_append_via_call passes). The write_address_to_memory fix changed the bridge_out root. Still investigating a remaining mismatch related to u256_le_to_abi + mem_store_double_word_unaligned interaction. Co-authored-by: marti <marti@hungrycats.studio> * fix: handling of dest address and ID in B2AGG * feat: reverse_limbs_and_change_byte_endianness * chore: integrate byte and limb swapping to bridging * fix: swap origin net ID endianness; rearrange mem writes Apply suggestions from code review Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * chore: pad mem with zeros after metadata --------- Co-authored-by: Cursor Agent <cursoragent@cursor.com> Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Builds on top of #2413 in the following way:
get_leaf_valueto first load the data from advice provider to memory, and then call another exposed procedurecompute_leaf_valuewhich operates on data in memorycompute_leaf_valueis then re-used for bridging-out, which also needs to hash data in the same leaf format and obtain the leaf valueOther than that, this PR carries the following changes and be reviewed independently of #2413:
bridge_outprepares the data and stores it to appropriate memory locationsLEAF_TYPE_ASSETadd_leaf_bridgeto mimic AggLayer Solidity contractsadd_leaf_bridgedoes two things:compute_leaf_valueAggLayerBridgecontract and update it uponB2AGGconsumption #2424)