-
Notifications
You must be signed in to change notification settings - Fork 97
Open
Open
Copy link
Description
What should be done?
B2AGG (Bridge-to-AggLayer) note
This issue is to outline the implementation of the B2AGG note: a note that contains a single asset and which calls the call.bridge::bridge_asset_out of the AggLayerBridgeOut contract.
This PR is intended to be small and to be the first step in the implementation of the AggLayerBridgeOut contract. The PR that implements the functionality defined in the issue will be to the agglayer branch, not next.
Resolves #1898
Scope:
- Implement the note script
- wire it to a stubbed out bridge procedure
bridge::bridge_asset_out(no faucet/exit-tree implementation yet) - make the note reclaimable
- Add a minimal test of executing the
B2AGGnote against the stubbed outAggLayerBridgeOutcontract.
Behavior
-
B2AGG note must carry exactly one asset (fungible for now).
-
Note inputs:
destination_network: u32(AggLayer-assigned network ID)destination_address: 20 bytes(Ethereum address of recipient)
-
Script:
- Validates exactly 1 asset is present.
- Loads the single asset.
- Calls stub
bridge::bridge_asset_out. - Note is reclaimable.
B2AGG MASM skeleton
use.miden::note
use.miden::contracts::agglayer::bridge
const.ERR_B2AGG_WRONG_NUMBER_OF_ASSETS="B2AGG script requires exactly 1 note asset"
#! Inputs: [destination_network(u32), destination_address(20 bytes as words)]
#! Outputs: []
#!
begin
# Check if reclaim
exec.account::get_id
# => [account_id_prefix, account_id_suffix]
exec.input_note::get_sender
# => [sender_id_prefix, sender_id_suffix, account_id_prefix, account_id_suffix]
exec.account_id::is_equal
# => [reclaim]
if.true
exec.active_note::add_assets_to_account
# => []
else
# Store number of note assets -> mem[0]
push.0 exec.active_note::get_assets
# => [num_assets, ptr]
# Must be exactly 1 asset
assert.err=ERR_B2AGG_WRONG_NUMBER_OF_ASSETS
# => [ptr]
# Load ASSET onto the stack
mem_loadw
# => [ASSET, destination_network, DESTINATION_ADDRESS]
# Hand-off to stubbed bridge call
call.bridge::bridge_asset_out
# => []
end
# => []
end
How should it be done?
Once the functionality in this PR is implemented it should be merged to the agglayer branch.
When is this task done?
When the B2AGG note is complete and a basic test of it being consumed is implemented using the stubbed out bridge::bridge_asset_out procedure.
Additional context
No response