From a40836b7ea1f03cd77475b6c6ddfa51785db0b70 Mon Sep 17 00:00:00 2001 From: Richard Janis Goldschmidt <701177+SuperFluffy@users.noreply.github.com> Date: Wed, 27 Apr 2022 19:28:14 +0200 Subject: [PATCH 01/38] Initial commit --- CODEOWNERS | 1 + README.md | 77 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 78 insertions(+) create mode 100644 CODEOWNERS create mode 100644 README.md diff --git a/CODEOWNERS b/CODEOWNERS new file mode 100644 index 00000000..737e5b74 --- /dev/null +++ b/CODEOWNERS @@ -0,0 +1 @@ +* @superfluffy @oldgalileo diff --git a/README.md b/README.md new file mode 100644 index 00000000..24055bbc --- /dev/null +++ b/README.md @@ -0,0 +1,77 @@ +# Orb Supervisor + +Orb supervisor is a central IPC server that coordinates device state and external UX across independent agents (binaries/processes). + +## Table of Contents + +- Minimal viable product (MVP) +- Why (this is necessary) + - Managing device health + - Consistent UX + - Seperation of concerns +- Relevant components + +## MVP + +### Initial release + +- supervisor running [tonic gRPC](https://github.com/hyperium/tonic) over UDS (Unix Domain Sockets) +- supervisor can broadcast shutdown message + - component apps (orb-core, update-agent) listen for broadcast and shutdown +- supervisor can update SMD **through sub-process** +- supervisor can display front LED patterns +- IPC (InterProcess-Communication) client library supporting defaults for process shutdown handlers + - Setup the bidirectional communication + the listener for broadcast messages + +### Immediate follow-up release +- supervisor can play sounds +- supervisor can engage in bi-directional communication for signup permission with orb-core; orb-core must not run a signup if... + - an update is scheduled; + - the device is shutting down; + - the SSD is full (coordinate with @AI on signup extensions); +- fan-controller PoC + - spin fans up/down depending on temperature/temperature-analogs + - watch iops/sec on NVMe as an indicator of SSD temperature (can be replaced by reading out SMART data after kernel 5.10 is deployed) +- supervisor can update SMD **through nvidia-smd crate** + - Implement an Nvidia SMD parser as a crate (other people may want this) + +## Why this is necessary + +There are two reasons that make the orb supervisor necessary: + +1. Managing device health (heat, updates) +1. Consistent UX (updates w/ voice, LEDs) +1. Separation of concerns + +### Managing device health + +Device health must be ensured at all times, whether the device is updating or in the middle of a signup. Furthermore, you want this to be maximally isolated to avoid a scenario where, through a vulnerability in a monolithic application, an attacker acquires fan control and overheats the device. + +> **Scenario**: _A non-security critical update is running in the background and writing large blobs of data to the NVMe SSD_ while _orb-core is running and signups are being performed. An attacker uses a vulnerability in the QR code processing to deadlock a thread. They then proceed to garble the incoming network traffic causing the download to be repeatedly retried and data to be constantly written to the SSD while thermal management is stuck in the blocked runtime. This can feasibly fry an Orb._ + +### Consistent UX + +By necessity, the update agent service must have heightened privileges. Under no circumstances can we extend these to the entire orb-core process. At the same time, the operator must receive feedback on the status of an update. For certain updates, orb-core will not run during the update. In this scenario there is currently no mechanism to give feedback to the operator. + +Thus, an independent service that owns UX is a necessary condition for operator feedback. + +### Seperation of concerns + +Breaking components down allows us to: + ++ Reduce attack surfaces by restricting the responsibilities of privileged services; ++ Employ best patterns for the job (a fan monitoring service looks different from an update agent looks different from orb core); ++ Reduce engineering load (understanding a 500 LoC binary and finding bugs _is_ easier than in a 10k LoC monolith); ++ Running integration tests is significantly easier outside of complex runtimes. + +It is best industry practice to write dedicated services *where possible*, where coupling is low and where solutions already exist. This applies especially on a full Linux host and will reduce engineering load. + +## Relevant components + ++ update agent ++ fan monitor & control ++ wifi management ++ UX controller, split into: + + Sound + + LED ++ library for basic and repeatable "component" From 5f61f552efbf82cd03e1054d447e297fd1c0868b Mon Sep 17 00:00:00 2001 From: Richard Janis Goldschmidt <701177+SuperFluffy@users.noreply.github.com> Date: Thu, 28 Apr 2022 10:19:12 +0200 Subject: [PATCH 02/38] Define project structure and core payload --- .gitignore | 2 ++ Cargo.toml | 5 +++++ orb-schema/Cargo.toml | 15 +++++++++++++++ orb-schema/build.rs | 10 ++++++++++ orb-schema/protos/container.proto | 7 +++++++ orb-schema/src/lib.rs | 23 +++++++++++++++++++++++ orb-supervisor/Cargo.toml | 9 +++++++++ orb-supervisor/src/lib.rs | 8 ++++++++ 8 files changed, 79 insertions(+) create mode 100644 .gitignore create mode 100644 Cargo.toml create mode 100644 orb-schema/Cargo.toml create mode 100644 orb-schema/build.rs create mode 100644 orb-schema/protos/container.proto create mode 100644 orb-schema/src/lib.rs create mode 100644 orb-supervisor/Cargo.toml create mode 100644 orb-supervisor/src/lib.rs diff --git a/.gitignore b/.gitignore new file mode 100644 index 00000000..96ef6c0b --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +/target +Cargo.lock diff --git a/Cargo.toml b/Cargo.toml new file mode 100644 index 00000000..1667d5be --- /dev/null +++ b/Cargo.toml @@ -0,0 +1,5 @@ +[workspace] +members = [ + "orb-schema", + "orb-supervisor", +] diff --git a/orb-schema/Cargo.toml b/orb-schema/Cargo.toml new file mode 100644 index 00000000..b44ccf63 --- /dev/null +++ b/orb-schema/Cargo.toml @@ -0,0 +1,15 @@ +[package] +name = "orb-schema" +version = "0.1.0" +edition = "2021" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[build-dependencies] +prost-build = "0.10.1" + +[dependencies] +prost = "0.10.1" + +[dev-dependencies] +bytes = "1.1.0" diff --git a/orb-schema/build.rs b/orb-schema/build.rs new file mode 100644 index 00000000..6a7b101b --- /dev/null +++ b/orb-schema/build.rs @@ -0,0 +1,10 @@ +use std::io::Result; + +use prost_build; + +fn main() -> Result<()> { + prost_build::Config::default() + .bytes(&["."]) + .compile_protos(&["protos/container.proto"], &["protos/"])?; + Ok(()) +} diff --git a/orb-schema/protos/container.proto b/orb-schema/protos/container.proto new file mode 100644 index 00000000..302eb473 --- /dev/null +++ b/orb-schema/protos/container.proto @@ -0,0 +1,7 @@ +syntax = "proto3"; + +package supervisor; + +message Container { + bytes payload = 1; +} diff --git a/orb-schema/src/lib.rs b/orb-schema/src/lib.rs new file mode 100644 index 00000000..1e1adc3a --- /dev/null +++ b/orb-schema/src/lib.rs @@ -0,0 +1,23 @@ +include!(concat!(env!("OUT_DIR"), "/supervisor.rs")); + +#[cfg(test)] +mod tests { + use prost::{ + DecodeError, + Message as _, + }; + + use super::Container; + + #[test] + fn container_roundtrip_works() -> Result<(), DecodeError> { + let msg = b"hello world"; + let expected_container = Container { + payload: (&msg[..]).into(), + }; + let encoded_container = expected_container.encode_to_vec(); + let decoded_container = Container::decode(&*encoded_container)?; + assert_eq!(expected_container, decoded_container); + Ok(()) + } +} diff --git a/orb-supervisor/Cargo.toml b/orb-supervisor/Cargo.toml new file mode 100644 index 00000000..fe614fe8 --- /dev/null +++ b/orb-supervisor/Cargo.toml @@ -0,0 +1,9 @@ +[package] +name = "orb-supervisor" +version = "0.1.0" +edition = "2021" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] +orb-schema = { path = "../orb-schema" } diff --git a/orb-supervisor/src/lib.rs b/orb-supervisor/src/lib.rs new file mode 100644 index 00000000..1b4a90c9 --- /dev/null +++ b/orb-supervisor/src/lib.rs @@ -0,0 +1,8 @@ +#[cfg(test)] +mod tests { + #[test] + fn it_works() { + let result = 2 + 2; + assert_eq!(result, 4); + } +} From e21f4eabcf1ec1d3b7c5339841d3f13651b7a7df Mon Sep 17 00:00:00 2001 From: Richard Janis Goldschmidt <701177+SuperFluffy@users.noreply.github.com> Date: Thu, 28 Apr 2022 10:19:22 +0200 Subject: [PATCH 03/38] Add rustfmt definition --- rustfmt.toml | 67 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 67 insertions(+) create mode 100644 rustfmt.toml diff --git a/rustfmt.toml b/rustfmt.toml new file mode 100644 index 00000000..020d7be6 --- /dev/null +++ b/rustfmt.toml @@ -0,0 +1,67 @@ +max_width = 100 +hard_tabs = false +tab_spaces = 4 +newline_style = "Unix" +indent_style = "Block" +use_small_heuristics = "Default" +wrap_comments = true +format_code_in_doc_comments = true +comment_width = 100 +normalize_comments = true +normalize_doc_attributes = false +license_template_path = "" +format_strings = true +format_macro_matchers = true +format_macro_bodies = true +empty_item_single_line = true +struct_lit_single_line = false +fn_single_line = false +where_single_line = false +imports_indent = "Block" +imports_layout = "Vertical" +imports_granularity = "Crate" +group_imports = "StdExternalCrate" +reorder_imports = true +reorder_modules = true +reorder_impl_items = true +type_punctuation_density = "Wide" +space_before_colon = false +space_after_colon = true +spaces_around_ranges = false +binop_separator = "Front" +remove_nested_parens = true +combine_control_expr = true +overflow_delimited_expr = false +struct_field_align_threshold = 0 +enum_discrim_align_threshold = 0 +match_arm_blocks = true +match_arm_leading_pipes = "Never" +force_multiline_blocks = false +fn_args_layout = "Tall" +brace_style = "SameLineWhere" +control_brace_style = "AlwaysSameLine" +trailing_semicolon = true +trailing_comma = "Vertical" +match_block_trailing_comma = false +blank_lines_upper_bound = 1 +blank_lines_lower_bound = 0 +edition = "2021" +version = "Two" +inline_attribute_width = 0 +merge_derives = true +use_try_shorthand = true +use_field_init_shorthand = true +force_explicit_abi = true +condense_wildcard_suffixes = true +color = "Auto" +unstable_features = true +disable_all_formatting = false +skip_children = false +hide_parse_errors = false +error_on_line_overflow = false +error_on_unformatted = false +report_todo = "Never" +report_fixme = "Never" +ignore = [] +emit_mode = "Files" +make_backup = false From 6f5e4c3bc6bb3e03edb22c6eb74691b20bcc2708 Mon Sep 17 00:00:00 2001 From: Galileo Daras Date: Thu, 28 Apr 2022 12:33:32 +0200 Subject: [PATCH 04/38] Add initial supervised process documentation --- PROCESS.md | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 PROCESS.md diff --git a/PROCESS.md b/PROCESS.md new file mode 100644 index 00000000..35453b5c --- /dev/null +++ b/PROCESS.md @@ -0,0 +1,15 @@ +# Guideline for Supervised Process Development + +Examples of SuPr (**Su**pervised **Pr**ocess) development: +- update-agent +- orb-core +- fan-controller +- ... + +## Expectations + +Through signal_hook or otherwise, we expect components to adhere to UNIX signal best practices, specifically around shutdown signals. + +### Shutdown Flow + +The supervisor _decides_ it must shutdown. The supervisor iterates over the list of supervised processes, reads their corresponding PID file, and issues a [SIGTERM](https://man7.org/linux/man-pages/man7/signal.7.html) to give the application **SOME DEFINED SECONDS** to shutdown. After that time has elapsed, the supervisor re-reads the SuPr PID files and sends a [SIGKILL](https://man7.org/linux/man-pages/man7/signal.7.html). From ea0908f6a393f771ae6ab7a0efd950ae5082d6ab Mon Sep 17 00:00:00 2001 From: Richard Janis Goldschmidt <701177+SuperFluffy@users.noreply.github.com> Date: Tue, 26 Jul 2022 14:20:25 +0200 Subject: [PATCH 05/38] Implement general github action (#5) This commit introduces github actions to the repository. To not affect developer experience, this commit uses `git config` to set the `url..insteadOf` variable to rewrite all instances of `ssh://git@github.com/worldcoin/`, `git@github.com:worldcoin/` `https://github.com/worldcoin` to `https://:x-auth-basic@github.com/worldcoin/`. --- .github/workflows/general.yml | 79 +++++++++++++++++++++++++++++++ Cargo.toml | 1 - orb-schema/Cargo.toml | 15 ------ orb-schema/build.rs | 10 ---- orb-schema/protos/container.proto | 7 --- orb-schema/src/lib.rs | 23 --------- orb-supervisor/Cargo.toml | 1 - orb-supervisor/src/lib.rs | 8 ---- orb-supervisor/src/main.rs | 3 ++ 9 files changed, 82 insertions(+), 65 deletions(-) create mode 100644 .github/workflows/general.yml delete mode 100644 orb-schema/Cargo.toml delete mode 100644 orb-schema/build.rs delete mode 100644 orb-schema/protos/container.proto delete mode 100644 orb-schema/src/lib.rs delete mode 100644 orb-supervisor/src/lib.rs create mode 100644 orb-supervisor/src/main.rs diff --git a/.github/workflows/general.yml b/.github/workflows/general.yml new file mode 100644 index 00000000..26ffa425 --- /dev/null +++ b/.github/workflows/general.yml @@ -0,0 +1,79 @@ +name: Continuous integration + +on: + push: + branches: + - main + - develop + pull_request: + workflow_dispatch: + +jobs: + test: + runs-on: ubuntu-latest + env: + RUSTFLAGS: "-D warnings -W unreachable-pub -W rust-2021-compatibility" + steps: + - run: | + git config --global url."https://${{ secrets.RUNNER_TOKEN }}:x-oauth-basic@github.com/worldcoin/".insteadOf "ssh://git@github.com/worldcoin/" + git config --global url."https://${{ secrets.RUNNER_TOKEN }}:x-oauth-basic@github.com/worldcoin/".insteadOf "git@github.com:worldcoin/" + git config --global url."https://${{ secrets.RUNNER_TOKEN }}:x-oauth-basic@github.com/worldcoin/".insteadOf "https://github.com/worldcoin/" + - uses: actions/checkout@v3 + with: + token: ${{ secrets.RUNNER_TOKEN }} + submodules: recursive + - uses: actions/cache@v2 + with: + path: | + ~/.cargo/bin/ + ~/.cargo/registry/index/ + ~/.cargo/registry/cache/ + ~/.cargo/git/db/ + target/ + key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} + - uses: dtolnay/rust-toolchain@1.61.0 + - run: cargo test + + rustfmt: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: actions/cache@v2 + with: + path: | + ~/.cargo/bin/ + ~/.cargo/registry/index/ + ~/.cargo/registry/cache/ + ~/.cargo/git/db/ + target/ + key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} + - uses: dtolnay/rust-toolchain@nightly + with: + components: rustfmt + - run: cargo fmt --all -- --check + + clippy: + name: Clippy + runs-on: ubuntu-latest + steps: + - run: | + git config --global url."https://${{ secrets.RUNNER_TOKEN }}:x-oauth-basic@github.com/worldcoin/".insteadOf "ssh://git@github.com/worldcoin/" + git config --global url."https://${{ secrets.RUNNER_TOKEN }}:x-oauth-basic@github.com/worldcoin/".insteadOf "git@github.com:worldcoin/" + git config --global url."https://${{ secrets.RUNNER_TOKEN }}:x-oauth-basic@github.com/worldcoin/".insteadOf "https://github.com/worldcoin/" + - uses: actions/checkout@v3 + with: + token: ${{ secrets.RUNNER_TOKEN }} + submodules: recursive + - uses: actions/cache@v2 + with: + path: | + ~/.cargo/bin/ + ~/.cargo/registry/index/ + ~/.cargo/registry/cache/ + ~/.cargo/git/db/ + target/ + key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} + - uses: dtolnay/rust-toolchain@1.61.0 + with: + components: clippy + - run: cargo clippy -- -D warnings -W clippy::pedantic -A clippy::missing_errors_doc -A clippy::module_name_repetitions diff --git a/Cargo.toml b/Cargo.toml index 1667d5be..21010784 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,5 +1,4 @@ [workspace] members = [ - "orb-schema", "orb-supervisor", ] diff --git a/orb-schema/Cargo.toml b/orb-schema/Cargo.toml deleted file mode 100644 index b44ccf63..00000000 --- a/orb-schema/Cargo.toml +++ /dev/null @@ -1,15 +0,0 @@ -[package] -name = "orb-schema" -version = "0.1.0" -edition = "2021" - -# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html - -[build-dependencies] -prost-build = "0.10.1" - -[dependencies] -prost = "0.10.1" - -[dev-dependencies] -bytes = "1.1.0" diff --git a/orb-schema/build.rs b/orb-schema/build.rs deleted file mode 100644 index 6a7b101b..00000000 --- a/orb-schema/build.rs +++ /dev/null @@ -1,10 +0,0 @@ -use std::io::Result; - -use prost_build; - -fn main() -> Result<()> { - prost_build::Config::default() - .bytes(&["."]) - .compile_protos(&["protos/container.proto"], &["protos/"])?; - Ok(()) -} diff --git a/orb-schema/protos/container.proto b/orb-schema/protos/container.proto deleted file mode 100644 index 302eb473..00000000 --- a/orb-schema/protos/container.proto +++ /dev/null @@ -1,7 +0,0 @@ -syntax = "proto3"; - -package supervisor; - -message Container { - bytes payload = 1; -} diff --git a/orb-schema/src/lib.rs b/orb-schema/src/lib.rs deleted file mode 100644 index 1e1adc3a..00000000 --- a/orb-schema/src/lib.rs +++ /dev/null @@ -1,23 +0,0 @@ -include!(concat!(env!("OUT_DIR"), "/supervisor.rs")); - -#[cfg(test)] -mod tests { - use prost::{ - DecodeError, - Message as _, - }; - - use super::Container; - - #[test] - fn container_roundtrip_works() -> Result<(), DecodeError> { - let msg = b"hello world"; - let expected_container = Container { - payload: (&msg[..]).into(), - }; - let encoded_container = expected_container.encode_to_vec(); - let decoded_container = Container::decode(&*encoded_container)?; - assert_eq!(expected_container, decoded_container); - Ok(()) - } -} diff --git a/orb-supervisor/Cargo.toml b/orb-supervisor/Cargo.toml index fe614fe8..13b5ea9c 100644 --- a/orb-supervisor/Cargo.toml +++ b/orb-supervisor/Cargo.toml @@ -6,4 +6,3 @@ edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -orb-schema = { path = "../orb-schema" } diff --git a/orb-supervisor/src/lib.rs b/orb-supervisor/src/lib.rs deleted file mode 100644 index 1b4a90c9..00000000 --- a/orb-supervisor/src/lib.rs +++ /dev/null @@ -1,8 +0,0 @@ -#[cfg(test)] -mod tests { - #[test] - fn it_works() { - let result = 2 + 2; - assert_eq!(result, 4); - } -} diff --git a/orb-supervisor/src/main.rs b/orb-supervisor/src/main.rs new file mode 100644 index 00000000..e7a11a96 --- /dev/null +++ b/orb-supervisor/src/main.rs @@ -0,0 +1,3 @@ +fn main() { + println!("Hello, world!"); +} From 5875648c265dbdbcd908093586b476282019c8bd Mon Sep 17 00:00:00 2001 From: Richard Janis Goldschmidt <701177+SuperFluffy@users.noreply.github.com> Date: Tue, 26 Jul 2022 17:17:12 +0200 Subject: [PATCH 06/38] Listen to signup-started and block background downloads (#6) This commit marks the first functional `orb-supervisor`. It is a persistent service that exists to be queried by `orb-update-agent` for whether the download of updates is permitted. It provides this functionality by doing 2 things: + listen to a `SignupStarted` event from `orb-core` over a user session D-Bus, which it expects to receive from the `org.worldcoin.OrbCore1.Signup` interface located at path `/org/worldcoin/OrbCore1/Signup` and served by a service with the well known name `org.worldcoin.OrbCore1`. + register on the user session D-Bus under the well known name `org.worldcoin.OrbSupervisor1` and provide an interface `org.worldcoin.OrbSupervisor1.Manager` at `/org.worldcoin/OrbSupervisor1/Manager` that has the property `BackgroundDownloadsAllowed`. --- .gitmodules | 3 + Cargo.toml | 1 + orb-mcu-schema/Cargo.toml | 12 ++ orb-mcu-schema/build.rs | 11 ++ orb-mcu-schema/src/lib.rs | 3 + orb-supervisor/Cargo.toml | 17 +++ orb-supervisor/README.md | 14 ++ orb-supervisor/src/interfaces/manager.rs | 148 +++++++++++++++++++++ orb-supervisor/src/interfaces/mod.rs | 3 + orb-supervisor/src/lib.rs | 5 + orb-supervisor/src/main.rs | 23 +++- orb-supervisor/src/proxies/core.rs | 12 ++ orb-supervisor/src/proxies/mod.rs | 1 + orb-supervisor/src/startup.rs | 129 ++++++++++++++++++ orb-supervisor/src/tasks/mod.rs | 5 + orb-supervisor/src/tasks/signup_started.rs | 48 +++++++ orb-supervisor/src/telemetry.rs | 3 + orb-supervisor/tests/it/helpers.rs | 101 ++++++++++++++ orb-supervisor/tests/it/main.rs | 39 ++++++ protobuf-definitions | 1 + rustfmt.toml | 3 - 21 files changed, 577 insertions(+), 5 deletions(-) create mode 100644 .gitmodules create mode 100644 orb-mcu-schema/Cargo.toml create mode 100644 orb-mcu-schema/build.rs create mode 100644 orb-mcu-schema/src/lib.rs create mode 100644 orb-supervisor/README.md create mode 100644 orb-supervisor/src/interfaces/manager.rs create mode 100644 orb-supervisor/src/interfaces/mod.rs create mode 100644 orb-supervisor/src/lib.rs create mode 100644 orb-supervisor/src/proxies/core.rs create mode 100644 orb-supervisor/src/proxies/mod.rs create mode 100644 orb-supervisor/src/startup.rs create mode 100644 orb-supervisor/src/tasks/mod.rs create mode 100644 orb-supervisor/src/tasks/signup_started.rs create mode 100644 orb-supervisor/src/telemetry.rs create mode 100644 orb-supervisor/tests/it/helpers.rs create mode 100644 orb-supervisor/tests/it/main.rs create mode 160000 protobuf-definitions diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 00000000..fec9a8bf --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "protobuf-definitions"] + path = protobuf-definitions + url = git@github.com:worldcoin/protobuf-definitions.git diff --git a/Cargo.toml b/Cargo.toml index 21010784..6419fdb2 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,4 +1,5 @@ [workspace] members = [ + "orb-mcu-schema", "orb-supervisor", ] diff --git a/orb-mcu-schema/Cargo.toml b/orb-mcu-schema/Cargo.toml new file mode 100644 index 00000000..f47d09f0 --- /dev/null +++ b/orb-mcu-schema/Cargo.toml @@ -0,0 +1,12 @@ +[package] +name = "orb-mcu-schema" +version = "0.1.0" +edition = "2021" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] +prost = "0.10.4" + +[build-dependencies] +prost-build = "0.10.4" diff --git a/orb-mcu-schema/build.rs b/orb-mcu-schema/build.rs new file mode 100644 index 00000000..d68f6cf2 --- /dev/null +++ b/orb-mcu-schema/build.rs @@ -0,0 +1,11 @@ +fn main() -> std::io::Result<()> { + println!("cargo:rerun-if-changed=../protobuf-definitions/"); + + prost_build::Config::new() + .default_package_filename("mcu_messaging") + .compile_protos( + &["../protobuf-definitions/mcu_messaging.proto"], + &["../protobuf-definitions/"], + )?; + Ok(()) +} diff --git a/orb-mcu-schema/src/lib.rs b/orb-mcu-schema/src/lib.rs new file mode 100644 index 00000000..d7196fab --- /dev/null +++ b/orb-mcu-schema/src/lib.rs @@ -0,0 +1,3 @@ +#![allow(clippy::all, clippy::pedantic)] + +include!(concat!(env!("OUT_DIR"), "/mcu_messaging.rs")); diff --git a/orb-supervisor/Cargo.toml b/orb-supervisor/Cargo.toml index 13b5ea9c..c31e9843 100644 --- a/orb-supervisor/Cargo.toml +++ b/orb-supervisor/Cargo.toml @@ -6,3 +6,20 @@ edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] +eyre = "0.6.8" +libc = "0.2.126" +listenfd = "1.0.0" +orb-mcu-schema = { path = "../orb-mcu-schema" } +prost = "0.10.4" +tokio = { version = "1.19.2", features = ["macros", "macros", "net", "rt-multi-thread"] } +tokio-stream = "0.1.9" +tracing = "0.1.35" +tracing-subscriber = "0.3.11" +zbus = { version = "2.3.1", default-features = false, features = ["tokio"] } +zbus_systemd = { version = "0.0.4", features = ["login1"] } +thiserror = "1.0.31" +futures = "0.3.21" + +[dev-dependencies] +dbus-launch = "0.2.0" +tokio = { version = "1.19.2", features = ["test-util"] } diff --git a/orb-supervisor/README.md b/orb-supervisor/README.md new file mode 100644 index 00000000..40a7896a --- /dev/null +++ b/orb-supervisor/README.md @@ -0,0 +1,14 @@ +# Building + +To build this crate and run it on the orb, make sure to have `zig` installed. +For example through the Arch Linux package manager: + +```shell +# pacman -S zig +``` + +```shell +$ rustup target add aarch64-unknown-linux-gnu +$ cargo install cargo-zigbuild +$ cargo zigbuild --release --target aarch64-unknown-linux-gnu -p orb-supervisor +``` diff --git a/orb-supervisor/src/interfaces/manager.rs b/orb-supervisor/src/interfaces/manager.rs new file mode 100644 index 00000000..49d8acdf --- /dev/null +++ b/orb-supervisor/src/interfaces/manager.rs @@ -0,0 +1,148 @@ +//! [`Manager`] defines the `org.worldcoin.OrbSupervisor1.Manager` Dbus interface. +//! +//! It currently only supports the `BackgroundDownloadsAllowed` property used by the update to +//! decide whether or not it can download updates. + +use tokio::time::{ + Duration, + Instant, +}; +use zbus::{ + dbus_interface, + SignalContext, +}; + +/// The duration of time since the last "start signup" event that has to have passed +/// before the update agent is permitted to start a download. +pub const DEFAULT_DURATION_TO_ALLOW_DOWNLOADS: Duration = Duration::from_secs(3600); + +pub const BACKGROUND_DOWNLOADS_ALLOWED_PROPERTY_NAME: &str = "BackgroundDownloadsAllowed"; +pub const INTERFACE_NAME: &str = "org.worldcoin.OrbSupervisor1.Manager"; +pub const OBJECT_PATH: &str = "/org/worldcoin/OrbSupervisor1/Manager"; + +pub struct Manager { + last_signup_event: Instant, + duration_to_allow_downloads: Duration, +} + +impl Manager { + /// Constructs a new `Manager` instance. + #[allow(clippy::must_use_candidate)] + pub fn new() -> Self { + Self::with_last_signup_event(Instant::now()) + } + + /// Constructs a new `Manager` instance with `last_signup_event` taken as the instant at + /// which the last signup event happened. + /// + /// This is primarily useful for integration tests. + /// + /// **NOTE** do not rely on this function as it will be removed once tokio's time API is + /// correctly respected inside zbus. + #[must_use] + pub fn with_last_signup_event(last_signup_event: Instant) -> Self { + Self { + last_signup_event, + duration_to_allow_downloads: DEFAULT_DURATION_TO_ALLOW_DOWNLOADS, + } + } + + #[must_use] + pub fn duration_to_allow_downloads(self, duration_to_allow_downloads: Duration) -> Self { + Self { + duration_to_allow_downloads, + ..self + } + } + + #[allow(clippy::must_use_candidate)] + pub fn are_downloads_allowed(&self) -> bool { + self.last_signup_event.elapsed() >= self.duration_to_allow_downloads + } + + fn reset_last_signup_event(&mut self) { + self.last_signup_event = Instant::now(); + } + + /// Resets the internal timer tracking the last signup event to the current time and emits a + /// `PropertyChanged` for the `BackgroundDownloadsAllowed` signal. + /// + /// # Errors + /// + /// The same as calling [`zbus::fdo::Properties::properties_changed`]. + pub async fn reset_last_signup_event_and_notify( + &mut self, + signal_context: &SignalContext<'_>, + ) -> zbus::Result<()> { + self.reset_last_signup_event(); + self.background_downloads_allowed_changed(signal_context) + .await + } +} + +impl Default for Manager { + fn default() -> Self { + Self::new() + } +} + +#[dbus_interface(name = "org.worldcoin.OrbSupervisor1.Manager")] +impl Manager { + #[dbus_interface(property, name = "BackgroundDownloadsAllowed")] + async fn background_downloads_allowed(&self) -> bool { + self.are_downloads_allowed() + } +} + +#[cfg(test)] +mod tests { + use zbus::Interface; + + use super::{ + Manager, + DEFAULT_DURATION_TO_ALLOW_DOWNLOADS, + }; + + #[test] + fn manager_interface_name_matches_exported_const() { + assert_eq!(super::INTERFACE_NAME, &*Manager::name()); + } + + #[tokio::test] + async fn manager_background_downloads_allowed_property_matched_exported_const() { + let manager = Manager::new(); + assert!( + manager + .get(super::BACKGROUND_DOWNLOADS_ALLOWED_PROPERTY_NAME) + .await + .is_some() + ); + } + + #[tokio::test(start_paused = true)] + async fn downloads_are_disallowed_if_last_signup_event_is_too_recent() { + let manager = + Manager::new().duration_to_allow_downloads(DEFAULT_DURATION_TO_ALLOW_DOWNLOADS); + tokio::time::advance(DEFAULT_DURATION_TO_ALLOW_DOWNLOADS / 2).await; + + assert!(!manager.are_downloads_allowed()); + } + + #[tokio::test(start_paused = true)] + async fn downloads_are_allowed_if_last_signup_event_is_old_enough() { + let manager = + Manager::new().duration_to_allow_downloads(DEFAULT_DURATION_TO_ALLOW_DOWNLOADS); + tokio::time::advance(DEFAULT_DURATION_TO_ALLOW_DOWNLOADS * 2).await; + assert!(manager.are_downloads_allowed()); + } + + #[tokio::test(start_paused = true)] + async fn downloads_become_disallowed_after_reset() { + let mut manager = + Manager::new().duration_to_allow_downloads(DEFAULT_DURATION_TO_ALLOW_DOWNLOADS); + tokio::time::advance(DEFAULT_DURATION_TO_ALLOW_DOWNLOADS * 2).await; + assert!(manager.are_downloads_allowed()); + manager.reset_last_signup_event(); + assert!(!manager.are_downloads_allowed()); + } +} diff --git a/orb-supervisor/src/interfaces/mod.rs b/orb-supervisor/src/interfaces/mod.rs new file mode 100644 index 00000000..99d5fa78 --- /dev/null +++ b/orb-supervisor/src/interfaces/mod.rs @@ -0,0 +1,3 @@ +pub mod manager; + +pub use manager::Manager; diff --git a/orb-supervisor/src/lib.rs b/orb-supervisor/src/lib.rs new file mode 100644 index 00000000..4c867618 --- /dev/null +++ b/orb-supervisor/src/lib.rs @@ -0,0 +1,5 @@ +pub mod interfaces; +pub mod proxies; +pub mod startup; +pub mod tasks; +pub mod telemetry; diff --git a/orb-supervisor/src/main.rs b/orb-supervisor/src/main.rs index e7a11a96..741e4bdb 100644 --- a/orb-supervisor/src/main.rs +++ b/orb-supervisor/src/main.rs @@ -1,3 +1,22 @@ -fn main() { - println!("Hello, world!"); +use eyre::WrapErr as _; +use orb_supervisor::{ + startup::{ + Application, + Settings, + }, + telemetry, +}; + +#[tokio::main] +async fn main() -> eyre::Result<()> { + telemetry::start(); + + let settings = Settings::default(); + let application = Application::build(settings.clone()) + .await + .wrap_err("failed to build supervisor")?; + + application.run().await?; + + Ok(()) } diff --git a/orb-supervisor/src/proxies/core.rs b/orb-supervisor/src/proxies/core.rs new file mode 100644 index 00000000..74356892 --- /dev/null +++ b/orb-supervisor/src/proxies/core.rs @@ -0,0 +1,12 @@ +//! Dbus proxies for interacting with orb core. + +use zbus::dbus_proxy; + +pub const SIGNUP_PROXY_DEFAULT_WELL_KNOWN_NAME: &str = "org.worldcoin.OrbCore1"; +pub const SIGNUP_PROXY_DEFAULT_OBJECT_PATH: &str = "/org/worldcoin/OrbCore1/Signup"; + +#[dbus_proxy(interface = "org.worldcoin.OrbCore1.Signup")] +pub trait Signup { + #[dbus_proxy(signal)] + fn signup_started(&self) -> Result<()>; +} diff --git a/orb-supervisor/src/proxies/mod.rs b/orb-supervisor/src/proxies/mod.rs new file mode 100644 index 00000000..5a7ca06a --- /dev/null +++ b/orb-supervisor/src/proxies/mod.rs @@ -0,0 +1 @@ +pub mod core; diff --git a/orb-supervisor/src/startup.rs b/orb-supervisor/src/startup.rs new file mode 100644 index 00000000..91e27d1c --- /dev/null +++ b/orb-supervisor/src/startup.rs @@ -0,0 +1,129 @@ +use futures::future::TryFutureExt as _; +use tokio::time::Instant; +use zbus::{ + Connection, + ConnectionBuilder, +}; + +use crate::{ + interfaces::{ + self, + manager, + }, + proxies::core::{ + SIGNUP_PROXY_DEFAULT_OBJECT_PATH, + SIGNUP_PROXY_DEFAULT_WELL_KNOWN_NAME, + }, + tasks, +}; + +pub const DBUS_WELL_KNOWN_NAME: &str = "org.worldcoin.orb.Supervisor1"; + +#[derive(Debug, thiserror::Error)] +pub enum Error { + #[error("failed to establish connection to session dbus")] + EstablishSessionConnection(#[source] zbus::Error), + #[error("error occured in zbus communication")] + Zbus(#[from] zbus::Error), + #[error("invalid session D-Bus address")] + SessionDbusAddress(#[source] zbus::Error), + #[error("error establishing a connection to the session D-Bus or registering an interface")] + SessionDbusConnection, +} + +#[derive(Clone, Debug)] +pub struct Settings { + pub session_dbus_path: Option, + pub manager_object_path: String, + pub signup_proxy_well_known_name: String, + pub signup_proxy_object_path: String, + pub manager_last_event: Option, + pub well_known_name: String, +} + +impl Settings { + fn new() -> Self { + Self { + session_dbus_path: None, + manager_object_path: manager::OBJECT_PATH.to_string(), + signup_proxy_well_known_name: SIGNUP_PROXY_DEFAULT_WELL_KNOWN_NAME.to_string(), + signup_proxy_object_path: SIGNUP_PROXY_DEFAULT_OBJECT_PATH.to_string(), + manager_last_event: None, + well_known_name: DBUS_WELL_KNOWN_NAME.to_string(), + } + } +} + +impl Default for Settings { + fn default() -> Self { + Self::new() + } +} + +pub struct Application { + pub session_connection: Connection, + pub settings: Settings, +} + +impl Application { + /// Constructs an [`Application`] from [`Settings`]. + /// + /// This function also connects to the session D-Bus instance. + /// + /// # Errors + /// + /// [`Application::build`] will return the following errors: + /// + /// + [`Error::SessionDbusAddress`], if the path to the socket holding the session D-Bus + /// instance was not understood (the path is conventionally stored in the environment variable + /// `$DBUS_SESSION_BUS_ADDRESS`, e.g. `unix:path=/run/user/1000/bus` and usually set by + /// systemd. + /// + [`Error::EstablishSessionConnection`], if an error occured while trying to establish + /// a connection to the session D-Bus instance, or trying to register an interface with it. + /// path to which is conventionally stored in the environment variable + /// systemd. + pub async fn build(settings: Settings) -> Result { + let manager = if let Some(last_event) = settings.manager_last_event { + interfaces::Manager::with_last_signup_event(last_event) + } else { + interfaces::Manager::new() + }; + + let session_builder = if let Some(path) = settings.session_dbus_path.as_deref() { + ConnectionBuilder::address(path) + } else { + ConnectionBuilder::session() + } + .map_err(Error::SessionDbusAddress)?; + + let session_connection = futures::future::ready( + session_builder + .name(settings.well_known_name.clone()) + .and_then(|builder| { + builder.serve_at(settings.manager_object_path.clone(), manager) + }), + ) + .and_then(ConnectionBuilder::build) + .await + .map_err(Error::EstablishSessionConnection)?; + + Ok(Self { + session_connection, + settings, + }) + } + + /// Runs `Application` by spawning its constituent tasks. + /// + /// # Errors + /// + /// + `[Error::Zbus]`, if an error when spawning the task listening to Orb signups. See + /// [`tasks::spawn_signup_started_task`] for more information. + pub async fn run(self) -> Result<(), Error> { + let signup_started_task = + tasks::spawn_signup_started_task(&self.settings, &self.session_connection).await?; + + let (..) = tokio::join!(signup_started_task); + Ok(()) + } +} diff --git a/orb-supervisor/src/tasks/mod.rs b/orb-supervisor/src/tasks/mod.rs new file mode 100644 index 00000000..dbbf51c7 --- /dev/null +++ b/orb-supervisor/src/tasks/mod.rs @@ -0,0 +1,5 @@ +//! Tasks that make up the orb supervisor. + +pub mod signup_started; + +pub use signup_started::spawn_signup_started_task; diff --git a/orb-supervisor/src/tasks/signup_started.rs b/orb-supervisor/src/tasks/signup_started.rs new file mode 100644 index 00000000..cc96cd99 --- /dev/null +++ b/orb-supervisor/src/tasks/signup_started.rs @@ -0,0 +1,48 @@ +//! Listens for signup started signals from Orb Core. + +use tokio::task::JoinHandle; +use tokio_stream::StreamExt as _; + +use crate::{ + interfaces::Manager, + proxies::core::SignupProxy, + startup::Settings, +}; + +/// Spawns a task on the tokio runtime listening for `SignupStarted` D-Bus signals from Orb Core. +/// +/// When the task receives a `SignupStarted` signal it resets the timer of the `Manager` interface, +/// and then sends out a `PropertiesChanged` signal for the `BackgroundDownloadsAllowed` property. +/// +/// # Errors +/// +/// + `[zbus::Error]` if an error occured while building a D-Bus proxy listening for signups from +/// `orb-core`. The errors are the same as those in [`zbus::ProxyBuilder`]. +pub async fn spawn_signup_started_task<'a>( + settings: &Settings, + connection: &'a zbus::Connection, +) -> zbus::Result>> { + let signup_proxy = SignupProxy::builder(connection) + .destination(settings.signup_proxy_well_known_name.clone())? + .path(settings.signup_proxy_object_path.clone())? + .build() + .await?; + let mut signup_started = signup_proxy.receive_signup_started().await?; + let conn = connection.clone(); + + let manager_object_path = settings.manager_object_path.clone(); + let task_handle = tokio::spawn(async move { + while signup_started.next().await.is_some() { + let iface_ref = conn + .object_server() + .interface::<_, Manager>(manager_object_path.clone()) + .await?; + let mut iface = iface_ref.get_mut().await; + iface + .reset_last_signup_event_and_notify(iface_ref.signal_context()) + .await?; + } + Ok::<_, zbus::Error>(()) + }); + Ok(task_handle) +} diff --git a/orb-supervisor/src/telemetry.rs b/orb-supervisor/src/telemetry.rs new file mode 100644 index 00000000..7f067ab1 --- /dev/null +++ b/orb-supervisor/src/telemetry.rs @@ -0,0 +1,3 @@ +pub fn start() { + tracing_subscriber::fmt().init(); +} diff --git a/orb-supervisor/tests/it/helpers.rs b/orb-supervisor/tests/it/helpers.rs new file mode 100644 index 00000000..2811fadc --- /dev/null +++ b/orb-supervisor/tests/it/helpers.rs @@ -0,0 +1,101 @@ +use std::io; + +use dbus_launch::{ + BusType, + Daemon, +}; +use orb_supervisor::startup::{ + Application, + Settings, +}; +use tokio::{ + task::JoinHandle, + time::Duration, +}; +use zbus::{ + dbus_interface, + dbus_proxy, + SignalContext, +}; + +pub struct DbusInstances { + pub session: Daemon, +} + +pub fn launch_dbuses() -> JoinHandle> { + tokio::task::spawn_blocking(|| { + let session = launch_session_dbus()?; + Ok(DbusInstances { + session, + }) + }) +} + +pub fn launch_session_dbus() -> io::Result { + dbus_launch::Launcher::daemon() + .bus_type(BusType::Session) + .launch() +} + +pub fn make_settings(dbus_instances: &DbusInstances) -> Settings { + Settings { + session_dbus_path: dbus_instances.session.address().to_string().into(), + ..Default::default() + } +} + +pub async fn spawn_supervisor_service(settings: Settings) -> eyre::Result { + let application = Application::build(settings.clone()).await?; + Ok(application) +} + +#[dbus_proxy(interface = "org.worldcoin.OrbSupervisor1.Manager")] +pub trait Signup { + #[dbus_proxy(property)] + fn background_downloads_allowed(&self) -> zbus::Result; +} + +pub async fn make_update_agent_proxy<'a>( + settings: &'a Settings, + dbus_instances: &DbusInstances, +) -> zbus::Result> { + let connection = zbus::ConnectionBuilder::address(dbus_instances.session.address())? + .build() + .await?; + SignupProxy::builder(&connection) + .destination(settings.well_known_name.clone())? + .path(settings.manager_object_path.clone())? + .build() + .await +} + +struct Signup; + +#[dbus_interface(name = "org.worldcoin.OrbCore1.Signup")] +impl Signup { + #[dbus_interface(signal)] + pub async fn signup_started(ctxt: &SignalContext<'_>) -> zbus::Result<()>; +} + +pub async fn spawn_signup_start_task( + settings: &Settings, + dbus_instances: &DbusInstances, +) -> zbus::Result>> { + let conn = zbus::ConnectionBuilder::address(dbus_instances.session.address())? + .name(settings.signup_proxy_well_known_name.clone())? + .serve_at(settings.signup_proxy_object_path.clone(), Signup)? + .build() + .await?; + + let signup_proxy_object_path = settings.signup_proxy_object_path.clone(); + Ok(tokio::spawn(async move { + loop { + Signup::signup_started(&zbus::SignalContext::new( + &conn, + signup_proxy_object_path.clone(), + )?) + .await?; + tokio::time::sleep(Duration::from_millis(100)).await; + } + })) +} diff --git a/orb-supervisor/tests/it/main.rs b/orb-supervisor/tests/it/main.rs new file mode 100644 index 00000000..69ffecb6 --- /dev/null +++ b/orb-supervisor/tests/it/main.rs @@ -0,0 +1,39 @@ +use tokio::time::{ + Duration, + Instant, +}; + +pub mod helpers; + +#[tokio::test(start_paused = true)] +async fn supervisor_disallows_downloads_if_signup_started_received() -> eyre::Result<()> { + let dbus_instances = helpers::launch_dbuses().await??; + + let mut settings = helpers::make_settings(&dbus_instances); + settings + .manager_last_event + .replace(Instant::now() - Duration::from_secs(3700)); + + let application = helpers::spawn_supervisor_service(settings.clone()).await?; + let _application_handle = tokio::spawn(application.run()); + + let update_agent_proxy = helpers::make_update_agent_proxy(&settings, &dbus_instances).await?; + + let downloads_are_allowed_initially = update_agent_proxy.background_downloads_allowed().await?; + assert!(downloads_are_allowed_initially); + + let _signup_task_handle = helpers::spawn_signup_start_task(&settings, &dbus_instances).await?; + + // FIXME: We want to use `#[tokio::test(start_paused = true)]` and `tokio::time::advance` here + // instead. Unfortunately, this does not currently play nicely with zbus, probably because of + // its internal executor. Once that is fixed upstream this should be changed to the mocked time + // API. + tokio::time::sleep(Duration::from_millis(500)).await; + // tokio::time::advance(Duration::from_millis(500)).await; + + let downloads_are_allowed_after_signal = + update_agent_proxy.background_downloads_allowed().await?; + assert!(!downloads_are_allowed_after_signal); + + Ok(()) +} diff --git a/protobuf-definitions b/protobuf-definitions new file mode 160000 index 00000000..43507dea --- /dev/null +++ b/protobuf-definitions @@ -0,0 +1 @@ +Subproject commit 43507dea63d8707cd4de7860c534551712bee9bb diff --git a/rustfmt.toml b/rustfmt.toml index 020d7be6..3293bdc7 100644 --- a/rustfmt.toml +++ b/rustfmt.toml @@ -9,7 +9,6 @@ format_code_in_doc_comments = true comment_width = 100 normalize_comments = true normalize_doc_attributes = false -license_template_path = "" format_strings = true format_macro_matchers = true format_macro_bodies = true @@ -60,8 +59,6 @@ skip_children = false hide_parse_errors = false error_on_line_overflow = false error_on_unformatted = false -report_todo = "Never" -report_fixme = "Never" ignore = [] emit_mode = "Files" make_backup = false From d3bc81410259f48c157464ede42c030bcf7594b6 Mon Sep 17 00:00:00 2001 From: Richard Janis Goldschmidt <701177+SuperFluffy@users.noreply.github.com> Date: Thu, 28 Jul 2022 17:55:58 +0200 Subject: [PATCH 07/38] Permit updates by shutting down `worldcore-core.service` (#7) --- orb-supervisor/Cargo.toml | 11 ++-- orb-supervisor/README.md | 9 +++ orb-supervisor/src/interfaces/manager.rs | 47 ++++++++++++++ orb-supervisor/src/main.rs | 6 +- orb-supervisor/src/startup.rs | 33 +++++++++- orb-supervisor/src/telemetry.rs | 20 +++++- orb-supervisor/tests/it/helpers.rs | 83 ++++++++++++++++++++++-- orb-supervisor/tests/it/main.rs | 23 +++++++ 8 files changed, 218 insertions(+), 14 deletions(-) diff --git a/orb-supervisor/Cargo.toml b/orb-supervisor/Cargo.toml index c31e9843..a5a9e0dc 100644 --- a/orb-supervisor/Cargo.toml +++ b/orb-supervisor/Cargo.toml @@ -11,15 +11,16 @@ libc = "0.2.126" listenfd = "1.0.0" orb-mcu-schema = { path = "../orb-mcu-schema" } prost = "0.10.4" -tokio = { version = "1.19.2", features = ["macros", "macros", "net", "rt-multi-thread"] } +tokio = { version = "1.19.2", features = ["macros", "net", "rt-multi-thread"] } tokio-stream = "0.1.9" -tracing = "0.1.35" -tracing-subscriber = "0.3.11" +tracing = { version = "0.1.35", features = ["attributes"] } +tracing-subscriber = { version = "0.3.11", features = ["env-filter"] } zbus = { version = "2.3.1", default-features = false, features = ["tokio"] } -zbus_systemd = { version = "0.0.4", features = ["login1"] } +zbus_systemd = { version = "0.0.4", features = ["systemd1"] } thiserror = "1.0.31" futures = "0.3.21" +once_cell = "1.13.0" [dev-dependencies] dbus-launch = "0.2.0" -tokio = { version = "1.19.2", features = ["test-util"] } +tokio = { version = "1.19.2", features = ["sync", "test-util"] } diff --git a/orb-supervisor/README.md b/orb-supervisor/README.md index 40a7896a..2fbaf2de 100644 --- a/orb-supervisor/README.md +++ b/orb-supervisor/README.md @@ -12,3 +12,12 @@ $ rustup target add aarch64-unknown-linux-gnu $ cargo install cargo-zigbuild $ cargo zigbuild --release --target aarch64-unknown-linux-gnu -p orb-supervisor ``` + +# Running tests + +Integration tests are spawned with telemetry, but logs are by default surpressed. To enable logs +in tests run with: + +```sh +$ TEST_LOG=1 cargo test +``` diff --git a/orb-supervisor/src/interfaces/manager.rs b/orb-supervisor/src/interfaces/manager.rs index 49d8acdf..6c8fa1a7 100644 --- a/orb-supervisor/src/interfaces/manager.rs +++ b/orb-supervisor/src/interfaces/manager.rs @@ -7,10 +7,17 @@ use tokio::time::{ Duration, Instant, }; +use tracing::{ + debug, + instrument, + warn, +}; use zbus::{ dbus_interface, + Connection, SignalContext, }; +use zbus_systemd::systemd1; /// The duration of time since the last "start signup" event that has to have passed /// before the update agent is permitted to start a download. @@ -23,6 +30,7 @@ pub const OBJECT_PATH: &str = "/org/worldcoin/OrbSupervisor1/Manager"; pub struct Manager { last_signup_event: Instant, duration_to_allow_downloads: Duration, + system_connection: Option, } impl Manager { @@ -44,6 +52,7 @@ impl Manager { Self { last_signup_event, duration_to_allow_downloads: DEFAULT_DURATION_TO_ALLOW_DOWNLOADS, + system_connection: None, } } @@ -64,6 +73,10 @@ impl Manager { self.last_signup_event = Instant::now(); } + pub fn set_system_connection(&mut self, conn: zbus::Connection) { + self.system_connection.replace(conn); + } + /// Resets the internal timer tracking the last signup event to the current time and emits a /// `PropertyChanged` for the `BackgroundDownloadsAllowed` signal. /// @@ -92,6 +105,40 @@ impl Manager { async fn background_downloads_allowed(&self) -> bool { self.are_downloads_allowed() } + + #[dbus_interface(name = "RequestUpdatePermission")] + #[instrument( + name = "org.worldcoin.OrbSupervisor1.RequestUpdatePermission", + skip_all + )] + async fn request_update_permission(&self) -> zbus::fdo::Result { + debug!("RequestUpdatePermission was called"); + let mut update_permitted = false; + if let Some(conn) = &self.system_connection { + let systemd_proxy = systemd1::ManagerProxy::new(conn).await?; + match systemd_proxy + .stop_unit("worldcoin-core.service".to_string(), "replace".to_string()) + .await + { + Ok(unit_path) => { + debug!( + job_object = unit_path.as_str(), + "`org.freedesktop.systemd1.Manager.StopUnit` returned" + ); + update_permitted = true; + } + Err(zbus::Error::FDO(e)) => { + warn!(err = %e, "encountered a D-Bus error when calling `org.freedesktop.systemd1.Manager.StopUnit`"); + update_permitted = true; + } + Err(e) => { + tracing::error!(err = ?e); + return Err(zbus::fdo::Error::ZBus(e)); + } + }; + } + Ok(update_permitted) + } } #[cfg(test)] diff --git a/orb-supervisor/src/main.rs b/orb-supervisor/src/main.rs index 741e4bdb..29eea8d3 100644 --- a/orb-supervisor/src/main.rs +++ b/orb-supervisor/src/main.rs @@ -6,10 +6,14 @@ use orb_supervisor::{ }, telemetry, }; +use tracing::debug; +use tracing_subscriber::filter::LevelFilter; #[tokio::main] async fn main() -> eyre::Result<()> { - telemetry::start(); + telemetry::start(LevelFilter::INFO, std::io::stdout); + + debug!("Starting orb supervisor"); let settings = Settings::default(); let application = Application::build(settings.clone()) diff --git a/orb-supervisor/src/startup.rs b/orb-supervisor/src/startup.rs index 91e27d1c..11ca34ab 100644 --- a/orb-supervisor/src/startup.rs +++ b/orb-supervisor/src/startup.rs @@ -1,5 +1,6 @@ use futures::future::TryFutureExt as _; use tokio::time::Instant; +use tracing::debug; use zbus::{ Connection, ConnectionBuilder, @@ -17,12 +18,14 @@ use crate::{ tasks, }; -pub const DBUS_WELL_KNOWN_NAME: &str = "org.worldcoin.orb.Supervisor1"; +pub const DBUS_WELL_KNOWN_NAME: &str = "org.worldcoin.OrbSupervisor1"; #[derive(Debug, thiserror::Error)] pub enum Error { #[error("failed to establish connection to session dbus")] EstablishSessionConnection(#[source] zbus::Error), + #[error("failed to establish connection to system dbus")] + EstablishSystemConnection(#[source] zbus::Error), #[error("error occured in zbus communication")] Zbus(#[from] zbus::Error), #[error("invalid session D-Bus address")] @@ -34,6 +37,7 @@ pub enum Error { #[derive(Clone, Debug)] pub struct Settings { pub session_dbus_path: Option, + pub system_dbus_path: Option, pub manager_object_path: String, pub signup_proxy_well_known_name: String, pub signup_proxy_object_path: String, @@ -45,6 +49,7 @@ impl Settings { fn new() -> Self { Self { session_dbus_path: None, + system_dbus_path: None, manager_object_path: manager::OBJECT_PATH.to_string(), signup_proxy_well_known_name: SIGNUP_PROXY_DEFAULT_WELL_KNOWN_NAME.to_string(), signup_proxy_object_path: SIGNUP_PROXY_DEFAULT_OBJECT_PATH.to_string(), @@ -62,6 +67,7 @@ impl Default for Settings { pub struct Application { pub session_connection: Connection, + pub system_connection: Connection, pub settings: Settings, } @@ -83,11 +89,28 @@ impl Application { /// path to which is conventionally stored in the environment variable /// systemd. pub async fn build(settings: Settings) -> Result { - let manager = if let Some(last_event) = settings.manager_last_event { + let system_builder = if let Some(path) = settings.system_dbus_path.as_deref() { + ConnectionBuilder::address(path)? + } else { + ConnectionBuilder::system()? + }; + let system_connection = system_builder + .name(settings.well_known_name.clone())? + .build() + .await + .map_err(Error::EstablishSystemConnection)?; + + debug!( + unique_bus_name = ?system_connection.unique_name(), + "system dbus assigned unique bus name", + ); + + let mut manager = if let Some(last_event) = settings.manager_last_event { interfaces::Manager::with_last_signup_event(last_event) } else { interfaces::Manager::new() }; + manager.set_system_connection(system_connection.clone()); let session_builder = if let Some(path) = settings.session_dbus_path.as_deref() { ConnectionBuilder::address(path) @@ -107,8 +130,14 @@ impl Application { .await .map_err(Error::EstablishSessionConnection)?; + debug!( + unique_bus_name = ?session_connection.unique_name(), + "session dbus assigned unique bus name", + ); + Ok(Self { session_connection, + system_connection, settings, }) } diff --git a/orb-supervisor/src/telemetry.rs b/orb-supervisor/src/telemetry.rs index 7f067ab1..964994fc 100644 --- a/orb-supervisor/src/telemetry.rs +++ b/orb-supervisor/src/telemetry.rs @@ -1,3 +1,19 @@ -pub fn start() { - tracing_subscriber::fmt().init(); +use tracing::metadata::LevelFilter; +use tracing_subscriber::{ + filter::EnvFilter, + fmt::MakeWriter, +}; + +pub fn start(env_filter: LevelFilter, sink: W) +where + W: for<'a> MakeWriter<'a> + Send + Sync + 'static, +{ + tracing_subscriber::fmt() + .with_writer(sink) + .with_env_filter( + EnvFilter::builder() + .with_default_directive(env_filter.into()) + .from_env_lossy(), + ) + .init(); } diff --git a/orb-supervisor/tests/it/helpers.rs b/orb-supervisor/tests/it/helpers.rs index 2811fadc..b3e3664c 100644 --- a/orb-supervisor/tests/it/helpers.rs +++ b/orb-supervisor/tests/it/helpers.rs @@ -4,29 +4,49 @@ use dbus_launch::{ BusType, Daemon, }; -use orb_supervisor::startup::{ - Application, - Settings, +use once_cell::sync::Lazy; +use orb_supervisor::{ + startup::{ + Application, + Settings, + }, + telemetry, }; use tokio::{ task::JoinHandle, time::Duration, }; +use tracing_subscriber::filter::LevelFilter; use zbus::{ dbus_interface, dbus_proxy, + fdo, + zvariant::OwnedObjectPath, + ProxyDefault, SignalContext, }; +static TRACING: Lazy<()> = Lazy::new(|| { + let filter = LevelFilter::DEBUG; + if std::env::var("TEST_LOG").is_ok() { + telemetry::start(filter, std::io::stdout); + } else { + telemetry::start(filter, std::io::sink); + } +}); + pub struct DbusInstances { pub session: Daemon, + pub system: Daemon, } pub fn launch_dbuses() -> JoinHandle> { tokio::task::spawn_blocking(|| { let session = launch_session_dbus()?; + let system = launch_system_dbus()?; Ok(DbusInstances { session, + system, }) }) } @@ -37,14 +57,22 @@ pub fn launch_session_dbus() -> io::Result { .launch() } +pub fn launch_system_dbus() -> io::Result { + dbus_launch::Launcher::daemon() + .bus_type(BusType::System) + .launch() +} + pub fn make_settings(dbus_instances: &DbusInstances) -> Settings { Settings { session_dbus_path: dbus_instances.session.address().to_string().into(), + system_dbus_path: dbus_instances.system.address().to_string().into(), ..Default::default() } } pub async fn spawn_supervisor_service(settings: Settings) -> eyre::Result { + Lazy::force(&TRACING); let application = Application::build(settings.clone()).await?; Ok(application) } @@ -53,12 +81,15 @@ pub async fn spawn_supervisor_service(settings: Settings) -> eyre::Result zbus::Result; + + #[dbus_interface(name = "RequestUpdatePermission")] + fn request_update_permission(&self) -> zbus::fdo::Result; } pub async fn make_update_agent_proxy<'a>( settings: &'a Settings, dbus_instances: &DbusInstances, -) -> zbus::Result> { +) -> zbus::Result> { let connection = zbus::ConnectionBuilder::address(dbus_instances.session.address())? .build() .await?; @@ -99,3 +130,47 @@ pub async fn spawn_signup_start_task( } })) } + +struct Manager { + tx: Option>, +} + +#[dbus_interface(name = "org.freedesktop.systemd1.Manager")] +impl Manager { + #[dbus_interface(name = "StopUnit")] + async fn stop_unit(&mut self, name: String, mode: String) -> fdo::Result { + tracing::debug!("StopUnit called"); + let tx = self + .tx + .take() + .expect("Method must not be called more than once"); + tx.send((name.clone(), mode)) + .expect("Oneshot receiver must exist"); + OwnedObjectPath::try_from( + format!("/org/freedesktop/systemd1/unit/{name}") + .replace('-', "_2d") + .replace('.', "_2e"), + ) + .map_err(move |_| fdo::Error::UnknownObject(name)) + } +} + +pub async fn start_systemd_manager( + dbus_instances: &DbusInstances, +) -> zbus::Result<( + zbus::Connection, + tokio::sync::oneshot::Receiver<(String, String)>, +)> { + let (tx, rx) = tokio::sync::oneshot::channel(); + let conn = zbus::ConnectionBuilder::address(dbus_instances.system.address())? + .name(zbus_systemd::systemd1::ManagerProxy::DESTINATION)? + .serve_at( + zbus_systemd::systemd1::ManagerProxy::PATH, + Manager { + tx: tx.into(), + }, + )? + .build() + .await?; + Ok((conn, rx)) +} diff --git a/orb-supervisor/tests/it/main.rs b/orb-supervisor/tests/it/main.rs index 69ffecb6..15894202 100644 --- a/orb-supervisor/tests/it/main.rs +++ b/orb-supervisor/tests/it/main.rs @@ -37,3 +37,26 @@ async fn supervisor_disallows_downloads_if_signup_started_received() -> eyre::Re Ok(()) } + +#[tokio::test] +async fn supervisor_stops_orb_core_when_update_permission_is_requested() -> eyre::Result<()> { + let dbus_instances = helpers::launch_dbuses().await??; + + let settings = helpers::make_settings(&dbus_instances); + let application = helpers::spawn_supervisor_service(settings.clone()).await?; + let _application_handle = tokio::spawn(application.run()); + + let update_agent_proxy = helpers::make_update_agent_proxy(&settings, &dbus_instances).await?; + let (_systemd_conn, rx) = helpers::start_systemd_manager(&dbus_instances).await?; + + let (permission_given, stop_unit_args) = + tokio::join!(update_agent_proxy.request_update_permission(), rx); + + assert!(permission_given?); + + let (name, replace) = stop_unit_args?; + assert_eq!(name, "worldcoin-core.service"); + assert_eq!(replace, "replace"); + + Ok(()) +} From 9bf10aa2618bcf880133577d891bcbe8de09a983 Mon Sep 17 00:00:00 2001 From: Richard Janis Goldschmidt <701177+SuperFluffy@users.noreply.github.com> Date: Wed, 24 Aug 2022 15:14:38 +0200 Subject: [PATCH 08/38] Update to zbus 3 and use tokio's test-util API (#8) * Update to zbus 3 and use tokio's test-util API --- Cargo.toml | 3 +++ orb-supervisor/Cargo.toml | 4 +-- orb-supervisor/src/interfaces/manager.rs | 24 ++++++++---------- orb-supervisor/src/startup.rs | 6 +---- orb-supervisor/tests/it/helpers.rs | 26 ++++++++------------ orb-supervisor/tests/it/main.rs | 31 ++++++++---------------- 6 files changed, 36 insertions(+), 58 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 6419fdb2..5c7b6c47 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -3,3 +3,6 @@ members = [ "orb-mcu-schema", "orb-supervisor", ] + +[patch.crates-io] +zbus_systemd = { version = "0.0.5", git = "https://github.com/superfluffy/zbus_systemd", branch = "zbus_3" } diff --git a/orb-supervisor/Cargo.toml b/orb-supervisor/Cargo.toml index a5a9e0dc..32b36a03 100644 --- a/orb-supervisor/Cargo.toml +++ b/orb-supervisor/Cargo.toml @@ -15,8 +15,8 @@ tokio = { version = "1.19.2", features = ["macros", "net", "rt-multi-thread"] } tokio-stream = "0.1.9" tracing = { version = "0.1.35", features = ["attributes"] } tracing-subscriber = { version = "0.3.11", features = ["env-filter"] } -zbus = { version = "2.3.1", default-features = false, features = ["tokio"] } -zbus_systemd = { version = "0.0.4", features = ["systemd1"] } +zbus = { version = "3", default-features = false, features = ["tokio"] } +zbus_systemd = { version = "0.0.5", features = ["systemd1"] } thiserror = "1.0.31" futures = "0.3.21" once_cell = "1.13.0" diff --git a/orb-supervisor/src/interfaces/manager.rs b/orb-supervisor/src/interfaces/manager.rs index 6c8fa1a7..5dbae5ed 100644 --- a/orb-supervisor/src/interfaces/manager.rs +++ b/orb-supervisor/src/interfaces/manager.rs @@ -28,8 +28,8 @@ pub const INTERFACE_NAME: &str = "org.worldcoin.OrbSupervisor1.Manager"; pub const OBJECT_PATH: &str = "/org/worldcoin/OrbSupervisor1/Manager"; pub struct Manager { - last_signup_event: Instant, duration_to_allow_downloads: Duration, + last_signup_event: Instant, system_connection: Option, } @@ -37,21 +37,9 @@ impl Manager { /// Constructs a new `Manager` instance. #[allow(clippy::must_use_candidate)] pub fn new() -> Self { - Self::with_last_signup_event(Instant::now()) - } - - /// Constructs a new `Manager` instance with `last_signup_event` taken as the instant at - /// which the last signup event happened. - /// - /// This is primarily useful for integration tests. - /// - /// **NOTE** do not rely on this function as it will be removed once tokio's time API is - /// correctly respected inside zbus. - #[must_use] - pub fn with_last_signup_event(last_signup_event: Instant) -> Self { Self { - last_signup_event, duration_to_allow_downloads: DEFAULT_DURATION_TO_ALLOW_DOWNLOADS, + last_signup_event: Instant::now(), system_connection: None, } } @@ -102,7 +90,15 @@ impl Default for Manager { #[dbus_interface(name = "org.worldcoin.OrbSupervisor1.Manager")] impl Manager { #[dbus_interface(property, name = "BackgroundDownloadsAllowed")] + #[instrument( + name = "org.worldcoin.OrbSupervisor1.Manager.BackgroundDownloadsAllowed", + skip_all + )] async fn background_downloads_allowed(&self) -> bool { + debug!( + millis = self.last_signup_event.elapsed().as_millis(), + "time since last signup event", + ); self.are_downloads_allowed() } diff --git a/orb-supervisor/src/startup.rs b/orb-supervisor/src/startup.rs index 11ca34ab..b7c1a097 100644 --- a/orb-supervisor/src/startup.rs +++ b/orb-supervisor/src/startup.rs @@ -105,11 +105,7 @@ impl Application { "system dbus assigned unique bus name", ); - let mut manager = if let Some(last_event) = settings.manager_last_event { - interfaces::Manager::with_last_signup_event(last_event) - } else { - interfaces::Manager::new() - }; + let mut manager = interfaces::Manager::new(); manager.set_system_connection(system_connection.clone()); let session_builder = if let Some(path) = settings.session_dbus_path.as_deref() { diff --git a/orb-supervisor/tests/it/helpers.rs b/orb-supervisor/tests/it/helpers.rs index b3e3664c..583c9360 100644 --- a/orb-supervisor/tests/it/helpers.rs +++ b/orb-supervisor/tests/it/helpers.rs @@ -12,10 +12,7 @@ use orb_supervisor::{ }, telemetry, }; -use tokio::{ - task::JoinHandle, - time::Duration, -}; +use tokio::task::JoinHandle; use tracing_subscriber::filter::LevelFilter; use zbus::{ dbus_interface, @@ -94,6 +91,7 @@ pub async fn make_update_agent_proxy<'a>( .build() .await?; SignupProxy::builder(&connection) + .cache_properties(zbus::CacheProperties::No) .destination(settings.well_known_name.clone())? .path(settings.manager_object_path.clone())? .build() @@ -108,10 +106,10 @@ impl Signup { pub async fn signup_started(ctxt: &SignalContext<'_>) -> zbus::Result<()>; } -pub async fn spawn_signup_start_task( +pub async fn start_signup_service_and_send_signal( settings: &Settings, dbus_instances: &DbusInstances, -) -> zbus::Result>> { +) -> zbus::Result<()> { let conn = zbus::ConnectionBuilder::address(dbus_instances.session.address())? .name(settings.signup_proxy_well_known_name.clone())? .serve_at(settings.signup_proxy_object_path.clone(), Signup)? @@ -119,16 +117,12 @@ pub async fn spawn_signup_start_task( .await?; let signup_proxy_object_path = settings.signup_proxy_object_path.clone(); - Ok(tokio::spawn(async move { - loop { - Signup::signup_started(&zbus::SignalContext::new( - &conn, - signup_proxy_object_path.clone(), - )?) - .await?; - tokio::time::sleep(Duration::from_millis(100)).await; - } - })) + Signup::signup_started(&zbus::SignalContext::new( + &conn, + signup_proxy_object_path.clone(), + )?) + .await?; + Ok(()) } struct Manager { diff --git a/orb-supervisor/tests/it/main.rs b/orb-supervisor/tests/it/main.rs index 15894202..0302a864 100644 --- a/orb-supervisor/tests/it/main.rs +++ b/orb-supervisor/tests/it/main.rs @@ -1,39 +1,28 @@ -use tokio::time::{ - Duration, - Instant, -}; - pub mod helpers; #[tokio::test(start_paused = true)] async fn supervisor_disallows_downloads_if_signup_started_received() -> eyre::Result<()> { let dbus_instances = helpers::launch_dbuses().await??; - let mut settings = helpers::make_settings(&dbus_instances); - settings - .manager_last_event - .replace(Instant::now() - Duration::from_secs(3700)); + let settings = helpers::make_settings(&dbus_instances); let application = helpers::spawn_supervisor_service(settings.clone()).await?; let _application_handle = tokio::spawn(application.run()); let update_agent_proxy = helpers::make_update_agent_proxy(&settings, &dbus_instances).await?; - let downloads_are_allowed_initially = update_agent_proxy.background_downloads_allowed().await?; - assert!(downloads_are_allowed_initially); + let downloads_allowed_initially = update_agent_proxy.background_downloads_allowed().await?; + assert!(!downloads_allowed_initially); - let _signup_task_handle = helpers::spawn_signup_start_task(&settings, &dbus_instances).await?; + tokio::time::advance(orb_supervisor::interfaces::manager::DEFAULT_DURATION_TO_ALLOW_DOWNLOADS) + .await; - // FIXME: We want to use `#[tokio::test(start_paused = true)]` and `tokio::time::advance` here - // instead. Unfortunately, this does not currently play nicely with zbus, probably because of - // its internal executor. Once that is fixed upstream this should be changed to the mocked time - // API. - tokio::time::sleep(Duration::from_millis(500)).await; - // tokio::time::advance(Duration::from_millis(500)).await; + let downloads_allowed_after_period = update_agent_proxy.background_downloads_allowed().await?; + assert!(downloads_allowed_after_period); - let downloads_are_allowed_after_signal = - update_agent_proxy.background_downloads_allowed().await?; - assert!(!downloads_are_allowed_after_signal); + helpers::start_signup_service_and_send_signal(&settings, &dbus_instances).await?; + let downloads_allowed_after_signal = update_agent_proxy.background_downloads_allowed().await?; + assert!(!downloads_allowed_after_signal); Ok(()) } From 4cb30f724e7646a0c20ff123d406466b7d6a4140 Mon Sep 17 00:00:00 2001 From: Auguste Pugnet <90900126+gugus1@users.noreply.github.com> Date: Thu, 25 Aug 2022 14:31:23 +0200 Subject: [PATCH 09/38] Add workflows for uploading and releasing supervisor binaries (#10) Co-authored-by: Auguste Pugnet <90900126+gugus1@users.noreply.github.com> Co-authored-by: Richard Janis Goldschmidt <701177+SuperFluffy@users.noreply.github.com> --- .github/workflows/release.yml | 74 +++++++++++++++++++++++++++++++++++ 1 file changed, 74 insertions(+) create mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 00000000..77209071 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,74 @@ +name: Release +on: + push: + branches: [ main ] + tags: [ 'v*' ] + pull_request: + +jobs: + build: + runs-on: ubuntu-latest + steps: + - run: | + git config --global url."https://${{ secrets.RUNNER_TOKEN }}:x-oauth-basic@github.com/worldcoin/".insteadOf "ssh://git@github.com/worldcoin/" + git config --global url."https://${{ secrets.RUNNER_TOKEN }}:x-oauth-basic@github.com/worldcoin/".insteadOf "git@github.com:worldcoin/" + git config --global url."https://${{ secrets.RUNNER_TOKEN }}:x-oauth-basic@github.com/worldcoin/".insteadOf "https://github.com/worldcoin/" + - uses: actions/checkout@v3 + with: + token: ${{ secrets.RUNNER_TOKEN }} + submodules: recursive + - name: Install zig + uses: goto-bus-stop/setup-zig@v1 + with: + version: 0.9.1 + - uses: dtolnay/rust-toolchain@1.61.0 + with: + targets: aarch64-unknown-linux-gnu + - run: cargo install cargo-zigbuild + - name: Build orb-supervisor binary + run: cargo zigbuild --release --target aarch64-unknown-linux-gnu.2.27 -p orb-supervisor + - name: Cache orb-supervisor binary + uses: actions/cache@v3 + with: + path: target/aarch64-unknown-linux-gnu/release/orb-supervisor + key: ${{ github.run_id }}-${{ github.run_number }}-${{ github.run_attempt }}-orb-supervisor-bin + + upload: + needs: build + runs-on: ubuntu-latest + steps: + - name: Retrieve cache + id: cache + uses: actions/cache@v3 + with: + path: target/aarch64-unknown-linux-gnu/release/orb-supervisor + key: ${{ github.run_id }}-${{ github.run_number }}-${{ github.run_attempt }}-orb-supervisor-bin + - name: Upload binary artifacts + uses: actions/upload-artifact@v3 + with: + name: orb-supervisor + path: target/aarch64-unknown-linux-gnu/release/orb-supervisor + if-no-files-found: error + + release: + needs: build + runs-on: ubuntu-latest + if: startsWith(github.ref, 'refs/tags/') + steps: + - name: Get tag + id: tag + uses: dawidd6/action-get-tag@v1 + - name: Archive binary + shell: bash + run: | + cd target/aarch64-unknown-linux-gnu/release + tar cvzf orb-supervisor-${{ steps.tag.outputs.tag }}.tar.gz orb-supervisor + shasum -a 256 orb-supervisor-${{ steps.tag.outputs.tag }}.tar.gz > orb-supervisor-${{ steps.tag.outputs.tag }}.tar.gz.tar.gz.sha256 + cd - + - name: Make a github release from the binary + uses: softprops/action-gh-release@v1 + with: + files: | + target/aarch64-unknown-linux-gnu/release/orb-supervisor*.tar.gz + prerelease: ${{ contains(github.ref, 'alpha') || contains(github.ref, 'beta') || contains(github.ref, 'rc') }} + generate_release_notes: true From a730227a53c09812ebc4f6409d067f02857841bf Mon Sep 17 00:00:00 2001 From: Richard Janis Goldschmidt <701177+SuperFluffy@users.noreply.github.com> Date: Wed, 31 Aug 2022 09:26:34 +0200 Subject: [PATCH 10/38] Use released zbus_systemd not patch (#12) --- Cargo.toml | 3 --- 1 file changed, 3 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 5c7b6c47..6419fdb2 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -3,6 +3,3 @@ members = [ "orb-mcu-schema", "orb-supervisor", ] - -[patch.crates-io] -zbus_systemd = { version = "0.0.5", git = "https://github.com/superfluffy/zbus_systemd", branch = "zbus_3" } From fbfe868674a301bc196a12401336035ff8f8dbac Mon Sep 17 00:00:00 2001 From: Richard Janis Goldschmidt <701177+SuperFluffy@users.noreply.github.com> Date: Wed, 31 Aug 2022 11:27:02 +0200 Subject: [PATCH 11/38] supervisor: prepare release v0.1.0 (#13) --- orb-supervisor/CHANGELOG.md | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 orb-supervisor/CHANGELOG.md diff --git a/orb-supervisor/CHANGELOG.md b/orb-supervisor/CHANGELOG.md new file mode 100644 index 00000000..bb90f1d4 --- /dev/null +++ b/orb-supervisor/CHANGELOG.md @@ -0,0 +1,14 @@ +# Changelog + +## 0.1.0 (August 31, 2022) + +This is the first release of `orb-supervisor`. + +### Added + ++ Expose dbus property `org.worldcoin.OrbSupervisor1.Manager.BackgroundDownloadsAllowed`; + + Tracks how much time has passed since the last + `org.worldcoin.OrbCore1.Signup.SignupStarted` events; ++ Expose dbus method `org.worldcoin.OrbSupervisor1.Manager.RequestUpdatePermission`; + + attempts to shutdown `worldcoin-core.service` through + `org.freedesktop.systemd1.Manager.StopUnit`; From 3df2a65d9596302755e0e5bfedc076690f8a6d0f Mon Sep 17 00:00:00 2001 From: Richard Janis Goldschmidt <701177+SuperFluffy@users.noreply.github.com> Date: Wed, 31 Aug 2022 12:39:27 +0200 Subject: [PATCH 12/38] Rework github release workflows (#11) --- .github/workflows/general.yml | 6 +- .../{release.yml => release-binary.yml} | 58 +++++++++++-------- .github/workflows/release-library.yml | 38 ++++++++++++ 3 files changed, 74 insertions(+), 28 deletions(-) rename .github/workflows/{release.yml => release-binary.yml} (65%) create mode 100644 .github/workflows/release-library.yml diff --git a/.github/workflows/general.yml b/.github/workflows/general.yml index 26ffa425..e60b60d4 100644 --- a/.github/workflows/general.yml +++ b/.github/workflows/general.yml @@ -22,7 +22,7 @@ jobs: with: token: ${{ secrets.RUNNER_TOKEN }} submodules: recursive - - uses: actions/cache@v2 + - uses: actions/cache@v3 with: path: | ~/.cargo/bin/ @@ -38,7 +38,7 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 - - uses: actions/cache@v2 + - uses: actions/cache@v3 with: path: | ~/.cargo/bin/ @@ -64,7 +64,7 @@ jobs: with: token: ${{ secrets.RUNNER_TOKEN }} submodules: recursive - - uses: actions/cache@v2 + - uses: actions/cache@v3 with: path: | ~/.cargo/bin/ diff --git a/.github/workflows/release.yml b/.github/workflows/release-binary.yml similarity index 65% rename from .github/workflows/release.yml rename to .github/workflows/release-binary.yml index 77209071..da3c708f 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release-binary.yml @@ -1,9 +1,8 @@ -name: Release +name: Release binary on: push: - branches: [ main ] - tags: [ 'v*' ] - pull_request: + tags: + - orb-supervisor-[0-9]+.* jobs: build: @@ -17,6 +16,15 @@ jobs: with: token: ${{ secrets.RUNNER_TOKEN }} submodules: recursive + - uses: actions/cache@v3 + with: + path: | + ~/.cargo/bin/ + ~/.cargo/registry/index/ + ~/.cargo/registry/cache/ + ~/.cargo/git/db/ + target/ + key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} - name: Install zig uses: goto-bus-stop/setup-zig@v1 with: @@ -33,42 +41,42 @@ jobs: path: target/aarch64-unknown-linux-gnu/release/orb-supervisor key: ${{ github.run_id }}-${{ github.run_number }}-${{ github.run_attempt }}-orb-supervisor-bin - upload: + release: needs: build runs-on: ubuntu-latest steps: + - uses: actions/checkout@v3 + - name: Get tag + id: tag + uses: dawidd6/action-get-tag@v1 - name: Retrieve cache - id: cache uses: actions/cache@v3 with: path: target/aarch64-unknown-linux-gnu/release/orb-supervisor key: ${{ github.run_id }}-${{ github.run_number }}-${{ github.run_attempt }}-orb-supervisor-bin - - name: Upload binary artifacts - uses: actions/upload-artifact@v3 - with: - name: orb-supervisor - path: target/aarch64-unknown-linux-gnu/release/orb-supervisor - if-no-files-found: error - - release: - needs: build - runs-on: ubuntu-latest - if: startsWith(github.ref, 'refs/tags/') - steps: - - name: Get tag - id: tag - uses: dawidd6/action-get-tag@v1 - name: Archive binary shell: bash run: | cd target/aarch64-unknown-linux-gnu/release - tar cvzf orb-supervisor-${{ steps.tag.outputs.tag }}.tar.gz orb-supervisor - shasum -a 256 orb-supervisor-${{ steps.tag.outputs.tag }}.tar.gz > orb-supervisor-${{ steps.tag.outputs.tag }}.tar.gz.tar.gz.sha256 + tar cvzf ${{ steps.tag.outputs.tag }}.tar.gz orb-supervisor + shasum -a 256 ${{ steps.tag.outputs.tag }}.tar.gz > ${{ steps.tag.outputs.tag }}.tar.gz.sha256 cd - - - name: Make a github release from the binary + - name: Install changelog parser + uses: taiki-e/install-action@parse-changelog + - name: Generate changelog + id: changelog + shell: bash + run: | + title="$(parse-changelog -t orb-supervisor/CHANGELOG.md)" + notes="$(parse-changelog orb-supervisor/CHANGELOG.md)" + echo "::set-output name=title::$title" + echo "::set-output name=notes::$notes" + - name: Make a github release for the binary uses: softprops/action-gh-release@v1 with: files: | target/aarch64-unknown-linux-gnu/release/orb-supervisor*.tar.gz + fail_on_unmatched_files: true prerelease: ${{ contains(github.ref, 'alpha') || contains(github.ref, 'beta') || contains(github.ref, 'rc') }} - generate_release_notes: true + name: ${{ steps.changelog.outputs.title }} + body: ${{ steps.changelog.outputs.notes }} diff --git a/.github/workflows/release-library.yml b/.github/workflows/release-library.yml new file mode 100644 index 00000000..3e92633a --- /dev/null +++ b/.github/workflows/release-library.yml @@ -0,0 +1,38 @@ +name: Release library +on: + push: + tags: + - orb-supervisor-[a-z]+-[0-9]+.* + +jobs: + release: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - name: Get tag + id: tag + uses: dawidd6/action-get-tag@v1 + - name: Get prefix + id: prefix + shell: bash + run: | + [[ ${{ steps.tag.outputs.tag }} =~ ^(orb-supervisor-[a-z]+).* ]] && echo "::set-output name=prefix::${BASH_REMATCH[1]}" + - name: Install changelog parser + uses: taiki-e/install-action@parse-changelog + - name: Generate changelog + id: changelog + shell: bash + env: + PREFIFX: ${{ steps.prefix.outputs.prefix }} + run: | + title="$(parse-changelog -t $PREFIX/CHANGELOG.md)" + notes="$(parse-changelog $PREFIX/CHANGELOG.md)" + echo "::set-output name=title::$title" + echo "::set-output name=notes::$notes" + - name: Make a github release for the library + uses: softprops/action-gh-release@v1 + with: + prerelease: ${{ contains(github.ref, 'alpha') || contains(github.ref, 'beta') || contains(github.ref, 'rc') }} + body_path: ${{ steps.prefix.outputs.prefix }}/CHANGELOG.md + name: ${{ steps.changelog.outputs.title }} + body: ${{ steps.changelog.outputs.notes }} From 4c8b6ba32bc2e4718440189de98053f78d769f22 Mon Sep 17 00:00:00 2001 From: Richard Janis Goldschmidt <701177+SuperFluffy@users.noreply.github.com> Date: Mon, 19 Sep 2022 15:32:59 +0200 Subject: [PATCH 13/38] Fix release workflow changelog and title (#14) * Use crate names in release notes * Prefer GITHUB_ENV over outputs * Use EOF for multiline strings * Set correct prefix for library releases --- .github/workflows/release-binary.yml | 16 +++++++++------- .github/workflows/release-library.yml | 21 ++++++++++----------- 2 files changed, 19 insertions(+), 18 deletions(-) diff --git a/.github/workflows/release-binary.yml b/.github/workflows/release-binary.yml index da3c708f..63740070 100644 --- a/.github/workflows/release-binary.yml +++ b/.github/workflows/release-binary.yml @@ -63,14 +63,16 @@ jobs: cd - - name: Install changelog parser uses: taiki-e/install-action@parse-changelog - - name: Generate changelog + - name: Read changelog contents id: changelog shell: bash run: | - title="$(parse-changelog -t orb-supervisor/CHANGELOG.md)" - notes="$(parse-changelog orb-supervisor/CHANGELOG.md)" - echo "::set-output name=title::$title" - echo "::set-output name=notes::$notes" + echo 'TITLE<> $GITHUB_ENV + parse-changelog -t orb-supervisor/CHANGELOG.md >> $GITHUB_ENV + echo 'EOF' >> $GITHUB_ENV + echo 'NOTES<> $GITHUB_ENV + parse-changelog orb-supervisor/CHANGELOG.md >> $GITHUB_ENV + echo 'EOF' >> $GITHUB_ENV - name: Make a github release for the binary uses: softprops/action-gh-release@v1 with: @@ -78,5 +80,5 @@ jobs: target/aarch64-unknown-linux-gnu/release/orb-supervisor*.tar.gz fail_on_unmatched_files: true prerelease: ${{ contains(github.ref, 'alpha') || contains(github.ref, 'beta') || contains(github.ref, 'rc') }} - name: ${{ steps.changelog.outputs.title }} - body: ${{ steps.changelog.outputs.notes }} + name: orb-supervisor ${{ env.TITLE }} + body: ${{ env.NOTES }} diff --git a/.github/workflows/release-library.yml b/.github/workflows/release-library.yml index 3e92633a..c7dec1ad 100644 --- a/.github/workflows/release-library.yml +++ b/.github/workflows/release-library.yml @@ -12,27 +12,26 @@ jobs: - name: Get tag id: tag uses: dawidd6/action-get-tag@v1 - - name: Get prefix + - name: Read tag prefix id: prefix shell: bash run: | [[ ${{ steps.tag.outputs.tag }} =~ ^(orb-supervisor-[a-z]+).* ]] && echo "::set-output name=prefix::${BASH_REMATCH[1]}" - name: Install changelog parser uses: taiki-e/install-action@parse-changelog - - name: Generate changelog + - name: Read changelog contents id: changelog shell: bash - env: - PREFIFX: ${{ steps.prefix.outputs.prefix }} run: | - title="$(parse-changelog -t $PREFIX/CHANGELOG.md)" - notes="$(parse-changelog $PREFIX/CHANGELOG.md)" - echo "::set-output name=title::$title" - echo "::set-output name=notes::$notes" + echo 'TITLE<> $GITHUB_ENV + parse-changelog -t ${{ steps.prefix.outputs.prefix }}/CHANGELOG.md >> $GITHUB_ENV + echo 'EOF' >> $GITHUB_ENV + echo 'NOTES<> $GITHUB_ENV + parse-changelog ${{ steps.prefix.outputs.prefix }}/CHANGELOG.md >> $GITHUB_ENV + echo 'EOF' >> $GITHUB_ENV - name: Make a github release for the library uses: softprops/action-gh-release@v1 with: prerelease: ${{ contains(github.ref, 'alpha') || contains(github.ref, 'beta') || contains(github.ref, 'rc') }} - body_path: ${{ steps.prefix.outputs.prefix }}/CHANGELOG.md - name: ${{ steps.changelog.outputs.title }} - body: ${{ steps.changelog.outputs.notes }} + name: ${{ steps.prefix.outputs.prefix }} ${{ env.TITLE }} + body: ${{ env.NOTES }} From 7b02f478401e25a77fb629a79db8cee47d3d06fc Mon Sep 17 00:00:00 2001 From: Richard Janis Goldschmidt <701177+SuperFluffy@users.noreply.github.com> Date: Mon, 10 Oct 2022 15:12:05 +0200 Subject: [PATCH 14/38] Update dependencies and check in lock file (#16) --- .github/workflows/general.yml | 6 +- .github/workflows/release-binary.yml | 6 +- .gitignore | 1 - .gitmodules | 3 - Cargo.lock | 1187 ++++++++++++++++++++++++++ Cargo.toml | 1 - orb-mcu-schema/Cargo.toml | 12 - orb-mcu-schema/build.rs | 11 - orb-mcu-schema/src/lib.rs | 3 - orb-supervisor/Cargo.toml | 24 +- orb-supervisor/README.md | 2 +- protobuf-definitions | 1 - 12 files changed, 1205 insertions(+), 52 deletions(-) delete mode 100644 .gitmodules create mode 100644 Cargo.lock delete mode 100644 orb-mcu-schema/Cargo.toml delete mode 100644 orb-mcu-schema/build.rs delete mode 100644 orb-mcu-schema/src/lib.rs delete mode 160000 protobuf-definitions diff --git a/.github/workflows/general.yml b/.github/workflows/general.yml index e60b60d4..b4bb41e4 100644 --- a/.github/workflows/general.yml +++ b/.github/workflows/general.yml @@ -15,9 +15,9 @@ jobs: RUSTFLAGS: "-D warnings -W unreachable-pub -W rust-2021-compatibility" steps: - run: | - git config --global url."https://${{ secrets.RUNNER_TOKEN }}:x-oauth-basic@github.com/worldcoin/".insteadOf "ssh://git@github.com/worldcoin/" - git config --global url."https://${{ secrets.RUNNER_TOKEN }}:x-oauth-basic@github.com/worldcoin/".insteadOf "git@github.com:worldcoin/" - git config --global url."https://${{ secrets.RUNNER_TOKEN }}:x-oauth-basic@github.com/worldcoin/".insteadOf "https://github.com/worldcoin/" + git config --global --add url."https://${{ secrets.RUNNER_TOKEN }}:x-oauth-basic@github.com/worldcoin/".insteadOf "ssh://git@github.com/worldcoin/" + git config --global --add url."https://${{ secrets.RUNNER_TOKEN }}:x-oauth-basic@github.com/worldcoin/".insteadOf "git@github.com:worldcoin/" + git config --global --add url."https://${{ secrets.RUNNER_TOKEN }}:x-oauth-basic@github.com/worldcoin/".insteadOf "https://github.com/worldcoin/" - uses: actions/checkout@v3 with: token: ${{ secrets.RUNNER_TOKEN }} diff --git a/.github/workflows/release-binary.yml b/.github/workflows/release-binary.yml index 63740070..e7226a71 100644 --- a/.github/workflows/release-binary.yml +++ b/.github/workflows/release-binary.yml @@ -9,9 +9,9 @@ jobs: runs-on: ubuntu-latest steps: - run: | - git config --global url."https://${{ secrets.RUNNER_TOKEN }}:x-oauth-basic@github.com/worldcoin/".insteadOf "ssh://git@github.com/worldcoin/" - git config --global url."https://${{ secrets.RUNNER_TOKEN }}:x-oauth-basic@github.com/worldcoin/".insteadOf "git@github.com:worldcoin/" - git config --global url."https://${{ secrets.RUNNER_TOKEN }}:x-oauth-basic@github.com/worldcoin/".insteadOf "https://github.com/worldcoin/" + git config --global --add url."https://${{ secrets.RUNNER_TOKEN }}:x-oauth-basic@github.com/worldcoin/".insteadOf "ssh://git@github.com/worldcoin/" + git config --global --add url."https://${{ secrets.RUNNER_TOKEN }}:x-oauth-basic@github.com/worldcoin/".insteadOf "git@github.com:worldcoin/" + git config --global --add url."https://${{ secrets.RUNNER_TOKEN }}:x-oauth-basic@github.com/worldcoin/".insteadOf "https://github.com/worldcoin/" - uses: actions/checkout@v3 with: token: ${{ secrets.RUNNER_TOKEN }} diff --git a/.gitignore b/.gitignore index 96ef6c0b..ea8c4bf7 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1 @@ /target -Cargo.lock diff --git a/.gitmodules b/.gitmodules deleted file mode 100644 index fec9a8bf..00000000 --- a/.gitmodules +++ /dev/null @@ -1,3 +0,0 @@ -[submodule "protobuf-definitions"] - path = protobuf-definitions - url = git@github.com:worldcoin/protobuf-definitions.git diff --git a/Cargo.lock b/Cargo.lock new file mode 100644 index 00000000..5c6b969d --- /dev/null +++ b/Cargo.lock @@ -0,0 +1,1187 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 3 + +[[package]] +name = "aho-corasick" +version = "0.7.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b4f55bd91a0978cbfd91c457a164bab8b4001c833b7f323132c0a4e1922dd44e" +dependencies = [ + "memchr", +] + +[[package]] +name = "async-broadcast" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6d26004fe83b2d1cd3a97609b21e39f9a31535822210fe83205d2ce48866ea61" +dependencies = [ + "event-listener", + "futures-core", + "parking_lot", +] + +[[package]] +name = "async-channel" +version = "1.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e14485364214912d3b19cc3435dde4df66065127f05fa0d75c712f36f12c2f28" +dependencies = [ + "concurrent-queue", + "event-listener", + "futures-core", +] + +[[package]] +name = "async-executor" +version = "1.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "871f9bb5e0a22eeb7e8cf16641feb87c9dc67032ccf8ff49e772eb9941d3a965" +dependencies = [ + "async-task", + "concurrent-queue", + "fastrand", + "futures-lite", + "once_cell", + "slab", +] + +[[package]] +name = "async-io" +version = "1.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "83e21f3a490c72b3b0cf44962180e60045de2925d8dff97918f7ee43c8f637c7" +dependencies = [ + "autocfg", + "concurrent-queue", + "futures-lite", + "libc", + "log", + "once_cell", + "parking", + "polling", + "slab", + "socket2", + "waker-fn", + "winapi", +] + +[[package]] +name = "async-lock" +version = "2.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e97a171d191782fba31bb902b14ad94e24a68145032b7eedf871ab0bc0d077b6" +dependencies = [ + "event-listener", +] + +[[package]] +name = "async-recursion" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d7d78656ba01f1b93024b7c3a0467f1608e4be67d725749fdcd7d2c7678fd7a2" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "async-task" +version = "4.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7a40729d2133846d9ed0ea60a8b9541bccddab49cd30f0715a1da672fe9a2524" + +[[package]] +name = "async-trait" +version = "0.1.57" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "76464446b8bc32758d7e88ee1a804d9914cd9b1cb264c029899680b0be29826f" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "autocfg" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" + +[[package]] +name = "bitflags" +version = "1.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" + +[[package]] +name = "byteorder" +version = "1.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "14c189c53d098945499cdfa7ecc63567cf3886b3332b312a5b4585d8d3a6a610" + +[[package]] +name = "bytes" +version = "1.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ec8a7b6a70fde80372154c65702f00a0f56f3e1c36abbc6c440484be248856db" + +[[package]] +name = "cache-padded" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c1db59621ec70f09c5e9b597b220c7a2b43611f4710dc03ceb8748637775692c" + +[[package]] +name = "cc" +version = "1.0.73" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2fff2a6927b3bb87f9595d67196a70493f627687a71d87a0d692242c33f58c11" + +[[package]] +name = "cfg-if" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" + +[[package]] +name = "concurrent-queue" +version = "1.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "af4780a44ab5696ea9e28294517f1fffb421a83a25af521333c838635509db9c" +dependencies = [ + "cache-padded", +] + +[[package]] +name = "dbus-launch" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7b605c1a7f0ca11e477d0eb78505f22e2337fd102e880eb5a357d10c080e02b1" +dependencies = [ + "libc", + "tempfile", +] + +[[package]] +name = "derivative" +version = "2.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fcc3dd5e9e9c0b295d6e1e4d811fb6f157d5ffd784b8d202fc62eac8035a770b" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "dirs" +version = "4.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ca3aa72a6f96ea37bbc5aa912f6788242832f75369bdfdadcb0e38423f100059" +dependencies = [ + "dirs-sys", +] + +[[package]] +name = "dirs-sys" +version = "0.3.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1b1d1d91c932ef41c0f2663aa8b0ca0342d444d842c06914aa0a7e352d0bada6" +dependencies = [ + "libc", + "redox_users", + "winapi", +] + +[[package]] +name = "enumflags2" +version = "0.7.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e75d4cd21b95383444831539909fbb14b9dc3fdceb2a6f5d36577329a1f55ccb" +dependencies = [ + "enumflags2_derive", + "serde", +] + +[[package]] +name = "enumflags2_derive" +version = "0.7.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f58dc3c5e468259f19f2d46304a6b28f1c3d034442e14b322d2b850e36f6d5ae" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "event-listener" +version = "2.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0206175f82b8d6bf6652ff7d71a1e27fd2e4efde587fd368662814d6ec1d9ce0" + +[[package]] +name = "eyre" +version = "0.6.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4c2b6b5a29c02cdc822728b7d7b8ae1bab3e3b05d44522770ddd49722eeac7eb" +dependencies = [ + "indenter", + "once_cell", +] + +[[package]] +name = "fastrand" +version = "1.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a7a407cfaa3385c4ae6b23e84623d48c2798d06e3e6a1878f7f59f17b3f86499" +dependencies = [ + "instant", +] + +[[package]] +name = "futures" +version = "0.3.24" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f21eda599937fba36daeb58a22e8f5cee2d14c4a17b5b7739c7c8e5e3b8230c" +dependencies = [ + "futures-channel", + "futures-core", + "futures-executor", + "futures-io", + "futures-sink", + "futures-task", + "futures-util", +] + +[[package]] +name = "futures-channel" +version = "0.3.24" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "30bdd20c28fadd505d0fd6712cdfcb0d4b5648baf45faef7f852afb2399bb050" +dependencies = [ + "futures-core", + "futures-sink", +] + +[[package]] +name = "futures-core" +version = "0.3.24" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4e5aa3de05362c3fb88de6531e6296e85cde7739cccad4b9dfeeb7f6ebce56bf" + +[[package]] +name = "futures-executor" +version = "0.3.24" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9ff63c23854bee61b6e9cd331d523909f238fc7636290b96826e9cfa5faa00ab" +dependencies = [ + "futures-core", + "futures-task", + "futures-util", +] + +[[package]] +name = "futures-io" +version = "0.3.24" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bbf4d2a7a308fd4578637c0b17c7e1c7ba127b8f6ba00b29f717e9655d85eb68" + +[[package]] +name = "futures-lite" +version = "1.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7694489acd39452c77daa48516b894c153f192c3578d5a839b62c58099fcbf48" +dependencies = [ + "fastrand", + "futures-core", + "futures-io", + "memchr", + "parking", + "pin-project-lite", + "waker-fn", +] + +[[package]] +name = "futures-macro" +version = "0.3.24" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "42cd15d1c7456c04dbdf7e88bcd69760d74f3a798d6444e16974b505b0e62f17" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "futures-sink" +version = "0.3.24" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "21b20ba5a92e727ba30e72834706623d94ac93a725410b6a6b6fbc1b07f7ba56" + +[[package]] +name = "futures-task" +version = "0.3.24" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a6508c467c73851293f390476d4491cf4d227dbabcd4170f3bb6044959b294f1" + +[[package]] +name = "futures-util" +version = "0.3.24" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "44fb6cb1be61cc1d2e43b262516aafcf63b241cffdb1d3fa115f91d9c7b09c90" +dependencies = [ + "futures-channel", + "futures-core", + "futures-io", + "futures-macro", + "futures-sink", + "futures-task", + "memchr", + "pin-project-lite", + "pin-utils", + "slab", +] + +[[package]] +name = "getrandom" +version = "0.2.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4eb1a864a501629691edf6c15a593b7a51eebaa1e8468e9ddc623de7c9b58ec6" +dependencies = [ + "cfg-if", + "libc", + "wasi", +] + +[[package]] +name = "hermit-abi" +version = "0.1.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "62b467343b94ba476dcb2500d242dadbb39557df889310ac77c5d99100aaac33" +dependencies = [ + "libc", +] + +[[package]] +name = "hex" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" + +[[package]] +name = "indenter" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ce23b50ad8242c51a442f3ff322d56b02f08852c77e4c0b4d3fd684abc89c683" + +[[package]] +name = "instant" +version = "0.1.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7a5bbe824c507c5da5956355e86a746d82e0e1464f65d862cc5e71da70e94b2c" +dependencies = [ + "cfg-if", +] + +[[package]] +name = "lazy_static" +version = "1.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" + +[[package]] +name = "libc" +version = "0.2.134" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "329c933548736bc49fd575ee68c89e8be4d260064184389a5b77517cddd99ffb" + +[[package]] +name = "listenfd" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "14e4fcc00ff6731d94b70e16e71f43bda62883461f31230742e3bc6dddf12988" +dependencies = [ + "libc", + "uuid", + "winapi", +] + +[[package]] +name = "lock_api" +version = "0.4.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "435011366fe56583b16cf956f9df0095b405b82d76425bc8981c0e22e60ec4df" +dependencies = [ + "autocfg", + "scopeguard", +] + +[[package]] +name = "log" +version = "0.4.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "abb12e687cfb44aa40f41fc3978ef76448f9b6038cad6aef4259d3c095a2382e" +dependencies = [ + "cfg-if", +] + +[[package]] +name = "matchers" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8263075bb86c5a1b1427b5ae862e8889656f126e9f77c484496e8b47cf5c5558" +dependencies = [ + "regex-automata", +] + +[[package]] +name = "memchr" +version = "2.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d" + +[[package]] +name = "memoffset" +version = "0.6.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5aa361d4faea93603064a027415f07bd8e1d5c88c9fbf68bf56a285428fd79ce" +dependencies = [ + "autocfg", +] + +[[package]] +name = "mio" +version = "0.8.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "57ee1c23c7c63b0c9250c339ffdc69255f110b298b901b9f6c82547b7b87caaf" +dependencies = [ + "libc", + "log", + "wasi", + "windows-sys", +] + +[[package]] +name = "nix" +version = "0.24.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "195cdbc1741b8134346d515b3a56a1c94b0912758009cfd53f99ea0f57b065fc" +dependencies = [ + "bitflags", + "cfg-if", + "libc", + "memoffset", +] + +[[package]] +name = "nu-ansi-term" +version = "0.46.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "77a8165726e8236064dbb45459242600304b42a5ea24ee2948e18e023bf7ba84" +dependencies = [ + "overload", + "winapi", +] + +[[package]] +name = "num_cpus" +version = "1.13.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "19e64526ebdee182341572e50e9ad03965aa510cd94427a4549448f285e957a1" +dependencies = [ + "hermit-abi", + "libc", +] + +[[package]] +name = "once_cell" +version = "1.15.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e82dad04139b71a90c080c8463fe0dc7902db5192d939bd0950f074d014339e1" + +[[package]] +name = "orb-supervisor" +version = "0.1.0" +dependencies = [ + "dbus-launch", + "eyre", + "futures", + "libc", + "listenfd", + "once_cell", + "thiserror", + "tokio", + "tokio-stream", + "tracing", + "tracing-subscriber", + "zbus", + "zbus_systemd", +] + +[[package]] +name = "ordered-stream" +version = "0.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "44630c059eacfd6e08bdaa51b1db2ce33119caa4ddc1235e923109aa5f25ccb1" +dependencies = [ + "futures-core", + "pin-project-lite", +] + +[[package]] +name = "overload" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b15813163c1d831bf4a13c3610c05c0d03b39feb07f7e09fa234dac9b15aaf39" + +[[package]] +name = "parking" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "427c3892f9e783d91cc128285287e70a59e206ca452770ece88a76f7a3eddd72" + +[[package]] +name = "parking_lot" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3742b2c103b9f06bc9fff0a37ff4912935851bee6d36f3c02bcc755bcfec228f" +dependencies = [ + "lock_api", + "parking_lot_core", +] + +[[package]] +name = "parking_lot_core" +version = "0.9.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09a279cbf25cb0757810394fbc1e359949b59e348145c643a939a525692e6929" +dependencies = [ + "cfg-if", + "libc", + "redox_syscall", + "smallvec", + "windows-sys", +] + +[[package]] +name = "pin-project-lite" +version = "0.2.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e0a7ae3ac2f1173085d398531c705756c94a4c56843785df85a60c1a0afac116" + +[[package]] +name = "pin-utils" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" + +[[package]] +name = "polling" +version = "2.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "899b00b9c8ab553c743b3e11e87c5c7d423b2a2de229ba95b24a756344748011" +dependencies = [ + "autocfg", + "cfg-if", + "libc", + "log", + "wepoll-ffi", + "winapi", +] + +[[package]] +name = "ppv-lite86" +version = "0.2.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eb9f9e6e233e5c4a35559a617bf40a4ec447db2e84c20b55a6f83167b7e57872" + +[[package]] +name = "proc-macro-crate" +version = "1.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eda0fc3b0fb7c975631757e14d9049da17374063edb6ebbcbc54d880d4fe94e9" +dependencies = [ + "once_cell", + "thiserror", + "toml", +] + +[[package]] +name = "proc-macro2" +version = "1.0.46" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "94e2ef8dbfc347b10c094890f778ee2e36ca9bb4262e86dc99cd217e35f3470b" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "quote" +version = "1.0.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bbe448f377a7d6961e30f5955f9b8d106c3f5e449d493ee1b125c1d43c2b5179" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "rand" +version = "0.8.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404" +dependencies = [ + "libc", + "rand_chacha", + "rand_core", +] + +[[package]] +name = "rand_chacha" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88" +dependencies = [ + "ppv-lite86", + "rand_core", +] + +[[package]] +name = "rand_core" +version = "0.6.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" +dependencies = [ + "getrandom", +] + +[[package]] +name = "redox_syscall" +version = "0.2.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fb5a58c1855b4b6819d59012155603f0b22ad30cad752600aadfcb695265519a" +dependencies = [ + "bitflags", +] + +[[package]] +name = "redox_users" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b033d837a7cf162d7993aded9304e30a83213c648b6e389db233191f891e5c2b" +dependencies = [ + "getrandom", + "redox_syscall", + "thiserror", +] + +[[package]] +name = "regex" +version = "1.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4c4eb3267174b8c6c2f654116623910a0fef09c4753f8dd83db29c48a0df988b" +dependencies = [ + "aho-corasick", + "memchr", + "regex-syntax", +] + +[[package]] +name = "regex-automata" +version = "0.1.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6c230d73fb8d8c1b9c0b3135c5142a8acee3a0558fb8db5cf1cb65f8d7862132" +dependencies = [ + "regex-syntax", +] + +[[package]] +name = "regex-syntax" +version = "0.6.27" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a3f87b73ce11b1619a3c6332f45341e0047173771e8b8b73f87bfeefb7b56244" + +[[package]] +name = "remove_dir_all" +version = "0.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3acd125665422973a33ac9d3dd2df85edad0f4ae9b00dafb1a05e43a9f5ef8e7" +dependencies = [ + "winapi", +] + +[[package]] +name = "scopeguard" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd" + +[[package]] +name = "serde" +version = "1.0.145" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "728eb6351430bccb993660dfffc5a72f91ccc1295abaa8ce19b27ebe4f75568b" +dependencies = [ + "serde_derive", +] + +[[package]] +name = "serde_derive" +version = "1.0.145" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "81fa1584d3d1bcacd84c277a0dfe21f5b0f6accf4a23d04d4c6d61f1af522b4c" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "serde_repr" +version = "0.1.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1fe39d9fbb0ebf5eb2c7cb7e2a47e4f462fad1379f1166b8ae49ad9eae89a7ca" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "sha1" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c1da05c97445caa12d05e848c4a4fcbbea29e748ac28f7e80e9b010392063770" +dependencies = [ + "sha1_smol", +] + +[[package]] +name = "sha1_smol" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ae1a47186c03a32177042e55dbc5fd5aee900b8e0069a8d70fba96a9375cd012" + +[[package]] +name = "sharded-slab" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "900fba806f70c630b0a382d0d825e17a0f19fcd059a2ade1ff237bcddf446b31" +dependencies = [ + "lazy_static", +] + +[[package]] +name = "slab" +version = "0.4.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4614a76b2a8be0058caa9dbbaf66d988527d86d003c11a94fbd335d7661edcef" +dependencies = [ + "autocfg", +] + +[[package]] +name = "smallvec" +version = "1.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a507befe795404456341dfab10cef66ead4c041f62b8b11bbb92bffe5d0953e0" + +[[package]] +name = "socket2" +version = "0.4.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "02e2d2db9033d13a1567121ddd7a095ee144db4e1ca1b1bda3419bc0da294ebd" +dependencies = [ + "libc", + "winapi", +] + +[[package]] +name = "static_assertions" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" + +[[package]] +name = "syn" +version = "1.0.102" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3fcd952facd492f9be3ef0d0b7032a6e442ee9b361d4acc2b1d0c4aaa5f613a1" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "tempfile" +version = "3.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5cdb1ef4eaeeaddc8fbd371e5017057064af0911902ef36b39801f67cc6d79e4" +dependencies = [ + "cfg-if", + "fastrand", + "libc", + "redox_syscall", + "remove_dir_all", + "winapi", +] + +[[package]] +name = "thiserror" +version = "1.0.37" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "10deb33631e3c9018b9baf9dcbbc4f737320d2b576bac10f6aefa048fa407e3e" +dependencies = [ + "thiserror-impl", +] + +[[package]] +name = "thiserror-impl" +version = "1.0.37" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "982d17546b47146b28f7c22e3d08465f6b8903d0ea13c1660d9d84a6e7adcdbb" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "thread_local" +version = "1.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5516c27b78311c50bf42c071425c560ac799b11c30b31f87e3081965fe5e0180" +dependencies = [ + "once_cell", +] + +[[package]] +name = "tokio" +version = "1.21.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a9e03c497dc955702ba729190dc4aac6f2a0ce97f913e5b1b5912fc5039d9099" +dependencies = [ + "autocfg", + "bytes", + "libc", + "memchr", + "mio", + "num_cpus", + "pin-project-lite", + "socket2", + "tokio-macros", + "winapi", +] + +[[package]] +name = "tokio-macros" +version = "1.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9724f9a975fb987ef7a3cd9be0350edcbe130698af5b8f7a631e23d42d052484" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "tokio-stream" +version = "0.1.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f6edf2d6bc038a43d31353570e27270603f4648d18f5ed10c0e179abe43255af" +dependencies = [ + "futures-core", + "pin-project-lite", + "tokio", +] + +[[package]] +name = "toml" +version = "0.5.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8d82e1a7758622a465f8cee077614c73484dac5b836c02ff6a40d5d1010324d7" +dependencies = [ + "serde", +] + +[[package]] +name = "tracing" +version = "0.1.37" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8ce8c33a8d48bd45d624a6e523445fd21ec13d3653cd51f681abf67418f54eb8" +dependencies = [ + "cfg-if", + "pin-project-lite", + "tracing-attributes", + "tracing-core", +] + +[[package]] +name = "tracing-attributes" +version = "0.1.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4017f8f45139870ca7e672686113917c71c7a6e02d4924eda67186083c03081a" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "tracing-core" +version = "0.1.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "24eb03ba0eab1fd845050058ce5e616558e8f8d8fca633e6b163fe25c797213a" +dependencies = [ + "once_cell", + "valuable", +] + +[[package]] +name = "tracing-log" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "78ddad33d2d10b1ed7eb9d1f518a5674713876e97e5bb9b7345a7984fbb4f922" +dependencies = [ + "lazy_static", + "log", + "tracing-core", +] + +[[package]] +name = "tracing-subscriber" +version = "0.3.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a6176eae26dd70d0c919749377897b54a9276bd7061339665dd68777926b5a70" +dependencies = [ + "matchers", + "nu-ansi-term", + "once_cell", + "regex", + "sharded-slab", + "smallvec", + "thread_local", + "tracing", + "tracing-core", + "tracing-log", +] + +[[package]] +name = "uds_windows" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ce65604324d3cce9b966701489fbd0cf318cb1f7bd9dd07ac9a4ee6fb791930d" +dependencies = [ + "tempfile", + "winapi", +] + +[[package]] +name = "unicode-ident" +version = "1.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6ceab39d59e4c9499d4e5a8ee0e2735b891bb7308ac83dfb4e80cad195c9f6f3" + +[[package]] +name = "uuid" +version = "1.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "feb41e78f93363bb2df8b0e86a2ca30eed7806ea16ea0c790d757cf93f79be83" + +[[package]] +name = "valuable" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "830b7e5d4d90034032940e4ace0d9a9a057e7a45cd94e6c007832e39edb82f6d" + +[[package]] +name = "waker-fn" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9d5b2c62b4012a3e1eca5a7e077d13b3bf498c4073e33ccd58626607748ceeca" + +[[package]] +name = "wasi" +version = "0.11.0+wasi-snapshot-preview1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" + +[[package]] +name = "wepoll-ffi" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d743fdedc5c64377b5fc2bc036b01c7fd642205a0d96356034ae3404d49eb7fb" +dependencies = [ + "cc", +] + +[[package]] +name = "winapi" +version = "0.3.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" +dependencies = [ + "winapi-i686-pc-windows-gnu", + "winapi-x86_64-pc-windows-gnu", +] + +[[package]] +name = "winapi-i686-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" + +[[package]] +name = "winapi-x86_64-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" + +[[package]] +name = "windows-sys" +version = "0.36.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ea04155a16a59f9eab786fe12a4a450e75cdb175f9e0d80da1e17db09f55b8d2" +dependencies = [ + "windows_aarch64_msvc", + "windows_i686_gnu", + "windows_i686_msvc", + "windows_x86_64_gnu", + "windows_x86_64_msvc", +] + +[[package]] +name = "windows_aarch64_msvc" +version = "0.36.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9bb8c3fd39ade2d67e9874ac4f3db21f0d710bee00fe7cab16949ec184eeaa47" + +[[package]] +name = "windows_i686_gnu" +version = "0.36.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "180e6ccf01daf4c426b846dfc66db1fc518f074baa793aa7d9b9aaeffad6a3b6" + +[[package]] +name = "windows_i686_msvc" +version = "0.36.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e2e7917148b2812d1eeafaeb22a97e4813dfa60a3f8f78ebe204bcc88f12f024" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.36.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4dcd171b8776c41b97521e5da127a2d86ad280114807d0b2ab1e462bc764d9e1" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.36.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c811ca4a8c853ef420abd8592ba53ddbbac90410fab6903b3e79972a631f7680" + +[[package]] +name = "zbus" +version = "3.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "be2db10dd0354816a3615c72deff837f983d5c8ad9a0312727d0f89a5a9e9145" +dependencies = [ + "async-broadcast", + "async-channel", + "async-executor", + "async-io", + "async-lock", + "async-recursion", + "async-task", + "async-trait", + "byteorder", + "derivative", + "dirs", + "enumflags2", + "event-listener", + "futures-core", + "futures-sink", + "futures-util", + "hex", + "lazy_static", + "nix", + "once_cell", + "ordered-stream", + "rand", + "serde", + "serde_repr", + "sha1", + "static_assertions", + "tokio", + "tracing", + "uds_windows", + "winapi", + "zbus_macros", + "zbus_names", + "zvariant", +] + +[[package]] +name = "zbus_macros" +version = "3.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7d03f1a5fb482cc0d97f3d3de9fe2e942f436a635a5fb6c12c9f03f21eb03075" +dependencies = [ + "proc-macro-crate", + "proc-macro2", + "quote", + "regex", + "syn", +] + +[[package]] +name = "zbus_names" +version = "2.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "41a408fd8a352695690f53906dc7fd036be924ec51ea5e05666ff42685ed0af5" +dependencies = [ + "serde", + "static_assertions", + "zvariant", +] + +[[package]] +name = "zbus_systemd" +version = "0.0.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f05d5be083af02c7f1e641f3e4f5a316721d561a3bbb7e7f216969ce25005bd1" +dependencies = [ + "futures", + "serde", + "zbus", +] + +[[package]] +name = "zvariant" +version = "3.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b794fb7f59af4105697b0449ba31731ee5dbb3e773a17dbdf3d36206ea1b1644" +dependencies = [ + "byteorder", + "enumflags2", + "libc", + "serde", + "static_assertions", + "zvariant_derive", +] + +[[package]] +name = "zvariant_derive" +version = "3.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dd58d4b6c8e26d3dd2149c8c40c6613ef6451b9885ff1296d1ac86c388351a54" +dependencies = [ + "proc-macro-crate", + "proc-macro2", + "quote", + "syn", +] diff --git a/Cargo.toml b/Cargo.toml index 6419fdb2..21010784 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,5 +1,4 @@ [workspace] members = [ - "orb-mcu-schema", "orb-supervisor", ] diff --git a/orb-mcu-schema/Cargo.toml b/orb-mcu-schema/Cargo.toml deleted file mode 100644 index f47d09f0..00000000 --- a/orb-mcu-schema/Cargo.toml +++ /dev/null @@ -1,12 +0,0 @@ -[package] -name = "orb-mcu-schema" -version = "0.1.0" -edition = "2021" - -# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html - -[dependencies] -prost = "0.10.4" - -[build-dependencies] -prost-build = "0.10.4" diff --git a/orb-mcu-schema/build.rs b/orb-mcu-schema/build.rs deleted file mode 100644 index d68f6cf2..00000000 --- a/orb-mcu-schema/build.rs +++ /dev/null @@ -1,11 +0,0 @@ -fn main() -> std::io::Result<()> { - println!("cargo:rerun-if-changed=../protobuf-definitions/"); - - prost_build::Config::new() - .default_package_filename("mcu_messaging") - .compile_protos( - &["../protobuf-definitions/mcu_messaging.proto"], - &["../protobuf-definitions/"], - )?; - Ok(()) -} diff --git a/orb-mcu-schema/src/lib.rs b/orb-mcu-schema/src/lib.rs deleted file mode 100644 index d7196fab..00000000 --- a/orb-mcu-schema/src/lib.rs +++ /dev/null @@ -1,3 +0,0 @@ -#![allow(clippy::all, clippy::pedantic)] - -include!(concat!(env!("OUT_DIR"), "/mcu_messaging.rs")); diff --git a/orb-supervisor/Cargo.toml b/orb-supervisor/Cargo.toml index 32b36a03..04319cc9 100644 --- a/orb-supervisor/Cargo.toml +++ b/orb-supervisor/Cargo.toml @@ -7,20 +7,18 @@ edition = "2021" [dependencies] eyre = "0.6.8" -libc = "0.2.126" +libc = "0.2.135" listenfd = "1.0.0" -orb-mcu-schema = { path = "../orb-mcu-schema" } -prost = "0.10.4" -tokio = { version = "1.19.2", features = ["macros", "net", "rt-multi-thread"] } -tokio-stream = "0.1.9" -tracing = { version = "0.1.35", features = ["attributes"] } -tracing-subscriber = { version = "0.3.11", features = ["env-filter"] } -zbus = { version = "3", default-features = false, features = ["tokio"] } -zbus_systemd = { version = "0.0.5", features = ["systemd1"] } -thiserror = "1.0.31" -futures = "0.3.21" -once_cell = "1.13.0" +tokio = { version = "1.21.2", features = ["macros", "net", "rt-multi-thread"] } +tokio-stream = "0.1.10" +tracing = { version = "0.1.37", features = ["attributes"] } +tracing-subscriber = { version = "0.3.16", features = ["env-filter"] } +zbus = { version = "3.2.0", default-features = false, features = ["tokio"] } +zbus_systemd = { version = "0.0.6", features = ["systemd1"] } +thiserror = "1.0.37" +futures = "0.3.24" +once_cell = "1.15.0" [dev-dependencies] dbus-launch = "0.2.0" -tokio = { version = "1.19.2", features = ["sync", "test-util"] } +tokio = { version = "1.21.2", features = ["sync", "test-util"] } diff --git a/orb-supervisor/README.md b/orb-supervisor/README.md index 2fbaf2de..cfd93638 100644 --- a/orb-supervisor/README.md +++ b/orb-supervisor/README.md @@ -1,6 +1,6 @@ # Building -To build this crate and run it on the orb, make sure to have `zig` installed. +To build this crate and run it on the orb, you need to have `zig` installed. For example through the Arch Linux package manager: ```shell diff --git a/protobuf-definitions b/protobuf-definitions deleted file mode 160000 index 43507dea..00000000 --- a/protobuf-definitions +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 43507dea63d8707cd4de7860c534551712bee9bb From 6df92197b28022dc6d17f02e33dab33d90be3747 Mon Sep 17 00:00:00 2001 From: Richard Janis Goldschmidt <701177+SuperFluffy@users.noreply.github.com> Date: Wed, 19 Oct 2022 12:03:09 +0200 Subject: [PATCH 15/38] Update tracing to write to journald (#15) * Disable journald and datadog in CI and test * report successful telemetry, supervisor settings --- Cargo.lock | 23 +++++++++- orb-supervisor/Cargo.toml | 2 + orb-supervisor/src/main.rs | 12 ++++-- orb-supervisor/src/startup.rs | 3 -- orb-supervisor/src/telemetry.rs | 68 +++++++++++++++++++++++++----- orb-supervisor/tests/it/helpers.rs | 9 ++-- 6 files changed, 95 insertions(+), 22 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 5c6b969d..f008eac5 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -395,9 +395,9 @@ checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" [[package]] name = "libc" -version = "0.2.134" +version = "0.2.135" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "329c933548736bc49fd575ee68c89e8be4d260064184389a5b77517cddd99ffb" +checksum = "68783febc7782c6c5cb401fbda4de5a9898be1762314da0bb2c10ced61f18b0c" [[package]] name = "listenfd" @@ -513,10 +513,12 @@ dependencies = [ "libc", "listenfd", "once_cell", + "tap", "thiserror", "tokio", "tokio-stream", "tracing", + "tracing-journald", "tracing-subscriber", "zbus", "zbus_systemd", @@ -816,6 +818,12 @@ dependencies = [ "unicode-ident", ] +[[package]] +name = "tap" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "55937e1799185b12863d447f42597ed69d9928686b8d88a1df17376a097d8369" + [[package]] name = "tempfile" version = "3.3.0" @@ -941,6 +949,17 @@ dependencies = [ "valuable", ] +[[package]] +name = "tracing-journald" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ba316a74e8fc3c3896a850dba2375928a9fa171b085ecddfc7c054d39970f3fd" +dependencies = [ + "libc", + "tracing-core", + "tracing-subscriber", +] + [[package]] name = "tracing-log" version = "0.1.3" diff --git a/orb-supervisor/Cargo.toml b/orb-supervisor/Cargo.toml index 04319cc9..5407f2ea 100644 --- a/orb-supervisor/Cargo.toml +++ b/orb-supervisor/Cargo.toml @@ -18,6 +18,8 @@ zbus_systemd = { version = "0.0.6", features = ["systemd1"] } thiserror = "1.0.37" futures = "0.3.24" once_cell = "1.15.0" +tap = "1.0.1" +tracing-journald = "0.3.0" [dev-dependencies] dbus-launch = "0.2.0" diff --git a/orb-supervisor/src/main.rs b/orb-supervisor/src/main.rs index 29eea8d3..198ca15b 100644 --- a/orb-supervisor/src/main.rs +++ b/orb-supervisor/src/main.rs @@ -4,18 +4,22 @@ use orb_supervisor::{ Application, Settings, }, - telemetry, + telemetry::{ + self, + ExecContext, + }, }; use tracing::debug; use tracing_subscriber::filter::LevelFilter; #[tokio::main] async fn main() -> eyre::Result<()> { - telemetry::start(LevelFilter::INFO, std::io::stdout); - - debug!("Starting orb supervisor"); + telemetry::start::(LevelFilter::INFO, std::io::stdout) + .wrap_err("failed to initialize tracing; bailing")?; + debug!("initialized telemetry"); let settings = Settings::default(); + debug!(?settings, "starting supervisor with settings"); let application = Application::build(settings.clone()) .await .wrap_err("failed to build supervisor")?; diff --git a/orb-supervisor/src/startup.rs b/orb-supervisor/src/startup.rs index b7c1a097..3cc26318 100644 --- a/orb-supervisor/src/startup.rs +++ b/orb-supervisor/src/startup.rs @@ -1,5 +1,4 @@ use futures::future::TryFutureExt as _; -use tokio::time::Instant; use tracing::debug; use zbus::{ Connection, @@ -41,7 +40,6 @@ pub struct Settings { pub manager_object_path: String, pub signup_proxy_well_known_name: String, pub signup_proxy_object_path: String, - pub manager_last_event: Option, pub well_known_name: String, } @@ -53,7 +51,6 @@ impl Settings { manager_object_path: manager::OBJECT_PATH.to_string(), signup_proxy_well_known_name: SIGNUP_PROXY_DEFAULT_WELL_KNOWN_NAME.to_string(), signup_proxy_object_path: SIGNUP_PROXY_DEFAULT_OBJECT_PATH.to_string(), - manager_last_event: None, well_known_name: DBUS_WELL_KNOWN_NAME.to_string(), } } diff --git a/orb-supervisor/src/telemetry.rs b/orb-supervisor/src/telemetry.rs index 964994fc..f079a32e 100644 --- a/orb-supervisor/src/telemetry.rs +++ b/orb-supervisor/src/telemetry.rs @@ -1,19 +1,67 @@ +use tap::prelude::*; use tracing::metadata::LevelFilter; use tracing_subscriber::{ - filter::EnvFilter, + filter, fmt::MakeWriter, + prelude::*, + util::TryInitError, }; -pub fn start(env_filter: LevelFilter, sink: W) +const SYSLOG_IDENTIFIER: &str = "worldcoin-supervisor"; + +fn is_tty_interactive() -> bool { + unsafe { libc::isatty(libc::STDIN_FILENO) == 1 } +} + +pub struct ExecContext; +pub struct TestContext; + +pub trait Context: private::Sealed { + const ENABLE_TELEMETRY: bool = false; +} + +impl Context for ExecContext { + const ENABLE_TELEMETRY: bool = true; +} +impl Context for TestContext {} + +mod private { + use super::{ + ExecContext, + TestContext, + }; + pub trait Sealed {} + + impl Sealed for ExecContext {} + impl Sealed for TestContext {} +} + +pub fn start(env_filter: LevelFilter, sink: W) -> Result<(), TryInitError> where W: for<'a> MakeWriter<'a> + Send + Sync + 'static, { - tracing_subscriber::fmt() - .with_writer(sink) - .with_env_filter( - EnvFilter::builder() - .with_default_directive(env_filter.into()) - .from_env_lossy(), - ) - .init(); + let env_filter = filter::EnvFilter::builder() + .with_default_directive(env_filter.into()) + .from_env_lossy(); + + let mut fmt = None; + let mut journald = None; + + if C::ENABLE_TELEMETRY && !is_tty_interactive() { + journald = tracing_journald::layer() + .tap_err(|err| { + eprintln!("failed connecting to journald socket; will write to stdout: {err}"); + }) + .map(|layer| layer.with_syslog_identifier(SYSLOG_IDENTIFIER.into())) + .ok(); + } + if journald.is_none() { + fmt = Some(tracing_subscriber::fmt::layer().with_writer(sink)); + } + + tracing_subscriber::registry() + .with(fmt) + .with(journald) + .with(env_filter) + .try_init() } diff --git a/orb-supervisor/tests/it/helpers.rs b/orb-supervisor/tests/it/helpers.rs index 583c9360..b6e4c2a9 100644 --- a/orb-supervisor/tests/it/helpers.rs +++ b/orb-supervisor/tests/it/helpers.rs @@ -10,7 +10,10 @@ use orb_supervisor::{ Application, Settings, }, - telemetry, + telemetry::{ + self, + TestContext, + }, }; use tokio::task::JoinHandle; use tracing_subscriber::filter::LevelFilter; @@ -26,9 +29,9 @@ use zbus::{ static TRACING: Lazy<()> = Lazy::new(|| { let filter = LevelFilter::DEBUG; if std::env::var("TEST_LOG").is_ok() { - telemetry::start(filter, std::io::stdout); + telemetry::start::(filter, std::io::stdout).unwrap(); } else { - telemetry::start(filter, std::io::sink); + telemetry::start::(filter, std::io::sink).unwrap(); } }); From bf72bb32c9728dbfe81d47ac7e08ee2dd9f5d0a7 Mon Sep 17 00:00:00 2001 From: Richard Janis Goldschmidt <701177+SuperFluffy@users.noreply.github.com> Date: Thu, 20 Oct 2022 15:11:54 +0200 Subject: [PATCH 16/38] supervisor: prepare release 0.2.0 --- Cargo.lock | 125 ++++++++++++++++++++++++++---------- orb-supervisor/CHANGELOG.md | 14 ++++ orb-supervisor/Cargo.toml | 2 +- 3 files changed, 106 insertions(+), 35 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index f008eac5..6248126c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -95,9 +95,9 @@ checksum = "7a40729d2133846d9ed0ea60a8b9541bccddab49cd30f0715a1da672fe9a2524" [[package]] name = "async-trait" -version = "0.1.57" +version = "0.1.58" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "76464446b8bc32758d7e88ee1a804d9914cd9b1cb264c029899680b0be29826f" +checksum = "1e805d94e6b5001b651426cf4cd446b1ab5f319d27bab5c644f61de0a804360c" dependencies = [ "proc-macro2", "quote", @@ -244,9 +244,9 @@ dependencies = [ [[package]] name = "futures" -version = "0.3.24" +version = "0.3.25" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f21eda599937fba36daeb58a22e8f5cee2d14c4a17b5b7739c7c8e5e3b8230c" +checksum = "38390104763dc37a5145a53c29c63c1290b5d316d6086ec32c293f6736051bb0" dependencies = [ "futures-channel", "futures-core", @@ -259,9 +259,9 @@ dependencies = [ [[package]] name = "futures-channel" -version = "0.3.24" +version = "0.3.25" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "30bdd20c28fadd505d0fd6712cdfcb0d4b5648baf45faef7f852afb2399bb050" +checksum = "52ba265a92256105f45b719605a571ffe2d1f0fea3807304b522c1d778f79eed" dependencies = [ "futures-core", "futures-sink", @@ -269,15 +269,15 @@ dependencies = [ [[package]] name = "futures-core" -version = "0.3.24" +version = "0.3.25" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4e5aa3de05362c3fb88de6531e6296e85cde7739cccad4b9dfeeb7f6ebce56bf" +checksum = "04909a7a7e4633ae6c4a9ab280aeb86da1236243a77b694a49eacd659a4bd3ac" [[package]] name = "futures-executor" -version = "0.3.24" +version = "0.3.25" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9ff63c23854bee61b6e9cd331d523909f238fc7636290b96826e9cfa5faa00ab" +checksum = "7acc85df6714c176ab5edf386123fafe217be88c0840ec11f199441134a074e2" dependencies = [ "futures-core", "futures-task", @@ -286,9 +286,9 @@ dependencies = [ [[package]] name = "futures-io" -version = "0.3.24" +version = "0.3.25" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bbf4d2a7a308fd4578637c0b17c7e1c7ba127b8f6ba00b29f717e9655d85eb68" +checksum = "00f5fb52a06bdcadeb54e8d3671f8888a39697dcb0b81b23b55174030427f4eb" [[package]] name = "futures-lite" @@ -307,9 +307,9 @@ dependencies = [ [[package]] name = "futures-macro" -version = "0.3.24" +version = "0.3.25" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "42cd15d1c7456c04dbdf7e88bcd69760d74f3a798d6444e16974b505b0e62f17" +checksum = "bdfb8ce053d86b91919aad980c220b1fb8401a9394410e1c289ed7e66b61835d" dependencies = [ "proc-macro2", "quote", @@ -318,21 +318,21 @@ dependencies = [ [[package]] name = "futures-sink" -version = "0.3.24" +version = "0.3.25" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "21b20ba5a92e727ba30e72834706623d94ac93a725410b6a6b6fbc1b07f7ba56" +checksum = "39c15cf1a4aa79df40f1bb462fb39676d0ad9e366c2a33b590d7c66f4f81fcf9" [[package]] name = "futures-task" -version = "0.3.24" +version = "0.3.25" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a6508c467c73851293f390476d4491cf4d227dbabcd4170f3bb6044959b294f1" +checksum = "2ffb393ac5d9a6eaa9d3fdf37ae2776656b706e200c8e16b1bdb227f5198e6ea" [[package]] name = "futures-util" -version = "0.3.24" +version = "0.3.25" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "44fb6cb1be61cc1d2e43b262516aafcf63b241cffdb1d3fa115f91d9c7b09c90" +checksum = "197676987abd2f9cadff84926f410af1c183608d36641465df73ae8211dc65d6" dependencies = [ "futures-channel", "futures-core", @@ -462,7 +462,7 @@ dependencies = [ "libc", "log", "wasi", - "windows-sys", + "windows-sys 0.36.1", ] [[package]] @@ -505,7 +505,7 @@ checksum = "e82dad04139b71a90c080c8463fe0dc7902db5192d939bd0950f074d014339e1" [[package]] name = "orb-supervisor" -version = "0.1.0" +version = "0.2.0" dependencies = [ "dbus-launch", "eyre", @@ -558,15 +558,15 @@ dependencies = [ [[package]] name = "parking_lot_core" -version = "0.9.3" +version = "0.9.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "09a279cbf25cb0757810394fbc1e359949b59e348145c643a939a525692e6929" +checksum = "4dc9e0dc2adc1c69d09143aff38d3d30c5c3f0df0dad82e6d25547af174ebec0" dependencies = [ "cfg-if", "libc", "redox_syscall", "smallvec", - "windows-sys", + "windows-sys 0.42.0", ] [[package]] @@ -614,9 +614,9 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.46" +version = "1.0.47" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "94e2ef8dbfc347b10c094890f778ee2e36ca9bb4262e86dc99cd217e35f3470b" +checksum = "5ea3d908b0e36316caf9e9e2c4625cdde190a7e6f440d794667ed17a1855e725" dependencies = [ "unicode-ident", ] @@ -898,9 +898,9 @@ dependencies = [ [[package]] name = "tokio-stream" -version = "0.1.10" +version = "0.1.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f6edf2d6bc038a43d31353570e27270603f4648d18f5ed10c0e179abe43255af" +checksum = "d660770404473ccd7bc9f8b28494a811bc18542b915c0855c51e8f419d5223ce" dependencies = [ "futures-core", "pin-project-lite", @@ -1066,43 +1066,100 @@ version = "0.36.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ea04155a16a59f9eab786fe12a4a450e75cdb175f9e0d80da1e17db09f55b8d2" dependencies = [ - "windows_aarch64_msvc", - "windows_i686_gnu", - "windows_i686_msvc", - "windows_x86_64_gnu", - "windows_x86_64_msvc", + "windows_aarch64_msvc 0.36.1", + "windows_i686_gnu 0.36.1", + "windows_i686_msvc 0.36.1", + "windows_x86_64_gnu 0.36.1", + "windows_x86_64_msvc 0.36.1", +] + +[[package]] +name = "windows-sys" +version = "0.42.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5a3e1820f08b8513f676f7ab6c1f99ff312fb97b553d30ff4dd86f9f15728aa7" +dependencies = [ + "windows_aarch64_gnullvm", + "windows_aarch64_msvc 0.42.0", + "windows_i686_gnu 0.42.0", + "windows_i686_msvc 0.42.0", + "windows_x86_64_gnu 0.42.0", + "windows_x86_64_gnullvm", + "windows_x86_64_msvc 0.42.0", ] +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.42.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "41d2aa71f6f0cbe00ae5167d90ef3cfe66527d6f613ca78ac8024c3ccab9a19e" + [[package]] name = "windows_aarch64_msvc" version = "0.36.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9bb8c3fd39ade2d67e9874ac4f3db21f0d710bee00fe7cab16949ec184eeaa47" +[[package]] +name = "windows_aarch64_msvc" +version = "0.42.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dd0f252f5a35cac83d6311b2e795981f5ee6e67eb1f9a7f64eb4500fbc4dcdb4" + [[package]] name = "windows_i686_gnu" version = "0.36.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "180e6ccf01daf4c426b846dfc66db1fc518f074baa793aa7d9b9aaeffad6a3b6" +[[package]] +name = "windows_i686_gnu" +version = "0.42.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fbeae19f6716841636c28d695375df17562ca208b2b7d0dc47635a50ae6c5de7" + [[package]] name = "windows_i686_msvc" version = "0.36.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e2e7917148b2812d1eeafaeb22a97e4813dfa60a3f8f78ebe204bcc88f12f024" +[[package]] +name = "windows_i686_msvc" +version = "0.42.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "84c12f65daa39dd2babe6e442988fc329d6243fdce47d7d2d155b8d874862246" + [[package]] name = "windows_x86_64_gnu" version = "0.36.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4dcd171b8776c41b97521e5da127a2d86ad280114807d0b2ab1e462bc764d9e1" +[[package]] +name = "windows_x86_64_gnu" +version = "0.42.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bf7b1b21b5362cbc318f686150e5bcea75ecedc74dd157d874d754a2ca44b0ed" + +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.42.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09d525d2ba30eeb3297665bd434a54297e4170c7f1a44cad4ef58095b4cd2028" + [[package]] name = "windows_x86_64_msvc" version = "0.36.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c811ca4a8c853ef420abd8592ba53ddbbac90410fab6903b3e79972a631f7680" +[[package]] +name = "windows_x86_64_msvc" +version = "0.42.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f40009d85759725a34da6d89a94e63d7bdc50a862acf0dbc7c8e488f1edcb6f5" + [[package]] name = "zbus" version = "3.2.0" diff --git a/orb-supervisor/CHANGELOG.md b/orb-supervisor/CHANGELOG.md index bb90f1d4..2f647cfe 100644 --- a/orb-supervisor/CHANGELOG.md +++ b/orb-supervisor/CHANGELOG.md @@ -1,5 +1,19 @@ # Changelog +## 0.2.0 (October 20, 2022) + +`orb-supervisor`'s integration with systemd and journald is improved by using +journald conventions and writing directly to the journald socket. + +### Added + ++ `orb-supervisor` detects if its attached to an interactive TTY using `STDIN`: + + if not attached to a TTY, it will write to the journald socket + + if attached to a TTY, it will write to stdout/stderr ++ `orb-supervisor` identifies itself as `worldcoin-supervisor` using SYSLOG IDENT; + + use `journalctl -t worldcoin-supervisor` to filter journald entries + (`-u worldcoin-supervisor` however is still the preferred way); + ## 0.1.0 (August 31, 2022) This is the first release of `orb-supervisor`. diff --git a/orb-supervisor/Cargo.toml b/orb-supervisor/Cargo.toml index 5407f2ea..2e7fe0b2 100644 --- a/orb-supervisor/Cargo.toml +++ b/orb-supervisor/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "orb-supervisor" -version = "0.1.0" +version = "0.2.0" edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html From ae39becf53806f8a182049653178aac0681e8c02 Mon Sep 17 00:00:00 2001 From: Richard Janis Goldschmidt <701177+SuperFluffy@users.noreply.github.com> Date: Thu, 16 Feb 2023 16:31:50 +0100 Subject: [PATCH 17/38] Delay orb core shutdown (#24) --- Cargo.lock | 466 +++++++++++++---------- orb-supervisor/Cargo.toml | 8 +- orb-supervisor/src/consts.rs | 4 + orb-supervisor/src/interfaces/manager.rs | 109 ++++-- orb-supervisor/src/lib.rs | 1 + orb-supervisor/src/proxies/core.rs | 7 +- orb-supervisor/src/tasks/mod.rs | 2 + orb-supervisor/src/tasks/update.rs | 257 +++++++++++++ orb-supervisor/src/telemetry.rs | 13 + orb-supervisor/tests/it/helpers.rs | 101 +++-- orb-supervisor/tests/it/main.rs | 66 +++- 11 files changed, 751 insertions(+), 283 deletions(-) create mode 100644 orb-supervisor/src/consts.rs create mode 100644 orb-supervisor/src/tasks/update.rs diff --git a/Cargo.lock b/Cargo.lock index 6248126c..324def12 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4,83 +4,73 @@ version = 3 [[package]] name = "aho-corasick" -version = "0.7.19" +version = "0.7.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b4f55bd91a0978cbfd91c457a164bab8b4001c833b7f323132c0a4e1922dd44e" +checksum = "cc936419f96fa211c1b9166887b38e5e40b19958e5b895be7c1f93adec7071ac" dependencies = [ "memchr", ] [[package]] name = "async-broadcast" -version = "0.4.1" +version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6d26004fe83b2d1cd3a97609b21e39f9a31535822210fe83205d2ce48866ea61" +checksum = "1b19760fa2b7301cf235360ffd6d3558b1ed4249edd16d6cca8d690cee265b95" dependencies = [ "event-listener", "futures-core", "parking_lot", ] -[[package]] -name = "async-channel" -version = "1.7.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e14485364214912d3b19cc3435dde4df66065127f05fa0d75c712f36f12c2f28" -dependencies = [ - "concurrent-queue", - "event-listener", - "futures-core", -] - [[package]] name = "async-executor" -version = "1.4.1" +version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "871f9bb5e0a22eeb7e8cf16641feb87c9dc67032ccf8ff49e772eb9941d3a965" +checksum = "17adb73da160dfb475c183343c8cccd80721ea5a605d3eb57125f0a7b7a92d0b" dependencies = [ + "async-lock", "async-task", "concurrent-queue", "fastrand", "futures-lite", - "once_cell", "slab", ] [[package]] name = "async-io" -version = "1.9.0" +version = "1.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "83e21f3a490c72b3b0cf44962180e60045de2925d8dff97918f7ee43c8f637c7" +checksum = "8c374dda1ed3e7d8f0d9ba58715f924862c63eae6849c92d3a18e7fbde9e2794" dependencies = [ + "async-lock", "autocfg", "concurrent-queue", "futures-lite", "libc", "log", - "once_cell", "parking", "polling", "slab", "socket2", "waker-fn", - "winapi", + "windows-sys 0.42.0", ] [[package]] name = "async-lock" -version = "2.5.0" +version = "2.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e97a171d191782fba31bb902b14ad94e24a68145032b7eedf871ab0bc0d077b6" +checksum = "c8101efe8695a6c17e02911402145357e718ac92d3ff88ae8419e84b1707b685" dependencies = [ "event-listener", + "futures-lite", ] [[package]] name = "async-recursion" -version = "0.3.2" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d7d78656ba01f1b93024b7c3a0467f1608e4be67d725749fdcd7d2c7678fd7a2" +checksum = "3b015a331cc64ebd1774ba119538573603427eaace0a1950c423ab971f903796" dependencies = [ "proc-macro2", "quote", @@ -95,9 +85,9 @@ checksum = "7a40729d2133846d9ed0ea60a8b9541bccddab49cd30f0715a1da672fe9a2524" [[package]] name = "async-trait" -version = "0.1.58" +version = "0.1.64" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e805d94e6b5001b651426cf4cd446b1ab5f319d27bab5c644f61de0a804360c" +checksum = "1cd7fce9ba8c3c042128ce72d8b2ddbf3a05747efb67ea0313c635e10bda47a2" dependencies = [ "proc-macro2", "quote", @@ -116,6 +106,15 @@ version = "1.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" +[[package]] +name = "block-buffer" +version = "0.10.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "69cce20737498f97b993470a6e536b8523f0af7892a4f928cceb1ac5e52ebe7e" +dependencies = [ + "generic-array", +] + [[package]] name = "byteorder" version = "1.4.3" @@ -124,21 +123,15 @@ checksum = "14c189c53d098945499cdfa7ecc63567cf3886b3332b312a5b4585d8d3a6a610" [[package]] name = "bytes" -version = "1.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ec8a7b6a70fde80372154c65702f00a0f56f3e1c36abbc6c440484be248856db" - -[[package]] -name = "cache-padded" -version = "1.2.0" +version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c1db59621ec70f09c5e9b597b220c7a2b43611f4710dc03ceb8748637775692c" +checksum = "89b2fd2a0dcf38d7971e2194b6b6eebab45ae01067456a7fd93d5547a61b70be" [[package]] name = "cc" -version = "1.0.73" +version = "1.0.79" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2fff2a6927b3bb87f9595d67196a70493f627687a71d87a0d692242c33f58c11" +checksum = "50d30906286121d95be3d479533b458f87493b30a4b5f79a607db8f5d11aa91f" [[package]] name = "cfg-if" @@ -148,11 +141,39 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" [[package]] name = "concurrent-queue" -version = "1.2.4" +version = "2.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "af4780a44ab5696ea9e28294517f1fffb421a83a25af521333c838635509db9c" +checksum = "c278839b831783b70278b14df4d45e1beb1aad306c07bb796637de9a0e323e8e" dependencies = [ - "cache-padded", + "crossbeam-utils", +] + +[[package]] +name = "cpufeatures" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "28d997bd5e24a5928dd43e46dc529867e207907fe0b239c3477d924f7f2ca320" +dependencies = [ + "libc", +] + +[[package]] +name = "crossbeam-utils" +version = "0.8.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4fb766fa798726286dbbb842f174001dab8abc7b627a1dd86e0b7222a95d929f" +dependencies = [ + "cfg-if", +] + +[[package]] +name = "crypto-common" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1bfb12502f3fc46cca1bb51ac28df9d618d813cdc3d2f25b9fe775a34af26bb3" +dependencies = [ + "generic-array", + "typenum", ] [[package]] @@ -176,6 +197,16 @@ dependencies = [ "syn", ] +[[package]] +name = "digest" +version = "0.10.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8168378f4e5023e7218c89c891c0fd8ecdb5e5e4f18cb78f38cf245dd021e76f" +dependencies = [ + "block-buffer", + "crypto-common", +] + [[package]] name = "dirs" version = "4.0.0" @@ -244,9 +275,9 @@ dependencies = [ [[package]] name = "futures" -version = "0.3.25" +version = "0.3.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "38390104763dc37a5145a53c29c63c1290b5d316d6086ec32c293f6736051bb0" +checksum = "13e2792b0ff0340399d58445b88fd9770e3489eff258a4cbc1523418f12abf84" dependencies = [ "futures-channel", "futures-core", @@ -259,9 +290,9 @@ dependencies = [ [[package]] name = "futures-channel" -version = "0.3.25" +version = "0.3.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "52ba265a92256105f45b719605a571ffe2d1f0fea3807304b522c1d778f79eed" +checksum = "2e5317663a9089767a1ec00a487df42e0ca174b61b4483213ac24448e4664df5" dependencies = [ "futures-core", "futures-sink", @@ -269,15 +300,15 @@ dependencies = [ [[package]] name = "futures-core" -version = "0.3.25" +version = "0.3.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "04909a7a7e4633ae6c4a9ab280aeb86da1236243a77b694a49eacd659a4bd3ac" +checksum = "ec90ff4d0fe1f57d600049061dc6bb68ed03c7d2fbd697274c41805dcb3f8608" [[package]] name = "futures-executor" -version = "0.3.25" +version = "0.3.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7acc85df6714c176ab5edf386123fafe217be88c0840ec11f199441134a074e2" +checksum = "e8de0a35a6ab97ec8869e32a2473f4b1324459e14c29275d14b10cb1fd19b50e" dependencies = [ "futures-core", "futures-task", @@ -286,9 +317,9 @@ dependencies = [ [[package]] name = "futures-io" -version = "0.3.25" +version = "0.3.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "00f5fb52a06bdcadeb54e8d3671f8888a39697dcb0b81b23b55174030427f4eb" +checksum = "bfb8371b6fb2aeb2d280374607aeabfc99d95c72edfe51692e42d3d7f0d08531" [[package]] name = "futures-lite" @@ -307,9 +338,9 @@ dependencies = [ [[package]] name = "futures-macro" -version = "0.3.25" +version = "0.3.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bdfb8ce053d86b91919aad980c220b1fb8401a9394410e1c289ed7e66b61835d" +checksum = "95a73af87da33b5acf53acfebdc339fe592ecf5357ac7c0a7734ab9d8c876a70" dependencies = [ "proc-macro2", "quote", @@ -318,21 +349,21 @@ dependencies = [ [[package]] name = "futures-sink" -version = "0.3.25" +version = "0.3.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "39c15cf1a4aa79df40f1bb462fb39676d0ad9e366c2a33b590d7c66f4f81fcf9" +checksum = "f310820bb3e8cfd46c80db4d7fb8353e15dfff853a127158425f31e0be6c8364" [[package]] name = "futures-task" -version = "0.3.25" +version = "0.3.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2ffb393ac5d9a6eaa9d3fdf37ae2776656b706e200c8e16b1bdb227f5198e6ea" +checksum = "dcf79a1bf610b10f42aea489289c5a2c478a786509693b80cd39c44ccd936366" [[package]] name = "futures-util" -version = "0.3.25" +version = "0.3.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "197676987abd2f9cadff84926f410af1c183608d36641465df73ae8211dc65d6" +checksum = "9c1d6de3acfef38d2be4b1f543f553131788603495be83da675e180c8d6b7bd1" dependencies = [ "futures-channel", "futures-core", @@ -346,22 +377,38 @@ dependencies = [ "slab", ] +[[package]] +name = "generic-array" +version = "0.14.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bff49e947297f3312447abdca79f45f4738097cc82b06e72054d2223f601f1b9" +dependencies = [ + "typenum", + "version_check", +] + [[package]] name = "getrandom" -version = "0.2.7" +version = "0.2.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4eb1a864a501629691edf6c15a593b7a51eebaa1e8468e9ddc623de7c9b58ec6" +checksum = "c05aeb6a22b8f62540c194aac980f2115af067bfe15a0734d7277a768d396b31" dependencies = [ "cfg-if", "libc", "wasi", ] +[[package]] +name = "hashbrown" +version = "0.12.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" + [[package]] name = "hermit-abi" -version = "0.1.19" +version = "0.2.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "62b467343b94ba476dcb2500d242dadbb39557df889310ac77c5d99100aaac33" +checksum = "ee512640fe35acbfb4bb779db6f0d80704c2cacfa2e39b601ef3e3f47d1ae4c7" dependencies = [ "libc", ] @@ -378,6 +425,16 @@ version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ce23b50ad8242c51a442f3ff322d56b02f08852c77e4c0b4d3fd684abc89c683" +[[package]] +name = "indexmap" +version = "1.9.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1885e79c1fc4b10f0e172c475f458b7f7b93061064d98c3293e98c5ba0c8b399" +dependencies = [ + "autocfg", + "hashbrown", +] + [[package]] name = "instant" version = "0.1.12" @@ -395,9 +452,9 @@ checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" [[package]] name = "libc" -version = "0.2.135" +version = "0.2.139" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "68783febc7782c6c5cb401fbda4de5a9898be1762314da0bb2c10ced61f18b0c" +checksum = "201de327520df007757c1f0adce6e827fe8562fbc28bfd9c15571c66ca1f5f79" [[package]] name = "listenfd" @@ -455,26 +512,37 @@ dependencies = [ [[package]] name = "mio" -version = "0.8.4" +version = "0.8.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "57ee1c23c7c63b0c9250c339ffdc69255f110b298b901b9f6c82547b7b87caaf" +checksum = "e5d732bc30207a6423068df043e3d02e0735b155ad7ce1a6f76fe2baa5b158de" dependencies = [ "libc", "log", "wasi", - "windows-sys 0.36.1", + "windows-sys 0.42.0", ] [[package]] name = "nix" -version = "0.24.2" +version = "0.25.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "195cdbc1741b8134346d515b3a56a1c94b0912758009cfd53f99ea0f57b065fc" +checksum = "f346ff70e7dbfd675fe90590b92d59ef2de15a8779ae305ebcbfd3f0caf59be4" dependencies = [ + "autocfg", "bitflags", "cfg-if", "libc", "memoffset", + "pin-utils", +] + +[[package]] +name = "nom8" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ae01545c9c7fc4486ab7debaf2aad7003ac19431791868fb2e8066df97fad2f8" +dependencies = [ + "memchr", ] [[package]] @@ -489,9 +557,9 @@ dependencies = [ [[package]] name = "num_cpus" -version = "1.13.1" +version = "1.15.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "19e64526ebdee182341572e50e9ad03965aa510cd94427a4549448f285e957a1" +checksum = "0fac9e2da13b5eb447a6ce3d392f23a29d8694bff781bf03a16cd9ac8697593b" dependencies = [ "hermit-abi", "libc", @@ -499,9 +567,9 @@ dependencies = [ [[package]] name = "once_cell" -version = "1.15.0" +version = "1.17.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e82dad04139b71a90c080c8463fe0dc7902db5192d939bd0950f074d014339e1" +checksum = "6f61fba1741ea2b3d6a1e3178721804bb716a68a6aeba1149b5d52e3d464ea66" [[package]] name = "orb-supervisor" @@ -526,9 +594,9 @@ dependencies = [ [[package]] name = "ordered-stream" -version = "0.0.1" +version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "44630c059eacfd6e08bdaa51b1db2ce33119caa4ddc1235e923109aa5f25ccb1" +checksum = "360a24bdacdb7801a1a6af8500392864791c130ebe8bd9a063158cab00040c90" dependencies = [ "futures-core", "pin-project-lite", @@ -558,15 +626,15 @@ dependencies = [ [[package]] name = "parking_lot_core" -version = "0.9.4" +version = "0.9.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4dc9e0dc2adc1c69d09143aff38d3d30c5c3f0df0dad82e6d25547af174ebec0" +checksum = "9069cbb9f99e3a5083476ccb29ceb1de18b9118cafa53e90c9551235de2b9521" dependencies = [ "cfg-if", "libc", "redox_syscall", "smallvec", - "windows-sys 0.42.0", + "windows-sys 0.45.0", ] [[package]] @@ -583,49 +651,48 @@ checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" [[package]] name = "polling" -version = "2.3.0" +version = "2.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "899b00b9c8ab553c743b3e11e87c5c7d423b2a2de229ba95b24a756344748011" +checksum = "22122d5ec4f9fe1b3916419b76be1e80bcb93f618d071d2edf841b137b2a2bd6" dependencies = [ "autocfg", "cfg-if", "libc", "log", "wepoll-ffi", - "winapi", + "windows-sys 0.42.0", ] [[package]] name = "ppv-lite86" -version = "0.2.16" +version = "0.2.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eb9f9e6e233e5c4a35559a617bf40a4ec447db2e84c20b55a6f83167b7e57872" +checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" [[package]] name = "proc-macro-crate" -version = "1.2.1" +version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eda0fc3b0fb7c975631757e14d9049da17374063edb6ebbcbc54d880d4fe94e9" +checksum = "66618389e4ec1c7afe67d51a9bf34ff9236480f8d51e7489b7d5ab0303c13f34" dependencies = [ "once_cell", - "thiserror", - "toml", + "toml_edit", ] [[package]] name = "proc-macro2" -version = "1.0.47" +version = "1.0.51" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5ea3d908b0e36316caf9e9e2c4625cdde190a7e6f440d794667ed17a1855e725" +checksum = "5d727cae5b39d21da60fa540906919ad737832fe0b1c165da3a34d6548c849d6" dependencies = [ "unicode-ident", ] [[package]] name = "quote" -version = "1.0.21" +version = "1.0.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bbe448f377a7d6961e30f5955f9b8d106c3f5e449d493ee1b125c1d43c2b5179" +checksum = "8856d8364d252a14d474036ea1358d63c9e6965c8e5c1885c18f73d70bff9c7b" dependencies = [ "proc-macro2", ] @@ -682,9 +749,9 @@ dependencies = [ [[package]] name = "regex" -version = "1.6.0" +version = "1.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c4eb3267174b8c6c2f654116623910a0fef09c4753f8dd83db29c48a0df988b" +checksum = "48aaa5748ba571fb95cd2c85c09f629215d3a6ece942baa100950af03a34f733" dependencies = [ "aho-corasick", "memchr", @@ -702,9 +769,9 @@ dependencies = [ [[package]] name = "regex-syntax" -version = "0.6.27" +version = "0.6.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a3f87b73ce11b1619a3c6332f45341e0047173771e8b8b73f87bfeefb7b56244" +checksum = "456c603be3e8d448b072f410900c09faf164fbce2d480456f50eea6e25f9c848" [[package]] name = "remove_dir_all" @@ -723,18 +790,18 @@ checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd" [[package]] name = "serde" -version = "1.0.145" +version = "1.0.152" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "728eb6351430bccb993660dfffc5a72f91ccc1295abaa8ce19b27ebe4f75568b" +checksum = "bb7d1f0d3021d347a83e556fc4683dea2ea09d87bccdf88ff5c12545d89d5efb" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.145" +version = "1.0.152" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "81fa1584d3d1bcacd84c277a0dfe21f5b0f6accf4a23d04d4c6d61f1af522b4c" +checksum = "af487d118eecd09402d70a5d72551860e788df87b464af30e5ea6a38c75c541e" dependencies = [ "proc-macro2", "quote", @@ -743,9 +810,9 @@ dependencies = [ [[package]] name = "serde_repr" -version = "0.1.9" +version = "0.1.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1fe39d9fbb0ebf5eb2c7cb7e2a47e4f462fad1379f1166b8ae49ad9eae89a7ca" +checksum = "9a5ec9fa74a20ebbe5d9ac23dac1fc96ba0ecfe9f50f2843b52e537b10fbcb4e" dependencies = [ "proc-macro2", "quote", @@ -754,19 +821,15 @@ dependencies = [ [[package]] name = "sha1" -version = "0.6.1" +version = "0.10.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c1da05c97445caa12d05e848c4a4fcbbea29e748ac28f7e80e9b010392063770" +checksum = "f04293dc80c3993519f2d7f6f511707ee7094fe0c6d3406feb330cdb3540eba3" dependencies = [ - "sha1_smol", + "cfg-if", + "cpufeatures", + "digest", ] -[[package]] -name = "sha1_smol" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ae1a47186c03a32177042e55dbc5fd5aee900b8e0069a8d70fba96a9375cd012" - [[package]] name = "sharded-slab" version = "0.1.4" @@ -809,9 +872,9 @@ checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" [[package]] name = "syn" -version = "1.0.102" +version = "1.0.107" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3fcd952facd492f9be3ef0d0b7032a6e442ee9b361d4acc2b1d0c4aaa5f613a1" +checksum = "1f4064b5b16e03ae50984a5a8ed5d4f8803e6bc1fd170a3cda91a1be4b18e3f5" dependencies = [ "proc-macro2", "quote", @@ -840,18 +903,18 @@ dependencies = [ [[package]] name = "thiserror" -version = "1.0.37" +version = "1.0.38" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "10deb33631e3c9018b9baf9dcbbc4f737320d2b576bac10f6aefa048fa407e3e" +checksum = "6a9cd18aa97d5c45c6603caea1da6628790b37f7a34b6ca89522331c5180fed0" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.37" +version = "1.0.38" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "982d17546b47146b28f7c22e3d08465f6b8903d0ea13c1660d9d84a6e7adcdbb" +checksum = "1fb327af4685e4d03fa8cbcf1716380da910eeb2bb8be417e7f9fd3fb164f36f" dependencies = [ "proc-macro2", "quote", @@ -869,9 +932,9 @@ dependencies = [ [[package]] name = "tokio" -version = "1.21.2" +version = "1.25.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a9e03c497dc955702ba729190dc4aac6f2a0ce97f913e5b1b5912fc5039d9099" +checksum = "c8e00990ebabbe4c14c08aca901caed183ecd5c09562a12c824bb53d3c3fd3af" dependencies = [ "autocfg", "bytes", @@ -882,14 +945,15 @@ dependencies = [ "pin-project-lite", "socket2", "tokio-macros", - "winapi", + "tracing", + "windows-sys 0.42.0", ] [[package]] name = "tokio-macros" -version = "1.8.0" +version = "1.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9724f9a975fb987ef7a3cd9be0350edcbe130698af5b8f7a631e23d42d052484" +checksum = "d266c00fde287f55d3f1c3e96c500c362a2b8c695076ec180f27918820bc6df8" dependencies = [ "proc-macro2", "quote", @@ -908,12 +972,20 @@ dependencies = [ ] [[package]] -name = "toml" -version = "0.5.9" +name = "toml_datetime" +version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8d82e1a7758622a465f8cee077614c73484dac5b836c02ff6a40d5d1010324d7" +checksum = "4553f467ac8e3d374bc9a177a26801e5d0f9b211aa1673fb137a403afd1c9cf5" + +[[package]] +name = "toml_edit" +version = "0.18.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "56c59d8dd7d0dcbc6428bf7aa2f0e823e26e43b3c9aca15bbc9475d23e5fa12b" dependencies = [ - "serde", + "indexmap", + "nom8", + "toml_datetime", ] [[package]] @@ -989,6 +1061,12 @@ dependencies = [ "tracing-log", ] +[[package]] +name = "typenum" +version = "1.16.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "497961ef93d974e23eb6f433eb5fe1b7930b659f06d12dec6fc44a8f554c0bba" + [[package]] name = "uds_windows" version = "1.0.2" @@ -1001,15 +1079,15 @@ dependencies = [ [[package]] name = "unicode-ident" -version = "1.0.5" +version = "1.0.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6ceab39d59e4c9499d4e5a8ee0e2735b891bb7308ac83dfb4e80cad195c9f6f3" +checksum = "84a22b9f218b40614adcb3f4ff08b703773ad44fa9423e4e0d346d5db86e4ebc" [[package]] name = "uuid" -version = "1.2.1" +version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "feb41e78f93363bb2df8b0e86a2ca30eed7806ea16ea0c790d757cf93f79be83" +checksum = "1674845326ee10d37ca60470760d4288a6f80f304007d92e5c53bab78c9cfd79" [[package]] name = "valuable" @@ -1017,6 +1095,12 @@ version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "830b7e5d4d90034032940e4ace0d9a9a057e7a45cd94e6c007832e39edb82f6d" +[[package]] +name = "version_check" +version = "0.9.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" + [[package]] name = "waker-fn" version = "1.1.0" @@ -1060,19 +1144,6 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" -[[package]] -name = "windows-sys" -version = "0.36.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ea04155a16a59f9eab786fe12a4a450e75cdb175f9e0d80da1e17db09f55b8d2" -dependencies = [ - "windows_aarch64_msvc 0.36.1", - "windows_i686_gnu 0.36.1", - "windows_i686_msvc 0.36.1", - "windows_x86_64_gnu 0.36.1", - "windows_x86_64_msvc 0.36.1", -] - [[package]] name = "windows-sys" version = "0.42.0" @@ -1080,94 +1151,87 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5a3e1820f08b8513f676f7ab6c1f99ff312fb97b553d30ff4dd86f9f15728aa7" dependencies = [ "windows_aarch64_gnullvm", - "windows_aarch64_msvc 0.42.0", - "windows_i686_gnu 0.42.0", - "windows_i686_msvc 0.42.0", - "windows_x86_64_gnu 0.42.0", + "windows_aarch64_msvc", + "windows_i686_gnu", + "windows_i686_msvc", + "windows_x86_64_gnu", "windows_x86_64_gnullvm", - "windows_x86_64_msvc 0.42.0", + "windows_x86_64_msvc", ] [[package]] -name = "windows_aarch64_gnullvm" -version = "0.42.0" +name = "windows-sys" +version = "0.45.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "41d2aa71f6f0cbe00ae5167d90ef3cfe66527d6f613ca78ac8024c3ccab9a19e" +checksum = "75283be5efb2831d37ea142365f009c02ec203cd29a3ebecbc093d52315b66d0" +dependencies = [ + "windows-targets", +] [[package]] -name = "windows_aarch64_msvc" -version = "0.36.1" +name = "windows-targets" +version = "0.42.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9bb8c3fd39ade2d67e9874ac4f3db21f0d710bee00fe7cab16949ec184eeaa47" +checksum = "8e2522491fbfcd58cc84d47aeb2958948c4b8982e9a2d8a2a35bbaed431390e7" +dependencies = [ + "windows_aarch64_gnullvm", + "windows_aarch64_msvc", + "windows_i686_gnu", + "windows_i686_msvc", + "windows_x86_64_gnu", + "windows_x86_64_gnullvm", + "windows_x86_64_msvc", +] [[package]] -name = "windows_aarch64_msvc" -version = "0.42.0" +name = "windows_aarch64_gnullvm" +version = "0.42.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dd0f252f5a35cac83d6311b2e795981f5ee6e67eb1f9a7f64eb4500fbc4dcdb4" +checksum = "8c9864e83243fdec7fc9c5444389dcbbfd258f745e7853198f365e3c4968a608" [[package]] -name = "windows_i686_gnu" -version = "0.36.1" +name = "windows_aarch64_msvc" +version = "0.42.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "180e6ccf01daf4c426b846dfc66db1fc518f074baa793aa7d9b9aaeffad6a3b6" +checksum = "4c8b1b673ffc16c47a9ff48570a9d85e25d265735c503681332589af6253c6c7" [[package]] name = "windows_i686_gnu" -version = "0.42.0" +version = "0.42.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fbeae19f6716841636c28d695375df17562ca208b2b7d0dc47635a50ae6c5de7" +checksum = "de3887528ad530ba7bdbb1faa8275ec7a1155a45ffa57c37993960277145d640" [[package]] name = "windows_i686_msvc" -version = "0.36.1" +version = "0.42.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e2e7917148b2812d1eeafaeb22a97e4813dfa60a3f8f78ebe204bcc88f12f024" - -[[package]] -name = "windows_i686_msvc" -version = "0.42.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "84c12f65daa39dd2babe6e442988fc329d6243fdce47d7d2d155b8d874862246" - -[[package]] -name = "windows_x86_64_gnu" -version = "0.36.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4dcd171b8776c41b97521e5da127a2d86ad280114807d0b2ab1e462bc764d9e1" +checksum = "bf4d1122317eddd6ff351aa852118a2418ad4214e6613a50e0191f7004372605" [[package]] name = "windows_x86_64_gnu" -version = "0.42.0" +version = "0.42.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bf7b1b21b5362cbc318f686150e5bcea75ecedc74dd157d874d754a2ca44b0ed" +checksum = "c1040f221285e17ebccbc2591ffdc2d44ee1f9186324dd3e84e99ac68d699c45" [[package]] name = "windows_x86_64_gnullvm" -version = "0.42.0" +version = "0.42.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "09d525d2ba30eeb3297665bd434a54297e4170c7f1a44cad4ef58095b4cd2028" +checksum = "628bfdf232daa22b0d64fdb62b09fcc36bb01f05a3939e20ab73aaf9470d0463" [[package]] name = "windows_x86_64_msvc" -version = "0.36.1" +version = "0.42.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c811ca4a8c853ef420abd8592ba53ddbbac90410fab6903b3e79972a631f7680" - -[[package]] -name = "windows_x86_64_msvc" -version = "0.42.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f40009d85759725a34da6d89a94e63d7bdc50a862acf0dbc7c8e488f1edcb6f5" +checksum = "447660ad36a13288b1db4d4248e857b510e8c3a225c822ba4fb748c0aafecffd" [[package]] name = "zbus" -version = "3.2.0" +version = "3.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "be2db10dd0354816a3615c72deff837f983d5c8ad9a0312727d0f89a5a9e9145" +checksum = "76f1a9e02a5659c712de386c2af5156c51a530fac0668d3ff85fa26a2bc006ba" dependencies = [ "async-broadcast", - "async-channel", "async-executor", "async-io", "async-lock", @@ -1203,9 +1267,9 @@ dependencies = [ [[package]] name = "zbus_macros" -version = "3.2.0" +version = "3.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7d03f1a5fb482cc0d97f3d3de9fe2e942f436a635a5fb6c12c9f03f21eb03075" +checksum = "414cd9f07964695e00bfef8e589d1752ea0480b8a619f2064cbaccb8a6c2ed59" dependencies = [ "proc-macro-crate", "proc-macro2", @@ -1216,9 +1280,9 @@ dependencies = [ [[package]] name = "zbus_names" -version = "2.2.0" +version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "41a408fd8a352695690f53906dc7fd036be924ec51ea5e05666ff42685ed0af5" +checksum = "f34f314916bd89bdb9934154627fab152f4f28acdda03e7c4c68181b214fe7e3" dependencies = [ "serde", "static_assertions", @@ -1227,9 +1291,9 @@ dependencies = [ [[package]] name = "zbus_systemd" -version = "0.0.6" +version = "0.0.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f05d5be083af02c7f1e641f3e4f5a316721d561a3bbb7e7f216969ce25005bd1" +checksum = "f7681e3440cbd50a17f2979785619b487e197b5e7e375a851702d4d20f3965f0" dependencies = [ "futures", "serde", @@ -1238,9 +1302,9 @@ dependencies = [ [[package]] name = "zvariant" -version = "3.7.1" +version = "3.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b794fb7f59af4105697b0449ba31731ee5dbb3e773a17dbdf3d36206ea1b1644" +checksum = "576cc41e65c7f283e5460f5818073e68fb1f1631502b969ef228c2e03c862efb" dependencies = [ "byteorder", "enumflags2", @@ -1252,9 +1316,9 @@ dependencies = [ [[package]] name = "zvariant_derive" -version = "3.7.1" +version = "3.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dd58d4b6c8e26d3dd2149c8c40c6613ef6451b9885ff1296d1ac86c388351a54" +checksum = "0fd4aafc0dee96ae7242a24249ce9babf21e1562822f03df650d4e68c20e41ed" dependencies = [ "proc-macro-crate", "proc-macro2", diff --git a/orb-supervisor/Cargo.toml b/orb-supervisor/Cargo.toml index 2e7fe0b2..f0280b70 100644 --- a/orb-supervisor/Cargo.toml +++ b/orb-supervisor/Cargo.toml @@ -10,11 +10,11 @@ eyre = "0.6.8" libc = "0.2.135" listenfd = "1.0.0" tokio = { version = "1.21.2", features = ["macros", "net", "rt-multi-thread"] } -tokio-stream = "0.1.10" +tokio-stream = "0.1.11" tracing = { version = "0.1.37", features = ["attributes"] } tracing-subscriber = { version = "0.3.16", features = ["env-filter"] } -zbus = { version = "3.2.0", default-features = false, features = ["tokio"] } -zbus_systemd = { version = "0.0.6", features = ["systemd1"] } +zbus = { version = "3.9.0", default-features = false, features = ["tokio"] } +zbus_systemd = { version = "0.0.8", features = ["systemd1"] } thiserror = "1.0.37" futures = "0.3.24" once_cell = "1.15.0" @@ -23,4 +23,4 @@ tracing-journald = "0.3.0" [dev-dependencies] dbus-launch = "0.2.0" -tokio = { version = "1.21.2", features = ["sync", "test-util"] } +tokio = { version = "1.25.0", features = ["sync", "test-util"] } diff --git a/orb-supervisor/src/consts.rs b/orb-supervisor/src/consts.rs new file mode 100644 index 00000000..0aaeca99 --- /dev/null +++ b/orb-supervisor/src/consts.rs @@ -0,0 +1,4 @@ +use tokio::time::Duration; + +pub const WORLDCOIN_CORE_UNIT_NAME: &str = "worldcoin-core.service"; +pub const DURATION_TO_STOP_CORE_AFTER_LAST_SIGNUP: Duration = Duration::from_secs(20 * 60); diff --git a/orb-supervisor/src/interfaces/manager.rs b/orb-supervisor/src/interfaces/manager.rs index 5dbae5ed..9ceb464e 100644 --- a/orb-supervisor/src/interfaces/manager.rs +++ b/orb-supervisor/src/interfaces/manager.rs @@ -3,9 +3,12 @@ //! It currently only supports the `BackgroundDownloadsAllowed` property used by the update to //! decide whether or not it can download updates. -use tokio::time::{ - Duration, - Instant, +use tokio::{ + sync::watch, + time::{ + Duration, + Instant, + }, }; use tracing::{ debug, @@ -15,9 +18,12 @@ use tracing::{ use zbus::{ dbus_interface, Connection, + DBusError, SignalContext, }; -use zbus_systemd::systemd1; +use zbus_systemd::systemd1::ManagerProxy; + +use crate::tasks; /// The duration of time since the last "start signup" event that has to have passed /// before the update agent is permitted to start a download. @@ -27,9 +33,23 @@ pub const BACKGROUND_DOWNLOADS_ALLOWED_PROPERTY_NAME: &str = "BackgroundDownload pub const INTERFACE_NAME: &str = "org.worldcoin.OrbSupervisor1.Manager"; pub const OBJECT_PATH: &str = "/org/worldcoin/OrbSupervisor1/Manager"; +#[derive(Debug, DBusError)] +#[dbus_error(prefix = "org.worldcoin.OrbSupervisor1.Manager")] +pub enum BusError { + #[dbus_error(zbus_error)] + ZBus(zbus::Error), + UpdatesBlocked(String), +} + +impl BusError { + fn updates_blocked(msg: impl Into) -> Self { + Self::UpdatesBlocked(msg.into()) + } +} + pub struct Manager { duration_to_allow_downloads: Duration, - last_signup_event: Instant, + last_signup_event: watch::Sender, system_connection: Option, } @@ -37,9 +57,10 @@ impl Manager { /// Constructs a new `Manager` instance. #[allow(clippy::must_use_candidate)] pub fn new() -> Self { + let (tx, _rx) = watch::channel(Instant::now()); Self { duration_to_allow_downloads: DEFAULT_DURATION_TO_ALLOW_DOWNLOADS, - last_signup_event: Instant::now(), + last_signup_event: tx, system_connection: None, } } @@ -54,11 +75,11 @@ impl Manager { #[allow(clippy::must_use_candidate)] pub fn are_downloads_allowed(&self) -> bool { - self.last_signup_event.elapsed() >= self.duration_to_allow_downloads + self.last_signup_event.borrow().elapsed() >= self.duration_to_allow_downloads } fn reset_last_signup_event(&mut self) { - self.last_signup_event = Instant::now(); + self.last_signup_event.send_replace(Instant::now()); } pub fn set_system_connection(&mut self, conn: zbus::Connection) { @@ -91,12 +112,12 @@ impl Default for Manager { impl Manager { #[dbus_interface(property, name = "BackgroundDownloadsAllowed")] #[instrument( - name = "org.worldcoin.OrbSupervisor1.Manager.BackgroundDownloadsAllowed", + fields(dbus_interface = "org.worldcoin.OrbSupervisor1.Manager.BackgroundDownloadsAllowed"), skip_all )] async fn background_downloads_allowed(&self) -> bool { debug!( - millis = self.last_signup_event.elapsed().as_millis(), + millis = self.last_signup_event.borrow().elapsed().as_millis(), "time since last signup event", ); self.are_downloads_allowed() @@ -104,36 +125,54 @@ impl Manager { #[dbus_interface(name = "RequestUpdatePermission")] #[instrument( - name = "org.worldcoin.OrbSupervisor1.RequestUpdatePermission", + name = "org.worldcoin.OrbSupervisor1.Manager.RequestUpdatePermission", skip_all )] - async fn request_update_permission(&self) -> zbus::fdo::Result { + async fn request_update_permission(&self) -> Result<(), BusError> { debug!("RequestUpdatePermission was called"); - let mut update_permitted = false; - if let Some(conn) = &self.system_connection { - let systemd_proxy = systemd1::ManagerProxy::new(conn).await?; - match systemd_proxy - .stop_unit("worldcoin-core.service".to_string(), "replace".to_string()) - .await - { - Ok(unit_path) => { - debug!( - job_object = unit_path.as_str(), - "`org.freedesktop.systemd1.Manager.StopUnit` returned" + let conn = self + .system_connection + .as_ref() + .expect("manager must be conntected to system dbus"); + let systemd_proxy = ManagerProxy::new(conn).await?; + // Spawn task to shut down worldcoin core + let mut shutdown_core_task = tasks::update::spawn_shutdown_worldcoin_core_timer( + systemd_proxy.clone(), + self.last_signup_event.subscribe(), + ); + // Wait for one second to see if worldcoin core is already shut down + match tokio::time::timeout(Duration::from_secs(1), &mut shutdown_core_task).await { + Ok(Ok(Ok(()))) => { + debug!("worldcoin core shut down task returned in less than 1s, permitting update"); + Ok(()) + } + Ok(Ok(Err(e))) => { + warn!( + error = ?e, + "worldcoin core shutdown task returned with error in less than 1s; permitting update because of unclear status", + ); + Ok(()) + } + Ok(Err(e)) => { + warn!( + panic_msg = ?e, + "worldcoin core shutdown task panicked trying; permitting update because of unclear status", + ); + Ok(()) + } + Err(elapsed) => { + debug!(%elapsed, "shutting down worldcoin core takes longer than 1s; running in background and blocking update by returning a method error"); + let _deteched_shutdown_task = + tasks::update::spawn_start_update_agent_after_core_shutdown_task( + systemd_proxy, + shutdown_core_task, ); - update_permitted = true; - } - Err(zbus::Error::FDO(e)) => { - warn!(err = %e, "encountered a D-Bus error when calling `org.freedesktop.systemd1.Manager.StopUnit`"); - update_permitted = true; - } - Err(e) => { - tracing::error!(err = ?e); - return Err(zbus::fdo::Error::ZBus(e)); - } - }; + Err(BusError::updates_blocked( + "orb core is still running and will be shut down 20 minutes after the last \ + signup; supervisor will start update agent after", + )) + } } - Ok(update_permitted) } } diff --git a/orb-supervisor/src/lib.rs b/orb-supervisor/src/lib.rs index 4c867618..187e36ec 100644 --- a/orb-supervisor/src/lib.rs +++ b/orb-supervisor/src/lib.rs @@ -1,3 +1,4 @@ +pub mod consts; pub mod interfaces; pub mod proxies; pub mod startup; diff --git a/orb-supervisor/src/proxies/core.rs b/orb-supervisor/src/proxies/core.rs index 74356892..758e99b7 100644 --- a/orb-supervisor/src/proxies/core.rs +++ b/orb-supervisor/src/proxies/core.rs @@ -5,7 +5,12 @@ use zbus::dbus_proxy; pub const SIGNUP_PROXY_DEFAULT_WELL_KNOWN_NAME: &str = "org.worldcoin.OrbCore1"; pub const SIGNUP_PROXY_DEFAULT_OBJECT_PATH: &str = "/org/worldcoin/OrbCore1/Signup"; -#[dbus_proxy(interface = "org.worldcoin.OrbCore1.Signup")] +#[dbus_proxy( + interface = "org.worldcoin.OrbCore1.Signup", + gen_blocking = false, + default_service = "org.worldcoin.OrbCore1", + default_path = "/org/worldcoin/OrbCore1/Signup" +)] pub trait Signup { #[dbus_proxy(signal)] fn signup_started(&self) -> Result<()>; diff --git a/orb-supervisor/src/tasks/mod.rs b/orb-supervisor/src/tasks/mod.rs index dbbf51c7..8d054a23 100644 --- a/orb-supervisor/src/tasks/mod.rs +++ b/orb-supervisor/src/tasks/mod.rs @@ -1,5 +1,7 @@ //! Tasks that make up the orb supervisor. pub mod signup_started; +pub mod update; pub use signup_started::spawn_signup_started_task; +pub use update::spawn_shutdown_worldcoin_core_timer; diff --git a/orb-supervisor/src/tasks/update.rs b/orb-supervisor/src/tasks/update.rs new file mode 100644 index 00000000..da035978 --- /dev/null +++ b/orb-supervisor/src/tasks/update.rs @@ -0,0 +1,257 @@ +use std::{ + convert::identity, + time::Duration, +}; + +use futures::{ + StreamExt as _, + TryFutureExt as _, +}; +use tokio::{ + task::JoinHandle, + time::{ + self, + error::Elapsed, + Instant, + }, +}; +use tracing::{ + debug, + info, + instrument, + warn, +}; +use zbus_systemd::systemd1::{ + self, + ManagerProxy, +}; + +use crate::consts::{ + DURATION_TO_STOP_CORE_AFTER_LAST_SIGNUP, + WORLDCOIN_CORE_UNIT_NAME, +}; + +/// Calculates the instant that is 20 minutes after the last signup event. +fn calculate_stop_deadline(last_signup_started_event: Instant) -> Instant { + last_signup_started_event + .checked_add(crate::consts::DURATION_TO_STOP_CORE_AFTER_LAST_SIGNUP) + .expect("`Instant` should always be able to represent the timescales of this codebase") +} + +#[derive(Debug, thiserror::Error)] +pub enum Error { + #[error("reached timeout while waiting for worldcoin core service to be stopped")] + Elapsed(#[from] Elapsed), + #[error("failed communicating over dbus; TODO: break this up into individual errors")] + Dbus(#[from] zbus::Error), +} + +/// Spawns a task that shuts down worldcoin core after enough time has passed. +#[must_use] +pub fn spawn_shutdown_worldcoin_core_timer( + proxy: ManagerProxy<'static>, + mut last_signup_started_event: tokio::sync::watch::Receiver, +) -> JoinHandle> { + tokio::spawn(async move { + let trigger_stop = + time::sleep_until(calculate_stop_deadline(*last_signup_started_event.borrow())); + tokio::pin!(trigger_stop); + loop { + tokio::select!( + + // reset the trigger if a new signup has started + _ = last_signup_started_event.changed() => { + info!( + duration_s = DURATION_TO_STOP_CORE_AFTER_LAST_SIGNUP.as_secs(), + "new signup started, resetting timer", + ); + trigger_stop + .as_mut() + .reset(calculate_stop_deadline(*last_signup_started_event.borrow())); + }, + + () = &mut trigger_stop => { + break; + } + ); + } + info!("deadline reached, shutting down worldcoin core service"); + let worldcoin_core_timeout_stop = get_worldcoin_core_timeout(proxy.clone()).await?; + stop_worldcoin_core(proxy.clone(), WORLDCOIN_CORE_UNIT_NAME, "replace").await?; + tokio::time::timeout( + worldcoin_core_timeout_stop, + has_worldcoin_core_stopped(proxy.clone()), + ) + .await + .map_err(From::from) + .and_then(identity) + }) +} + +#[must_use] +pub fn spawn_start_update_agent_after_core_shutdown_task( + proxy: systemd1::ManagerProxy<'static>, + shutdown_task: JoinHandle>, +) -> JoinHandle> { + tokio::spawn(async move { + match shutdown_task.await { + Ok(Ok(())) => info!("worldcoin core shutdown task completed"), + Ok(Err(e)) => warn!(error = ?e, "worldcoin core shutdown task returned with error"), + Err(e) => warn!(panic_msg = ?e, "worldcoin core shutdown task panicked"), + } + info!("calling `org.freedesktop.systemd1.Manager.StartUnit` to start update agent"); + proxy + .start_unit("worldcoin-update-agent.service".into(), "replace".into()) + .await + .map(|_| {}) + .map_err(Into::into) + }) +} +// #[instrument( +// name = "spawn_update_agent_after_core_stopped", +// skip_all, +// )] +// pub async fn spawn_start_update_agent_after_worldcoin_core_stopped_task( +// proxy: ManagerProxy<'static>, +// ) -> JoinHandle> { +// tokio::spawn(async move { +// let timeout_duration = get_worldcoin_core_timeout(proxy.clone()).await?; +// match tokio::time::timeout( +// timeout_duration, +// has_worldcoin_core_stopped(proxy), +// ).await { +// Ok(_) => todo!("worldcoin core stopped"), +// Err(elapsed) => { +// info!(error = %elapsed, "did not " +// } +// }; +// Ok(()) +// }) + +// } + +#[instrument(skip_all, err, ret(Debug))] +async fn get_worldcoin_core_timeout(proxy: ManagerProxy<'static>) -> zbus::Result { + let worldcoin_core_service = proxy + .get_unit(WORLDCOIN_CORE_UNIT_NAME.to_string()) + .and_then(|worldcoin_core_object| async { + zbus_systemd::systemd1::ServiceProxy::builder(proxy.connection()) + .destination("org.freedesktop.systemd1")? + .path(worldcoin_core_object)? + .build() + .await + }) + .await?; + worldcoin_core_service + .timeout_stop_u_sec() + .map_ok(Duration::from_micros) + .await +} + +/// Reports if the worldcoin core systemd service has stopped. +/// +/// This function makes use of the fact that the first item produced by the `PropertyChangedStream` +/// is its current value. This is probably an implementation detail of zbus. +#[instrument(skip_all, err, ret)] +async fn has_worldcoin_core_stopped(proxy: ManagerProxy<'static>) -> Result<(), Error> { + let orb_core_unit = proxy + .get_unit(WORLDCOIN_CORE_UNIT_NAME.to_string()) + .and_then(|object_path| async { + zbus_systemd::systemd1::UnitProxy::builder(proxy.connection()) + .destination("org.freedesktop.systemd1")? + .path(object_path)? + .build() + .await + }) + .await?; + debug!("awaiting active state changed"); + let mut active_state_stream = orb_core_unit.receive_active_state_changed().await; + + // This makes use of the fact that the first iteration always returns the current state. + // So if the service is already inactive or failed, then this loop will break and we + // doesn't spin indefinitely. + debug!("spinning"); + while let Some(event) = active_state_stream.next().await { + match &*event.get().await? { + "inactive" | "failed" => break, + other => { + info!(event = other, "received event"); + } + } + } + Ok(()) +} + +#[instrument( + skip(proxy), + fields(dbus_method = "org.freedesktop.systemd1.Manager.StopUnit",) +)] +async fn stop_worldcoin_core( + proxy: systemd1::ManagerProxy<'static>, + unit_name: &'static str, + stop_mode: &'static str, +) -> zbus::Result<()> { + match proxy + .stop_unit(unit_name.to_string(), stop_mode.to_string()) + .await + { + Ok(unit_path) => { + debug!( + job_object = unit_path.as_str(), + "dbus method call successful" + ); + } + + Err(zbus::Error::MethodError(name, detail, reply)) + if name == "org.freedesktop.systemd1.NoSuchUnit" => + { + // We need to reconstruct the error here because the destructuring, guards and bindings + // don't work in match statements + let method_error = zbus::Error::MethodError(name, detail, reply); + debug!(error = %method_error, "systemd mostl likely reported that worldcoin core is stopped"); + } + + Err(zbus::Error::FDO(e)) => { + warn!( + err = ?e, + dbus_method = "org.freedesktop.systemd1.Manager.StopUnit", + "encountered a D-Bus error when dbus method; permitting update", + ); + } + Err(e) => { + return Err(e); + } + }; + Ok(()) +} + +#[cfg(test)] +mod tests { + use std::time::Duration; + + use tokio::time::Instant; + + use super::{ + calculate_stop_deadline, + DURATION_TO_STOP_CORE_AFTER_LAST_SIGNUP, + }; + + #[test] + fn deadline_of_old_signup_event_is_in_the_past() { + let an_hour_ago = Instant::now() + .checked_sub(Duration::from_secs(60 * 60)) + .expect("`Instant` should always be able to represent current time minus 60 minutes"); + let stop_deadline = calculate_stop_deadline(an_hour_ago); + assert!(stop_deadline < Instant::now()); + } + + #[test] + fn deadline_of_now_is_wait_time() { + let now = Instant::now(); + let calculated_stop_deadline = calculate_stop_deadline(now); + let expected_stop_deadline = now + .checked_add(DURATION_TO_STOP_CORE_AFTER_LAST_SIGNUP) + .expect("`Instant` should always be able to represent current time + some minutes"); + assert_eq!(expected_stop_deadline, calculated_stop_deadline); + } +} diff --git a/orb-supervisor/src/telemetry.rs b/orb-supervisor/src/telemetry.rs index f079a32e..264ea848 100644 --- a/orb-supervisor/src/telemetry.rs +++ b/orb-supervisor/src/telemetry.rs @@ -36,6 +36,19 @@ mod private { impl Sealed for TestContext {} } +/// Start telemetry (tracing, logging) of orb supervisor. +/// +/// If supervisor is run form an interactive CLI all trace events will be written to stdout. +/// If this function detects that orb-supervisor is not attached to an interactive session, +/// events will be written to journald (this is the case if supervisor is started as a systemd +/// service). +/// +/// The `C: Context` generic type parameter is used for disabling telemetry inside +/// a test environment. +/// +/// # Errors +/// +/// Returns [`tracing_subscriber.util.TryInitError`] pub fn start(env_filter: LevelFilter, sink: W) -> Result<(), TryInitError> where W: for<'a> MakeWriter<'a> + Send + Sync + 'static, diff --git a/orb-supervisor/tests/it/helpers.rs b/orb-supervisor/tests/it/helpers.rs index b6e4c2a9..ab6ab20d 100644 --- a/orb-supervisor/tests/it/helpers.rs +++ b/orb-supervisor/tests/it/helpers.rs @@ -26,6 +26,8 @@ use zbus::{ SignalContext, }; +pub const WORLDCOIN_CORE_SERVICE_OBJECT_PATH: &str = + "/org/freedesktop/systemd1/unit/worldcoin_2dcore_2eservice"; static TRACING: Lazy<()> = Lazy::new(|| { let filter = LevelFilter::DEBUG; if std::env::var("TEST_LOG").is_ok() { @@ -35,6 +37,7 @@ static TRACING: Lazy<()> = Lazy::new(|| { } }); +#[derive(Debug)] pub struct DbusInstances { pub session: Daemon, pub system: Daemon, @@ -77,13 +80,19 @@ pub async fn spawn_supervisor_service(settings: Settings) -> eyre::Result zbus::Result; - #[dbus_interface(name = "RequestUpdatePermission")] - fn request_update_permission(&self) -> zbus::fdo::Result; + #[dbus_proxy(name = "RequestUpdatePermission")] + fn request_update_permission(&self) -> zbus::fdo::Result<()>; } pub async fn make_update_agent_proxy<'a>( @@ -128,46 +137,76 @@ pub async fn start_signup_service_and_send_signal( Ok(()) } -struct Manager { - tx: Option>, -} +struct Manager; #[dbus_interface(name = "org.freedesktop.systemd1.Manager")] impl Manager { - #[dbus_interface(name = "StopUnit")] - async fn stop_unit(&mut self, name: String, mode: String) -> fdo::Result { - tracing::debug!("StopUnit called"); - let tx = self - .tx - .take() - .expect("Method must not be called more than once"); - tx.send((name.clone(), mode)) - .expect("Oneshot receiver must exist"); - OwnedObjectPath::try_from( - format!("/org/freedesktop/systemd1/unit/{name}") - .replace('-', "_2d") - .replace('.', "_2e"), - ) + #[dbus_interface(name = "GetUnit")] + async fn get_unit(&self, name: String) -> fdo::Result { + tracing::debug!(name, "GetUnit called"); + match &*name { + "worldcoin-core.service" => { + OwnedObjectPath::try_from(WORLDCOIN_CORE_SERVICE_OBJECT_PATH) + } + _other => OwnedObjectPath::try_from( + format!("/org/freedesktop/systemd1/unit/{name}") + .replace('-', "_2d") + .replace('.', "_2e"), + ), + } .map_err(move |_| fdo::Error::UnknownObject(name)) } + + #[dbus_interface(name = "StopUnit")] + async fn stop_unit(&self, name: String, _mode: String) -> fdo::Result { + tracing::debug!(name, _mode, "StopUnit called"); + OwnedObjectPath::try_from(format!("/org/freedesktop/systemd1/job/1234")) + .map_err(move |_| fdo::Error::UnknownObject(name)) + } } -pub async fn start_systemd_manager( - dbus_instances: &DbusInstances, -) -> zbus::Result<( - zbus::Connection, - tokio::sync::oneshot::Receiver<(String, String)>, -)> { - let (tx, rx) = tokio::sync::oneshot::channel(); +pub struct CoreUnit { + active_state: String, +} + +#[dbus_interface(name = "org.freedesktop.systemd1.Unit")] +impl CoreUnit { + #[dbus_interface(property)] + pub async fn active_state(&self) -> String { + tracing::debug!("ActiveState property requested"); + self.active_state.clone() + } + + #[dbus_interface(property)] + pub async fn set_active_state(&mut self, active_state: String) { + tracing::debug!(active_state, "SetActiveState property called"); + self.active_state = active_state; + } +} + +pub struct CoreService; + +#[dbus_interface(name = "org.freedesktop.systemd1.Service")] +impl CoreService { + #[dbus_interface(property, name = "TimeoutStopUSec")] + async fn timeout_stop_u_sec(&self) -> u64 { + tracing::debug!("TimeoutStopUSec property requested"); + 20_000_000 + } +} + +pub async fn start_interfaces(dbus_instances: &DbusInstances) -> zbus::Result { let conn = zbus::ConnectionBuilder::address(dbus_instances.system.address())? .name(zbus_systemd::systemd1::ManagerProxy::DESTINATION)? + .serve_at(zbus_systemd::systemd1::ManagerProxy::PATH, Manager)? + .serve_at(WORLDCOIN_CORE_SERVICE_OBJECT_PATH, CoreService)? .serve_at( - zbus_systemd::systemd1::ManagerProxy::PATH, - Manager { - tx: tx.into(), + WORLDCOIN_CORE_SERVICE_OBJECT_PATH, + CoreUnit { + active_state: "active".into(), }, )? .build() .await?; - Ok((conn, rx)) + Ok(conn) } diff --git a/orb-supervisor/tests/it/main.rs b/orb-supervisor/tests/it/main.rs index 0302a864..252cd980 100644 --- a/orb-supervisor/tests/it/main.rs +++ b/orb-supervisor/tests/it/main.rs @@ -1,3 +1,9 @@ +use std::time::Duration; + +use tap::TapFallible; +use tokio::sync::oneshot; +use tracing::error; + pub mod helpers; #[tokio::test(start_paused = true)] @@ -27,25 +33,63 @@ async fn supervisor_disallows_downloads_if_signup_started_received() -> eyre::Re Ok(()) } -#[tokio::test] +#[tokio::test(start_paused = true)] async fn supervisor_stops_orb_core_when_update_permission_is_requested() -> eyre::Result<()> { + // FIXME: This is a hack to inhibit tokio auto-advance functionality in tests; + // See https://github.com/tokio-rs/tokio/pull/5200 for more info and rework this + // once the necessary functionality is exposed in an API. + let (inhibit_tx, inhibit_rx) = tokio::sync::oneshot::channel(); + tokio::task::spawn_blocking(move || inhibit_rx.blocking_recv()); + let dbus_instances = helpers::launch_dbuses().await??; let settings = helpers::make_settings(&dbus_instances); let application = helpers::spawn_supervisor_service(settings.clone()).await?; - let _application_handle = tokio::spawn(application.run()); - let update_agent_proxy = helpers::make_update_agent_proxy(&settings, &dbus_instances).await?; - let (_systemd_conn, rx) = helpers::start_systemd_manager(&dbus_instances).await?; - - let (permission_given, stop_unit_args) = - tokio::join!(update_agent_proxy.request_update_permission(), rx); + let _application_handle = tokio::spawn(application.run()); - assert!(permission_given?); + tokio::time::advance(orb_supervisor::consts::DURATION_TO_STOP_CORE_AFTER_LAST_SIGNUP).await; - let (name, replace) = stop_unit_args?; - assert_eq!(name, "worldcoin-core.service"); - assert_eq!(replace, "replace"); + let update_agent_proxy = helpers::make_update_agent_proxy(&settings, &dbus_instances).await?; + let system_conn = helpers::start_interfaces(&dbus_instances).await?; + + let request_update_permission_task = + tokio::task::spawn(async move { update_agent_proxy.request_update_permission().await }); + // Switch active state to "inactive" after 300ms with forced synchronizatoin + // through the oneshot channel because tasks are not scheduled immediately. + let (active_task_tx, active_task_rx) = oneshot::channel(); + let system_conn_clone = system_conn.clone(); + let set_active_state_task = tokio::task::spawn(async move { + let core_unit = system_conn_clone + .object_server() + .interface::<_, helpers::CoreUnit>(helpers::WORLDCOIN_CORE_SERVICE_OBJECT_PATH) + .await + .tap_err(|e| error!(error = ?e, "failed getting CoreUnit interface from object server")) + .unwrap(); + active_task_tx + .send(()) + .expect("oneshot channel should be open"); + tokio::time::sleep(Duration::from_millis(300)).await; + core_unit + .get_mut() + .await + .set_active_state("inactive".into()) + .await; + }); + // Using the rx channel as a sync point to make sure time isn't advancing too quickly. + active_task_rx + .await + .expect("oneshot channel should be open"); + tokio::time::advance(Duration::from_millis(500)).await; + let (update_permission, active_state) = + tokio::join!(request_update_permission_task, set_active_state_task); + let update_permission = update_permission.expect( + "the request update permissions task should not have panicked because we don't explicitly \ + panick in it", + ); + assert!(matches!(update_permission, Ok(()))); + assert!(matches!(active_state, Ok(()))); + inhibit_tx.send(()).unwrap(); Ok(()) } From 6a71da69e20479a4763ecb0d54bfc0a0bbd5205d Mon Sep 17 00:00:00 2001 From: Richard Janis Goldschmidt <701177+SuperFluffy@users.noreply.github.com> Date: Thu, 16 Feb 2023 22:59:27 +0100 Subject: [PATCH 18/38] Prepare supervisor 0.3.0 (#25) * bump toolchain due to zigbuild --- .github/workflows/general.yml | 4 ++-- .github/workflows/release-binary.yml | 2 +- Cargo.lock | 2 +- orb-supervisor/CHANGELOG.md | 17 +++++++++++++++++ orb-supervisor/Cargo.toml | 2 +- orb-supervisor/tests/it/helpers.rs | 2 +- 6 files changed, 23 insertions(+), 6 deletions(-) diff --git a/.github/workflows/general.yml b/.github/workflows/general.yml index b4bb41e4..14dab1d4 100644 --- a/.github/workflows/general.yml +++ b/.github/workflows/general.yml @@ -31,7 +31,7 @@ jobs: ~/.cargo/git/db/ target/ key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} - - uses: dtolnay/rust-toolchain@1.61.0 + - uses: dtolnay/rust-toolchain@1.64.0 - run: cargo test rustfmt: @@ -73,7 +73,7 @@ jobs: ~/.cargo/git/db/ target/ key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} - - uses: dtolnay/rust-toolchain@1.61.0 + - uses: dtolnay/rust-toolchain@1.64.0 with: components: clippy - run: cargo clippy -- -D warnings -W clippy::pedantic -A clippy::missing_errors_doc -A clippy::module_name_repetitions diff --git a/.github/workflows/release-binary.yml b/.github/workflows/release-binary.yml index e7226a71..e7386f16 100644 --- a/.github/workflows/release-binary.yml +++ b/.github/workflows/release-binary.yml @@ -29,7 +29,7 @@ jobs: uses: goto-bus-stop/setup-zig@v1 with: version: 0.9.1 - - uses: dtolnay/rust-toolchain@1.61.0 + - uses: dtolnay/rust-toolchain@1.64.0 with: targets: aarch64-unknown-linux-gnu - run: cargo install cargo-zigbuild diff --git a/Cargo.lock b/Cargo.lock index 324def12..ab43d29e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -573,7 +573,7 @@ checksum = "6f61fba1741ea2b3d6a1e3178721804bb716a68a6aeba1149b5d52e3d464ea66" [[package]] name = "orb-supervisor" -version = "0.2.0" +version = "0.3.0" dependencies = [ "dbus-launch", "eyre", diff --git a/orb-supervisor/CHANGELOG.md b/orb-supervisor/CHANGELOG.md index 2f647cfe..883a3492 100644 --- a/orb-supervisor/CHANGELOG.md +++ b/orb-supervisor/CHANGELOG.md @@ -1,5 +1,22 @@ # Changelog +## 0.3.0 + +`orb-supervisor` no longer shuts down `orb-core` immediately when an update happens +but waits until no new signups have been started for a while. + +### Added + ++ Upon receiving a `RequestUpdatePermission` request, `orb-supervisor` only shuts + down `orb-core` after 20 minutes of inactivity (meaning that no signups have been + performed for 20 minutes). This timer is reset every time a new signup starts. + Once the timer is up, `orb-supervisor` schedules `update-agent` to immediately run again. + +### Changed + ++ `orb-supervisor` now returns custom `MethodError`s to report why an update was denied, + bringing it more in line with DBus conventions. + ## 0.2.0 (October 20, 2022) `orb-supervisor`'s integration with systemd and journald is improved by using diff --git a/orb-supervisor/Cargo.toml b/orb-supervisor/Cargo.toml index f0280b70..2c1a03c9 100644 --- a/orb-supervisor/Cargo.toml +++ b/orb-supervisor/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "orb-supervisor" -version = "0.2.0" +version = "0.3.0" edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html diff --git a/orb-supervisor/tests/it/helpers.rs b/orb-supervisor/tests/it/helpers.rs index ab6ab20d..c3ebeb59 100644 --- a/orb-supervisor/tests/it/helpers.rs +++ b/orb-supervisor/tests/it/helpers.rs @@ -115,7 +115,7 @@ struct Signup; #[dbus_interface(name = "org.worldcoin.OrbCore1.Signup")] impl Signup { #[dbus_interface(signal)] - pub async fn signup_started(ctxt: &SignalContext<'_>) -> zbus::Result<()>; + pub(crate) async fn signup_started(ctxt: &SignalContext<'_>) -> zbus::Result<()>; } pub async fn start_signup_service_and_send_signal( From 088e00a338a835657ec450041cbf91d0580bd609 Mon Sep 17 00:00:00 2001 From: Cyril Fougeray Date: Tue, 18 Apr 2023 10:41:22 +0200 Subject: [PATCH 19/38] fix various typos (#21) --- orb-supervisor/README.md | 2 +- orb-supervisor/src/startup.rs | 4 ++-- orb-supervisor/src/tasks/signup_started.rs | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/orb-supervisor/README.md b/orb-supervisor/README.md index cfd93638..c570df68 100644 --- a/orb-supervisor/README.md +++ b/orb-supervisor/README.md @@ -15,7 +15,7 @@ $ cargo zigbuild --release --target aarch64-unknown-linux-gnu -p orb-supervisor # Running tests -Integration tests are spawned with telemetry, but logs are by default surpressed. To enable logs +Integration tests are spawned with telemetry, but logs are by default suppressed. To enable logs in tests run with: ```sh diff --git a/orb-supervisor/src/startup.rs b/orb-supervisor/src/startup.rs index 3cc26318..37fb9ae9 100644 --- a/orb-supervisor/src/startup.rs +++ b/orb-supervisor/src/startup.rs @@ -25,7 +25,7 @@ pub enum Error { EstablishSessionConnection(#[source] zbus::Error), #[error("failed to establish connection to system dbus")] EstablishSystemConnection(#[source] zbus::Error), - #[error("error occured in zbus communication")] + #[error("error occurred in zbus communication")] Zbus(#[from] zbus::Error), #[error("invalid session D-Bus address")] SessionDbusAddress(#[source] zbus::Error), @@ -81,7 +81,7 @@ impl Application { /// instance was not understood (the path is conventionally stored in the environment variable /// `$DBUS_SESSION_BUS_ADDRESS`, e.g. `unix:path=/run/user/1000/bus` and usually set by /// systemd. - /// + [`Error::EstablishSessionConnection`], if an error occured while trying to establish + /// + [`Error::EstablishSessionConnection`], if an error occurred while trying to establish /// a connection to the session D-Bus instance, or trying to register an interface with it. /// path to which is conventionally stored in the environment variable /// systemd. diff --git a/orb-supervisor/src/tasks/signup_started.rs b/orb-supervisor/src/tasks/signup_started.rs index cc96cd99..f20f9eb7 100644 --- a/orb-supervisor/src/tasks/signup_started.rs +++ b/orb-supervisor/src/tasks/signup_started.rs @@ -16,7 +16,7 @@ use crate::{ /// /// # Errors /// -/// + `[zbus::Error]` if an error occured while building a D-Bus proxy listening for signups from +/// + `[zbus::Error]` if an error occurred while building a D-Bus proxy listening for signups from /// `orb-core`. The errors are the same as those in [`zbus::ProxyBuilder`]. pub async fn spawn_signup_started_task<'a>( settings: &Settings, From 55509f0a50d73799a10e353040fe7c62729874ba Mon Sep 17 00:00:00 2001 From: mrkdir <56895722+mrkdir@users.noreply.github.com> Date: Tue, 25 Apr 2023 15:27:09 +0200 Subject: [PATCH 20/38] Add development build release (#27) For latest successful build of main branch, use tag `latest` --- .github/workflows/release-binary.yml | 38 ++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/.github/workflows/release-binary.yml b/.github/workflows/release-binary.yml index e7386f16..24e1cf99 100644 --- a/.github/workflows/release-binary.yml +++ b/.github/workflows/release-binary.yml @@ -3,6 +3,8 @@ on: push: tags: - orb-supervisor-[0-9]+.* + branches: + - main jobs: build: @@ -42,6 +44,8 @@ jobs: key: ${{ github.run_id }}-${{ github.run_number }}-${{ github.run_attempt }}-orb-supervisor-bin release: + # only run this for release tags + if: ${{ github.ref_type == 'tag' && startsWith(github.ref_name, 'orb-supervisor') }} needs: build runs-on: ubuntu-latest steps: @@ -82,3 +86,37 @@ jobs: prerelease: ${{ contains(github.ref, 'alpha') || contains(github.ref, 'beta') || contains(github.ref, 'rc') }} name: orb-supervisor ${{ env.TITLE }} body: ${{ env.NOTES }} + + release-latest: + # only release on pushes on main branch + if: ${{ github.ref_name == 'main' }} + runs-on: ubuntu-22.04 + needs: [build] + steps: + - uses: actions/checkout@v3 + - name: Retrieve cache + uses: actions/cache@v3 + with: + path: target/aarch64-unknown-linux-gnu/release/orb-supervisor + key: ${{ github.run_id }}-${{ github.run_number }}-${{ github.run_attempt }}-orb-supervisor-bin + - name: archive binary + run: | + cd target/aarch64-unknown-linux-gnu/release + tar cvzf orb-supervisor-latest.tar.gz orb-supervisor + shasum -a 256 orb-supervisor-latest.tar.gz > orb-supervisor-latest.tar.gz.sha256 + cd - + - name: upload development build + run: | + gh release delete latest \ + --yes \ + --cleanup-tag \ + --repo ${{ github.repository }} || true + gh release create latest \ + --title 'Development Build' \ + --notes 'Latest successful build of main branch' \ + --prerelease \ + --repo ${{ github.repository }} \ + target/aarch64-unknown-linux-gnu/release/orb-supervisor-latest.tar.gz \ + target/aarch64-unknown-linux-gnu/release/orb-supervisor-latest.tar.gz.sha256 + env: + GH_TOKEN: ${{ github.token }} From 2e1442a1d64dbcd1727705aea456be91457c7982 Mon Sep 17 00:00:00 2001 From: Galileo Daras Date: Tue, 20 Jun 2023 16:54:09 +0200 Subject: [PATCH 21/38] Add logind ScheduleShutdown proxy (#28) * Add logind ScheduleShutdown proxy --------- Co-authored-by: mrkdir <56895722+mrkdir@users.noreply.github.com> --- Cargo.lock | 2 +- orb-supervisor/CHANGELOG.md | 8 ++ orb-supervisor/Cargo.toml | 4 +- orb-supervisor/src/interfaces/manager.rs | 43 +++++- orb-supervisor/src/tasks/mod.rs | 1 + orb-supervisor/src/tasks/shutdown.rs | 169 +++++++++++++++++++++++ 6 files changed, 222 insertions(+), 5 deletions(-) create mode 100644 orb-supervisor/src/tasks/shutdown.rs diff --git a/Cargo.lock b/Cargo.lock index ab43d29e..0ad4692e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -573,7 +573,7 @@ checksum = "6f61fba1741ea2b3d6a1e3178721804bb716a68a6aeba1149b5d52e3d464ea66" [[package]] name = "orb-supervisor" -version = "0.3.0" +version = "0.4.0" dependencies = [ "dbus-launch", "eyre", diff --git a/orb-supervisor/CHANGELOG.md b/orb-supervisor/CHANGELOG.md index 883a3492..eeea8c47 100644 --- a/orb-supervisor/CHANGELOG.md +++ b/orb-supervisor/CHANGELOG.md @@ -1,5 +1,13 @@ # Changelog +## 0.4.0 + +### Added + ++ Proxy for logind method `org.freedesktop.login1.Manager.ScheduleShutdown` + + enables `orb-core` and `update-agent` to shutdown or restart the device without + needing to grant elevated priveleges/suid + ## 0.3.0 `orb-supervisor` no longer shuts down `orb-core` immediately when an update happens diff --git a/orb-supervisor/Cargo.toml b/orb-supervisor/Cargo.toml index 2c1a03c9..7635ff44 100644 --- a/orb-supervisor/Cargo.toml +++ b/orb-supervisor/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "orb-supervisor" -version = "0.3.0" +version = "0.4.0" edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html @@ -14,7 +14,7 @@ tokio-stream = "0.1.11" tracing = { version = "0.1.37", features = ["attributes"] } tracing-subscriber = { version = "0.3.16", features = ["env-filter"] } zbus = { version = "3.9.0", default-features = false, features = ["tokio"] } -zbus_systemd = { version = "0.0.8", features = ["systemd1"] } +zbus_systemd = { version = "0.0.8", features = [ "systemd1", "login1" ] } thiserror = "1.0.37" futures = "0.3.24" once_cell = "1.15.0" diff --git a/orb-supervisor/src/interfaces/manager.rs b/orb-supervisor/src/interfaces/manager.rs index 9ceb464e..cb5c80e5 100644 --- a/orb-supervisor/src/interfaces/manager.rs +++ b/orb-supervisor/src/interfaces/manager.rs @@ -12,6 +12,7 @@ use tokio::{ }; use tracing::{ debug, + info, instrument, warn, }; @@ -21,7 +22,10 @@ use zbus::{ DBusError, SignalContext, }; -use zbus_systemd::systemd1::ManagerProxy; +use zbus_systemd::{ + login1, + systemd1, +}; use crate::tasks; @@ -39,6 +43,7 @@ pub enum BusError { #[dbus_error(zbus_error)] ZBus(zbus::Error), UpdatesBlocked(String), + InvalidArgs(String), } impl BusError { @@ -134,7 +139,7 @@ impl Manager { .system_connection .as_ref() .expect("manager must be conntected to system dbus"); - let systemd_proxy = ManagerProxy::new(conn).await?; + let systemd_proxy = systemd1::ManagerProxy::new(conn).await?; // Spawn task to shut down worldcoin core let mut shutdown_core_task = tasks::update::spawn_shutdown_worldcoin_core_timer( systemd_proxy.clone(), @@ -174,6 +179,40 @@ impl Manager { } } } + + #[dbus_interface(name = "ScheduleShutdown")] + #[instrument( + name = "org.worldcoin.OrbSupervisor1.Manager.ScheduleShutdown", + skip_all + )] + async fn schedule_shutdown(&self, kind: &str, when: u64) -> Result<(), BusError> { + debug!("ScheduleShutdown was called"); + let shutdown = tasks::shutdown::ScheduledShutdown::try_from_dbus((kind.to_string(), when)) + .map_err(|err| BusError::InvalidArgs(format!("schedule shutdown failed: `{err:?}`")))?; + let conn = self + .system_connection + .as_ref() + .expect("manager must be conntected to system dbus"); + let logind_proxy = login1::ManagerProxy::new(conn).await?; + let schedule_shutdown_task = + tasks::shutdown::spawn_logind_schedule_shutdown_task(logind_proxy, shutdown.clone()); + match schedule_shutdown_task.await { + Ok(Ok(())) => info!("scheduled shutdown `{shutdown:?}`"), + Ok(Err(err @ tasks::shutdown::Error::Defer(_))) => warn!( + error = ?err, + "skipped shutdown `{shutdown:?}`" + ), + Ok(Err(err)) => warn!( + error = ?err, + "failed to schedule shutdown `{shutdown:?}` with error `{err:?}`" + ), + Err(err) => warn!( + panic_msg = ?err, + "logind schedule shutdown task panicked trying;", + ), + }; + Ok(()) + } } #[cfg(test)] diff --git a/orb-supervisor/src/tasks/mod.rs b/orb-supervisor/src/tasks/mod.rs index 8d054a23..e8f2e033 100644 --- a/orb-supervisor/src/tasks/mod.rs +++ b/orb-supervisor/src/tasks/mod.rs @@ -1,5 +1,6 @@ //! Tasks that make up the orb supervisor. +pub mod shutdown; pub mod signup_started; pub mod update; diff --git a/orb-supervisor/src/tasks/shutdown.rs b/orb-supervisor/src/tasks/shutdown.rs new file mode 100644 index 00000000..660166c4 --- /dev/null +++ b/orb-supervisor/src/tasks/shutdown.rs @@ -0,0 +1,169 @@ +use std::{ + cmp::Ordering, + fmt::Display, +}; + +use futures::TryFutureExt; +use tokio::task::JoinHandle; +use tracing::{ + info, + instrument, +}; +use zbus_systemd::login1::{ + self, + ManagerProxy, +}; +use Kind::{ + DryHalt, + DryPoweroff, + DryReboot, + Halt, + Poweroff, + Reboot, +}; + +/// `ScheduledShutdown` represents the logind shutdown tuple both as an argument +/// and return value for the `org.freedesktop.login1.Manager.ScheduledShutdown` +/// dbus method. +/// +/// The priority of a scheduled shutdown is determined first by the kind (and +/// its presence), followed by the soonest (lowest `when` value). +#[derive(Clone, Debug, PartialEq, Eq)] +pub struct ScheduledShutdown { + pub kind: Option, + pub when: u64, +} + +#[derive(Clone, Debug, PartialEq, PartialOrd, Eq, Ord)] +pub enum Kind { + Poweroff = 6, + Reboot = 5, + Halt = 4, + DryPoweroff = 3, + DryReboot = 2, + DryHalt = 1, +} + +impl ScheduledShutdown { + /// `try_from_dbus` attempts to convert from the tuple returned by + /// `org.freedesktop.login1.Manager.ScheduleShutdown` into a `ScheduledShutdown` instance + /// + /// # Errors + /// This function bubbles up any errors encountered while calling `TryFrom` for `Kind` + pub fn try_from_dbus((kind, when): (String, u64)) -> Result { + let kind = match Kind::try_from(kind.as_str()) { + Ok(kind) => Some(kind), + Err(Error::NothingScheduled) => None, + Err(err) => return Err(err), + }; + + Ok(Self { + kind, + when, + }) + } + + #[must_use] + pub fn kind_as_str(&self) -> String { + match &self.kind { + None => String::new(), + Some(kind) => kind.to_string(), + } + } +} + +impl PartialOrd for ScheduledShutdown { + fn partial_cmp(&self, other: &Self) -> Option { + match self.kind.cmp(&other.kind) { + // We want to prioritize smaller `when` values + Ordering::Equal => Some(self.when.cmp(&other.when).reverse()), + v => Some(v), + } + } +} + +impl TryFrom<&str> for Kind { + type Error = Error; + + fn try_from(value: &str) -> Result { + match value { + "" => Err(Error::NothingScheduled), + "dry-poweroff" => Ok(Self::DryPoweroff), + "dry-reboot" => Ok(Self::DryReboot), + "dry-halt" => Ok(Self::DryHalt), + "poweroff" => Ok(Self::Poweroff), + "reboot" => Ok(Self::Reboot), + "halt" => Ok(Self::Halt), + unknown => Err(Error::unrecognized_type(unknown)), + } + } +} + +impl Display for Kind { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + write!( + f, + "{}", + match self { + Poweroff => "poweroff", + Reboot => "reboot", + Halt => "halt", + DryPoweroff => "dry-poweroff", + DryReboot => "dry-reboot", + DryHalt => "dry-halt", + } + ) + } +} + +#[derive(Debug, thiserror::Error)] +pub enum Error { + #[error("logind has no shutdown scheduled")] + NothingScheduled, + #[error("unrecognized shutdown type `{0}`")] + UnrecognizedType(String), + #[error("failed communicating over dbus")] + Dbus(#[from] zbus::Error), + #[error("deferring for higher priority scheduled shutdown `{0:?}`")] + Defer(ScheduledShutdown), +} + +impl Error { + fn unrecognized_type(kind: &str) -> Self { + Self::UnrecognizedType(kind.to_string()) + } +} + +#[must_use] +pub fn spawn_logind_schedule_shutdown_task( + proxy: login1::ManagerProxy<'static>, + shutdown_req: ScheduledShutdown, +) -> JoinHandle> { + tokio::spawn(async move { + info!("getting property `org.freedesktop.login1.Manager.ScheduledShutdown`"); + let scheduled_shutdown = get_logind_scheduled_shutdown(proxy.clone()).await?; + + // PartialOrd guarantees us that a requested "Poweroff" in 1000us will + // take priority over an already scheduled "Reboot" in 10us + if shutdown_req.gt(&scheduled_shutdown) { + info!("calling `org.freedesktop.login1.Manager.ScheduleShutdown` to shutdown system"); + proxy + .schedule_shutdown(shutdown_req.kind_as_str(), shutdown_req.when) + .map_err(Error::from) + .await + } else { + Err(Error::Defer(scheduled_shutdown)) + } + }) +} + +#[instrument(skip_all, err, ret(Debug))] +async fn get_logind_scheduled_shutdown( + proxy: ManagerProxy<'static>, +) -> Result { + proxy + .scheduled_shutdown() + .map_ok(ScheduledShutdown::try_from_dbus) + .map_err(Error::from) + .await? +} From 2673cfe973cd00acf345bfb88bea7b6a56ad7ea0 Mon Sep 17 00:00:00 2001 From: Ryan Butler Date: Tue, 24 Oct 2023 10:55:54 -0400 Subject: [PATCH 22/38] Pin rust version to stable (#29) * Fix CI * Fix clippy --- .github/workflows/general.yml | 66 +++++------------- .github/workflows/release-binary.yml | 23 ++---- Cargo.toml | 1 + orb-supervisor/src/consts.rs | 3 +- orb-supervisor/src/interfaces/manager.rs | 81 ++++++++++------------ orb-supervisor/src/lib.rs | 7 ++ orb-supervisor/src/main.rs | 10 +-- orb-supervisor/src/startup.rs | 22 +++--- orb-supervisor/src/tasks/shutdown.rs | 29 ++------ orb-supervisor/src/tasks/signup_started.rs | 6 +- orb-supervisor/src/tasks/update.rs | 74 +++++++------------- orb-supervisor/src/telemetry.rs | 21 +++--- orb-supervisor/tests/it/helpers.rs | 45 +++++------- orb-supervisor/tests/it/main.rs | 37 ++++++---- rust-toolchain.toml | 5 ++ rustfmt.toml | 64 +---------------- 16 files changed, 169 insertions(+), 325 deletions(-) create mode 100644 rust-toolchain.toml diff --git a/.github/workflows/general.yml b/.github/workflows/general.yml index 14dab1d4..92603dcc 100644 --- a/.github/workflows/general.yml +++ b/.github/workflows/general.yml @@ -8,48 +8,27 @@ on: pull_request: workflow_dispatch: +# Make sure CI fails on all warnings, including Clippy lints +env: + RUSTFLAGS: "-Dwarnings" + jobs: test: runs-on: ubuntu-latest - env: - RUSTFLAGS: "-D warnings -W unreachable-pub -W rust-2021-compatibility" steps: - run: | - git config --global --add url."https://${{ secrets.RUNNER_TOKEN }}:x-oauth-basic@github.com/worldcoin/".insteadOf "ssh://git@github.com/worldcoin/" - git config --global --add url."https://${{ secrets.RUNNER_TOKEN }}:x-oauth-basic@github.com/worldcoin/".insteadOf "git@github.com:worldcoin/" - git config --global --add url."https://${{ secrets.RUNNER_TOKEN }}:x-oauth-basic@github.com/worldcoin/".insteadOf "https://github.com/worldcoin/" + git config --global --add url."https://${{ secrets.GIT_HUB_TOKEN }}:x-oauth-basic@github.com/worldcoin/".insteadOf "ssh://git@github.com/worldcoin/" + git config --global --add url."https://${{ secrets.GIT_HUB_TOKEN }}:x-oauth-basic@github.com/worldcoin/".insteadOf "git@github.com:worldcoin/" + git config --global --add url."https://${{ secrets.GIT_HUB_TOKEN }}:x-oauth-basic@github.com/worldcoin/".insteadOf "https://github.com/worldcoin/" - uses: actions/checkout@v3 - with: - token: ${{ secrets.RUNNER_TOKEN }} - submodules: recursive - - uses: actions/cache@v3 - with: - path: | - ~/.cargo/bin/ - ~/.cargo/registry/index/ - ~/.cargo/registry/cache/ - ~/.cargo/git/db/ - target/ - key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} - - uses: dtolnay/rust-toolchain@1.64.0 - - run: cargo test + - name: Cache cargo dependencies + uses: Swatinem/rust-cache@v2 + - run: cargo test --all rustfmt: runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 - - uses: actions/cache@v3 - with: - path: | - ~/.cargo/bin/ - ~/.cargo/registry/index/ - ~/.cargo/registry/cache/ - ~/.cargo/git/db/ - target/ - key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} - - uses: dtolnay/rust-toolchain@nightly - with: - components: rustfmt - run: cargo fmt --all -- --check clippy: @@ -57,23 +36,10 @@ jobs: runs-on: ubuntu-latest steps: - run: | - git config --global url."https://${{ secrets.RUNNER_TOKEN }}:x-oauth-basic@github.com/worldcoin/".insteadOf "ssh://git@github.com/worldcoin/" - git config --global url."https://${{ secrets.RUNNER_TOKEN }}:x-oauth-basic@github.com/worldcoin/".insteadOf "git@github.com:worldcoin/" - git config --global url."https://${{ secrets.RUNNER_TOKEN }}:x-oauth-basic@github.com/worldcoin/".insteadOf "https://github.com/worldcoin/" + git config --global url."https://${{ secrets.GIT_HUB_TOKEN }}:x-oauth-basic@github.com/worldcoin/".insteadOf "ssh://git@github.com/worldcoin/" + git config --global url."https://${{ secrets.GIT_HUB_TOKEN }}:x-oauth-basic@github.com/worldcoin/".insteadOf "git@github.com:worldcoin/" + git config --global url."https://${{ secrets.GIT_HUB_TOKEN }}:x-oauth-basic@github.com/worldcoin/".insteadOf "https://github.com/worldcoin/" - uses: actions/checkout@v3 - with: - token: ${{ secrets.RUNNER_TOKEN }} - submodules: recursive - - uses: actions/cache@v3 - with: - path: | - ~/.cargo/bin/ - ~/.cargo/registry/index/ - ~/.cargo/registry/cache/ - ~/.cargo/git/db/ - target/ - key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} - - uses: dtolnay/rust-toolchain@1.64.0 - with: - components: clippy - - run: cargo clippy -- -D warnings -W clippy::pedantic -A clippy::missing_errors_doc -A clippy::module_name_repetitions + - name: Cache cargo dependencies + uses: Swatinem/rust-cache@v2 + - run: cargo clippy --all --all-features --all-targets --no-deps diff --git a/.github/workflows/release-binary.yml b/.github/workflows/release-binary.yml index 24e1cf99..9c2ff9bd 100644 --- a/.github/workflows/release-binary.yml +++ b/.github/workflows/release-binary.yml @@ -11,29 +11,16 @@ jobs: runs-on: ubuntu-latest steps: - run: | - git config --global --add url."https://${{ secrets.RUNNER_TOKEN }}:x-oauth-basic@github.com/worldcoin/".insteadOf "ssh://git@github.com/worldcoin/" - git config --global --add url."https://${{ secrets.RUNNER_TOKEN }}:x-oauth-basic@github.com/worldcoin/".insteadOf "git@github.com:worldcoin/" - git config --global --add url."https://${{ secrets.RUNNER_TOKEN }}:x-oauth-basic@github.com/worldcoin/".insteadOf "https://github.com/worldcoin/" + git config --global --add url."https://${{ secrets.GIT_HUB_TOKEN }}:x-oauth-basic@github.com/worldcoin/".insteadOf "ssh://git@github.com/worldcoin/" + git config --global --add url."https://${{ secrets.GIT_HUB_TOKEN }}:x-oauth-basic@github.com/worldcoin/".insteadOf "git@github.com:worldcoin/" + git config --global --add url."https://${{ secrets.GIT_HUB_TOKEN }}:x-oauth-basic@github.com/worldcoin/".insteadOf "https://github.com/worldcoin/" - uses: actions/checkout@v3 - with: - token: ${{ secrets.RUNNER_TOKEN }} - submodules: recursive - - uses: actions/cache@v3 - with: - path: | - ~/.cargo/bin/ - ~/.cargo/registry/index/ - ~/.cargo/registry/cache/ - ~/.cargo/git/db/ - target/ - key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} - name: Install zig uses: goto-bus-stop/setup-zig@v1 with: version: 0.9.1 - - uses: dtolnay/rust-toolchain@1.64.0 - with: - targets: aarch64-unknown-linux-gnu + - name: Cache cargo dependencies + uses: Swatinem/rust-cache@v2 - run: cargo install cargo-zigbuild - name: Build orb-supervisor binary run: cargo zigbuild --release --target aarch64-unknown-linux-gnu.2.27 -p orb-supervisor diff --git a/Cargo.toml b/Cargo.toml index 21010784..b3503253 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,4 +1,5 @@ [workspace] +resolver = "2" members = [ "orb-supervisor", ] diff --git a/orb-supervisor/src/consts.rs b/orb-supervisor/src/consts.rs index 0aaeca99..46adb979 100644 --- a/orb-supervisor/src/consts.rs +++ b/orb-supervisor/src/consts.rs @@ -1,4 +1,5 @@ use tokio::time::Duration; pub const WORLDCOIN_CORE_UNIT_NAME: &str = "worldcoin-core.service"; -pub const DURATION_TO_STOP_CORE_AFTER_LAST_SIGNUP: Duration = Duration::from_secs(20 * 60); +pub const DURATION_TO_STOP_CORE_AFTER_LAST_SIGNUP: Duration = + Duration::from_secs(20 * 60); diff --git a/orb-supervisor/src/interfaces/manager.rs b/orb-supervisor/src/interfaces/manager.rs index cb5c80e5..ad34cd71 100644 --- a/orb-supervisor/src/interfaces/manager.rs +++ b/orb-supervisor/src/interfaces/manager.rs @@ -5,27 +5,11 @@ use tokio::{ sync::watch, - time::{ - Duration, - Instant, - }, -}; -use tracing::{ - debug, - info, - instrument, - warn, -}; -use zbus::{ - dbus_interface, - Connection, - DBusError, - SignalContext, -}; -use zbus_systemd::{ - login1, - systemd1, + time::{Duration, Instant}, }; +use tracing::{debug, info, instrument, warn}; +use zbus::{dbus_interface, Connection, DBusError, SignalContext}; +use zbus_systemd::{login1, systemd1}; use crate::tasks; @@ -33,7 +17,8 @@ use crate::tasks; /// before the update agent is permitted to start a download. pub const DEFAULT_DURATION_TO_ALLOW_DOWNLOADS: Duration = Duration::from_secs(3600); -pub const BACKGROUND_DOWNLOADS_ALLOWED_PROPERTY_NAME: &str = "BackgroundDownloadsAllowed"; +pub const BACKGROUND_DOWNLOADS_ALLOWED_PROPERTY_NAME: &str = + "BackgroundDownloadsAllowed"; pub const INTERFACE_NAME: &str = "org.worldcoin.OrbSupervisor1.Manager"; pub const OBJECT_PATH: &str = "/org/worldcoin/OrbSupervisor1/Manager"; @@ -71,7 +56,10 @@ impl Manager { } #[must_use] - pub fn duration_to_allow_downloads(self, duration_to_allow_downloads: Duration) -> Self { + pub fn duration_to_allow_downloads( + self, + duration_to_allow_downloads: Duration, + ) -> Self { Self { duration_to_allow_downloads, ..self @@ -117,7 +105,9 @@ impl Default for Manager { impl Manager { #[dbus_interface(property, name = "BackgroundDownloadsAllowed")] #[instrument( - fields(dbus_interface = "org.worldcoin.OrbSupervisor1.Manager.BackgroundDownloadsAllowed"), + fields( + dbus_interface = "org.worldcoin.OrbSupervisor1.Manager.BackgroundDownloadsAllowed" + ), skip_all )] async fn background_downloads_allowed(&self) -> bool { @@ -146,7 +136,9 @@ impl Manager { self.last_signup_event.subscribe(), ); // Wait for one second to see if worldcoin core is already shut down - match tokio::time::timeout(Duration::from_secs(1), &mut shutdown_core_task).await { + match tokio::time::timeout(Duration::from_secs(1), &mut shutdown_core_task) + .await + { Ok(Ok(Ok(()))) => { debug!("worldcoin core shut down task returned in less than 1s, permitting update"); Ok(()) @@ -187,15 +179,23 @@ impl Manager { )] async fn schedule_shutdown(&self, kind: &str, when: u64) -> Result<(), BusError> { debug!("ScheduleShutdown was called"); - let shutdown = tasks::shutdown::ScheduledShutdown::try_from_dbus((kind.to_string(), when)) - .map_err(|err| BusError::InvalidArgs(format!("schedule shutdown failed: `{err:?}`")))?; + let shutdown = + tasks::shutdown::ScheduledShutdown::try_from_dbus((kind.to_string(), when)) + .map_err(|err| { + BusError::InvalidArgs(format!( + "schedule shutdown failed: `{err:?}`" + )) + })?; let conn = self .system_connection .as_ref() .expect("manager must be conntected to system dbus"); let logind_proxy = login1::ManagerProxy::new(conn).await?; let schedule_shutdown_task = - tasks::shutdown::spawn_logind_schedule_shutdown_task(logind_proxy, shutdown.clone()); + tasks::shutdown::spawn_logind_schedule_shutdown_task( + logind_proxy, + shutdown.clone(), + ); match schedule_shutdown_task.await { Ok(Ok(())) => info!("scheduled shutdown `{shutdown:?}`"), Ok(Err(err @ tasks::shutdown::Error::Defer(_))) => warn!( @@ -219,10 +219,7 @@ impl Manager { mod tests { use zbus::Interface; - use super::{ - Manager, - DEFAULT_DURATION_TO_ALLOW_DOWNLOADS, - }; + use super::{Manager, DEFAULT_DURATION_TO_ALLOW_DOWNLOADS}; #[test] fn manager_interface_name_matches_exported_const() { @@ -232,18 +229,16 @@ mod tests { #[tokio::test] async fn manager_background_downloads_allowed_property_matched_exported_const() { let manager = Manager::new(); - assert!( - manager - .get(super::BACKGROUND_DOWNLOADS_ALLOWED_PROPERTY_NAME) - .await - .is_some() - ); + assert!(manager + .get(super::BACKGROUND_DOWNLOADS_ALLOWED_PROPERTY_NAME) + .await + .is_some()); } #[tokio::test(start_paused = true)] async fn downloads_are_disallowed_if_last_signup_event_is_too_recent() { - let manager = - Manager::new().duration_to_allow_downloads(DEFAULT_DURATION_TO_ALLOW_DOWNLOADS); + let manager = Manager::new() + .duration_to_allow_downloads(DEFAULT_DURATION_TO_ALLOW_DOWNLOADS); tokio::time::advance(DEFAULT_DURATION_TO_ALLOW_DOWNLOADS / 2).await; assert!(!manager.are_downloads_allowed()); @@ -251,16 +246,16 @@ mod tests { #[tokio::test(start_paused = true)] async fn downloads_are_allowed_if_last_signup_event_is_old_enough() { - let manager = - Manager::new().duration_to_allow_downloads(DEFAULT_DURATION_TO_ALLOW_DOWNLOADS); + let manager = Manager::new() + .duration_to_allow_downloads(DEFAULT_DURATION_TO_ALLOW_DOWNLOADS); tokio::time::advance(DEFAULT_DURATION_TO_ALLOW_DOWNLOADS * 2).await; assert!(manager.are_downloads_allowed()); } #[tokio::test(start_paused = true)] async fn downloads_become_disallowed_after_reset() { - let mut manager = - Manager::new().duration_to_allow_downloads(DEFAULT_DURATION_TO_ALLOW_DOWNLOADS); + let mut manager = Manager::new() + .duration_to_allow_downloads(DEFAULT_DURATION_TO_ALLOW_DOWNLOADS); tokio::time::advance(DEFAULT_DURATION_TO_ALLOW_DOWNLOADS * 2).await; assert!(manager.are_downloads_allowed()); manager.reset_last_signup_event(); diff --git a/orb-supervisor/src/lib.rs b/orb-supervisor/src/lib.rs index 187e36ec..ba538dd4 100644 --- a/orb-supervisor/src/lib.rs +++ b/orb-supervisor/src/lib.rs @@ -1,3 +1,10 @@ +#![warn(clippy::pedantic)] +#![allow( + clippy::missing_errors_doc, + clippy::module_name_repetitions, + clippy::ignored_unit_patterns +)] + pub mod consts; pub mod interfaces; pub mod proxies; diff --git a/orb-supervisor/src/main.rs b/orb-supervisor/src/main.rs index 198ca15b..d3fafbda 100644 --- a/orb-supervisor/src/main.rs +++ b/orb-supervisor/src/main.rs @@ -1,13 +1,7 @@ use eyre::WrapErr as _; use orb_supervisor::{ - startup::{ - Application, - Settings, - }, - telemetry::{ - self, - ExecContext, - }, + startup::{Application, Settings}, + telemetry::{self, ExecContext}, }; use tracing::debug; use tracing_subscriber::filter::LevelFilter; diff --git a/orb-supervisor/src/startup.rs b/orb-supervisor/src/startup.rs index 37fb9ae9..a72daf06 100644 --- a/orb-supervisor/src/startup.rs +++ b/orb-supervisor/src/startup.rs @@ -1,18 +1,11 @@ use futures::future::TryFutureExt as _; use tracing::debug; -use zbus::{ - Connection, - ConnectionBuilder, -}; +use zbus::{Connection, ConnectionBuilder}; use crate::{ - interfaces::{ - self, - manager, - }, + interfaces::{self, manager}, proxies::core::{ - SIGNUP_PROXY_DEFAULT_OBJECT_PATH, - SIGNUP_PROXY_DEFAULT_WELL_KNOWN_NAME, + SIGNUP_PROXY_DEFAULT_OBJECT_PATH, SIGNUP_PROXY_DEFAULT_WELL_KNOWN_NAME, }, tasks, }; @@ -49,7 +42,8 @@ impl Settings { session_dbus_path: None, system_dbus_path: None, manager_object_path: manager::OBJECT_PATH.to_string(), - signup_proxy_well_known_name: SIGNUP_PROXY_DEFAULT_WELL_KNOWN_NAME.to_string(), + signup_proxy_well_known_name: SIGNUP_PROXY_DEFAULT_WELL_KNOWN_NAME + .to_string(), signup_proxy_object_path: SIGNUP_PROXY_DEFAULT_OBJECT_PATH.to_string(), well_known_name: DBUS_WELL_KNOWN_NAME.to_string(), } @@ -105,7 +99,8 @@ impl Application { let mut manager = interfaces::Manager::new(); manager.set_system_connection(system_connection.clone()); - let session_builder = if let Some(path) = settings.session_dbus_path.as_deref() { + let session_builder = if let Some(path) = settings.session_dbus_path.as_deref() + { ConnectionBuilder::address(path) } else { ConnectionBuilder::session() @@ -143,7 +138,8 @@ impl Application { /// [`tasks::spawn_signup_started_task`] for more information. pub async fn run(self) -> Result<(), Error> { let signup_started_task = - tasks::spawn_signup_started_task(&self.settings, &self.session_connection).await?; + tasks::spawn_signup_started_task(&self.settings, &self.session_connection) + .await?; let (..) = tokio::join!(signup_started_task); Ok(()) diff --git a/orb-supervisor/src/tasks/shutdown.rs b/orb-supervisor/src/tasks/shutdown.rs index 660166c4..ac05cb5b 100644 --- a/orb-supervisor/src/tasks/shutdown.rs +++ b/orb-supervisor/src/tasks/shutdown.rs @@ -1,26 +1,10 @@ -use std::{ - cmp::Ordering, - fmt::Display, -}; +use std::{cmp::Ordering, fmt::Display}; use futures::TryFutureExt; use tokio::task::JoinHandle; -use tracing::{ - info, - instrument, -}; -use zbus_systemd::login1::{ - self, - ManagerProxy, -}; -use Kind::{ - DryHalt, - DryPoweroff, - DryReboot, - Halt, - Poweroff, - Reboot, -}; +use tracing::{info, instrument}; +use zbus_systemd::login1::{self, ManagerProxy}; +use Kind::{DryHalt, DryPoweroff, DryReboot, Halt, Poweroff, Reboot}; /// `ScheduledShutdown` represents the logind shutdown tuple both as an argument /// and return value for the `org.freedesktop.login1.Manager.ScheduledShutdown` @@ -57,10 +41,7 @@ impl ScheduledShutdown { Err(err) => return Err(err), }; - Ok(Self { - kind, - when, - }) + Ok(Self { kind, when }) } #[must_use] diff --git a/orb-supervisor/src/tasks/signup_started.rs b/orb-supervisor/src/tasks/signup_started.rs index f20f9eb7..764a6ddf 100644 --- a/orb-supervisor/src/tasks/signup_started.rs +++ b/orb-supervisor/src/tasks/signup_started.rs @@ -3,11 +3,7 @@ use tokio::task::JoinHandle; use tokio_stream::StreamExt as _; -use crate::{ - interfaces::Manager, - proxies::core::SignupProxy, - startup::Settings, -}; +use crate::{interfaces::Manager, proxies::core::SignupProxy, startup::Settings}; /// Spawns a task on the tokio runtime listening for `SignupStarted` D-Bus signals from Orb Core. /// diff --git a/orb-supervisor/src/tasks/update.rs b/orb-supervisor/src/tasks/update.rs index da035978..11578c4d 100644 --- a/orb-supervisor/src/tasks/update.rs +++ b/orb-supervisor/src/tasks/update.rs @@ -1,34 +1,15 @@ -use std::{ - convert::identity, - time::Duration, -}; +use std::{convert::identity, time::Duration}; -use futures::{ - StreamExt as _, - TryFutureExt as _, -}; +use futures::{StreamExt as _, TryFutureExt as _}; use tokio::{ task::JoinHandle, - time::{ - self, - error::Elapsed, - Instant, - }, -}; -use tracing::{ - debug, - info, - instrument, - warn, -}; -use zbus_systemd::systemd1::{ - self, - ManagerProxy, + time::{self, error::Elapsed, Instant}, }; +use tracing::{debug, info, instrument, warn}; +use zbus_systemd::systemd1::{self, ManagerProxy}; use crate::consts::{ - DURATION_TO_STOP_CORE_AFTER_LAST_SIGNUP, - WORLDCOIN_CORE_UNIT_NAME, + DURATION_TO_STOP_CORE_AFTER_LAST_SIGNUP, WORLDCOIN_CORE_UNIT_NAME, }; /// Calculates the instant that is 20 minutes after the last signup event. @@ -42,7 +23,9 @@ fn calculate_stop_deadline(last_signup_started_event: Instant) -> Instant { pub enum Error { #[error("reached timeout while waiting for worldcoin core service to be stopped")] Elapsed(#[from] Elapsed), - #[error("failed communicating over dbus; TODO: break this up into individual errors")] + #[error( + "failed communicating over dbus; TODO: break this up into individual errors" + )] Dbus(#[from] zbus::Error), } @@ -53,8 +36,9 @@ pub fn spawn_shutdown_worldcoin_core_timer( mut last_signup_started_event: tokio::sync::watch::Receiver, ) -> JoinHandle> { tokio::spawn(async move { - let trigger_stop = - time::sleep_until(calculate_stop_deadline(*last_signup_started_event.borrow())); + let trigger_stop = time::sleep_until(calculate_stop_deadline( + *last_signup_started_event.borrow(), + )); tokio::pin!(trigger_stop); loop { tokio::select!( @@ -76,7 +60,8 @@ pub fn spawn_shutdown_worldcoin_core_timer( ); } info!("deadline reached, shutting down worldcoin core service"); - let worldcoin_core_timeout_stop = get_worldcoin_core_timeout(proxy.clone()).await?; + let worldcoin_core_timeout_stop = + get_worldcoin_core_timeout(proxy.clone()).await?; stop_worldcoin_core(proxy.clone(), WORLDCOIN_CORE_UNIT_NAME, "replace").await?; tokio::time::timeout( worldcoin_core_timeout_stop, @@ -96,7 +81,9 @@ pub fn spawn_start_update_agent_after_core_shutdown_task( tokio::spawn(async move { match shutdown_task.await { Ok(Ok(())) => info!("worldcoin core shutdown task completed"), - Ok(Err(e)) => warn!(error = ?e, "worldcoin core shutdown task returned with error"), + Ok(Err(e)) => { + warn!(error = ?e, "worldcoin core shutdown task returned with error"); + } Err(e) => warn!(panic_msg = ?e, "worldcoin core shutdown task panicked"), } info!("calling `org.freedesktop.systemd1.Manager.StartUnit` to start update agent"); @@ -113,25 +100,17 @@ pub fn spawn_start_update_agent_after_core_shutdown_task( // )] // pub async fn spawn_start_update_agent_after_worldcoin_core_stopped_task( // proxy: ManagerProxy<'static>, -// ) -> JoinHandle> { -// tokio::spawn(async move { -// let timeout_duration = get_worldcoin_core_timeout(proxy.clone()).await?; -// match tokio::time::timeout( -// timeout_duration, -// has_worldcoin_core_stopped(proxy), -// ).await { -// Ok(_) => todo!("worldcoin core stopped"), -// Err(elapsed) => { -// info!(error = %elapsed, "did not " -// } -// }; -// Ok(()) -// }) +// ) -> JoinHandle> { tokio::spawn(async move { let timeout_duration = +// get_worldcoin_core_timeout(proxy.clone()).await?; match tokio::time::timeout( timeout_duration, +// has_worldcoin_core_stopped(proxy), ).await { Ok(_) => todo!("worldcoin core stopped"), +// Err(elapsed) => { info!(error = %elapsed, "did not " } }; Ok(()) }) // } #[instrument(skip_all, err, ret(Debug))] -async fn get_worldcoin_core_timeout(proxy: ManagerProxy<'static>) -> zbus::Result { +async fn get_worldcoin_core_timeout( + proxy: ManagerProxy<'static>, +) -> zbus::Result { let worldcoin_core_service = proxy .get_unit(WORLDCOIN_CORE_UNIT_NAME.to_string()) .and_then(|worldcoin_core_object| async { @@ -231,10 +210,7 @@ mod tests { use tokio::time::Instant; - use super::{ - calculate_stop_deadline, - DURATION_TO_STOP_CORE_AFTER_LAST_SIGNUP, - }; + use super::{calculate_stop_deadline, DURATION_TO_STOP_CORE_AFTER_LAST_SIGNUP}; #[test] fn deadline_of_old_signup_event_is_in_the_past() { diff --git a/orb-supervisor/src/telemetry.rs b/orb-supervisor/src/telemetry.rs index 264ea848..2eab1d61 100644 --- a/orb-supervisor/src/telemetry.rs +++ b/orb-supervisor/src/telemetry.rs @@ -1,11 +1,6 @@ use tap::prelude::*; use tracing::metadata::LevelFilter; -use tracing_subscriber::{ - filter, - fmt::MakeWriter, - prelude::*, - util::TryInitError, -}; +use tracing_subscriber::{filter, fmt::MakeWriter, prelude::*, util::TryInitError}; const SYSLOG_IDENTIFIER: &str = "worldcoin-supervisor"; @@ -26,10 +21,7 @@ impl Context for ExecContext { impl Context for TestContext {} mod private { - use super::{ - ExecContext, - TestContext, - }; + use super::{ExecContext, TestContext}; pub trait Sealed {} impl Sealed for ExecContext {} @@ -49,7 +41,10 @@ mod private { /// # Errors /// /// Returns [`tracing_subscriber.util.TryInitError`] -pub fn start(env_filter: LevelFilter, sink: W) -> Result<(), TryInitError> +pub fn start( + env_filter: LevelFilter, + sink: W, +) -> Result<(), TryInitError> where W: for<'a> MakeWriter<'a> + Send + Sync + 'static, { @@ -63,7 +58,9 @@ where if C::ENABLE_TELEMETRY && !is_tty_interactive() { journald = tracing_journald::layer() .tap_err(|err| { - eprintln!("failed connecting to journald socket; will write to stdout: {err}"); + eprintln!( + "failed connecting to journald socket; will write to stdout: {err}" + ); }) .map(|layer| layer.with_syslog_identifier(SYSLOG_IDENTIFIER.into())) .ok(); diff --git a/orb-supervisor/tests/it/helpers.rs b/orb-supervisor/tests/it/helpers.rs index c3ebeb59..c64cf233 100644 --- a/orb-supervisor/tests/it/helpers.rs +++ b/orb-supervisor/tests/it/helpers.rs @@ -1,28 +1,15 @@ use std::io; -use dbus_launch::{ - BusType, - Daemon, -}; +use dbus_launch::{BusType, Daemon}; use once_cell::sync::Lazy; use orb_supervisor::{ - startup::{ - Application, - Settings, - }, - telemetry::{ - self, - TestContext, - }, + startup::{Application, Settings}, + telemetry::{self, TestContext}, }; use tokio::task::JoinHandle; use tracing_subscriber::filter::LevelFilter; use zbus::{ - dbus_interface, - dbus_proxy, - fdo, - zvariant::OwnedObjectPath, - ProxyDefault, + dbus_interface, dbus_proxy, fdo, zvariant::OwnedObjectPath, ProxyDefault, SignalContext, }; @@ -47,10 +34,7 @@ pub fn launch_dbuses() -> JoinHandle> { tokio::task::spawn_blocking(|| { let session = launch_session_dbus()?; let system = launch_system_dbus()?; - Ok(DbusInstances { - session, - system, - }) + Ok(DbusInstances { session, system }) }) } @@ -99,9 +83,10 @@ pub async fn make_update_agent_proxy<'a>( settings: &'a Settings, dbus_instances: &DbusInstances, ) -> zbus::Result> { - let connection = zbus::ConnectionBuilder::address(dbus_instances.session.address())? - .build() - .await?; + let connection = + zbus::ConnectionBuilder::address(dbus_instances.session.address())? + .build() + .await?; SignupProxy::builder(&connection) .cache_properties(zbus::CacheProperties::No) .destination(settings.well_known_name.clone())? @@ -158,9 +143,13 @@ impl Manager { } #[dbus_interface(name = "StopUnit")] - async fn stop_unit(&self, name: String, _mode: String) -> fdo::Result { + async fn stop_unit( + &self, + name: String, + _mode: String, + ) -> fdo::Result { tracing::debug!(name, _mode, "StopUnit called"); - OwnedObjectPath::try_from(format!("/org/freedesktop/systemd1/job/1234")) + OwnedObjectPath::try_from("/org/freedesktop/systemd1/job/1234") .map_err(move |_| fdo::Error::UnknownObject(name)) } } @@ -195,7 +184,9 @@ impl CoreService { } } -pub async fn start_interfaces(dbus_instances: &DbusInstances) -> zbus::Result { +pub async fn start_interfaces( + dbus_instances: &DbusInstances, +) -> zbus::Result { let conn = zbus::ConnectionBuilder::address(dbus_instances.system.address())? .name(zbus_systemd::systemd1::ManagerProxy::DESTINATION)? .serve_at(zbus_systemd::systemd1::ManagerProxy::PATH, Manager)? diff --git a/orb-supervisor/tests/it/main.rs b/orb-supervisor/tests/it/main.rs index 252cd980..bedd7a6d 100644 --- a/orb-supervisor/tests/it/main.rs +++ b/orb-supervisor/tests/it/main.rs @@ -7,7 +7,8 @@ use tracing::error; pub mod helpers; #[tokio::test(start_paused = true)] -async fn supervisor_disallows_downloads_if_signup_started_received() -> eyre::Result<()> { +async fn supervisor_disallows_downloads_if_signup_started_received() -> eyre::Result<()> +{ let dbus_instances = helpers::launch_dbuses().await??; let settings = helpers::make_settings(&dbus_instances); @@ -15,26 +16,33 @@ async fn supervisor_disallows_downloads_if_signup_started_received() -> eyre::Re let application = helpers::spawn_supervisor_service(settings.clone()).await?; let _application_handle = tokio::spawn(application.run()); - let update_agent_proxy = helpers::make_update_agent_proxy(&settings, &dbus_instances).await?; + let update_agent_proxy = + helpers::make_update_agent_proxy(&settings, &dbus_instances).await?; - let downloads_allowed_initially = update_agent_proxy.background_downloads_allowed().await?; + let downloads_allowed_initially = + update_agent_proxy.background_downloads_allowed().await?; assert!(!downloads_allowed_initially); - tokio::time::advance(orb_supervisor::interfaces::manager::DEFAULT_DURATION_TO_ALLOW_DOWNLOADS) - .await; + tokio::time::advance( + orb_supervisor::interfaces::manager::DEFAULT_DURATION_TO_ALLOW_DOWNLOADS, + ) + .await; - let downloads_allowed_after_period = update_agent_proxy.background_downloads_allowed().await?; + let downloads_allowed_after_period = + update_agent_proxy.background_downloads_allowed().await?; assert!(downloads_allowed_after_period); helpers::start_signup_service_and_send_signal(&settings, &dbus_instances).await?; - let downloads_allowed_after_signal = update_agent_proxy.background_downloads_allowed().await?; + let downloads_allowed_after_signal = + update_agent_proxy.background_downloads_allowed().await?; assert!(!downloads_allowed_after_signal); Ok(()) } #[tokio::test(start_paused = true)] -async fn supervisor_stops_orb_core_when_update_permission_is_requested() -> eyre::Result<()> { +async fn supervisor_stops_orb_core_when_update_permission_is_requested( +) -> eyre::Result<()> { // FIXME: This is a hack to inhibit tokio auto-advance functionality in tests; // See https://github.com/tokio-rs/tokio/pull/5200 for more info and rework this // once the necessary functionality is exposed in an API. @@ -48,13 +56,18 @@ async fn supervisor_stops_orb_core_when_update_permission_is_requested() -> eyre let _application_handle = tokio::spawn(application.run()); - tokio::time::advance(orb_supervisor::consts::DURATION_TO_STOP_CORE_AFTER_LAST_SIGNUP).await; + tokio::time::advance( + orb_supervisor::consts::DURATION_TO_STOP_CORE_AFTER_LAST_SIGNUP, + ) + .await; - let update_agent_proxy = helpers::make_update_agent_proxy(&settings, &dbus_instances).await?; + let update_agent_proxy = + helpers::make_update_agent_proxy(&settings, &dbus_instances).await?; let system_conn = helpers::start_interfaces(&dbus_instances).await?; - let request_update_permission_task = - tokio::task::spawn(async move { update_agent_proxy.request_update_permission().await }); + let request_update_permission_task = tokio::task::spawn(async move { + update_agent_proxy.request_update_permission().await + }); // Switch active state to "inactive" after 300ms with forced synchronizatoin // through the oneshot channel because tasks are not scheduled immediately. let (active_task_tx, active_task_rx) = oneshot::channel(); diff --git a/rust-toolchain.toml b/rust-toolchain.toml new file mode 100644 index 00000000..357723dc --- /dev/null +++ b/rust-toolchain.toml @@ -0,0 +1,5 @@ +[toolchain] +channel = "1.73.0" +targets = ["aarch64-unknown-linux-gnu"] +profile = "minimal" +components = ["clippy", "llvm-tools-preview", "rustfmt", "rust-src", "rust-analyzer"] diff --git a/rustfmt.toml b/rustfmt.toml index 3293bdc7..3365f946 100644 --- a/rustfmt.toml +++ b/rustfmt.toml @@ -1,64 +1,2 @@ -max_width = 100 -hard_tabs = false -tab_spaces = 4 +max_width = 88 # From python's black newline_style = "Unix" -indent_style = "Block" -use_small_heuristics = "Default" -wrap_comments = true -format_code_in_doc_comments = true -comment_width = 100 -normalize_comments = true -normalize_doc_attributes = false -format_strings = true -format_macro_matchers = true -format_macro_bodies = true -empty_item_single_line = true -struct_lit_single_line = false -fn_single_line = false -where_single_line = false -imports_indent = "Block" -imports_layout = "Vertical" -imports_granularity = "Crate" -group_imports = "StdExternalCrate" -reorder_imports = true -reorder_modules = true -reorder_impl_items = true -type_punctuation_density = "Wide" -space_before_colon = false -space_after_colon = true -spaces_around_ranges = false -binop_separator = "Front" -remove_nested_parens = true -combine_control_expr = true -overflow_delimited_expr = false -struct_field_align_threshold = 0 -enum_discrim_align_threshold = 0 -match_arm_blocks = true -match_arm_leading_pipes = "Never" -force_multiline_blocks = false -fn_args_layout = "Tall" -brace_style = "SameLineWhere" -control_brace_style = "AlwaysSameLine" -trailing_semicolon = true -trailing_comma = "Vertical" -match_block_trailing_comma = false -blank_lines_upper_bound = 1 -blank_lines_lower_bound = 0 -edition = "2021" -version = "Two" -inline_attribute_width = 0 -merge_derives = true -use_try_shorthand = true -use_field_init_shorthand = true -force_explicit_abi = true -condense_wildcard_suffixes = true -color = "Auto" -unstable_features = true -disable_all_formatting = false -skip_children = false -hide_parse_errors = false -error_on_line_overflow = false -error_on_unformatted = false -ignore = [] -emit_mode = "Files" -make_backup = false From be0ab5c1333c023ba61b8b5d23bc5c2fb71dba5e Mon Sep 17 00:00:00 2001 From: Ryan Butler Date: Wed, 25 Oct 2023 14:35:20 -0400 Subject: [PATCH 23/38] Added wait_for_dbus_registration (#32) * Added wait_for_dbus_registration * Filter on name --- orb-supervisor/src/proxies/mod.rs | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/orb-supervisor/src/proxies/mod.rs b/orb-supervisor/src/proxies/mod.rs index 5a7ca06a..2c8fb4f9 100644 --- a/orb-supervisor/src/proxies/mod.rs +++ b/orb-supervisor/src/proxies/mod.rs @@ -1 +1,24 @@ +use eyre::{eyre, Result, WrapErr}; +use futures::StreamExt; +use zbus::fdo::DBusProxy; +use zbus::Connection; + pub mod core; + +/// Returns after `name` appears on dbus. +pub async fn wait_for_dbus_registration(conn: &Connection, name: &str) -> Result<()> { + let dbus = DBusProxy::new(conn) + .await + .wrap_err("failed to create org.freedesktop.DBus proxy object")?; + let mut name_changed = dbus + .receive_name_owner_changed() + .await + .wrap_err("failed to get NameOwnerChanged signal stream")?; + while let Some(c) = name_changed.next().await { + let a = c.args().wrap_err("failed to extract signal args")?; + if a.name == name { + return Ok(()); + } + } + Err(eyre!("NameOwnerChanged stream unexpectedly ended")) +} From 05d58b679943d6bf5f0d6a381abb22d24ffbc4db Mon Sep 17 00:00:00 2001 From: Ethan Wright Date: Fri, 1 Dec 2023 10:45:15 -0800 Subject: [PATCH 24/38] add hash pinning to github actions (#33) --- .github/workflows/general.yml | 12 +++++------ .github/workflows/release-binary.yml | 30 +++++++++++++-------------- .github/workflows/release-library.yml | 8 +++---- 3 files changed, 25 insertions(+), 25 deletions(-) diff --git a/.github/workflows/general.yml b/.github/workflows/general.yml index 92603dcc..504b3c36 100644 --- a/.github/workflows/general.yml +++ b/.github/workflows/general.yml @@ -8,7 +8,7 @@ on: pull_request: workflow_dispatch: -# Make sure CI fails on all warnings, including Clippy lints + # Make sure CI fails on all warnings, including Clippy lints env: RUSTFLAGS: "-Dwarnings" @@ -20,15 +20,15 @@ jobs: git config --global --add url."https://${{ secrets.GIT_HUB_TOKEN }}:x-oauth-basic@github.com/worldcoin/".insteadOf "ssh://git@github.com/worldcoin/" git config --global --add url."https://${{ secrets.GIT_HUB_TOKEN }}:x-oauth-basic@github.com/worldcoin/".insteadOf "git@github.com:worldcoin/" git config --global --add url."https://${{ secrets.GIT_HUB_TOKEN }}:x-oauth-basic@github.com/worldcoin/".insteadOf "https://github.com/worldcoin/" - - uses: actions/checkout@v3 + - uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # pin@v3 - name: Cache cargo dependencies - uses: Swatinem/rust-cache@v2 + uses: Swatinem/rust-cache@a95ba195448af2da9b00fb742d14ffaaf3c21f43 # pin@v2 - run: cargo test --all rustfmt: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # pin@v3 - run: cargo fmt --all -- --check clippy: @@ -39,7 +39,7 @@ jobs: git config --global url."https://${{ secrets.GIT_HUB_TOKEN }}:x-oauth-basic@github.com/worldcoin/".insteadOf "ssh://git@github.com/worldcoin/" git config --global url."https://${{ secrets.GIT_HUB_TOKEN }}:x-oauth-basic@github.com/worldcoin/".insteadOf "git@github.com:worldcoin/" git config --global url."https://${{ secrets.GIT_HUB_TOKEN }}:x-oauth-basic@github.com/worldcoin/".insteadOf "https://github.com/worldcoin/" - - uses: actions/checkout@v3 + - uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # pin@v3 - name: Cache cargo dependencies - uses: Swatinem/rust-cache@v2 + uses: Swatinem/rust-cache@a95ba195448af2da9b00fb742d14ffaaf3c21f43 # pin@v2 - run: cargo clippy --all --all-features --all-targets --no-deps diff --git a/.github/workflows/release-binary.yml b/.github/workflows/release-binary.yml index 9c2ff9bd..8f1da88f 100644 --- a/.github/workflows/release-binary.yml +++ b/.github/workflows/release-binary.yml @@ -11,21 +11,21 @@ jobs: runs-on: ubuntu-latest steps: - run: | - git config --global --add url."https://${{ secrets.GIT_HUB_TOKEN }}:x-oauth-basic@github.com/worldcoin/".insteadOf "ssh://git@github.com/worldcoin/" - git config --global --add url."https://${{ secrets.GIT_HUB_TOKEN }}:x-oauth-basic@github.com/worldcoin/".insteadOf "git@github.com:worldcoin/" - git config --global --add url."https://${{ secrets.GIT_HUB_TOKEN }}:x-oauth-basic@github.com/worldcoin/".insteadOf "https://github.com/worldcoin/" - - uses: actions/checkout@v3 + git config --global --add url."https://${{ secrets.GIT_HUB_TOKEN }}:x-oauth-basic@github.com/worldcoin/".insteadOf "ssh://git@github.com/worldcoin/" + git config --global --add url."https://${{ secrets.GIT_HUB_TOKEN }}:x-oauth-basic@github.com/worldcoin/".insteadOf "git@github.com:worldcoin/" + git config --global --add url."https://${{ secrets.GIT_HUB_TOKEN }}:x-oauth-basic@github.com/worldcoin/".insteadOf "https://github.com/worldcoin/" + - uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # pin@v3 - name: Install zig - uses: goto-bus-stop/setup-zig@v1 + uses: goto-bus-stop/setup-zig@222d316fd35ce56a4141fe4a869e1aeefc7f3590 # pin@v1 with: version: 0.9.1 - name: Cache cargo dependencies - uses: Swatinem/rust-cache@v2 + uses: Swatinem/rust-cache@a95ba195448af2da9b00fb742d14ffaaf3c21f43 # pin@v2 - run: cargo install cargo-zigbuild - name: Build orb-supervisor binary run: cargo zigbuild --release --target aarch64-unknown-linux-gnu.2.27 -p orb-supervisor - name: Cache orb-supervisor binary - uses: actions/cache@v3 + uses: actions/cache@704facf57e6136b1bc63b828d79edcd491f0ee84 # pin@v3 with: path: target/aarch64-unknown-linux-gnu/release/orb-supervisor key: ${{ github.run_id }}-${{ github.run_number }}-${{ github.run_attempt }}-orb-supervisor-bin @@ -36,12 +36,12 @@ jobs: needs: build runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # pin@v3 - name: Get tag id: tag - uses: dawidd6/action-get-tag@v1 + uses: dawidd6/action-get-tag@727a6f0a561be04e09013531e73a3983a65e3479 # pin@v1 - name: Retrieve cache - uses: actions/cache@v3 + uses: actions/cache@704facf57e6136b1bc63b828d79edcd491f0ee84 # pin@v3 with: path: target/aarch64-unknown-linux-gnu/release/orb-supervisor key: ${{ github.run_id }}-${{ github.run_number }}-${{ github.run_attempt }}-orb-supervisor-bin @@ -53,7 +53,7 @@ jobs: shasum -a 256 ${{ steps.tag.outputs.tag }}.tar.gz > ${{ steps.tag.outputs.tag }}.tar.gz.sha256 cd - - name: Install changelog parser - uses: taiki-e/install-action@parse-changelog + uses: taiki-e/install-action@f863cdaef3a8e79111b7a8c74d466b89d31d2fdc # pin@parse-changelog - name: Read changelog contents id: changelog shell: bash @@ -65,7 +65,7 @@ jobs: parse-changelog orb-supervisor/CHANGELOG.md >> $GITHUB_ENV echo 'EOF' >> $GITHUB_ENV - name: Make a github release for the binary - uses: softprops/action-gh-release@v1 + uses: softprops/action-gh-release@de2c0eb89ae2a093876385947365aca7b0e5f844 # pin@v1 with: files: | target/aarch64-unknown-linux-gnu/release/orb-supervisor*.tar.gz @@ -78,11 +78,11 @@ jobs: # only release on pushes on main branch if: ${{ github.ref_name == 'main' }} runs-on: ubuntu-22.04 - needs: [build] + needs: [ build ] steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # pin@v3 - name: Retrieve cache - uses: actions/cache@v3 + uses: actions/cache@704facf57e6136b1bc63b828d79edcd491f0ee84 # pin@v3 with: path: target/aarch64-unknown-linux-gnu/release/orb-supervisor key: ${{ github.run_id }}-${{ github.run_number }}-${{ github.run_attempt }}-orb-supervisor-bin diff --git a/.github/workflows/release-library.yml b/.github/workflows/release-library.yml index c7dec1ad..dd136309 100644 --- a/.github/workflows/release-library.yml +++ b/.github/workflows/release-library.yml @@ -8,17 +8,17 @@ jobs: release: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # pin@v3 - name: Get tag id: tag - uses: dawidd6/action-get-tag@v1 + uses: dawidd6/action-get-tag@727a6f0a561be04e09013531e73a3983a65e3479 # pin@v1 - name: Read tag prefix id: prefix shell: bash run: | [[ ${{ steps.tag.outputs.tag }} =~ ^(orb-supervisor-[a-z]+).* ]] && echo "::set-output name=prefix::${BASH_REMATCH[1]}" - name: Install changelog parser - uses: taiki-e/install-action@parse-changelog + uses: taiki-e/install-action@f863cdaef3a8e79111b7a8c74d466b89d31d2fdc # pin@parse-changelog - name: Read changelog contents id: changelog shell: bash @@ -30,7 +30,7 @@ jobs: parse-changelog ${{ steps.prefix.outputs.prefix }}/CHANGELOG.md >> $GITHUB_ENV echo 'EOF' >> $GITHUB_ENV - name: Make a github release for the library - uses: softprops/action-gh-release@v1 + uses: softprops/action-gh-release@de2c0eb89ae2a093876385947365aca7b0e5f844 # pin@v1 with: prerelease: ${{ contains(github.ref, 'alpha') || contains(github.ref, 'beta') || contains(github.ref, 'rc') }} name: ${{ steps.prefix.outputs.prefix }} ${{ env.TITLE }} From b740e43245d111f6e193020cc5df34f79e6969ec Mon Sep 17 00:00:00 2001 From: Galileo Daras Date: Tue, 30 Jan 2024 16:56:13 +0100 Subject: [PATCH 25/38] Fix initial check for whether OTA downloads allowed (#35) When the orb first booted, the downloads would throttle for the first DEFAULT_DURATION_TO_ALLOW_DOWNLOADS duration, since we would fill the queue with an `Instant::now()`. The behavior is changed by subtracting the default duration from the now to ensure the elapsed time is correct on first check. --- orb-supervisor/src/interfaces/manager.rs | 34 ++++++++++++++++++++---- orb-supervisor/tests/it/main.rs | 16 ++++++----- 2 files changed, 39 insertions(+), 11 deletions(-) diff --git a/orb-supervisor/src/interfaces/manager.rs b/orb-supervisor/src/interfaces/manager.rs index ad34cd71..1a61402e 100644 --- a/orb-supervisor/src/interfaces/manager.rs +++ b/orb-supervisor/src/interfaces/manager.rs @@ -47,9 +47,17 @@ impl Manager { /// Constructs a new `Manager` instance. #[allow(clippy::must_use_candidate)] pub fn new() -> Self { - let (tx, _rx) = watch::channel(Instant::now()); + let duration_to_allow_downloads = DEFAULT_DURATION_TO_ALLOW_DOWNLOADS; + + // We subtract the DEFAULT_DURATION_TO_ALLOW_DOWNLOADS from the current time + // so that the first check on boot doesn't throttle + let (tx, _rx) = watch::channel( + Instant::now() + .checked_sub(duration_to_allow_downloads) + .unwrap_or(Instant::now()), + ); Self { - duration_to_allow_downloads: DEFAULT_DURATION_TO_ALLOW_DOWNLOADS, + duration_to_allow_downloads, last_signup_event: tx, system_connection: None, } @@ -235,19 +243,32 @@ mod tests { .is_some()); } + #[test] + fn downloads_are_allowed_on_startup() { + let manager = Manager::new() + .duration_to_allow_downloads(DEFAULT_DURATION_TO_ALLOW_DOWNLOADS); + + assert!(manager.are_downloads_allowed()); + } + #[tokio::test(start_paused = true)] async fn downloads_are_disallowed_if_last_signup_event_is_too_recent() { - let manager = Manager::new() + let mut manager = Manager::new() .duration_to_allow_downloads(DEFAULT_DURATION_TO_ALLOW_DOWNLOADS); - tokio::time::advance(DEFAULT_DURATION_TO_ALLOW_DOWNLOADS / 2).await; + manager.reset_last_signup_event(); + + tokio::time::advance(DEFAULT_DURATION_TO_ALLOW_DOWNLOADS / 2).await; assert!(!manager.are_downloads_allowed()); } #[tokio::test(start_paused = true)] async fn downloads_are_allowed_if_last_signup_event_is_old_enough() { - let manager = Manager::new() + let mut manager = Manager::new() .duration_to_allow_downloads(DEFAULT_DURATION_TO_ALLOW_DOWNLOADS); + + manager.reset_last_signup_event(); + tokio::time::advance(DEFAULT_DURATION_TO_ALLOW_DOWNLOADS * 2).await; assert!(manager.are_downloads_allowed()); } @@ -256,8 +277,11 @@ mod tests { async fn downloads_become_disallowed_after_reset() { let mut manager = Manager::new() .duration_to_allow_downloads(DEFAULT_DURATION_TO_ALLOW_DOWNLOADS); + manager.reset_last_signup_event(); + tokio::time::advance(DEFAULT_DURATION_TO_ALLOW_DOWNLOADS * 2).await; assert!(manager.are_downloads_allowed()); + manager.reset_last_signup_event(); assert!(!manager.are_downloads_allowed()); } diff --git a/orb-supervisor/tests/it/main.rs b/orb-supervisor/tests/it/main.rs index bedd7a6d..459e4a87 100644 --- a/orb-supervisor/tests/it/main.rs +++ b/orb-supervisor/tests/it/main.rs @@ -19,10 +19,19 @@ async fn supervisor_disallows_downloads_if_signup_started_received() -> eyre::Re let update_agent_proxy = helpers::make_update_agent_proxy(&settings, &dbus_instances).await?; + // We want to ensure that downloads are allowed when the manager begins let downloads_allowed_initially = update_agent_proxy.background_downloads_allowed().await?; - assert!(!downloads_allowed_initially); + assert!(downloads_allowed_initially); + // Now we check thaht after a signup, downloads are not allowed + helpers::start_signup_service_and_send_signal(&settings, &dbus_instances).await?; + let downloads_allowed_after_signal = + update_agent_proxy.background_downloads_allowed().await?; + assert!(!downloads_allowed_after_signal); + + // Then wait for the timeout duration to pass and ensure that the downloads + // are once again allowed tokio::time::advance( orb_supervisor::interfaces::manager::DEFAULT_DURATION_TO_ALLOW_DOWNLOADS, ) @@ -32,11 +41,6 @@ async fn supervisor_disallows_downloads_if_signup_started_received() -> eyre::Re update_agent_proxy.background_downloads_allowed().await?; assert!(downloads_allowed_after_period); - helpers::start_signup_service_and_send_signal(&settings, &dbus_instances).await?; - let downloads_allowed_after_signal = - update_agent_proxy.background_downloads_allowed().await?; - assert!(!downloads_allowed_after_signal); - Ok(()) } From edcc10a0828055e2dfbfe12132b8307e6e2ea531 Mon Sep 17 00:00:00 2001 From: Galileo Daras Date: Tue, 30 Jan 2024 17:05:03 +0100 Subject: [PATCH 26/38] Prepare orb-supervisor 0.4.1 (#36) --- orb-supervisor/CHANGELOG.md | 12 ++++++++++++ orb-supervisor/Cargo.toml | 2 +- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/orb-supervisor/CHANGELOG.md b/orb-supervisor/CHANGELOG.md index eeea8c47..0593f0fd 100644 --- a/orb-supervisor/CHANGELOG.md +++ b/orb-supervisor/CHANGELOG.md @@ -1,5 +1,17 @@ # Changelog +## 0.4.1 + +### Added + ++ Private proxy for getting notified of service registration `org.worldcoin.OrbSupervisor1` ++ Version pinning for GitHub actions + +### Changed + ++ Upon booting `orb-supervisor` permits `update-agent` to begin downloading + immediately without throttling, until a signup starts + ## 0.4.0 ### Added diff --git a/orb-supervisor/Cargo.toml b/orb-supervisor/Cargo.toml index 7635ff44..80a92a43 100644 --- a/orb-supervisor/Cargo.toml +++ b/orb-supervisor/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "orb-supervisor" -version = "0.4.0" +version = "0.4.1" edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html From 404d35ec630e4778034adf65dc4b63a7c1675e9b Mon Sep 17 00:00:00 2001 From: Galileo Daras Date: Thu, 21 Mar 2024 00:09:59 +0100 Subject: [PATCH 27/38] Change download resumption 60->20 minutes (#38) --- orb-supervisor/src/interfaces/manager.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/orb-supervisor/src/interfaces/manager.rs b/orb-supervisor/src/interfaces/manager.rs index 1a61402e..ed6dc786 100644 --- a/orb-supervisor/src/interfaces/manager.rs +++ b/orb-supervisor/src/interfaces/manager.rs @@ -15,7 +15,7 @@ use crate::tasks; /// The duration of time since the last "start signup" event that has to have passed /// before the update agent is permitted to start a download. -pub const DEFAULT_DURATION_TO_ALLOW_DOWNLOADS: Duration = Duration::from_secs(3600); +pub const DEFAULT_DURATION_TO_ALLOW_DOWNLOADS: Duration = Duration::from_secs(20 * 60); pub const BACKGROUND_DOWNLOADS_ALLOWED_PROPERTY_NAME: &str = "BackgroundDownloadsAllowed"; From e9fd593b00515cda30662b1ebd535ee73b346233 Mon Sep 17 00:00:00 2001 From: Ryan Butler Date: Mon, 3 Jun 2024 13:44:49 -0400 Subject: [PATCH 28/38] fix unused result, use color-eyre (#46) --- Cargo.lock | 111 +++++++++++++++++++++++++++-- orb-supervisor/Cargo.toml | 2 +- orb-supervisor/src/main.rs | 5 +- orb-supervisor/src/proxies/mod.rs | 2 +- orb-supervisor/src/startup.rs | 17 ++--- orb-supervisor/tests/it/helpers.rs | 4 +- orb-supervisor/tests/it/main.rs | 6 +- 7 files changed, 127 insertions(+), 20 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 0ad4692e..98c8c96f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2,6 +2,21 @@ # It is not intended for manual editing. version = 3 +[[package]] +name = "addr2line" +version = "0.19.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a76fd60b23679b7d19bd066031410fb7e458ccc5e958eb5c325888ce4baedc97" +dependencies = [ + "gimli", +] + +[[package]] +name = "adler" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" + [[package]] name = "aho-corasick" version = "0.7.20" @@ -100,6 +115,21 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" +[[package]] +name = "backtrace" +version = "0.3.67" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "233d376d6d185f2a3093e58f283f60f880315b6c60075b01f36b3b85154564ca" +dependencies = [ + "addr2line", + "cc", + "cfg-if", + "libc", + "miniz_oxide", + "object", + "rustc-demangle", +] + [[package]] name = "bitflags" version = "1.3.2" @@ -139,6 +169,33 @@ version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" +[[package]] +name = "color-eyre" +version = "0.6.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "55146f5e46f237f7423d74111267d4597b59b0dad0ffaf7303bce9945d843ad5" +dependencies = [ + "backtrace", + "color-spantrace", + "eyre", + "indenter", + "once_cell", + "owo-colors", + "tracing-error", +] + +[[package]] +name = "color-spantrace" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cd6be1b2a7e382e2b98b43b2adcca6bb0e465af0bdd38123873ae61eb17a72c2" +dependencies = [ + "once_cell", + "owo-colors", + "tracing-core", + "tracing-error", +] + [[package]] name = "concurrent-queue" version = "2.1.0" @@ -398,6 +455,12 @@ dependencies = [ "wasi", ] +[[package]] +name = "gimli" +version = "0.27.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6c80984affa11d98d1b88b66ac8853f143217b399d3c74116778ff8fdb4ed2e" + [[package]] name = "hashbrown" version = "0.12.3" @@ -510,6 +573,15 @@ dependencies = [ "autocfg", ] +[[package]] +name = "miniz_oxide" +version = "0.6.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b275950c28b37e794e8c55d88aeb5e139d0ce23fdbbeda68f8d7174abdf9e8fa" +dependencies = [ + "adler", +] + [[package]] name = "mio" version = "0.8.5" @@ -565,18 +637,27 @@ dependencies = [ "libc", ] +[[package]] +name = "object" +version = "0.30.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "03b4680b86d9cfafba8fc491dc9b6df26b68cf40e9e6cd73909194759a63c385" +dependencies = [ + "memchr", +] + [[package]] name = "once_cell" -version = "1.17.0" +version = "1.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6f61fba1741ea2b3d6a1e3178721804bb716a68a6aeba1149b5d52e3d464ea66" +checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" [[package]] name = "orb-supervisor" -version = "0.4.0" +version = "0.4.1" dependencies = [ + "color-eyre", "dbus-launch", - "eyre", "futures", "libc", "listenfd", @@ -608,6 +689,12 @@ version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b15813163c1d831bf4a13c3610c05c0d03b39feb07f7e09fa234dac9b15aaf39" +[[package]] +name = "owo-colors" +version = "3.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c1b04fb49957986fdce4d6ee7a65027d55d4b6d2265e5848bbb507b58ccfdb6f" + [[package]] name = "parking" version = "2.0.0" @@ -782,6 +869,12 @@ dependencies = [ "winapi", ] +[[package]] +name = "rustc-demangle" +version = "0.1.24" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "719b953e2095829ee67db738b3bfa9fa368c94900df327b3f07fe6e794d2fe1f" + [[package]] name = "scopeguard" version = "1.1.0" @@ -1021,6 +1114,16 @@ dependencies = [ "valuable", ] +[[package]] +name = "tracing-error" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d686ec1c0f384b1277f097b2f279a2ecc11afe8c133c1aabf036a27cb4cd206e" +dependencies = [ + "tracing", + "tracing-subscriber", +] + [[package]] name = "tracing-journald" version = "0.3.0" diff --git a/orb-supervisor/Cargo.toml b/orb-supervisor/Cargo.toml index 80a92a43..109bfd46 100644 --- a/orb-supervisor/Cargo.toml +++ b/orb-supervisor/Cargo.toml @@ -6,7 +6,7 @@ edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -eyre = "0.6.8" +color-eyre = "0.6.3" libc = "0.2.135" listenfd = "1.0.0" tokio = { version = "1.21.2", features = ["macros", "net", "rt-multi-thread"] } diff --git a/orb-supervisor/src/main.rs b/orb-supervisor/src/main.rs index d3fafbda..8a2e2c1d 100644 --- a/orb-supervisor/src/main.rs +++ b/orb-supervisor/src/main.rs @@ -1,4 +1,4 @@ -use eyre::WrapErr as _; +use color_eyre::eyre::WrapErr as _; use orb_supervisor::{ startup::{Application, Settings}, telemetry::{self, ExecContext}, @@ -7,7 +7,8 @@ use tracing::debug; use tracing_subscriber::filter::LevelFilter; #[tokio::main] -async fn main() -> eyre::Result<()> { +async fn main() -> color_eyre::Result<()> { + color_eyre::install()?; telemetry::start::(LevelFilter::INFO, std::io::stdout) .wrap_err("failed to initialize tracing; bailing")?; debug!("initialized telemetry"); diff --git a/orb-supervisor/src/proxies/mod.rs b/orb-supervisor/src/proxies/mod.rs index 2c8fb4f9..f9dcffa7 100644 --- a/orb-supervisor/src/proxies/mod.rs +++ b/orb-supervisor/src/proxies/mod.rs @@ -1,4 +1,4 @@ -use eyre::{eyre, Result, WrapErr}; +use color_eyre::eyre::{eyre, Result, WrapErr as _}; use futures::StreamExt; use zbus::fdo::DBusProxy; use zbus::Connection; diff --git a/orb-supervisor/src/startup.rs b/orb-supervisor/src/startup.rs index a72daf06..17066cf9 100644 --- a/orb-supervisor/src/startup.rs +++ b/orb-supervisor/src/startup.rs @@ -1,4 +1,5 @@ -use futures::future::TryFutureExt as _; +use color_eyre::eyre::WrapErr as _; +use futures::{future::TryFutureExt as _, FutureExt as _}; use tracing::debug; use zbus::{Connection, ConnectionBuilder}; @@ -131,17 +132,17 @@ impl Application { } /// Runs `Application` by spawning its constituent tasks. - /// - /// # Errors - /// - /// + `[Error::Zbus]`, if an error when spawning the task listening to Orb signups. See - /// [`tasks::spawn_signup_started_task`] for more information. - pub async fn run(self) -> Result<(), Error> { + pub async fn run(self) -> color_eyre::Result<()> { let signup_started_task = tasks::spawn_signup_started_task(&self.settings, &self.session_connection) .await?; - let (..) = tokio::join!(signup_started_task); + let ((),) = tokio::try_join!( + // All tasks are joined here + signup_started_task.map(|e| e + .wrap_err("signup_started task aborted unexpectedly")? + .wrap_err("signup_started task exited with error")), + )?; Ok(()) } } diff --git a/orb-supervisor/tests/it/helpers.rs b/orb-supervisor/tests/it/helpers.rs index c64cf233..957fda88 100644 --- a/orb-supervisor/tests/it/helpers.rs +++ b/orb-supervisor/tests/it/helpers.rs @@ -58,7 +58,9 @@ pub fn make_settings(dbus_instances: &DbusInstances) -> Settings { } } -pub async fn spawn_supervisor_service(settings: Settings) -> eyre::Result { +pub async fn spawn_supervisor_service( + settings: Settings, +) -> color_eyre::Result { Lazy::force(&TRACING); let application = Application::build(settings.clone()).await?; Ok(application) diff --git a/orb-supervisor/tests/it/main.rs b/orb-supervisor/tests/it/main.rs index 459e4a87..d83b70a5 100644 --- a/orb-supervisor/tests/it/main.rs +++ b/orb-supervisor/tests/it/main.rs @@ -7,8 +7,8 @@ use tracing::error; pub mod helpers; #[tokio::test(start_paused = true)] -async fn supervisor_disallows_downloads_if_signup_started_received() -> eyre::Result<()> -{ +async fn supervisor_disallows_downloads_if_signup_started_received( +) -> color_eyre::Result<()> { let dbus_instances = helpers::launch_dbuses().await??; let settings = helpers::make_settings(&dbus_instances); @@ -46,7 +46,7 @@ async fn supervisor_disallows_downloads_if_signup_started_received() -> eyre::Re #[tokio::test(start_paused = true)] async fn supervisor_stops_orb_core_when_update_permission_is_requested( -) -> eyre::Result<()> { +) -> color_eyre::Result<()> { // FIXME: This is a hack to inhibit tokio auto-advance functionality in tests; // See https://github.com/tokio-rs/tokio/pull/5200 for more info and rework this // once the necessary functionality is exposed in an API. From 29b7bf74434bb1632f0b260ef2c636a39a3a1f1b Mon Sep 17 00:00:00 2001 From: Ryan Butler Date: Tue, 4 Jun 2024 12:42:15 -0400 Subject: [PATCH 29/38] gitignore direnv things (#44) --- .gitignore | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.gitignore b/.gitignore index ea8c4bf7..1cbd80d9 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,3 @@ /target +/.direnv +/.envrc From e28d360669ce18f203fba9aa95139baecfca4ee1 Mon Sep 17 00:00:00 2001 From: Ryan Butler Date: Tue, 4 Jun 2024 12:42:46 -0400 Subject: [PATCH 30/38] update to rust 1.78.0 (#40) --- orb-supervisor/Cargo.toml | 2 -- rust-toolchain.toml | 2 +- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/orb-supervisor/Cargo.toml b/orb-supervisor/Cargo.toml index 109bfd46..e4924b11 100644 --- a/orb-supervisor/Cargo.toml +++ b/orb-supervisor/Cargo.toml @@ -3,8 +3,6 @@ name = "orb-supervisor" version = "0.4.1" edition = "2021" -# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html - [dependencies] color-eyre = "0.6.3" libc = "0.2.135" diff --git a/rust-toolchain.toml b/rust-toolchain.toml index 357723dc..0e4f5ad2 100644 --- a/rust-toolchain.toml +++ b/rust-toolchain.toml @@ -1,5 +1,5 @@ [toolchain] -channel = "1.73.0" +channel = "1.78.0" targets = ["aarch64-unknown-linux-gnu"] profile = "minimal" components = ["clippy", "llvm-tools-preview", "rustfmt", "rust-src", "rust-analyzer"] From 2071730dcffcfbad287ea9dab6e5cd26c26dcabd Mon Sep 17 00:00:00 2001 From: Ryan Butler Date: Tue, 4 Jun 2024 12:43:24 -0400 Subject: [PATCH 31/38] ci: remove unecessary git config (#41) --- .github/workflows/general.yml | 4 ---- .github/workflows/release-binary.yml | 2 -- 2 files changed, 6 deletions(-) diff --git a/.github/workflows/general.yml b/.github/workflows/general.yml index 504b3c36..8880344a 100644 --- a/.github/workflows/general.yml +++ b/.github/workflows/general.yml @@ -17,8 +17,6 @@ jobs: runs-on: ubuntu-latest steps: - run: | - git config --global --add url."https://${{ secrets.GIT_HUB_TOKEN }}:x-oauth-basic@github.com/worldcoin/".insteadOf "ssh://git@github.com/worldcoin/" - git config --global --add url."https://${{ secrets.GIT_HUB_TOKEN }}:x-oauth-basic@github.com/worldcoin/".insteadOf "git@github.com:worldcoin/" git config --global --add url."https://${{ secrets.GIT_HUB_TOKEN }}:x-oauth-basic@github.com/worldcoin/".insteadOf "https://github.com/worldcoin/" - uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # pin@v3 - name: Cache cargo dependencies @@ -36,8 +34,6 @@ jobs: runs-on: ubuntu-latest steps: - run: | - git config --global url."https://${{ secrets.GIT_HUB_TOKEN }}:x-oauth-basic@github.com/worldcoin/".insteadOf "ssh://git@github.com/worldcoin/" - git config --global url."https://${{ secrets.GIT_HUB_TOKEN }}:x-oauth-basic@github.com/worldcoin/".insteadOf "git@github.com:worldcoin/" git config --global url."https://${{ secrets.GIT_HUB_TOKEN }}:x-oauth-basic@github.com/worldcoin/".insteadOf "https://github.com/worldcoin/" - uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # pin@v3 - name: Cache cargo dependencies diff --git a/.github/workflows/release-binary.yml b/.github/workflows/release-binary.yml index 8f1da88f..353d0dd3 100644 --- a/.github/workflows/release-binary.yml +++ b/.github/workflows/release-binary.yml @@ -11,8 +11,6 @@ jobs: runs-on: ubuntu-latest steps: - run: | - git config --global --add url."https://${{ secrets.GIT_HUB_TOKEN }}:x-oauth-basic@github.com/worldcoin/".insteadOf "ssh://git@github.com/worldcoin/" - git config --global --add url."https://${{ secrets.GIT_HUB_TOKEN }}:x-oauth-basic@github.com/worldcoin/".insteadOf "git@github.com:worldcoin/" git config --global --add url."https://${{ secrets.GIT_HUB_TOKEN }}:x-oauth-basic@github.com/worldcoin/".insteadOf "https://github.com/worldcoin/" - uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # pin@v3 - name: Install zig From 6c7096bf11f6f8ebac2048311c05f599bc9c818d Mon Sep 17 00:00:00 2001 From: Ryan Butler Date: Tue, 4 Jun 2024 12:53:19 -0400 Subject: [PATCH 32/38] rework error handling for shutdown and stop spawning task (#45) --- orb-supervisor/src/interfaces/manager.rs | 66 +++++----- orb-supervisor/src/lib.rs | 4 +- orb-supervisor/src/shutdown.rs | 154 +++++++++++++++++++++++ orb-supervisor/src/tasks/mod.rs | 1 - orb-supervisor/src/tasks/shutdown.rs | 150 ---------------------- 5 files changed, 189 insertions(+), 186 deletions(-) create mode 100644 orb-supervisor/src/shutdown.rs delete mode 100644 orb-supervisor/src/tasks/shutdown.rs diff --git a/orb-supervisor/src/interfaces/manager.rs b/orb-supervisor/src/interfaces/manager.rs index ed6dc786..1705a02b 100644 --- a/orb-supervisor/src/interfaces/manager.rs +++ b/orb-supervisor/src/interfaces/manager.rs @@ -8,10 +8,12 @@ use tokio::{ time::{Duration, Instant}, }; use tracing::{debug, info, instrument, warn}; -use zbus::{dbus_interface, Connection, DBusError, SignalContext}; +use zbus::{ + dbus_interface, fdo::Error as FdoError, Connection, DBusError, SignalContext, +}; use zbus_systemd::{login1, systemd1}; -use crate::tasks; +use crate::shutdown::UnknownShutdownKind; /// The duration of time since the last "start signup" event that has to have passed /// before the update agent is permitted to start a download. @@ -139,10 +141,11 @@ impl Manager { .expect("manager must be conntected to system dbus"); let systemd_proxy = systemd1::ManagerProxy::new(conn).await?; // Spawn task to shut down worldcoin core - let mut shutdown_core_task = tasks::update::spawn_shutdown_worldcoin_core_timer( - systemd_proxy.clone(), - self.last_signup_event.subscribe(), - ); + let mut shutdown_core_task = + crate::tasks::update::spawn_shutdown_worldcoin_core_timer( + systemd_proxy.clone(), + self.last_signup_event.subscribe(), + ); // Wait for one second to see if worldcoin core is already shut down match tokio::time::timeout(Duration::from_secs(1), &mut shutdown_core_task) .await @@ -168,7 +171,7 @@ impl Manager { Err(elapsed) => { debug!(%elapsed, "shutting down worldcoin core takes longer than 1s; running in background and blocking update by returning a method error"); let _deteched_shutdown_task = - tasks::update::spawn_start_update_agent_after_core_shutdown_task( + crate::tasks::update::spawn_start_update_agent_after_core_shutdown_task( systemd_proxy, shutdown_core_task, ); @@ -185,38 +188,33 @@ impl Manager { name = "org.worldcoin.OrbSupervisor1.Manager.ScheduleShutdown", skip_all )] - async fn schedule_shutdown(&self, kind: &str, when: u64) -> Result<(), BusError> { + async fn schedule_shutdown(&self, kind: &str, when: u64) -> zbus::fdo::Result<()> { debug!("ScheduleShutdown was called"); - let shutdown = - tasks::shutdown::ScheduledShutdown::try_from_dbus((kind.to_string(), when)) - .map_err(|err| { - BusError::InvalidArgs(format!( - "schedule shutdown failed: `{err:?}`" - )) - })?; + let shutdown_request = + crate::shutdown::ScheduledShutdown::try_from_dbus((kind.to_owned(), when)) + .map_err(|err: UnknownShutdownKind| { + FdoError::InvalidArgs(format!("{err:?}`")) + })? + .ok_or(FdoError::InvalidArgs("empty string".to_owned()))?; let conn = self .system_connection .as_ref() - .expect("manager must be conntected to system dbus"); + .expect("manager must be connected to the system dbus"); let logind_proxy = login1::ManagerProxy::new(conn).await?; - let schedule_shutdown_task = - tasks::shutdown::spawn_logind_schedule_shutdown_task( - logind_proxy, - shutdown.clone(), - ); - match schedule_shutdown_task.await { - Ok(Ok(())) => info!("scheduled shutdown `{shutdown:?}`"), - Ok(Err(err @ tasks::shutdown::Error::Defer(_))) => warn!( - error = ?err, - "skipped shutdown `{shutdown:?}`" - ), - Ok(Err(err)) => warn!( - error = ?err, - "failed to schedule shutdown `{shutdown:?}` with error `{err:?}`" - ), - Err(err) => warn!( - panic_msg = ?err, - "logind schedule shutdown task panicked trying;", + + let preemption_info = + crate::shutdown::schedule_shutdown(logind_proxy, shutdown_request.clone()) + .await?; + use crate::shutdown::PreemptionInfo as P; + match preemption_info { + P::NoExistingShutdown => { + info!("scheduled shutdown {shutdown_request:?}"); + } + P::PreemptedExistingShutdown(s) => { + warn!("preempting existing lower priority shutdown {s:?} with new shutdown {shutdown_request:?}"); + } + P::KeptExistingShutdown(s) => warn!( + "skipped scheduling shutdown {shutdown_request:?} due to existing higher priority shutdown {s:?}" ), }; Ok(()) diff --git a/orb-supervisor/src/lib.rs b/orb-supervisor/src/lib.rs index ba538dd4..59209814 100644 --- a/orb-supervisor/src/lib.rs +++ b/orb-supervisor/src/lib.rs @@ -2,12 +2,14 @@ #![allow( clippy::missing_errors_doc, clippy::module_name_repetitions, - clippy::ignored_unit_patterns + clippy::ignored_unit_patterns, + clippy::items_after_statements )] pub mod consts; pub mod interfaces; pub mod proxies; +pub mod shutdown; pub mod startup; pub mod tasks; pub mod telemetry; diff --git a/orb-supervisor/src/shutdown.rs b/orb-supervisor/src/shutdown.rs new file mode 100644 index 00000000..6c893bc1 --- /dev/null +++ b/orb-supervisor/src/shutdown.rs @@ -0,0 +1,154 @@ +use std::{cmp::Ordering, fmt::Display, str::FromStr}; + +use tracing::info; +use zbus_systemd::login1::{self}; +use Kind::{DryHalt, DryPoweroff, DryReboot, Halt, Poweroff, Reboot}; + +/// `ScheduledShutdown` represents the logind shutdown tuple as an argument +/// for the `org.freedesktop.login1.Manager.ScheduleShutdown` dbus method. +/// +/// `Option` represents the return value of the +/// `org.freedesktop.login1.Manager.ScheduleShutdown` property. +/// +/// The priority of a scheduled shutdown is determined first by the kind (and +/// its presence), followed by the soonest (lowest `when` value). +#[derive(Clone, Debug, PartialEq, Eq)] +pub struct ScheduledShutdown { + pub kind: Kind, + pub when: u64, +} + +impl ScheduledShutdown { + /// `try_from_dbus` attempts to convert from the tuple returned by + /// `org.freedesktop.login1.Manager.ScheduledShutdown` into a + /// `Option` instance. + /// + /// `org.freedesktop.login1.Manager.ScheduledShutdown` returns an empty + /// string for `kind` (and `0` for `when`) if there is no already scheduled + /// shutdown. In this case, we return `Ok(None)` + pub fn try_from_dbus( + (kind, when): (String, u64), + ) -> Result, UnknownShutdownKind> { + let kind = match kind.parse::() { + Ok(kind) => kind, + Err(KindParseErr::EmptyStr) => return Ok(None), + Err(KindParseErr::Unknown(err)) => return Err(err), + }; + + Ok(Some(Self { kind, when })) + } +} + +impl PartialOrd for ScheduledShutdown { + fn partial_cmp(&self, other: &Self) -> Option { + match self.kind.cmp(&other.kind) { + // We want to prioritize smaller `when` values + Ordering::Equal => Some(self.when.cmp(&other.when).reverse()), + v => Some(v), + } + } +} + +#[derive(Clone, Debug, PartialEq, PartialOrd, Eq, Ord)] +pub enum Kind { + Poweroff = 6, + Reboot = 5, + Halt = 4, + DryPoweroff = 3, + DryReboot = 2, + DryHalt = 1, +} + +#[derive(thiserror::Error, Debug, Eq, PartialEq)] +#[error("unknown shutdown kind `{0}`")] +pub struct UnknownShutdownKind(String); + +#[derive(thiserror::Error, Debug, Eq, PartialEq)] +pub enum KindParseErr { + #[error(transparent)] + Unknown(#[from] UnknownShutdownKind), + #[error("empty string")] + EmptyStr, +} + +impl FromStr for Kind { + type Err = KindParseErr; + + fn from_str(value: &str) -> Result { + Ok(match value { + "" => return Err(KindParseErr::EmptyStr), + "dry-poweroff" => Kind::DryPoweroff, + "dry-reboot" => Kind::DryReboot, + "dry-halt" => Kind::DryHalt, + "poweroff" => Kind::Poweroff, + "reboot" => Kind::Reboot, + "halt" => Kind::Halt, + unknown => return Err(UnknownShutdownKind(unknown.to_owned()).into()), + }) + } +} + +impl Kind { + #[must_use] + pub fn as_str(&self) -> &'static str { + match self { + Poweroff => "poweroff", + Reboot => "reboot", + Halt => "halt", + DryPoweroff => "dry-poweroff", + DryReboot => "dry-reboot", + DryHalt => "dry-halt", + } + } +} + +impl Display for Kind { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + write!(f, "{}", self.as_str()) + } +} + +/// The Happy path return value of [`schedule_shutdown`]. Describes whether there +/// were any existing scheduled shutdowns. +#[derive(Debug, Eq, PartialEq)] +pub enum PreemptionInfo { + /// Scheduled successfully, and there were no existing shutdowns to preempt. + NoExistingShutdown, + /// The shutdown that was requested was ignored in favor of an existing shutdown. + KeptExistingShutdown(ScheduledShutdown), + /// The shutdown that was requested preempted/replaced an existing shutdown. + PreemptedExistingShutdown(ScheduledShutdown), +} + +/// Schedules a shutdown using `proxy`. Will preempt a pre-existing shutdown +/// of lower priority. +#[allow(clippy::missing_panics_doc)] +pub async fn schedule_shutdown( + proxy: login1::ManagerProxy<'static>, + shutdown_req: ScheduledShutdown, +) -> zbus::Result { + let already_scheduled: Option = { + info!("getting property `org.freedesktop.login1.Manager.ScheduledShutdown`"); + let raw_tuple = proxy.scheduled_shutdown().await?; + ScheduledShutdown::try_from_dbus(raw_tuple) + .expect("infallible, the result should always parse") + }; + + let result = if let Some(already_scheduled) = already_scheduled { + if shutdown_req.lt(&already_scheduled) { + return Ok(PreemptionInfo::KeptExistingShutdown(already_scheduled)); + } + PreemptionInfo::PreemptedExistingShutdown(already_scheduled) + } else { + PreemptionInfo::NoExistingShutdown + }; + + info!( + "calling `org.freedesktop.login1.Manager.ScheduleShutdown` to shutdown system" + ); + proxy + .schedule_shutdown(shutdown_req.kind.as_str().to_owned(), shutdown_req.when) + .await?; + + Ok(result) +} diff --git a/orb-supervisor/src/tasks/mod.rs b/orb-supervisor/src/tasks/mod.rs index e8f2e033..8d054a23 100644 --- a/orb-supervisor/src/tasks/mod.rs +++ b/orb-supervisor/src/tasks/mod.rs @@ -1,6 +1,5 @@ //! Tasks that make up the orb supervisor. -pub mod shutdown; pub mod signup_started; pub mod update; diff --git a/orb-supervisor/src/tasks/shutdown.rs b/orb-supervisor/src/tasks/shutdown.rs deleted file mode 100644 index ac05cb5b..00000000 --- a/orb-supervisor/src/tasks/shutdown.rs +++ /dev/null @@ -1,150 +0,0 @@ -use std::{cmp::Ordering, fmt::Display}; - -use futures::TryFutureExt; -use tokio::task::JoinHandle; -use tracing::{info, instrument}; -use zbus_systemd::login1::{self, ManagerProxy}; -use Kind::{DryHalt, DryPoweroff, DryReboot, Halt, Poweroff, Reboot}; - -/// `ScheduledShutdown` represents the logind shutdown tuple both as an argument -/// and return value for the `org.freedesktop.login1.Manager.ScheduledShutdown` -/// dbus method. -/// -/// The priority of a scheduled shutdown is determined first by the kind (and -/// its presence), followed by the soonest (lowest `when` value). -#[derive(Clone, Debug, PartialEq, Eq)] -pub struct ScheduledShutdown { - pub kind: Option, - pub when: u64, -} - -#[derive(Clone, Debug, PartialEq, PartialOrd, Eq, Ord)] -pub enum Kind { - Poweroff = 6, - Reboot = 5, - Halt = 4, - DryPoweroff = 3, - DryReboot = 2, - DryHalt = 1, -} - -impl ScheduledShutdown { - /// `try_from_dbus` attempts to convert from the tuple returned by - /// `org.freedesktop.login1.Manager.ScheduleShutdown` into a `ScheduledShutdown` instance - /// - /// # Errors - /// This function bubbles up any errors encountered while calling `TryFrom` for `Kind` - pub fn try_from_dbus((kind, when): (String, u64)) -> Result { - let kind = match Kind::try_from(kind.as_str()) { - Ok(kind) => Some(kind), - Err(Error::NothingScheduled) => None, - Err(err) => return Err(err), - }; - - Ok(Self { kind, when }) - } - - #[must_use] - pub fn kind_as_str(&self) -> String { - match &self.kind { - None => String::new(), - Some(kind) => kind.to_string(), - } - } -} - -impl PartialOrd for ScheduledShutdown { - fn partial_cmp(&self, other: &Self) -> Option { - match self.kind.cmp(&other.kind) { - // We want to prioritize smaller `when` values - Ordering::Equal => Some(self.when.cmp(&other.when).reverse()), - v => Some(v), - } - } -} - -impl TryFrom<&str> for Kind { - type Error = Error; - - fn try_from(value: &str) -> Result { - match value { - "" => Err(Error::NothingScheduled), - "dry-poweroff" => Ok(Self::DryPoweroff), - "dry-reboot" => Ok(Self::DryReboot), - "dry-halt" => Ok(Self::DryHalt), - "poweroff" => Ok(Self::Poweroff), - "reboot" => Ok(Self::Reboot), - "halt" => Ok(Self::Halt), - unknown => Err(Error::unrecognized_type(unknown)), - } - } -} - -impl Display for Kind { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - write!( - f, - "{}", - match self { - Poweroff => "poweroff", - Reboot => "reboot", - Halt => "halt", - DryPoweroff => "dry-poweroff", - DryReboot => "dry-reboot", - DryHalt => "dry-halt", - } - ) - } -} - -#[derive(Debug, thiserror::Error)] -pub enum Error { - #[error("logind has no shutdown scheduled")] - NothingScheduled, - #[error("unrecognized shutdown type `{0}`")] - UnrecognizedType(String), - #[error("failed communicating over dbus")] - Dbus(#[from] zbus::Error), - #[error("deferring for higher priority scheduled shutdown `{0:?}`")] - Defer(ScheduledShutdown), -} - -impl Error { - fn unrecognized_type(kind: &str) -> Self { - Self::UnrecognizedType(kind.to_string()) - } -} - -#[must_use] -pub fn spawn_logind_schedule_shutdown_task( - proxy: login1::ManagerProxy<'static>, - shutdown_req: ScheduledShutdown, -) -> JoinHandle> { - tokio::spawn(async move { - info!("getting property `org.freedesktop.login1.Manager.ScheduledShutdown`"); - let scheduled_shutdown = get_logind_scheduled_shutdown(proxy.clone()).await?; - - // PartialOrd guarantees us that a requested "Poweroff" in 1000us will - // take priority over an already scheduled "Reboot" in 10us - if shutdown_req.gt(&scheduled_shutdown) { - info!("calling `org.freedesktop.login1.Manager.ScheduleShutdown` to shutdown system"); - proxy - .schedule_shutdown(shutdown_req.kind_as_str(), shutdown_req.when) - .map_err(Error::from) - .await - } else { - Err(Error::Defer(scheduled_shutdown)) - } - }) -} - -#[instrument(skip_all, err, ret(Debug))] -async fn get_logind_scheduled_shutdown( - proxy: ManagerProxy<'static>, -) -> Result { - proxy - .scheduled_shutdown() - .map_ok(ScheduledShutdown::try_from_dbus) - .map_err(Error::from) - .await? -} From 6d0bf562f0990aa69e4a819d273fe3a7c604a986 Mon Sep 17 00:00:00 2001 From: Ryan Butler Date: Tue, 4 Jun 2024 12:56:09 -0400 Subject: [PATCH 33/38] add protoc to ci (#43) --- .github/workflows/general.yml | 8 ++++++++ .github/workflows/release-binary.yml | 4 ++++ 2 files changed, 12 insertions(+) diff --git a/.github/workflows/general.yml b/.github/workflows/general.yml index 8880344a..0552202c 100644 --- a/.github/workflows/general.yml +++ b/.github/workflows/general.yml @@ -18,6 +18,10 @@ jobs: steps: - run: | git config --global --add url."https://${{ secrets.GIT_HUB_TOKEN }}:x-oauth-basic@github.com/worldcoin/".insteadOf "https://github.com/worldcoin/" + - name: Install Protoc + uses: arduino/setup-protoc@c65c819552d16ad3c9b72d9dfd5ba5237b9c906b # pin@v3 + with: + version: "24.1" - uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # pin@v3 - name: Cache cargo dependencies uses: Swatinem/rust-cache@a95ba195448af2da9b00fb742d14ffaaf3c21f43 # pin@v2 @@ -35,6 +39,10 @@ jobs: steps: - run: | git config --global url."https://${{ secrets.GIT_HUB_TOKEN }}:x-oauth-basic@github.com/worldcoin/".insteadOf "https://github.com/worldcoin/" + - name: Install Protoc + uses: arduino/setup-protoc@c65c819552d16ad3c9b72d9dfd5ba5237b9c906b # pin@v3 + with: + version: "24.1" - uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # pin@v3 - name: Cache cargo dependencies uses: Swatinem/rust-cache@a95ba195448af2da9b00fb742d14ffaaf3c21f43 # pin@v2 diff --git a/.github/workflows/release-binary.yml b/.github/workflows/release-binary.yml index 353d0dd3..eb4f2990 100644 --- a/.github/workflows/release-binary.yml +++ b/.github/workflows/release-binary.yml @@ -17,6 +17,10 @@ jobs: uses: goto-bus-stop/setup-zig@222d316fd35ce56a4141fe4a869e1aeefc7f3590 # pin@v1 with: version: 0.9.1 + - name: Install Protoc + uses: arduino/setup-protoc@c65c819552d16ad3c9b72d9dfd5ba5237b9c906b # pin@v3 + with: + version: "24.1" - name: Cache cargo dependencies uses: Swatinem/rust-cache@a95ba195448af2da9b00fb742d14ffaaf3c21f43 # pin@v2 - run: cargo install cargo-zigbuild From e64771490c8d9cb8d51489c42bd920e2ebf1ebef Mon Sep 17 00:00:00 2001 From: wld-terraform <102665000+wld-terraform@users.noreply.github.com> Date: Fri, 19 Jul 2024 11:40:36 +0200 Subject: [PATCH 34/38] Add .github/workflows/relyance-sci.yml --- .github/workflows/relyance-sci.yml | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 .github/workflows/relyance-sci.yml diff --git a/.github/workflows/relyance-sci.yml b/.github/workflows/relyance-sci.yml new file mode 100644 index 00000000..eb25964d --- /dev/null +++ b/.github/workflows/relyance-sci.yml @@ -0,0 +1,20 @@ +name: Relyance SCI Scan + +on: + schedule: + - cron: "0 20 * * *" + workflow_dispatch: + +jobs: + execute-relyance-sci: + name: Relyance SCI Job + runs-on: ubuntu-latest + + steps: + - name: Checkout + uses: actions/checkout@v2 + + - name: Pull and run SCI binary + run: |- + docker pull gcr.io/relyance-ext/compliance_inspector:release && \ + docker run --rm -v `pwd`:/repo --env API_KEY='${{ secrets.DPP_SCI_KEY }}' gcr.io/relyance-ext/compliance_inspector:release From 63cb50441c7321ebd1d048a0c0a7e30c00a0cb13 Mon Sep 17 00:00:00 2001 From: wld-terraform <102665000+wld-terraform@users.noreply.github.com> Date: Wed, 24 Jul 2024 14:43:41 +0200 Subject: [PATCH 35/38] Update .github/workflows/relyance-sci.yml --- .github/workflows/relyance-sci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/relyance-sci.yml b/.github/workflows/relyance-sci.yml index eb25964d..1462102d 100644 --- a/.github/workflows/relyance-sci.yml +++ b/.github/workflows/relyance-sci.yml @@ -12,7 +12,7 @@ jobs: steps: - name: Checkout - uses: actions/checkout@v2 + uses: actions/checkout@v4 - name: Pull and run SCI binary run: |- From fcaaca41e49d04d711daf236e3b1edf336658ee6 Mon Sep 17 00:00:00 2001 From: Ryan Butler Date: Fri, 2 Aug 2024 17:13:57 -0400 Subject: [PATCH 36/38] Add Ryan and Victor to CODEOWNERS, remove SuperFluffy (#49) * Add Ryan and Victor to CODEOWNERS * Remove superfluffly --- CODEOWNERS | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CODEOWNERS b/CODEOWNERS index 737e5b74..063ea269 100644 --- a/CODEOWNERS +++ b/CODEOWNERS @@ -1 +1 @@ -* @superfluffy @oldgalileo +* @oldgalileo @thebutlah @vmenge From 27142c9a39facef18f21dff5a4cd8ebff44e0a9e Mon Sep 17 00:00:00 2001 From: Ian Klatzco <124045038+ik-work-gh@users.noreply.github.com> Date: Fri, 2 Aug 2024 14:31:08 -0700 Subject: [PATCH 37/38] Add branches: main to release-library.yml (#48) --- .github/workflows/release-library.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/release-library.yml b/.github/workflows/release-library.yml index dd136309..85529817 100644 --- a/.github/workflows/release-library.yml +++ b/.github/workflows/release-library.yml @@ -3,6 +3,8 @@ on: push: tags: - orb-supervisor-[a-z]+-[0-9]+.* + branches: + - main jobs: release: From e197dd807b759d4b39fd93130a397d486c0c8417 Mon Sep 17 00:00:00 2001 From: Ryan Butler Date: Tue, 6 Aug 2024 15:41:55 -0400 Subject: [PATCH 38/38] supervisor: prepare open sourcing --- .github/workflows/general.yml | 49 - .github/workflows/release-binary.yml | 111 -- .github/workflows/release-library.yml | 39 - .github/workflows/relyance-sci.yml | 20 - .gitignore | 3 - CODEOWNERS | 1 - Cargo.lock | 1430 ----------------------- Cargo.toml | 5 - README.md | 77 -- PROCESS.md => orb-supervisor/PROCESS.md | 0 orb-supervisor/README.md | 88 +- rust-toolchain.toml | 5 - rustfmt.toml | 2 - 13 files changed, 71 insertions(+), 1759 deletions(-) delete mode 100644 .github/workflows/general.yml delete mode 100644 .github/workflows/release-binary.yml delete mode 100644 .github/workflows/release-library.yml delete mode 100644 .github/workflows/relyance-sci.yml delete mode 100644 .gitignore delete mode 100644 CODEOWNERS delete mode 100644 Cargo.lock delete mode 100644 Cargo.toml delete mode 100644 README.md rename PROCESS.md => orb-supervisor/PROCESS.md (100%) delete mode 100644 rust-toolchain.toml delete mode 100644 rustfmt.toml diff --git a/.github/workflows/general.yml b/.github/workflows/general.yml deleted file mode 100644 index 0552202c..00000000 --- a/.github/workflows/general.yml +++ /dev/null @@ -1,49 +0,0 @@ -name: Continuous integration - -on: - push: - branches: - - main - - develop - pull_request: - workflow_dispatch: - - # Make sure CI fails on all warnings, including Clippy lints -env: - RUSTFLAGS: "-Dwarnings" - -jobs: - test: - runs-on: ubuntu-latest - steps: - - run: | - git config --global --add url."https://${{ secrets.GIT_HUB_TOKEN }}:x-oauth-basic@github.com/worldcoin/".insteadOf "https://github.com/worldcoin/" - - name: Install Protoc - uses: arduino/setup-protoc@c65c819552d16ad3c9b72d9dfd5ba5237b9c906b # pin@v3 - with: - version: "24.1" - - uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # pin@v3 - - name: Cache cargo dependencies - uses: Swatinem/rust-cache@a95ba195448af2da9b00fb742d14ffaaf3c21f43 # pin@v2 - - run: cargo test --all - - rustfmt: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # pin@v3 - - run: cargo fmt --all -- --check - - clippy: - name: Clippy - runs-on: ubuntu-latest - steps: - - run: | - git config --global url."https://${{ secrets.GIT_HUB_TOKEN }}:x-oauth-basic@github.com/worldcoin/".insteadOf "https://github.com/worldcoin/" - - name: Install Protoc - uses: arduino/setup-protoc@c65c819552d16ad3c9b72d9dfd5ba5237b9c906b # pin@v3 - with: - version: "24.1" - - uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # pin@v3 - - name: Cache cargo dependencies - uses: Swatinem/rust-cache@a95ba195448af2da9b00fb742d14ffaaf3c21f43 # pin@v2 - - run: cargo clippy --all --all-features --all-targets --no-deps diff --git a/.github/workflows/release-binary.yml b/.github/workflows/release-binary.yml deleted file mode 100644 index eb4f2990..00000000 --- a/.github/workflows/release-binary.yml +++ /dev/null @@ -1,111 +0,0 @@ -name: Release binary -on: - push: - tags: - - orb-supervisor-[0-9]+.* - branches: - - main - -jobs: - build: - runs-on: ubuntu-latest - steps: - - run: | - git config --global --add url."https://${{ secrets.GIT_HUB_TOKEN }}:x-oauth-basic@github.com/worldcoin/".insteadOf "https://github.com/worldcoin/" - - uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # pin@v3 - - name: Install zig - uses: goto-bus-stop/setup-zig@222d316fd35ce56a4141fe4a869e1aeefc7f3590 # pin@v1 - with: - version: 0.9.1 - - name: Install Protoc - uses: arduino/setup-protoc@c65c819552d16ad3c9b72d9dfd5ba5237b9c906b # pin@v3 - with: - version: "24.1" - - name: Cache cargo dependencies - uses: Swatinem/rust-cache@a95ba195448af2da9b00fb742d14ffaaf3c21f43 # pin@v2 - - run: cargo install cargo-zigbuild - - name: Build orb-supervisor binary - run: cargo zigbuild --release --target aarch64-unknown-linux-gnu.2.27 -p orb-supervisor - - name: Cache orb-supervisor binary - uses: actions/cache@704facf57e6136b1bc63b828d79edcd491f0ee84 # pin@v3 - with: - path: target/aarch64-unknown-linux-gnu/release/orb-supervisor - key: ${{ github.run_id }}-${{ github.run_number }}-${{ github.run_attempt }}-orb-supervisor-bin - - release: - # only run this for release tags - if: ${{ github.ref_type == 'tag' && startsWith(github.ref_name, 'orb-supervisor') }} - needs: build - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # pin@v3 - - name: Get tag - id: tag - uses: dawidd6/action-get-tag@727a6f0a561be04e09013531e73a3983a65e3479 # pin@v1 - - name: Retrieve cache - uses: actions/cache@704facf57e6136b1bc63b828d79edcd491f0ee84 # pin@v3 - with: - path: target/aarch64-unknown-linux-gnu/release/orb-supervisor - key: ${{ github.run_id }}-${{ github.run_number }}-${{ github.run_attempt }}-orb-supervisor-bin - - name: Archive binary - shell: bash - run: | - cd target/aarch64-unknown-linux-gnu/release - tar cvzf ${{ steps.tag.outputs.tag }}.tar.gz orb-supervisor - shasum -a 256 ${{ steps.tag.outputs.tag }}.tar.gz > ${{ steps.tag.outputs.tag }}.tar.gz.sha256 - cd - - - name: Install changelog parser - uses: taiki-e/install-action@f863cdaef3a8e79111b7a8c74d466b89d31d2fdc # pin@parse-changelog - - name: Read changelog contents - id: changelog - shell: bash - run: | - echo 'TITLE<> $GITHUB_ENV - parse-changelog -t orb-supervisor/CHANGELOG.md >> $GITHUB_ENV - echo 'EOF' >> $GITHUB_ENV - echo 'NOTES<> $GITHUB_ENV - parse-changelog orb-supervisor/CHANGELOG.md >> $GITHUB_ENV - echo 'EOF' >> $GITHUB_ENV - - name: Make a github release for the binary - uses: softprops/action-gh-release@de2c0eb89ae2a093876385947365aca7b0e5f844 # pin@v1 - with: - files: | - target/aarch64-unknown-linux-gnu/release/orb-supervisor*.tar.gz - fail_on_unmatched_files: true - prerelease: ${{ contains(github.ref, 'alpha') || contains(github.ref, 'beta') || contains(github.ref, 'rc') }} - name: orb-supervisor ${{ env.TITLE }} - body: ${{ env.NOTES }} - - release-latest: - # only release on pushes on main branch - if: ${{ github.ref_name == 'main' }} - runs-on: ubuntu-22.04 - needs: [ build ] - steps: - - uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # pin@v3 - - name: Retrieve cache - uses: actions/cache@704facf57e6136b1bc63b828d79edcd491f0ee84 # pin@v3 - with: - path: target/aarch64-unknown-linux-gnu/release/orb-supervisor - key: ${{ github.run_id }}-${{ github.run_number }}-${{ github.run_attempt }}-orb-supervisor-bin - - name: archive binary - run: | - cd target/aarch64-unknown-linux-gnu/release - tar cvzf orb-supervisor-latest.tar.gz orb-supervisor - shasum -a 256 orb-supervisor-latest.tar.gz > orb-supervisor-latest.tar.gz.sha256 - cd - - - name: upload development build - run: | - gh release delete latest \ - --yes \ - --cleanup-tag \ - --repo ${{ github.repository }} || true - gh release create latest \ - --title 'Development Build' \ - --notes 'Latest successful build of main branch' \ - --prerelease \ - --repo ${{ github.repository }} \ - target/aarch64-unknown-linux-gnu/release/orb-supervisor-latest.tar.gz \ - target/aarch64-unknown-linux-gnu/release/orb-supervisor-latest.tar.gz.sha256 - env: - GH_TOKEN: ${{ github.token }} diff --git a/.github/workflows/release-library.yml b/.github/workflows/release-library.yml deleted file mode 100644 index 85529817..00000000 --- a/.github/workflows/release-library.yml +++ /dev/null @@ -1,39 +0,0 @@ -name: Release library -on: - push: - tags: - - orb-supervisor-[a-z]+-[0-9]+.* - branches: - - main - -jobs: - release: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # pin@v3 - - name: Get tag - id: tag - uses: dawidd6/action-get-tag@727a6f0a561be04e09013531e73a3983a65e3479 # pin@v1 - - name: Read tag prefix - id: prefix - shell: bash - run: | - [[ ${{ steps.tag.outputs.tag }} =~ ^(orb-supervisor-[a-z]+).* ]] && echo "::set-output name=prefix::${BASH_REMATCH[1]}" - - name: Install changelog parser - uses: taiki-e/install-action@f863cdaef3a8e79111b7a8c74d466b89d31d2fdc # pin@parse-changelog - - name: Read changelog contents - id: changelog - shell: bash - run: | - echo 'TITLE<> $GITHUB_ENV - parse-changelog -t ${{ steps.prefix.outputs.prefix }}/CHANGELOG.md >> $GITHUB_ENV - echo 'EOF' >> $GITHUB_ENV - echo 'NOTES<> $GITHUB_ENV - parse-changelog ${{ steps.prefix.outputs.prefix }}/CHANGELOG.md >> $GITHUB_ENV - echo 'EOF' >> $GITHUB_ENV - - name: Make a github release for the library - uses: softprops/action-gh-release@de2c0eb89ae2a093876385947365aca7b0e5f844 # pin@v1 - with: - prerelease: ${{ contains(github.ref, 'alpha') || contains(github.ref, 'beta') || contains(github.ref, 'rc') }} - name: ${{ steps.prefix.outputs.prefix }} ${{ env.TITLE }} - body: ${{ env.NOTES }} diff --git a/.github/workflows/relyance-sci.yml b/.github/workflows/relyance-sci.yml deleted file mode 100644 index 1462102d..00000000 --- a/.github/workflows/relyance-sci.yml +++ /dev/null @@ -1,20 +0,0 @@ -name: Relyance SCI Scan - -on: - schedule: - - cron: "0 20 * * *" - workflow_dispatch: - -jobs: - execute-relyance-sci: - name: Relyance SCI Job - runs-on: ubuntu-latest - - steps: - - name: Checkout - uses: actions/checkout@v4 - - - name: Pull and run SCI binary - run: |- - docker pull gcr.io/relyance-ext/compliance_inspector:release && \ - docker run --rm -v `pwd`:/repo --env API_KEY='${{ secrets.DPP_SCI_KEY }}' gcr.io/relyance-ext/compliance_inspector:release diff --git a/.gitignore b/.gitignore deleted file mode 100644 index 1cbd80d9..00000000 --- a/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -/target -/.direnv -/.envrc diff --git a/CODEOWNERS b/CODEOWNERS deleted file mode 100644 index 063ea269..00000000 --- a/CODEOWNERS +++ /dev/null @@ -1 +0,0 @@ -* @oldgalileo @thebutlah @vmenge diff --git a/Cargo.lock b/Cargo.lock deleted file mode 100644 index 98c8c96f..00000000 --- a/Cargo.lock +++ /dev/null @@ -1,1430 +0,0 @@ -# This file is automatically @generated by Cargo. -# It is not intended for manual editing. -version = 3 - -[[package]] -name = "addr2line" -version = "0.19.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a76fd60b23679b7d19bd066031410fb7e458ccc5e958eb5c325888ce4baedc97" -dependencies = [ - "gimli", -] - -[[package]] -name = "adler" -version = "1.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" - -[[package]] -name = "aho-corasick" -version = "0.7.20" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cc936419f96fa211c1b9166887b38e5e40b19958e5b895be7c1f93adec7071ac" -dependencies = [ - "memchr", -] - -[[package]] -name = "async-broadcast" -version = "0.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1b19760fa2b7301cf235360ffd6d3558b1ed4249edd16d6cca8d690cee265b95" -dependencies = [ - "event-listener", - "futures-core", - "parking_lot", -] - -[[package]] -name = "async-executor" -version = "1.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "17adb73da160dfb475c183343c8cccd80721ea5a605d3eb57125f0a7b7a92d0b" -dependencies = [ - "async-lock", - "async-task", - "concurrent-queue", - "fastrand", - "futures-lite", - "slab", -] - -[[package]] -name = "async-io" -version = "1.12.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8c374dda1ed3e7d8f0d9ba58715f924862c63eae6849c92d3a18e7fbde9e2794" -dependencies = [ - "async-lock", - "autocfg", - "concurrent-queue", - "futures-lite", - "libc", - "log", - "parking", - "polling", - "slab", - "socket2", - "waker-fn", - "windows-sys 0.42.0", -] - -[[package]] -name = "async-lock" -version = "2.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c8101efe8695a6c17e02911402145357e718ac92d3ff88ae8419e84b1707b685" -dependencies = [ - "event-listener", - "futures-lite", -] - -[[package]] -name = "async-recursion" -version = "1.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3b015a331cc64ebd1774ba119538573603427eaace0a1950c423ab971f903796" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "async-task" -version = "4.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a40729d2133846d9ed0ea60a8b9541bccddab49cd30f0715a1da672fe9a2524" - -[[package]] -name = "async-trait" -version = "0.1.64" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1cd7fce9ba8c3c042128ce72d8b2ddbf3a05747efb67ea0313c635e10bda47a2" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "autocfg" -version = "1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" - -[[package]] -name = "backtrace" -version = "0.3.67" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "233d376d6d185f2a3093e58f283f60f880315b6c60075b01f36b3b85154564ca" -dependencies = [ - "addr2line", - "cc", - "cfg-if", - "libc", - "miniz_oxide", - "object", - "rustc-demangle", -] - -[[package]] -name = "bitflags" -version = "1.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" - -[[package]] -name = "block-buffer" -version = "0.10.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "69cce20737498f97b993470a6e536b8523f0af7892a4f928cceb1ac5e52ebe7e" -dependencies = [ - "generic-array", -] - -[[package]] -name = "byteorder" -version = "1.4.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "14c189c53d098945499cdfa7ecc63567cf3886b3332b312a5b4585d8d3a6a610" - -[[package]] -name = "bytes" -version = "1.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "89b2fd2a0dcf38d7971e2194b6b6eebab45ae01067456a7fd93d5547a61b70be" - -[[package]] -name = "cc" -version = "1.0.79" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "50d30906286121d95be3d479533b458f87493b30a4b5f79a607db8f5d11aa91f" - -[[package]] -name = "cfg-if" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" - -[[package]] -name = "color-eyre" -version = "0.6.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "55146f5e46f237f7423d74111267d4597b59b0dad0ffaf7303bce9945d843ad5" -dependencies = [ - "backtrace", - "color-spantrace", - "eyre", - "indenter", - "once_cell", - "owo-colors", - "tracing-error", -] - -[[package]] -name = "color-spantrace" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cd6be1b2a7e382e2b98b43b2adcca6bb0e465af0bdd38123873ae61eb17a72c2" -dependencies = [ - "once_cell", - "owo-colors", - "tracing-core", - "tracing-error", -] - -[[package]] -name = "concurrent-queue" -version = "2.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c278839b831783b70278b14df4d45e1beb1aad306c07bb796637de9a0e323e8e" -dependencies = [ - "crossbeam-utils", -] - -[[package]] -name = "cpufeatures" -version = "0.2.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "28d997bd5e24a5928dd43e46dc529867e207907fe0b239c3477d924f7f2ca320" -dependencies = [ - "libc", -] - -[[package]] -name = "crossbeam-utils" -version = "0.8.14" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4fb766fa798726286dbbb842f174001dab8abc7b627a1dd86e0b7222a95d929f" -dependencies = [ - "cfg-if", -] - -[[package]] -name = "crypto-common" -version = "0.1.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1bfb12502f3fc46cca1bb51ac28df9d618d813cdc3d2f25b9fe775a34af26bb3" -dependencies = [ - "generic-array", - "typenum", -] - -[[package]] -name = "dbus-launch" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7b605c1a7f0ca11e477d0eb78505f22e2337fd102e880eb5a357d10c080e02b1" -dependencies = [ - "libc", - "tempfile", -] - -[[package]] -name = "derivative" -version = "2.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fcc3dd5e9e9c0b295d6e1e4d811fb6f157d5ffd784b8d202fc62eac8035a770b" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "digest" -version = "0.10.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8168378f4e5023e7218c89c891c0fd8ecdb5e5e4f18cb78f38cf245dd021e76f" -dependencies = [ - "block-buffer", - "crypto-common", -] - -[[package]] -name = "dirs" -version = "4.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ca3aa72a6f96ea37bbc5aa912f6788242832f75369bdfdadcb0e38423f100059" -dependencies = [ - "dirs-sys", -] - -[[package]] -name = "dirs-sys" -version = "0.3.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1b1d1d91c932ef41c0f2663aa8b0ca0342d444d842c06914aa0a7e352d0bada6" -dependencies = [ - "libc", - "redox_users", - "winapi", -] - -[[package]] -name = "enumflags2" -version = "0.7.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e75d4cd21b95383444831539909fbb14b9dc3fdceb2a6f5d36577329a1f55ccb" -dependencies = [ - "enumflags2_derive", - "serde", -] - -[[package]] -name = "enumflags2_derive" -version = "0.7.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f58dc3c5e468259f19f2d46304a6b28f1c3d034442e14b322d2b850e36f6d5ae" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "event-listener" -version = "2.5.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0206175f82b8d6bf6652ff7d71a1e27fd2e4efde587fd368662814d6ec1d9ce0" - -[[package]] -name = "eyre" -version = "0.6.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c2b6b5a29c02cdc822728b7d7b8ae1bab3e3b05d44522770ddd49722eeac7eb" -dependencies = [ - "indenter", - "once_cell", -] - -[[package]] -name = "fastrand" -version = "1.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a7a407cfaa3385c4ae6b23e84623d48c2798d06e3e6a1878f7f59f17b3f86499" -dependencies = [ - "instant", -] - -[[package]] -name = "futures" -version = "0.3.26" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "13e2792b0ff0340399d58445b88fd9770e3489eff258a4cbc1523418f12abf84" -dependencies = [ - "futures-channel", - "futures-core", - "futures-executor", - "futures-io", - "futures-sink", - "futures-task", - "futures-util", -] - -[[package]] -name = "futures-channel" -version = "0.3.26" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2e5317663a9089767a1ec00a487df42e0ca174b61b4483213ac24448e4664df5" -dependencies = [ - "futures-core", - "futures-sink", -] - -[[package]] -name = "futures-core" -version = "0.3.26" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ec90ff4d0fe1f57d600049061dc6bb68ed03c7d2fbd697274c41805dcb3f8608" - -[[package]] -name = "futures-executor" -version = "0.3.26" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e8de0a35a6ab97ec8869e32a2473f4b1324459e14c29275d14b10cb1fd19b50e" -dependencies = [ - "futures-core", - "futures-task", - "futures-util", -] - -[[package]] -name = "futures-io" -version = "0.3.26" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bfb8371b6fb2aeb2d280374607aeabfc99d95c72edfe51692e42d3d7f0d08531" - -[[package]] -name = "futures-lite" -version = "1.12.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7694489acd39452c77daa48516b894c153f192c3578d5a839b62c58099fcbf48" -dependencies = [ - "fastrand", - "futures-core", - "futures-io", - "memchr", - "parking", - "pin-project-lite", - "waker-fn", -] - -[[package]] -name = "futures-macro" -version = "0.3.26" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "95a73af87da33b5acf53acfebdc339fe592ecf5357ac7c0a7734ab9d8c876a70" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "futures-sink" -version = "0.3.26" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f310820bb3e8cfd46c80db4d7fb8353e15dfff853a127158425f31e0be6c8364" - -[[package]] -name = "futures-task" -version = "0.3.26" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dcf79a1bf610b10f42aea489289c5a2c478a786509693b80cd39c44ccd936366" - -[[package]] -name = "futures-util" -version = "0.3.26" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c1d6de3acfef38d2be4b1f543f553131788603495be83da675e180c8d6b7bd1" -dependencies = [ - "futures-channel", - "futures-core", - "futures-io", - "futures-macro", - "futures-sink", - "futures-task", - "memchr", - "pin-project-lite", - "pin-utils", - "slab", -] - -[[package]] -name = "generic-array" -version = "0.14.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bff49e947297f3312447abdca79f45f4738097cc82b06e72054d2223f601f1b9" -dependencies = [ - "typenum", - "version_check", -] - -[[package]] -name = "getrandom" -version = "0.2.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c05aeb6a22b8f62540c194aac980f2115af067bfe15a0734d7277a768d396b31" -dependencies = [ - "cfg-if", - "libc", - "wasi", -] - -[[package]] -name = "gimli" -version = "0.27.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b6c80984affa11d98d1b88b66ac8853f143217b399d3c74116778ff8fdb4ed2e" - -[[package]] -name = "hashbrown" -version = "0.12.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" - -[[package]] -name = "hermit-abi" -version = "0.2.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ee512640fe35acbfb4bb779db6f0d80704c2cacfa2e39b601ef3e3f47d1ae4c7" -dependencies = [ - "libc", -] - -[[package]] -name = "hex" -version = "0.4.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" - -[[package]] -name = "indenter" -version = "0.3.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ce23b50ad8242c51a442f3ff322d56b02f08852c77e4c0b4d3fd684abc89c683" - -[[package]] -name = "indexmap" -version = "1.9.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1885e79c1fc4b10f0e172c475f458b7f7b93061064d98c3293e98c5ba0c8b399" -dependencies = [ - "autocfg", - "hashbrown", -] - -[[package]] -name = "instant" -version = "0.1.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a5bbe824c507c5da5956355e86a746d82e0e1464f65d862cc5e71da70e94b2c" -dependencies = [ - "cfg-if", -] - -[[package]] -name = "lazy_static" -version = "1.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" - -[[package]] -name = "libc" -version = "0.2.139" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "201de327520df007757c1f0adce6e827fe8562fbc28bfd9c15571c66ca1f5f79" - -[[package]] -name = "listenfd" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "14e4fcc00ff6731d94b70e16e71f43bda62883461f31230742e3bc6dddf12988" -dependencies = [ - "libc", - "uuid", - "winapi", -] - -[[package]] -name = "lock_api" -version = "0.4.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "435011366fe56583b16cf956f9df0095b405b82d76425bc8981c0e22e60ec4df" -dependencies = [ - "autocfg", - "scopeguard", -] - -[[package]] -name = "log" -version = "0.4.17" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "abb12e687cfb44aa40f41fc3978ef76448f9b6038cad6aef4259d3c095a2382e" -dependencies = [ - "cfg-if", -] - -[[package]] -name = "matchers" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8263075bb86c5a1b1427b5ae862e8889656f126e9f77c484496e8b47cf5c5558" -dependencies = [ - "regex-automata", -] - -[[package]] -name = "memchr" -version = "2.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d" - -[[package]] -name = "memoffset" -version = "0.6.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5aa361d4faea93603064a027415f07bd8e1d5c88c9fbf68bf56a285428fd79ce" -dependencies = [ - "autocfg", -] - -[[package]] -name = "miniz_oxide" -version = "0.6.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b275950c28b37e794e8c55d88aeb5e139d0ce23fdbbeda68f8d7174abdf9e8fa" -dependencies = [ - "adler", -] - -[[package]] -name = "mio" -version = "0.8.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e5d732bc30207a6423068df043e3d02e0735b155ad7ce1a6f76fe2baa5b158de" -dependencies = [ - "libc", - "log", - "wasi", - "windows-sys 0.42.0", -] - -[[package]] -name = "nix" -version = "0.25.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f346ff70e7dbfd675fe90590b92d59ef2de15a8779ae305ebcbfd3f0caf59be4" -dependencies = [ - "autocfg", - "bitflags", - "cfg-if", - "libc", - "memoffset", - "pin-utils", -] - -[[package]] -name = "nom8" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ae01545c9c7fc4486ab7debaf2aad7003ac19431791868fb2e8066df97fad2f8" -dependencies = [ - "memchr", -] - -[[package]] -name = "nu-ansi-term" -version = "0.46.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "77a8165726e8236064dbb45459242600304b42a5ea24ee2948e18e023bf7ba84" -dependencies = [ - "overload", - "winapi", -] - -[[package]] -name = "num_cpus" -version = "1.15.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0fac9e2da13b5eb447a6ce3d392f23a29d8694bff781bf03a16cd9ac8697593b" -dependencies = [ - "hermit-abi", - "libc", -] - -[[package]] -name = "object" -version = "0.30.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "03b4680b86d9cfafba8fc491dc9b6df26b68cf40e9e6cd73909194759a63c385" -dependencies = [ - "memchr", -] - -[[package]] -name = "once_cell" -version = "1.19.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" - -[[package]] -name = "orb-supervisor" -version = "0.4.1" -dependencies = [ - "color-eyre", - "dbus-launch", - "futures", - "libc", - "listenfd", - "once_cell", - "tap", - "thiserror", - "tokio", - "tokio-stream", - "tracing", - "tracing-journald", - "tracing-subscriber", - "zbus", - "zbus_systemd", -] - -[[package]] -name = "ordered-stream" -version = "0.1.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "360a24bdacdb7801a1a6af8500392864791c130ebe8bd9a063158cab00040c90" -dependencies = [ - "futures-core", - "pin-project-lite", -] - -[[package]] -name = "overload" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b15813163c1d831bf4a13c3610c05c0d03b39feb07f7e09fa234dac9b15aaf39" - -[[package]] -name = "owo-colors" -version = "3.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c1b04fb49957986fdce4d6ee7a65027d55d4b6d2265e5848bbb507b58ccfdb6f" - -[[package]] -name = "parking" -version = "2.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "427c3892f9e783d91cc128285287e70a59e206ca452770ece88a76f7a3eddd72" - -[[package]] -name = "parking_lot" -version = "0.12.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3742b2c103b9f06bc9fff0a37ff4912935851bee6d36f3c02bcc755bcfec228f" -dependencies = [ - "lock_api", - "parking_lot_core", -] - -[[package]] -name = "parking_lot_core" -version = "0.9.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9069cbb9f99e3a5083476ccb29ceb1de18b9118cafa53e90c9551235de2b9521" -dependencies = [ - "cfg-if", - "libc", - "redox_syscall", - "smallvec", - "windows-sys 0.45.0", -] - -[[package]] -name = "pin-project-lite" -version = "0.2.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e0a7ae3ac2f1173085d398531c705756c94a4c56843785df85a60c1a0afac116" - -[[package]] -name = "pin-utils" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" - -[[package]] -name = "polling" -version = "2.5.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "22122d5ec4f9fe1b3916419b76be1e80bcb93f618d071d2edf841b137b2a2bd6" -dependencies = [ - "autocfg", - "cfg-if", - "libc", - "log", - "wepoll-ffi", - "windows-sys 0.42.0", -] - -[[package]] -name = "ppv-lite86" -version = "0.2.17" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" - -[[package]] -name = "proc-macro-crate" -version = "1.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "66618389e4ec1c7afe67d51a9bf34ff9236480f8d51e7489b7d5ab0303c13f34" -dependencies = [ - "once_cell", - "toml_edit", -] - -[[package]] -name = "proc-macro2" -version = "1.0.51" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5d727cae5b39d21da60fa540906919ad737832fe0b1c165da3a34d6548c849d6" -dependencies = [ - "unicode-ident", -] - -[[package]] -name = "quote" -version = "1.0.23" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8856d8364d252a14d474036ea1358d63c9e6965c8e5c1885c18f73d70bff9c7b" -dependencies = [ - "proc-macro2", -] - -[[package]] -name = "rand" -version = "0.8.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404" -dependencies = [ - "libc", - "rand_chacha", - "rand_core", -] - -[[package]] -name = "rand_chacha" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88" -dependencies = [ - "ppv-lite86", - "rand_core", -] - -[[package]] -name = "rand_core" -version = "0.6.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" -dependencies = [ - "getrandom", -] - -[[package]] -name = "redox_syscall" -version = "0.2.16" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fb5a58c1855b4b6819d59012155603f0b22ad30cad752600aadfcb695265519a" -dependencies = [ - "bitflags", -] - -[[package]] -name = "redox_users" -version = "0.4.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b033d837a7cf162d7993aded9304e30a83213c648b6e389db233191f891e5c2b" -dependencies = [ - "getrandom", - "redox_syscall", - "thiserror", -] - -[[package]] -name = "regex" -version = "1.7.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "48aaa5748ba571fb95cd2c85c09f629215d3a6ece942baa100950af03a34f733" -dependencies = [ - "aho-corasick", - "memchr", - "regex-syntax", -] - -[[package]] -name = "regex-automata" -version = "0.1.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6c230d73fb8d8c1b9c0b3135c5142a8acee3a0558fb8db5cf1cb65f8d7862132" -dependencies = [ - "regex-syntax", -] - -[[package]] -name = "regex-syntax" -version = "0.6.28" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "456c603be3e8d448b072f410900c09faf164fbce2d480456f50eea6e25f9c848" - -[[package]] -name = "remove_dir_all" -version = "0.5.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3acd125665422973a33ac9d3dd2df85edad0f4ae9b00dafb1a05e43a9f5ef8e7" -dependencies = [ - "winapi", -] - -[[package]] -name = "rustc-demangle" -version = "0.1.24" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "719b953e2095829ee67db738b3bfa9fa368c94900df327b3f07fe6e794d2fe1f" - -[[package]] -name = "scopeguard" -version = "1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd" - -[[package]] -name = "serde" -version = "1.0.152" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bb7d1f0d3021d347a83e556fc4683dea2ea09d87bccdf88ff5c12545d89d5efb" -dependencies = [ - "serde_derive", -] - -[[package]] -name = "serde_derive" -version = "1.0.152" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "af487d118eecd09402d70a5d72551860e788df87b464af30e5ea6a38c75c541e" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "serde_repr" -version = "0.1.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9a5ec9fa74a20ebbe5d9ac23dac1fc96ba0ecfe9f50f2843b52e537b10fbcb4e" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "sha1" -version = "0.10.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f04293dc80c3993519f2d7f6f511707ee7094fe0c6d3406feb330cdb3540eba3" -dependencies = [ - "cfg-if", - "cpufeatures", - "digest", -] - -[[package]] -name = "sharded-slab" -version = "0.1.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "900fba806f70c630b0a382d0d825e17a0f19fcd059a2ade1ff237bcddf446b31" -dependencies = [ - "lazy_static", -] - -[[package]] -name = "slab" -version = "0.4.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4614a76b2a8be0058caa9dbbaf66d988527d86d003c11a94fbd335d7661edcef" -dependencies = [ - "autocfg", -] - -[[package]] -name = "smallvec" -version = "1.10.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a507befe795404456341dfab10cef66ead4c041f62b8b11bbb92bffe5d0953e0" - -[[package]] -name = "socket2" -version = "0.4.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "02e2d2db9033d13a1567121ddd7a095ee144db4e1ca1b1bda3419bc0da294ebd" -dependencies = [ - "libc", - "winapi", -] - -[[package]] -name = "static_assertions" -version = "1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" - -[[package]] -name = "syn" -version = "1.0.107" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1f4064b5b16e03ae50984a5a8ed5d4f8803e6bc1fd170a3cda91a1be4b18e3f5" -dependencies = [ - "proc-macro2", - "quote", - "unicode-ident", -] - -[[package]] -name = "tap" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "55937e1799185b12863d447f42597ed69d9928686b8d88a1df17376a097d8369" - -[[package]] -name = "tempfile" -version = "3.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5cdb1ef4eaeeaddc8fbd371e5017057064af0911902ef36b39801f67cc6d79e4" -dependencies = [ - "cfg-if", - "fastrand", - "libc", - "redox_syscall", - "remove_dir_all", - "winapi", -] - -[[package]] -name = "thiserror" -version = "1.0.38" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6a9cd18aa97d5c45c6603caea1da6628790b37f7a34b6ca89522331c5180fed0" -dependencies = [ - "thiserror-impl", -] - -[[package]] -name = "thiserror-impl" -version = "1.0.38" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1fb327af4685e4d03fa8cbcf1716380da910eeb2bb8be417e7f9fd3fb164f36f" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "thread_local" -version = "1.1.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5516c27b78311c50bf42c071425c560ac799b11c30b31f87e3081965fe5e0180" -dependencies = [ - "once_cell", -] - -[[package]] -name = "tokio" -version = "1.25.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c8e00990ebabbe4c14c08aca901caed183ecd5c09562a12c824bb53d3c3fd3af" -dependencies = [ - "autocfg", - "bytes", - "libc", - "memchr", - "mio", - "num_cpus", - "pin-project-lite", - "socket2", - "tokio-macros", - "tracing", - "windows-sys 0.42.0", -] - -[[package]] -name = "tokio-macros" -version = "1.8.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d266c00fde287f55d3f1c3e96c500c362a2b8c695076ec180f27918820bc6df8" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "tokio-stream" -version = "0.1.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d660770404473ccd7bc9f8b28494a811bc18542b915c0855c51e8f419d5223ce" -dependencies = [ - "futures-core", - "pin-project-lite", - "tokio", -] - -[[package]] -name = "toml_datetime" -version = "0.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4553f467ac8e3d374bc9a177a26801e5d0f9b211aa1673fb137a403afd1c9cf5" - -[[package]] -name = "toml_edit" -version = "0.18.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "56c59d8dd7d0dcbc6428bf7aa2f0e823e26e43b3c9aca15bbc9475d23e5fa12b" -dependencies = [ - "indexmap", - "nom8", - "toml_datetime", -] - -[[package]] -name = "tracing" -version = "0.1.37" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8ce8c33a8d48bd45d624a6e523445fd21ec13d3653cd51f681abf67418f54eb8" -dependencies = [ - "cfg-if", - "pin-project-lite", - "tracing-attributes", - "tracing-core", -] - -[[package]] -name = "tracing-attributes" -version = "0.1.23" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4017f8f45139870ca7e672686113917c71c7a6e02d4924eda67186083c03081a" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "tracing-core" -version = "0.1.30" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "24eb03ba0eab1fd845050058ce5e616558e8f8d8fca633e6b163fe25c797213a" -dependencies = [ - "once_cell", - "valuable", -] - -[[package]] -name = "tracing-error" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d686ec1c0f384b1277f097b2f279a2ecc11afe8c133c1aabf036a27cb4cd206e" -dependencies = [ - "tracing", - "tracing-subscriber", -] - -[[package]] -name = "tracing-journald" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ba316a74e8fc3c3896a850dba2375928a9fa171b085ecddfc7c054d39970f3fd" -dependencies = [ - "libc", - "tracing-core", - "tracing-subscriber", -] - -[[package]] -name = "tracing-log" -version = "0.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "78ddad33d2d10b1ed7eb9d1f518a5674713876e97e5bb9b7345a7984fbb4f922" -dependencies = [ - "lazy_static", - "log", - "tracing-core", -] - -[[package]] -name = "tracing-subscriber" -version = "0.3.16" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a6176eae26dd70d0c919749377897b54a9276bd7061339665dd68777926b5a70" -dependencies = [ - "matchers", - "nu-ansi-term", - "once_cell", - "regex", - "sharded-slab", - "smallvec", - "thread_local", - "tracing", - "tracing-core", - "tracing-log", -] - -[[package]] -name = "typenum" -version = "1.16.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "497961ef93d974e23eb6f433eb5fe1b7930b659f06d12dec6fc44a8f554c0bba" - -[[package]] -name = "uds_windows" -version = "1.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ce65604324d3cce9b966701489fbd0cf318cb1f7bd9dd07ac9a4ee6fb791930d" -dependencies = [ - "tempfile", - "winapi", -] - -[[package]] -name = "unicode-ident" -version = "1.0.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "84a22b9f218b40614adcb3f4ff08b703773ad44fa9423e4e0d346d5db86e4ebc" - -[[package]] -name = "uuid" -version = "1.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1674845326ee10d37ca60470760d4288a6f80f304007d92e5c53bab78c9cfd79" - -[[package]] -name = "valuable" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "830b7e5d4d90034032940e4ace0d9a9a057e7a45cd94e6c007832e39edb82f6d" - -[[package]] -name = "version_check" -version = "0.9.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" - -[[package]] -name = "waker-fn" -version = "1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9d5b2c62b4012a3e1eca5a7e077d13b3bf498c4073e33ccd58626607748ceeca" - -[[package]] -name = "wasi" -version = "0.11.0+wasi-snapshot-preview1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" - -[[package]] -name = "wepoll-ffi" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d743fdedc5c64377b5fc2bc036b01c7fd642205a0d96356034ae3404d49eb7fb" -dependencies = [ - "cc", -] - -[[package]] -name = "winapi" -version = "0.3.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" -dependencies = [ - "winapi-i686-pc-windows-gnu", - "winapi-x86_64-pc-windows-gnu", -] - -[[package]] -name = "winapi-i686-pc-windows-gnu" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" - -[[package]] -name = "winapi-x86_64-pc-windows-gnu" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" - -[[package]] -name = "windows-sys" -version = "0.42.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5a3e1820f08b8513f676f7ab6c1f99ff312fb97b553d30ff4dd86f9f15728aa7" -dependencies = [ - "windows_aarch64_gnullvm", - "windows_aarch64_msvc", - "windows_i686_gnu", - "windows_i686_msvc", - "windows_x86_64_gnu", - "windows_x86_64_gnullvm", - "windows_x86_64_msvc", -] - -[[package]] -name = "windows-sys" -version = "0.45.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "75283be5efb2831d37ea142365f009c02ec203cd29a3ebecbc093d52315b66d0" -dependencies = [ - "windows-targets", -] - -[[package]] -name = "windows-targets" -version = "0.42.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e2522491fbfcd58cc84d47aeb2958948c4b8982e9a2d8a2a35bbaed431390e7" -dependencies = [ - "windows_aarch64_gnullvm", - "windows_aarch64_msvc", - "windows_i686_gnu", - "windows_i686_msvc", - "windows_x86_64_gnu", - "windows_x86_64_gnullvm", - "windows_x86_64_msvc", -] - -[[package]] -name = "windows_aarch64_gnullvm" -version = "0.42.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8c9864e83243fdec7fc9c5444389dcbbfd258f745e7853198f365e3c4968a608" - -[[package]] -name = "windows_aarch64_msvc" -version = "0.42.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c8b1b673ffc16c47a9ff48570a9d85e25d265735c503681332589af6253c6c7" - -[[package]] -name = "windows_i686_gnu" -version = "0.42.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "de3887528ad530ba7bdbb1faa8275ec7a1155a45ffa57c37993960277145d640" - -[[package]] -name = "windows_i686_msvc" -version = "0.42.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bf4d1122317eddd6ff351aa852118a2418ad4214e6613a50e0191f7004372605" - -[[package]] -name = "windows_x86_64_gnu" -version = "0.42.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c1040f221285e17ebccbc2591ffdc2d44ee1f9186324dd3e84e99ac68d699c45" - -[[package]] -name = "windows_x86_64_gnullvm" -version = "0.42.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "628bfdf232daa22b0d64fdb62b09fcc36bb01f05a3939e20ab73aaf9470d0463" - -[[package]] -name = "windows_x86_64_msvc" -version = "0.42.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "447660ad36a13288b1db4d4248e857b510e8c3a225c822ba4fb748c0aafecffd" - -[[package]] -name = "zbus" -version = "3.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "76f1a9e02a5659c712de386c2af5156c51a530fac0668d3ff85fa26a2bc006ba" -dependencies = [ - "async-broadcast", - "async-executor", - "async-io", - "async-lock", - "async-recursion", - "async-task", - "async-trait", - "byteorder", - "derivative", - "dirs", - "enumflags2", - "event-listener", - "futures-core", - "futures-sink", - "futures-util", - "hex", - "lazy_static", - "nix", - "once_cell", - "ordered-stream", - "rand", - "serde", - "serde_repr", - "sha1", - "static_assertions", - "tokio", - "tracing", - "uds_windows", - "winapi", - "zbus_macros", - "zbus_names", - "zvariant", -] - -[[package]] -name = "zbus_macros" -version = "3.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "414cd9f07964695e00bfef8e589d1752ea0480b8a619f2064cbaccb8a6c2ed59" -dependencies = [ - "proc-macro-crate", - "proc-macro2", - "quote", - "regex", - "syn", -] - -[[package]] -name = "zbus_names" -version = "2.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f34f314916bd89bdb9934154627fab152f4f28acdda03e7c4c68181b214fe7e3" -dependencies = [ - "serde", - "static_assertions", - "zvariant", -] - -[[package]] -name = "zbus_systemd" -version = "0.0.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f7681e3440cbd50a17f2979785619b487e197b5e7e375a851702d4d20f3965f0" -dependencies = [ - "futures", - "serde", - "zbus", -] - -[[package]] -name = "zvariant" -version = "3.10.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "576cc41e65c7f283e5460f5818073e68fb1f1631502b969ef228c2e03c862efb" -dependencies = [ - "byteorder", - "enumflags2", - "libc", - "serde", - "static_assertions", - "zvariant_derive", -] - -[[package]] -name = "zvariant_derive" -version = "3.10.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0fd4aafc0dee96ae7242a24249ce9babf21e1562822f03df650d4e68c20e41ed" -dependencies = [ - "proc-macro-crate", - "proc-macro2", - "quote", - "syn", -] diff --git a/Cargo.toml b/Cargo.toml deleted file mode 100644 index b3503253..00000000 --- a/Cargo.toml +++ /dev/null @@ -1,5 +0,0 @@ -[workspace] -resolver = "2" -members = [ - "orb-supervisor", -] diff --git a/README.md b/README.md deleted file mode 100644 index 24055bbc..00000000 --- a/README.md +++ /dev/null @@ -1,77 +0,0 @@ -# Orb Supervisor - -Orb supervisor is a central IPC server that coordinates device state and external UX across independent agents (binaries/processes). - -## Table of Contents - -- Minimal viable product (MVP) -- Why (this is necessary) - - Managing device health - - Consistent UX - - Seperation of concerns -- Relevant components - -## MVP - -### Initial release - -- supervisor running [tonic gRPC](https://github.com/hyperium/tonic) over UDS (Unix Domain Sockets) -- supervisor can broadcast shutdown message - - component apps (orb-core, update-agent) listen for broadcast and shutdown -- supervisor can update SMD **through sub-process** -- supervisor can display front LED patterns -- IPC (InterProcess-Communication) client library supporting defaults for process shutdown handlers - - Setup the bidirectional communication + the listener for broadcast messages - -### Immediate follow-up release -- supervisor can play sounds -- supervisor can engage in bi-directional communication for signup permission with orb-core; orb-core must not run a signup if... - - an update is scheduled; - - the device is shutting down; - - the SSD is full (coordinate with @AI on signup extensions); -- fan-controller PoC - - spin fans up/down depending on temperature/temperature-analogs - - watch iops/sec on NVMe as an indicator of SSD temperature (can be replaced by reading out SMART data after kernel 5.10 is deployed) -- supervisor can update SMD **through nvidia-smd crate** - - Implement an Nvidia SMD parser as a crate (other people may want this) - -## Why this is necessary - -There are two reasons that make the orb supervisor necessary: - -1. Managing device health (heat, updates) -1. Consistent UX (updates w/ voice, LEDs) -1. Separation of concerns - -### Managing device health - -Device health must be ensured at all times, whether the device is updating or in the middle of a signup. Furthermore, you want this to be maximally isolated to avoid a scenario where, through a vulnerability in a monolithic application, an attacker acquires fan control and overheats the device. - -> **Scenario**: _A non-security critical update is running in the background and writing large blobs of data to the NVMe SSD_ while _orb-core is running and signups are being performed. An attacker uses a vulnerability in the QR code processing to deadlock a thread. They then proceed to garble the incoming network traffic causing the download to be repeatedly retried and data to be constantly written to the SSD while thermal management is stuck in the blocked runtime. This can feasibly fry an Orb._ - -### Consistent UX - -By necessity, the update agent service must have heightened privileges. Under no circumstances can we extend these to the entire orb-core process. At the same time, the operator must receive feedback on the status of an update. For certain updates, orb-core will not run during the update. In this scenario there is currently no mechanism to give feedback to the operator. - -Thus, an independent service that owns UX is a necessary condition for operator feedback. - -### Seperation of concerns - -Breaking components down allows us to: - -+ Reduce attack surfaces by restricting the responsibilities of privileged services; -+ Employ best patterns for the job (a fan monitoring service looks different from an update agent looks different from orb core); -+ Reduce engineering load (understanding a 500 LoC binary and finding bugs _is_ easier than in a 10k LoC monolith); -+ Running integration tests is significantly easier outside of complex runtimes. - -It is best industry practice to write dedicated services *where possible*, where coupling is low and where solutions already exist. This applies especially on a full Linux host and will reduce engineering load. - -## Relevant components - -+ update agent -+ fan monitor & control -+ wifi management -+ UX controller, split into: - + Sound - + LED -+ library for basic and repeatable "component" diff --git a/PROCESS.md b/orb-supervisor/PROCESS.md similarity index 100% rename from PROCESS.md rename to orb-supervisor/PROCESS.md diff --git a/orb-supervisor/README.md b/orb-supervisor/README.md index c570df68..24055bbc 100644 --- a/orb-supervisor/README.md +++ b/orb-supervisor/README.md @@ -1,23 +1,77 @@ -# Building +# Orb Supervisor -To build this crate and run it on the orb, you need to have `zig` installed. -For example through the Arch Linux package manager: +Orb supervisor is a central IPC server that coordinates device state and external UX across independent agents (binaries/processes). -```shell -# pacman -S zig -``` +## Table of Contents -```shell -$ rustup target add aarch64-unknown-linux-gnu -$ cargo install cargo-zigbuild -$ cargo zigbuild --release --target aarch64-unknown-linux-gnu -p orb-supervisor -``` +- Minimal viable product (MVP) +- Why (this is necessary) + - Managing device health + - Consistent UX + - Seperation of concerns +- Relevant components -# Running tests +## MVP -Integration tests are spawned with telemetry, but logs are by default suppressed. To enable logs -in tests run with: +### Initial release -```sh -$ TEST_LOG=1 cargo test -``` +- supervisor running [tonic gRPC](https://github.com/hyperium/tonic) over UDS (Unix Domain Sockets) +- supervisor can broadcast shutdown message + - component apps (orb-core, update-agent) listen for broadcast and shutdown +- supervisor can update SMD **through sub-process** +- supervisor can display front LED patterns +- IPC (InterProcess-Communication) client library supporting defaults for process shutdown handlers + - Setup the bidirectional communication + the listener for broadcast messages + +### Immediate follow-up release +- supervisor can play sounds +- supervisor can engage in bi-directional communication for signup permission with orb-core; orb-core must not run a signup if... + - an update is scheduled; + - the device is shutting down; + - the SSD is full (coordinate with @AI on signup extensions); +- fan-controller PoC + - spin fans up/down depending on temperature/temperature-analogs + - watch iops/sec on NVMe as an indicator of SSD temperature (can be replaced by reading out SMART data after kernel 5.10 is deployed) +- supervisor can update SMD **through nvidia-smd crate** + - Implement an Nvidia SMD parser as a crate (other people may want this) + +## Why this is necessary + +There are two reasons that make the orb supervisor necessary: + +1. Managing device health (heat, updates) +1. Consistent UX (updates w/ voice, LEDs) +1. Separation of concerns + +### Managing device health + +Device health must be ensured at all times, whether the device is updating or in the middle of a signup. Furthermore, you want this to be maximally isolated to avoid a scenario where, through a vulnerability in a monolithic application, an attacker acquires fan control and overheats the device. + +> **Scenario**: _A non-security critical update is running in the background and writing large blobs of data to the NVMe SSD_ while _orb-core is running and signups are being performed. An attacker uses a vulnerability in the QR code processing to deadlock a thread. They then proceed to garble the incoming network traffic causing the download to be repeatedly retried and data to be constantly written to the SSD while thermal management is stuck in the blocked runtime. This can feasibly fry an Orb._ + +### Consistent UX + +By necessity, the update agent service must have heightened privileges. Under no circumstances can we extend these to the entire orb-core process. At the same time, the operator must receive feedback on the status of an update. For certain updates, orb-core will not run during the update. In this scenario there is currently no mechanism to give feedback to the operator. + +Thus, an independent service that owns UX is a necessary condition for operator feedback. + +### Seperation of concerns + +Breaking components down allows us to: + ++ Reduce attack surfaces by restricting the responsibilities of privileged services; ++ Employ best patterns for the job (a fan monitoring service looks different from an update agent looks different from orb core); ++ Reduce engineering load (understanding a 500 LoC binary and finding bugs _is_ easier than in a 10k LoC monolith); ++ Running integration tests is significantly easier outside of complex runtimes. + +It is best industry practice to write dedicated services *where possible*, where coupling is low and where solutions already exist. This applies especially on a full Linux host and will reduce engineering load. + +## Relevant components + ++ update agent ++ fan monitor & control ++ wifi management ++ UX controller, split into: + + Sound + + LED ++ library for basic and repeatable "component" diff --git a/rust-toolchain.toml b/rust-toolchain.toml deleted file mode 100644 index 0e4f5ad2..00000000 --- a/rust-toolchain.toml +++ /dev/null @@ -1,5 +0,0 @@ -[toolchain] -channel = "1.78.0" -targets = ["aarch64-unknown-linux-gnu"] -profile = "minimal" -components = ["clippy", "llvm-tools-preview", "rustfmt", "rust-src", "rust-analyzer"] diff --git a/rustfmt.toml b/rustfmt.toml deleted file mode 100644 index 3365f946..00000000 --- a/rustfmt.toml +++ /dev/null @@ -1,2 +0,0 @@ -max_width = 88 # From python's black -newline_style = "Unix"