diff --git a/Cargo.lock b/Cargo.lock index 261f6e52b7..f6f2740bda 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -68,9 +68,9 @@ checksum = "250f629c0161ad8107cf89319e990051fae62832fd343083bea452d93e2205fd" [[package]] name = "ambient-authority" -version = "0.0.1" +version = "0.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ec8ad6edb4840b78c5c3d88de606b22252d552b55f3a4699fbb10fc070ec3049" +checksum = "e9d4ee0d472d1cd2e28c97dfa124b3d8d992e10eb0a035f33f5d12e3a177ba3b" [[package]] name = "android_system_properties" @@ -526,38 +526,38 @@ checksum = "89b2fd2a0dcf38d7971e2194b6b6eebab45ae01067456a7fd93d5547a61b70be" [[package]] name = "cap-fs-ext" -version = "1.0.7" +version = "1.0.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "07d9cd7dc1d714d59974a6a68bed489c914b7b2620d1d4334d88d5ec9f29ebbd" +checksum = "58bc48200a1a0fa6fba138b1802ad7def18ec1cdd92f7b2a04e21f1bd887f7b9" dependencies = [ "cap-primitives", "cap-std", "io-lifetimes", - "windows-sys 0.45.0", + "windows-sys 0.48.0", ] [[package]] name = "cap-primitives" -version = "1.0.7" +version = "1.0.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e41334d53bab60f94878253f8a950c231596c8bbb99b4f71b13223dd48e18c6" +checksum = "a4b6df5b295dca8d56f35560be8c391d59f0420f72e546997154e24e765e6451" dependencies = [ "ambient-authority", - "fs-set-times 0.18.1", + "fs-set-times", "io-extras", "io-lifetimes", "ipnet", "maybe-owned", - "rustix 0.36.9", - "windows-sys 0.45.0", + "rustix 0.37.20", + "windows-sys 0.48.0", "winx", ] [[package]] name = "cap-rand" -version = "1.0.7" +version = "1.0.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6b5ddc7e3565e7cc4bf20d0c386b328f9e0f1b83fe0bcc0e055a1f08245e2aca" +checksum = "4d25555efacb0b5244cf1d35833d55d21abc916fff0eaad254b8e2453ea9b8ab" dependencies = [ "ambient-authority", "rand 0.8.5", @@ -565,15 +565,14 @@ dependencies = [ [[package]] name = "cap-std" -version = "1.0.7" +version = "1.0.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e9dd840c16dee1df417f3985d173a2bb6ef55d48ea3d4deddcef46f31c9e7028" +checksum = "3373a62accd150b4fcba056d4c5f3b552127f0ec86d3c8c102d60b978174a012" dependencies = [ "cap-primitives", "io-extras", "io-lifetimes", - "ipnet", - "rustix 0.36.9", + "rustix 0.37.20", ] [[package]] @@ -681,8 +680,8 @@ checksum = "eef2b3ded6a26dfaec672a742c93c8cf6b689220324da509ec5caa20de55dc83" dependencies = [ "atty", "bitflags 1.3.2", - "clap_derive 3.2.24", - "clap_lex 0.2.4", + "clap_derive", + "clap_lex", "indexmap", "once_cell", "strsim", @@ -690,21 +689,6 @@ dependencies = [ "textwrap 0.16.0", ] -[[package]] -name = "clap" -version = "4.1.13" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3c911b090850d79fc64fe9ea01e28e465f65e821e08813ced95bced72f7a8a9b" -dependencies = [ - "bitflags 1.3.2", - "clap_derive 4.1.12", - "clap_lex 0.3.3", - "is-terminal", - "once_cell", - "strsim", - "termcolor", -] - [[package]] name = "clap_derive" version = "3.2.24" @@ -718,18 +702,6 @@ dependencies = [ "syn 1.0.109", ] -[[package]] -name = "clap_derive" -version = "4.1.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9a932373bab67b984c790ddf2c9ca295d8e3af3b7ef92de5a5bacdccdee4b09b" -dependencies = [ - "heck 0.4.1", - "proc-macro2", - "quote", - "syn 2.0.8", -] - [[package]] name = "clap_lex" version = "0.2.4" @@ -739,15 +711,6 @@ dependencies = [ "os_str_bytes", ] -[[package]] -name = "clap_lex" -version = "0.3.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "033f6b7a4acb1f358c742aaca805c939ee73b4c6209ae4318ec7aca81c42e646" -dependencies = [ - "os_str_bytes", -] - [[package]] name = "clearscreen" version = "2.0.1" @@ -887,18 +850,18 @@ dependencies = [ [[package]] name = "cranelift-bforest" -version = "0.96.4" +version = "0.97.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "182b82f78049f54d3aee5a19870d356ef754226665a695ce2fcdd5d55379718e" +checksum = "e5dbee3d5a789503694c0e850f72fed0a1ee38afffe948865381a9163a1dae5c" dependencies = [ "cranelift-entity", ] [[package]] name = "cranelift-codegen" -version = "0.96.4" +version = "0.97.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e7c027bf04ecae5b048d3554deb888061bc26f426afff47bf06d6ac933dce0a6" +checksum = "12aa555c34996adf66fef25db7310ae3ca6398dc58c57e8ba02a5cd68dbd445b" dependencies = [ "bumpalo", "cranelift-bforest", @@ -917,42 +880,42 @@ dependencies = [ [[package]] name = "cranelift-codegen-meta" -version = "0.96.4" +version = "0.97.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "649f70038235e4c81dba5680d7e5ae83e1081f567232425ab98b55b03afd9904" +checksum = "071f869d92ad97e1f8ed4fe61f645bc9b75044d53ea614664295b6ca3a0443ec" dependencies = [ "cranelift-codegen-shared", ] [[package]] name = "cranelift-codegen-shared" -version = "0.96.4" +version = "0.97.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a1d1c5ee2611c6a0bdc8d42d5d3dc5ce8bf53a8040561e26e88b9b21f966417" +checksum = "9afba6234a61fc7202e044bf784986e214b9150d609f539fe2b045af13038e0b" [[package]] name = "cranelift-control" -version = "0.96.4" +version = "0.97.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "da66a68b1f48da863d1d53209b8ddb1a6236411d2d72a280ffa8c2f734f7219e" +checksum = "1123c8dce2e2abd6e8c524b2afb047964ffa84cbc55d4b032315c8783b53ec1d" dependencies = [ "arbitrary", ] [[package]] name = "cranelift-entity" -version = "0.96.4" +version = "0.97.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9bd897422dbb66621fa558f4d9209875530c53e3c8f4b13b2849fbb667c431a6" +checksum = "0a89f494b76990da8a2101c8f6cadad97b043833ff7a22c3ada18d295a0fcf49" dependencies = [ "serde", ] [[package]] name = "cranelift-frontend" -version = "0.96.4" +version = "0.97.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "05db883114c98cfcd6959f72278d2fec42e01ea6a6982cfe4f20e88eebe86653" +checksum = "0c2c38bcc7b9764edf206102df7a2f95a389776fbb5a2c6b398da5b58e6b72ee" dependencies = [ "cranelift-codegen", "log", @@ -962,15 +925,15 @@ dependencies = [ [[package]] name = "cranelift-isle" -version = "0.96.4" +version = "0.97.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "84559de86e2564152c87e299c8b2559f9107e9c6d274b24ebeb04fb0a5f4abf8" +checksum = "b50429229ca95b6c716f848dc4374b04cf0bfaf39eceecd832b3ed0edab7931b" [[package]] name = "cranelift-native" -version = "0.96.4" +version = "0.97.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3f40b57f187f0fe1ffaf281df4adba2b4bc623a0f6651954da9f3c184be72761" +checksum = "024d062d42630b19fb187bb7ea8a6e6f84220494bcd5537f9adfde48893b7d40" dependencies = [ "cranelift-codegen", "libc", @@ -979,9 +942,9 @@ dependencies = [ [[package]] name = "cranelift-wasm" -version = "0.96.4" +version = "0.97.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f3eab6084cc789b9dd0b1316241efeb2968199fee709f4bb4fe0fb0923bb468b" +checksum = "080b611b7a1578bad711ca417ff26c55b742da309e37919cfca5e1c415da6864" dependencies = [ "cranelift-codegen", "cranelift-entity", @@ -989,7 +952,7 @@ dependencies = [ "itertools", "log", "smallvec", - "wasmparser 0.103.0", + "wasmparser 0.107.0", "wasmtime-types", ] @@ -1652,9 +1615,9 @@ dependencies = [ [[package]] name = "file-per-thread-logger" -version = "0.1.6" +version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "84f2e425d9790201ba4af4630191feac6dcc98765b118d4d18e91d23c2353866" +checksum = "8a3cc21c33af89af0930c8cae4ade5e6fdc17b5d2c97b3d2e2edb67a1cf683f3" dependencies = [ "env_logger 0.10.0", "log", @@ -1777,17 +1740,6 @@ dependencies = [ "syn 1.0.109", ] -[[package]] -name = "fs-set-times" -version = "0.18.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "857cf27edcb26c2a36d84b2954019573d335bb289876113aceacacdca47a4fd4" -dependencies = [ - "io-lifetimes", - "rustix 0.36.9", - "windows-sys 0.45.0", -] - [[package]] name = "fs-set-times" version = "0.19.1" @@ -2356,24 +2308,6 @@ dependencies = [ "digest 0.10.6", ] -[[package]] -name = "host" -version = "0.0.0" -source = "git+https://github.com/fermyon/spin-componentize?rev=8a596f722556d17cc1dc9b3ae8a7e7a77d3e90ae#8a596f722556d17cc1dc9b3ae8a7e7a77d3e90ae" -dependencies = [ - "anyhow", - "async-trait", - "cap-rand", - "cap-std", - "clap 4.1.13", - "thiserror", - "tokio", - "tracing", - "wasi-cap-std-sync 0.0.0", - "wasi-common 0.0.0", - "wasmtime", -] - [[package]] name = "hrana-client-proto" version = "0.1.2" @@ -4270,9 +4204,9 @@ dependencies = [ [[package]] name = "regalloc2" -version = "0.8.1" +version = "0.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d4a52e724646c6c0800fc456ec43b4165d2f91fba88ceaca06d9e0b400023478" +checksum = "12513beb38dd35aab3ac5f5b89fd0330159a0dc21d5309d75073011bbc8032b0" dependencies = [ "hashbrown 0.13.2", "log", @@ -4535,10 +4469,8 @@ dependencies = [ "bitflags 1.3.2", "errno 0.2.8", "io-lifetimes", - "itoa", "libc", "linux-raw-sys 0.1.4", - "once_cell", "windows-sys 0.45.0", ] @@ -4551,8 +4483,10 @@ dependencies = [ "bitflags 1.3.2", "errno 0.3.1", "io-lifetimes", + "itoa", "libc", "linux-raw-sys 0.3.6", + "once_cell", "windows-sys 0.48.0", ] @@ -5172,12 +5106,14 @@ dependencies = [ [[package]] name = "spin-componentize" version = "0.1.0" -source = "git+https://github.com/fermyon/spin-componentize?rev=8a596f722556d17cc1dc9b3ae8a7e7a77d3e90ae#8a596f722556d17cc1dc9b3ae8a7e7a77d3e90ae" +source = "git+https://github.com/fermyon/spin-componentize?rev=bdea058594f73edba21e12950b5f71a71244bac9#bdea058594f73edba21e12950b5f71a71244bac9" dependencies = [ "anyhow", - "wasm-encoder 0.26.0", - "wasmparser 0.104.0", - "wit-component", + "wasm-encoder 0.29.0", + "wasmparser 0.107.0", + "wit-component 0.11.0", + "wit-component 0.8.2", + "wit-parser 0.8.0", ] [[package]] @@ -5206,7 +5142,6 @@ dependencies = [ "async-trait", "cap-std", "crossbeam-channel", - "host", "io-extras", "rustix 0.37.20", "spin-componentize", @@ -5214,9 +5149,7 @@ dependencies = [ "tempfile", "tokio", "tracing", - "wasi-cap-std-sync 0.0.0", - "wasi-common 0.0.0", - "wasi-common 9.0.4", + "wasi-common", "wasmtime", "wasmtime-wasi", ] @@ -5602,7 +5535,7 @@ dependencies = [ "tokio", "tokio-rustls", "tracing", - "wasi-common 9.0.4", + "wasi-common", "wasmtime", "wasmtime-wasi", ] @@ -5614,6 +5547,12 @@ dependencies = [ "wasmtime", ] +[[package]] +name = "sptr" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3b9b39299b249ad65f3b7e96443bad61c02ca5cd3589f46cb6d610a0fd6c0d6a" + [[package]] name = "sqlparser" version = "0.34.0" @@ -6421,33 +6360,9 @@ checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" [[package]] name = "wasi-cap-std-sync" -version = "0.0.0" -source = "git+https://github.com/fermyon/spin-componentize?rev=8a596f722556d17cc1dc9b3ae8a7e7a77d3e90ae#8a596f722556d17cc1dc9b3ae8a7e7a77d3e90ae" -dependencies = [ - "anyhow", - "async-trait", - "cap-fs-ext", - "cap-rand", - "cap-std", - "cap-time-ext", - "fs-set-times 0.18.1", - "io-extras", - "io-lifetimes", - "ipnet", - "is-terminal", - "once_cell", - "rustix 0.36.9", - "system-interface", - "tracing", - "wasi-common 0.0.0", - "windows-sys 0.45.0", -] - -[[package]] -name = "wasi-cap-std-sync" -version = "9.0.4" +version = "10.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5d29c5da3b5cfc9212a7fa824224875cb67fb89d2a8392db655e4c59b8ab2ae7" +checksum = "d36ac062e4596c6d08cfb1551e4b9e1841e647aa0b3e07bd260c8669e9c64a17" dependencies = [ "anyhow", "async-trait", @@ -6455,7 +6370,7 @@ dependencies = [ "cap-rand", "cap-std", "cap-time-ext", - "fs-set-times 0.19.1", + "fs-set-times", "io-extras", "io-lifetimes", "is-terminal", @@ -6463,35 +6378,15 @@ dependencies = [ "rustix 0.37.20", "system-interface", "tracing", - "wasi-common 9.0.4", + "wasi-common", "windows-sys 0.48.0", ] [[package]] name = "wasi-common" -version = "0.0.0" -source = "git+https://github.com/fermyon/spin-componentize?rev=8a596f722556d17cc1dc9b3ae8a7e7a77d3e90ae#8a596f722556d17cc1dc9b3ae8a7e7a77d3e90ae" -dependencies = [ - "anyhow", - "async-trait", - "bitflags 1.3.2", - "cap-fs-ext", - "cap-rand", - "cap-std", - "io-extras", - "ipnet", - "rustix 0.36.9", - "system-interface", - "thiserror", - "tracing", - "windows-sys 0.45.0", -] - -[[package]] -name = "wasi-common" -version = "9.0.4" +version = "10.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f8bd905dcec1448664bf63d42d291cbae0feeea3ad41631817b8819e096d76bd" +checksum = "7a24fe619974e7b17b3ecf8bb3c4c5b19126528ff41a28bf33934474a1567269" dependencies = [ "anyhow", "bitflags 1.3.2", @@ -6509,9 +6404,9 @@ dependencies = [ [[package]] name = "wasi-tokio" -version = "9.0.4" +version = "10.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c27f8d49f64ffce4f6c566f87241f0855816a8954ffd2dd038d8c945457c50a2" +checksum = "4405af132cf6581235f5941865b4067e0e908d468e71c42dcce21ae1a7c6f5ee" dependencies = [ "anyhow", "cap-std", @@ -6519,8 +6414,8 @@ dependencies = [ "io-lifetimes", "rustix 0.37.20", "tokio", - "wasi-cap-std-sync 9.0.4", - "wasi-common 9.0.4", + "wasi-cap-std-sync", + "wasi-common", "wiggle", ] @@ -6590,15 +6485,6 @@ version = "0.2.84" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0046fef7e28c3804e5e38bfa31ea2a0f73905319b677e57ebe37e49358989b5d" -[[package]] -name = "wasm-encoder" -version = "0.25.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4eff853c4f09eec94d76af527eddad4e9de13b11d6286a1ef7134bc30135a2b7" -dependencies = [ - "leb128", -] - [[package]] name = "wasm-encoder" version = "0.26.0" @@ -6630,6 +6516,19 @@ dependencies = [ "wasmparser 0.104.0", ] +[[package]] +name = "wasm-metadata" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "36e5156581ff4a302405c44ca7c85347563ca431d15f1a773f12c9c7b9a6cdc9" +dependencies = [ + "anyhow", + "indexmap", + "serde", + "wasm-encoder 0.29.0", + "wasmparser 0.107.0", +] + [[package]] name = "wasm-streams" version = "0.2.3" @@ -6643,16 +6542,6 @@ dependencies = [ "web-sys", ] -[[package]] -name = "wasmparser" -version = "0.103.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2c437373cac5ea84f1113d648d51f71751ffbe3d90c00ae67618cf20d0b5ee7b" -dependencies = [ - "indexmap", - "url", -] - [[package]] name = "wasmparser" version = "0.104.0" @@ -6685,9 +6574,9 @@ dependencies = [ [[package]] name = "wasmtime" -version = "9.0.4" +version = "10.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "634357e8668774b24c80b210552f3f194e2342a065d6d83845ba22c5817d0770" +checksum = "9bade460fa8739cd1ae051cf0b6268eeb23ed27ea5eec6f4ab369742cd1504da" dependencies = [ "anyhow", "async-trait", @@ -6707,7 +6596,7 @@ dependencies = [ "serde", "serde_json", "target-lexicon", - "wasmparser 0.103.0", + "wasmparser 0.107.0", "wasmtime-cache", "wasmtime-component-macro", "wasmtime-component-util", @@ -6723,18 +6612,18 @@ dependencies = [ [[package]] name = "wasmtime-asm-macros" -version = "9.0.4" +version = "10.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d33c73c24ce79b0483a3b091a9acf88871f4490b88998e8974b22236264d304c" +checksum = "f899f1a46389189c3fa9838ca45ea6c3b77df50b48eeda4c1c3aca33f40872e3" dependencies = [ "cfg-if", ] [[package]] name = "wasmtime-cache" -version = "9.0.4" +version = "10.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6107809b2d9f5b2fd3ddbaddb3bb92ff8048b62f4030debf1408119ffd38c6cb" +checksum = "c5f87db2b83e4620d93a209c185c6fad49cff940247e9714383033cd23471b88" dependencies = [ "anyhow", "base64 0.21.0", @@ -6752,9 +6641,9 @@ dependencies = [ [[package]] name = "wasmtime-component-macro" -version = "9.0.4" +version = "10.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e5ba489850d9c91c6c5b9e1696ee89e7a69d9796236a005f7e9131b6746e13b6" +checksum = "067bcd4bdc41887a7fffeb7b2c973e4b20cb956969861a09ca7e0dd58e2473bd" dependencies = [ "anyhow", "proc-macro2", @@ -6762,20 +6651,20 @@ dependencies = [ "syn 1.0.109", "wasmtime-component-util", "wasmtime-wit-bindgen", - "wit-parser 0.7.1", + "wit-parser 0.8.0", ] [[package]] name = "wasmtime-component-util" -version = "9.0.4" +version = "10.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7fa88f9e77d80f828c9d684741a9da649366c6d1cceb814755dd9cab7112d1d1" +checksum = "32c0805f77c9178070a67b203c7c9a69673e991a82ca63e02b5890aecb135286" [[package]] name = "wasmtime-cranelift" -version = "9.0.4" +version = "10.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5800616a28ed6bd5e8b99ea45646c956d798ae030494ac0689bc3e45d3b689c1" +checksum = "11a553c6d6d41eee928fc6f2a9eb4104fa8af074a16536b6da0310568e2174a3" dependencies = [ "anyhow", "cranelift-codegen", @@ -6789,16 +6678,16 @@ dependencies = [ "object", "target-lexicon", "thiserror", - "wasmparser 0.103.0", + "wasmparser 0.107.0", "wasmtime-cranelift-shared", "wasmtime-environ", ] [[package]] name = "wasmtime-cranelift-shared" -version = "9.0.4" +version = "10.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "27e4030b959ac5c5d6ee500078977e813f8768fa2b92fc12be01856cd0c76c55" +checksum = "5497c31cc06dcca342337d141d9e5511bc6e21bd4f05f539c08fa36812c7b7fa" dependencies = [ "anyhow", "cranelift-codegen", @@ -6812,9 +6701,9 @@ dependencies = [ [[package]] name = "wasmtime-environ" -version = "9.0.4" +version = "10.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9ec815d01a8d38aceb7ed4678f9ba551ae6b8a568a63810ac3ad9293b0fd01c8" +checksum = "306dc41f40c03e6b709a4b31aadd12903a0ce77d4365369d171739cc377dc036" dependencies = [ "anyhow", "cranelift-entity", @@ -6825,8 +6714,8 @@ dependencies = [ "serde", "target-lexicon", "thiserror", - "wasm-encoder 0.25.0", - "wasmparser 0.103.0", + "wasm-encoder 0.29.0", + "wasmparser 0.107.0", "wasmprinter", "wasmtime-component-util", "wasmtime-types", @@ -6834,9 +6723,9 @@ dependencies = [ [[package]] name = "wasmtime-fiber" -version = "9.0.4" +version = "10.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "23c5127908fdf720614891ec741c13dd70c844e102caa393e2faca1ee68e9bfb" +checksum = "01caff74520c214bef2047d34cf5d5c65c3483e5170e5139cbc7ff29e8213d75" dependencies = [ "cc", "cfg-if", @@ -6847,9 +6736,9 @@ dependencies = [ [[package]] name = "wasmtime-jit" -version = "9.0.4" +version = "10.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2712eafe829778b426cad0e1769fef944898923dd29f0039e34e0d53ba72b234" +checksum = "9b5de1a7d77f073204c6071009c6b2ef6f674e38a832f6c8bc7f56e77e4a3bf3" dependencies = [ "addr2line", "anyhow", @@ -6861,6 +6750,7 @@ dependencies = [ "log", "object", "rustc-demangle", + "rustix 0.37.20", "serde", "target-lexicon", "wasmtime-environ", @@ -6872,9 +6762,9 @@ dependencies = [ [[package]] name = "wasmtime-jit-debug" -version = "9.0.4" +version = "10.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "65fb78eacf4a6e47260d8ef8cc81ea8ddb91397b2e848b3fb01567adebfe89b5" +checksum = "a98a08580b1435e3758af9797e0576befe2a3e2019532ea86c94a5b563a2279b" dependencies = [ "object", "once_cell", @@ -6883,9 +6773,9 @@ dependencies = [ [[package]] name = "wasmtime-jit-icache-coherence" -version = "9.0.4" +version = "10.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d1364900b05f7d6008516121e8e62767ddb3e176bdf4c84dfa85da1734aeab79" +checksum = "41ce2d1403b99a4f9d6277fc54a7234ab7bf5205d58b4f540625aaf306e95581" dependencies = [ "cfg-if", "libc", @@ -6894,9 +6784,9 @@ dependencies = [ [[package]] name = "wasmtime-runtime" -version = "9.0.4" +version = "10.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4a16ffe4de9ac9669175c0ea5c6c51ffc596dfb49320aaa6f6c57eff58cef069" +checksum = "f4295ade57c7ea2ae2ffed4a254c14cdcf2ed9e9b00b30ad61aeb285697164d1" dependencies = [ "anyhow", "cc", @@ -6911,6 +6801,7 @@ dependencies = [ "paste", "rand 0.8.5", "rustix 0.37.20", + "sptr", "wasmtime-asm-macros", "wasmtime-environ", "wasmtime-fiber", @@ -6920,58 +6811,70 @@ dependencies = [ [[package]] name = "wasmtime-types" -version = "9.0.4" +version = "10.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "19961c9a3b04d5e766875a5c467f6f5d693f508b3e81f8dc4a1444aa94f041c9" +checksum = "1848a854370f825e6846d284cf08e048a4be1806922bf1aa1f4dd1951e3bea82" dependencies = [ "cranelift-entity", "serde", "thiserror", - "wasmparser 0.103.0", + "wasmparser 0.107.0", ] [[package]] name = "wasmtime-wasi" -version = "9.0.4" +version = "10.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "21080ff62878f1d7c53d9571053dbe96552c0f982f9f29eac65ea89974fabfd7" +checksum = "5550eeb812b65ab91fcb5f90f16698f2f6c7682f4728a316986b5d48b71d3f62" dependencies = [ "anyhow", + "async-trait", + "bitflags 1.3.2", + "cap-fs-ext", + "cap-rand", + "cap-std", + "cap-time-ext", + "fs-set-times", + "io-extras", "libc", - "wasi-cap-std-sync 9.0.4", - "wasi-common 9.0.4", + "rustix 0.37.20", + "system-interface", + "thiserror", + "tracing", + "wasi-cap-std-sync", + "wasi-common", "wasi-tokio", "wasmtime", "wiggle", + "windows-sys 0.48.0", ] [[package]] name = "wasmtime-winch" -version = "9.0.4" +version = "10.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "931600bd05200b3f19d9373c182b6a5657938400e51c42572f3477dbc8897344" +checksum = "9c1b6f75bb946f211cd2f1dc3fa81674c84b8000bfcd95770354952699a6ee91" dependencies = [ "anyhow", "cranelift-codegen", "gimli", "object", "target-lexicon", - "wasmparser 0.103.0", + "wasmparser 0.107.0", "wasmtime-cranelift-shared", "wasmtime-environ", "winch-codegen", - "winch-environ", ] [[package]] name = "wasmtime-wit-bindgen" -version = "9.0.4" +version = "10.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "421f0d16cc5c612b35ae53a0be3d3124c72296f18e5be3468263c745d56d37ab" +checksum = "d425bdb4c50c912089c114ca2aae888f454985f3816595ac2c20c4d8a8b2402e" dependencies = [ "anyhow", "heck 0.4.1", - "wit-parser 0.7.1", + "wit-parser 0.8.0", ] [[package]] @@ -7091,9 +6994,9 @@ dependencies = [ [[package]] name = "wiggle" -version = "9.0.4" +version = "10.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5b34e40b7b17a920d03449ca78b0319984379eed01a9a11c1def9c3d3832d85a" +checksum = "9765ec9983813e35ff4ed0ac7eeb565504bff06593e2c600576e8c6e5de597b3" dependencies = [ "anyhow", "async-trait", @@ -7106,9 +7009,9 @@ dependencies = [ [[package]] name = "wiggle-generate" -version = "9.0.4" +version = "10.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9eefda132eaa84fe5f15d23a55a912f8417385aee65d0141d78a3b65e46201ed" +checksum = "9f774e46d00b0bcf0bf8531e162c3f19706d425f630cc070ebd4d25a07127d2c" dependencies = [ "anyhow", "heck 0.4.1", @@ -7121,9 +7024,9 @@ dependencies = [ [[package]] name = "wiggle-macro" -version = "9.0.4" +version = "10.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6ca1a344a0ba781e2a94b27be5bb78f23e43d52336bd663b810d49d7189ad334" +checksum = "6c00a7ac880c0efe015d43d314cb80fab4b5866b353e6320e3a1d2f1fdbf9295" dependencies = [ "proc-macro2", "quote", @@ -7164,9 +7067,9 @@ checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" [[package]] name = "winch-codegen" -version = "0.7.4" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b50a93c2d1b20b921c227019af592ee9a8baf4a09199a6ee97b5f46b740799ab" +checksum = "3f8e17f9b4b2117957b88c9e72789e14372f66221664fac7a2ac3c4cba1ce9c0" dependencies = [ "anyhow", "cranelift-codegen", @@ -7174,18 +7077,8 @@ dependencies = [ "regalloc2", "smallvec", "target-lexicon", - "wasmparser 0.103.0", -] - -[[package]] -name = "winch-environ" -version = "0.7.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4ea5c7578daccdf34857f45658f61b9eb79c38ac1c7f410e51bd35fe5d4d9431" -dependencies = [ - "wasmparser 0.103.0", + "wasmparser 0.107.0", "wasmtime-environ", - "winch-codegen", ] [[package]] @@ -7382,10 +7275,10 @@ dependencies = [ [[package]] name = "wit-bindgen-gen-core" version = "0.2.0" -source = "git+https://github.com/fermyon/wit-bindgen-backport?rev=634687fde664ed0016179d9427562ac57c2af639#634687fde664ed0016179d9427562ac57c2af639" +source = "git+https://github.com/fermyon/wit-bindgen-backport?rev=b89d5079ba5b07b319631a1b191d2139f126c976#b89d5079ba5b07b319631a1b191d2139f126c976" dependencies = [ "anyhow", - "wit-parser 0.2.0 (git+https://github.com/fermyon/wit-bindgen-backport?rev=634687fde664ed0016179d9427562ac57c2af639)", + "wit-parser 0.2.0 (git+https://github.com/fermyon/wit-bindgen-backport?rev=b89d5079ba5b07b319631a1b191d2139f126c976)", ] [[package]] @@ -7400,10 +7293,10 @@ dependencies = [ [[package]] name = "wit-bindgen-gen-rust" version = "0.2.0" -source = "git+https://github.com/fermyon/wit-bindgen-backport?rev=634687fde664ed0016179d9427562ac57c2af639#634687fde664ed0016179d9427562ac57c2af639" +source = "git+https://github.com/fermyon/wit-bindgen-backport?rev=b89d5079ba5b07b319631a1b191d2139f126c976#b89d5079ba5b07b319631a1b191d2139f126c976" dependencies = [ "heck 0.3.3", - "wit-bindgen-gen-core 0.2.0 (git+https://github.com/fermyon/wit-bindgen-backport?rev=634687fde664ed0016179d9427562ac57c2af639)", + "wit-bindgen-gen-core 0.2.0 (git+https://github.com/fermyon/wit-bindgen-backport?rev=b89d5079ba5b07b319631a1b191d2139f126c976)", ] [[package]] @@ -7428,11 +7321,11 @@ dependencies = [ [[package]] name = "wit-bindgen-gen-wasmtime" version = "0.2.0" -source = "git+https://github.com/fermyon/wit-bindgen-backport?rev=634687fde664ed0016179d9427562ac57c2af639#634687fde664ed0016179d9427562ac57c2af639" +source = "git+https://github.com/fermyon/wit-bindgen-backport?rev=b89d5079ba5b07b319631a1b191d2139f126c976#b89d5079ba5b07b319631a1b191d2139f126c976" dependencies = [ "heck 0.3.3", - "wit-bindgen-gen-core 0.2.0 (git+https://github.com/fermyon/wit-bindgen-backport?rev=634687fde664ed0016179d9427562ac57c2af639)", - "wit-bindgen-gen-rust 0.2.0 (git+https://github.com/fermyon/wit-bindgen-backport?rev=634687fde664ed0016179d9427562ac57c2af639)", + "wit-bindgen-gen-core 0.2.0 (git+https://github.com/fermyon/wit-bindgen-backport?rev=b89d5079ba5b07b319631a1b191d2139f126c976)", + "wit-bindgen-gen-rust 0.2.0 (git+https://github.com/fermyon/wit-bindgen-backport?rev=b89d5079ba5b07b319631a1b191d2139f126c976)", ] [[package]] @@ -7459,7 +7352,7 @@ dependencies = [ [[package]] name = "wit-bindgen-wasmtime" version = "0.2.0" -source = "git+https://github.com/fermyon/wit-bindgen-backport?rev=634687fde664ed0016179d9427562ac57c2af639#634687fde664ed0016179d9427562ac57c2af639" +source = "git+https://github.com/fermyon/wit-bindgen-backport?rev=b89d5079ba5b07b319631a1b191d2139f126c976#b89d5079ba5b07b319631a1b191d2139f126c976" dependencies = [ "anyhow", "async-trait", @@ -7472,11 +7365,11 @@ dependencies = [ [[package]] name = "wit-bindgen-wasmtime-impl" version = "0.2.0" -source = "git+https://github.com/fermyon/wit-bindgen-backport?rev=634687fde664ed0016179d9427562ac57c2af639#634687fde664ed0016179d9427562ac57c2af639" +source = "git+https://github.com/fermyon/wit-bindgen-backport?rev=b89d5079ba5b07b319631a1b191d2139f126c976#b89d5079ba5b07b319631a1b191d2139f126c976" dependencies = [ "proc-macro2", "syn 1.0.109", - "wit-bindgen-gen-core 0.2.0 (git+https://github.com/fermyon/wit-bindgen-backport?rev=634687fde664ed0016179d9427562ac57c2af639)", + "wit-bindgen-gen-core 0.2.0 (git+https://github.com/fermyon/wit-bindgen-backport?rev=b89d5079ba5b07b319631a1b191d2139f126c976)", "wit-bindgen-gen-wasmtime", ] @@ -7492,15 +7385,31 @@ dependencies = [ "log", "url", "wasm-encoder 0.26.0", - "wasm-metadata", + "wasm-metadata 0.5.0", "wasmparser 0.104.0", "wit-parser 0.7.1", ] +[[package]] +name = "wit-component" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7cbd4c7f8f400327c482c88571f373844b7889e61460650d650fc5881bb3575c" +dependencies = [ + "anyhow", + "bitflags 1.3.2", + "indexmap", + "log", + "wasm-encoder 0.29.0", + "wasm-metadata 0.8.0", + "wasmparser 0.107.0", + "wit-parser 0.8.0", +] + [[package]] name = "wit-parser" version = "0.2.0" -source = "git+https://github.com/fermyon/wit-bindgen-backport?rev=634687fde664ed0016179d9427562ac57c2af639#634687fde664ed0016179d9427562ac57c2af639" +source = "git+https://github.com/fermyon/wit-bindgen-backport?rev=b89d5079ba5b07b319631a1b191d2139f126c976#b89d5079ba5b07b319631a1b191d2139f126c976" dependencies = [ "anyhow", "id-arena", @@ -7536,6 +7445,22 @@ dependencies = [ "url", ] +[[package]] +name = "wit-parser" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6daec9f093dbaea0e94043eeb92ece327bbbe70c86b1f41aca9bbfefd7f050f0" +dependencies = [ + "anyhow", + "id-arena", + "indexmap", + "log", + "pulldown-cmark", + "semver 1.0.16", + "unicode-xid", + "url", +] + [[package]] name = "witx" version = "0.9.1" diff --git a/Cargo.toml b/Cargo.toml index ad40cf4a77..5ac5084ff5 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -109,13 +109,10 @@ members = [ [workspace.dependencies] tracing = { version = "0.1", features = ["log"] } -wasmtime-wasi = { version = "9.0.4", features = ["tokio"] } -wasi-common-preview1 = { package = "wasi-common", version = "9.0.4" } -wasmtime = { version = "9.0.4", features = ["component-model"] } -spin-componentize = { git = "https://github.com/fermyon/spin-componentize", rev = "8a596f722556d17cc1dc9b3ae8a7e7a77d3e90ae" } -wasi-host = { package = "host", git = "https://github.com/fermyon/spin-componentize", rev = "8a596f722556d17cc1dc9b3ae8a7e7a77d3e90ae" } -wasi-common = { git = "https://github.com/fermyon/spin-componentize", rev = "8a596f722556d17cc1dc9b3ae8a7e7a77d3e90ae" } -wasi-cap-std-sync = { git = "https://github.com/fermyon/spin-componentize", rev = "8a596f722556d17cc1dc9b3ae8a7e7a77d3e90ae" } +wasmtime-wasi = { version = "10.0.0", features = ["tokio"] } +wasi-common-preview1 = { package = "wasi-common", version = "10.0.0" } +wasmtime = { version = "10.0.0", features = ["component-model"] } +spin-componentize = { git = "https://github.com/fermyon/spin-componentize", rev = "bdea058594f73edba21e12950b5f71a71244bac9" } [workspace.dependencies.bindle] git = "https://github.com/fermyon/bindle" diff --git a/crates/core/Cargo.toml b/crates/core/Cargo.toml index ace637735f..39192f229d 100644 --- a/crates/core/Cargo.toml +++ b/crates/core/Cargo.toml @@ -9,14 +9,11 @@ anyhow = "1.0" async-trait = "0.1" crossbeam-channel = "0.5" tracing = { workspace = true } -wasi-host = { workspace = true } -wasi-common = { workspace = true } -wasi-common-preview1 = { workspace = true } -wasi-cap-std-sync = { workspace = true } wasmtime = { workspace = true } wasmtime-wasi = { workspace = true } +wasi-common-preview1 = { workspace = true } system-interface = { version = "0.25.1", features = ["cap_std_impls"] } -cap-std = "1.0.5" +cap-std = "1.0.13" [target.'cfg(unix)'.dependencies] rustix = "0.37.19" diff --git a/crates/core/src/io.rs b/crates/core/src/io.rs index 66729ce68a..d37ee93797 100644 --- a/crates/core/src/io.rs +++ b/crates/core/src/io.rs @@ -1,6 +1,6 @@ use std::sync::{Arc, RwLock}; -use wasi_common::pipe::WritePipe; +use wasmtime_wasi::preview2::pipe::WritePipe; /// An in-memory stdio output buffer. #[derive(Default)] @@ -19,7 +19,7 @@ impl OutputBuffer { #[cfg(test)] mod tests { - use wasi_common::OutputStream; + use wasmtime_wasi::preview2::OutputStream; use super::*; diff --git a/crates/core/src/lib.rs b/crates/core/src/lib.rs index 8c9dbfe602..210eec4888 100644 --- a/crates/core/src/lib.rs +++ b/crates/core/src/lib.rs @@ -16,23 +16,25 @@ mod store; use std::{sync::Arc, time::Duration}; use anyhow::Result; -pub use async_trait::async_trait; use crossbeam_channel::Sender; use tracing::instrument; -pub use wasi_common::I32Exit; +use wasmtime_wasi::preview2::Table; + +use self::host_component::{HostComponents, HostComponentsBuilder}; + +pub use async_trait::async_trait; pub use wasmtime::{ self, component::{Component, Instance}, Instance as ModuleInstance, Module, Trap, }; - -use self::host_component::{HostComponents, HostComponentsBuilder}; +pub use wasmtime_wasi::preview2::I32Exit; pub use host_component::{ AnyHostComponentDataHandle, HostComponent, HostComponentDataHandle, HostComponentsData, }; pub use io::OutputBuffer; -pub use store::{Store, StoreBuilder, Wasi}; +pub use store::{Store, StoreBuilder, Wasi, WasiVersion}; /// The default [`EngineBuilder::epoch_tick_interval`]. pub const DEFAULT_EPOCH_TICK_INTERVAL: Duration = Duration::from_millis(10); @@ -69,6 +71,7 @@ pub struct Data { wasi: Wasi, host_components_data: HostComponentsData, store_limits: limits::StoreLimitsAsync, + table: Table, } impl Data { @@ -90,6 +93,30 @@ impl AsMut for Data { } } +impl wasmtime_wasi::preview2::WasiView for Data { + fn table(&self) -> &wasmtime_wasi::preview2::Table { + &self.table + } + + fn table_mut(&mut self) -> &mut wasmtime_wasi::preview2::Table { + &mut self.table + } + + fn ctx(&self) -> &wasmtime_wasi::preview2::WasiCtx { + match &self.wasi { + Wasi::Preview1(_) => panic!("using WASI Preview 1 functions with Preview 2 store"), + Wasi::Preview2(ctx) => ctx, + } + } + + fn ctx_mut(&mut self) -> &mut wasmtime_wasi::preview2::WasiCtx { + match &mut self.wasi { + Wasi::Preview1(_) => panic!("using WASI Preview 1 functions with Preview 2 store"), + Wasi::Preview2(ctx) => ctx, + } + } +} + /// An alias for [`wasmtime::Linker`] specialized to [`Data`]. pub type ModuleLinker = wasmtime::Linker>; @@ -113,10 +140,7 @@ impl EngineBuilder { let engine = wasmtime::Engine::new(&config.inner)?; let mut linker: Linker = Linker::new(&engine); - wasi_host::command::add_to_linker(&mut linker, |data| match &mut data.wasi { - Wasi::Preview1(_) => panic!("using WASI Preview 1 functions with Preview 2 store"), - Wasi::Preview2(ctx) => ctx, - })?; + wasmtime_wasi::preview2::wasi::command::add_to_linker(&mut linker)?; let mut module_linker = ModuleLinker::new(&engine); wasmtime_wasi::tokio::add_to_linker(&mut module_linker, |data| match &mut data.wasi { @@ -241,12 +265,12 @@ impl Engine { } /// Creates a new [`StoreBuilder`]. - pub fn store_builder(&self, wasi: Wasi) -> StoreBuilder { + pub fn store_builder(&self, wasi_version: WasiVersion) -> StoreBuilder { StoreBuilder::new( self.inner.clone(), self.epoch_tick_interval, &self.host_components, - wasi, + wasi_version, ) } diff --git a/crates/core/src/store.rs b/crates/core/src/store.rs index 3147ed7558..1d2fc61f40 100644 --- a/crates/core/src/store.rs +++ b/crates/core/src/store.rs @@ -5,10 +5,9 @@ use std::{ time::{Duration, Instant}, }; use system_interface::io::ReadReady; -use wasi_cap_std_sync as wasmtime_wasi_preview2; -use wasi_common as wasi_preview2; use wasi_common_preview1 as wasi_preview1; use wasmtime_wasi as wasmtime_wasi_preview1; +use wasmtime_wasi::preview2 as wasi_preview2; use crate::{ host_component::{HostComponents, HostComponentsData}, @@ -42,16 +41,11 @@ pub enum Wasi { Preview2(wasi_preview2::WasiCtx), } -impl Wasi { - /// Create a new `Wasi::Preview1` context - pub fn new_preview1() -> Self { - Self::Preview1(wasmtime_wasi_preview1::WasiCtxBuilder::new().build()) - } - - /// Create a new `Wasi::Preview2` context - pub fn new_preview2() -> Self { - Self::Preview2(wasmtime_wasi_preview2::WasiCtxBuilder::new().build()) - } +/// The version of Wasi being used +#[allow(missing_docs)] +pub enum WasiVersion { + Preview1, + Preview2, } /// A `Store` holds the runtime state of a Spin instance. @@ -125,7 +119,7 @@ impl wasmtime::AsContextMut for Store { pub struct StoreBuilder { engine: wasmtime::Engine, epoch_tick_interval: Duration, - wasi: std::result::Result, + wasi: std::result::Result, host_components_data: HostComponentsData, store_limits: StoreLimitsAsync, } @@ -136,12 +130,12 @@ impl StoreBuilder { engine: wasmtime::Engine, epoch_tick_interval: Duration, host_components: &HostComponents, - wasi: Wasi, + wasi: WasiVersion, ) -> Self { Self { engine, epoch_tick_interval, - wasi: Ok(wasi), + wasi: Ok(wasi.into()), host_components_data: host_components.new_data(), store_limits: StoreLimitsAsync::default(), } @@ -158,27 +152,35 @@ impl StoreBuilder { /// Inherit stdin from the host process. pub fn inherit_stdin(&mut self) { self.with_wasi(|wasi| match wasi { - Wasi::Preview1(ctx) => ctx.set_stdin(Box::new(wasmtime_wasi_preview1::stdio::stdin())), - Wasi::Preview2(ctx) => ctx.set_stdin(Box::new(wasmtime_wasi_preview2::stdio::stdin())), + WasiCtxBuilder::Preview1(ctx) => { + ctx.set_stdin(Box::new(wasmtime_wasi_preview1::stdio::stdin())) + } + WasiCtxBuilder::Preview2(ctx) => { + *ctx = std::mem::take(ctx).set_stdin(wasi_preview2::stdio::stdin()) + } }); } /// Sets the WASI `stdin` descriptor to the given [`Read`]er. pub fn stdin_pipe(&mut self, r: impl Read + ReadReady + Send + Sync + 'static) { self.with_wasi(|wasi| match wasi { - Wasi::Preview1(ctx) => ctx.set_stdin(Box::new(wasi_preview1::pipe::ReadPipe::new(r))), - Wasi::Preview2(ctx) => ctx.set_stdin(Box::new(wasi_preview2::pipe::ReadPipe::new(r))), + WasiCtxBuilder::Preview1(ctx) => { + ctx.set_stdin(Box::new(wasi_preview1::pipe::ReadPipe::new(r))) + } + WasiCtxBuilder::Preview2(ctx) => { + *ctx = std::mem::take(ctx).set_stdin(wasi_preview2::pipe::ReadPipe::new(r)) + } }) } /// Inherit stdin from the host process. pub fn inherit_stdout(&mut self) { self.with_wasi(|wasi| match wasi { - Wasi::Preview1(ctx) => { + WasiCtxBuilder::Preview1(ctx) => { ctx.set_stdout(Box::new(wasmtime_wasi_preview1::stdio::stdout())) } - Wasi::Preview2(ctx) => { - ctx.set_stdout(Box::new(wasmtime_wasi_preview2::stdio::stdout())) + WasiCtxBuilder::Preview2(ctx) => { + *ctx = std::mem::take(ctx).set_stdout(wasi_preview2::stdio::stdout()) } }); } @@ -186,11 +188,11 @@ impl StoreBuilder { /// Sets the WASI `stdout` descriptor to the given [`Write`]er. pub fn stdout(&mut self, w: Box) -> Result<()> { self.try_with_wasi(|wasi| match wasi { - Wasi::Preview1(ctx) => { + WasiCtxBuilder::Preview1(ctx) => { ctx.set_stdout(w); Ok(()) } - Wasi::Preview2(_) => Err(anyhow!( + WasiCtxBuilder::Preview2(_) => Err(anyhow!( "`Store::stdout` only supported with WASI Preview 1" )), }) @@ -199,8 +201,12 @@ impl StoreBuilder { /// Sets the WASI `stdout` descriptor to the given [`Write`]er. pub fn stdout_pipe(&mut self, w: impl Write + Send + Sync + 'static) { self.with_wasi(|wasi| match wasi { - Wasi::Preview1(ctx) => ctx.set_stdout(Box::new(wasi_preview1::pipe::WritePipe::new(w))), - Wasi::Preview2(ctx) => ctx.set_stdout(Box::new(wasi_preview2::pipe::WritePipe::new(w))), + WasiCtxBuilder::Preview1(ctx) => { + ctx.set_stdout(Box::new(wasi_preview1::pipe::WritePipe::new(w))) + } + WasiCtxBuilder::Preview2(ctx) => { + *ctx = std::mem::take(ctx).set_stdout(wasi_preview2::pipe::WritePipe::new(w)) + } }) } @@ -210,11 +216,11 @@ impl StoreBuilder { let buffer = OutputBuffer::default(); // This only needs to work with Preview 2 since WAGI does its own thing with Preview 1: self.try_with_wasi(|wasi| match wasi { - Wasi::Preview1(_) => Err(anyhow!( + WasiCtxBuilder::Preview1(_) => Err(anyhow!( "`Store::stdout_buffered` only supported with WASI Preview 2" )), - Wasi::Preview2(ctx) => { - ctx.set_stdout(Box::new(buffer.writer())); + WasiCtxBuilder::Preview2(ctx) => { + *ctx = std::mem::take(ctx).set_stdout(buffer.writer()); Ok(()) } })?; @@ -224,11 +230,11 @@ impl StoreBuilder { /// Inherit stdin from the host process. pub fn inherit_stderr(&mut self) { self.with_wasi(|wasi| match wasi { - Wasi::Preview1(ctx) => { + WasiCtxBuilder::Preview1(ctx) => { ctx.set_stderr(Box::new(wasmtime_wasi_preview1::stdio::stderr())) } - Wasi::Preview2(ctx) => { - ctx.set_stderr(Box::new(wasmtime_wasi_preview2::stdio::stderr())) + WasiCtxBuilder::Preview2(ctx) => { + *ctx = std::mem::take(ctx).set_stderr(wasi_preview2::stdio::stderr()) } }); } @@ -236,8 +242,12 @@ impl StoreBuilder { /// Sets the WASI `stderr` descriptor to the given [`Write`]er. pub fn stderr_pipe(&mut self, w: impl Write + Send + Sync + 'static) { self.with_wasi(|wasi| match wasi { - Wasi::Preview1(ctx) => ctx.set_stderr(Box::new(wasi_preview1::pipe::WritePipe::new(w))), - Wasi::Preview2(ctx) => ctx.set_stderr(Box::new(wasi_preview2::pipe::WritePipe::new(w))), + WasiCtxBuilder::Preview1(ctx) => { + ctx.set_stderr(Box::new(wasi_preview1::pipe::WritePipe::new(w))) + } + WasiCtxBuilder::Preview2(ctx) => { + *ctx = std::mem::take(ctx).set_stderr(wasi_preview2::pipe::WritePipe::new(w)) + } }) } @@ -246,8 +256,8 @@ impl StoreBuilder { self.try_with_wasi(|wasi| { for arg in args { match wasi { - Wasi::Preview1(ctx) => ctx.push_arg(arg)?, - Wasi::Preview2(ctx) => ctx.push_arg(arg), + WasiCtxBuilder::Preview1(ctx) => ctx.push_arg(arg)?, + WasiCtxBuilder::Preview2(ctx) => *ctx = std::mem::take(ctx).push_arg(arg), } } Ok(()) @@ -262,8 +272,10 @@ impl StoreBuilder { self.try_with_wasi(|wasi| { for (k, v) in vars { match wasi { - Wasi::Preview1(ctx) => ctx.push_env(k.as_ref(), v.as_ref())?, - Wasi::Preview2(ctx) => ctx.push_env(k.as_ref(), v.as_ref()), + WasiCtxBuilder::Preview1(ctx) => ctx.push_env(k.as_ref(), v.as_ref())?, + WasiCtxBuilder::Preview2(ctx) => { + *ctx = std::mem::take(ctx).push_env(k, v); + } } } @@ -305,7 +317,7 @@ impl StoreBuilder { self.try_with_wasi(|wasi| { match wasi { - Wasi::Preview1(ctx) => { + WasiCtxBuilder::Preview1(ctx) => { let mut dir = Box::new(wasmtime_wasi_preview1::dir::Dir::from_cap_std(cap_std_dir)) as _; if !writable { @@ -313,13 +325,20 @@ impl StoreBuilder { } ctx.push_preopened_dir(dir, path)?; } - Wasi::Preview2(ctx) => { - let mut dir = - Box::new(wasmtime_wasi_preview2::dir::Dir::from_cap_std(cap_std_dir)) as _; - if !writable { - dir = Box::new(wasi_preview2::dir::ReadOnlyDir(dir)); - } - ctx.push_preopened_dir(dir, path)?; + WasiCtxBuilder::Preview2(ctx) => { + let dir_perms = if writable { + wasi_preview2::DirPerms::all() + } else { + wasi_preview2::DirPerms::READ + }; + let file_perms = wasi_preview2::FilePerms::all(); + + *ctx = std::mem::take(ctx).push_preopened_dir( + cap_std_dir, + dir_perms, + file_perms, + path, + ); } } Ok(()) @@ -335,7 +354,8 @@ impl StoreBuilder { /// /// If `T: Default`, it may be preferable to use [`Store::build`]. pub fn build_with_data(self, inner_data: T) -> Result> { - let wasi = self.wasi.map_err(anyhow::Error::msg)?; + let mut table = wasi_preview2::Table::new(); + let wasi = self.wasi.map_err(anyhow::Error::msg)?.build(&mut table)?; let mut inner = wasmtime::Store::new( &self.engine, @@ -344,6 +364,7 @@ impl StoreBuilder { wasi, host_components_data: self.host_components_data, store_limits: self.store_limits, + table, }, ); @@ -366,14 +387,14 @@ impl StoreBuilder { self.build_with_data(T::default()) } - fn with_wasi(&mut self, f: impl FnOnce(&mut Wasi)) { + fn with_wasi(&mut self, f: impl FnOnce(&mut WasiCtxBuilder)) { let _ = self.try_with_wasi(|wasi| { f(wasi); Ok(()) }); } - fn try_with_wasi(&mut self, f: impl FnOnce(&mut Wasi) -> Result<()>) -> Result<()> { + fn try_with_wasi(&mut self, f: impl FnOnce(&mut WasiCtxBuilder) -> Result<()>) -> Result<()> { let wasi = self .wasi .as_mut() @@ -388,3 +409,30 @@ impl StoreBuilder { } } } + +/// A builder of a `WasiCtx` for all versions of Wasi +#[allow(clippy::large_enum_variant)] +enum WasiCtxBuilder { + Preview1(wasi_preview1::WasiCtx), + Preview2(wasi_preview2::WasiCtxBuilder), +} + +impl From for WasiCtxBuilder { + fn from(value: WasiVersion) -> Self { + match value { + WasiVersion::Preview1 => { + Self::Preview1(wasmtime_wasi_preview1::WasiCtxBuilder::new().build()) + } + WasiVersion::Preview2 => Self::Preview2(wasi_preview2::WasiCtxBuilder::new()), + } + } +} + +impl WasiCtxBuilder { + fn build(self, table: &mut wasi_preview2::Table) -> anyhow::Result { + match self { + WasiCtxBuilder::Preview1(ctx) => Ok(Wasi::Preview1(ctx)), + WasiCtxBuilder::Preview2(b) => b.build(table).map(Wasi::Preview2), + } + } +} diff --git a/crates/core/tests/core-wasi-test/Cargo.toml b/crates/core/tests/core-wasi-test/Cargo.toml index 9de6561859..49204d2759 100644 --- a/crates/core/tests/core-wasi-test/Cargo.toml +++ b/crates/core/tests/core-wasi-test/Cargo.toml @@ -7,6 +7,6 @@ edition = "2021" debug = true [dependencies] -wit-bindgen = "0.6.0" +wit-bindgen = "0.7.0" [workspace] diff --git a/crates/core/tests/core-wasi-test/wit/multiplier.wit b/crates/core/tests/core-wasi-test/wit/multiplier.wit index a79b5bf243..0f3bf4c689 100644 --- a/crates/core/tests/core-wasi-test/wit/multiplier.wit +++ b/crates/core/tests/core-wasi-test/wit/multiplier.wit @@ -1,4 +1,6 @@ -default world multiplier { +package test:test + +world multiplier { import imports: interface { multiply: func(n: s32) -> s32 } diff --git a/crates/core/tests/integration_test.rs b/crates/core/tests/integration_test.rs index 953d7ed927..eae33ef43b 100644 --- a/crates/core/tests/integration_test.rs +++ b/crates/core/tests/integration_test.rs @@ -5,7 +5,7 @@ use std::{ }; use spin_core::{ - Component, Config, Engine, HostComponent, I32Exit, Store, StoreBuilder, Trap, Wasi, + Component, Config, Engine, HostComponent, I32Exit, Store, StoreBuilder, Trap, WasiVersion, }; use tempfile::TempDir; use tokio::fs; @@ -49,7 +49,10 @@ async fn test_read_only_preopened_dir_write_fails() { }) .await .unwrap_err(); - let trap = err.downcast::().expect("trap"); + let trap = err + .root_cause() // The error returned is a backtrace. We need the root cause. + .downcast_ref::() + .expect("trap error was not an I32Exit"); assert_eq!(trap.0, 1); } @@ -90,7 +93,10 @@ async fn test_max_memory_size_violated() { }) .await .unwrap_err(); - let trap = err.downcast::().expect("trap"); + let trap = err + .root_cause() // The error returned is a backtrace. We need the root cause. + .downcast_ref::() + .expect("trap error was not an I32Exit"); assert_eq!(trap.0, 1); } @@ -187,7 +193,7 @@ async fn run_core_wasi_test_engine<'a>( update_store_builder: impl FnOnce(&mut StoreBuilder), update_store: impl FnOnce(&mut Store<()>), ) -> anyhow::Result { - let mut store_builder: StoreBuilder = engine.store_builder(Wasi::new_preview2()); + let mut store_builder: StoreBuilder = engine.store_builder(WasiVersion::Preview2); let mut stdout_buf = store_builder.stdout_buffered()?; store_builder.stderr_pipe(TestWriter); store_builder.args(args)?; @@ -201,7 +207,7 @@ async fn run_core_wasi_test_engine<'a>( let component = Component::new(engine.as_ref(), &component)?; let instance_pre = engine.instantiate_pre(&component)?; let instance = instance_pre.instantiate_async(&mut store).await?; - let func = instance.get_typed_func::<(), (Result<(), ()>,)>(&mut store, "main")?; + let func = instance.get_typed_func::<(), (Result<(), ()>,)>(&mut store, "run")?; update_store(&mut store); diff --git a/crates/redis/src/spin.rs b/crates/redis/src/spin.rs index 8e8db82575..5d0bb8ddc7 100644 --- a/crates/redis/src/spin.rs +++ b/crates/redis/src/spin.rs @@ -47,7 +47,7 @@ impl SpinRedisExecutor { ) -> Result<()> { let func = instance .exports(&mut store) - .instance("inbound-redis") + .instance("fermyon:spin/inbound-redis") .ok_or_else(|| anyhow!("no inbound-redis instance found"))? .typed_func::<(Payload,), (Result<(), Error>,)>("handle-message")?; diff --git a/crates/templates/Cargo.toml b/crates/templates/Cargo.toml index d6f7cac57e..554b0f9d53 100644 --- a/crates/templates/Cargo.toml +++ b/crates/templates/Cargo.toml @@ -37,5 +37,5 @@ wasmtime-wasi = { workspace = true } [dependencies.wit-bindgen-wasmtime] git = "https://github.com/fermyon/wit-bindgen-backport" -rev = "634687fde664ed0016179d9427562ac57c2af639" +rev = "b89d5079ba5b07b319631a1b191d2139f126c976" features = ["async"] diff --git a/crates/trigger-http/src/spin.rs b/crates/trigger-http/src/spin.rs index 54d9fb5720..4fa2e20922 100644 --- a/crates/trigger-http/src/spin.rs +++ b/crates/trigger-http/src/spin.rs @@ -61,7 +61,7 @@ impl SpinHttpExecutor { let func = instance .exports(&mut store) - .instance("inbound-http") + .instance("fermyon:spin/inbound-http") .ok_or_else(|| anyhow!("no inbound-http instance found"))? .typed_func::<(http_types::Request,), (http_types::Response,)>("handle-request")?; diff --git a/crates/trigger-http/src/wagi.rs b/crates/trigger-http/src/wagi.rs index dae2a0db90..435c361876 100644 --- a/crates/trigger-http/src/wagi.rs +++ b/crates/trigger-http/src/wagi.rs @@ -6,7 +6,7 @@ use hyper::{ body::{self}, Body, Request, Response, }; -use spin_core::Wasi; +use spin_core::WasiVersion; use spin_http::{config::WagiTriggerConfig, routes::RoutePattern, wagi}; use spin_trigger::{EitherInstance, TriggerAppEngine}; use wasi_common_preview1::{pipe::WritePipe, I32Exit}; @@ -84,7 +84,7 @@ impl HttpExecutor for WagiHttpExecutor { let stdout = WritePipe::new_in_memory(); - let mut store_builder = engine.store_builder(component, Wasi::new_preview1())?; + let mut store_builder = engine.store_builder(component, WasiVersion::Preview1)?; // Set up Wagi environment store_builder.args(argv.split(' '))?; store_builder.env(headers)?; diff --git a/crates/trigger/src/lib.rs b/crates/trigger/src/lib.rs index 0b76eeae24..da9a42e562 100644 --- a/crates/trigger/src/lib.rs +++ b/crates/trigger/src/lib.rs @@ -14,7 +14,7 @@ use serde::de::DeserializeOwned; use spin_app::{App, AppComponent, AppLoader, AppTrigger, Loader, OwnedApp}; use spin_core::{ Config, Engine, EngineBuilder, Instance, InstancePre, ModuleInstance, ModuleInstancePre, Store, - StoreBuilder, Wasi, + StoreBuilder, WasiVersion, }; pub use crate::runtime_config::RuntimeConfig; @@ -236,8 +236,12 @@ impl TriggerAppEngine { } /// Returns a new StoreBuilder for the given component ID. - pub fn store_builder(&self, component_id: &str, wasi: Wasi) -> Result { - let mut builder = self.engine.store_builder(wasi); + pub fn store_builder( + &self, + component_id: &str, + wasi_version: WasiVersion, + ) -> Result { + let mut builder = self.engine.store_builder(wasi_version); let component = self.get_component(component_id)?; self.hooks .iter() @@ -250,7 +254,7 @@ impl TriggerAppEngine { &self, component_id: &str, ) -> Result<(EitherInstance, Store)> { - let store_builder = self.store_builder(component_id, Wasi::new_preview2())?; + let store_builder = self.store_builder(component_id, WasiVersion::Preview2)?; self.prepare_instance_with_store(component_id, store_builder) .await } diff --git a/crates/world/src/lib.rs b/crates/world/src/lib.rs index c045e9ec43..2181cbbc1e 100644 --- a/crates/world/src/lib.rs +++ b/crates/world/src/lib.rs @@ -5,3 +5,5 @@ wasmtime::component::bindgen!({ world: "reactor", async: true }); + +pub use fermyon::spin::*; diff --git a/wit/preview2/config.wit b/wit/preview2/config.wit index acdd206f77..2513e9e2a2 100644 --- a/wit/preview2/config.wit +++ b/wit/preview2/config.wit @@ -1,4 +1,4 @@ -default interface config { +interface config { // Get a configuration value for the current component. // The config key must match one defined in in the component manifest. get-config: func(key: string) -> result diff --git a/wit/preview2/http-types.wit b/wit/preview2/http-types.wit index bd69b4791e..5d156046bd 100644 --- a/wit/preview2/http-types.wit +++ b/wit/preview2/http-types.wit @@ -1,4 +1,4 @@ -default interface http-types { +interface http-types { type http-status = u16 type body = list diff --git a/wit/preview2/http.wit b/wit/preview2/http.wit index 4e906d5c48..faac938aca 100644 --- a/wit/preview2/http.wit +++ b/wit/preview2/http.wit @@ -1,5 +1,5 @@ -default interface http { - use pkg.http-types.{request, response, http-error} +interface http { + use http-types.{request, response, http-error} send-request: func(req: request) -> result } diff --git a/wit/preview2/inbound-http.wit b/wit/preview2/inbound-http.wit index f20df00255..0fef7f58dd 100644 --- a/wit/preview2/inbound-http.wit +++ b/wit/preview2/inbound-http.wit @@ -1,5 +1,5 @@ -default interface inbound-http { - use pkg.http-types.{request, response} +interface inbound-http { + use http-types.{request, response} handle-request: func(req: request) -> response } diff --git a/wit/preview2/inbound-redis.wit b/wit/preview2/inbound-redis.wit index b71cb799e2..2a027c5467 100644 --- a/wit/preview2/inbound-redis.wit +++ b/wit/preview2/inbound-redis.wit @@ -1,5 +1,5 @@ -default interface inbound-redis { - use pkg.redis-types.{payload, error} +interface inbound-redis { + use redis-types.{payload, error} // The entrypoint for a Redis handler. handle-message: func(message: payload) -> result<_, error> diff --git a/wit/preview2/key-value.wit b/wit/preview2/key-value.wit index 91ae81228e..29218f5871 100644 --- a/wit/preview2/key-value.wit +++ b/wit/preview2/key-value.wit @@ -1,4 +1,4 @@ -default interface key-value { +interface key-value { // A handle to an open key-value store type store = u32 diff --git a/wit/preview2/mysql.wit b/wit/preview2/mysql.wit index 348739cdf0..a08d86f5ef 100644 --- a/wit/preview2/mysql.wit +++ b/wit/preview2/mysql.wit @@ -1,5 +1,5 @@ -default interface mysql { - use pkg.rdbms-types.{parameter-value, row-set} +interface mysql { + use rdbms-types.{parameter-value, row-set} // General purpose error. variant mysql-error { diff --git a/wit/preview2/postgres.wit b/wit/preview2/postgres.wit index 9fd7a35465..d9c8afef68 100644 --- a/wit/preview2/postgres.wit +++ b/wit/preview2/postgres.wit @@ -1,5 +1,5 @@ -default interface postgres { - use pkg.rdbms-types.{parameter-value, row-set} +interface postgres { + use rdbms-types.{parameter-value, row-set} // General purpose error. variant pg-error { diff --git a/wit/preview2/rdbms-types.wit b/wit/preview2/rdbms-types.wit index b2bd41f1d6..ffadd9a3e2 100644 --- a/wit/preview2/rdbms-types.wit +++ b/wit/preview2/rdbms-types.wit @@ -1,4 +1,4 @@ -default interface rdbms-types { +interface rdbms-types { enum db-data-type { boolean, int8, diff --git a/wit/preview2/reactor.wit b/wit/preview2/reactor.wit index 042c1da4b8..c06a4bdf80 100644 --- a/wit/preview2/reactor.wit +++ b/wit/preview2/reactor.wit @@ -1,11 +1,13 @@ -default world reactor { - import config: pkg.config - import postgres: pkg.postgres - import mysql: pkg.mysql - import sqlite: pkg.sqlite - import redis: pkg.redis - import key-value: pkg.key-value - import http: pkg.http - export inbound-http: pkg.inbound-http - export inbound-redis: pkg.inbound-redis +package fermyon:spin + +world reactor { + import config + import postgres + import mysql + import sqlite + import redis + import key-value + import http + export inbound-http + export inbound-redis } diff --git a/wit/preview2/redis-types.wit b/wit/preview2/redis-types.wit index ab762dc08d..e08d593dd5 100644 --- a/wit/preview2/redis-types.wit +++ b/wit/preview2/redis-types.wit @@ -1,4 +1,4 @@ -default interface redis-types { +interface redis-types { // General purpose error. enum error { success, diff --git a/wit/preview2/redis.wit b/wit/preview2/redis.wit index b4413c331a..6d1d1da3e1 100644 --- a/wit/preview2/redis.wit +++ b/wit/preview2/redis.wit @@ -1,5 +1,5 @@ -default interface redis { - use pkg.redis-types.{payload, redis-parameter, redis-result, error} +interface redis { + use redis-types.{payload, redis-parameter, redis-result, error} // Publish a Redis message to the specificed channel and return an error, if any. publish: func(address: string, channel: string, payload: payload) -> result<_, error> diff --git a/wit/preview2/sqlite.wit b/wit/preview2/sqlite.wit index a539b905e8..8d802edf81 100644 --- a/wit/preview2/sqlite.wit +++ b/wit/preview2/sqlite.wit @@ -1,4 +1,4 @@ -default interface sqlite { +interface sqlite { // A handle to an open sqlite instance type connection = u32