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

Add The Federation Layer #601

Closed
wants to merge 25 commits into from
Closed

Conversation

Reckless-Satoshi
Copy link
Collaborator

@Reckless-Satoshi Reckless-Satoshi commented May 19, 2023

follow up of #380. This PR squashes and rebases over main the-federation-layer branch
All API pre-requisites are already merged in Main. This PR contains only frontend changes

What does this PR do?

This PR brings to main the experimental fork The Federation Layer. We will keep it open as a draft for some time to track progress. We will certainly keep it away from main until well tested with a bunch of Testnet voluntary coordinators.

For context read the Issue where the RoboSats Federation concept was introduced #228

Tasks towards RoboSats Federation Minimum Viable Product:

Frontend:

  • Read from static/federation.json the list of RoboSats coordinators and their .onion addresses.
  • Build Coordinator Dialog with a profile of each coordinator. Optionally, make it cool and add coordinator badges.
  • Build Coordinator table (keep it in the Settings tab)
  • Refactor Stats dialogs to show aggregated stats for all active coordinators (volume, premium, etc).
  • Create Context high level functions and abstractions of the federation.
  • Book page requests all orders from all coordinators. Shows each row on coordinator's color as well as the coordinator logo. Book page allows for filtering by Federation member.
  • If a user clicks on the order of another coordinator, it should trigger an api/usergen/ request (so that Robot / Avatar / Token hash / PGP pubkey and encPrivKey exists as well on the coordinator's database). EDIT: new middleware will generate robots in the fly if auth token (SHA256(robot_token)) does not exist. New endpoint "Robot" to fetch existing robot nickname, pubkey, etc.
  • Everything else in the trade pipeline remains the same. However the /order/ API requests will be made to that order's coordinator .onion address.
  • Each coordinator, on its hosted frontend should be able to opt-in and out of showing other coordinators orders. They can do so by editing the static file they host in static/federation.json.
  • Use paths for each coordinator. E.g. ...robosats.onion/order/coordinator_shortname/21
  • Add a "select host" dropdown in the MakerForm
  • Add a new Setting "Number of active coordinators" to select how many coordinators to use at once. Default to 5. Users can increase them at the cost of UI performance.
  • At startup coordinators will be selected ranked 1 to N, the rank will be probabilistically linked to the devfund donation (%) of the coordinator. The top K (default 5) will be selected. Orders in the order book will be sorted by coordinator rank by default. This is the only patron perk so far designed to reward those coordinators contributing to RoboSats development.
  • If selfhosted, use the same "local" endpoint for every coordinator, yet a different path using the coordinator shortname. E.g. ".../api/coordinator_shortname/order/...".On nodeapp, spawan a socat bridge for each Coordinator Onion address and write nginx config to proxy each API subpath to the coordinator onion endpoint.
  • Optional - Low priority On the coordinator table, add tools for users to delete/add coordinators using a form (issue: these are forgotten in browsers that do not keep local storage after restart. This will work just fine on Android app).
  • Optional - Needs research At the end of a trade, the user rates the coordinator (instead of "What do you think of RoboSats?"). The order ID, rating and coordinator alias is sent to every Federation member. The ratings will help keep coordinators informed about their own performance and other federation members performance. It will allow for sorting access to coordinator addresses in the docs / github / frontends according to some non-arbitrary criteria.

Backend:

  • Allow CORS. Let other origins make calls to coordinator API.
  • Upgrade authentication. Replace SessionID + CSRF token for only robot hash token on every authenticated request. Implement middleware that creates user+profile+avatar entries on first authenticated request with a robot token hash not seen before.
  • Deprecate /user/ POST.
  • Anyone with the hash of a robot token could send authenticated requests (e.g, another coordinator could MITM attack a user on another coordinator). Solution: robot submits his pubkey on first authenticated requests, then every next requests must be pgp signed?
  • Delete current rewards program (hard to fit on a multi-coordinator set up. There are ways, but this is to be explored in the future).
  • Implement compute_trade_proceeds() on each trade finished. Implement Keysend feature for Dev donations.
  • Limit Coordinator devfund donation to 49% of trade proceeds.
  • Optional - Needs research coordinators backend could periodically fetch stats from other coordinators and "keep them in check". E.g. a coordinator might not want to show in its frontend orders of Federation members whose LN node is down, whose trade fee is very large, not contributing Sats to the dev fund, etc.

Other:

  • Write up FEDERATION.md base guide/ruleset document.
  • Build and release docker-compose orchestration.
  • Build and release kubernetes RoboSats orchestration.

@Reckless-Satoshi Reckless-Satoshi mentioned this pull request May 19, 2023
23 tasks
@Reckless-Satoshi Reckless-Satoshi force-pushed the the-federation-layer-v0.5.0 branch 5 times, most recently from 08efdd5 to b1fa15d Compare May 25, 2023 10:38
@Reckless-Satoshi Reckless-Satoshi force-pushed the the-federation-layer-v0.5.0 branch 2 times, most recently from 0487e6f to 024a514 Compare June 6, 2023 11:15
@Reckless-Satoshi Reckless-Satoshi force-pushed the the-federation-layer-v0.5.0 branch 3 times, most recently from 5cfaa18 to 04d253a Compare July 27, 2023 13:01
@Reckless-Satoshi Reckless-Satoshi force-pushed the the-federation-layer-v0.5.0 branch 7 times, most recently from 799de0e to 5c1da7e Compare August 13, 2023 14:01
@Reckless-Satoshi Reckless-Satoshi force-pushed the the-federation-layer-v0.5.0 branch 2 times, most recently from 96ebe99 to f5fe224 Compare August 17, 2023 11:51
Reckless-Satoshi and others added 25 commits September 25, 2023 04:05
* Add new coordinator entry issue form

* Add Federation basis
* Squash and rebase the-federation-layer over main v0.5.0

* Refactor fetchRobot for multi-coordinator set up

* Add RobotInfo per coordinator

* Small cosmetic fixes
* Fix lint errors

* Fix more linting issues

* Fix more linting issues

* Fix more linting issues

* Fix more linting issues

* Fix more linting issues

* Fix more linting issues

* Fix more linting issues

* Fix more linting issues

* Fix more linting issues

* Fix more linting issues

* Fix more linting issues, only 1 left

* Last fix
@Reckless-Satoshi
Copy link
Collaborator Author

Closing, follow up on v0.6.0 PR #922

@Reckless-Satoshi Reckless-Satoshi deleted the the-federation-layer-v0.5.0 branch February 12, 2024 00:20
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

Successfully merging this pull request may close these issues.

1 participant