Galileo Daras
    • Create new note
    • Create a note from template
      • Sharing URL Link copied
      • /edit
      • View mode
        • Edit mode
        • View mode
        • Book mode
        • Slide mode
        Edit mode View mode Book mode Slide mode
      • Customize slides
      • Note Permission
      • Read
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Write
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Engagement control Commenting, Suggest edit, Emoji Reply
    • Invite by email
      Invitee

      This note has no invitees

    • Publish Note

      Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

      Your note will be visible on your profile and discoverable by anyone.
      Your note is now live.
      This note is visible on your profile and discoverable online.
      Everyone on the web can find and read all notes of this public team.
      See published notes
      Unpublish note
      Please check the box to agree to the Community Guidelines.
      View profile
    • Commenting
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
      • Everyone
    • Suggest edit
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
    • Emoji Reply
    • Enable
    • Versions and GitHub Sync
    • Note settings
    • Note Insights New
    • Engagement control
    • Make a copy
    • Transfer ownership
    • Delete this note
    • Save as template
    • Insert from template
    • Import from
      • Dropbox
      • Google Drive
      • Gist
      • Clipboard
    • Export to
      • Dropbox
      • Google Drive
      • Gist
    • Download
      • Markdown
      • HTML
      • Raw HTML
Menu Note settings Note Insights Versions and GitHub Sync Sharing URL Create Help
Create Create new note Create a note from template
Menu
Options
Engagement control Make a copy Transfer ownership Delete this note
Import from
Dropbox Google Drive Gist Clipboard
Export to
Dropbox Google Drive Gist
Download
Markdown HTML Raw HTML
Back
Sharing URL Link copied
/edit
View mode
  • Edit mode
  • View mode
  • Book mode
  • Slide mode
Edit mode View mode Book mode Slide mode
Customize slides
Note Permission
Read
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Write
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Engagement control Commenting, Suggest edit, Emoji Reply
  • Invite by email
    Invitee

    This note has no invitees

  • Publish Note

    Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

    Your note will be visible on your profile and discoverable by anyone.
    Your note is now live.
    This note is visible on your profile and discoverable online.
    Everyone on the web can find and read all notes of this public team.
    See published notes
    Unpublish note
    Please check the box to agree to the Community Guidelines.
    View profile
    Engagement control
    Commenting
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    • Everyone
    Suggest edit
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    Emoji Reply
    Enable
    Import from Dropbox Google Drive Gist Clipboard
       Owned this note    Owned this note      
    Published Linked with GitHub
    • Any changes
      Be notified of any changes
    • Mention me
      Be notified of mention me
    • Unsubscribe
    # Orb Supervisor Paradigm (Draft) Ensure Orb functionality is split out and siloed. The goal is to minimize impact on signups by preventing failures in less importants parts of the orb stack to cascade to the critical signup path. ## Motivation The monolithic approach of orb-core allows for crashes from areas that aren't in the critical path of a signup to nevertheless impact a signup. In the short to medium term on-orb signup complexity will increase drastically with the addition of signup extensions, fraud detection models, and multiple gabor identifiers. There is a growing need to clearly distinguish between what is *critical* to pushing a signup as successful, and what is not. ### Process coordination In addition, there is an immediate need for both interprocess communication and execution coordination between the _`update-agent`_\* (responsible for OTA updates) and orb-core. These processes need to be able to coordinate to avoid CAN line saturation or restarts in the middle of an update. When a security-critical update is pushed, we need to ensure that signups are restricted and, if an orb has just powered on, that orb-core isn't and will not be started until the security update has been applied. ### Faster UX development Restructuring the on-orb stack will allow writing a independent UX-server that listens to events from Orb-core and, based on those, decides to play sounds or change LEDs. Because feedback loops and iteration cycles for UX will likely be much shorter than orb-core development this means that we can spin up a team that can work without affecting orb-core. ### Open sourcing Open-sourcing our on-orb software is on the roadmap for 2022 and is something we publicly committed to. Releasing the orb-core mono-repo would likely not be feasible before a full audit, given the largely interconnected nature of all the pieces therein. As we look to bolster hiring and find goodwill with skeptics of the project, open-sourcing may turn out to be a critical piece in those processes. ### Integration testing Integration-testing on-and-off the orb is made tricky by the inclusion of many `bindgen` C-bindings for various libraries in orb-core. To do an integration test of various pieces of orb-core (which might have mock-able inputs), one needs to bring in a number of dependencies and pre-requisites which may not have a direct impact or bearing on the piece to be tested. Specifically, there isn't anything that intrinsically couples the presence of real cameras or a real face to the testing of the signup UX flow. Rather, this is linked simply by project structure. > Comment: (Necessary?) Siloing functionality and opening the door for rapid integration testing/prototyping could prove to be powerful assets in the coming sprints as we attempt to stabilize and "professionalize" the signup flow. The uses cases around splitting functionality are largely to do with UX and stability, but by introducing standalone processes as first-class projects with well-maintained support we might see new ideas and extensions come into existence in the future. ## Guide-level explanation ### Siloed components Creating a siloed component involves connecting and registering itself on the IPC bus, and registering for any signals/events it's interested in. ```rust /// Receiving "signup finished" events. /// /// This is all pseudo-code intended to strike a balance between the mentioned IPC bus solutions /// to avoid biasing strongly one way or another. This API _does not exist_ as written below. fn main() -> Result<()> { // ... let subscriber = Bus::connect(Type::SUB, "org.worldcoin.bus1")?; subscriber.subscribe(vec![Topics::SIGNUP])?; let start = Instant::now(); loop { let event = TryInto::<Event>::try_into(subscriber.recv()?); match event { Event::SignupFinished(success) if success => println!("signup finished successfully!"), Event::SignupFinished(_) => println!("signup failed :("), _ => {}, }; if Instant::now().duration_since(start) >= Duration::from_secs(10) { break; } } } ``` #### Event publishing We use a bus to support easy extensions without significant modifications to existing processes and projects. This allows for greater composability when testing, and when writing for the first time. On the sending side, we want to ensure that we only notify when there has been a state transition: ```rust /// Though variable across actual IPC bus implementations, in our example the publisher is not /// required to register process-specific events. This means that, in theory, any process could /// publish any event. /// /// We consider this approach reasonable in a highly-collaborative environment but it should be /// understood that such a compromise may not scale with team-size nor outside the organization. async fn main() -> Result<()> { let publisher = Bus::connect(Type::PUB, "org.worldcoin.bus1")?; select! { result = core::run_signup() => { publisher.publish(Topics::SIGNUP, Event::SignupFinished(result.is_ok())?; // ... do real post-signup cleanup } } } ``` #### Event design By notifying as early into the state change as possible, we give the other components a better chance to properly respond to the state change in a timely fashion. This implements and covers a key point: *events should convey the minimal information necessary to act upon it*. With careful event design, we discourage remote process calls and avoid strict dependence on foreign APIs. An example of this is the intentional decision to **not** include "LedState" events wherein another process might try to publish an "LedState" event and have the `led-server` subscribe to such a topic and perform operations accordingly. This violates the separation of active "Messages" (which this RFC makes no attempt to include or define) from "passive 'Events'". ### Systemd We use systemd to manage standalone processes and register their initialization. Most services will depend only on the presence of the event bus. Referring back to the first example for a simple "signup finished" listener program, the service file might look something like: ``` [Unit] Description=Worldcoin Signup Finished-listener After=worldcoin-supervisor.service Requires=worldcoin-supervisor.service [Service] Type=simple ExecStart=/usr/local/bin/signup-finished-listener SyslogIdentifier=worldcoin-signup-finished-listener Restart=on-failure [Install] WantedBy=multi-user.target ``` #### Let's add a party LED mode - i want to implement a special UI control if someone taps the button 5 times - pull in `zbus` + our `can-rs` - open receive loop to receive `button pressed` message from MCU - (isotp) open listen-mode ISO-TP stream on broadcast address - (canfd) open `FrameStream` with the broadcast filter - connect to the supervisor bus (maybe the system bus?) - (dbus) call the LED interface methods - (generic bus) publish a `set LEDs (medium priority)` message - **behind the scenes** - (isotp) the `isotp-courier` process manages the flow-control for receiving content - (all bus systems) the orb-supervisor initializes the bus to connect to at startup - the LED UX process receives the message on the bus and, if not in the middle of a higher-priority task will execute the `set LEDs` instruction ## Reference-level explanation Major orb-core restructuring is necessary to move UX handling over to the event bus. There are two main support components to enable this extraction: - IPC event bus library - CAN library stabilization With the supporting components mentioned above, the audio and LED management are split into their own processes started and managed my `systemd`. These both subscribe to `update-agent` and `orb-core` events. Strict adherence to the notion of "passive 'Events'" hands off arbitration of priority entirely to the implementing processes. The `orb-supervisor` is concerned with three tasks: - Dbus private-bus registration - `update-agent` <-> `orb-core` execution coordination - `update-agent` & `orb-core` shutdown coordination #### Dbus for IPC event bus Dbus supports pub/sub events through the "signals" interface. Processes register themselves and their signals with the *worldcoin private bus* initialized by `zbus`. Using Dbus reduces the dependency complexity and could have huge gains in implementing IPC outside of the worldcoin private bus, extending into systemd state querying, NetworkManager communication, and more. #### CAN communication + ISO-TP CAN communications remain almost entirely unchanged. The only exception is a good-tenant expectation when working with the *broadcast* ISO-TP stream. All processes that engage with the *broadcast* ISO-TP stream do so in *LISTEN_MODE*, which disables the sending of Flow Control frames when receiving. This works in combination with an `isotp-manager` which holds open a non-*LISTEN_MODE* ISO-TP stream on the *broadcast* IDs, so that only one stream sends the Flow Control frames\*. ## Drawbacks When using a daemon-based bus, "Event" transmission is guaranteed to be slower than a similar IPC solution without a centralized bus. The hope and intention of introducing events at the same time as we split apart functionality was to lessen this impact. This means that--for example-- highly complicated LED patterns can still be used because there isn't a round-trip IPC action for every "Set LED" message. That being said, we may see this break down as more work is done in this system. This IPC implementation does not cover all of the current IPC needs. As an example, the execution of PyCUDA-related tasks (python execution of ML models) are time-sensitive and do not fit in this paradigm. We generally consider this okay, and encourage processes with latency-sensitive aspects to pull them directly into their immediate execution context. However, this means that we will need to maintain different IPC systems at the same time. ## Rationale and Alternatives - Choosing Dbus for our main IPC event bus library allows us to leverage software that has been thoroughly battle-tested, and does not require us to re-implement an IPC library on top of Unix Domain Sockets or work with less actively maintained libraries. There have also been recent efforts to shed some of the legacy baggage of Dbus, and ChromeOS has published their "Dbus best practices" document. Finally, the `zbus` Rust bindings for Dbus are actively maintained and very intentionally thought-out to make the huge complexity of Dbus' features manageable. **However** - Dbus suffers from even more overhead than other IPC solutions due to it's self-proclaimed aim to be a batteries-included, all-in-one Linux IPC solution. **The main alternative to Dbus--investigated in the writing of this RFC-- is ZeroMQ**. ZeroMQ is extremely light-weight, similarly well-maintained, and the Rust bindings are similarly reasonable (although we would have to implement the serialization and deserialization to strings ourselves). - Dbus' API, even with `zbus`, is very complicated when compared with other IPC solutions. The reliance on procedural macros would make auditing Dbus-reliant processes very difficult (?). Generally, the design is reminiscent of Java Spring - Splitting apart "functionality-isolated" components both at the process level and at the code level addresses many of the pain-points and motivations described in the "Motivations" section. However, there is already work being done on the process-isolation front within orb-core, as well as already-written examples of independant binary generation. While open-sourcing may still be effected, the solutions put forth in this RFC are not **strictly necessary** to lessen the impact of, for example, the audio device failing during a signup. ## Notable Mentions - dbus-broker(1) - cargo-generate - zbus - nng-rs - nng ipc (https://nng.nanomsg.org/man/tip/nng_ipc.7.html) - grpc latency (https://www.mpi-hd.mpg.de/personalhomes/fwerner/research/2021/09/grpc-for-ipc/) - chromeos dbus best practices (https://chromium.googlesource.com/chromiumos/docs/+/2efe4b73ea2109870480a3d6148024686faf1e6e/dbus_best_practices.md#Avoid-depending-heavily-on-D_Bus_specific-concepts)

    Import from clipboard

    Paste your markdown or webpage here...

    Advanced permission required

    Your current role can only read. Ask the system administrator to acquire write and comment permission.

    This team is disabled

    Sorry, this team is disabled. You can't edit this note.

    This note is locked

    Sorry, only owner can edit this note.

    Reach the limit

    Sorry, you've reached the max length this note can be.
    Please reduce the content or divide it to more notes, thank you!

    Import from Gist

    Import from Snippet

    or

    Export to Snippet

    Are you sure?

    Do you really want to delete this note?
    All users will lose their connection.

    Create a note from template

    Create a note from template

    Oops...
    This template has been removed or transferred.
    Upgrade
    All
    • All
    • Team
    No template.

    Create a template

    Upgrade

    Delete template

    Do you really want to delete this template?
    Turn this template into a regular note and keep its content, versions, and comments.

    This page need refresh

    You have an incompatible client version.
    Refresh to update.
    New version available!
    See releases notes here
    Refresh to enjoy new features.
    Your user state has changed.
    Refresh to load new user state.

    Sign in

    Forgot password

    or

    By clicking below, you agree to our terms of service.

    Sign in via Facebook Sign in via Twitter Sign in via GitHub Sign in via Dropbox Sign in with Wallet
    Wallet ( )
    Connect another wallet

    New to HackMD? Sign up

    Help

    • English
    • 中文
    • Français
    • Deutsch
    • 日本語
    • Español
    • Català
    • Ελληνικά
    • Português
    • italiano
    • Türkçe
    • Русский
    • Nederlands
    • hrvatski jezik
    • język polski
    • Українська
    • हिन्दी
    • svenska
    • Esperanto
    • dansk

    Documents

    Help & Tutorial

    How to use Book mode

    Slide Example

    API Docs

    Edit in VSCode

    Install browser extension

    Contacts

    Feedback

    Discord

    Send us email

    Resources

    Releases

    Pricing

    Blog

    Policy

    Terms

    Privacy

    Cheatsheet

    Syntax Example Reference
    # Header Header 基本排版
    - Unordered List
    • Unordered List
    1. Ordered List
    1. Ordered List
    - [ ] Todo List
    • Todo List
    > Blockquote
    Blockquote
    **Bold font** Bold font
    *Italics font* Italics font
    ~~Strikethrough~~ Strikethrough
    19^th^ 19th
    H~2~O H2O
    ++Inserted text++ Inserted text
    ==Marked text== Marked text
    [link text](https:// "title") Link
    ![image alt](https:// "title") Image
    `Code` Code 在筆記中貼入程式碼
    ```javascript
    var i = 0;
    ```
    var i = 0;
    :smile: :smile: Emoji list
    {%youtube youtube_id %} Externals
    $L^aT_eX$ LaTeX
    :::info
    This is a alert area.
    :::

    This is a alert area.

    Versions and GitHub Sync
    Get Full History Access

    • Edit version name
    • Delete

    revision author avatar     named on  

    More Less

    Note content is identical to the latest version.
    Compare
      Choose a version
      No search result
      Version not found
    Sign in to link this note to GitHub
    Learn more
    This note is not linked with GitHub
     

    Feedback

    Submission failed, please try again

    Thanks for your support.

    On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?

    Please give us some advice and help us improve HackMD.

     

    Thanks for your feedback

    Remove version name

    Do you want to remove this version name and description?

    Transfer ownership

    Transfer to
      Warning: is a public team. If you transfer note to this team, everyone on the web can find and read this note.

        Link with GitHub

        Please authorize HackMD on GitHub
        • Please sign in to GitHub and install the HackMD app on your GitHub repo.
        • HackMD links with GitHub through a GitHub App. You can choose which repo to install our App.
        Learn more  Sign in to GitHub

        Push the note to GitHub Push to GitHub Pull a file from GitHub

          Authorize again
         

        Choose which file to push to

        Select repo
        Refresh Authorize more repos
        Select branch
        Select file
        Select branch
        Choose version(s) to push
        • Save a new version and push
        • Choose from existing versions
        Include title and tags
        Available push count

        Pull from GitHub

         
        File from GitHub
        File from HackMD

        GitHub Link Settings

        File linked

        Linked by
        File path
        Last synced branch
        Available push count

        Danger Zone

        Unlink
        You will no longer receive notification when GitHub file changes after unlink.

        Syncing

        Push failed

        Push successfully