diff --git a/Cargo.lock b/Cargo.lock index 59ca9dc8..3dd148c8 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1035,6 +1035,26 @@ version = "0.9.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "28c122c3980598d243d63d9a704629a2d748d101f278052ff068be5a4423ab6f" +[[package]] +name = "const_format" +version = "0.2.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e3a214c7af3d04997541b18d432afaff4c455e79e2029079647e72fc2bd27673" +dependencies = [ + "const_format_proc_macros", +] + +[[package]] +name = "const_format_proc_macros" +version = "0.2.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c7f6ff08fd20f4f299298a28e2dfa8a8ba1036e6cd2460ac1de7b425d76f2500" +dependencies = [ + "proc-macro2", + "quote", + "unicode-xid", +] + [[package]] name = "constant_time_eq" version = "0.3.0" @@ -2494,6 +2514,7 @@ dependencies = [ "clap", "config", "console-subscriber", + "const_format", "criterion", "crossbeam", "daemonize", diff --git a/Cargo.toml b/Cargo.toml index d22f0536..0035ea79 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -76,6 +76,7 @@ lto = true debug-assertions = false [profile.release.package.homestar-runtime] +# Will slow-down compile, but improve perf on generated code. codegen-units = 1 debug-assertions = false @@ -87,6 +88,7 @@ debug-assertions = false # Example: `cargo build -p homestar-functions-test --target wasm32-unknown-unknown --profile release-wasm-fn` [profile.release-wasm-fn] inherits = "release" +# Will slow-down compile, but improve perf on generated code. codegen-units = 1 # Tell `rustc` to optimize for small code size. opt-level = "z" # 'z' to optimize "aggressively" for size diff --git a/DEVELOPMENT.md b/DEVELOPMENT.md index 072e8502..63d6d571 100644 --- a/DEVELOPMENT.md +++ b/DEVELOPMENT.md @@ -2,6 +2,7 @@ ## Outline +- [Building and Running the Project](#building-and-running-the-project) - [Testing the Project](#testing-the-project) - [Running the Runtime on Docker](#running-the-runtime-on-docker) - [Nix](#nix) @@ -10,18 +11,51 @@ - [Recommended Development Flow](#recommended-development-flow) - [Conventional Commits](#conventional-commits) +## Building and Running the Project + +- Building `homestar`: + + For the fastest compile-times and prettiest logs while developing `homestar`, + build with: + + ``` console + cargo build --no-default-features --features dev + ``` + + This removes underlying `wasmtime` `zstd` compression while also turning on + ANSI color-coded logs. If you bulid with default features, `zstd` compression + and other `wasmtime` defaults will be included in the build. + +- Running the `homestar` server/runtime: + + ``` console + cargo run --no-default-features --features dev -- start + ``` + +- Running alongside [`tokio-console`][tokio-console] for diagnosis and debugging: + + ``` console + cargo run --no-default-features --features dev,console -- start + ``` + + Then, in another window: + + ```console + tokio-console --retain-for 60sec + ``` + ## Testing the Project - Running the tests: -We recommend using [cargo nextest][cargo-nextest], which is installed by default -in our [Nix flake](#nix) or can be [installed separately][cargo-nextest-install]. + We recommend using [cargo nextest][cargo-nextest], which is installed by default + in our [Nix flake](#nix) or can be [installed separately][cargo-nextest-install]. ```console cargo nextest run --all-features --no-capture ``` -The above command translates to this using the default `cargo test`: + The above command translates to this using the default `cargo test`: ```console cargo test --all-features -- --nocapture @@ -139,4 +173,5 @@ a type of `fix`, `feat`, `docs`, `ci`, `refactor`, etc..., structured like so: [nix]:https://nixos.org/download.html [nix-flake]: https://nixos.wiki/wiki/Flakes [pre-commit]: https://pre-commit.com/ +[tokio-console]: https://github.com/tokio-rs/console [wit-bindgen]: https://github.com/bytecodealliance/wit-bindgen diff --git a/README.md b/README.md index 345c2fdb..cf9a4a01 100644 --- a/README.md +++ b/README.md @@ -102,7 +102,7 @@ Our current list includes: - [websocket relay](./examples/websocket-relay/README.md) - An example (browser-based) application that connects to the `homestar-runtime` over a - websocket connection in order to run a couple static Wasm-based, image + WebSocket connection in order to run a couple static Wasm-based, image processing workflows that chain inputs and outputs. ## Workspace @@ -176,7 +176,6 @@ We would be happy to try to answer your question or try opening a new issue on G - [IPVM - IPFS and WASM][ipfs-thing-ipvm] by Brooklyn Zelenka - [Breaking Down the Interplanetary Virtual Machine][blog-1] - [Ucan Invocation Spec][ucan-invocation] -- [Wasm/Wit Demo - Februrary 2023][demo-1] by Zeeshan Lakhani ## License diff --git a/examples/README.md b/examples/README.md index b0766833..a99ab3fc 100644 --- a/examples/README.md +++ b/examples/README.md @@ -5,7 +5,7 @@ and the `homestar runtime`. Each example is set up as its own crate, demonstrating the necessary dependencies and setup(s). * [websocket relay](./websocket-relay) - An example (browser-based) application - that connects to the `homestar-runtime` over a websocket connection in order + that connects to the `homestar-runtime` over a WebSocket connection in order to run a couple static Wasm-based, image processing workflows that chain inputs and outputs using [inlined promises][pipelines]. diff --git a/examples/websocket-relay/example_test.wasm b/examples/websocket-relay/example_test.wasm index 0d0e7528..15306f11 100755 Binary files a/examples/websocket-relay/example_test.wasm and b/examples/websocket-relay/example_test.wasm differ diff --git a/examples/websocket-relay/relay-app/src/lib/workflow.ts b/examples/websocket-relay/relay-app/src/lib/workflow.ts index d362620e..f71e7448 100644 --- a/examples/websocket-relay/relay-app/src/lib/workflow.ts +++ b/examples/websocket-relay/relay-app/src/lib/workflow.ts @@ -256,7 +256,7 @@ export const workflowOnePromised = WorkflowBuilder.workflow({ WorkflowBuilder.crop({ name: "crop", resource: - "ipfs://bafybeiczefaiu7464ehupezpzulnti5jvcwnvdalqrdliugnnwcdz6ljia", + "ipfs://bafybeig6u35v6t3f4j3zgz2jvj4erd45fbkeolioaddu3lmu6uxm3ilb7a", args: { data: "{{ cid:bafybeiejevluvtoevgk66plh5t6xiy3ikyuuxg3vgofuvpeckb6eadresm }}", x: 150, @@ -268,7 +268,7 @@ export const workflowOnePromised = WorkflowBuilder.workflow({ WorkflowBuilder.rotate90({ name: "rotate90", resource: - "ipfs://bafybeiczefaiu7464ehupezpzulnti5jvcwnvdalqrdliugnnwcdz6ljia", + "ipfs://bafybeig6u35v6t3f4j3zgz2jvj4erd45fbkeolioaddu3lmu6uxm3ilb7a", args: { data: "{{needs.crop.output}}", }, @@ -276,7 +276,7 @@ export const workflowOnePromised = WorkflowBuilder.workflow({ WorkflowBuilder.blur({ name: "blur", resource: - "ipfs://bafybeiczefaiu7464ehupezpzulnti5jvcwnvdalqrdliugnnwcdz6ljia", + "ipfs://bafybeig6u35v6t3f4j3zgz2jvj4erd45fbkeolioaddu3lmu6uxm3ilb7a", args: { data: "{{needs.rotate90.output}}", sigma: 20.2, @@ -293,7 +293,7 @@ export const workflowTwoPromised = WorkflowBuilder.workflow({ WorkflowBuilder.crop({ name: "crop", resource: - "ipfs://bafybeiczefaiu7464ehupezpzulnti5jvcwnvdalqrdliugnnwcdz6ljia", + "ipfs://bafybeig6u35v6t3f4j3zgz2jvj4erd45fbkeolioaddu3lmu6uxm3ilb7a", args: { data: "{{ cid:bafybeiejevluvtoevgk66plh5t6xiy3ikyuuxg3vgofuvpeckb6eadresm }}", x: 150, @@ -305,7 +305,7 @@ export const workflowTwoPromised = WorkflowBuilder.workflow({ WorkflowBuilder.rotate90({ name: "rotate90", resource: - "ipfs://bafybeiczefaiu7464ehupezpzulnti5jvcwnvdalqrdliugnnwcdz6ljia", + "ipfs://bafybeig6u35v6t3f4j3zgz2jvj4erd45fbkeolioaddu3lmu6uxm3ilb7a", args: { data: "{{needs.crop.output}}", }, @@ -313,7 +313,7 @@ export const workflowTwoPromised = WorkflowBuilder.workflow({ WorkflowBuilder.grayscale({ name: "grayscale", resource: - "ipfs://bafybeiczefaiu7464ehupezpzulnti5jvcwnvdalqrdliugnnwcdz6ljia", + "ipfs://bafybeig6u35v6t3f4j3zgz2jvj4erd45fbkeolioaddu3lmu6uxm3ilb7a", args: { data: "{{needs.rotate90.output}}", }, diff --git a/examples/websocket-relay/src/main.rs b/examples/websocket-relay/src/main.rs index d5b00051..b17d847a 100644 --- a/examples/websocket-relay/src/main.rs +++ b/examples/websocket-relay/src/main.rs @@ -16,18 +16,11 @@ fn main() -> Result<()> { // daemon. Typically, these would be started separately. let ipfs_daemon = ipfs_setup(); - info!( - subject = "settings", - category = "homestar_init", - "starting with settings: {:?}", - settings, - ); + info!("starting with settings: {:?}", settings,); let db = Db::setup_connection_pool(settings.node(), None).expect("to setup database pool"); info!( - subject = "database", - category = "homestar_init", "starting with database: {}", Db::url().expect("database url to be provided"), ); diff --git a/flake.lock b/flake.lock index 4c33b930..685d0257 100644 --- a/flake.lock +++ b/flake.lock @@ -36,11 +36,11 @@ }, "nixpkgs": { "locked": { - "lastModified": 1699186365, - "narHash": "sha256-Pxrw5U8mBsL3NlrJ6q1KK1crzvSUcdfwb9083sKDrcU=", + "lastModified": 1701080425, + "narHash": "sha256-QUaQPXLMsgIWxY2JsbK2TlqKHtcbhf9BGpmn4ilAkrI=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "a0b3b06b7a82c965ae0bb1d59f6e386fe755001d", + "rev": "21ea9c80732bc4168ed38c5c2f1f4df37c57a6dd", "type": "github" }, "original": { @@ -68,11 +68,11 @@ ] }, "locked": { - "lastModified": 1699323235, - "narHash": "sha256-ZFRItRv0dDSzsfpqSjj9qWM/SA1kRrOk6R04qhBZuxM=", + "lastModified": 1701224160, + "narHash": "sha256-qnMmxNMKmd6Soel0cfauyMJ+LzuZbvmiDQPSIuTbQ+M=", "owner": "oxalica", "repo": "rust-overlay", - "rev": "8a9d6f544c08ee898c7f3761cc9587be7565db5e", + "rev": "4a080e26d55eaedb95ab1bf8eeaeb84149c10f12", "type": "github" }, "original": { diff --git a/flake.nix b/flake.nix index cbf11fa8..b7795159 100644 --- a/flake.nix +++ b/flake.nix @@ -57,7 +57,6 @@ cargo-expand cargo-nextest cargo-sort - cargo-spellcheck cargo-unused-features cargo-udeps cargo-watch @@ -101,7 +100,7 @@ devRunServer = pkgs.writeScriptBin "cargo-run-dev" '' #!${pkgs.stdenv.shell} - cargo run --no-default-features --features dev -- start -c homestar-runtime/config/settings.toml + cargo run --no-default-features --features dev -- start ''; doc = pkgs.writeScriptBin "doc" '' diff --git a/homestar-core/src/test_utils/workflow.rs b/homestar-core/src/test_utils/workflow.rs index 956cedc4..2c11f01e 100644 --- a/homestar-core/src/test_utils/workflow.rs +++ b/homestar-core/src/test_utils/workflow.rs @@ -19,7 +19,7 @@ use std::collections::BTreeMap; use url::Url; const RAW: u64 = 0x55; -const WASM_CID: &str = "bafybeiczefaiu7464ehupezpzulnti5jvcwnvdalqrdliugnnwcdz6ljia"; +const WASM_CID: &str = "bafybeig6u35v6t3f4j3zgz2jvj4erd45fbkeolioaddu3lmu6uxm3ilb7a"; type NonceBytes = Vec; diff --git a/homestar-core/src/workflow/instruction.rs b/homestar-core/src/workflow/instruction.rs index 991a4134..3c9c18d8 100644 --- a/homestar-core/src/workflow/instruction.rs +++ b/homestar-core/src/workflow/instruction.rs @@ -336,7 +336,7 @@ mod test { ( RESOURCE_KEY.into(), Ipld::String( - "ipfs://bafybeiczefaiu7464ehupezpzulnti5jvcwnvdalqrdliugnnwcdz6ljia".into() + "ipfs://bafybeig6u35v6t3f4j3zgz2jvj4erd45fbkeolioaddu3lmu6uxm3ilb7a".into() ) ), (OP_KEY.into(), Ipld::String("ipld/fun".to_string())), @@ -357,7 +357,7 @@ mod test { "func": "join-strings" }, "nnc": "", "op": "wasm/run", - "rsc": "ipfs://bafybeiczefaiu7464ehupezpzulnti5jvcwnvdalqrdliugnnwcdz6ljia"}); + "rsc": "ipfs://bafybeig6u35v6t3f4j3zgz2jvj4erd45fbkeolioaddu3lmu6uxm3ilb7a"}); let instruction = Instruction::::try_from(ipld.clone()).unwrap(); let instr_cid = instruction.to_cid().unwrap(); diff --git a/homestar-core/src/workflow/task.rs b/homestar-core/src/workflow/task.rs index 8bd6d914..02b35255 100644 --- a/homestar-core/src/workflow/task.rs +++ b/homestar-core/src/workflow/task.rs @@ -190,7 +190,7 @@ mod test { ( "rsc".into(), Ipld::String( - "ipfs://bafybeiczefaiu7464ehupezpzulnti5jvcwnvdalqrdliugnnwcdz6ljia".into(), + "ipfs://bafybeig6u35v6t3f4j3zgz2jvj4erd45fbkeolioaddu3lmu6uxm3ilb7a".into(), ), ), ("op".into(), Ipld::String("ipld/fun".to_string())), diff --git a/homestar-functions/test/src/lib.rs b/homestar-functions/test/src/lib.rs index 706aee9a..b4332144 100644 --- a/homestar-functions/test/src/lib.rs +++ b/homestar-functions/test/src/lib.rs @@ -6,7 +6,11 @@ wit_bindgen::generate!({ }); use base64::{engine::general_purpose, Engine}; -use std::io::Cursor; +use std::{ + collections::hash_map::DefaultHasher, + hash::{Hash, Hasher}, + io::Cursor, +}; pub struct Component; @@ -115,6 +119,12 @@ impl Guest for Component { .unwrap(); Self::rotate90(decoded) } + + fn hash(s: String) -> Vec { + let mut hash = DefaultHasher::new(); + s.hash(&mut hash); + hash.finish().to_be_bytes().to_vec() + } } #[cfg(test)] diff --git a/homestar-functions/test/wit/host.wit b/homestar-functions/test/wit/host.wit index cab94571..87cdb521 100644 --- a/homestar-functions/test/wit/host.wit +++ b/homestar-functions/test/wit/host.wit @@ -13,4 +13,5 @@ world test { export grayscale-base64: func(data: string) -> list export rotate90: func(data: list) -> list export rotate90-base64: func(data: string) -> list + export hash: func(data: string) -> list } diff --git a/homestar-runtime/Cargo.toml b/homestar-runtime/Cargo.toml index e991ca26..5588f3d6 100644 --- a/homestar-runtime/Cargo.toml +++ b/homestar-runtime/Cargo.toml @@ -54,6 +54,7 @@ config = { version = "0.13", default-features = false, features = ["toml"] } console-subscriber = { version = "0.2", default-features = false, features = [ "parking_lot", ], optional = true } +const_format = "0.2" crossbeam = "0.8" dagga = "0.2" dashmap = "5.5" @@ -218,7 +219,7 @@ wait-timeout = "0.2" [features] default = ["wasmtime-default", "ipfs", "monitoring", "websocket-notify"] -dev = ["ansi-logs", "console", "ipfs", "monitoring", "websocket-notify"] +dev = ["ansi-logs", "ipfs", "monitoring", "websocket-notify"] ansi-logs = ["tracing-logfmt/ansi_logs"] console = ["dep:console-subscriber"] ipfs = ["dep:ipfs-api", "dep:ipfs-api-backend-hyper"] diff --git a/homestar-runtime/src/event_handler/channel.rs b/homestar-runtime/src/channel.rs similarity index 93% rename from homestar-runtime/src/event_handler/channel.rs rename to homestar-runtime/src/channel.rs index 4eab0e24..d06eb361 100644 --- a/homestar-runtime/src/event_handler/channel.rs +++ b/homestar-runtime/src/channel.rs @@ -1,5 +1,5 @@ -//! Wrapper around [crossbeam::channel] and [flume::bounded] to provide common -//! interfaces for sync/async bounded and non-tokio "oneshot" channels. +//! Wrapper around [crossbeam::channel] and [flume] to provide common +//! interfaces for sync/async (un)bounded and non-tokio "oneshot" channels. use crossbeam::channel; diff --git a/homestar-runtime/src/cli/show.rs b/homestar-runtime/src/cli/show.rs index c631b539..d38bdd2d 100644 --- a/homestar-runtime/src/cli/show.rs +++ b/homestar-runtime/src/cli/show.rs @@ -1,3 +1,5 @@ +//! Styled, output response for console table. + use std::{ fmt, io::{self, Write}, diff --git a/homestar-runtime/src/db.rs b/homestar-runtime/src/db.rs index 02f14fc7..f8f06238 100644 --- a/homestar-runtime/src/db.rs +++ b/homestar-runtime/src/db.rs @@ -25,7 +25,6 @@ use tracing::info; pub mod schema; pub(crate) mod utils; -pub(crate) const ENV: &str = "DATABASE_URL"; const MIGRATIONS: EmbeddedMigrations = embed_migrations!("migrations/"); const PRAGMAS: &str = " PRAGMA journal_mode = WAL; -- better write-concurrency @@ -35,6 +34,9 @@ PRAGMA busy_timeout = 1000; -- sleep if the database is busy PRAGMA foreign_keys = ON; -- enforce foreign keys "; +/// Database environment variable. +pub(crate) const ENV: &str = "DATABASE_URL"; + /// A Sqlite connection [pool]. /// /// [pool]: r2d2::Pool @@ -92,7 +94,7 @@ pub trait Database: Send + Sync + Clone { fn setup(url: &str) -> Result { info!( subject = "database", - category = "homestar_init", + category = "homestar.init", "setting up database at {}, running migrations if needed", url ); @@ -211,6 +213,9 @@ pub trait Database: Send + Sync + Clone { } /// Store localized workflow cid and information, e.g. number of tasks. + /// + /// On conflicts, do nothing. + /// Otherwise, return the stored workflow. fn store_workflow( workflow: workflow::Stored, conn: &mut Connection, diff --git a/homestar-runtime/src/db/utils.rs b/homestar-runtime/src/db/utils.rs index 6dc7c64c..08d76e36 100644 --- a/homestar-runtime/src/db/utils.rs +++ b/homestar-runtime/src/db/utils.rs @@ -1,5 +1,8 @@ +//! Utility functions Database interaction. + use chrono::NaiveDateTime; +/// Trait for converting nanoseconds to a timestamp. pub(crate) trait Timestamp { fn timestamp_from_nanos(&self) -> Option; } diff --git a/homestar-runtime/src/event_handler.rs b/homestar-runtime/src/event_handler.rs index fdc6e9d9..8f4289a5 100644 --- a/homestar-runtime/src/event_handler.rs +++ b/homestar-runtime/src/event_handler.rs @@ -5,6 +5,7 @@ use crate::network::webserver::{self, notifier}; #[cfg(feature = "ipfs")] use crate::network::IpfsCli; use crate::{ + channel, db::Database, network::swarm::{ComposedBehaviour, PeerDiscoveryInfo, RequestResponseKey}, settings, @@ -22,7 +23,6 @@ use swarm_event::ResponseEvent; use tokio::{runtime::Handle, select}; pub(crate) mod cache; -pub mod channel; pub(crate) mod error; pub(crate) mod event; #[cfg(feature = "websocket-notify")] @@ -51,24 +51,45 @@ where #[cfg_attr(docsrs, doc(cfg(feature = "websocket-notify")))] #[allow(missing_debug_implementations, dead_code)] pub(crate) struct EventHandler { + /// Minimum number of peers required to receive a receipt. receipt_quorum: usize, + /// Minimum number of peers required to receive workflow information. workflow_quorum: usize, + /// Timeout for p2p provider requests. p2p_provider_timeout: Duration, + /// Accesible database instance. db: DB, + /// [libp2p::swarm::Swarm] swarm instance. swarm: Swarm, + /// [moka::future::Cache] instance, centered around retry logic. cache: Arc>, + /// [channel::AsyncChannelSender] for sending [Event]s to the [EventHandler]. sender: Arc>, + /// [channel::AsyncChannelReceiver] for receiving [Event]s from the [EventHandler]. receiver: channel::AsyncChannelReceiver, + /// [QueryId] to [RequestResponseKey] and [P2PSender] mapping. query_senders: FnvHashMap)>, + /// [PeerId] to [ConnectedPoint] connections mapping. connections: Connections, + /// [RequestId] to [RequestResponseKey] and [P2PSender] mapping. request_response_senders: FnvHashMap, + /// Rendezvous protocol configurations and state (cookies). rendezvous: Rendezvous, + /// Whether or not to enable pubsub. pubsub_enabled: bool, + /// [tokio::sync::broadcast::Sender] for websocket event + /// notification messages. ws_evt_sender: webserver::Notifier, + /// [tokio::sync::broadcast::Sender] for websocket workflow-related + /// notification messages. ws_workflow_sender: webserver::Notifier, + /// [libp2p::Multiaddr] addresses to dial. node_addresses: Vec, + /// [libp2p::Multiaddr] addresses to announce to the network. announce_addresses: Vec, + /// Maximum number of external-facing addresses to announce to the network. external_address_limit: u32, + /// Interval for polling cache for expired entries. poll_cache_interval: Duration, } @@ -76,22 +97,39 @@ pub(crate) struct EventHandler { #[cfg(not(feature = "websocket-notify"))] #[allow(missing_debug_implementations, dead_code)] pub(crate) struct EventHandler { + /// Minimum number of peers required to receive a receipt. receipt_quorum: usize, + /// Minimum number of peers required to receive workflow information. workflow_quorum: usize, + /// Timeout for p2p provider requests. p2p_provider_timeout: Duration, + /// Accesible database instance. db: DB, + /// [libp2p::swarm::Swarm] swarm instance. swarm: Swarm, + /// [moka::future::Cache] instance, centered around retry logic. cache: Arc>, + /// [channel::AsyncChannelReceiver] for receiving [Event]s from the [EventHandler]. sender: Arc>, + /// [channel::AsyncChannelReceiver] for receiving [Event]s from the [EventHandler]. receiver: channel::AsyncChannelReceiver, + /// [QueryId] to [RequestResponseKey] and [P2PSender] mapping. query_senders: FnvHashMap)>, + /// [PeerId] to [ConnectedPoint] connections mapping. connections: Connections, + /// [RequestId] to [RequestResponseKey] and [P2PSender] mapping. request_response_senders: FnvHashMap, + /// Rendezvous protocol configurations and state (cookies). rendezvous: Rendezvous, + /// Whether or not to enable pubsub. pubsub_enabled: bool, + /// [libp2p::Multiaddr] addresses to dial. node_addresses: Vec, + /// [libp2p::Multiaddr] addresses to announce to the network. announce_addresses: Vec, + /// Maximum number of external-facing addresses to announce to the network. external_address_limit: u32, + /// Interval for polling cache for expired entries. poll_cache_interval: Duration, } @@ -210,8 +248,8 @@ where self.sender.clone() } - /// [tokio::sync::broadcast::Sender] for sending messages through the - /// webSocket server to subscribers. + /// [tokio::sync::broadcast::Sender] for sending workflow-related messages + /// through the WebSocket server to subscribers. #[cfg(feature = "websocket-notify")] #[cfg_attr(docsrs, doc(cfg(feature = "websocket-notify")))] #[allow(dead_code)] @@ -219,7 +257,8 @@ where self.ws_workflow_sender.clone() } - /// TODO + /// [tokio::sync::broadcast::Sender] for sending event-related messages + /// through the WebSocket server to subscribers. #[cfg(feature = "websocket-notify")] #[cfg_attr(docsrs, doc(cfg(feature = "websocket-notify")))] #[allow(dead_code)] diff --git a/homestar-runtime/src/event_handler/cache.rs b/homestar-runtime/src/event_handler/cache.rs index a5227dad..a4fedb8b 100644 --- a/homestar-runtime/src/event_handler/cache.rs +++ b/homestar-runtime/src/event_handler/cache.rs @@ -1,3 +1,5 @@ +//! Event-handler cache for retry events. + use crate::{channel, event_handler::Event}; use libp2p::PeerId; use moka::{ @@ -24,6 +26,7 @@ impl ExpiryBase for Expiry { } } +/// A cache value, made-up of an expiration and data map. #[derive(Clone, Debug)] pub(crate) struct CacheValue { expiration: Duration, @@ -36,18 +39,21 @@ impl CacheValue { } } +/// Kinds of data to be stored in the cache. #[derive(Clone, Debug)] pub(crate) enum CacheData { Peer(PeerId), OnExpiration(DispatchEvent), } +/// Events to be dispatched on cache expiration. #[derive(Clone, Debug)] pub(crate) enum DispatchEvent { RegisterPeer, DiscoverPeers, } +/// Setup a cache with an eviction listener. pub(crate) fn setup_cache( sender: Arc>, ) -> Cache { diff --git a/homestar-runtime/src/event_handler/event.rs b/homestar-runtime/src/event_handler/event.rs index 8ab39f62..455e5c01 100644 --- a/homestar-runtime/src/event_handler/event.rs +++ b/homestar-runtime/src/event_handler/event.rs @@ -34,6 +34,8 @@ use std::{collections::HashSet, num::NonZeroUsize, sync::Arc}; use tokio::runtime::Handle; use tracing::{error, info, warn}; +const RENDEZVOUS_NAMESPACE: &str = "homestar"; + /// A [Receipt] captured (inner) event. #[allow(dead_code)] #[derive(Debug, Clone)] @@ -115,12 +117,10 @@ pub(crate) enum Event { RegisterPeer(PeerId), /// Discover peers from a rendezvous node. DiscoverPeers(PeerId), - /// TODO + /// Dynamically get listeners for the swarm. GetListeners(AsyncChannelSender>), } -const RENDEZVOUS_NAMESPACE: &str = "homestar"; - #[allow(unreachable_patterns)] impl Event { async fn handle_info(self, event_handler: &mut EventHandler) -> Result<()> @@ -132,7 +132,11 @@ impl Event { let _ = captured.publish_and_notify(event_handler); } Event::Shutdown(tx) => { - info!("event_handler server shutting down"); + info!( + subject = "shutdown", + category = "handle_event", + "event_handler server shutting down" + ); event_handler.shutdown().await; let _ = tx.send_async(()).await; } @@ -183,7 +187,12 @@ impl Event { } } Event::Providers(Err(err)) => { - error!("failed to find providers: {}", err); + info!( + subject = "libp2p.providers.err", + category = "handle_event", + err=?err, + "failed to find providers", + ); } Event::RegisterPeer(peer_id) => { if let Some(rendezvous_client) = event_handler @@ -199,6 +208,8 @@ impl Event { Some(event_handler.rendezvous.registration_ttl.as_secs()), ) { warn!( + subject = "libp2p.register.rendezvous.err", + category = "handle_event", peer_id = peer_id.to_string(), err = format!("{err}"), "failed to register with rendezvous peer" @@ -265,6 +276,14 @@ impl Captured { ) } + // short-circuit if no peers + // + // - don't send over gossip + // - don't store receipt or workflow info on DHT + if event_handler.connections.peers.is_empty() { + return Ok((self.receipt, invocation_receipt)); + } + if event_handler.pubsub_enabled { match event_handler.swarm.behaviour_mut().gossip_publish( pubsub::RECEIPTS_TOPIC, @@ -272,6 +291,8 @@ impl Captured { ) { Ok(msg_id) => { info!( + subject = "libp2p.gossip.publish", + category = "publish_event", cid = receipt_cid.to_string(), message_id = msg_id.to_string(), "message published on {} topic for receipt with cid: {receipt_cid}", @@ -292,8 +313,10 @@ impl Captured { } Err(err) => { warn!( - err=?err, + subject = "libp2p.gossip.publish.err", + category = "publish_event", cid = receipt_cid.to_string(), + err=?err, "message not published on {} topic for receipt", pubsub::RECEIPTS_TOPIC ) @@ -322,7 +345,12 @@ impl Captured { Record::new(instruction_bytes, receipt_bytes.to_vec()), receipt_quorum, ) - .map_err(|err| warn!(err=?err, "receipt not PUT on dht")); + .map_err(|err| { + warn!(subject = "libp2p.put_record.err", + category = "publish_event", + err=?err, + "receipt not PUT onto DHT") + }); Arc::make_mut(&mut self.workflow).increment_progress(receipt_cid); let workflow_cid_bytes = self.workflow.cid_as_bytes(); @@ -335,15 +363,27 @@ impl Captured { Record::new(workflow_cid_bytes, workflow_bytes), workflow_quorum, ) - .map_err(|err| warn!(err=?err, "workflow information not PUT on dht")); + .map_err(|err| { + warn!(subject = "libp2p.put_record.err", + category = "publish_event", + err=?err, + "workflow information not PUT onto DHT") + }); } else { error!( - "cannot convert workflow information {} to bytes", - self.workflow.cid() + subject = "libp2p.put_record.err", + category = "publish_event", + cid = self.workflow.cid().to_string(), + "cannot convert workflow information to bytes", ); } } else { - error!("cannot convert receipt {receipt_cid} to bytes"); + error!( + subject = "libp2p.put_record.err", + category = "publish_event", + cid = receipt_cid.to_string(), + "cannot convert receipt to bytes" + ); } Ok((self.receipt, invocation_receipt)) @@ -401,28 +441,35 @@ impl Replay { TopicMessage::CapturedReceipt(pubsub::Message::new(receipt.clone())), ) .map(|msg_id| { - info!(cid=receipt_cid, - message_id = msg_id.to_string(), - "message published on {} topic for receipt with cid: {receipt_cid}", - pubsub::RECEIPTS_TOPIC); - - #[cfg(feature = "websocket-notify")] - notification::emit_event( - event_handler.ws_evt_sender(), - EventNotificationTyp::SwarmNotification( - SwarmNotification::PublishedReceiptPubsub, - ), - btreemap! { - "cid" => receipt.cid().to_string(), - "ran" => receipt.ran().to_string() - }, - ); + info!( + subject = "libp2p.gossip.publish.replay", + category = "publish_event", + cid = receipt_cid, + message_id = msg_id.to_string(), + "message published on {} topic for receipt with cid: {receipt_cid}", + pubsub::RECEIPTS_TOPIC + ); + + #[cfg(feature = "websocket-notify")] + notification::emit_event( + event_handler.ws_evt_sender(), + EventNotificationTyp::SwarmNotification( + SwarmNotification::PublishedReceiptPubsub, + ), + btreemap! { + "cid" => receipt.cid().to_string(), + "ran" => receipt.ran().to_string() + }, + ); }) - .map_err( - |err| - warn!(err=?err, cid=receipt_cid, - "message not published on {} topic for receipt", pubsub::RECEIPTS_TOPIC), - ); + .map_err(|err| { + warn!( + subject = "libp2p.gossip.publish.replay.err", + category = "publish_event", + err=?err, + cid=receipt_cid, + "message not published on {} topic for receipt", pubsub::RECEIPTS_TOPIC) + }); }); } Ok(()) @@ -444,8 +491,6 @@ impl QueryRecord { DB: Database, { if event_handler.connections.peers.is_empty() { - info!("no connections to send request to"); - if let Some(sender) = self.sender { let _ = sender.send_async(ResponseEvent::NoPeersAvailable).await; } @@ -468,8 +513,6 @@ impl QueryRecord { DB: Database, { if event_handler.connections.peers.is_empty() { - info!("no connections to send request to"); - if let Some(sender) = self.sender { let _ = sender.send_async(ResponseEvent::NoPeersAvailable).await; } @@ -495,8 +538,6 @@ impl QueryRecord { DB: Database, { if event_handler.connections.peers.is_empty() { - info!("no connections to send request to"); - if let Some(sender) = self.sender { let _ = sender.send_async(ResponseEvent::NoPeersAvailable).await; } @@ -534,7 +575,10 @@ where #[cfg(not(feature = "ipfs"))] async fn handle_event(self, event_handler: &mut EventHandler) { if let Err(err) = self.handle_info(event_handler).await { - error!(error=?err, "error storing event") + error!(subject = "handle.err", + category = "handle_event", + error=?err, + "error storing event") } } @@ -551,37 +595,59 @@ where let handle = Handle::current(); let ipfs = ipfs.clone(); handle.spawn(async move { - if let Ok(bytes) = receipt.try_into() { - match ipfs.put_receipt_bytes(bytes).await { - Ok(put_cid) => { - info!(cid = put_cid, "IPLD DAG node stored"); - #[cfg(debug_assertions)] - debug_assert_eq!(put_cid, cid.to_string()); - } - Err(err) => { - error!(error=?err, cid=cid.to_string(), "failed to store IPLD DAG node"); + if let Ok(bytes) = receipt.try_into() { + match ipfs.put_receipt_bytes(bytes).await { + Ok(put_cid) => { + info!( + subject = "ipfs.put.receipt", + category = "handle_event", + cid = put_cid, + "IPLD DAG node stored" + ); + #[cfg(debug_assertions)] + debug_assert_eq!(put_cid, cid.to_string()); + } + Err(err) => { + warn!(subject = "ipfs.put.receipt.err", + category = "handle_event", + error=?err, + cid=cid.to_string(), + "failed to store IPLD DAG node"); + } } + } else { + warn!( + subject = "ipfs.put.receipt.err", + category = "handle_event", + cid = cid.to_string(), + "failed to convert receipt to bytes" + ); } - } else { - warn!(cid=cid.to_string(), "failed to convert receipt to bytes"); - } - }); + }); } - #[cfg(feature = "test-utils")] - info!(cid = cid.to_string(), "cid stored on the network"); } else { - error!("failed to store receipt"); + error!( + subject = "ipfs.put.receipt.err", + category = "handle_event", + "failed to capture receipt" + ); } } #[cfg(feature = "websocket-notify")] Event::ReplayReceipts(replay) => { if let Err(err) = replay.notify(event_handler) { - error!(error=?err, "error notifying receipts") + error!(subject = "replay.err", + category = "handle_event", + error=?err, + "error replaying and notifying receipts") } } event => { if let Err(err) = event.handle_info(event_handler).await { - error!(error=?err, "error storing event") + error!(subject = "event.err", + category = "handle_event", + error=?err, + "error storing event") } } } diff --git a/homestar-runtime/src/event_handler/notification.rs b/homestar-runtime/src/event_handler/notification.rs index 1d630d6d..f074c07c 100644 --- a/homestar-runtime/src/event_handler/notification.rs +++ b/homestar-runtime/src/event_handler/notification.rs @@ -1,3 +1,5 @@ +//! Evented notifications emitted to clients. + use crate::{ network::webserver::{ notifier::{self, Header, Message, Notifier, SubscriptionTyp}, @@ -16,8 +18,8 @@ use homestar_core::{ }; use libipld::{serde::from_ipld, Ipld}; use serde::{Deserialize, Serialize}; -use std::{collections::BTreeMap, str::FromStr}; -use tracing::{info, warn}; +use std::{collections::BTreeMap, fmt, str::FromStr}; +use tracing::{debug, warn}; pub(crate) mod receipt; pub(crate) mod swarm; @@ -39,9 +41,11 @@ pub(crate) fn emit_receipt( let notification = ReceiptNotification::with(invocation_receipt, receipt_cid, metadata.clone()); if let Ok(json) = notification.to_json() { - info!( + debug!( + subject = "notification.receipt", + category = "notification", cid = receipt_cid.to_string(), - "Sending receipt to websocket" + "emitting receipt to WebSocket" ); if let Some(ipld) = metadata { match (ipld.get(WORKFLOW_KEY), ipld.get(WORKFLOW_NAME_KEY)) { @@ -58,7 +62,12 @@ pub(crate) fn emit_receipt( } } } else { - warn!("Unable to serialize receipt as bytes: {receipt:?}"); + warn!( + subject = "notification.err", + category = "notification", + cid = receipt_cid.to_string(), + "unable to serialize receipt notification as bytes" + ); } } @@ -77,7 +86,12 @@ pub(crate) fn emit_event( if let Ok(json) = notification.to_json() { let _ = notifier.notify(Message::new(header, json)); } else { - warn!("Unable to serialize notification as bytes: {notification:?}"); + warn!( + subject = "notification.err", + category = "notification", + "unable to serialize event notification as bytes: {}", + notification.typ + ); } } @@ -153,6 +167,16 @@ pub(crate) enum EventNotificationTyp { SwarmNotification(SwarmNotification), } +impl fmt::Display for EventNotificationTyp { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + match self { + EventNotificationTyp::SwarmNotification(subtype) => { + write!(f, "swarm notification: {}", subtype) + } + } + } +} + impl DagJson for EventNotificationTyp where Ipld: From {} impl From for Ipld { diff --git a/homestar-runtime/src/event_handler/notification/receipt.rs b/homestar-runtime/src/event_handler/notification/receipt.rs index f2f222ec..8ca58583 100644 --- a/homestar-runtime/src/event_handler/notification/receipt.rs +++ b/homestar-runtime/src/event_handler/notification/receipt.rs @@ -1,23 +1,26 @@ +//! Notification receipts. + use homestar_core::{ipld::DagJson, workflow::Receipt}; use libipld::{ipld, Cid, Ipld}; -/// A [Receipt] that is sent out *just* for websocket notifications. +/// A [Receipt] that is sent out for websocket notifications. #[derive(Debug, Clone, PartialEq)] pub(crate) struct ReceiptNotification(Ipld); impl ReceiptNotification { - /// TODO + /// Obtain a reference to the inner [Ipld] value. #[allow(dead_code)] pub(crate) fn inner(&self) -> &Ipld { &self.0 } - /// TODO + /// Obtain ownership of the inner [Ipld] value. #[allow(dead_code)] pub(crate) fn into_inner(self) -> Ipld { self.0.to_owned() } + /// Create a new [ReceiptNotification]. pub(crate) fn with(receipt: Receipt, cid: Cid, metadata: Option) -> Self { let receipt: Ipld = receipt.into(); let data = ipld!({ diff --git a/homestar-runtime/src/event_handler/notification/swarm.rs b/homestar-runtime/src/event_handler/notification/swarm.rs index c2745bd2..d5aeda46 100644 --- a/homestar-runtime/src/event_handler/notification/swarm.rs +++ b/homestar-runtime/src/event_handler/notification/swarm.rs @@ -1,3 +1,7 @@ +// Notification types for [swarm] events. +// +// [swarm]: libp2p_swarm::Swarm + use anyhow::anyhow; use serde::{Deserialize, Serialize}; use std::{fmt, str::FromStr}; diff --git a/homestar-runtime/src/event_handler/swarm_event.rs b/homestar-runtime/src/event_handler/swarm_event.rs index a9ced8d0..a428ec55 100644 --- a/homestar-runtime/src/event_handler/swarm_event.rs +++ b/homestar-runtime/src/event_handler/swarm_event.rs @@ -61,9 +61,9 @@ const RENDEZVOUS_NAMESPACE: &str = "homestar"; pub(crate) enum ResponseEvent { /// Found [PeerRecord] on the DHT. Found(Result), - /// TODO + /// No peers available to network with on the DHT. NoPeersAvailable, - /// Found Providers/[PeerId]s on the DHT. + /// Found providers/[PeerId]s on the DHT. Providers(Result>), } @@ -115,17 +115,33 @@ async fn handle_swarm_event( SwarmEvent::Behaviour(ComposedEvent::Identify(identify_event)) => { match identify_event { identify::Event::Error { peer_id, error } => { - warn!(peer_id=peer_id.to_string(), err=?error, "error while attempting to identify the remote") + warn!(subject = "libp2p.identify.err", + category = "handle_swarm_event", + peer_id=peer_id.to_string(), + err=?error, + "error while attempting to identify the remote") } identify::Event::Sent { peer_id } => { - debug!(peer_id = peer_id.to_string(), "sent identify info to peer") + debug!( + subject = "libp2p.identify.sent", + category = "handle_swarm_event", + peer_id = peer_id.to_string(), + "sent identify info to peer" + ) } identify::Event::Received { peer_id, info } => { - debug!(peer_id=peer_id.to_string(), info=?info, "identify info received from peer"); + debug!(subject = "libp2p.identify.recv", + category = "handle_swarm_event", + peer_id=peer_id.to_string(), + info=?info, + "identify info received from peer"); // Ignore peers that do not use the Homestar protocol if info.protocol_version != HOMESTAR_PROTOCOL_VER { - info!(protocol_version=info.protocol_version, "peer was not using our homestar protocol version: {HOMESTAR_PROTOCOL_VER}"); + debug!(subject ="libp2p.identify.recv", + category="handle_swarm_event", + protocol_version=info.protocol_version, + "peer was not using our homestar protocol version: {HOMESTAR_PROTOCOL_VER}"); return; } @@ -145,7 +161,6 @@ async fn handle_swarm_event( .all(|proto| !proto.is_private()) // Identify observed a potentially valid external address that we weren't aware of. // Add it to the addresses we announce to other peers. - // TODO: have a set of _maybe_ external addresses that we validate with other peers first before adding it .then(|| event_handler.swarm.add_external_address(info.observed_addr)); } @@ -156,6 +171,8 @@ async fn handle_swarm_event( for addr in info.listen_addrs { behavior.kademlia.add_address(&peer_id, addr); debug!( + subject = "libp2p.identify.recv", + category = "handle_swarm_event", peer_id = peer_id.to_string(), "added identified node to kademlia routing table" ); @@ -177,6 +194,8 @@ async fn handle_swarm_event( Some(event_handler.rendezvous.registration_ttl.as_secs()), ) { warn!( + subject = "libp2p.identify.recv", + category = "handle_swarm_event", peer_id = peer_id.to_string(), err = format!("{err}"), "failed to register with rendezvous peer" @@ -194,6 +213,8 @@ async fn handle_swarm_event( } } identify::Event::Pushed { peer_id } => debug!( + subject = "libp2p.identify.pushed", + category = "handle_swarm_event", peer_id = peer_id.to_string(), "pushed identify info to peer" ), @@ -208,6 +229,8 @@ async fn handle_swarm_event( } => { if cookie.namespace() == Some(&Namespace::from_static(RENDEZVOUS_NAMESPACE)) { debug!( + subject = "libp2p.rendezvous.cli.discovered", + category = "handle_swarm_event", peer_id = rendezvous_node.to_string(), "received discovery from rendezvous server" ); @@ -222,7 +245,11 @@ async fn handle_swarm_event( // Skip dialing peers if at connected peers limit if connected_peers_count >= event_handler.connections.max_peers as usize { - warn!("peers discovered through rendezvous not dialed because max connected peers limit reached"); + debug!( + subject = "libp2p.rendezvous.cli.discovered", + category = "handle_swarm_event", + "peers discovered not dialed b/c max connected peers limit reached" + ); return; } @@ -263,14 +290,18 @@ async fn handle_swarm_event( ); } Err(err) => { - warn!(peer_id=peer_id.to_string(), err=?err, "failed to dial peer discovered through rendezvous"); + warn!(subject = "libp2p.rendezvous.cli.discovered.err", + category = "handle_swarm_event", + peer_id=peer_id.to_string(), + err=?err, + "failed to dial discovered peer"); } }; } else if !self_registration { - warn!( - peer_id=registration.record.peer_id().to_string(), - "peer discovered through rendezvous not dialed because the max connected peers limit was reached" - ) + debug!(subject = "libp2p.rendezvous.cli.discovered", + category = "handle_swarm_event", + peer_id=registration.record.peer_id().to_string(), + "peer discovered not dialed b/c the max connected peers limit was reached") } } @@ -298,22 +329,31 @@ async fn handle_swarm_event( .await; } else { // Do not dial peers that are not using our namespace - warn!(peer_id=rendezvous_node.to_string(), namespace=?cookie.namespace(), "rendezvous peer gave records from an unexpected namespace"); + debug!(subject = "libp2p.rendezvous.cli.discovered", + category = "handle_swarm_event", + peer_id=rendezvous_node.to_string(), + namespace=?cookie.namespace(), + "rendezvous peer gave records from an unexpected namespace"); } } rendezvous::client::Event::DiscoverFailed { rendezvous_node, error, .. - } => { - error!(peer_id=rendezvous_node.to_string(), err=?error, "failed to discover peers from rendezvous peer") - } + } => warn!(subject = "libp2p.rendezvous.cli.discovered.err", + category = "handle_swarm_event", + peer_id=rendezvous_node.to_string(), + err=?error, + "failed to discover peers"), + rendezvous::client::Event::Registered { rendezvous_node, ttl, .. } => { debug!( + subject = "libp2p.rendezvous.cli.registered", + category = "handle_swarm_event", peer_id = rendezvous_node.to_string(), ttl = ttl, "registered self with rendezvous node" @@ -344,7 +384,11 @@ async fn handle_swarm_event( error, .. } => { - error!(peer_id=rendezvous_node.to_string(), err=?error, "failed to register self with rendezvous peer") + warn!(subject = "libp2p.rendezvous.cli.registered", + category = "handle_swarm_event", + peer_id=rendezvous_node.to_string(), + err=?error, + "failed to register self with rendezvous peer") } rendezvous::client::Event::Expired { peer } => { // re-discover records from peer @@ -373,14 +417,22 @@ async fn handle_swarm_event( SwarmEvent::Behaviour(ComposedEvent::RendezvousServer(rendezvous_server_event)) => { match rendezvous_server_event { rendezvous::server::Event::DiscoverServed { enquirer, .. } => debug!( + subject = "libp2p.rendezvous.server.discover", + category = "handle_swarm_event", peer_id = enquirer.to_string(), "served rendezvous discover request to peer" ), rendezvous::server::Event::DiscoverNotServed { enquirer, error } => { - warn!(peer_id=enquirer.to_string(), err=?error, "did not serve rendezvous discover request") + warn!(subject = "libp2p.rendezvous.server.discover.err", + category = "handle_swarm_event", + peer_id=enquirer.to_string(), + err=?error, + "did not serve rendezvous discover request") } rendezvous::server::Event::PeerRegistered { peer, .. } => { debug!( + subject = "libp2p.rendezvous.server.peer_registered", + category = "handle_swarm_event", peer_id = peer.to_string(), "registered peer through rendezvous" ) @@ -390,10 +442,17 @@ async fn handle_swarm_event( namespace, error, } => { - warn!(peer_id=peer.to_string(), err=?error, namespace=?namespace, "did not register peer with rendezvous") + debug!(subject = "libp2p.rendezvous.server.peer_registered.err", + category = "handle_swarm_event", + peer_id=peer.to_string(), + err=?error, + namespace=?namespace, + "did not register peer with rendezvous") } rendezvous::server::Event::RegistrationExpired(registration) => { debug!( + subject = "libp2p.rendezvous.server.registration_expired", + category = "handle_swarm_event", peer_id = registration.record.peer_id().to_string(), "rendezvous peer registration expired on server" ) @@ -409,10 +468,11 @@ async fn handle_swarm_event( } => { let bytes: Vec = message.data; match pubsub::Message::::try_from(bytes) { - // TODO: dont fail blindly if we get a non receipt message Ok(msg) => { let receipt = msg.payload; info!( + subject = "libp2p.gossipsub.recv", + category = "handle_swarm_event", peer_id = propagation_source.to_string(), message_id = message_id.to_string(), "message received on receipts topic: {}", @@ -439,16 +499,19 @@ async fn handle_swarm_event( }, ); } - Err(err) => info!(err=?err, "cannot handle incoming gossipsub message"), + Err(err) => debug!(subject = "libp2p.gossipsub.err", + category = "handle_swarm_event", + err=?err, + "cannot handle incoming gossipsub message"), } } - gossipsub::Event::Subscribed { peer_id, topic } => { - debug!( - peer_id = peer_id.to_string(), - topic = topic.to_string(), - "subscribed to topic over gossipsub" - ) - } + gossipsub::Event::Subscribed { peer_id, topic } => debug!( + subject = "libp2p.gossipsub.subscribed", + category = "handle_swarm_event", + peer_id = peer_id.to_string(), + topic = topic.to_string(), + "subscribed to topic over gossipsub" + ), _ => {} }, @@ -458,9 +521,11 @@ async fn handle_swarm_event( .. })) => { match result { - QueryResult::Bootstrap(Ok(BootstrapOk { peer, .. })) => { - debug!("successfully bootstrapped peer: {peer}") - } + QueryResult::Bootstrap(Ok(BootstrapOk { peer, .. })) => debug!( + subject = "libp2p.kad.bootstrap", + category = "handle_swarm_event", + "successfully bootstrapped peer: {peer}" + ), QueryResult::GetProviders(Ok(GetProvidersOk::FoundProviders { key: _, providers, @@ -488,7 +553,10 @@ async fn handle_swarm_event( } QueryResult::GetProviders(Err(err)) => { - warn!(err=?err, "error retrieving outbound query providers"); + warn!(subject = "libp2p.kad.get_providers.err", + category = "handle_swarm_event", + err=?err, + "error retrieving outbound query providers"); let Some((_, sender)) = event_handler.query_senders.remove(&id) else { return; @@ -502,8 +570,11 @@ async fn handle_swarm_event( } QueryResult::GetRecord(Ok(GetRecordOk::FoundRecord(peer_record))) => { debug!( + subject = "libp2p.kad.get_record.err", + category = "handle_swarm_event", "found record {:#?}, published by {:?}", - peer_record.record.key, peer_record.record.publisher + peer_record.record.key, + peer_record.record.publisher ); match peer_record.found_record() { Ok(event) => { @@ -516,8 +587,10 @@ async fn handle_swarm_event( } } Err(err) => { - warn!(err=?err, "error retrieving record"); - + warn!(subject = "libp2p.kad.get_record.err", + category = "handle_swarm_event", + err=?err, + "error retrieving record"); let Some((_, sender)) = event_handler.query_senders.remove(&id) else { return; }; @@ -530,7 +603,10 @@ async fn handle_swarm_event( } QueryResult::GetRecord(Ok(_)) => {} QueryResult::GetRecord(Err(err)) => { - warn!(err=?err, "error retrieving record"); + warn!(subject = "libp2p.kad.get_record.err", + category = "handle_swarm_event", + err=?err, + "error retrieving record"); // Upon an error, attempt to find the record on the DHT via // a provider if it's a Workflow/Info one. @@ -562,42 +638,67 @@ async fn handle_swarm_event( )))) .await; } else { - warn!("not a valid provider record tag: {capsule_tag}",) + warn!( + subject = "libp2p.kad.req_resp.err", + category = "handle_swarm_event", + "not a valid provider record tag: {capsule_tag}", + ) } } - None => { - info!("No provider found for outbound query {id:?}") - } + None => debug!( + subject = "libp2p.kad.req_resp", + category = "handle_swarm_event", + "No provider found for outbound query {id:?}" + ), } } - QueryResult::PutRecord(Ok(PutRecordOk { key })) => { - debug!("successfully put record {key:#?}"); - } - QueryResult::PutRecord(Err(err)) => { - warn!("error putting record: {err}") - } + QueryResult::PutRecord(Ok(PutRecordOk { key })) => debug!( + subject = "libp2p.kad.put_record", + category = "handle_swarm_event", + "successfully put record {key:#?}" + ), + QueryResult::PutRecord(Err(err)) => warn!( + subject = "libp2p.kad.put_record.err", + category = "handle_swarm_event", + err=?err, + "error putting record"), QueryResult::StartProviding(Ok(AddProviderOk { key })) => { // Currently, we don't send anything to the channel, // once they key is provided. let _ = event_handler.query_senders.remove(&id); - debug!("successfully providing {key:#?}"); + debug!( + subject = "libp2p.kad.provide_record", + category = "handle_swarm_event", + "successfully providing {key:#?}" + ); } QueryResult::StartProviding(Err(err)) => { // Currently, we don't send anything to the channel, // once they key is provided. let _ = event_handler.query_senders.remove(&id); - warn!("error providing key: {:#?}", err.key()); + warn!( + subject = "libp2p.kad.provide_record.err", + category = "handle_swarm_event", + "error providing key: {:#?}", + err.key() + ); } _ => {} } } SwarmEvent::Behaviour(ComposedEvent::Kademlia(kad::Event::InboundRequest { request })) => { - debug!("kademlia inbound request received {request:?}") + debug!( + subject = "libp2p.kad.inbound_request", + category = "handle_swarm_event", + "kademlia inbound request received {request:?}" + ) } SwarmEvent::Behaviour(ComposedEvent::Kademlia(kad::Event::RoutingUpdated { peer, .. })) => { debug!( + subject = "libp2p.kad.routing", + category = "handle_swarm_event", peer = peer.to_string(), "kademlia routing table updated with peer" ) @@ -646,7 +747,11 @@ async fn handle_swarm_event( } } Err(err) => { - warn!(err=?err, cid=?cid, "error retrieving workflow info"); + warn!(subject = "libp2p.req_resp.err", + category = "handle_swarm_event", + err=?err, + cid=?cid, + "error retrieving workflow info"); let _ = event_handler .swarm @@ -687,11 +792,11 @@ async fn handle_swarm_event( let _ = sender.send_async(ResponseEvent::Found(Ok(event))).await; } Err(err) => { - warn!( - err=?err, - cid = key_cid.as_str(), - "error returning capsule for request_id: {request_id}" - ); + warn!(subject = "libp2p.req_resp.resp", + category = "handle_swarm_event", + err=?err, + cid = key_cid.as_str(), + "error returning capsule for request_id: {request_id}"); let _ = sender.send_async(ResponseEvent::Found(Err(err))).await; } @@ -702,7 +807,9 @@ async fn handle_swarm_event( }, SwarmEvent::Behaviour(ComposedEvent::Mdns(mdns::Event::Discovered(list))) => { for (peer_id, multiaddr) in list { - info!( + debug!( + subject = "libp2p.mdns.discovered", + category = "handle_swarm_event", peer_id = peer_id.to_string(), addr = multiaddr.to_string(), "mDNS discovered a new peer" @@ -717,9 +824,10 @@ async fn handle_swarm_event( .build(), ); } else { - warn!( - peer_id = peer_id.to_string(), - "peer discovered by mDNS not dialed because max connected peers limit reached" + debug!(subject = "libp2p.mdns.discovered", + category = "handle_swarm_event", + peer_id = peer_id.to_string(), + "peer discovered by mDNS not dialed because max connected peers limit reached" ) } } @@ -729,13 +837,17 @@ async fn handle_swarm_event( if let Some(mdns) = behaviour.mdns.as_ref() { for (peer_id, multiaddr) in list { - info!( + debug!( + subject = "libp2p.mdns.expired", + category = "handle_swarm_event", peer_id = peer_id.to_string(), "mDNS discover peer has expired" ); if mdns.has_node(&peer_id) { behaviour.kademlia.remove_address(&peer_id, &multiaddr); debug!( + subject = "libp2p.mdns.expired", + category = "handle_swarm_event", peer_id = peer_id.to_string(), "removed peer address from kademlia table" ); @@ -747,8 +859,11 @@ async fn handle_swarm_event( let local_peer = *event_handler.swarm.local_peer_id(); info!( + subject = "libp2p.listen.addr", + category = "handle_swarm_event", peer_id = local_peer.to_string(), - "local node is listening on {}", address + "local node is listening on {}", + address ); #[cfg(feature = "websocket-notify")] @@ -765,7 +880,12 @@ async fn handle_swarm_event( SwarmEvent::ConnectionEstablished { peer_id, endpoint, .. } => { - debug!(peer_id=peer_id.to_string(), endpoint=?endpoint, "peer connection established"); + debug!(subject = "libp2p.conn.established", + category = "handle_swarm_event", + peer_id=peer_id.to_string(), + endpoint=?endpoint, + "peer connection established"); + // add peer to connected peers list event_handler .connections @@ -789,6 +909,8 @@ async fn handle_swarm_event( .. } => { debug!( + subject = "libp2p.conn.closed", + category = "handle_swarm_event", peer_id = peer_id.to_string(), "peer connection closed, cause: {cause:#?}, endpoint: {endpoint:#?}" ); @@ -801,7 +923,11 @@ async fn handle_swarm_event( } else { // TODO: We may want to check the multiadress without relying on // the peer ID. This would give more flexibility when configuring nodes. - warn!("Configured peer must include a peer ID: {multiaddr}"); + warn!( + subject = "libp2p.conn.closed", + category = "handle_swarm_event", + "Configured peer must include a peer ID: {multiaddr}" + ); true } }) { @@ -812,6 +938,8 @@ async fn handle_swarm_event( .remove_peer(&peer_id); debug!( + subject = "libp2p.kad.remove", + category = "handle_swarm_event", peer_id = peer_id.to_string(), "removed peer from kademlia table" ); @@ -832,11 +960,12 @@ async fn handle_swarm_event( peer_id, error, } => { - error!( - peer_id=peer_id.map(|p| p.to_string()).unwrap_or_default(), - err=?error, - connection_id=?connection_id, - "outgoing connection error" + warn!(subject = "libp2p.outgoing.err", + category = "handle_swarm_event", + peer_id=peer_id.map(|p| p.to_string()).unwrap_or_default(), + err=?error, + connection_id=?connection_id, + "outgoing connection error" ); #[cfg(feature = "websocket-notify")] @@ -855,13 +984,13 @@ async fn handle_swarm_event( send_back_addr, error, } => { - error!( - err=?error, - connection_id=?connection_id, - local_address=local_addr.to_string(), - remote_address=send_back_addr.to_string(), - "incoming connection error" - ); + warn!(subject = "libp2p.incoming.err", + category = "handle_swarm_event", + err=?error, + connection_id=?connection_id, + local_address=local_addr.to_string(), + remote_address=send_back_addr.to_string(), + "incoming connection error"); #[cfg(feature = "websocket-notify")] notification::emit_event( @@ -873,13 +1002,31 @@ async fn handle_swarm_event( ); } SwarmEvent::ListenerError { listener_id, error } => { - error!(err=?error, listener_id=?listener_id, "listener error") + error!(subject = "libp2p.listener.err", + category = "handle_swarm_event", + err=?error, + listener_id=?listener_id, + "listener error") } SwarmEvent::Dialing { peer_id, .. } => match peer_id { - Some(id) => debug!(peer_id = id.to_string(), "dialing peer"), - None => debug!("dialing an unknown peer"), + Some(id) => { + debug!( + subject = "libp2p.dialing", + category = "handle_swarm_event", + peer_id = id.to_string(), + "dialing peer" + ) + } + None => debug!( + subject = "libp2p.dialing", + category = "handle_swarm_event", + "dialing an unknown peer" + ), }, - e => debug!(e=?e, "uncaught event"), + e => debug!(subject = "libp2p.event", + category = "handle_swarm_event", + e=?e, + "uncaught event"), } } @@ -915,10 +1062,7 @@ fn decode_capsule(key_cid: Cid, value: &Vec) -> Result { Ok(ipld) => Err(anyhow!( "decode mismatch: expected an Ipld map, got {ipld:#?}", )), - Err(err) => { - warn!(error=?err, "error deserializing record value"); - Err(anyhow!("error deserializing record value")) - } + Err(err) => Err(anyhow!("error deserializing record value: {err}")), } } diff --git a/homestar-runtime/src/lib.rs b/homestar-runtime/src/lib.rs index e6f84323..b81b5364 100644 --- a/homestar-runtime/src/lib.rs +++ b/homestar-runtime/src/lib.rs @@ -17,6 +17,7 @@ //! [homestar-core]: homestar_core //! [homestar-wasm]: homestar_wasm +pub mod channel; pub mod cli; pub mod daemon; pub mod db; @@ -37,12 +38,14 @@ pub mod workflow; pub mod test_utils; pub use db::Db; -pub use event_handler::channel; pub(crate) mod libp2p; pub use logger::*; pub(crate) mod metrics; +#[allow(unused_imports)] +pub(crate) use event_handler::EventHandler; pub use receipt::{Receipt, RECEIPT_TAG, VERSION_KEY}; pub use runner::Runner; +pub(crate) use scheduler::TaskScheduler; pub use settings::Settings; pub(crate) use worker::Worker; pub use workflow::WORKFLOW_TAG; diff --git a/homestar-runtime/src/libp2p/mod.rs b/homestar-runtime/src/libp2p/mod.rs index 8254556f..c2ac9fe1 100644 --- a/homestar-runtime/src/libp2p/mod.rs +++ b/homestar-runtime/src/libp2p/mod.rs @@ -1 +1,3 @@ +//! [libp2p] utilities. + pub(crate) mod multiaddr; diff --git a/homestar-runtime/src/libp2p/multiaddr.rs b/homestar-runtime/src/libp2p/multiaddr.rs index 894d7008..12f43531 100644 --- a/homestar-runtime/src/libp2p/multiaddr.rs +++ b/homestar-runtime/src/libp2p/multiaddr.rs @@ -1,5 +1,7 @@ +/// Multiaddr extension methods. use libp2p::{multiaddr::Protocol, Multiaddr, PeerId}; +/// [Multiaddr] extension trait. pub(crate) trait MultiaddrExt { fn peer_id(&self) -> Option; } diff --git a/homestar-runtime/src/main.rs b/homestar-runtime/src/main.rs index f9fce8f7..9639b3aa 100644 --- a/homestar-runtime/src/main.rs +++ b/homestar-runtime/src/main.rs @@ -37,7 +37,7 @@ fn main() -> Result<()> { info!( subject = "settings", - category = "homestar_init", + category = "homestar.init", "starting with settings: {:?}", settings, ); @@ -47,7 +47,7 @@ fn main() -> Result<()> { info!( subject = "database", - category = "homestar_init", + category = "homestar.init", "starting with database: {}", Db::url().expect("database url to be provided"), ); diff --git a/homestar-runtime/src/metrics.rs b/homestar-runtime/src/metrics.rs index e0b308e9..d5a3623a 100644 --- a/homestar-runtime/src/metrics.rs +++ b/homestar-runtime/src/metrics.rs @@ -11,6 +11,7 @@ mod exporter; mod node; /// Start metrics collection and setup scrape endpoint. +/// Also, spawn a task to collect process metrics at a regular interval. #[cfg(feature = "monitoring")] pub(crate) async fn start( monitor_settings: &settings::Monitoring, @@ -27,6 +28,7 @@ pub(crate) async fn start( Ok(metrics_hdl) } +/// Start metrics collection and setup scrape endpoint. #[cfg(not(feature = "monitoring"))] pub(crate) async fn start(network_settings: &settings::Network) -> Result { let metrics_hdl = exporter::setup_metrics_recorder(network_settings)?; diff --git a/homestar-runtime/src/network/error.rs b/homestar-runtime/src/network/error.rs index 10f18416..1e0319f1 100644 --- a/homestar-runtime/src/network/error.rs +++ b/homestar-runtime/src/network/error.rs @@ -1,3 +1,5 @@ +//! # Error types centered around the networking. + #[derive(thiserror::Error, Debug)] pub(crate) enum Error { #[error("pubsub error: {0}")] diff --git a/homestar-runtime/src/network/mod.rs b/homestar-runtime/src/network/mod.rs index 01a55a31..e47cb79e 100644 --- a/homestar-runtime/src/network/mod.rs +++ b/homestar-runtime/src/network/mod.rs @@ -1,9 +1,8 @@ -//! [libp2p], multi-use [http] and [websocket] server, and [ipfs] networking +//! [libp2p], multi-use [HTTP] and [WebSocket] server, and [ipfs] networking //! interfaces. //! -//! [libp2p]: libp2p -//! [http]: jsonrpsee::server -//! [websocket]: jsonrpsee::server +//! [HTTP]: jsonrpsee::server +//! [WebSocket]: jsonrpsee::server //! [ipfs]: ipfs_api pub(crate) mod error; diff --git a/homestar-runtime/src/network/pubsub/message.rs b/homestar-runtime/src/network/pubsub/message.rs index 841212b8..8153af05 100644 --- a/homestar-runtime/src/network/pubsub/message.rs +++ b/homestar-runtime/src/network/pubsub/message.rs @@ -1,3 +1,7 @@ +//! [Message] type for messages transmitted over [gossipsub]. +//! +//! [gossipsub]: libp2p::gossipsub + use anyhow::{anyhow, Result}; use homestar_core::workflow::Nonce; use libipld::{self, cbor::DagCborCodec, prelude::Codec, serde::from_ipld, Ipld}; diff --git a/homestar-runtime/src/network/rpc.rs b/homestar-runtime/src/network/rpc.rs index 667f1d9c..f260634f 100644 --- a/homestar-runtime/src/network/rpc.rs +++ b/homestar-runtime/src/network/rpc.rs @@ -1,4 +1,4 @@ -//! RPC server implementation. +//! CLI-focused RPC server implementation. use crate::{ channel::{AsyncChannel, AsyncChannelReceiver, AsyncChannelSender}, @@ -138,7 +138,9 @@ impl Interface for ServerHandler { }, _ = time::sleep_until(now + self.timeout) => { let s = format!("server timeout of {} ms reached", self.timeout.as_millis()); - info!("{s}"); + info!(subject = "rpc.timeout", + category = "rpc", + "{s}"); Err(Error::FailureToReceiveOnChannel(s)) } @@ -180,7 +182,12 @@ impl Server { tarpc::serde_transport::tcp::listen(self.addr, MessagePack::default).await?; listener.config_mut().max_frame_length(usize::MAX); - info!("RPC server listening on {}", self.addr); + info!( + subject = "rpc.spawn", + category = "rpc", + "RPC server listening on {}", + self.addr + ); // setup valved listener for cancellation let (exit, incoming) = Valved::new(listener); @@ -203,11 +210,16 @@ impl Server { select! { Ok(ServerMessage::GracefulShutdown(tx)) = self.receiver.recv_async() => { - info!("RPC server shutting down"); + info!(subject = "shutdown", + category = "homestar.shutdown", + "RPC server shutting down"); drop(exit); let _ = tx.send_async(()).await; } - _ = fut => warn!("RPC server exited unexpectedly"), + _ = fut => + warn!(subject = "rpc.spawn.err", + category = "rpc", + "RPC server exited unexpectedly"), } }); diff --git a/homestar-runtime/src/network/swarm.rs b/homestar-runtime/src/network/swarm.rs index ce638854..f25d332a 100644 --- a/homestar-runtime/src/network/swarm.rs +++ b/homestar-runtime/src/network/swarm.rs @@ -1,9 +1,6 @@ -#![allow(missing_docs)] - //! Sets up a [libp2p] [Swarm], containing the state of the network and the way //! it should behave. //! -//! [libp2p]: libp2p //! [Swarm]: libp2p::Swarm use crate::{ @@ -11,6 +8,7 @@ use crate::{ settings, Receipt, RECEIPT_TAG, WORKFLOW_TAG, }; use anyhow::{Context, Result}; +use const_format::formatcp; use enum_assoc::Assoc; use faststr::FastStr; use libp2p::{ @@ -32,7 +30,10 @@ use serde::{Deserialize, Serialize}; use std::fmt; use tracing::{info, warn}; -pub(crate) const HOMESTAR_PROTOCOL_VER: &str = "homestar/0.0.1"; +/// Homestar protocol version, shared among peers, tied to the homestar version. +pub(crate) const HOMESTAR_PROTOCOL_VER: &str = formatcp!("homestar/{VERSION}"); + +const VERSION: &str = env!("CARGO_PKG_VERSION"); /// Build a new [Swarm] with a given transport and a tokio executor. pub(crate) async fn new(settings: &settings::Network) -> Result> { @@ -42,7 +43,12 @@ pub(crate) async fn new(settings: &settings::Network) -> Result)), /// Acknowledgement of a [Workflow] run. AckWorkflow((Cid, FastStr)), - /// TODO + /// Message sent to the [Runner] to gather node information from the [EventHandler]. + /// + /// [Runner]: crate::Runner + /// [EventHandler]: crate::EventHandler GetNodeInfo, - /// TODO + /// Acknowledgement of a [Message::GetNodeInfo] request, receiving static and dynamic + /// node information. AckNodeInfo((StaticNodeInfo, DynamicNodeInfo)), } -/// WebSocket server fields. +/// Server fields. #[cfg(feature = "websocket-notify")] #[derive(Clone, Debug)] pub(crate) struct Server { - /// Address of the websocket server. + /// Address of the server. addr: SocketAddr, - /// TODO + /// Message buffer capacity for the server. capacity: usize, - /// TODO + /// Message sender for broadcasting internal events to clients connected to + /// to the server. evt_notifier: Notifier, - /// Message sender for broadcasting to clients connected to the - /// websocket server. + /// Message sender for broadcasting workflow-related events to clients + /// connected to to the server. workflow_msg_notifier: Notifier, - /// Receiver timeout for the websocket server. + /// Receiver timeout for the server when communicating with the [Runner]. + /// + /// [Runner]: crate::Runner receiver_timeout: Duration, - /// TODO + /// General timeout for the server. webserver_timeout: Duration, } +/// Server fields. #[cfg(not(feature = "websocket-notify"))] #[derive(Clone, Debug)] pub(crate) struct Server { - /// Address of the websocket server. + /// Address of the server. addr: SocketAddr, - /// TODO + /// Message buffer capacity for the server. capacity: usize, - /// Receiver timeout for the websocket server. + /// Receiver timeout for the server when communicating with the [Runner]. + /// + /// [Runner]: crate::Runner receiver_timeout: Duration, - /// TODO + /// General timeout for the server. webserver_timeout: Duration, } impl Server { /// Setup bounded, MPMC channel for runtime to send and received messages - /// through the websocket connection(s). + /// through the WebSocket connection(s). #[cfg(feature = "websocket-notify")] fn setup_channel( capacity: usize, @@ -111,6 +121,8 @@ impl Server { broadcast::channel(capacity) } + /// Set up a new [Server] instance, which simultaneously acts as both a + /// WebSocket and HTTP server. #[cfg(feature = "websocket-notify")] pub(crate) fn new(settings: &settings::Webserver) -> Result { let (evt_sender, _receiver) = Self::setup_channel(settings.websocket_capacity); @@ -136,6 +148,7 @@ impl Server { }) } + /// Set up a new [Server] instance, which only acts as an HTTP server. #[cfg(not(feature = "websocket-notify"))] pub(crate) fn new(settings: &settings::Webserver) -> Result { let host = IpAddr::from_str(&settings.host.to_string())?; @@ -157,7 +170,7 @@ impl Server { }) } - /// Start the websocket server. + /// Instantiates the [JsonRpc] module, and starts the server. #[cfg(feature = "websocket-notify")] pub(crate) async fn start( &self, @@ -176,7 +189,7 @@ impl Server { self.start_inner(module).await } - /// Start the websocket server. + /// Instantiates the [JsonRpc] module, and starts the server. #[cfg(not(feature = "websocket-notify"))] pub(crate) async fn start( &self, @@ -192,23 +205,29 @@ impl Server { self.start_inner(module).await } - /// Get websocket message sender for broadcasting messages to websocket + /// Return the WebSocket event sender for broadcasting messages to connected /// clients. #[cfg(feature = "websocket-notify")] pub(crate) fn evt_notifier(&self) -> Notifier { self.evt_notifier.clone() } - /// Get websocket message sender for broadcasting messages to websocket - /// clients. + /// Get WebSocket message sender for broadcasting workflow-related messages + /// to connected clients. #[cfg(feature = "websocket-notify")] pub(crate) fn workflow_msg_notifier(&self) -> Notifier { self.workflow_msg_notifier.clone() } + /// Shared start logic for both WebSocket and HTTP servers. async fn start_inner(&self, module: JsonRpc) -> Result { let addr = self.addr; - info!("webserver listening on {}", addr); + info!( + subject = "webserver.start", + category = "webserver", + "webserver listening on {}", + addr + ); let cors = CorsLayer::new() // Allow `POST` when accessing the resource diff --git a/homestar-runtime/src/network/webserver/listener.rs b/homestar-runtime/src/network/webserver/listener.rs index 47a37c7a..9423ce20 100644 --- a/homestar-runtime/src/network/webserver/listener.rs +++ b/homestar-runtime/src/network/webserver/listener.rs @@ -1,3 +1,5 @@ +//! Listener for incoming requests types. + use faststr::FastStr; use homestar_core::{ipld::DagJson, Workflow}; use homestar_wasm::io::Arg; @@ -5,7 +7,7 @@ use names::{Generator, Name}; use serde::{de, Deserialize, Deserializer, Serialize}; use serde_json::value::RawValue; -/// A [Workflow] run command via a websocket channel. +/// A [Workflow] run command via a WebSocket channel. /// /// Note: We leverage the [RawValue] type in order to use our [DagJson] /// implementation, which is not a direct [Deserialize] implementation. diff --git a/homestar-runtime/src/network/webserver/notifier.rs b/homestar-runtime/src/network/webserver/notifier.rs index dc7abd6a..b1ad4f86 100644 --- a/homestar-runtime/src/network/webserver/notifier.rs +++ b/homestar-runtime/src/network/webserver/notifier.rs @@ -6,7 +6,7 @@ use libipld::Cid; use std::{fmt, sync::Arc}; use tokio::sync::broadcast; -/// Type-wrapper for websocket sender. +/// Type-wrapper for WebSocket sender. #[derive(Debug)] pub(crate) struct Notifier(Arc>); @@ -37,7 +37,7 @@ where self.0 } - /// Send a message to all connected websocket clients. + /// Send a message to all connected WebSocket clients. pub(crate) fn notify(&self, msg: T) -> Result<()> { let _ = self.0.send(msg)?; Ok(()) @@ -52,7 +52,7 @@ pub(crate) enum SubscriptionTyp { Cid(Cid), } -/// A header for a message to be sent to a websocket client. +/// A header for a message to be sent to a WebSocket client. #[derive(Debug, Clone)] pub(crate) struct Header { pub(crate) subscription: SubscriptionTyp, @@ -69,7 +69,7 @@ impl Header { } } -/// A message to be sent to a websocket client, with a header and payload. +/// A message to be sent to a WebSocket client, with a header and payload. #[derive(Debug, Clone)] pub(crate) struct Message { pub(crate) header: Header, @@ -82,13 +82,13 @@ impl Message { Self { header, payload } } - /// TODO + /// Get a reference to the [Header] of a [Message]. #[allow(dead_code)] pub(crate) fn header(&self) -> &Header { &self.header } - /// TODO + /// Get a reference to the payload of a [Message]. #[allow(dead_code)] pub(crate) fn payload(&self) -> &[u8] { &self.payload diff --git a/homestar-runtime/src/network/webserver/rpc.rs b/homestar-runtime/src/network/webserver/rpc.rs index c56b3c65..c7c9502f 100644 --- a/homestar-runtime/src/network/webserver/rpc.rs +++ b/homestar-runtime/src/network/webserver/rpc.rs @@ -1,3 +1,5 @@ +//! JSON-RPC module for registering methods and subscriptions. + #[cfg(feature = "websocket-notify")] use super::notifier::{self, Header, Notifier, SubscriptionTyp}; #[allow(unused_imports)] @@ -37,7 +39,7 @@ use tokio_stream::wrappers::BroadcastStream; #[allow(unused_imports)] use tracing::warn; #[cfg(feature = "websocket-notify")] -use tracing::{debug, error, info}; +use tracing::{debug, error}; /// Health endpoint. pub(crate) const HEALTH_ENDPOINT: &str = "health"; @@ -56,7 +58,7 @@ pub(crate) const SUBSCRIBE_NETWORK_EVENTS_ENDPOINT: &str = "subscribe_network_ev #[cfg(feature = "websocket-notify")] pub(crate) const UNSUBSCRIBE_NETWORK_EVENTS_ENDPOINT: &str = "unsubscribe_network_events"; -/// TODO +/// Context needed for RPC methods. #[cfg(feature = "websocket-notify")] pub(crate) struct Context { metrics_hdl: PrometheusHandle, @@ -67,7 +69,7 @@ pub(crate) struct Context { workflow_listeners: Arc, (Cid, FastStr)>>, } -/// TODO +/// Context needed for RPC methods. #[allow(dead_code)] #[cfg(not(feature = "websocket-notify"))] pub(crate) struct Context { @@ -77,7 +79,7 @@ pub(crate) struct Context { } impl Context { - /// TODO + /// Create a new [Context] instance. #[cfg(feature = "websocket-notify")] #[cfg_attr(docsrs, doc(cfg(feature = "websocket-notify")))] pub(crate) fn new( @@ -97,7 +99,7 @@ impl Context { } } - /// TODO + /// Create a new [Context] instance. #[cfg(not(feature = "websocket-notify"))] pub(crate) fn new( metrics_hdl: PrometheusHandle, @@ -150,7 +152,12 @@ impl JsonRpc { Ok(serde_json::json!({ "healthy": true, "nodeInfo": { "static": static_info, "dynamic": dyn_info}})) } else { - warn!(sub = HEALTH_ENDPOINT, "did not acknowledge message in time"); + error!( + subject = "call.health", + category = "jsonrpc.call", + sub = HEALTH_ENDPOINT, + "did not acknowledge message in time" + ); Err(internal_err("failed to get node information".to_string())) } })?; @@ -229,7 +236,9 @@ impl JsonRpc { let stream = BroadcastStream::new(rx); Self::handle_workflow_subscription(sink, stream, ctx).await?; } else { - warn!( + error!( + subject = "subscription.workflow.err", + category = "jsonrpc.subscription", sub = SUBSCRIBE_RUN_WORKFLOW_ENDPOINT, workflow_name = name.to_string(), "did not acknowledge message in time" @@ -243,7 +252,10 @@ impl JsonRpc { } } Err(err) => { - warn!("failed to parse run workflow params: {}", err); + warn!(subject = "subscription.workflow.err", + category = "jsonrpc.subscription", + err=?err, + "failed to parse run workflow params"); let _ = pending.reject(err).await; } } @@ -278,7 +290,10 @@ impl JsonRpc { })) if evt == subscription_type => payload, Some(Ok(_)) => continue, Some(Err(err)) => { - error!("subscription stream error: {}", err); + error!(subject = "subscription.event.err", + category = "jsonrpc.subscription", + err=?err, + "subscription stream error"); break Err(err.into()); } None => break Ok(()), @@ -290,7 +305,9 @@ impl JsonRpc { break Err(anyhow!("subscription sink closed")); } Err(TrySendError::Full(_)) => { - info!("subscription sink full"); + error!(subject = "subscription.event.err", + category = "jsonrpc.subscription", + "subscription sink full"); } } } @@ -326,9 +343,11 @@ impl JsonRpc { .and_then(|v| { let (v_cid, v_name) = v.value(); if v_cid == &cid && (Some(v_name) == ident.as_ref() || ident.is_none()) { - debug!(cid = cid.to_string(), - ident = ident.clone().unwrap_or( - "undefined".into()).to_string(), "received message"); + debug!( + subject = "subscription.workflow", + category = "jsonrpc.subscription", + cid = cid.to_string(), + ident = ident.clone().unwrap_or("undefined".into()).to_string(), "received message"); Some(payload) } else { None @@ -359,7 +378,9 @@ impl JsonRpc { break Err(anyhow!("subscription sink closed")); } Err(TrySendError::Full(_)) => { - info!("subscription sink full"); + error!(subject = "subscription.workflow.err", + category = "jsonrpc.subscription", + "subscription sink full"); } } } diff --git a/homestar-runtime/src/receipt.rs b/homestar-runtime/src/receipt.rs index bf65fa35..c8dcd1f1 100644 --- a/homestar-runtime/src/receipt.rs +++ b/homestar-runtime/src/receipt.rs @@ -1,4 +1,7 @@ -//! Output of an invocation, referenced by its invocation pointer. +//! Runtime, extended representation of a [Receipt] for [Invocation]s and storage. +//! +//! [Receipt]: homestar_core::workflow::Receipt +//! [Invocation]: homestar_core::workflow::Invocation use anyhow::anyhow; use diesel::{ diff --git a/homestar-runtime/src/runner.rs b/homestar-runtime/src/runner.rs index ed6217a6..7c5470ab 100644 --- a/homestar-runtime/src/runner.rs +++ b/homestar-runtime/src/runner.rs @@ -38,7 +38,7 @@ use tokio::{ time, }; use tokio_util::time::{delay_queue, DelayQueue}; -use tracing::{error, info, warn}; +use tracing::{debug, error, info, warn}; mod error; pub(crate) mod file; @@ -74,13 +74,13 @@ pub(crate) type RpcReceiver = AsyncChannelReceiver<( Option>, )>; -/// [AsyncChannelSender] for sending messages websocket server clients. +/// [AsyncChannelSender] for sending messages WebSocket server clients. pub(crate) type WsSender = AsyncChannelSender<( webserver::Message, Option>, )>; -/// [AsyncChannelReceiver] for receiving messages from websocket server clients. +/// [AsyncChannelReceiver] for receiving messages from WebSocket server clients. pub(crate) type WsReceiver = AsyncChannelReceiver<( webserver::Message, Option>, @@ -129,7 +129,7 @@ impl Runner { } /// MPSC channel for sending and receiving messages through to/from - /// websocket server clients. + /// WebSocket server clients. pub(crate) fn setup_ws_mpsc_channel(capacity: usize) -> (WsSender, WsReceiver) { AsyncChannel::with(capacity) } @@ -262,21 +262,27 @@ impl Runner { Ok(ControlFlow::Break(())) => break now.elapsed(), Ok(ControlFlow::Continue(rpc::ServerMessage::Skip)) => {}, Ok(ControlFlow::Continue(msg @ rpc::ServerMessage::RunAck(_))) => { - info!("sending message to rpc server"); + debug!(subject = "rpc.ack", + category = "rpc", + "sending message to rpc server"); let _ = oneshot_tx.send_async(msg).await; }, Err(err) => { - error!(err=?err, "error handling rpc message"); + error!(subject = "rpc.err", + category = "rpc", + err=?err, + "error handling rpc message"); let _ = oneshot_tx.send_async(rpc::ServerMessage::RunErr(err.into())).await; }, _ => {} } } Ok(msg) = ws_receiver.recv_async() => { - println!("ws message: {:?}", msg); match msg { (webserver::Message::RunWorkflow((name, workflow)), Some(oneshot_tx)) => { - info!("running workflow: {}", name); + info!(subject = "workflow", + category = "workflow.run", + "running workflow: {}", name); // TODO: Parse this from the workflow data itself. let workflow_settings = workflow::Settings::default(); match self.run_worker( @@ -287,18 +293,25 @@ impl Runner { db.clone(), ).await { Ok(data) => { - info!("sending message to rpc server"); + debug!(subject = "jsonrpc.ack", + category = "jsonrpc", + "sending message to jsonrpc server"); let _ = oneshot_tx.send_async(webserver::Message::AckWorkflow((data.info.cid, data.name))).await; } Err(err) => { - error!(err=?err, "error handling ws message"); + error!(subject = "jsonrpc.err", + category = "jsonrpc", + err=?err, + "error handling ws message"); let _ = oneshot_tx.send_async(webserver::Message::RunErr(err.into())).await; } } } (webserver::Message::GetNodeInfo, Some(oneshot_tx)) => { - info!("getting node info"); + debug!(subject = "jsonrpc.nodeinfo", + category = "jsonrpc", + "getting node info"); let (tx, rx) = AsyncChannel::oneshot(); let _ = self.event_sender.send_async(Event::GetListeners(tx)).await; let dyn_node_info = if let Ok(listeners) = rx.recv_deadline(Instant::now() + self.settings.node.network.webserver.timeout) { @@ -331,12 +344,16 @@ impl Runner { Err(_) => Poll::Pending, } ) => { - info!("worker expired, aborting"); + info!(subject = "worker.expired", + category = "worker", + "worker expired, aborting"); let _ = self.abort_worker(*expired.get_ref()); }, // Handle shutdown signal. _ = Self::shutdown_signal() => { - info!("gracefully shutting down runner"); + info!(subject = "shutdown", + category = "homestar.shutdown", + "gracefully shutting down runner"); let now = time::Instant::now(); let drain_timeout = now + shutdown_timeout; @@ -347,7 +364,9 @@ impl Runner { }, // Force shutdown upon drain timeout. _ = time::sleep_until(drain_timeout) => { - info!("shutdown timeout reached, shutting down runner anyway"); + info!(subject = "shutdown", + category = "homestar.shutdown", + "shutdown timeout reached, shutting down runner anyway"); break now.elapsed(); } } @@ -360,7 +379,11 @@ impl Runner { if shutdown_time_left < shutdown_timeout { self.runtime .shutdown_timeout(shutdown_timeout - shutdown_time_left); - info!("runner shutdown complete"); + info!( + subject = "shutdown", + category = "homestar.shutdown", + "runner shutdown complete" + ); } Ok(()) @@ -488,9 +511,18 @@ impl Runner { let mut sigterm = signal(SignalKind::terminate())?; select! { - _ = tokio::signal::ctrl_c() => info!("CTRL-C received, shutting down"), - _ = sigint.recv() => info!("SIGINT received, shutting down"), - _ = sigterm.recv() => info!("SIGTERM received, shutting down"), + _ = tokio::signal::ctrl_c() => + info!(subject = "shutdown", + category = "homestar.shutdown", + "CTRL-C received, shutting down"), + _ = sigint.recv() => + info!(subject = "shutdown", + category = "homestar.shutdown", + "SIGINT received, shutting down"), + _ = sigterm.recv() => + info!(subject = "shutdown", + category = "homestar.shutdown", + "SIGTERM received, shutting down"), } Ok(()) } @@ -503,10 +535,22 @@ impl Runner { let mut sighup = windows::ctrl_break()?; select! { - _ = tokio::signal::ctrl_c() => info!("CTRL-C received, shutting down"), - _ = sigint.recv() => info!("SIGINT received, shutting down"), - _ = sigterm.recv() => info!("SIGTERM received, shutting down"), - _ = sighup.recv() => info!("SIGHUP received, shutting down") + _ = tokio::signal::ctrl_c() => + info!(subject = "shutdown", + category = "homestar.shutdown", + "CTRL-C received, shutting down"), + _ = sigint.recv() => + info!(subject = "shutdown", + category = "homestar.shutdown", + "SIGINT received, shutting down"), + _ = sigterm.recv() => + info!(subject = "shutdown", + category = "homestar.shutdown", + "SIGTERM received, shutting down"), + _ = sighup.recv() => + info!(subject = "shutdown", + category = "homestar.shutdown", + "SIGHUP received, shutting down") } Ok(()) } @@ -526,7 +570,11 @@ impl Runner { .await; let _ = shutdown_receiver; - info!("shutting down webserver"); + info!( + subject = "shutdown", + category = "homestar.shutdown", + "shutting down webserver" + ); let _ = ws_hdl.stop(); ws_hdl.clone().stopped().await; @@ -553,7 +601,11 @@ impl Runner { ) -> Result> { match msg { rpc::ServerMessage::ShutdownCmd => { - info!("RPC shutdown signal received, shutting down runner"); + info!( + subject = "rpc.command", + category = "rpc", + "RPC shutdown signal received, shutting down runner" + ); let drain_timeout = now + self.settings.node.shutdown_timeout; select! { // we can unwrap here b/c we know we have a sender based @@ -562,7 +614,9 @@ impl Runner { Ok(ControlFlow::Break(())) }, _ = time::sleep_until(drain_timeout) => { - info!("shutdown timeout reached, shutting down runner anyway"); + info!(subject = "shutdown", + category = "homestar.shutdown", + "shutdown timeout reached, shutting down runner anyway"); Ok(ControlFlow::Break(())) } } @@ -582,7 +636,12 @@ impl Runner { )))) } msg => { - warn!("received unexpected message: {:?}", msg); + warn!( + subject = "rpc.command", + category = "rpc", + "received unexpected message: {:?}", + msg + ); Ok(ControlFlow::Continue(rpc::ServerMessage::Skip)) } } @@ -619,8 +678,11 @@ impl Runner { // Spawn worker, which initializees the scheduler and runs // the workflow. info!( + subject = "workflow.run", + category = "workflow", cid = worker.workflow_info.cid.to_string(), - "running workflow with settings: {:#?}", worker.workflow_settings + "running workflow with settings: {:#?}", + worker.workflow_settings ); // Provide workflow to network. diff --git a/homestar-runtime/src/runner/nodeinfo.rs b/homestar-runtime/src/runner/nodeinfo.rs index 58e9484a..aa14be84 100644 --- a/homestar-runtime/src/runner/nodeinfo.rs +++ b/homestar-runtime/src/runner/nodeinfo.rs @@ -1,33 +1,38 @@ +//! Node information. + use libp2p::{Multiaddr, PeerId}; use serde::{Deserialize, Serialize}; -/// TODO +/// Static node information available at startup. #[derive(Debug, Clone, Serialize, Deserialize)] pub(crate) struct StaticNodeInfo { + /// The [PeerId] of a node. pub(crate) peer_id: PeerId, } impl StaticNodeInfo { - /// TODO + /// Create an instance of [StaticNodeInfo]. pub(crate) fn new(peer_id: PeerId) -> Self { Self { peer_id } } - /// TODO + /// Get a reference to the [PeerId] of a node. #[allow(dead_code)] pub(crate) fn peer_id(&self) -> &PeerId { &self.peer_id } } -/// TODO +/// Dynamic node information available through events +/// at runtime. #[derive(Debug, Clone, Serialize, Deserialize)] pub(crate) struct DynamicNodeInfo { + /// Listeners for the node. pub(crate) listeners: Vec, } impl DynamicNodeInfo { - /// TODO + /// Create an instance of [DynamicNodeInfo]. pub(crate) fn new(listeners: Vec) -> Self { Self { listeners } } diff --git a/homestar-runtime/src/runner/response.rs b/homestar-runtime/src/runner/response.rs index c6b8b781..8a5928c4 100644 --- a/homestar-runtime/src/runner/response.rs +++ b/homestar-runtime/src/runner/response.rs @@ -1,5 +1,5 @@ //! Responses for display/return to the user for -//! Client requests. +//! client requests. use crate::{ cli::show::{self, ApplyStyle}, diff --git a/homestar-runtime/src/scheduler.rs b/homestar-runtime/src/scheduler.rs index 1970bc0a..de364ee1 100644 --- a/homestar-runtime/src/scheduler.rs +++ b/homestar-runtime/src/scheduler.rs @@ -19,7 +19,7 @@ use indexmap::IndexMap; use libipld::Cid; use std::{ops::ControlFlow, str::FromStr, sync::Arc}; use tokio::sync::RwLock; -use tracing::info; +use tracing::debug; /// Type alias for a [Dag] set of batched nodes. /// @@ -150,7 +150,11 @@ impl<'a> TaskScheduler<'a> { } } Err(_) => { - info!("receipt not available in the database"); + debug!( + subject = "receipt.db.check", + category = "scheduler.run", + "receipt not available in the database" + ); continue; } } @@ -199,7 +203,9 @@ impl<'a> TaskScheduler<'a> { } } - /// TODO + /// Get the number of tasks that have already ran in the [Workflow]. + /// + /// [Workflow]: homestar_core::Workflow #[allow(dead_code)] pub(crate) fn ran_length(&self) -> usize { self.ran @@ -208,7 +214,9 @@ impl<'a> TaskScheduler<'a> { .unwrap_or_default() } - /// TODO + /// Get the number of tasks left to run in the [Workflow]. + /// + /// [Workflow]: homestar_core::Workflow #[allow(dead_code)] pub(crate) fn run_length(&self) -> usize { self.run.iter().flatten().collect::>().len() diff --git a/homestar-runtime/src/settings.rs b/homestar-runtime/src/settings.rs index f82c97ea..fb06d9a7 100644 --- a/homestar-runtime/src/settings.rs +++ b/homestar-runtime/src/settings.rs @@ -1,4 +1,4 @@ -//! Settings / Configuration. +//! General runtime settings / configuration. use config::{Config, ConfigError, Environment, File}; use http::Uri; @@ -162,7 +162,7 @@ pub(crate) struct Webserver { pub(crate) host: Uri, /// Webserver-server port. pub(crate) port: u16, - /// TODO + /// Webserver timeout. #[serde_as(as = "DurationSeconds")] pub(crate) timeout: Duration, /// Number of *bounded* clients to send messages to, used for a diff --git a/homestar-runtime/src/settings/libp2p_config.rs b/homestar-runtime/src/settings/libp2p_config.rs index b561cb4b..3df3aba9 100644 --- a/homestar-runtime/src/settings/libp2p_config.rs +++ b/homestar-runtime/src/settings/libp2p_config.rs @@ -1,4 +1,4 @@ -//! Libp2p setttings +//! [libp2p] configuration. use http::Uri; use serde::{Deserialize, Serialize}; diff --git a/homestar-runtime/src/settings/pubkey_config.rs b/homestar-runtime/src/settings/pubkey_config.rs index 171dcb87..a8c87ec6 100644 --- a/homestar-runtime/src/settings/pubkey_config.rs +++ b/homestar-runtime/src/settings/pubkey_config.rs @@ -1,3 +1,5 @@ +//! Pubkey configuration. + use anyhow::{anyhow, Context}; use libp2p::{identity, identity::secp256k1}; use rand::{Rng, SeedableRng}; @@ -54,7 +56,11 @@ impl PubkeyConfig { pub(crate) fn keypair(&self) -> anyhow::Result { match self { PubkeyConfig::Random => { - info!("generating random ed25519 key"); + info!( + subject = "pubkey_config.random", + category = "pubkey_config", + "generating random ed25519 key" + ); Ok(identity::Keypair::generate_ed25519()) } PubkeyConfig::GenerateFromSeed(RNGSeed { key_type, seed }) => { @@ -64,14 +70,22 @@ impl PubkeyConfig { match key_type { KeyType::Ed25519 => { - info!("generating random ed25519 key from seed"); + info!( + subject = "pubkey_config.random_seed.ed25519", + category = "pubkey_config", + "generating random ed25519 key from seed" + ); identity::Keypair::ed25519_from_bytes(new_key).map_err(|e| { anyhow!("failed to generate ed25519 key from random: {:?}", e) }) } KeyType::Secp256k1 => { - info!("generating random secp256k1 key from seed"); + info!( + subject = "pubkey_config.random_seed.secp256k1", + category = "pubkey_config", + "generating random secp256k1 key from seed" + ); let sk = secp256k1::SecretKey::try_from_bytes(&mut new_key).map_err(|e| { @@ -94,7 +108,12 @@ impl PubkeyConfig { KeyType::Ed25519 => { const PEM_HEADER: &str = "PRIVATE KEY"; - info!("importing ed25519 key from: {}", path.display()); + info!( + subject = "pubkey_config.path.ed25519", + category = "pubkey_config", + "importing ed25519 key from: {}", + path.display() + ); let (tag, mut key) = sec1::der::pem::decode_vec(&buf) .map_err(|e| anyhow!("key file must be PEM formatted: {:#?}", e))?; @@ -107,7 +126,12 @@ impl PubkeyConfig { .with_context(|| "imported key material was invalid for ed25519") } KeyType::Secp256k1 => { - info!("importing secp256k1 key from: {}", path.display()); + info!( + subject = "pubkey_config.path.secp256k1", + category = "pubkey_config", + "importing secp256k1 key from: {}", + path.display() + ); let sk = match path.extension().and_then(|ext| ext.to_str()) { Some("der") => sec1::EcPrivateKey::from_der(buf.as_slice()).map_err(|e| anyhow!("failed to parse DER encoded secp256k1 key: {e:#?}")), diff --git a/homestar-runtime/src/tasks.rs b/homestar-runtime/src/tasks.rs index caf8ca77..c054c877 100644 --- a/homestar-runtime/src/tasks.rs +++ b/homestar-runtime/src/tasks.rs @@ -1,5 +1,3 @@ -#![allow(missing_docs)] - //! Module for working with task-types and task-specific functionality. use anyhow::{anyhow, Result}; diff --git a/homestar-runtime/src/tasks/fetch.rs b/homestar-runtime/src/tasks/fetch.rs index 87922afd..d56df0f5 100644 --- a/homestar-runtime/src/tasks/fetch.rs +++ b/homestar-runtime/src/tasks/fetch.rs @@ -14,7 +14,7 @@ use std::sync::Arc; pub(crate) struct Fetch; #[cfg(any(test, feature = "test-utils"))] -const WASM_CID: &str = "bafybeiczefaiu7464ehupezpzulnti5jvcwnvdalqrdliugnnwcdz6ljia"; +const WASM_CID: &str = "bafybeig6u35v6t3f4j3zgz2jvj4erd45fbkeolioaddu3lmu6uxm3ilb7a"; #[cfg(any(test, feature = "test-utils"))] const CAT_CID: &str = "bafybeiejevluvtoevgk66plh5t6xiy3ikyuuxg3vgofuvpeckb6eadresm"; @@ -34,6 +34,8 @@ impl Fetch { for rsc in resources.iter() { let task = tryhard::retry_fn(|| async { tracing::info!( + subject = "fetch_rsc", + category = "fetch", rsc = rsc.to_string(), "attempting to fetch resource from IPFS" ); @@ -47,20 +49,32 @@ impl Fetch { async move { if attempts < retries { tracing::warn!( + subject = "fetch_rsc.err", + category = "fetch", err = err, attempts = attempts, "retrying fetch after error @ {}ms", next_delay.map(|d| d.as_millis()).unwrap_or(0) ); } else { - tracing::warn!(err = err, attempts = attempts, "maxed out # of retries"); + tracing::warn!( + subject = "fetch_rsc.err", + category = "fetch", + err = err, + attempts = attempts, + "maxed out # of retries" + ); } } }); tasks.push(task); } - tracing::info!("fetching necessary resources from IPFS"); + tracing::info!( + subject = "fetch_rscs", + category = "fetch", + "fetching necessary resources from IPFS" + ); if let Ok(vec) = tasks.try_collect::>().await { vec.into_iter() .try_fold(IndexMap::default(), |mut acc, res| { diff --git a/homestar-runtime/src/tasks/wasm.rs b/homestar-runtime/src/tasks/wasm.rs index b55f3a37..7ba5fd70 100644 --- a/homestar-runtime/src/tasks/wasm.rs +++ b/homestar-runtime/src/tasks/wasm.rs @@ -1,3 +1,7 @@ +//! Functionality around Wasm-based [tasks]. +//! +//! [tasks]: homestar_core::workflow::Task + use super::FileLoad; use async_trait::async_trait; use homestar_core::workflow::input::Args; diff --git a/homestar-runtime/src/test_utils/worker_builder.rs b/homestar-runtime/src/test_utils/worker_builder.rs index f9c8e24c..14e0d255 100644 --- a/homestar-runtime/src/test_utils/worker_builder.rs +++ b/homestar-runtime/src/test_utils/worker_builder.rs @@ -25,26 +25,45 @@ use homestar_wasm::io::Arg; use indexmap::IndexMap; use libipld::Cid; -/// TODO +/// Utility structure for building out [Worker]s for testing purposes. +/// +/// [Worker]: crate::Worker #[cfg(feature = "ipfs")] pub(crate) struct WorkerBuilder<'a> { + /// In-memory database for testing. db: MemoryDb, + /// Event channel sender. event_sender: AsyncChannelSender, + /// [IPFS client]. + /// + /// [IPFS client]: crate::network::IpfsCli ipfs: IpfsCli, + /// Runner channel sender. runner_sender: AsyncChannelSender, + /// Name of the workflow. name: Option, + /// [Workflow] to run. workflow: Workflow<'a, Arg>, + /// [Workflow] settings. workflow_settings: workflow::Settings, } -/// TODO +/// Utility structure for building out [Worker]s for testing purposes. +/// +/// [Worker]: crate::Worker #[cfg(not(feature = "ipfs"))] pub(crate) struct WorkerBuilder<'a> { + /// In-memory database for testing. db: MemoryDb, + /// Event channel sender. event_sender: AsyncChannelSender, + /// Runner channel sender. runner_sender: AsyncChannelSender, + /// Name of the workflow. name: Option, + /// [Workflow] to run. workflow: Workflow<'a, Arg>, + /// [Workflow] settings. workflow_settings: workflow::Settings, } @@ -113,7 +132,10 @@ impl<'a> WorkerBuilder<'a> { .unwrap() } - /// TODO + /// Fetch-function closure for the [Worker]/[Scheduler] to use. + /// + /// [Worker]: crate::Worker + /// [Scheduler]: crate::TaskScheduler #[cfg(feature = "ipfs")] #[allow(dead_code)] pub(crate) fn fetch_fn( @@ -129,7 +151,10 @@ impl<'a> WorkerBuilder<'a> { fetch_fn } - /// TODO + /// Fetch-function closure for the [Worker]/[Scheduler] to use. + /// + /// [Worker]: crate::Worker + /// [Scheduler]: crate::TaskScheduler #[cfg(not(feature = "ipfs"))] #[allow(dead_code)] pub(crate) fn fetch_fn( diff --git a/homestar-runtime/src/worker.rs b/homestar-runtime/src/worker.rs index 05f55af3..001f4872 100644 --- a/homestar-runtime/src/worker.rs +++ b/homestar-runtime/src/worker.rs @@ -2,7 +2,7 @@ //! sends [Event]'s to the [EventHandler]. //! //! [Workflow]: homestar_core::Workflow -//! [EventHandler]: crate::event_handler::EventHandler +//! [EventHandler]: crate::EventHandler #[cfg(feature = "websocket-notify")] use crate::event_handler::event::Replay; @@ -16,10 +16,10 @@ use crate::{ }, network::swarm::CapsuleTag, runner::{ModifiedSet, RunningTaskSet}, - scheduler::{ExecutionGraph, TaskScheduler}, + scheduler::ExecutionGraph, tasks::{RegisteredTasks, WasmContext}, workflow::{self, Resource}, - Db, Receipt, + Db, Receipt, TaskScheduler, }; use anyhow::{anyhow, Context, Result}; use chrono::NaiveDateTime; @@ -51,8 +51,12 @@ use tracing::{debug, error, info}; #[allow(dead_code)] pub(crate) type TaskSet = JoinSet>; +/// Messages sent to [Worker] from [Runner]. +/// +/// [Runner]: crate::Runner #[derive(Debug, Clone, PartialEq)] pub(crate) enum WorkerMessage { + /// Signal that the [Worker] has been dropped for a workflow run. Dropped(Cid), } @@ -60,13 +64,25 @@ pub(crate) enum WorkerMessage { #[allow(dead_code)] #[allow(missing_debug_implementations)] pub(crate) struct Worker<'a, DB: Database> { + /// [ExecutionGraph] of the [Workflow] to run. pub(crate) graph: Arc>, + /// [EventHandler] channel to send [Event]s to. + /// + /// [EventHandler]: crate::EventHandler pub(crate) event_sender: Arc>, + /// [Runner] channel to send [WorkerMessage]s to. + /// + /// [Runner]: crate::Runner pub(crate) runner_sender: AsyncChannelSender, + /// [Database] pool to pull connections from for the [Worker] run. pub(crate) db: DB, + /// Local name of the [Workflow] being run. pub(crate) workflow_name: FastStr, + /// [Workflow] information. pub(crate) workflow_info: Arc, + /// [Workflow] settings. pub(crate) workflow_settings: Arc, + /// [NaiveDateTime] of when the [Workflow] was started. pub(crate) workflow_started: NaiveDateTime, } @@ -152,7 +168,10 @@ where { Ok(ctx) => self.run_queue(ctx.scheduler, running_tasks).await, Err(err) => { - error!(err=?err, "error initializing scheduler"); + error!(subject = "worker.init", + category = "worker.run", + err=?err, + "error initializing scheduler"); Err(anyhow!("error initializing scheduler")) } } @@ -184,16 +203,28 @@ where event_sender: Arc>, ) -> Result, ResolveError> { info!( + subject = "worker.resolve_cid", + category = "worker.run", workflow_cid = workflow_cid.to_string(), cid = cid.to_string(), "attempting to resolve cid in workflow" ); if let Some(result) = linkmap.read().await.get(&cid) { - debug!(cid = cid.to_string(), "found in in-memory linkmap"); + debug!( + subject = "worker.resolve_cid", + category = "worker.run", + cid = cid.to_string(), + "found CID in in-memory linkmap" + ); Ok(result.to_owned()) } else if let Some(bytes) = resources.read().await.get(&Resource::Cid(cid)) { - debug!(cid = cid.to_string(), "found in resources"); + debug!( + subject = "worker.resolve_cid", + category = "worker.run", + cid = cid.to_string(), + "found CID in map of resources" + ); Ok(InstructionResult::Ok(Arg::Ipld(Ipld::Bytes( bytes.to_vec(), )))) @@ -202,7 +233,11 @@ where match Db::find_instruction_by_cid(cid, conn) { Ok(found) => Ok(found.output_as_arg()), Err(_) => { - debug!("no related instruction receipt found in the DB"); + debug!( + subject = "worker.resolve_cid", + category = "worker.run", + "no related instruction receipt found in the DB" + ); let (tx, rx) = AsyncChannel::oneshot(); let _ = event_sender .send_async(Event::FindRecord(QueryRecord::with( @@ -251,6 +286,8 @@ where { if scheduler.ran_length() > 0 { info!( + subject = "worker.replay", + category = "worker.run", workflow_cid = self.workflow_info.cid.to_string(), "{} tasks left to run, sending last batch for workflow", scheduler.run_length() @@ -350,7 +387,10 @@ where let resolved = match resolved.await { Ok(inst_result) => inst_result, Err(err) => { - error!(err=?err, "error resolving cid"); + error!(subject = "worker.resolve_cid", + category = "worker.run", + err=?err, + "error resolving cid"); return Err(anyhow!("error resolving cid: {err}")) .with_context(|| { format!("could not spawn task for cid: {workflow_cid}") @@ -367,13 +407,15 @@ where Err(err) => Err( anyhow!("cannot execute wasm module: {err}")) .with_context(|| { - format!("not able to run fn {fun} for promised cid: {instruction_ptr}, in workflow {workflow_cid}") + format!("not able to run fn {fun} for cid: {instruction_ptr}, in workflow {workflow_cid}") }), } }); handles.push(handle); } None => error!( + subject = "worker.run.task.err", + category = "worker.run", "no valid task/instruction-type referenced by operation: {}", instruction.op() ), @@ -387,11 +429,17 @@ where { Ok(Ok(data)) => data, Ok(Err(err)) => { - error!(err=?err, "error in running task"); + error!(subject = "worker.run.task.err", + category = "worker.run", + err=?err, + "error in running task"); break; } Err(err) => { - error!(err=?err, "error in running task"); + error!(subject = "worker.run.task.err", + category = "worker.run", + err=?err, + "error in running task"); break; } }; @@ -426,6 +474,8 @@ where Db::commit_receipt(self.workflow_info.cid, receipt, &mut self.db.conn()?)?; debug!( + subject = "db.commit_receipt", + category = "worker.run", cid = self.workflow_info.cid.to_string(), "commited to database" ); diff --git a/homestar-runtime/src/workflow.rs b/homestar-runtime/src/workflow.rs index a01b48ce..b4669a9a 100644 --- a/homestar-runtime/src/workflow.rs +++ b/homestar-runtime/src/workflow.rs @@ -156,7 +156,12 @@ impl<'a> Builder<'a> { (Dag::default(), vec![], vec![], IndexMap::new()), |(mut dag, mut unawaits, mut awaited, mut resources), (i, task)| { let instr_cid = task.instruction_cid()?; - debug!("instruction cid: {}", instr_cid); + debug!( + subject = "task.instruction", + category = "aot.information", + "instruction cid of task: {}", + instr_cid + ); // Clone as we're owning the struct going backward. let ptr: Pointer = Invocation::::from(task.clone()).try_into()?; diff --git a/homestar-runtime/src/workflow/info.rs b/homestar-runtime/src/workflow/info.rs index 7110a64d..e4b7e351 100644 --- a/homestar-runtime/src/workflow/info.rs +++ b/homestar-runtime/src/workflow/info.rs @@ -44,11 +44,29 @@ const RESOURCES_KEY: &str = "resources"; #[derive(Debug, Clone, PartialEq, Queryable, Insertable, Identifiable, Selectable)] #[diesel(table_name = crate::db::schema::workflows, primary_key(cid))] pub struct Stored { + /// Wrapped-[Cid] of [Workflow]. + /// + /// [Workflow]: homestar_core::Workflow pub(crate) cid: Pointer, + /// Local name of [Workflow]. + /// + /// [Workflow]: homestar_core::Workflow pub(crate) name: Option, + /// Number of tasks in [Workflow]. + /// + /// [Workflow]: homestar_core::Workflow pub(crate) num_tasks: i32, + /// Map of [Instruction] [Cid]s to resources. + /// + /// [Instruction]: homestar_core::workflow::Instruction pub(crate) resources: IndexedResources, + /// Local timestamp of [Workflow] creation. + /// + /// [Workflow]: homestar_core::Workflow pub(crate) created_at: NaiveDateTime, + /// Local timestamp of [Workflow] completion. + /// + /// [Workflow]: homestar_core::Workflow pub(crate) completed_at: Option, } @@ -275,6 +293,8 @@ impl Info { Ok((_, info)) => Ok((info, timestamp)), Err(_err) => { info!( + subject = "workflow.init.db.check", + category = "workflow", cid = workflow_cid.to_string(), "workflow information not available in the database" ); @@ -322,6 +342,8 @@ impl Info { Some((_name, workflow_info)) => Ok(workflow_info), None => { info!( + subject = "workflow.gather.db.check", + category = "workflow", cid = workflow_cid.to_string(), "workflow information not available in the database" ); diff --git a/homestar-runtime/src/workflow/settings.rs b/homestar-runtime/src/workflow/settings.rs index 9ea3e682..b5eae6de 100644 --- a/homestar-runtime/src/workflow/settings.rs +++ b/homestar-runtime/src/workflow/settings.rs @@ -7,10 +7,15 @@ use std::time::Duration; /// Workflow settings. #[derive(Debug, Clone, PartialEq)] pub struct Settings { + /// Number of retries for a given workflow. pub(crate) retries: u32, + /// Maximum delay between retries. pub(crate) retry_max_delay: Duration, + /// Initial delay between retries. pub(crate) retry_initial_delay: Duration, + /// Timeout for P2P/DHT operations. pub(crate) p2p_timeout: Duration, + /// Timeout for a given workflow. pub(crate) timeout: Duration, } diff --git a/homestar-runtime/tests/cli.rs b/homestar-runtime/tests/cli.rs index 550b0263..e7fce91c 100644 --- a/homestar-runtime/tests/cli.rs +++ b/homestar-runtime/tests/cli.rs @@ -200,7 +200,7 @@ fn test_workflow_run_serial() -> Result<()> { .assert() .success() .stdout(predicate::str::contains( - "ipfs://bafybeiczefaiu7464ehupezpzulnti5jvcwnvdalqrdliugnnwcdz6ljia", + "ipfs://bafybeig6u35v6t3f4j3zgz2jvj4erd45fbkeolioaddu3lmu6uxm3ilb7a", )) .stdout(predicate::str::contains("num_tasks")) .stdout(predicate::str::contains("progress_count")); @@ -215,7 +215,7 @@ fn test_workflow_run_serial() -> Result<()> { .assert() .success() .stdout(predicate::str::contains( - "ipfs://bafybeiczefaiu7464ehupezpzulnti5jvcwnvdalqrdliugnnwcdz6ljia", + "ipfs://bafybeig6u35v6t3f4j3zgz2jvj4erd45fbkeolioaddu3lmu6uxm3ilb7a", )) .stdout(predicate::str::contains("num_tasks")) .stdout(predicate::str::contains("progress_count")); diff --git a/homestar-runtime/tests/fixtures/test-workflow-add-one.json b/homestar-runtime/tests/fixtures/test-workflow-add-one.json index 05aa7c3c..5b83a711 100644 --- a/homestar-runtime/tests/fixtures/test-workflow-add-one.json +++ b/homestar-runtime/tests/fixtures/test-workflow-add-one.json @@ -17,7 +17,7 @@ }, "nnc": "", "op": "wasm/run", - "rsc": "ipfs://bafybeiczefaiu7464ehupezpzulnti5jvcwnvdalqrdliugnnwcdz6ljia" + "rsc": "ipfs://bafybeig6u35v6t3f4j3zgz2jvj4erd45fbkeolioaddu3lmu6uxm3ilb7a" } }, { @@ -33,7 +33,7 @@ "args": [ { "await/ok": { - "/": "bafyrmid5morwzj3lz436g44usvu35xcfyn4ommfe4ozulmnrsohybdez3a" + "/": "bafyrmie3vqqilbt6ghxqkvzieials254hwqr23fl6ecktt4kdmftbxejfu" } } ], @@ -41,7 +41,7 @@ }, "nnc": "", "op": "wasm/run", - "rsc": "ipfs://bafybeiczefaiu7464ehupezpzulnti5jvcwnvdalqrdliugnnwcdz6ljia" + "rsc": "ipfs://bafybeig6u35v6t3f4j3zgz2jvj4erd45fbkeolioaddu3lmu6uxm3ilb7a" } } ] diff --git a/homestar-runtime/tests/fixtures/test-workflow-image-pipeline.json b/homestar-runtime/tests/fixtures/test-workflow-image-pipeline.json index 5d252963..a9362b96 100644 --- a/homestar-runtime/tests/fixtures/test-workflow-image-pipeline.json +++ b/homestar-runtime/tests/fixtures/test-workflow-image-pipeline.json @@ -22,7 +22,7 @@ }, "nnc": "", "op": "wasm/run", - "rsc": "ipfs://bafybeiczefaiu7464ehupezpzulnti5jvcwnvdalqrdliugnnwcdz6ljia" + "rsc": "ipfs://bafybeig6u35v6t3f4j3zgz2jvj4erd45fbkeolioaddu3lmu6uxm3ilb7a" } }, { @@ -37,7 +37,7 @@ "args": [ { "await/ok": { - "/": "bafyrmid35kzcxbn5xhsewyzzja5gngm54peve5i45vdj3bxgokmuvj2wwy" + "/": "bafyrmiaadxb2oauwkak5ugyvgmi4jtw5bck2e3rvoznlegahniv654b3l4" } } ], @@ -45,7 +45,7 @@ }, "nnc": "", "op": "wasm/run", - "rsc": "ipfs://bafybeiczefaiu7464ehupezpzulnti5jvcwnvdalqrdliugnnwcdz6ljia" + "rsc": "ipfs://bafybeig6u35v6t3f4j3zgz2jvj4erd45fbkeolioaddu3lmu6uxm3ilb7a" } }, { @@ -60,7 +60,7 @@ "args": [ { "await/ok": { - "/": "bafyrmicubn76iynz6hjice6x47p7hgdlhht6qoizhuu746uea6e674jap4" + "/": "bafyrmigat3k3pbwavivjg3fldsnlwaxpznechmuibnhhldfhfiwmbnbyrq" } } ], @@ -68,7 +68,7 @@ }, "nnc": "", "op": "wasm/run", - "rsc": "ipfs://bafybeiczefaiu7464ehupezpzulnti5jvcwnvdalqrdliugnnwcdz6ljia" + "rsc": "ipfs://bafybeig6u35v6t3f4j3zgz2jvj4erd45fbkeolioaddu3lmu6uxm3ilb7a" } } ] diff --git a/homestar-runtime/tests/fixtures/test-workflow-jco.json b/homestar-runtime/tests/fixtures/test-workflow-jco.json index 85bbaeb3..abc2d206 100644 --- a/homestar-runtime/tests/fixtures/test-workflow-jco.json +++ b/homestar-runtime/tests/fixtures/test-workflow-jco.json @@ -9,13 +9,36 @@ "prf": [], "run": { "input": { - "args": ["hello", 10], + "args": ["helloworld", 10], "func": "sum" }, "nnc": "", "op": "wasm/run", "rsc": "ipfs://bafybeibawnb3pytqmky4ph37hj7y7qosqcneofjextqq55zhxfniiletfu" } + }, + { + "cause": null, + "meta": { + "memory": 4294967296, + "time": 100000 + }, + "prf": [], + "run": { + "input": { + "args": [ + { + "await/ok": { + "/": "bafyrmigltroc4nrdaskjselusvfcuooc52k2rl7nmrf72edbauyptmx5bq" + } + } + ], + "func": "hashbytes" + }, + "nnc": "", + "op": "wasm/run", + "rsc": "ipfs://bafybeifrgndv3blrxucig2pei6uaoyiyipk5vvzds7ps47ec6pzf4ax2d4" + } } ] } diff --git a/homestar-runtime/tests/fixtures/test-workflow-no-awaits1.json b/homestar-runtime/tests/fixtures/test-workflow-no-awaits1.json index cc0407fc..b8569a09 100644 --- a/homestar-runtime/tests/fixtures/test-workflow-no-awaits1.json +++ b/homestar-runtime/tests/fixtures/test-workflow-no-awaits1.json @@ -22,7 +22,7 @@ }, "nnc": "", "op": "wasm/run", - "rsc": "ipfs://bafybeiczefaiu7464ehupezpzulnti5jvcwnvdalqrdliugnnwcdz6ljia" + "rsc": "ipfs://bafybeig6u35v6t3f4j3zgz2jvj4erd45fbkeolioaddu3lmu6uxm3ilb7a" } } ] diff --git a/homestar-runtime/tests/fixtures/test-workflow-no-awaits2.json b/homestar-runtime/tests/fixtures/test-workflow-no-awaits2.json index d7d6a2e2..e82e7f63 100644 --- a/homestar-runtime/tests/fixtures/test-workflow-no-awaits2.json +++ b/homestar-runtime/tests/fixtures/test-workflow-no-awaits2.json @@ -22,7 +22,7 @@ }, "nnc": "", "op": "wasm/run", - "rsc": "ipfs://bafybeiczefaiu7464ehupezpzulnti5jvcwnvdalqrdliugnnwcdz6ljia" + "rsc": "ipfs://bafybeig6u35v6t3f4j3zgz2jvj4erd45fbkeolioaddu3lmu6uxm3ilb7a" } }, { @@ -47,7 +47,7 @@ }, "nnc": "", "op": "wasm/run", - "rsc": "ipfs://bafybeiczefaiu7464ehupezpzulnti5jvcwnvdalqrdliugnnwcdz6ljia" + "rsc": "ipfs://bafybeig6u35v6t3f4j3zgz2jvj4erd45fbkeolioaddu3lmu6uxm3ilb7a" } } ] diff --git a/homestar-runtime/tests/network.rs b/homestar-runtime/tests/network.rs index c4d78acc..c52eb19f 100644 --- a/homestar-runtime/tests/network.rs +++ b/homestar-runtime/tests/network.rs @@ -456,7 +456,7 @@ fn test_libp2p_connect_rendezvous_discovery_serial() -> Result<()> { } // Wait for registration to complete - // TODO When we have websocket push events, listen on a registration event instead of using an arbitrary sleep + // TODO When we have WebSocket push events, listen on a registration event instead of using an arbitrary sleep thread::sleep(Duration::from_secs(2)); // Start a peer that will discover the registrant through the rendezvous server @@ -762,7 +762,7 @@ fn test_libp2p_disconnect_rendezvous_discovery_serial() -> Result<()> { } // Wait for registration to complete. - // TODO When we have websocket push events, listen on a registration event instead of using an arbitrary sleep. + // TODO When we have WebSocket push events, listen on a registration event instead of using an arbitrary sleep. thread::sleep(Duration::from_secs(2)); // Start a peer that will discover the registrant through the rendezvous server @@ -1036,7 +1036,7 @@ fn test_libp2p_rendezvous_rediscover_on_expiration_serial() -> Result<()> { } // Wait for registration to complete. - // TODO When we have websocket push events, listen on a registration event instead of using an arbitrary sleep. + // TODO When we have WebSocket push events, listen on a registration event instead of using an arbitrary sleep. thread::sleep(Duration::from_secs(2)); // Start a peer that will discover with the rendezvous server when diff --git a/homestar-runtime/tests/webserver.rs b/homestar-runtime/tests/webserver.rs index 1aebda3f..6e3bb537 100644 --- a/homestar-runtime/tests/webserver.rs +++ b/homestar-runtime/tests/webserver.rs @@ -20,6 +20,7 @@ use std::{ static BIN: Lazy = Lazy::new(|| assert_cmd::cargo::cargo_bin(BIN_NAME)); const SUBSCRIBE_RUN_WORKFLOW_ENDPOINT: &str = "subscribe_run_workflow"; const UNSUBSCRIBE_RUN_WORKFLOW_ENDPOINT: &str = "unsubscribe_run_workflow"; +const AWAIT_CID: &str = "bafyrmih5bwjinspvn5ktpcaxqvvxkmhxrznhuu3qqmu45jnpmo3ab72vaq"; #[test] #[file_serial] @@ -75,7 +76,7 @@ fn test_workflow_run_serial() -> Result<()> { let json: serde_json::Value = serde_json::from_slice(&msg.unwrap().unwrap()).unwrap(); let check = json.get("metadata").unwrap(); - let expected = serde_json::json!({"name": "test", "replayed": false, "workflow": {"/": "bafyrmihfhdhxmhotbgn5digt6n7vgz2ukisafhjozki2e6nwtvunep3mrm"}}); + let expected = serde_json::json!({"name": "test", "replayed": false, "workflow": {"/": format!("{AWAIT_CID}")}}); assert_eq!(check, &expected); received_cids += 1; } else { @@ -103,7 +104,7 @@ fn test_workflow_run_serial() -> Result<()> { let json: serde_json::Value = serde_json::from_slice(&msg.unwrap().unwrap()).unwrap(); let check = json.get("metadata").unwrap(); - let expected = serde_json::json!({"name": "test", "replayed": true, "workflow": {"/": "bafyrmihfhdhxmhotbgn5digt6n7vgz2ukisafhjozki2e6nwtvunep3mrm"}}); + let expected = serde_json::json!({"name": "test", "replayed": true, "workflow": {"/": format!("{AWAIT_CID}")}}); assert_eq!(check, &expected); received_cids += 1; } else { @@ -137,7 +138,7 @@ fn test_workflow_run_serial() -> Result<()> { let json: serde_json::Value = serde_json::from_slice(&msg.unwrap().unwrap()).unwrap(); let check = json.get("metadata").unwrap(); - let expected = serde_json::json!({"name": "test", "replayed": true, "workflow": {"/": "bafyrmihfhdhxmhotbgn5digt6n7vgz2ukisafhjozki2e6nwtvunep3mrm"}}); + let expected = serde_json::json!({"name": "test", "replayed": true, "workflow": {"/": format!("{AWAIT_CID}")}}); assert_eq!(check, &expected); received_cids += 1; } else { @@ -172,7 +173,7 @@ fn test_workflow_run_serial() -> Result<()> { let json: serde_json::Value = serde_json::from_slice(&msg.unwrap().unwrap()).unwrap(); let check = json.get("metadata").unwrap(); - let expected = serde_json::json!({"name": "another_test", "replayed": true, "workflow": {"/": "bafyrmihfhdhxmhotbgn5digt6n7vgz2ukisafhjozki2e6nwtvunep3mrm"}}); + let expected = serde_json::json!({"name": "another_test", "replayed": true, "workflow": {"/": format!("{AWAIT_CID}")}}); assert_eq!(check, &expected); received_cids += 1; } else { diff --git a/homestar-wasm/fixtures/example_add.wasm b/homestar-wasm/fixtures/example_add.wasm index 2f3d643a..47bea752 100755 Binary files a/homestar-wasm/fixtures/example_add.wasm and b/homestar-wasm/fixtures/example_add.wasm differ diff --git a/homestar-wasm/fixtures/example_add.wat b/homestar-wasm/fixtures/example_add.wat index 868c0d5e..042ab78d 100644 --- a/homestar-wasm/fixtures/example_add.wat +++ b/homestar-wasm/fixtures/example_add.wat @@ -402,7 +402,7 @@ block ;; label = @6 i32.const 0 i32.load offset=1048984 - local.tee 7 + local.tee 6 i32.const 16 local.get 0 i32.const 11 @@ -432,51 +432,51 @@ i32.and local.get 1 i32.add - local.tee 2 + local.tee 1 i32.const 3 i32.shl - local.tee 5 + local.tee 2 i32.const 1048728 i32.add i32.load local.tee 0 i32.const 8 i32.add - local.tee 6 + local.tee 7 i32.load - local.tee 1 - local.get 5 + local.tee 5 + local.get 2 i32.const 1048720 i32.add - local.tee 5 + local.tee 2 i32.eq br_if 0 (;@8;) - local.get 1 local.get 5 + local.get 2 i32.store offset=12 + local.get 2 local.get 5 - local.get 1 i32.store offset=8 br 1 (;@7;) end i32.const 0 - local.get 7 + local.get 6 i32.const -2 - local.get 2 + local.get 1 i32.rotl i32.and i32.store offset=1048984 end local.get 0 - local.get 2 + local.get 1 i32.const 3 i32.shl - local.tee 2 + local.tee 1 i32.const 3 i32.or i32.store offset=4 local.get 0 - local.get 2 + local.get 1 i32.add local.tee 0 local.get 0 @@ -484,7 +484,7 @@ i32.const 1 i32.or i32.store offset=4 - local.get 6 + local.get 7 return end local.get 2 @@ -513,7 +513,7 @@ i32.const 1048576 i32.add i32.load - local.tee 6 + local.tee 7 i32.load offset=4 i32.const -8 i32.and @@ -522,11 +522,11 @@ local.set 5 block ;; label = @13 block ;; label = @14 - local.get 6 + local.get 7 i32.load offset=16 local.tee 0 br_if 0 (;@14;) - local.get 6 + local.get 7 i32.const 20 i32.add i32.load @@ -544,7 +544,7 @@ local.tee 8 local.get 5 i32.lt_u - local.set 7 + local.set 6 block ;; label = @15 local.get 0 i32.load offset=16 @@ -558,47 +558,47 @@ end local.get 8 local.get 5 - local.get 7 + local.get 6 select local.set 5 local.get 0 - local.get 6 local.get 7 + local.get 6 select - local.set 6 + local.set 7 local.get 1 local.set 0 local.get 1 br_if 0 (;@14;) end end - local.get 6 + local.get 7 call 7 local.get 5 i32.const 16 i32.lt_u br_if 2 (;@10;) - local.get 6 + local.get 7 local.get 2 i32.const 3 i32.or i32.store offset=4 - local.get 6 + local.get 7 local.get 2 i32.add - local.tee 2 + local.tee 1 local.get 5 i32.const 1 i32.or i32.store offset=4 - local.get 2 + local.get 1 local.get 5 i32.add local.get 5 i32.store i32.const 0 i32.load offset=1048992 - local.tee 7 + local.tee 6 br_if 1 (;@11;) br 5 (;@7;) end @@ -623,7 +623,7 @@ local.tee 1 i32.const 3 i32.shl - local.tee 6 + local.tee 7 i32.const 1048728 i32.add i32.load @@ -633,22 +633,22 @@ local.tee 8 i32.load local.tee 5 - local.get 6 + local.get 7 i32.const 1048720 i32.add - local.tee 6 + local.tee 7 i32.eq br_if 0 (;@13;) local.get 5 - local.get 6 + local.get 7 i32.store offset=12 - local.get 6 + local.get 7 local.get 5 i32.store offset=8 br 1 (;@12;) end i32.const 0 - local.get 7 + local.get 6 i32.const -2 local.get 1 i32.rotl @@ -663,34 +663,34 @@ local.get 0 local.get 2 i32.add - local.tee 7 + local.tee 6 local.get 1 i32.const 3 i32.shl - local.tee 1 + local.tee 5 local.get 2 i32.sub - local.tee 2 + local.tee 1 i32.const 1 i32.or i32.store offset=4 local.get 0 - local.get 1 + local.get 5 i32.add - local.get 2 + local.get 1 i32.store i32.const 0 i32.load offset=1048992 - local.tee 5 + local.tee 2 br_if 2 (;@9;) br 3 (;@8;) end - local.get 7 + local.get 6 i32.const -8 i32.and i32.const 1048720 i32.add - local.set 1 + local.set 2 i32.const 0 i32.load offset=1049000 local.set 0 @@ -700,42 +700,41 @@ i32.load offset=1048984 local.tee 8 i32.const 1 - local.get 7 + local.get 6 i32.const 3 i32.shr_u i32.shl - local.tee 7 + local.tee 6 i32.and - i32.eqz br_if 0 (;@12;) - local.get 1 - i32.load offset=8 - local.set 7 + i32.const 0 + local.get 8 + local.get 6 + i32.or + i32.store offset=1048984 + local.get 2 + local.set 6 br 1 (;@11;) end - i32.const 0 - local.get 8 - local.get 7 - i32.or - i32.store offset=1048984 - local.get 1 - local.set 7 + local.get 2 + i32.load offset=8 + local.set 6 end - local.get 1 + local.get 2 local.get 0 i32.store offset=8 - local.get 7 + local.get 6 local.get 0 i32.store offset=12 local.get 0 - local.get 1 + local.get 2 i32.store offset=12 local.get 0 - local.get 7 + local.get 6 i32.store offset=8 br 3 (;@7;) end - local.get 6 + local.get 7 local.get 5 local.get 2 i32.add @@ -743,7 +742,7 @@ i32.const 3 i32.or i32.store offset=4 - local.get 6 + local.get 7 local.get 0 i32.add local.tee 0 @@ -754,12 +753,12 @@ i32.store offset=4 br 3 (;@6;) end - local.get 5 + local.get 2 i32.const -8 i32.and i32.const 1048720 i32.add - local.set 1 + local.set 5 i32.const 0 i32.load offset=1049000 local.set 0 @@ -767,59 +766,58 @@ block ;; label = @10 i32.const 0 i32.load offset=1048984 - local.tee 6 + local.tee 7 i32.const 1 - local.get 5 + local.get 2 i32.const 3 i32.shr_u i32.shl - local.tee 5 + local.tee 2 i32.and - i32.eqz br_if 0 (;@10;) - local.get 1 - i32.load offset=8 - local.set 5 + i32.const 0 + local.get 7 + local.get 2 + i32.or + i32.store offset=1048984 + local.get 5 + local.set 2 br 1 (;@9;) end - i32.const 0 - local.get 6 local.get 5 - i32.or - i32.store offset=1048984 - local.get 1 - local.set 5 + i32.load offset=8 + local.set 2 end - local.get 1 + local.get 5 local.get 0 i32.store offset=8 - local.get 5 + local.get 2 local.get 0 i32.store offset=12 local.get 0 - local.get 1 + local.get 5 i32.store offset=12 local.get 0 - local.get 5 + local.get 2 i32.store offset=8 end i32.const 0 - local.get 7 + local.get 6 i32.store offset=1049000 i32.const 0 - local.get 2 + local.get 1 i32.store offset=1048992 local.get 8 return end i32.const 0 - local.get 2 + local.get 1 i32.store offset=1049000 i32.const 0 local.get 5 i32.store offset=1048992 end - local.get 6 + local.get 7 i32.const 8 i32.add return @@ -858,21 +856,30 @@ br_if 1 (;@3;) end loop ;; label = @4 + local.get 0 + local.get 6 local.get 0 i32.load offset=4 i32.const -8 i32.and local.tee 5 local.get 2 - i32.ge_u - local.get 5 - local.get 2 i32.sub local.tee 8 local.get 1 i32.lt_u - i32.and + local.tee 4 + select + local.set 3 + local.get 5 + local.get 2 + i32.lt_u local.set 7 + local.get 8 + local.get 1 + local.get 4 + select + local.set 8 block ;; label = @5 local.get 0 i32.load offset=16 @@ -884,13 +891,13 @@ i32.load local.set 5 end - local.get 0 local.get 6 + local.get 3 local.get 7 select local.set 6 - local.get 8 local.get 1 + local.get 8 local.get 7 select local.set 1 @@ -958,12 +965,12 @@ i32.and i32.const 1048720 i32.add - local.set 2 + local.set 5 block ;; label = @5 block ;; label = @6 i32.const 0 i32.load offset=1048984 - local.tee 5 + local.tee 2 i32.const 1 local.get 1 i32.const 3 @@ -971,29 +978,28 @@ i32.shl local.tee 1 i32.and - i32.eqz br_if 0 (;@6;) + i32.const 0 local.get 2 - i32.load offset=8 + local.get 1 + i32.or + i32.store offset=1048984 + local.get 5 local.set 1 br 1 (;@5;) end - i32.const 0 local.get 5 - local.get 1 - i32.or - i32.store offset=1048984 - local.get 2 + i32.load offset=8 local.set 1 end - local.get 2 + local.get 5 local.get 0 i32.store offset=8 local.get 1 local.get 0 i32.store offset=12 local.get 0 - local.get 2 + local.get 5 i32.store offset=12 local.get 0 local.get 1 @@ -1031,887 +1037,884 @@ block ;; label = @7 block ;; label = @8 block ;; label = @9 + i32.const 0 + i32.load offset=1048992 + local.tee 0 + local.get 2 + i32.ge_u + br_if 0 (;@9;) block ;; label = @10 + i32.const 0 + i32.load offset=1048996 + local.tee 0 + local.get 2 + i32.gt_u + br_if 0 (;@10;) + i32.const 0 + local.set 1 + local.get 2 + i32.const 65583 + i32.add + local.tee 5 + i32.const 16 + i32.shr_u + memory.grow + local.tee 0 + i32.const -1 + i32.eq + local.tee 7 + br_if 9 (;@1;) + local.get 0 + i32.const 16 + i32.shl + local.tee 6 + i32.eqz + br_if 9 (;@1;) + i32.const 0 + i32.const 0 + i32.load offset=1049008 + i32.const 0 + local.get 5 + i32.const -65536 + i32.and + local.get 7 + select + local.tee 8 + i32.add + local.tee 0 + i32.store offset=1049008 + i32.const 0 + i32.const 0 + i32.load offset=1049012 + local.tee 1 + local.get 0 + local.get 1 + local.get 0 + i32.gt_u + select + i32.store offset=1049012 block ;; label = @11 - i32.const 0 - i32.load offset=1048992 - local.tee 0 - local.get 2 - i32.ge_u - br_if 0 (;@11;) block ;; label = @12 + block ;; label = @13 + i32.const 0 + i32.load offset=1049004 + local.tee 1 + i32.eqz + br_if 0 (;@13;) + i32.const 1048704 + local.set 0 + loop ;; label = @14 + local.get 0 + i32.load + local.tee 5 + local.get 0 + i32.load offset=4 + local.tee 7 + i32.add + local.get 6 + i32.eq + br_if 2 (;@12;) + local.get 0 + i32.load offset=8 + local.tee 0 + br_if 0 (;@14;) + br 3 (;@11;) + end + end + block ;; label = @13 + block ;; label = @14 + i32.const 0 + i32.load offset=1049020 + local.tee 0 + i32.eqz + br_if 0 (;@14;) + local.get 0 + local.get 6 + i32.le_u + br_if 1 (;@13;) + end + i32.const 0 + local.get 6 + i32.store offset=1049020 + end i32.const 0 - i32.load offset=1048996 - local.tee 0 - local.get 2 - i32.gt_u - br_if 0 (;@12;) + i32.const 4095 + i32.store offset=1049024 i32.const 0 - local.set 1 - local.get 2 - i32.const 65583 - i32.add - local.tee 5 - i32.const 16 - i32.shr_u - memory.grow - local.tee 0 - i32.const -1 - i32.eq - local.tee 6 - br_if 11 (;@1;) - local.get 0 - i32.const 16 - i32.shl - local.tee 7 - i32.eqz - br_if 11 (;@1;) + local.get 8 + i32.store offset=1048708 i32.const 0 + local.get 6 + i32.store offset=1048704 i32.const 0 - i32.load offset=1049008 + i32.const 1048720 + i32.store offset=1048732 i32.const 0 - local.get 5 - i32.const -65536 - i32.and - local.get 6 - select - local.tee 8 - i32.add - local.tee 0 - i32.store offset=1049008 + i32.const 1048728 + i32.store offset=1048740 i32.const 0 + i32.const 1048720 + i32.store offset=1048728 i32.const 0 - i32.load offset=1049012 - local.tee 1 - local.get 0 - local.get 1 - local.get 0 - i32.gt_u - select - i32.store offset=1049012 - block ;; label = @13 - block ;; label = @14 - block ;; label = @15 - i32.const 0 - i32.load offset=1049004 - local.tee 1 - i32.eqz - br_if 0 (;@15;) - i32.const 1048704 - local.set 0 - loop ;; label = @16 - local.get 0 - i32.load - local.tee 5 - local.get 0 - i32.load offset=4 - local.tee 6 - i32.add - local.get 7 - i32.eq - br_if 2 (;@14;) - local.get 0 - i32.load offset=8 - local.tee 0 - br_if 0 (;@16;) - br 3 (;@13;) - end - end - i32.const 0 - i32.load offset=1049020 - local.tee 0 - i32.eqz - br_if 4 (;@10;) - local.get 0 - local.get 7 - i32.gt_u - br_if 4 (;@10;) - br 11 (;@3;) - end - local.get 0 - i32.load offset=12 - br_if 0 (;@13;) - local.get 5 - local.get 1 - i32.gt_u - br_if 0 (;@13;) - local.get 1 - local.get 7 - i32.lt_u - br_if 4 (;@9;) - end + i32.const 1048736 + i32.store offset=1048748 + i32.const 0 + i32.const 1048728 + i32.store offset=1048736 + i32.const 0 + i32.const 1048744 + i32.store offset=1048756 + i32.const 0 + i32.const 1048736 + i32.store offset=1048744 + i32.const 0 + i32.const 1048752 + i32.store offset=1048764 + i32.const 0 + i32.const 1048744 + i32.store offset=1048752 + i32.const 0 + i32.const 1048760 + i32.store offset=1048772 + i32.const 0 + i32.const 1048752 + i32.store offset=1048760 + i32.const 0 + i32.const 1048768 + i32.store offset=1048780 + i32.const 0 + i32.const 1048760 + i32.store offset=1048768 + i32.const 0 + i32.const 1048776 + i32.store offset=1048788 + i32.const 0 + i32.const 1048768 + i32.store offset=1048776 + i32.const 0 + i32.const 0 + i32.store offset=1048716 + i32.const 0 + i32.const 1048784 + i32.store offset=1048796 + i32.const 0 + i32.const 1048776 + i32.store offset=1048784 + i32.const 0 + i32.const 1048784 + i32.store offset=1048792 + i32.const 0 + i32.const 1048792 + i32.store offset=1048804 + i32.const 0 + i32.const 1048792 + i32.store offset=1048800 + i32.const 0 + i32.const 1048800 + i32.store offset=1048812 + i32.const 0 + i32.const 1048800 + i32.store offset=1048808 + i32.const 0 + i32.const 1048808 + i32.store offset=1048820 + i32.const 0 + i32.const 1048808 + i32.store offset=1048816 + i32.const 0 + i32.const 1048816 + i32.store offset=1048828 + i32.const 0 + i32.const 1048816 + i32.store offset=1048824 + i32.const 0 + i32.const 1048824 + i32.store offset=1048836 + i32.const 0 + i32.const 1048824 + i32.store offset=1048832 + i32.const 0 + i32.const 1048832 + i32.store offset=1048844 + i32.const 0 + i32.const 1048832 + i32.store offset=1048840 + i32.const 0 + i32.const 1048840 + i32.store offset=1048852 + i32.const 0 + i32.const 1048840 + i32.store offset=1048848 + i32.const 0 + i32.const 1048848 + i32.store offset=1048860 + i32.const 0 + i32.const 1048856 + i32.store offset=1048868 + i32.const 0 + i32.const 1048848 + i32.store offset=1048856 + i32.const 0 + i32.const 1048864 + i32.store offset=1048876 + i32.const 0 + i32.const 1048856 + i32.store offset=1048864 + i32.const 0 + i32.const 1048872 + i32.store offset=1048884 + i32.const 0 + i32.const 1048864 + i32.store offset=1048872 + i32.const 0 + i32.const 1048880 + i32.store offset=1048892 + i32.const 0 + i32.const 1048872 + i32.store offset=1048880 + i32.const 0 + i32.const 1048888 + i32.store offset=1048900 + i32.const 0 + i32.const 1048880 + i32.store offset=1048888 + i32.const 0 + i32.const 1048896 + i32.store offset=1048908 i32.const 0 + i32.const 1048888 + i32.store offset=1048896 i32.const 0 - i32.load offset=1049020 + i32.const 1048904 + i32.store offset=1048916 + i32.const 0 + i32.const 1048896 + i32.store offset=1048904 + i32.const 0 + i32.const 1048912 + i32.store offset=1048924 + i32.const 0 + i32.const 1048904 + i32.store offset=1048912 + i32.const 0 + i32.const 1048920 + i32.store offset=1048932 + i32.const 0 + i32.const 1048912 + i32.store offset=1048920 + i32.const 0 + i32.const 1048928 + i32.store offset=1048940 + i32.const 0 + i32.const 1048920 + i32.store offset=1048928 + i32.const 0 + i32.const 1048936 + i32.store offset=1048948 + i32.const 0 + i32.const 1048928 + i32.store offset=1048936 + i32.const 0 + i32.const 1048944 + i32.store offset=1048956 + i32.const 0 + i32.const 1048936 + i32.store offset=1048944 + i32.const 0 + i32.const 1048952 + i32.store offset=1048964 + i32.const 0 + i32.const 1048944 + i32.store offset=1048952 + i32.const 0 + i32.const 1048960 + i32.store offset=1048972 + i32.const 0 + i32.const 1048952 + i32.store offset=1048960 + i32.const 0 + i32.const 1048968 + i32.store offset=1048980 + i32.const 0 + i32.const 1048960 + i32.store offset=1048968 + i32.const 0 + local.get 6 + i32.store offset=1049004 + i32.const 0 + i32.const 1048968 + i32.store offset=1048976 + i32.const 0 + local.get 8 + i32.const -40 + i32.add local.tee 0 - local.get 7 + i32.store offset=1048996 + local.get 6 + local.get 0 + i32.const 1 + i32.or + i32.store offset=4 + local.get 6 local.get 0 - local.get 7 - i32.lt_u - select - i32.store offset=1049020 - local.get 7 - local.get 8 i32.add - local.set 5 - i32.const 1048704 - local.set 0 + i32.const 40 + i32.store offset=4 + i32.const 0 + i32.const 2097152 + i32.store offset=1049016 + br 10 (;@2;) + end + local.get 0 + i32.load offset=12 + br_if 0 (;@11;) + local.get 5 + local.get 1 + i32.gt_u + br_if 0 (;@11;) + local.get 1 + local.get 6 + i32.lt_u + br_if 3 (;@8;) + end + i32.const 0 + i32.const 0 + i32.load offset=1049020 + local.tee 0 + local.get 6 + local.get 0 + local.get 6 + i32.lt_u + select + i32.store offset=1049020 + local.get 6 + local.get 8 + i32.add + local.set 5 + i32.const 1048704 + local.set 0 + block ;; label = @11 + block ;; label = @12 block ;; label = @13 - block ;; label = @14 - block ;; label = @15 - loop ;; label = @16 - local.get 0 - i32.load - local.get 5 - i32.eq - br_if 1 (;@15;) - local.get 0 - i32.load offset=8 - local.tee 0 - br_if 0 (;@16;) - br 2 (;@14;) - end - end - local.get 0 - i32.load offset=12 - i32.eqz - br_if 1 (;@13;) - end - i32.const 1048704 - local.set 0 - block ;; label = @14 - loop ;; label = @15 - block ;; label = @16 - local.get 0 - i32.load - local.tee 5 - local.get 1 - i32.gt_u - br_if 0 (;@16;) - local.get 5 - local.get 0 - i32.load offset=4 - i32.add - local.tee 5 - local.get 1 - i32.gt_u - br_if 2 (;@14;) - end - local.get 0 - i32.load offset=8 - local.set 0 - br 0 (;@15;) - end - end - i32.const 0 - local.get 7 - i32.store offset=1049004 - i32.const 0 - local.get 8 - i32.const -40 - i32.add - local.tee 0 - i32.store offset=1048996 - local.get 7 - local.get 0 - i32.const 1 - i32.or - i32.store offset=4 - local.get 7 - local.get 0 - i32.add - i32.const 40 - i32.store offset=4 - i32.const 0 - i32.const 2097152 - i32.store offset=1049016 - local.get 1 - local.get 5 - i32.const -32 - i32.add - i32.const -8 - i32.and - i32.const -8 - i32.add - local.tee 0 - local.get 0 - local.get 1 - i32.const 16 - i32.add - i32.lt_u - select - local.tee 6 - i32.const 27 - i32.store offset=4 - i32.const 0 - i64.load offset=1048704 align=4 - local.set 9 - local.get 6 - i32.const 16 - i32.add - i32.const 0 - i64.load offset=1048712 align=4 - i64.store align=4 - local.get 6 - local.get 9 - i64.store offset=8 align=4 - i32.const 0 - local.get 8 - i32.store offset=1048708 - i32.const 0 - local.get 7 - i32.store offset=1048704 - i32.const 0 - local.get 6 - i32.const 8 - i32.add - i32.store offset=1048712 - i32.const 0 - i32.const 0 - i32.store offset=1048716 - local.get 6 - i32.const 28 - i32.add - local.set 0 loop ;; label = @14 local.get 0 - i32.const 7 - i32.store + i32.load + local.get 5 + i32.eq + br_if 1 (;@13;) local.get 0 - i32.const 4 - i32.add + i32.load offset=8 local.tee 0 - local.get 5 - i32.lt_u br_if 0 (;@14;) + br 2 (;@12;) end - local.get 6 - local.get 1 - i32.eq - br_if 11 (;@2;) - local.get 6 - local.get 6 - i32.load offset=4 - i32.const -2 - i32.and - i32.store offset=4 - local.get 1 - local.get 6 - local.get 1 - i32.sub - local.tee 0 - i32.const 1 - i32.or - i32.store offset=4 - local.get 6 - local.get 0 - i32.store + end + local.get 0 + i32.load offset=12 + i32.eqz + br_if 1 (;@11;) + end + i32.const 1048704 + local.set 0 + block ;; label = @12 + loop ;; label = @13 block ;; label = @14 local.get 0 - i32.const 256 - i32.lt_u - br_if 0 (;@14;) + i32.load + local.tee 5 local.get 1 - local.get 0 - call 8 - br 12 (;@2;) - end - local.get 0 - i32.const -8 - i32.and - i32.const 1048720 - i32.add - local.set 5 - block ;; label = @14 - block ;; label = @15 - i32.const 0 - i32.load offset=1048984 - local.tee 7 - i32.const 1 - local.get 0 - i32.const 3 - i32.shr_u - i32.shl - local.tee 0 - i32.and - i32.eqz - br_if 0 (;@15;) - local.get 5 - i32.load offset=8 - local.set 0 - br 1 (;@14;) - end - i32.const 0 - local.get 7 - local.get 0 - i32.or - i32.store offset=1048984 + i32.gt_u + br_if 0 (;@14;) local.get 5 - local.set 0 + local.get 0 + i32.load offset=4 + i32.add + local.tee 5 + local.get 1 + i32.gt_u + br_if 2 (;@12;) end - local.get 5 - local.get 1 - i32.store offset=8 - local.get 0 - local.get 1 - i32.store offset=12 - local.get 1 - local.get 5 - i32.store offset=12 - local.get 1 local.get 0 - i32.store offset=8 - br 11 (;@2;) + i32.load offset=8 + local.set 0 + br 0 (;@13;) end + end + i32.const 0 + local.get 6 + i32.store offset=1049004 + i32.const 0 + local.get 8 + i32.const -40 + i32.add + local.tee 0 + i32.store offset=1048996 + local.get 6 + local.get 0 + i32.const 1 + i32.or + i32.store offset=4 + local.get 6 + local.get 0 + i32.add + i32.const 40 + i32.store offset=4 + i32.const 0 + i32.const 2097152 + i32.store offset=1049016 + local.get 1 + local.get 5 + i32.const -32 + i32.add + i32.const -8 + i32.and + i32.const -8 + i32.add + local.tee 0 + local.get 0 + local.get 1 + i32.const 16 + i32.add + i32.lt_u + select + local.tee 7 + i32.const 27 + i32.store offset=4 + i32.const 0 + i64.load offset=1048704 align=4 + local.set 9 + local.get 7 + i32.const 16 + i32.add + i32.const 0 + i64.load offset=1048712 align=4 + i64.store align=4 + local.get 7 + local.get 9 + i64.store offset=8 align=4 + i32.const 0 + local.get 8 + i32.store offset=1048708 + i32.const 0 + local.get 6 + i32.store offset=1048704 + i32.const 0 + local.get 7 + i32.const 8 + i32.add + i32.store offset=1048712 + i32.const 0 + i32.const 0 + i32.store offset=1048716 + local.get 7 + i32.const 28 + i32.add + local.set 0 + loop ;; label = @12 local.get 0 - local.get 7 + i32.const 7 i32.store local.get 0 + i32.const 4 + i32.add + local.tee 0 + local.get 5 + i32.lt_u + br_if 0 (;@12;) + end + local.get 7 + local.get 1 + i32.eq + br_if 9 (;@2;) + local.get 7 + local.get 7 + i32.load offset=4 + i32.const -2 + i32.and + i32.store offset=4 + local.get 1 + local.get 7 + local.get 1 + i32.sub + local.tee 0 + i32.const 1 + i32.or + i32.store offset=4 + local.get 7 + local.get 0 + i32.store + block ;; label = @12 + local.get 0 + i32.const 256 + i32.lt_u + br_if 0 (;@12;) + local.get 1 local.get 0 - i32.load offset=4 - local.get 8 - i32.add - i32.store offset=4 - local.get 7 - local.get 2 - i32.const 3 - i32.or - i32.store offset=4 - local.get 5 - local.get 7 - local.get 2 - i32.add - local.tee 0 - i32.sub - local.set 2 + call 8 + br 10 (;@2;) + end + local.get 0 + i32.const -8 + i32.and + i32.const 1048720 + i32.add + local.set 5 + block ;; label = @12 block ;; label = @13 - local.get 5 - i32.const 0 - i32.load offset=1049004 - i32.eq - br_if 0 (;@13;) - local.get 5 i32.const 0 - i32.load offset=1049000 - i32.eq - br_if 5 (;@8;) - local.get 5 - i32.load offset=4 - local.tee 1 + i32.load offset=1048984 + local.tee 6 + i32.const 1 + local.get 0 i32.const 3 + i32.shr_u + i32.shl + local.tee 0 i32.and - i32.const 1 - i32.ne - br_if 8 (;@5;) - block ;; label = @14 - block ;; label = @15 - local.get 1 - i32.const -8 - i32.and - local.tee 6 - i32.const 256 - i32.lt_u - br_if 0 (;@15;) - local.get 5 - call 7 - br 1 (;@14;) - end - block ;; label = @15 - local.get 5 - i32.const 12 - i32.add - i32.load - local.tee 8 - local.get 5 - i32.const 8 - i32.add - i32.load - local.tee 4 - i32.eq - br_if 0 (;@15;) - local.get 4 - local.get 8 - i32.store offset=12 - local.get 8 - local.get 4 - i32.store offset=8 - br 1 (;@14;) - end - i32.const 0 - i32.const 0 - i32.load offset=1048984 - i32.const -2 - local.get 1 - i32.const 3 - i32.shr_u - i32.rotl - i32.and - i32.store offset=1048984 - end + br_if 0 (;@13;) + i32.const 0 local.get 6 - local.get 2 - i32.add - local.set 2 + local.get 0 + i32.or + i32.store offset=1048984 local.get 5 - local.get 6 - i32.add - local.tee 5 - i32.load offset=4 - local.set 1 - br 8 (;@5;) + local.set 0 + br 1 (;@12;) end - i32.const 0 - local.get 0 - i32.store offset=1049004 - i32.const 0 - i32.const 0 - i32.load offset=1048996 - local.get 2 - i32.add - local.tee 2 - i32.store offset=1048996 - local.get 0 - local.get 2 - i32.const 1 - i32.or - i32.store offset=4 - br 8 (;@4;) + local.get 5 + i32.load offset=8 + local.set 0 end - i32.const 0 - local.get 0 - local.get 2 - i32.sub - local.tee 1 - i32.store offset=1048996 - i32.const 0 - i32.const 0 - i32.load offset=1049004 - local.tee 0 - local.get 2 - i32.add - local.tee 5 - i32.store offset=1049004 local.get 5 local.get 1 - i32.const 1 - i32.or - i32.store offset=4 + i32.store offset=8 local.get 0 - local.get 2 - i32.const 3 - i32.or - i32.store offset=4 + local.get 1 + i32.store offset=12 + local.get 1 + local.get 5 + i32.store offset=12 + local.get 1 local.get 0 - i32.const 8 - i32.add - local.set 1 - br 10 (;@1;) + i32.store offset=8 + br 9 (;@2;) end - i32.const 0 - i32.load offset=1049000 - local.set 1 local.get 0 + local.get 6 + i32.store + local.get 0 + local.get 0 + i32.load offset=4 + local.get 8 + i32.add + i32.store offset=4 + local.get 6 local.get 2 + i32.const 3 + i32.or + i32.store offset=4 + local.get 5 + local.get 6 + local.get 2 + i32.add + local.tee 0 i32.sub - local.tee 5 - i32.const 16 - i32.lt_u - br_if 3 (;@7;) + local.set 1 + local.get 5 i32.const 0 + i32.load offset=1049004 + i32.eq + br_if 3 (;@7;) local.get 5 - i32.store offset=1048992 i32.const 0 - local.get 1 - local.get 2 - i32.add - local.tee 7 - i32.store offset=1049000 - local.get 7 + i32.load offset=1049000 + i32.eq + br_if 4 (;@6;) + block ;; label = @11 + local.get 5 + i32.load offset=4 + local.tee 2 + i32.const 3 + i32.and + i32.const 1 + i32.ne + br_if 0 (;@11;) + block ;; label = @12 + block ;; label = @13 + local.get 2 + i32.const -8 + i32.and + local.tee 7 + i32.const 256 + i32.lt_u + br_if 0 (;@13;) + local.get 5 + call 7 + br 1 (;@12;) + end + block ;; label = @13 + local.get 5 + i32.const 12 + i32.add + i32.load + local.tee 8 + local.get 5 + i32.const 8 + i32.add + i32.load + local.tee 4 + i32.eq + br_if 0 (;@13;) + local.get 4 + local.get 8 + i32.store offset=12 + local.get 8 + local.get 4 + i32.store offset=8 + br 1 (;@12;) + end + i32.const 0 + i32.const 0 + i32.load offset=1048984 + i32.const -2 + local.get 2 + i32.const 3 + i32.shr_u + i32.rotl + i32.and + i32.store offset=1048984 + end + local.get 7 + local.get 1 + i32.add + local.set 1 + local.get 5 + local.get 7 + i32.add + local.tee 5 + i32.load offset=4 + local.set 2 + end local.get 5 + local.get 2 + i32.const -2 + i32.and + i32.store offset=4 + local.get 0 + local.get 1 i32.const 1 i32.or i32.store offset=4 + local.get 0 + local.get 1 + i32.add + local.get 1 + i32.store + block ;; label = @11 + local.get 1 + i32.const 256 + i32.lt_u + br_if 0 (;@11;) + local.get 0 + local.get 1 + call 8 + br 8 (;@3;) + end + local.get 1 + i32.const -8 + i32.and + i32.const 1048720 + i32.add + local.set 5 + block ;; label = @11 + block ;; label = @12 + i32.const 0 + i32.load offset=1048984 + local.tee 2 + i32.const 1 + local.get 1 + i32.const 3 + i32.shr_u + i32.shl + local.tee 1 + i32.and + br_if 0 (;@12;) + i32.const 0 + local.get 2 + local.get 1 + i32.or + i32.store offset=1048984 + local.get 5 + local.set 1 + br 1 (;@11;) + end + local.get 5 + i32.load offset=8 + local.set 1 + end + local.get 5 + local.get 0 + i32.store offset=8 local.get 1 local.get 0 - i32.add + i32.store offset=12 + local.get 0 local.get 5 - i32.store + i32.store offset=12 + local.get 0 local.get 1 - local.get 2 - i32.const 3 - i32.or - i32.store offset=4 - br 4 (;@6;) + i32.store offset=8 + br 7 (;@3;) end i32.const 0 - local.get 7 - i32.store offset=1049020 - br 6 (;@3;) + local.get 0 + local.get 2 + i32.sub + local.tee 1 + i32.store offset=1048996 + i32.const 0 + i32.const 0 + i32.load offset=1049004 + local.tee 0 + local.get 2 + i32.add + local.tee 5 + i32.store offset=1049004 + local.get 5 + local.get 1 + i32.const 1 + i32.or + i32.store offset=4 + local.get 0 + local.get 2 + i32.const 3 + i32.or + i32.store offset=4 + local.get 0 + i32.const 8 + i32.add + local.set 1 + br 8 (;@1;) end + i32.const 0 + i32.load offset=1049000 + local.set 1 local.get 0 - local.get 6 - local.get 8 - i32.add - i32.store offset=4 + local.get 2 + i32.sub + local.tee 5 + i32.const 16 + i32.lt_u + br_if 3 (;@5;) i32.const 0 - i32.load offset=1049004 + local.get 5 + i32.store offset=1048992 i32.const 0 - i32.load offset=1048996 - local.get 8 + local.get 1 + local.get 2 i32.add - call 9 - br 6 (;@2;) + local.tee 6 + i32.store offset=1049000 + local.get 6 + local.get 5 + i32.const 1 + i32.or + i32.store offset=4 + local.get 1 + local.get 0 + i32.add + local.get 5 + i32.store + local.get 1 + local.get 2 + i32.const 3 + i32.or + i32.store offset=4 + br 4 (;@4;) end - i32.const 0 local.get 0 - i32.store offset=1049000 - i32.const 0 - i32.const 0 - i32.load offset=1048992 - local.get 2 + local.get 7 + local.get 8 i32.add - local.tee 2 - i32.store offset=1048992 - local.get 0 - local.get 2 - i32.const 1 - i32.or i32.store offset=4 - local.get 0 - local.get 2 + i32.const 0 + i32.load offset=1049004 + i32.const 0 + i32.load offset=1048996 + local.get 8 i32.add - local.get 2 - i32.store - br 3 (;@4;) + call 9 + br 5 (;@2;) end i32.const 0 - i32.const 0 - i32.store offset=1049000 + local.get 0 + i32.store offset=1049004 i32.const 0 i32.const 0 - i32.store offset=1048992 - local.get 1 - local.get 0 - i32.const 3 - i32.or - i32.store offset=4 + i32.load offset=1048996 local.get 1 - local.get 0 i32.add - local.tee 0 + local.tee 1 + i32.store offset=1048996 local.get 0 - i32.load offset=4 - i32.const 1 - i32.or - i32.store offset=4 - end - local.get 1 - i32.const 8 - i32.add - return - end - local.get 5 - local.get 1 - i32.const -2 - i32.and - i32.store offset=4 - local.get 0 - local.get 2 - i32.const 1 - i32.or - i32.store offset=4 - local.get 0 - local.get 2 - i32.add - local.get 2 - i32.store - block ;; label = @5 - local.get 2 - i32.const 256 - i32.lt_u - br_if 0 (;@5;) - local.get 0 - local.get 2 - call 8 - br 1 (;@4;) - end - local.get 2 - i32.const -8 - i32.and - i32.const 1048720 - i32.add - local.set 1 - block ;; label = @5 - block ;; label = @6 - i32.const 0 - i32.load offset=1048984 - local.tee 5 - i32.const 1 - local.get 2 - i32.const 3 - i32.shr_u - i32.shl - local.tee 2 - i32.and - i32.eqz - br_if 0 (;@6;) - local.get 1 - i32.load offset=8 - local.set 2 - br 1 (;@5;) - end - i32.const 0 - local.get 5 - local.get 2 - i32.or - i32.store offset=1048984 - local.get 1 - local.set 2 - end - local.get 1 - local.get 0 - i32.store offset=8 - local.get 2 - local.get 0 - i32.store offset=12 - local.get 0 - local.get 1 - i32.store offset=12 - local.get 0 - local.get 2 - i32.store offset=8 - end - local.get 7 - i32.const 8 - i32.add - return - end - i32.const 0 - i32.const 4095 - i32.store offset=1049024 - i32.const 0 - local.get 8 - i32.store offset=1048708 - i32.const 0 - local.get 7 - i32.store offset=1048704 - i32.const 0 - i32.const 1048720 - i32.store offset=1048732 - i32.const 0 - i32.const 1048728 - i32.store offset=1048740 - i32.const 0 - i32.const 1048720 - i32.store offset=1048728 - i32.const 0 - i32.const 1048736 - i32.store offset=1048748 - i32.const 0 - i32.const 1048728 - i32.store offset=1048736 - i32.const 0 - i32.const 1048744 - i32.store offset=1048756 - i32.const 0 - i32.const 1048736 - i32.store offset=1048744 - i32.const 0 - i32.const 1048752 - i32.store offset=1048764 - i32.const 0 - i32.const 1048744 - i32.store offset=1048752 - i32.const 0 - i32.const 1048760 - i32.store offset=1048772 - i32.const 0 - i32.const 1048752 - i32.store offset=1048760 - i32.const 0 - i32.const 1048768 - i32.store offset=1048780 - i32.const 0 - i32.const 1048760 - i32.store offset=1048768 - i32.const 0 - i32.const 1048776 - i32.store offset=1048788 - i32.const 0 - i32.const 1048768 - i32.store offset=1048776 - i32.const 0 - i32.const 0 - i32.store offset=1048716 - i32.const 0 - i32.const 1048784 - i32.store offset=1048796 - i32.const 0 - i32.const 1048776 - i32.store offset=1048784 - i32.const 0 - i32.const 1048784 - i32.store offset=1048792 - i32.const 0 - i32.const 1048792 - i32.store offset=1048804 - i32.const 0 - i32.const 1048792 - i32.store offset=1048800 - i32.const 0 - i32.const 1048800 - i32.store offset=1048812 - i32.const 0 - i32.const 1048800 - i32.store offset=1048808 - i32.const 0 - i32.const 1048808 - i32.store offset=1048820 - i32.const 0 - i32.const 1048808 - i32.store offset=1048816 - i32.const 0 - i32.const 1048816 - i32.store offset=1048828 - i32.const 0 - i32.const 1048816 - i32.store offset=1048824 - i32.const 0 - i32.const 1048824 - i32.store offset=1048836 - i32.const 0 - i32.const 1048824 - i32.store offset=1048832 - i32.const 0 - i32.const 1048832 - i32.store offset=1048844 - i32.const 0 - i32.const 1048832 - i32.store offset=1048840 - i32.const 0 - i32.const 1048840 - i32.store offset=1048852 - i32.const 0 - i32.const 1048840 - i32.store offset=1048848 - i32.const 0 - i32.const 1048848 - i32.store offset=1048860 - i32.const 0 - i32.const 1048856 - i32.store offset=1048868 - i32.const 0 - i32.const 1048848 - i32.store offset=1048856 - i32.const 0 - i32.const 1048864 - i32.store offset=1048876 - i32.const 0 - i32.const 1048856 - i32.store offset=1048864 - i32.const 0 - i32.const 1048872 - i32.store offset=1048884 - i32.const 0 - i32.const 1048864 - i32.store offset=1048872 - i32.const 0 - i32.const 1048880 - i32.store offset=1048892 - i32.const 0 - i32.const 1048872 - i32.store offset=1048880 - i32.const 0 - i32.const 1048888 - i32.store offset=1048900 - i32.const 0 - i32.const 1048880 - i32.store offset=1048888 - i32.const 0 - i32.const 1048896 - i32.store offset=1048908 - i32.const 0 - i32.const 1048888 - i32.store offset=1048896 - i32.const 0 - i32.const 1048904 - i32.store offset=1048916 - i32.const 0 - i32.const 1048896 - i32.store offset=1048904 - i32.const 0 - i32.const 1048912 - i32.store offset=1048924 - i32.const 0 - i32.const 1048904 - i32.store offset=1048912 - i32.const 0 - i32.const 1048920 - i32.store offset=1048932 - i32.const 0 - i32.const 1048912 - i32.store offset=1048920 - i32.const 0 - i32.const 1048928 - i32.store offset=1048940 - i32.const 0 - i32.const 1048920 - i32.store offset=1048928 - i32.const 0 - i32.const 1048936 - i32.store offset=1048948 - i32.const 0 - i32.const 1048928 - i32.store offset=1048936 - i32.const 0 - i32.const 1048944 - i32.store offset=1048956 - i32.const 0 - i32.const 1048936 - i32.store offset=1048944 - i32.const 0 - i32.const 1048952 - i32.store offset=1048964 - i32.const 0 - i32.const 1048944 - i32.store offset=1048952 - i32.const 0 - i32.const 1048960 - i32.store offset=1048972 - i32.const 0 - i32.const 1048952 - i32.store offset=1048960 - i32.const 0 - i32.const 1048968 - i32.store offset=1048980 - i32.const 0 - i32.const 1048960 - i32.store offset=1048968 - i32.const 0 - local.get 7 - i32.store offset=1049004 - i32.const 0 - i32.const 1048968 - i32.store offset=1048976 - i32.const 0 - local.get 8 - i32.const -40 - i32.add - local.tee 0 - i32.store offset=1048996 - local.get 7 - local.get 0 - i32.const 1 - i32.or - i32.store offset=4 - local.get 7 - local.get 0 + local.get 1 + i32.const 1 + i32.or + i32.store offset=4 + br 3 (;@3;) + end + i32.const 0 + local.get 0 + i32.store offset=1049000 + i32.const 0 + i32.const 0 + i32.load offset=1048992 + local.get 1 + i32.add + local.tee 1 + i32.store offset=1048992 + local.get 0 + local.get 1 + i32.const 1 + i32.or + i32.store offset=4 + local.get 0 + local.get 1 + i32.add + local.get 1 + i32.store + br 2 (;@3;) + end + i32.const 0 + i32.const 0 + i32.store offset=1049000 + i32.const 0 + i32.const 0 + i32.store offset=1048992 + local.get 1 + local.get 0 + i32.const 3 + i32.or + i32.store offset=4 + local.get 1 + local.get 0 + i32.add + local.tee 0 + local.get 0 + i32.load offset=4 + i32.const 1 + i32.or + i32.store offset=4 + end + local.get 1 + i32.const 8 + i32.add + return + end + local.get 6 + i32.const 8 i32.add - i32.const 40 - i32.store offset=4 - i32.const 0 - i32.const 2097152 - i32.store offset=1049016 + return end i32.const 0 local.set 1 @@ -2054,92 +2057,99 @@ i32.and i32.store offset=1048984 end - block ;; label = @3 - local.get 2 - i32.load offset=4 - local.tee 3 - i32.const 2 - i32.and - i32.eqz - br_if 0 (;@3;) - local.get 2 - local.get 3 - i32.const -2 - i32.and - i32.store offset=4 - local.get 0 - local.get 1 - i32.const 1 - i32.or - i32.store offset=4 - local.get 0 - local.get 1 - i32.add - local.get 1 - i32.store - br 2 (;@1;) - end block ;; label = @3 block ;; label = @4 - local.get 2 - i32.const 0 - i32.load offset=1049004 - i32.eq - br_if 0 (;@4;) - local.get 2 - i32.const 0 - i32.load offset=1049000 - i32.eq - br_if 1 (;@3;) - local.get 3 - i32.const -8 - i32.and - local.tee 4 - local.get 1 - i32.add - local.set 1 block ;; label = @5 - block ;; label = @6 - local.get 4 - i32.const 256 - i32.lt_u - br_if 0 (;@6;) - local.get 2 - call 7 - br 1 (;@5;) - end - block ;; label = @6 - local.get 2 - i32.const 12 - i32.add - i32.load - local.tee 4 - local.get 2 - i32.const 8 - i32.add - i32.load - local.tee 2 - i32.eq - br_if 0 (;@6;) - local.get 2 - local.get 4 - i32.store offset=12 - local.get 4 - local.get 2 - i32.store offset=8 - br 1 (;@5;) - end + local.get 2 + i32.load offset=4 + local.tee 3 + i32.const 2 + i32.and + br_if 0 (;@5;) + local.get 2 i32.const 0 + i32.load offset=1049004 + i32.eq + br_if 2 (;@3;) + local.get 2 i32.const 0 - i32.load offset=1048984 - i32.const -2 + i32.load offset=1049000 + i32.eq + br_if 4 (;@1;) local.get 3 - i32.const 3 - i32.shr_u - i32.rotl + i32.const -8 i32.and - i32.store offset=1048984 + local.tee 4 + local.get 1 + i32.add + local.set 1 + block ;; label = @6 + block ;; label = @7 + local.get 4 + i32.const 256 + i32.lt_u + br_if 0 (;@7;) + local.get 2 + call 7 + br 1 (;@6;) + end + block ;; label = @7 + local.get 2 + i32.const 12 + i32.add + i32.load + local.tee 4 + local.get 2 + i32.const 8 + i32.add + i32.load + local.tee 2 + i32.eq + br_if 0 (;@7;) + local.get 2 + local.get 4 + i32.store offset=12 + local.get 4 + local.get 2 + i32.store offset=8 + br 1 (;@6;) + end + i32.const 0 + i32.const 0 + i32.load offset=1048984 + i32.const -2 + local.get 3 + i32.const 3 + i32.shr_u + i32.rotl + i32.and + i32.store offset=1048984 + end + local.get 0 + local.get 1 + i32.const 1 + i32.or + i32.store offset=4 + local.get 0 + local.get 1 + i32.add + local.get 1 + i32.store + local.get 0 + i32.const 0 + i32.load offset=1049000 + i32.ne + br_if 1 (;@4;) + i32.const 0 + local.get 1 + i32.store offset=1048992 + return end + local.get 2 + local.get 3 + i32.const -2 + i32.and + i32.store offset=4 local.get 0 local.get 1 i32.const 1 @@ -2150,123 +2160,112 @@ i32.add local.get 1 i32.store + end + block ;; label = @4 + local.get 1 + i32.const 256 + i32.lt_u + br_if 0 (;@4;) local.get 0 - i32.const 0 - i32.load offset=1049000 - i32.ne - br_if 3 (;@1;) - i32.const 0 local.get 1 - i32.store offset=1048992 - br 2 (;@2;) + call 8 + return end - i32.const 0 - local.get 0 - i32.store offset=1049004 - i32.const 0 - i32.const 0 - i32.load offset=1048996 local.get 1 + i32.const -8 + i32.and + i32.const 1048720 i32.add - local.tee 1 - i32.store offset=1048996 + local.set 2 + block ;; label = @4 + block ;; label = @5 + i32.const 0 + i32.load offset=1048984 + local.tee 3 + i32.const 1 + local.get 1 + i32.const 3 + i32.shr_u + i32.shl + local.tee 1 + i32.and + br_if 0 (;@5;) + i32.const 0 + local.get 3 + local.get 1 + i32.or + i32.store offset=1048984 + local.get 2 + local.set 1 + br 1 (;@4;) + end + local.get 2 + i32.load offset=8 + local.set 1 + end + local.get 2 local.get 0 + i32.store offset=8 local.get 1 - i32.const 1 - i32.or - i32.store offset=4 local.get 0 - i32.const 0 - i32.load offset=1049000 - i32.ne - br_if 1 (;@2;) - i32.const 0 - i32.const 0 - i32.store offset=1048992 - i32.const 0 - i32.const 0 - i32.store offset=1049000 + i32.store offset=12 + local.get 0 + local.get 2 + i32.store offset=12 + local.get 0 + local.get 1 + i32.store offset=8 return end i32.const 0 local.get 0 - i32.store offset=1049000 + i32.store offset=1049004 i32.const 0 i32.const 0 - i32.load offset=1048992 + i32.load offset=1048996 local.get 1 i32.add local.tee 1 - i32.store offset=1048992 + i32.store offset=1048996 local.get 0 local.get 1 i32.const 1 i32.or i32.store offset=4 local.get 0 - local.get 1 - i32.add - local.get 1 - i32.store - return - end - return - end - block ;; label = @1 - local.get 1 - i32.const 256 - i32.lt_u - br_if 0 (;@1;) - local.get 0 - local.get 1 - call 8 - return - end - local.get 1 - i32.const -8 - i32.and - i32.const 1048720 - i32.add - local.set 2 - block ;; label = @1 - block ;; label = @2 i32.const 0 - i32.load offset=1048984 - local.tee 3 - i32.const 1 - local.get 1 - i32.const 3 - i32.shr_u - i32.shl - local.tee 1 - i32.and - i32.eqz + i32.load offset=1049000 + i32.ne br_if 0 (;@2;) - local.get 2 - i32.load offset=8 - local.set 1 - br 1 (;@1;) + i32.const 0 + i32.const 0 + i32.store offset=1048992 + i32.const 0 + i32.const 0 + i32.store offset=1049000 end - i32.const 0 - local.get 3 - local.get 1 - i32.or - i32.store offset=1048984 - local.get 2 - local.set 1 + return end - local.get 2 + i32.const 0 local.get 0 - i32.store offset=8 + i32.store offset=1049000 + i32.const 0 + i32.const 0 + i32.load offset=1048992 local.get 1 + i32.add + local.tee 1 + i32.store offset=1048992 local.get 0 - i32.store offset=12 - local.get 0 - local.get 2 - i32.store offset=12 + local.get 1 + i32.const 1 + i32.or + i32.store offset=4 local.get 0 local.get 1 - i32.store offset=8 + i32.add + local.get 1 + i32.store ) (func (;7;) (type 4) (param i32) (local i32 i32 i32 i32 i32) @@ -2470,45 +2469,44 @@ i32.add local.set 3 block ;; label = @1 + block ;; label = @2 + i32.const 0 + i32.load offset=1048988 + local.tee 4 + i32.const 1 + local.get 2 + i32.shl + local.tee 5 + i32.and + br_if 0 (;@2;) + i32.const 0 + local.get 4 + local.get 5 + i32.or + i32.store offset=1048988 + local.get 3 + local.get 0 + i32.store + local.get 0 + local.get 3 + i32.store offset=24 + br 1 (;@1;) + end block ;; label = @2 block ;; label = @3 block ;; label = @4 - block ;; label = @5 - i32.const 0 - i32.load offset=1048988 - local.tee 4 - i32.const 1 - local.get 2 - i32.shl - local.tee 5 - i32.and - i32.eqz - br_if 0 (;@5;) - local.get 3 - i32.load - local.tee 4 - i32.load offset=4 - i32.const -8 - i32.and - local.get 1 - i32.ne - br_if 1 (;@4;) - local.get 4 - local.set 2 - br 2 (;@3;) - end - i32.const 0 - local.get 4 - local.get 5 - i32.or - i32.store offset=1048988 local.get 3 - local.get 0 - i32.store - local.get 0 - local.get 3 - i32.store offset=24 - br 3 (;@1;) + i32.load + local.tee 4 + i32.load offset=4 + i32.const -8 + i32.and + local.get 1 + i32.ne + br_if 0 (;@4;) + local.get 4 + local.set 2 + br 1 (;@3;) end local.get 1 i32.const 0 @@ -2643,137 +2641,118 @@ local.set 3 block ;; label = @1 block ;; label = @2 - local.get 2 - i32.const 1 - i32.and - br_if 0 (;@2;) - local.get 2 - i32.const 3 - i32.and - i32.eqz - br_if 1 (;@1;) - local.get 1 - i32.load - local.tee 2 - local.get 0 - i32.add - local.set 0 - block ;; label = @3 - local.get 1 - local.get 2 - i32.sub - local.tee 1 - i32.const 0 - i32.load offset=1049000 - i32.ne - br_if 0 (;@3;) - local.get 3 - i32.load offset=4 - i32.const 3 - i32.and - i32.const 3 - i32.ne - br_if 1 (;@2;) - i32.const 0 - local.get 0 - i32.store offset=1048992 - local.get 3 - local.get 3 - i32.load offset=4 - i32.const -2 - i32.and - i32.store offset=4 - local.get 1 - local.get 0 - i32.const 1 - i32.or - i32.store offset=4 - local.get 3 - local.get 0 - i32.store - return - end - block ;; label = @3 - local.get 2 - i32.const 256 - i32.lt_u - br_if 0 (;@3;) - local.get 1 - call 7 - br 1 (;@2;) - end - block ;; label = @3 - local.get 1 - i32.const 12 - i32.add - i32.load - local.tee 4 - local.get 1 - i32.const 8 - i32.add - i32.load - local.tee 5 - i32.eq - br_if 0 (;@3;) - local.get 5 - local.get 4 - i32.store offset=12 - local.get 4 - local.get 5 - i32.store offset=8 - br 1 (;@2;) - end - i32.const 0 - i32.const 0 - i32.load offset=1048984 - i32.const -2 - local.get 2 - i32.const 3 - i32.shr_u - i32.rotl - i32.and - i32.store offset=1048984 - end - block ;; label = @2 - block ;; label = @3 - local.get 3 - i32.load offset=4 - local.tee 2 - i32.const 2 - i32.and - i32.eqz - br_if 0 (;@3;) - local.get 3 - local.get 2 - i32.const -2 - i32.and - i32.store offset=4 - local.get 1 - local.get 0 - i32.const 1 - i32.or - i32.store offset=4 - local.get 1 - local.get 0 - i32.add - local.get 0 - i32.store - br 1 (;@2;) - end block ;; label = @3 + block ;; label = @4 + local.get 2 + i32.const 1 + i32.and + br_if 0 (;@4;) + local.get 2 + i32.const 3 + i32.and + i32.eqz + br_if 1 (;@3;) + local.get 1 + i32.load + local.tee 2 + local.get 0 + i32.add + local.set 0 + block ;; label = @5 + local.get 1 + local.get 2 + i32.sub + local.tee 1 + i32.const 0 + i32.load offset=1049000 + i32.ne + br_if 0 (;@5;) + local.get 3 + i32.load offset=4 + i32.const 3 + i32.and + i32.const 3 + i32.ne + br_if 1 (;@4;) + i32.const 0 + local.get 0 + i32.store offset=1048992 + local.get 3 + local.get 3 + i32.load offset=4 + i32.const -2 + i32.and + i32.store offset=4 + local.get 1 + local.get 0 + i32.const 1 + i32.or + i32.store offset=4 + local.get 3 + local.get 0 + i32.store + return + end + block ;; label = @5 + local.get 2 + i32.const 256 + i32.lt_u + br_if 0 (;@5;) + local.get 1 + call 7 + br 1 (;@4;) + end + block ;; label = @5 + local.get 1 + i32.const 12 + i32.add + i32.load + local.tee 4 + local.get 1 + i32.const 8 + i32.add + i32.load + local.tee 5 + i32.eq + br_if 0 (;@5;) + local.get 5 + local.get 4 + i32.store offset=12 + local.get 4 + local.get 5 + i32.store offset=8 + br 1 (;@4;) + end + i32.const 0 + i32.const 0 + i32.load offset=1048984 + i32.const -2 + local.get 2 + i32.const 3 + i32.shr_u + i32.rotl + i32.and + i32.store offset=1048984 + end block ;; label = @4 block ;; label = @5 block ;; label = @6 + local.get 3 + i32.load offset=4 + local.tee 2 + i32.const 2 + i32.and + br_if 0 (;@6;) local.get 3 i32.const 0 i32.load offset=1049004 i32.eq - br_if 0 (;@6;) + br_if 2 (;@4;) local.get 3 i32.const 0 i32.load offset=1049000 i32.eq - br_if 1 (;@5;) + br_if 5 (;@1;) local.get 2 i32.const -8 i32.and @@ -2837,133 +2816,126 @@ i32.const 0 i32.load offset=1049000 i32.ne - br_if 4 (;@2;) + br_if 1 (;@5;) i32.const 0 local.get 0 i32.store offset=1048992 return end - i32.const 0 - local.get 1 - i32.store offset=1049004 - i32.const 0 - i32.const 0 - i32.load offset=1048996 - local.get 0 - i32.add - local.tee 0 - i32.store offset=1048996 + local.get 3 + local.get 2 + i32.const -2 + i32.and + i32.store offset=4 local.get 1 local.get 0 i32.const 1 i32.or i32.store offset=4 local.get 1 - i32.const 0 - i32.load offset=1049000 - i32.eq - br_if 1 (;@4;) - br 2 (;@3;) + local.get 0 + i32.add + local.get 0 + i32.store end - i32.const 0 + local.get 0 + i32.const 256 + i32.lt_u + br_if 2 (;@2;) local.get 1 - i32.store offset=1049000 + local.get 0 + call 8 i32.const 0 i32.const 0 - i32.load offset=1048992 - local.get 0 + i32.load offset=1049024 + i32.const -1 i32.add - local.tee 0 - i32.store offset=1048992 - local.get 1 - local.get 0 - i32.const 1 - i32.or - i32.store offset=4 + local.tee 1 + i32.store offset=1049024 local.get 1 - local.get 0 - i32.add - local.get 0 - i32.store + br_if 1 (;@3;) + call 11 return end i32.const 0 + local.get 1 + i32.store offset=1049004 i32.const 0 - i32.store offset=1048992 i32.const 0 + i32.load offset=1048996 + local.get 0 + i32.add + local.tee 0 + i32.store offset=1048996 + local.get 1 + local.get 0 + i32.const 1 + i32.or + i32.store offset=4 + block ;; label = @4 + local.get 1 + i32.const 0 + i32.load offset=1049000 + i32.ne + br_if 0 (;@4;) + i32.const 0 + i32.const 0 + i32.store offset=1048992 + i32.const 0 + i32.const 0 + i32.store offset=1049000 + end + local.get 0 i32.const 0 - i32.store offset=1049000 - end - local.get 0 - i32.const 0 - i32.load offset=1049016 - i32.le_u - br_if 1 (;@1;) - i32.const 0 - i32.load offset=1049004 - local.tee 0 - i32.eqz - br_if 1 (;@1;) - block ;; label = @3 + i32.load offset=1049016 + i32.le_u + br_if 0 (;@3;) i32.const 0 - i32.load offset=1048996 - i32.const 41 - i32.lt_u + i32.load offset=1049004 + local.tee 0 + i32.eqz br_if 0 (;@3;) - i32.const 1048704 - local.set 1 - loop ;; label = @4 - block ;; label = @5 + block ;; label = @4 + i32.const 0 + i32.load offset=1048996 + i32.const 41 + i32.lt_u + br_if 0 (;@4;) + i32.const 1048704 + local.set 1 + loop ;; label = @5 + block ;; label = @6 + local.get 1 + i32.load + local.tee 3 + local.get 0 + i32.gt_u + br_if 0 (;@6;) + local.get 3 + local.get 1 + i32.load offset=4 + i32.add + local.get 0 + i32.gt_u + br_if 2 (;@4;) + end local.get 1 - i32.load - local.tee 3 - local.get 0 - i32.gt_u + i32.load offset=8 + local.tee 1 br_if 0 (;@5;) - local.get 3 - local.get 1 - i32.load offset=4 - i32.add - local.get 0 - i32.gt_u - br_if 2 (;@3;) end - local.get 1 - i32.load offset=8 - local.tee 1 - br_if 0 (;@4;) end + call 11 + i32.const 0 + i32.load offset=1048996 + i32.const 0 + i32.load offset=1049016 + i32.le_u + br_if 0 (;@3;) + i32.const 0 + i32.const -1 + i32.store offset=1049016 end - call 11 - i32.const 0 - i32.load offset=1048996 - i32.const 0 - i32.load offset=1049016 - i32.le_u - br_if 1 (;@1;) - i32.const 0 - i32.const -1 - i32.store offset=1049016 - return - end - block ;; label = @2 - local.get 0 - i32.const 256 - i32.lt_u - br_if 0 (;@2;) - local.get 1 - local.get 0 - call 8 - i32.const 0 - i32.const 0 - i32.load offset=1049024 - i32.const -1 - i32.add - local.tee 1 - i32.store offset=1049024 - local.get 1 - br_if 1 (;@1;) - call 11 return end local.get 0 @@ -2984,19 +2956,18 @@ i32.shl local.tee 0 i32.and - i32.eqz br_if 0 (;@3;) + i32.const 0 + local.get 2 + local.get 0 + i32.or + i32.store offset=1048984 local.get 3 - i32.load offset=8 local.set 0 br 1 (;@2;) end - i32.const 0 - local.get 2 - local.get 0 - i32.or - i32.store offset=1048984 local.get 3 + i32.load offset=8 local.set 0 end local.get 3 @@ -3011,7 +2982,28 @@ local.get 1 local.get 0 i32.store offset=8 + return end + i32.const 0 + local.get 1 + i32.store offset=1049000 + i32.const 0 + i32.const 0 + i32.load offset=1048992 + local.get 0 + i32.add + local.tee 0 + i32.store offset=1048992 + local.get 1 + local.get 0 + i32.const 1 + i32.or + i32.store offset=4 + local.get 1 + local.get 0 + i32.add + local.get 0 + i32.store ) (func (;11;) (type 0) (local i32 i32) @@ -3497,8 +3489,8 @@ block ;; label = @1 block ;; label = @2 local.get 2 - i32.const 15 - i32.gt_u + i32.const 16 + i32.ge_u br_if 0 (;@2;) local.get 0 local.set 3 diff --git a/homestar-wasm/fixtures/example_add_component.wasm b/homestar-wasm/fixtures/example_add_component.wasm index b6094828..4d0f6c69 100644 Binary files a/homestar-wasm/fixtures/example_add_component.wasm and b/homestar-wasm/fixtures/example_add_component.wasm differ diff --git a/homestar-wasm/fixtures/example_add_component.wat b/homestar-wasm/fixtures/example_add_component.wat index 72935d99..95d691cd 100644 --- a/homestar-wasm/fixtures/example_add_component.wat +++ b/homestar-wasm/fixtures/example_add_component.wat @@ -403,7 +403,7 @@ block ;; label = @6 i32.const 0 i32.load offset=1048984 - local.tee 7 + local.tee 6 i32.const 16 local.get 0 i32.const 11 @@ -433,51 +433,51 @@ i32.and local.get 1 i32.add - local.tee 2 + local.tee 1 i32.const 3 i32.shl - local.tee 5 + local.tee 2 i32.const 1048728 i32.add i32.load local.tee 0 i32.const 8 i32.add - local.tee 6 + local.tee 7 i32.load - local.tee 1 - local.get 5 + local.tee 5 + local.get 2 i32.const 1048720 i32.add - local.tee 5 + local.tee 2 i32.eq br_if 0 (;@8;) - local.get 1 local.get 5 + local.get 2 i32.store offset=12 + local.get 2 local.get 5 - local.get 1 i32.store offset=8 br 1 (;@7;) end i32.const 0 - local.get 7 + local.get 6 i32.const -2 - local.get 2 + local.get 1 i32.rotl i32.and i32.store offset=1048984 end local.get 0 - local.get 2 + local.get 1 i32.const 3 i32.shl - local.tee 2 + local.tee 1 i32.const 3 i32.or i32.store offset=4 local.get 0 - local.get 2 + local.get 1 i32.add local.tee 0 local.get 0 @@ -485,7 +485,7 @@ i32.const 1 i32.or i32.store offset=4 - local.get 6 + local.get 7 return end local.get 2 @@ -514,7 +514,7 @@ i32.const 1048576 i32.add i32.load - local.tee 6 + local.tee 7 i32.load offset=4 i32.const -8 i32.and @@ -523,11 +523,11 @@ local.set 5 block ;; label = @13 block ;; label = @14 - local.get 6 + local.get 7 i32.load offset=16 local.tee 0 br_if 0 (;@14;) - local.get 6 + local.get 7 i32.const 20 i32.add i32.load @@ -545,7 +545,7 @@ local.tee 8 local.get 5 i32.lt_u - local.set 7 + local.set 6 block ;; label = @15 local.get 0 i32.load offset=16 @@ -559,47 +559,47 @@ end local.get 8 local.get 5 - local.get 7 + local.get 6 select local.set 5 local.get 0 - local.get 6 local.get 7 + local.get 6 select - local.set 6 + local.set 7 local.get 1 local.set 0 local.get 1 br_if 0 (;@14;) end end - local.get 6 + local.get 7 call 7 local.get 5 i32.const 16 i32.lt_u br_if 2 (;@10;) - local.get 6 + local.get 7 local.get 2 i32.const 3 i32.or i32.store offset=4 - local.get 6 + local.get 7 local.get 2 i32.add - local.tee 2 + local.tee 1 local.get 5 i32.const 1 i32.or i32.store offset=4 - local.get 2 + local.get 1 local.get 5 i32.add local.get 5 i32.store i32.const 0 i32.load offset=1048992 - local.tee 7 + local.tee 6 br_if 1 (;@11;) br 5 (;@7;) end @@ -624,7 +624,7 @@ local.tee 1 i32.const 3 i32.shl - local.tee 6 + local.tee 7 i32.const 1048728 i32.add i32.load @@ -634,22 +634,22 @@ local.tee 8 i32.load local.tee 5 - local.get 6 + local.get 7 i32.const 1048720 i32.add - local.tee 6 + local.tee 7 i32.eq br_if 0 (;@13;) local.get 5 - local.get 6 + local.get 7 i32.store offset=12 - local.get 6 + local.get 7 local.get 5 i32.store offset=8 br 1 (;@12;) end i32.const 0 - local.get 7 + local.get 6 i32.const -2 local.get 1 i32.rotl @@ -664,34 +664,34 @@ local.get 0 local.get 2 i32.add - local.tee 7 + local.tee 6 local.get 1 i32.const 3 i32.shl - local.tee 1 + local.tee 5 local.get 2 i32.sub - local.tee 2 + local.tee 1 i32.const 1 i32.or i32.store offset=4 local.get 0 - local.get 1 + local.get 5 i32.add - local.get 2 + local.get 1 i32.store i32.const 0 i32.load offset=1048992 - local.tee 5 + local.tee 2 br_if 2 (;@9;) br 3 (;@8;) end - local.get 7 + local.get 6 i32.const -8 i32.and i32.const 1048720 i32.add - local.set 1 + local.set 2 i32.const 0 i32.load offset=1049000 local.set 0 @@ -701,42 +701,41 @@ i32.load offset=1048984 local.tee 8 i32.const 1 - local.get 7 + local.get 6 i32.const 3 i32.shr_u i32.shl - local.tee 7 + local.tee 6 i32.and - i32.eqz br_if 0 (;@12;) - local.get 1 - i32.load offset=8 - local.set 7 + i32.const 0 + local.get 8 + local.get 6 + i32.or + i32.store offset=1048984 + local.get 2 + local.set 6 br 1 (;@11;) end - i32.const 0 - local.get 8 - local.get 7 - i32.or - i32.store offset=1048984 - local.get 1 - local.set 7 + local.get 2 + i32.load offset=8 + local.set 6 end - local.get 1 + local.get 2 local.get 0 i32.store offset=8 - local.get 7 + local.get 6 local.get 0 i32.store offset=12 local.get 0 - local.get 1 + local.get 2 i32.store offset=12 local.get 0 - local.get 7 + local.get 6 i32.store offset=8 br 3 (;@7;) end - local.get 6 + local.get 7 local.get 5 local.get 2 i32.add @@ -744,7 +743,7 @@ i32.const 3 i32.or i32.store offset=4 - local.get 6 + local.get 7 local.get 0 i32.add local.tee 0 @@ -755,12 +754,12 @@ i32.store offset=4 br 3 (;@6;) end - local.get 5 + local.get 2 i32.const -8 i32.and i32.const 1048720 i32.add - local.set 1 + local.set 5 i32.const 0 i32.load offset=1049000 local.set 0 @@ -768,59 +767,58 @@ block ;; label = @10 i32.const 0 i32.load offset=1048984 - local.tee 6 + local.tee 7 i32.const 1 - local.get 5 + local.get 2 i32.const 3 i32.shr_u i32.shl - local.tee 5 + local.tee 2 i32.and - i32.eqz br_if 0 (;@10;) - local.get 1 - i32.load offset=8 - local.set 5 + i32.const 0 + local.get 7 + local.get 2 + i32.or + i32.store offset=1048984 + local.get 5 + local.set 2 br 1 (;@9;) end - i32.const 0 - local.get 6 local.get 5 - i32.or - i32.store offset=1048984 - local.get 1 - local.set 5 + i32.load offset=8 + local.set 2 end - local.get 1 + local.get 5 local.get 0 i32.store offset=8 - local.get 5 + local.get 2 local.get 0 i32.store offset=12 local.get 0 - local.get 1 + local.get 5 i32.store offset=12 local.get 0 - local.get 5 + local.get 2 i32.store offset=8 end i32.const 0 - local.get 7 + local.get 6 i32.store offset=1049000 i32.const 0 - local.get 2 + local.get 1 i32.store offset=1048992 local.get 8 return end i32.const 0 - local.get 2 + local.get 1 i32.store offset=1049000 i32.const 0 local.get 5 i32.store offset=1048992 end - local.get 6 + local.get 7 i32.const 8 i32.add return @@ -859,21 +857,30 @@ br_if 1 (;@3;) end loop ;; label = @4 + local.get 0 + local.get 6 local.get 0 i32.load offset=4 i32.const -8 i32.and local.tee 5 local.get 2 - i32.ge_u - local.get 5 - local.get 2 i32.sub local.tee 8 local.get 1 i32.lt_u - i32.and + local.tee 4 + select + local.set 3 + local.get 5 + local.get 2 + i32.lt_u local.set 7 + local.get 8 + local.get 1 + local.get 4 + select + local.set 8 block ;; label = @5 local.get 0 i32.load offset=16 @@ -885,13 +892,13 @@ i32.load local.set 5 end - local.get 0 local.get 6 + local.get 3 local.get 7 select local.set 6 - local.get 8 local.get 1 + local.get 8 local.get 7 select local.set 1 @@ -959,12 +966,12 @@ i32.and i32.const 1048720 i32.add - local.set 2 + local.set 5 block ;; label = @5 block ;; label = @6 i32.const 0 i32.load offset=1048984 - local.tee 5 + local.tee 2 i32.const 1 local.get 1 i32.const 3 @@ -972,29 +979,28 @@ i32.shl local.tee 1 i32.and - i32.eqz br_if 0 (;@6;) + i32.const 0 local.get 2 - i32.load offset=8 + local.get 1 + i32.or + i32.store offset=1048984 + local.get 5 local.set 1 br 1 (;@5;) end - i32.const 0 local.get 5 - local.get 1 - i32.or - i32.store offset=1048984 - local.get 2 + i32.load offset=8 local.set 1 end - local.get 2 + local.get 5 local.get 0 i32.store offset=8 local.get 1 local.get 0 i32.store offset=12 local.get 0 - local.get 2 + local.get 5 i32.store offset=12 local.get 0 local.get 1 @@ -1032,887 +1038,884 @@ block ;; label = @7 block ;; label = @8 block ;; label = @9 + i32.const 0 + i32.load offset=1048992 + local.tee 0 + local.get 2 + i32.ge_u + br_if 0 (;@9;) block ;; label = @10 + i32.const 0 + i32.load offset=1048996 + local.tee 0 + local.get 2 + i32.gt_u + br_if 0 (;@10;) + i32.const 0 + local.set 1 + local.get 2 + i32.const 65583 + i32.add + local.tee 5 + i32.const 16 + i32.shr_u + memory.grow + local.tee 0 + i32.const -1 + i32.eq + local.tee 7 + br_if 9 (;@1;) + local.get 0 + i32.const 16 + i32.shl + local.tee 6 + i32.eqz + br_if 9 (;@1;) + i32.const 0 + i32.const 0 + i32.load offset=1049008 + i32.const 0 + local.get 5 + i32.const -65536 + i32.and + local.get 7 + select + local.tee 8 + i32.add + local.tee 0 + i32.store offset=1049008 + i32.const 0 + i32.const 0 + i32.load offset=1049012 + local.tee 1 + local.get 0 + local.get 1 + local.get 0 + i32.gt_u + select + i32.store offset=1049012 block ;; label = @11 - i32.const 0 - i32.load offset=1048992 - local.tee 0 - local.get 2 - i32.ge_u - br_if 0 (;@11;) block ;; label = @12 + block ;; label = @13 + i32.const 0 + i32.load offset=1049004 + local.tee 1 + i32.eqz + br_if 0 (;@13;) + i32.const 1048704 + local.set 0 + loop ;; label = @14 + local.get 0 + i32.load + local.tee 5 + local.get 0 + i32.load offset=4 + local.tee 7 + i32.add + local.get 6 + i32.eq + br_if 2 (;@12;) + local.get 0 + i32.load offset=8 + local.tee 0 + br_if 0 (;@14;) + br 3 (;@11;) + end + end + block ;; label = @13 + block ;; label = @14 + i32.const 0 + i32.load offset=1049020 + local.tee 0 + i32.eqz + br_if 0 (;@14;) + local.get 0 + local.get 6 + i32.le_u + br_if 1 (;@13;) + end + i32.const 0 + local.get 6 + i32.store offset=1049020 + end i32.const 0 - i32.load offset=1048996 - local.tee 0 - local.get 2 - i32.gt_u - br_if 0 (;@12;) + i32.const 4095 + i32.store offset=1049024 i32.const 0 - local.set 1 - local.get 2 - i32.const 65583 - i32.add - local.tee 5 - i32.const 16 - i32.shr_u - memory.grow - local.tee 0 - i32.const -1 - i32.eq - local.tee 6 - br_if 11 (;@1;) - local.get 0 - i32.const 16 - i32.shl - local.tee 7 - i32.eqz - br_if 11 (;@1;) + local.get 8 + i32.store offset=1048708 i32.const 0 + local.get 6 + i32.store offset=1048704 i32.const 0 - i32.load offset=1049008 + i32.const 1048720 + i32.store offset=1048732 i32.const 0 - local.get 5 - i32.const -65536 - i32.and - local.get 6 - select - local.tee 8 - i32.add - local.tee 0 - i32.store offset=1049008 + i32.const 1048728 + i32.store offset=1048740 i32.const 0 + i32.const 1048720 + i32.store offset=1048728 i32.const 0 - i32.load offset=1049012 - local.tee 1 - local.get 0 - local.get 1 - local.get 0 - i32.gt_u - select - i32.store offset=1049012 - block ;; label = @13 - block ;; label = @14 - block ;; label = @15 - i32.const 0 - i32.load offset=1049004 - local.tee 1 - i32.eqz - br_if 0 (;@15;) - i32.const 1048704 - local.set 0 - loop ;; label = @16 - local.get 0 - i32.load - local.tee 5 - local.get 0 - i32.load offset=4 - local.tee 6 - i32.add - local.get 7 - i32.eq - br_if 2 (;@14;) - local.get 0 - i32.load offset=8 - local.tee 0 - br_if 0 (;@16;) - br 3 (;@13;) - end - end - i32.const 0 - i32.load offset=1049020 - local.tee 0 - i32.eqz - br_if 4 (;@10;) - local.get 0 - local.get 7 - i32.gt_u - br_if 4 (;@10;) - br 11 (;@3;) - end - local.get 0 - i32.load offset=12 - br_if 0 (;@13;) - local.get 5 - local.get 1 - i32.gt_u - br_if 0 (;@13;) - local.get 1 - local.get 7 - i32.lt_u - br_if 4 (;@9;) - end + i32.const 1048736 + i32.store offset=1048748 + i32.const 0 + i32.const 1048728 + i32.store offset=1048736 + i32.const 0 + i32.const 1048744 + i32.store offset=1048756 + i32.const 0 + i32.const 1048736 + i32.store offset=1048744 + i32.const 0 + i32.const 1048752 + i32.store offset=1048764 + i32.const 0 + i32.const 1048744 + i32.store offset=1048752 + i32.const 0 + i32.const 1048760 + i32.store offset=1048772 + i32.const 0 + i32.const 1048752 + i32.store offset=1048760 + i32.const 0 + i32.const 1048768 + i32.store offset=1048780 + i32.const 0 + i32.const 1048760 + i32.store offset=1048768 + i32.const 0 + i32.const 1048776 + i32.store offset=1048788 + i32.const 0 + i32.const 1048768 + i32.store offset=1048776 + i32.const 0 + i32.const 0 + i32.store offset=1048716 + i32.const 0 + i32.const 1048784 + i32.store offset=1048796 + i32.const 0 + i32.const 1048776 + i32.store offset=1048784 + i32.const 0 + i32.const 1048784 + i32.store offset=1048792 + i32.const 0 + i32.const 1048792 + i32.store offset=1048804 + i32.const 0 + i32.const 1048792 + i32.store offset=1048800 + i32.const 0 + i32.const 1048800 + i32.store offset=1048812 + i32.const 0 + i32.const 1048800 + i32.store offset=1048808 + i32.const 0 + i32.const 1048808 + i32.store offset=1048820 + i32.const 0 + i32.const 1048808 + i32.store offset=1048816 + i32.const 0 + i32.const 1048816 + i32.store offset=1048828 + i32.const 0 + i32.const 1048816 + i32.store offset=1048824 + i32.const 0 + i32.const 1048824 + i32.store offset=1048836 + i32.const 0 + i32.const 1048824 + i32.store offset=1048832 + i32.const 0 + i32.const 1048832 + i32.store offset=1048844 + i32.const 0 + i32.const 1048832 + i32.store offset=1048840 + i32.const 0 + i32.const 1048840 + i32.store offset=1048852 + i32.const 0 + i32.const 1048840 + i32.store offset=1048848 + i32.const 0 + i32.const 1048848 + i32.store offset=1048860 + i32.const 0 + i32.const 1048856 + i32.store offset=1048868 + i32.const 0 + i32.const 1048848 + i32.store offset=1048856 + i32.const 0 + i32.const 1048864 + i32.store offset=1048876 + i32.const 0 + i32.const 1048856 + i32.store offset=1048864 + i32.const 0 + i32.const 1048872 + i32.store offset=1048884 + i32.const 0 + i32.const 1048864 + i32.store offset=1048872 + i32.const 0 + i32.const 1048880 + i32.store offset=1048892 + i32.const 0 + i32.const 1048872 + i32.store offset=1048880 + i32.const 0 + i32.const 1048888 + i32.store offset=1048900 + i32.const 0 + i32.const 1048880 + i32.store offset=1048888 + i32.const 0 + i32.const 1048896 + i32.store offset=1048908 i32.const 0 + i32.const 1048888 + i32.store offset=1048896 i32.const 0 - i32.load offset=1049020 + i32.const 1048904 + i32.store offset=1048916 + i32.const 0 + i32.const 1048896 + i32.store offset=1048904 + i32.const 0 + i32.const 1048912 + i32.store offset=1048924 + i32.const 0 + i32.const 1048904 + i32.store offset=1048912 + i32.const 0 + i32.const 1048920 + i32.store offset=1048932 + i32.const 0 + i32.const 1048912 + i32.store offset=1048920 + i32.const 0 + i32.const 1048928 + i32.store offset=1048940 + i32.const 0 + i32.const 1048920 + i32.store offset=1048928 + i32.const 0 + i32.const 1048936 + i32.store offset=1048948 + i32.const 0 + i32.const 1048928 + i32.store offset=1048936 + i32.const 0 + i32.const 1048944 + i32.store offset=1048956 + i32.const 0 + i32.const 1048936 + i32.store offset=1048944 + i32.const 0 + i32.const 1048952 + i32.store offset=1048964 + i32.const 0 + i32.const 1048944 + i32.store offset=1048952 + i32.const 0 + i32.const 1048960 + i32.store offset=1048972 + i32.const 0 + i32.const 1048952 + i32.store offset=1048960 + i32.const 0 + i32.const 1048968 + i32.store offset=1048980 + i32.const 0 + i32.const 1048960 + i32.store offset=1048968 + i32.const 0 + local.get 6 + i32.store offset=1049004 + i32.const 0 + i32.const 1048968 + i32.store offset=1048976 + i32.const 0 + local.get 8 + i32.const -40 + i32.add local.tee 0 - local.get 7 + i32.store offset=1048996 + local.get 6 + local.get 0 + i32.const 1 + i32.or + i32.store offset=4 + local.get 6 local.get 0 - local.get 7 - i32.lt_u - select - i32.store offset=1049020 - local.get 7 - local.get 8 i32.add - local.set 5 - i32.const 1048704 - local.set 0 + i32.const 40 + i32.store offset=4 + i32.const 0 + i32.const 2097152 + i32.store offset=1049016 + br 10 (;@2;) + end + local.get 0 + i32.load offset=12 + br_if 0 (;@11;) + local.get 5 + local.get 1 + i32.gt_u + br_if 0 (;@11;) + local.get 1 + local.get 6 + i32.lt_u + br_if 3 (;@8;) + end + i32.const 0 + i32.const 0 + i32.load offset=1049020 + local.tee 0 + local.get 6 + local.get 0 + local.get 6 + i32.lt_u + select + i32.store offset=1049020 + local.get 6 + local.get 8 + i32.add + local.set 5 + i32.const 1048704 + local.set 0 + block ;; label = @11 + block ;; label = @12 block ;; label = @13 - block ;; label = @14 - block ;; label = @15 - loop ;; label = @16 - local.get 0 - i32.load - local.get 5 - i32.eq - br_if 1 (;@15;) - local.get 0 - i32.load offset=8 - local.tee 0 - br_if 0 (;@16;) - br 2 (;@14;) - end - end - local.get 0 - i32.load offset=12 - i32.eqz - br_if 1 (;@13;) - end - i32.const 1048704 - local.set 0 - block ;; label = @14 - loop ;; label = @15 - block ;; label = @16 - local.get 0 - i32.load - local.tee 5 - local.get 1 - i32.gt_u - br_if 0 (;@16;) - local.get 5 - local.get 0 - i32.load offset=4 - i32.add - local.tee 5 - local.get 1 - i32.gt_u - br_if 2 (;@14;) - end - local.get 0 - i32.load offset=8 - local.set 0 - br 0 (;@15;) - end - end - i32.const 0 - local.get 7 - i32.store offset=1049004 - i32.const 0 - local.get 8 - i32.const -40 - i32.add - local.tee 0 - i32.store offset=1048996 - local.get 7 - local.get 0 - i32.const 1 - i32.or - i32.store offset=4 - local.get 7 - local.get 0 - i32.add - i32.const 40 - i32.store offset=4 - i32.const 0 - i32.const 2097152 - i32.store offset=1049016 - local.get 1 - local.get 5 - i32.const -32 - i32.add - i32.const -8 - i32.and - i32.const -8 - i32.add - local.tee 0 - local.get 0 - local.get 1 - i32.const 16 - i32.add - i32.lt_u - select - local.tee 6 - i32.const 27 - i32.store offset=4 - i32.const 0 - i64.load offset=1048704 align=4 - local.set 9 - local.get 6 - i32.const 16 - i32.add - i32.const 0 - i64.load offset=1048712 align=4 - i64.store align=4 - local.get 6 - local.get 9 - i64.store offset=8 align=4 - i32.const 0 - local.get 8 - i32.store offset=1048708 - i32.const 0 - local.get 7 - i32.store offset=1048704 - i32.const 0 - local.get 6 - i32.const 8 - i32.add - i32.store offset=1048712 - i32.const 0 - i32.const 0 - i32.store offset=1048716 - local.get 6 - i32.const 28 - i32.add - local.set 0 loop ;; label = @14 local.get 0 - i32.const 7 - i32.store + i32.load + local.get 5 + i32.eq + br_if 1 (;@13;) local.get 0 - i32.const 4 - i32.add + i32.load offset=8 local.tee 0 - local.get 5 - i32.lt_u br_if 0 (;@14;) + br 2 (;@12;) end - local.get 6 - local.get 1 - i32.eq - br_if 11 (;@2;) - local.get 6 - local.get 6 - i32.load offset=4 - i32.const -2 - i32.and - i32.store offset=4 - local.get 1 - local.get 6 - local.get 1 - i32.sub - local.tee 0 - i32.const 1 - i32.or - i32.store offset=4 - local.get 6 - local.get 0 - i32.store + end + local.get 0 + i32.load offset=12 + i32.eqz + br_if 1 (;@11;) + end + i32.const 1048704 + local.set 0 + block ;; label = @12 + loop ;; label = @13 block ;; label = @14 local.get 0 - i32.const 256 - i32.lt_u - br_if 0 (;@14;) + i32.load + local.tee 5 local.get 1 - local.get 0 - call 8 - br 12 (;@2;) - end - local.get 0 - i32.const -8 - i32.and - i32.const 1048720 - i32.add - local.set 5 - block ;; label = @14 - block ;; label = @15 - i32.const 0 - i32.load offset=1048984 - local.tee 7 - i32.const 1 - local.get 0 - i32.const 3 - i32.shr_u - i32.shl - local.tee 0 - i32.and - i32.eqz - br_if 0 (;@15;) - local.get 5 - i32.load offset=8 - local.set 0 - br 1 (;@14;) - end - i32.const 0 - local.get 7 - local.get 0 - i32.or - i32.store offset=1048984 + i32.gt_u + br_if 0 (;@14;) local.get 5 - local.set 0 + local.get 0 + i32.load offset=4 + i32.add + local.tee 5 + local.get 1 + i32.gt_u + br_if 2 (;@12;) end - local.get 5 - local.get 1 - i32.store offset=8 - local.get 0 - local.get 1 - i32.store offset=12 - local.get 1 - local.get 5 - i32.store offset=12 - local.get 1 local.get 0 - i32.store offset=8 - br 11 (;@2;) + i32.load offset=8 + local.set 0 + br 0 (;@13;) end + end + i32.const 0 + local.get 6 + i32.store offset=1049004 + i32.const 0 + local.get 8 + i32.const -40 + i32.add + local.tee 0 + i32.store offset=1048996 + local.get 6 + local.get 0 + i32.const 1 + i32.or + i32.store offset=4 + local.get 6 + local.get 0 + i32.add + i32.const 40 + i32.store offset=4 + i32.const 0 + i32.const 2097152 + i32.store offset=1049016 + local.get 1 + local.get 5 + i32.const -32 + i32.add + i32.const -8 + i32.and + i32.const -8 + i32.add + local.tee 0 + local.get 0 + local.get 1 + i32.const 16 + i32.add + i32.lt_u + select + local.tee 7 + i32.const 27 + i32.store offset=4 + i32.const 0 + i64.load offset=1048704 align=4 + local.set 9 + local.get 7 + i32.const 16 + i32.add + i32.const 0 + i64.load offset=1048712 align=4 + i64.store align=4 + local.get 7 + local.get 9 + i64.store offset=8 align=4 + i32.const 0 + local.get 8 + i32.store offset=1048708 + i32.const 0 + local.get 6 + i32.store offset=1048704 + i32.const 0 + local.get 7 + i32.const 8 + i32.add + i32.store offset=1048712 + i32.const 0 + i32.const 0 + i32.store offset=1048716 + local.get 7 + i32.const 28 + i32.add + local.set 0 + loop ;; label = @12 local.get 0 - local.get 7 + i32.const 7 i32.store local.get 0 + i32.const 4 + i32.add + local.tee 0 + local.get 5 + i32.lt_u + br_if 0 (;@12;) + end + local.get 7 + local.get 1 + i32.eq + br_if 9 (;@2;) + local.get 7 + local.get 7 + i32.load offset=4 + i32.const -2 + i32.and + i32.store offset=4 + local.get 1 + local.get 7 + local.get 1 + i32.sub + local.tee 0 + i32.const 1 + i32.or + i32.store offset=4 + local.get 7 + local.get 0 + i32.store + block ;; label = @12 + local.get 0 + i32.const 256 + i32.lt_u + br_if 0 (;@12;) + local.get 1 local.get 0 - i32.load offset=4 - local.get 8 - i32.add - i32.store offset=4 - local.get 7 - local.get 2 - i32.const 3 - i32.or - i32.store offset=4 - local.get 5 - local.get 7 - local.get 2 - i32.add - local.tee 0 - i32.sub - local.set 2 + call 8 + br 10 (;@2;) + end + local.get 0 + i32.const -8 + i32.and + i32.const 1048720 + i32.add + local.set 5 + block ;; label = @12 block ;; label = @13 - local.get 5 - i32.const 0 - i32.load offset=1049004 - i32.eq - br_if 0 (;@13;) - local.get 5 i32.const 0 - i32.load offset=1049000 - i32.eq - br_if 5 (;@8;) - local.get 5 - i32.load offset=4 - local.tee 1 + i32.load offset=1048984 + local.tee 6 + i32.const 1 + local.get 0 i32.const 3 + i32.shr_u + i32.shl + local.tee 0 i32.and - i32.const 1 - i32.ne - br_if 8 (;@5;) - block ;; label = @14 - block ;; label = @15 - local.get 1 - i32.const -8 - i32.and - local.tee 6 - i32.const 256 - i32.lt_u - br_if 0 (;@15;) - local.get 5 - call 7 - br 1 (;@14;) - end - block ;; label = @15 - local.get 5 - i32.const 12 - i32.add - i32.load - local.tee 8 - local.get 5 - i32.const 8 - i32.add - i32.load - local.tee 4 - i32.eq - br_if 0 (;@15;) - local.get 4 - local.get 8 - i32.store offset=12 - local.get 8 - local.get 4 - i32.store offset=8 - br 1 (;@14;) - end - i32.const 0 - i32.const 0 - i32.load offset=1048984 - i32.const -2 - local.get 1 - i32.const 3 - i32.shr_u - i32.rotl - i32.and - i32.store offset=1048984 - end + br_if 0 (;@13;) + i32.const 0 local.get 6 - local.get 2 - i32.add - local.set 2 + local.get 0 + i32.or + i32.store offset=1048984 local.get 5 - local.get 6 - i32.add - local.tee 5 - i32.load offset=4 - local.set 1 - br 8 (;@5;) + local.set 0 + br 1 (;@12;) end - i32.const 0 - local.get 0 - i32.store offset=1049004 - i32.const 0 - i32.const 0 - i32.load offset=1048996 - local.get 2 - i32.add - local.tee 2 - i32.store offset=1048996 - local.get 0 - local.get 2 - i32.const 1 - i32.or - i32.store offset=4 - br 8 (;@4;) + local.get 5 + i32.load offset=8 + local.set 0 end - i32.const 0 - local.get 0 - local.get 2 - i32.sub - local.tee 1 - i32.store offset=1048996 - i32.const 0 - i32.const 0 - i32.load offset=1049004 - local.tee 0 - local.get 2 - i32.add - local.tee 5 - i32.store offset=1049004 local.get 5 local.get 1 - i32.const 1 - i32.or - i32.store offset=4 + i32.store offset=8 local.get 0 - local.get 2 - i32.const 3 - i32.or - i32.store offset=4 + local.get 1 + i32.store offset=12 + local.get 1 + local.get 5 + i32.store offset=12 + local.get 1 local.get 0 - i32.const 8 - i32.add - local.set 1 - br 10 (;@1;) + i32.store offset=8 + br 9 (;@2;) end - i32.const 0 - i32.load offset=1049000 - local.set 1 local.get 0 + local.get 6 + i32.store + local.get 0 + local.get 0 + i32.load offset=4 + local.get 8 + i32.add + i32.store offset=4 + local.get 6 local.get 2 + i32.const 3 + i32.or + i32.store offset=4 + local.get 5 + local.get 6 + local.get 2 + i32.add + local.tee 0 i32.sub - local.tee 5 - i32.const 16 - i32.lt_u - br_if 3 (;@7;) + local.set 1 + local.get 5 i32.const 0 + i32.load offset=1049004 + i32.eq + br_if 3 (;@7;) local.get 5 - i32.store offset=1048992 i32.const 0 - local.get 1 - local.get 2 - i32.add - local.tee 7 - i32.store offset=1049000 - local.get 7 + i32.load offset=1049000 + i32.eq + br_if 4 (;@6;) + block ;; label = @11 + local.get 5 + i32.load offset=4 + local.tee 2 + i32.const 3 + i32.and + i32.const 1 + i32.ne + br_if 0 (;@11;) + block ;; label = @12 + block ;; label = @13 + local.get 2 + i32.const -8 + i32.and + local.tee 7 + i32.const 256 + i32.lt_u + br_if 0 (;@13;) + local.get 5 + call 7 + br 1 (;@12;) + end + block ;; label = @13 + local.get 5 + i32.const 12 + i32.add + i32.load + local.tee 8 + local.get 5 + i32.const 8 + i32.add + i32.load + local.tee 4 + i32.eq + br_if 0 (;@13;) + local.get 4 + local.get 8 + i32.store offset=12 + local.get 8 + local.get 4 + i32.store offset=8 + br 1 (;@12;) + end + i32.const 0 + i32.const 0 + i32.load offset=1048984 + i32.const -2 + local.get 2 + i32.const 3 + i32.shr_u + i32.rotl + i32.and + i32.store offset=1048984 + end + local.get 7 + local.get 1 + i32.add + local.set 1 + local.get 5 + local.get 7 + i32.add + local.tee 5 + i32.load offset=4 + local.set 2 + end local.get 5 + local.get 2 + i32.const -2 + i32.and + i32.store offset=4 + local.get 0 + local.get 1 i32.const 1 i32.or i32.store offset=4 + local.get 0 + local.get 1 + i32.add + local.get 1 + i32.store + block ;; label = @11 + local.get 1 + i32.const 256 + i32.lt_u + br_if 0 (;@11;) + local.get 0 + local.get 1 + call 8 + br 8 (;@3;) + end + local.get 1 + i32.const -8 + i32.and + i32.const 1048720 + i32.add + local.set 5 + block ;; label = @11 + block ;; label = @12 + i32.const 0 + i32.load offset=1048984 + local.tee 2 + i32.const 1 + local.get 1 + i32.const 3 + i32.shr_u + i32.shl + local.tee 1 + i32.and + br_if 0 (;@12;) + i32.const 0 + local.get 2 + local.get 1 + i32.or + i32.store offset=1048984 + local.get 5 + local.set 1 + br 1 (;@11;) + end + local.get 5 + i32.load offset=8 + local.set 1 + end + local.get 5 + local.get 0 + i32.store offset=8 local.get 1 local.get 0 - i32.add + i32.store offset=12 + local.get 0 local.get 5 - i32.store + i32.store offset=12 + local.get 0 local.get 1 - local.get 2 - i32.const 3 - i32.or - i32.store offset=4 - br 4 (;@6;) + i32.store offset=8 + br 7 (;@3;) end i32.const 0 - local.get 7 - i32.store offset=1049020 - br 6 (;@3;) + local.get 0 + local.get 2 + i32.sub + local.tee 1 + i32.store offset=1048996 + i32.const 0 + i32.const 0 + i32.load offset=1049004 + local.tee 0 + local.get 2 + i32.add + local.tee 5 + i32.store offset=1049004 + local.get 5 + local.get 1 + i32.const 1 + i32.or + i32.store offset=4 + local.get 0 + local.get 2 + i32.const 3 + i32.or + i32.store offset=4 + local.get 0 + i32.const 8 + i32.add + local.set 1 + br 8 (;@1;) end + i32.const 0 + i32.load offset=1049000 + local.set 1 local.get 0 - local.get 6 - local.get 8 - i32.add - i32.store offset=4 + local.get 2 + i32.sub + local.tee 5 + i32.const 16 + i32.lt_u + br_if 3 (;@5;) i32.const 0 - i32.load offset=1049004 + local.get 5 + i32.store offset=1048992 i32.const 0 - i32.load offset=1048996 - local.get 8 + local.get 1 + local.get 2 i32.add - call 9 - br 6 (;@2;) + local.tee 6 + i32.store offset=1049000 + local.get 6 + local.get 5 + i32.const 1 + i32.or + i32.store offset=4 + local.get 1 + local.get 0 + i32.add + local.get 5 + i32.store + local.get 1 + local.get 2 + i32.const 3 + i32.or + i32.store offset=4 + br 4 (;@4;) end - i32.const 0 local.get 0 - i32.store offset=1049000 - i32.const 0 - i32.const 0 - i32.load offset=1048992 - local.get 2 + local.get 7 + local.get 8 i32.add - local.tee 2 - i32.store offset=1048992 - local.get 0 - local.get 2 - i32.const 1 - i32.or i32.store offset=4 - local.get 0 - local.get 2 + i32.const 0 + i32.load offset=1049004 + i32.const 0 + i32.load offset=1048996 + local.get 8 i32.add - local.get 2 - i32.store - br 3 (;@4;) + call 9 + br 5 (;@2;) end i32.const 0 - i32.const 0 - i32.store offset=1049000 + local.get 0 + i32.store offset=1049004 i32.const 0 i32.const 0 - i32.store offset=1048992 - local.get 1 - local.get 0 - i32.const 3 - i32.or - i32.store offset=4 + i32.load offset=1048996 local.get 1 - local.get 0 i32.add - local.tee 0 + local.tee 1 + i32.store offset=1048996 local.get 0 - i32.load offset=4 - i32.const 1 - i32.or - i32.store offset=4 - end - local.get 1 - i32.const 8 - i32.add - return - end - local.get 5 - local.get 1 - i32.const -2 - i32.and - i32.store offset=4 - local.get 0 - local.get 2 - i32.const 1 - i32.or - i32.store offset=4 - local.get 0 - local.get 2 - i32.add - local.get 2 - i32.store - block ;; label = @5 - local.get 2 - i32.const 256 - i32.lt_u - br_if 0 (;@5;) - local.get 0 - local.get 2 - call 8 - br 1 (;@4;) - end - local.get 2 - i32.const -8 - i32.and - i32.const 1048720 - i32.add - local.set 1 - block ;; label = @5 - block ;; label = @6 - i32.const 0 - i32.load offset=1048984 - local.tee 5 - i32.const 1 - local.get 2 - i32.const 3 - i32.shr_u - i32.shl - local.tee 2 - i32.and - i32.eqz - br_if 0 (;@6;) - local.get 1 - i32.load offset=8 - local.set 2 - br 1 (;@5;) - end - i32.const 0 - local.get 5 - local.get 2 - i32.or - i32.store offset=1048984 - local.get 1 - local.set 2 - end - local.get 1 - local.get 0 - i32.store offset=8 - local.get 2 - local.get 0 - i32.store offset=12 - local.get 0 - local.get 1 - i32.store offset=12 - local.get 0 - local.get 2 - i32.store offset=8 - end - local.get 7 - i32.const 8 - i32.add - return - end - i32.const 0 - i32.const 4095 - i32.store offset=1049024 - i32.const 0 - local.get 8 - i32.store offset=1048708 - i32.const 0 - local.get 7 - i32.store offset=1048704 - i32.const 0 - i32.const 1048720 - i32.store offset=1048732 - i32.const 0 - i32.const 1048728 - i32.store offset=1048740 - i32.const 0 - i32.const 1048720 - i32.store offset=1048728 - i32.const 0 - i32.const 1048736 - i32.store offset=1048748 - i32.const 0 - i32.const 1048728 - i32.store offset=1048736 - i32.const 0 - i32.const 1048744 - i32.store offset=1048756 - i32.const 0 - i32.const 1048736 - i32.store offset=1048744 - i32.const 0 - i32.const 1048752 - i32.store offset=1048764 - i32.const 0 - i32.const 1048744 - i32.store offset=1048752 - i32.const 0 - i32.const 1048760 - i32.store offset=1048772 - i32.const 0 - i32.const 1048752 - i32.store offset=1048760 - i32.const 0 - i32.const 1048768 - i32.store offset=1048780 - i32.const 0 - i32.const 1048760 - i32.store offset=1048768 - i32.const 0 - i32.const 1048776 - i32.store offset=1048788 - i32.const 0 - i32.const 1048768 - i32.store offset=1048776 - i32.const 0 - i32.const 0 - i32.store offset=1048716 - i32.const 0 - i32.const 1048784 - i32.store offset=1048796 - i32.const 0 - i32.const 1048776 - i32.store offset=1048784 - i32.const 0 - i32.const 1048784 - i32.store offset=1048792 - i32.const 0 - i32.const 1048792 - i32.store offset=1048804 - i32.const 0 - i32.const 1048792 - i32.store offset=1048800 - i32.const 0 - i32.const 1048800 - i32.store offset=1048812 - i32.const 0 - i32.const 1048800 - i32.store offset=1048808 - i32.const 0 - i32.const 1048808 - i32.store offset=1048820 - i32.const 0 - i32.const 1048808 - i32.store offset=1048816 - i32.const 0 - i32.const 1048816 - i32.store offset=1048828 - i32.const 0 - i32.const 1048816 - i32.store offset=1048824 - i32.const 0 - i32.const 1048824 - i32.store offset=1048836 - i32.const 0 - i32.const 1048824 - i32.store offset=1048832 - i32.const 0 - i32.const 1048832 - i32.store offset=1048844 - i32.const 0 - i32.const 1048832 - i32.store offset=1048840 - i32.const 0 - i32.const 1048840 - i32.store offset=1048852 - i32.const 0 - i32.const 1048840 - i32.store offset=1048848 - i32.const 0 - i32.const 1048848 - i32.store offset=1048860 - i32.const 0 - i32.const 1048856 - i32.store offset=1048868 - i32.const 0 - i32.const 1048848 - i32.store offset=1048856 - i32.const 0 - i32.const 1048864 - i32.store offset=1048876 - i32.const 0 - i32.const 1048856 - i32.store offset=1048864 - i32.const 0 - i32.const 1048872 - i32.store offset=1048884 - i32.const 0 - i32.const 1048864 - i32.store offset=1048872 - i32.const 0 - i32.const 1048880 - i32.store offset=1048892 - i32.const 0 - i32.const 1048872 - i32.store offset=1048880 - i32.const 0 - i32.const 1048888 - i32.store offset=1048900 - i32.const 0 - i32.const 1048880 - i32.store offset=1048888 - i32.const 0 - i32.const 1048896 - i32.store offset=1048908 - i32.const 0 - i32.const 1048888 - i32.store offset=1048896 - i32.const 0 - i32.const 1048904 - i32.store offset=1048916 - i32.const 0 - i32.const 1048896 - i32.store offset=1048904 - i32.const 0 - i32.const 1048912 - i32.store offset=1048924 - i32.const 0 - i32.const 1048904 - i32.store offset=1048912 - i32.const 0 - i32.const 1048920 - i32.store offset=1048932 - i32.const 0 - i32.const 1048912 - i32.store offset=1048920 - i32.const 0 - i32.const 1048928 - i32.store offset=1048940 - i32.const 0 - i32.const 1048920 - i32.store offset=1048928 - i32.const 0 - i32.const 1048936 - i32.store offset=1048948 - i32.const 0 - i32.const 1048928 - i32.store offset=1048936 - i32.const 0 - i32.const 1048944 - i32.store offset=1048956 - i32.const 0 - i32.const 1048936 - i32.store offset=1048944 - i32.const 0 - i32.const 1048952 - i32.store offset=1048964 - i32.const 0 - i32.const 1048944 - i32.store offset=1048952 - i32.const 0 - i32.const 1048960 - i32.store offset=1048972 - i32.const 0 - i32.const 1048952 - i32.store offset=1048960 - i32.const 0 - i32.const 1048968 - i32.store offset=1048980 - i32.const 0 - i32.const 1048960 - i32.store offset=1048968 - i32.const 0 - local.get 7 - i32.store offset=1049004 - i32.const 0 - i32.const 1048968 - i32.store offset=1048976 - i32.const 0 - local.get 8 - i32.const -40 - i32.add - local.tee 0 - i32.store offset=1048996 - local.get 7 - local.get 0 - i32.const 1 - i32.or - i32.store offset=4 - local.get 7 - local.get 0 + local.get 1 + i32.const 1 + i32.or + i32.store offset=4 + br 3 (;@3;) + end + i32.const 0 + local.get 0 + i32.store offset=1049000 + i32.const 0 + i32.const 0 + i32.load offset=1048992 + local.get 1 + i32.add + local.tee 1 + i32.store offset=1048992 + local.get 0 + local.get 1 + i32.const 1 + i32.or + i32.store offset=4 + local.get 0 + local.get 1 + i32.add + local.get 1 + i32.store + br 2 (;@3;) + end + i32.const 0 + i32.const 0 + i32.store offset=1049000 + i32.const 0 + i32.const 0 + i32.store offset=1048992 + local.get 1 + local.get 0 + i32.const 3 + i32.or + i32.store offset=4 + local.get 1 + local.get 0 + i32.add + local.tee 0 + local.get 0 + i32.load offset=4 + i32.const 1 + i32.or + i32.store offset=4 + end + local.get 1 + i32.const 8 + i32.add + return + end + local.get 6 + i32.const 8 i32.add - i32.const 40 - i32.store offset=4 - i32.const 0 - i32.const 2097152 - i32.store offset=1049016 + return end i32.const 0 local.set 1 @@ -2055,92 +2058,99 @@ i32.and i32.store offset=1048984 end - block ;; label = @3 - local.get 2 - i32.load offset=4 - local.tee 3 - i32.const 2 - i32.and - i32.eqz - br_if 0 (;@3;) - local.get 2 - local.get 3 - i32.const -2 - i32.and - i32.store offset=4 - local.get 0 - local.get 1 - i32.const 1 - i32.or - i32.store offset=4 - local.get 0 - local.get 1 - i32.add - local.get 1 - i32.store - br 2 (;@1;) - end block ;; label = @3 block ;; label = @4 - local.get 2 - i32.const 0 - i32.load offset=1049004 - i32.eq - br_if 0 (;@4;) - local.get 2 - i32.const 0 - i32.load offset=1049000 - i32.eq - br_if 1 (;@3;) - local.get 3 - i32.const -8 - i32.and - local.tee 4 - local.get 1 - i32.add - local.set 1 block ;; label = @5 - block ;; label = @6 - local.get 4 - i32.const 256 - i32.lt_u - br_if 0 (;@6;) - local.get 2 - call 7 - br 1 (;@5;) - end - block ;; label = @6 - local.get 2 - i32.const 12 - i32.add - i32.load - local.tee 4 - local.get 2 - i32.const 8 - i32.add - i32.load - local.tee 2 - i32.eq - br_if 0 (;@6;) - local.get 2 - local.get 4 - i32.store offset=12 - local.get 4 - local.get 2 - i32.store offset=8 - br 1 (;@5;) - end + local.get 2 + i32.load offset=4 + local.tee 3 + i32.const 2 + i32.and + br_if 0 (;@5;) + local.get 2 i32.const 0 + i32.load offset=1049004 + i32.eq + br_if 2 (;@3;) + local.get 2 i32.const 0 - i32.load offset=1048984 - i32.const -2 + i32.load offset=1049000 + i32.eq + br_if 4 (;@1;) local.get 3 - i32.const 3 - i32.shr_u - i32.rotl + i32.const -8 i32.and - i32.store offset=1048984 + local.tee 4 + local.get 1 + i32.add + local.set 1 + block ;; label = @6 + block ;; label = @7 + local.get 4 + i32.const 256 + i32.lt_u + br_if 0 (;@7;) + local.get 2 + call 7 + br 1 (;@6;) + end + block ;; label = @7 + local.get 2 + i32.const 12 + i32.add + i32.load + local.tee 4 + local.get 2 + i32.const 8 + i32.add + i32.load + local.tee 2 + i32.eq + br_if 0 (;@7;) + local.get 2 + local.get 4 + i32.store offset=12 + local.get 4 + local.get 2 + i32.store offset=8 + br 1 (;@6;) + end + i32.const 0 + i32.const 0 + i32.load offset=1048984 + i32.const -2 + local.get 3 + i32.const 3 + i32.shr_u + i32.rotl + i32.and + i32.store offset=1048984 + end + local.get 0 + local.get 1 + i32.const 1 + i32.or + i32.store offset=4 + local.get 0 + local.get 1 + i32.add + local.get 1 + i32.store + local.get 0 + i32.const 0 + i32.load offset=1049000 + i32.ne + br_if 1 (;@4;) + i32.const 0 + local.get 1 + i32.store offset=1048992 + return end + local.get 2 + local.get 3 + i32.const -2 + i32.and + i32.store offset=4 local.get 0 local.get 1 i32.const 1 @@ -2151,123 +2161,112 @@ i32.add local.get 1 i32.store + end + block ;; label = @4 + local.get 1 + i32.const 256 + i32.lt_u + br_if 0 (;@4;) local.get 0 - i32.const 0 - i32.load offset=1049000 - i32.ne - br_if 3 (;@1;) - i32.const 0 local.get 1 - i32.store offset=1048992 - br 2 (;@2;) + call 8 + return end - i32.const 0 - local.get 0 - i32.store offset=1049004 - i32.const 0 - i32.const 0 - i32.load offset=1048996 local.get 1 + i32.const -8 + i32.and + i32.const 1048720 i32.add - local.tee 1 - i32.store offset=1048996 + local.set 2 + block ;; label = @4 + block ;; label = @5 + i32.const 0 + i32.load offset=1048984 + local.tee 3 + i32.const 1 + local.get 1 + i32.const 3 + i32.shr_u + i32.shl + local.tee 1 + i32.and + br_if 0 (;@5;) + i32.const 0 + local.get 3 + local.get 1 + i32.or + i32.store offset=1048984 + local.get 2 + local.set 1 + br 1 (;@4;) + end + local.get 2 + i32.load offset=8 + local.set 1 + end + local.get 2 local.get 0 + i32.store offset=8 local.get 1 - i32.const 1 - i32.or - i32.store offset=4 local.get 0 - i32.const 0 - i32.load offset=1049000 - i32.ne - br_if 1 (;@2;) - i32.const 0 - i32.const 0 - i32.store offset=1048992 - i32.const 0 - i32.const 0 - i32.store offset=1049000 + i32.store offset=12 + local.get 0 + local.get 2 + i32.store offset=12 + local.get 0 + local.get 1 + i32.store offset=8 return end i32.const 0 local.get 0 - i32.store offset=1049000 + i32.store offset=1049004 i32.const 0 i32.const 0 - i32.load offset=1048992 + i32.load offset=1048996 local.get 1 i32.add local.tee 1 - i32.store offset=1048992 + i32.store offset=1048996 local.get 0 local.get 1 i32.const 1 i32.or i32.store offset=4 local.get 0 - local.get 1 - i32.add - local.get 1 - i32.store - return - end - return - end - block ;; label = @1 - local.get 1 - i32.const 256 - i32.lt_u - br_if 0 (;@1;) - local.get 0 - local.get 1 - call 8 - return - end - local.get 1 - i32.const -8 - i32.and - i32.const 1048720 - i32.add - local.set 2 - block ;; label = @1 - block ;; label = @2 i32.const 0 - i32.load offset=1048984 - local.tee 3 - i32.const 1 - local.get 1 - i32.const 3 - i32.shr_u - i32.shl - local.tee 1 - i32.and - i32.eqz + i32.load offset=1049000 + i32.ne br_if 0 (;@2;) - local.get 2 - i32.load offset=8 - local.set 1 - br 1 (;@1;) + i32.const 0 + i32.const 0 + i32.store offset=1048992 + i32.const 0 + i32.const 0 + i32.store offset=1049000 end - i32.const 0 - local.get 3 - local.get 1 - i32.or - i32.store offset=1048984 - local.get 2 - local.set 1 + return end - local.get 2 + i32.const 0 local.get 0 - i32.store offset=8 + i32.store offset=1049000 + i32.const 0 + i32.const 0 + i32.load offset=1048992 local.get 1 + i32.add + local.tee 1 + i32.store offset=1048992 local.get 0 - i32.store offset=12 - local.get 0 - local.get 2 - i32.store offset=12 + local.get 1 + i32.const 1 + i32.or + i32.store offset=4 local.get 0 local.get 1 - i32.store offset=8 + i32.add + local.get 1 + i32.store ) (func (;7;) (type 4) (param i32) (local i32 i32 i32 i32 i32) @@ -2471,45 +2470,44 @@ i32.add local.set 3 block ;; label = @1 + block ;; label = @2 + i32.const 0 + i32.load offset=1048988 + local.tee 4 + i32.const 1 + local.get 2 + i32.shl + local.tee 5 + i32.and + br_if 0 (;@2;) + i32.const 0 + local.get 4 + local.get 5 + i32.or + i32.store offset=1048988 + local.get 3 + local.get 0 + i32.store + local.get 0 + local.get 3 + i32.store offset=24 + br 1 (;@1;) + end block ;; label = @2 block ;; label = @3 block ;; label = @4 - block ;; label = @5 - i32.const 0 - i32.load offset=1048988 - local.tee 4 - i32.const 1 - local.get 2 - i32.shl - local.tee 5 - i32.and - i32.eqz - br_if 0 (;@5;) - local.get 3 - i32.load - local.tee 4 - i32.load offset=4 - i32.const -8 - i32.and - local.get 1 - i32.ne - br_if 1 (;@4;) - local.get 4 - local.set 2 - br 2 (;@3;) - end - i32.const 0 - local.get 4 - local.get 5 - i32.or - i32.store offset=1048988 local.get 3 - local.get 0 - i32.store - local.get 0 - local.get 3 - i32.store offset=24 - br 3 (;@1;) + i32.load + local.tee 4 + i32.load offset=4 + i32.const -8 + i32.and + local.get 1 + i32.ne + br_if 0 (;@4;) + local.get 4 + local.set 2 + br 1 (;@3;) end local.get 1 i32.const 0 @@ -2644,137 +2642,118 @@ local.set 3 block ;; label = @1 block ;; label = @2 - local.get 2 - i32.const 1 - i32.and - br_if 0 (;@2;) - local.get 2 - i32.const 3 - i32.and - i32.eqz - br_if 1 (;@1;) - local.get 1 - i32.load - local.tee 2 - local.get 0 - i32.add - local.set 0 - block ;; label = @3 - local.get 1 - local.get 2 - i32.sub - local.tee 1 - i32.const 0 - i32.load offset=1049000 - i32.ne - br_if 0 (;@3;) - local.get 3 - i32.load offset=4 - i32.const 3 - i32.and - i32.const 3 - i32.ne - br_if 1 (;@2;) - i32.const 0 - local.get 0 - i32.store offset=1048992 - local.get 3 - local.get 3 - i32.load offset=4 - i32.const -2 - i32.and - i32.store offset=4 - local.get 1 - local.get 0 - i32.const 1 - i32.or - i32.store offset=4 - local.get 3 - local.get 0 - i32.store - return - end - block ;; label = @3 - local.get 2 - i32.const 256 - i32.lt_u - br_if 0 (;@3;) - local.get 1 - call 7 - br 1 (;@2;) - end - block ;; label = @3 - local.get 1 - i32.const 12 - i32.add - i32.load - local.tee 4 - local.get 1 - i32.const 8 - i32.add - i32.load - local.tee 5 - i32.eq - br_if 0 (;@3;) - local.get 5 - local.get 4 - i32.store offset=12 - local.get 4 - local.get 5 - i32.store offset=8 - br 1 (;@2;) - end - i32.const 0 - i32.const 0 - i32.load offset=1048984 - i32.const -2 - local.get 2 - i32.const 3 - i32.shr_u - i32.rotl - i32.and - i32.store offset=1048984 - end - block ;; label = @2 - block ;; label = @3 - local.get 3 - i32.load offset=4 - local.tee 2 - i32.const 2 - i32.and - i32.eqz - br_if 0 (;@3;) - local.get 3 - local.get 2 - i32.const -2 - i32.and - i32.store offset=4 - local.get 1 - local.get 0 - i32.const 1 - i32.or - i32.store offset=4 - local.get 1 - local.get 0 - i32.add - local.get 0 - i32.store - br 1 (;@2;) - end block ;; label = @3 + block ;; label = @4 + local.get 2 + i32.const 1 + i32.and + br_if 0 (;@4;) + local.get 2 + i32.const 3 + i32.and + i32.eqz + br_if 1 (;@3;) + local.get 1 + i32.load + local.tee 2 + local.get 0 + i32.add + local.set 0 + block ;; label = @5 + local.get 1 + local.get 2 + i32.sub + local.tee 1 + i32.const 0 + i32.load offset=1049000 + i32.ne + br_if 0 (;@5;) + local.get 3 + i32.load offset=4 + i32.const 3 + i32.and + i32.const 3 + i32.ne + br_if 1 (;@4;) + i32.const 0 + local.get 0 + i32.store offset=1048992 + local.get 3 + local.get 3 + i32.load offset=4 + i32.const -2 + i32.and + i32.store offset=4 + local.get 1 + local.get 0 + i32.const 1 + i32.or + i32.store offset=4 + local.get 3 + local.get 0 + i32.store + return + end + block ;; label = @5 + local.get 2 + i32.const 256 + i32.lt_u + br_if 0 (;@5;) + local.get 1 + call 7 + br 1 (;@4;) + end + block ;; label = @5 + local.get 1 + i32.const 12 + i32.add + i32.load + local.tee 4 + local.get 1 + i32.const 8 + i32.add + i32.load + local.tee 5 + i32.eq + br_if 0 (;@5;) + local.get 5 + local.get 4 + i32.store offset=12 + local.get 4 + local.get 5 + i32.store offset=8 + br 1 (;@4;) + end + i32.const 0 + i32.const 0 + i32.load offset=1048984 + i32.const -2 + local.get 2 + i32.const 3 + i32.shr_u + i32.rotl + i32.and + i32.store offset=1048984 + end block ;; label = @4 block ;; label = @5 block ;; label = @6 + local.get 3 + i32.load offset=4 + local.tee 2 + i32.const 2 + i32.and + br_if 0 (;@6;) local.get 3 i32.const 0 i32.load offset=1049004 i32.eq - br_if 0 (;@6;) + br_if 2 (;@4;) local.get 3 i32.const 0 i32.load offset=1049000 i32.eq - br_if 1 (;@5;) + br_if 5 (;@1;) local.get 2 i32.const -8 i32.and @@ -2838,133 +2817,126 @@ i32.const 0 i32.load offset=1049000 i32.ne - br_if 4 (;@2;) + br_if 1 (;@5;) i32.const 0 local.get 0 i32.store offset=1048992 return end - i32.const 0 - local.get 1 - i32.store offset=1049004 - i32.const 0 - i32.const 0 - i32.load offset=1048996 - local.get 0 - i32.add - local.tee 0 - i32.store offset=1048996 + local.get 3 + local.get 2 + i32.const -2 + i32.and + i32.store offset=4 local.get 1 local.get 0 i32.const 1 i32.or i32.store offset=4 local.get 1 - i32.const 0 - i32.load offset=1049000 - i32.eq - br_if 1 (;@4;) - br 2 (;@3;) + local.get 0 + i32.add + local.get 0 + i32.store end - i32.const 0 + local.get 0 + i32.const 256 + i32.lt_u + br_if 2 (;@2;) local.get 1 - i32.store offset=1049000 + local.get 0 + call 8 i32.const 0 i32.const 0 - i32.load offset=1048992 - local.get 0 + i32.load offset=1049024 + i32.const -1 i32.add - local.tee 0 - i32.store offset=1048992 - local.get 1 - local.get 0 - i32.const 1 - i32.or - i32.store offset=4 + local.tee 1 + i32.store offset=1049024 local.get 1 - local.get 0 - i32.add - local.get 0 - i32.store + br_if 1 (;@3;) + call 11 return end i32.const 0 + local.get 1 + i32.store offset=1049004 i32.const 0 - i32.store offset=1048992 i32.const 0 + i32.load offset=1048996 + local.get 0 + i32.add + local.tee 0 + i32.store offset=1048996 + local.get 1 + local.get 0 + i32.const 1 + i32.or + i32.store offset=4 + block ;; label = @4 + local.get 1 + i32.const 0 + i32.load offset=1049000 + i32.ne + br_if 0 (;@4;) + i32.const 0 + i32.const 0 + i32.store offset=1048992 + i32.const 0 + i32.const 0 + i32.store offset=1049000 + end + local.get 0 i32.const 0 - i32.store offset=1049000 - end - local.get 0 - i32.const 0 - i32.load offset=1049016 - i32.le_u - br_if 1 (;@1;) - i32.const 0 - i32.load offset=1049004 - local.tee 0 - i32.eqz - br_if 1 (;@1;) - block ;; label = @3 + i32.load offset=1049016 + i32.le_u + br_if 0 (;@3;) i32.const 0 - i32.load offset=1048996 - i32.const 41 - i32.lt_u + i32.load offset=1049004 + local.tee 0 + i32.eqz br_if 0 (;@3;) - i32.const 1048704 - local.set 1 - loop ;; label = @4 - block ;; label = @5 + block ;; label = @4 + i32.const 0 + i32.load offset=1048996 + i32.const 41 + i32.lt_u + br_if 0 (;@4;) + i32.const 1048704 + local.set 1 + loop ;; label = @5 + block ;; label = @6 + local.get 1 + i32.load + local.tee 3 + local.get 0 + i32.gt_u + br_if 0 (;@6;) + local.get 3 + local.get 1 + i32.load offset=4 + i32.add + local.get 0 + i32.gt_u + br_if 2 (;@4;) + end local.get 1 - i32.load - local.tee 3 - local.get 0 - i32.gt_u + i32.load offset=8 + local.tee 1 br_if 0 (;@5;) - local.get 3 - local.get 1 - i32.load offset=4 - i32.add - local.get 0 - i32.gt_u - br_if 2 (;@3;) end - local.get 1 - i32.load offset=8 - local.tee 1 - br_if 0 (;@4;) end + call 11 + i32.const 0 + i32.load offset=1048996 + i32.const 0 + i32.load offset=1049016 + i32.le_u + br_if 0 (;@3;) + i32.const 0 + i32.const -1 + i32.store offset=1049016 end - call 11 - i32.const 0 - i32.load offset=1048996 - i32.const 0 - i32.load offset=1049016 - i32.le_u - br_if 1 (;@1;) - i32.const 0 - i32.const -1 - i32.store offset=1049016 - return - end - block ;; label = @2 - local.get 0 - i32.const 256 - i32.lt_u - br_if 0 (;@2;) - local.get 1 - local.get 0 - call 8 - i32.const 0 - i32.const 0 - i32.load offset=1049024 - i32.const -1 - i32.add - local.tee 1 - i32.store offset=1049024 - local.get 1 - br_if 1 (;@1;) - call 11 return end local.get 0 @@ -2985,19 +2957,18 @@ i32.shl local.tee 0 i32.and - i32.eqz br_if 0 (;@3;) + i32.const 0 + local.get 2 + local.get 0 + i32.or + i32.store offset=1048984 local.get 3 - i32.load offset=8 local.set 0 br 1 (;@2;) end - i32.const 0 - local.get 2 - local.get 0 - i32.or - i32.store offset=1048984 local.get 3 + i32.load offset=8 local.set 0 end local.get 3 @@ -3012,7 +2983,28 @@ local.get 1 local.get 0 i32.store offset=8 + return end + i32.const 0 + local.get 1 + i32.store offset=1049000 + i32.const 0 + i32.const 0 + i32.load offset=1048992 + local.get 0 + i32.add + local.tee 0 + i32.store offset=1048992 + local.get 1 + local.get 0 + i32.const 1 + i32.or + i32.store offset=4 + local.get 1 + local.get 0 + i32.add + local.get 0 + i32.store ) (func (;11;) (type 0) (local i32 i32) @@ -3498,8 +3490,8 @@ block ;; label = @1 block ;; label = @2 local.get 2 - i32.const 15 - i32.gt_u + i32.const 16 + i32.ge_u br_if 0 (;@2;) local.get 0 local.set 3 @@ -3706,6 +3698,6 @@ (func (;2;) (type 0) (canon lift (core func 2))) (export (;3;) "add-two" (func 2)) (@producers - (processed-by "wit-component" "0.16.0") + (processed-by "wit-component" "0.18.1") ) ) diff --git a/homestar-wasm/fixtures/example_test.wasm b/homestar-wasm/fixtures/example_test.wasm index 0d0e7528..15306f11 100755 Binary files a/homestar-wasm/fixtures/example_test.wasm and b/homestar-wasm/fixtures/example_test.wasm differ diff --git a/homestar-wasm/fixtures/example_test_component.wasm b/homestar-wasm/fixtures/example_test_component.wasm index 41b38a4f..97168009 100644 Binary files a/homestar-wasm/fixtures/example_test_component.wasm and b/homestar-wasm/fixtures/example_test_component.wasm differ