Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Meta issue #2

Open
15 of 21 tasks
0xbok opened this issue Jul 14, 2023 · 1 comment
Open
15 of 21 tasks

Meta issue #2

0xbok opened this issue Jul 14, 2023 · 1 comment

Comments

@0xbok
Copy link
Member

0xbok commented Jul 14, 2023

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 send x eth to receiver) 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 >= x user_balance db #3 .
  • 3. Find relevant leaves in state merkle tree: Given sender and x eth, find the leaves owner by sender in merkle tree that have total balance >= x eth.
  • 4. Prepare message for sender authorization 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 n messages from queue and batch prove them.
  • 10. Validate these messages.
  • 11. Update the state of a "proven merkle tree" after these n messages.
  • 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.

@0xbok
Copy link
Member Author

0xbok commented Jul 23, 2023

arcpay-server-design

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant