-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Description
System design: https://excalidraw.com/#json=curpA9Oidkvos4QTQHqET,KHZ4Y8j9aN3HbSmJ6N-kyw
Send flow
- 1. GraphQL (GQL from here on) endpoint for users to initiate send (I (
sender) want to sendxeth toreceiver) user_balance db #3. - 2. Check user balance is enough user_balance db #3.
- a. Create a SQL table
user_bal: (address, balance) - b. Query that
sender.balance >= xuser_balance db #3 .
- a. Create a SQL table
- 3. Find relevant leaves in
state merkle tree: Givensenderandxeth, find the leaves owner bysenderin merkle tree that have total balance >=xeth. - 4. Prepare message for
senderauthorization and reply to the GQL request with these messages. - 5. Send API to receive the leaf, coin and receiver info along with signature from sender add pre-image table with merkle tree #5 update pmtree dependency to arcpay org #7.
- 6. validate signature, update merkle tree, fetch merkle proofs add proofs to queue message #8.
- 7. Enqueue all information in "send request queue" add proofs to queue message #8.
- 8. API receive an ACK from queue and returns promise to the caller.
- 9. Collect
nmessages from queue and batch prove them. - 10. Validate these messages.
- 11. Update the state of a "proven merkle tree" after these
nmessages. - 12. Create a transaction object and call an Owner to sign it.
- 13. Broadcast this tx on chain.
Mint flow
- watch mint events.
- update "state merkle tree".
- push event to queue.
Withdraw flow
- API
- Update merkle tree and send to queue.
- Consume the message, prove it, and update the proven merkle tree.
Proving remains a blocker.
Metadata
Metadata
Assignees
Labels
No labels