diff --git a/Cargo.lock b/Cargo.lock index 587a5cd..9eddf1e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -142,7 +142,7 @@ checksum = "c7c24de15d275a1ecfd47a380fb4d5ec9bfe0933f309ed5e705b775596a3574d" dependencies = [ "proc-macro2", "quote", - "syn 2.0.79", + "syn 2.0.85", ] [[package]] @@ -153,7 +153,7 @@ checksum = "721cae7de5c34fbb2acd27e21e6d2cf7b886dce0c27388d46c4e6c47ea4318dd" dependencies = [ "proc-macro2", "quote", - "syn 2.0.79", + "syn 2.0.85", ] [[package]] @@ -225,7 +225,16 @@ dependencies = [ "miniz_oxide", "object", "rustc-demangle", - "windows-targets", + "windows-targets 0.52.6", +] + +[[package]] +name = "backtrace-ext" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "537beee3be4a18fb023b570f80e3ae28003db9167a751266b259926e25539d50" +dependencies = [ + "backtrace", ] [[package]] @@ -241,7 +250,7 @@ name = "balius-macros" version = "0.1.0" dependencies = [ "quote", - "syn 2.0.79", + "syn 2.0.85", ] [[package]] @@ -260,6 +269,7 @@ dependencies = [ "tar", "thiserror", "tokio", + "tokio-util", "tracing", "utxorpc", "warp", @@ -284,6 +294,24 @@ dependencies = [ "wit-bindgen", ] +[[package]] +name = "baliusd" +version = "0.1.0" +dependencies = [ + "balius-runtime", + "config", + "gasket", + "miette", + "serde", + "serde_json", + "serde_with", + "tokio", + "tokio-macros", + "tokio-util", + "tracing", + "tracing-subscriber", +] + [[package]] name = "base58" version = "0.2.0" @@ -401,7 +429,7 @@ dependencies = [ "iana-time-zone", "num-traits", "serde", - "windows-targets", + "windows-targets 0.52.6", ] [[package]] @@ -435,7 +463,7 @@ dependencies = [ "heck 0.5.0", "proc-macro2", "quote", - "syn 2.0.79", + "syn 2.0.85", ] [[package]] @@ -456,6 +484,21 @@ version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d3fd119d74b830634cea2a0f58bbd0d54540518a14397557951e79340abc28c0" +[[package]] +name = "config" +version = "0.13.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "23738e11972c7643e4ec947840fc463b6a571afcd3e735bdfce7d03c7a784aca" +dependencies = [ + "async-trait", + "lazy_static", + "nom", + "pathdiff", + "serde", + "serde_json", + "toml 0.5.11", +] + [[package]] name = "core-foundation" version = "0.9.4" @@ -636,6 +679,28 @@ dependencies = [ "cfg-if", ] +[[package]] +name = "crossbeam" +version = "0.8.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1137cd7e7fc0fb5d3c5a8678be38ec56e819125d8d7907411fe24ccb943faca8" +dependencies = [ + "crossbeam-channel", + "crossbeam-deque", + "crossbeam-epoch", + "crossbeam-queue", + "crossbeam-utils", +] + +[[package]] +name = "crossbeam-channel" +version = "0.5.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "33480d6946193aa8033910124896ca395333cae7e2d1113d1fef6c3272217df2" +dependencies = [ + "crossbeam-utils", +] + [[package]] name = "crossbeam-deque" version = "0.8.5" @@ -655,6 +720,15 @@ dependencies = [ "crossbeam-utils", ] +[[package]] +name = "crossbeam-queue" +version = "0.3.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "df0346b5d5e76ac2fe4e327c5fd1118d6be7c51dfb18f9b7922923f287471e35" +dependencies = [ + "crossbeam-utils", +] + [[package]] name = "crossbeam-utils" version = "0.8.20" @@ -723,7 +797,7 @@ dependencies = [ "proc-macro2", "quote", "strsim", - "syn 2.0.79", + "syn 2.0.85", ] [[package]] @@ -734,7 +808,7 @@ checksum = "d336a2a514f6ccccaa3e09b02d41d35330c07ddf03a62165fcec10bb561c7806" dependencies = [ "darling_core", "quote", - "syn 2.0.79", + "syn 2.0.85", ] [[package]] @@ -1002,6 +1076,33 @@ dependencies = [ "serde_json", ] +[[package]] +name = "gasket" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "75b60154514ed9e060f0b2b78819602fa5d68746d6b618efb2ea2fecc6f89f32" +dependencies = [ + "async-trait", + "crossbeam", + "gasket-derive", + "serde", + "signal-hook", + "thiserror", + "tokio", + "tracing", +] + +[[package]] +name = "gasket-derive" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d16f3b9da5c685c55178b9749f79bf6a6c62d1bd07656a0c8eeddadb80ef29c8" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.85", +] + [[package]] name = "generic-array" version = "0.14.7" @@ -1426,6 +1527,12 @@ version = "2.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ddc24109865250148c2e0f3d25d4f0f479571723792d3802153c60922a4fb708" +[[package]] +name = "is_ci" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7655c9839580ee829dfacba1d1278c2b7883e50a277ff7541299489d6bdfdc45" + [[package]] name = "is_terminal_polyfill" version = "1.70.1" @@ -1503,6 +1610,12 @@ dependencies = [ "wasm-bindgen", ] +[[package]] +name = "lazy_static" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" + [[package]] name = "leb128" version = "0.2.5" @@ -1574,6 +1687,37 @@ dependencies = [ "rustix", ] +[[package]] +name = "miette" +version = "7.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4edc8853320c2a0dab800fbda86253c8938f6ea88510dc92c5f1ed20e794afc1" +dependencies = [ + "backtrace", + "backtrace-ext", + "cfg-if", + "miette-derive", + "owo-colors", + "supports-color", + "supports-hyperlinks", + "supports-unicode", + "terminal_size", + "textwrap", + "thiserror", + "unicode-width", +] + +[[package]] +name = "miette-derive" +version = "7.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dcf09caffaac8068c346b6df2a7fc27a177fd20b39421a39ce0a211bde679a6c" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.85", +] + [[package]] name = "mime" version = "0.3.17" @@ -1611,6 +1755,12 @@ dependencies = [ "syn 1.0.109", ] +[[package]] +name = "minimal-lexical" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a" + [[package]] name = "miniz_oxide" version = "0.8.0" @@ -1696,6 +1846,26 @@ dependencies = [ "tempfile", ] +[[package]] +name = "nom" +version = "7.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d273983c5a657a70a3e8f2a01329822f3b8c8172b73826411a55751e404a0a4a" +dependencies = [ + "memchr", + "minimal-lexical", +] + +[[package]] +name = "nu-ansi-term" +version = "0.46.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "77a8165726e8236064dbb45459242600304b42a5ea24ee2948e18e023bf7ba84" +dependencies = [ + "overload", + "winapi", +] + [[package]] name = "num-bigint" version = "0.4.6" @@ -1788,7 +1958,7 @@ checksum = "a948666b637a0f465e8564c73e89d4dde00d72d4d473cc972f390fc3dcee7d9c" dependencies = [ "proc-macro2", "quote", - "syn 2.0.79", + "syn 2.0.85", ] [[package]] @@ -1809,6 +1979,18 @@ dependencies = [ "vcpkg", ] +[[package]] +name = "overload" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b15813163c1d831bf4a13c3610c05c0d03b39feb07f7e09fa234dac9b15aaf39" + +[[package]] +name = "owo-colors" +version = "4.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fb37767f6569cd834a413442455e0f066d0d522de8630436e2a1761d9726ba56" + [[package]] name = "pallas" version = "0.30.2" @@ -2077,6 +2259,12 @@ version = "1.0.15" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "57c0d7b74b563b49d38dae00a0c37d4d6de9b432382b2892f0574ddcae73fd0a" +[[package]] +name = "pathdiff" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d61c5ce1153ab5b689d0c074c4e7fc613e942dfb7dd9eea5ab202d2ad91fe361" + [[package]] name = "pbjson" version = "0.6.0" @@ -2147,7 +2335,7 @@ checksum = "2f38a4412a78282e09a2cf38d195ea5420d15ba0602cb375210efbc877243965" dependencies = [ "proc-macro2", "quote", - "syn 2.0.79", + "syn 2.0.85", ] [[package]] @@ -2202,7 +2390,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5f12335488a2f3b0a83b14edad48dca9879ce89b2edd10e80237e4e852dd645e" dependencies = [ "proc-macro2", - "syn 2.0.79", + "syn 2.0.85", ] [[package]] @@ -2251,7 +2439,7 @@ dependencies = [ "prost 0.12.6", "prost-types 0.12.6", "regex", - "syn 2.0.79", + "syn 2.0.85", "tempfile", ] @@ -2265,7 +2453,7 @@ dependencies = [ "itertools 0.12.1", "proc-macro2", "quote", - "syn 2.0.79", + "syn 2.0.85", ] [[package]] @@ -2278,7 +2466,7 @@ dependencies = [ "itertools 0.13.0", "proc-macro2", "quote", - "syn 2.0.79", + "syn 2.0.85", ] [[package]] @@ -2658,29 +2846,29 @@ dependencies = [ [[package]] name = "serde" -version = "1.0.210" +version = "1.0.213" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c8e3592472072e6e22e0a54d5904d9febf8508f65fb8552499a1abc7d1078c3a" +checksum = "3ea7893ff5e2466df8d720bb615088341b295f849602c6956047f8f80f0e9bc1" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.210" +version = "1.0.213" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "243902eda00fad750862fc144cea25caca5e20d615af0a81bee94ca738f1df1f" +checksum = "7e85ad2009c50b58e87caa8cd6dac16bdf511bbfb7af6c33df902396aa480fa5" dependencies = [ "proc-macro2", "quote", - "syn 2.0.79", + "syn 2.0.85", ] [[package]] name = "serde_json" -version = "1.0.128" +version = "1.0.132" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6ff5456707a1de34e7e37f2a6fd3d3f808c318259cbd01ab6377795054b483d8" +checksum = "d726bfaff4b320266d395898905d0eba0345aae23b54aee3a737e260fd46db03" dependencies = [ "itoa", "memchr", @@ -2711,9 +2899,9 @@ dependencies = [ [[package]] name = "serde_with" -version = "3.9.0" +version = "3.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "69cecfa94848272156ea67b2b1a53f20fc7bc638c4a46d2f8abde08f05f4b857" +checksum = "8e28bdad6db2b8340e449f7108f020b3b092e8583a9e3fb82713e1d4e71fe817" dependencies = [ "base64 0.22.1", "chrono", @@ -2729,14 +2917,14 @@ dependencies = [ [[package]] name = "serde_with_macros" -version = "3.9.0" +version = "3.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a8fee4991ef4f274617a51ad4af30519438dacb2f56ac773b08a1922ff743350" +checksum = "9d846214a9854ef724f3da161b426242d8de7c1fc7de2f89bb1efcb154dca79d" dependencies = [ "darling", "proc-macro2", "quote", - "syn 2.0.79", + "syn 2.0.85", ] [[package]] @@ -2774,12 +2962,40 @@ dependencies = [ "digest 0.10.7", ] +[[package]] +name = "sharded-slab" +version = "0.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f40ca3c46823713e0d4209592e8d6e826aa57e928f09752619fc696c499637f6" +dependencies = [ + "lazy_static", +] + [[package]] name = "shlex" version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64" +[[package]] +name = "signal-hook" +version = "0.3.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8621587d4798caf8eb44879d42e56b9a93ea5dcd315a6487c357130095b62801" +dependencies = [ + "libc", + "signal-hook-registry", +] + +[[package]] +name = "signal-hook-registry" +version = "1.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a9e9e0b4211b72e7b8b6e85c807d36c212bdb33ea8587f7569562a84df5465b1" +dependencies = [ + "libc", +] + [[package]] name = "slab" version = "0.4.9" @@ -2804,6 +3020,12 @@ dependencies = [ "serde", ] +[[package]] +name = "smawk" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b7c388c1b5e93756d0c740965c41e8822f866621d41acbdf6336a6a168f8840c" + [[package]] name = "socket2" version = "0.5.7" @@ -2853,6 +3075,27 @@ version = "2.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "13c2bddecc57b384dee18652358fb23172facb8a2c51ccc10d74c157bdea3292" +[[package]] +name = "supports-color" +version = "3.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8775305acf21c96926c900ad056abeef436701108518cf890020387236ac5a77" +dependencies = [ + "is_ci", +] + +[[package]] +name = "supports-hyperlinks" +version = "3.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2c0a1e5168041f5f3ff68ff7d95dcb9c8749df29f6e7e89ada40dd4c9de404ee" + +[[package]] +name = "supports-unicode" +version = "3.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b7401a30af6cb5818bb64852270bb722533397edcfc7344954a38f420819ece2" + [[package]] name = "syn" version = "1.0.109" @@ -2866,9 +3109,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.79" +version = "2.0.85" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "89132cd0bf050864e1d38dc3bbc07a0eb8e7530af26344d3d2bbbef83499f590" +checksum = "5023162dfcd14ef8f32034d8bcd4cc5ddc61ef7a247c024a33e24e1f24d21b56" dependencies = [ "proc-macro2", "quote", @@ -2950,6 +3193,27 @@ dependencies = [ "winapi-util", ] +[[package]] +name = "terminal_size" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "21bebf2b7c9e0a515f6e0f8c51dc0f8e4696391e6f1ff30379559f8365fb0df7" +dependencies = [ + "rustix", + "windows-sys 0.48.0", +] + +[[package]] +name = "textwrap" +version = "0.16.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "23d434d3f8967a09480fb04132ebe0a3e088c173e6d0ee7897abbdf4eab0f8b9" +dependencies = [ + "smawk", + "unicode-linebreak", + "unicode-width", +] + [[package]] name = "thiserror" version = "1.0.64" @@ -2967,7 +3231,17 @@ checksum = "08904e7672f5eb876eaaf87e0ce17857500934f4981c4a0ab2b4aa98baac7fc3" dependencies = [ "proc-macro2", "quote", - "syn 2.0.79", + "syn 2.0.85", +] + +[[package]] +name = "thread_local" +version = "1.1.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8b9ef9bad013ada3808854ceac7b46812a6465ba368859a37e2100283d2d719c" +dependencies = [ + "cfg-if", + "once_cell", ] [[package]] @@ -3018,15 +3292,16 @@ checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" [[package]] name = "tokio" -version = "1.40.0" +version = "1.41.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e2b070231665d27ad9ec9b8df639893f46727666c6767db40317fbe920a5d998" +checksum = "145f3413504347a2be84393cc8a7d2fb4d863b375909ea59f2158261aa258bbb" dependencies = [ "backtrace", "bytes", "libc", "mio", "pin-project-lite", + "signal-hook-registry", "socket2", "tokio-macros", "windows-sys 0.52.0", @@ -3050,7 +3325,7 @@ checksum = "693d596312e88961bc67d7f1f97af8a70227d9f90c31bba5806eec004978d752" dependencies = [ "proc-macro2", "quote", - "syn 2.0.79", + "syn 2.0.85", ] [[package]] @@ -3121,6 +3396,15 @@ dependencies = [ "tokio", ] +[[package]] +name = "toml" +version = "0.5.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f4f7f0dd8d50a853a531c426359045b1998f04219d88799810762cd4ad314234" +dependencies = [ + "serde", +] + [[package]] name = "toml" version = "0.8.19" @@ -3238,7 +3522,7 @@ checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.79", + "syn 2.0.85", ] [[package]] @@ -3248,6 +3532,32 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c06d3da6113f116aaee68e4d601191614c9053067f9ab7f6edbcb161237daa54" dependencies = [ "once_cell", + "valuable", +] + +[[package]] +name = "tracing-log" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ee855f1f400bd0e5c02d150ae5de3840039a3f54b025156404e34c23c03f47c3" +dependencies = [ + "log", + "once_cell", + "tracing-core", +] + +[[package]] +name = "tracing-subscriber" +version = "0.3.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ad0f048c97dbd9faa9b7df56362b8ebcaa52adb06b498c050d2f4e32f90a7a8b" +dependencies = [ + "nu-ansi-term", + "sharded-slab", + "smallvec", + "thread_local", + "tracing-core", + "tracing-log", ] [[package]] @@ -3302,6 +3612,12 @@ version = "1.0.12" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" +[[package]] +name = "unicode-linebreak" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3b09c83c3c29d37506a3e260c08c03743a6bb66a9cd432c6934ab501a190571f" + [[package]] name = "unicode-normalization" version = "0.1.22" @@ -3386,6 +3702,12 @@ version = "1.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "81dfa00651efa65069b0b6b651f4aaa31ba9e3c3ce0137aaad053604ee7e0314" +[[package]] +name = "valuable" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "830b7e5d4d90034032940e4ace0d9a9a057e7a45cd94e6c007832e39edb82f6d" + [[package]] name = "vcpkg" version = "0.2.15" @@ -3482,7 +3804,7 @@ dependencies = [ "once_cell", "proc-macro2", "quote", - "syn 2.0.79", + "syn 2.0.85", "wasm-bindgen-shared", ] @@ -3516,7 +3838,7 @@ checksum = "afc340c74d9005395cf9dd098506f7f44e38f2b4a21c6aaacf9a105ea5e1e836" dependencies = [ "proc-macro2", "quote", - "syn 2.0.79", + "syn 2.0.85", "wasm-bindgen-backend", "wasm-bindgen-shared", ] @@ -3680,7 +4002,7 @@ dependencies = [ "serde", "serde_derive", "sha2 0.10.8", - "toml", + "toml 0.8.19", "windows-sys 0.52.0", "zstd", ] @@ -3694,7 +4016,7 @@ dependencies = [ "anyhow", "proc-macro2", "quote", - "syn 2.0.79", + "syn 2.0.85", "wasmtime-component-util", "wasmtime-wit-bindgen", "wit-parser 0.212.0", @@ -3824,7 +4146,7 @@ checksum = "99c02af2e9dbeb427304d1a08787d70ed0dbfec1af2236616f84c9f1f03e7969" dependencies = [ "proc-macro2", "quote", - "syn 2.0.79", + "syn 2.0.85", ] [[package]] @@ -3942,7 +4264,7 @@ version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "33ab640c8d7e35bf8ba19b884ba838ceb4fba93a4e8c65a9059d08afcfc683d9" dependencies = [ - "windows-targets", + "windows-targets 0.52.6", ] [[package]] @@ -3953,7 +4275,7 @@ checksum = "e400001bb720a623c1c69032f8e3e4cf09984deec740f007dd2b03ec864804b0" dependencies = [ "windows-result", "windows-strings", - "windows-targets", + "windows-targets 0.52.6", ] [[package]] @@ -3962,7 +4284,7 @@ version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1d1043d8214f791817bab27572aaa8af63732e11bf84aa21a45a78d6c317ae0e" dependencies = [ - "windows-targets", + "windows-targets 0.52.6", ] [[package]] @@ -3972,7 +4294,16 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4cd9b125c486025df0eabcb585e62173c6c9eddcec5d117d3b6e8c30e2ee4d10" dependencies = [ "windows-result", - "windows-targets", + "windows-targets 0.52.6", +] + +[[package]] +name = "windows-sys" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9" +dependencies = [ + "windows-targets 0.48.5", ] [[package]] @@ -3981,7 +4312,7 @@ version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" dependencies = [ - "windows-targets", + "windows-targets 0.52.6", ] [[package]] @@ -3990,7 +4321,22 @@ version = "0.59.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1e38bc4d79ed67fd075bcc251a1c39b32a1776bbe92e5bef1f0bf1f8c531853b" dependencies = [ - "windows-targets", + "windows-targets 0.52.6", +] + +[[package]] +name = "windows-targets" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9a2fa6e2155d7247be68c096456083145c183cbbbc2764150dda45a87197940c" +dependencies = [ + "windows_aarch64_gnullvm 0.48.5", + "windows_aarch64_msvc 0.48.5", + "windows_i686_gnu 0.48.5", + "windows_i686_msvc 0.48.5", + "windows_x86_64_gnu 0.48.5", + "windows_x86_64_gnullvm 0.48.5", + "windows_x86_64_msvc 0.48.5", ] [[package]] @@ -3999,28 +4345,46 @@ version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973" dependencies = [ - "windows_aarch64_gnullvm", - "windows_aarch64_msvc", - "windows_i686_gnu", + "windows_aarch64_gnullvm 0.52.6", + "windows_aarch64_msvc 0.52.6", + "windows_i686_gnu 0.52.6", "windows_i686_gnullvm", - "windows_i686_msvc", - "windows_x86_64_gnu", - "windows_x86_64_gnullvm", - "windows_x86_64_msvc", + "windows_i686_msvc 0.52.6", + "windows_x86_64_gnu 0.52.6", + "windows_x86_64_gnullvm 0.52.6", + "windows_x86_64_msvc 0.52.6", ] +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8" + [[package]] name = "windows_aarch64_gnullvm" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3" +[[package]] +name = "windows_aarch64_msvc" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc" + [[package]] name = "windows_aarch64_msvc" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469" +[[package]] +name = "windows_i686_gnu" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e" + [[package]] name = "windows_i686_gnu" version = "0.52.6" @@ -4033,24 +4397,48 @@ version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66" +[[package]] +name = "windows_i686_msvc" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406" + [[package]] name = "windows_i686_msvc" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66" +[[package]] +name = "windows_x86_64_gnu" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e" + [[package]] name = "windows_x86_64_gnu" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78" +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc" + [[package]] name = "windows_x86_64_gnullvm" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d" +[[package]] +name = "windows_x86_64_msvc" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538" + [[package]] name = "windows_x86_64_msvc" version = "0.52.6" @@ -4106,7 +4494,7 @@ dependencies = [ "heck 0.5.0", "indexmap 2.6.0", "prettyplease", - "syn 2.0.79", + "syn 2.0.85", "wasm-metadata", "wit-bindgen-core", "wit-component", @@ -4122,7 +4510,7 @@ dependencies = [ "prettyplease", "proc-macro2", "quote", - "syn 2.0.79", + "syn 2.0.85", "wit-bindgen-core", "wit-bindgen-rust", ] @@ -4211,7 +4599,7 @@ checksum = "9ce1b18ccd8e73a9321186f97e46f9f04b778851177567b1975109d26a08d2a6" dependencies = [ "proc-macro2", "quote", - "syn 2.0.79", + "syn 2.0.85", ] [[package]] diff --git a/Cargo.toml b/Cargo.toml index d0971c9..7db1ba5 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -9,5 +9,5 @@ members = [ "examples/minter/offchain", "balius-sdk", "balius-runtime", - "balius-macros", + "balius-macros", "baliusd", ] diff --git a/balius-runtime/Cargo.toml b/balius-runtime/Cargo.toml index 9c446ed..1937864 100644 --- a/balius-runtime/Cargo.toml +++ b/balius-runtime/Cargo.toml @@ -20,6 +20,7 @@ hex = "0.4.3" itertools = "0.13.0" async-trait = "0.1.83" utxorpc = { version = "0.7.1", optional = true } +tokio-util = "0.7.12" [dev-dependencies] tokio = "1.40.0" diff --git a/balius-runtime/src/drivers/jsonrpc.rs b/balius-runtime/src/drivers/jsonrpc.rs new file mode 100644 index 0000000..bceff71 --- /dev/null +++ b/balius-runtime/src/drivers/jsonrpc.rs @@ -0,0 +1,91 @@ +use serde::{Deserialize, Serialize}; +use std::net::SocketAddr; +use tokio_util::sync::CancellationToken; +use tracing::{debug, error}; +use warp::Filter as _; + +use crate::{Error, Runtime}; + +#[derive(Serialize, Deserialize, Clone, Debug)] +pub struct Config { + pub listen_address: String, +} + +#[derive(Deserialize)] +struct Request { + pub id: Option, + pub method: String, + pub params: serde_json::Value, +} + +#[derive(Serialize)] +struct ErrorResponse { + error: String, +} + +fn parse_request(body: serde_json::Value) -> Result { + match serde_json::from_value(body) { + Ok(x) => Ok(x), + Err(x) => Err(ErrorResponse { + error: x.to_string(), + }), + } +} + +pub async fn serve( + config: Config, + runtime: Runtime, + cancel: CancellationToken, +) -> Result<(), Error> { + let filter = warp::any() + .map(move || runtime.clone()) + .and(warp::path::param()) + .and(warp::post()) + .and(warp::body::json()) + .then( + |runtime: Runtime, worker: String, body: serde_json::Value| async move { + let request = match parse_request(body) { + Ok(x) => x, + Err(err) => return warp::reply::json(&err), + }; + + debug!( + worker, + id = request.id, + method = request.method, + "handling request" + ); + + let reply = runtime + .handle_request(&worker, &request.method, request.params) + .await; + + match reply { + Ok(x) => { + debug!(worker, id = request.id, "request successful"); + warp::reply::json(&x) + } + Err(err) => { + error!(worker, id = request.id, "request failed"); + warp::reply::json(&ErrorResponse { + error: err.to_string(), + }) + } + } + }, + ); + + let address: SocketAddr = config + .listen_address + .parse() + .map_err(|x: std::net::AddrParseError| Error::Config(x.to_string()))?; + + let (addr, server) = + warp::serve(filter).bind_with_graceful_shutdown(address, cancel.cancelled_owned()); + + tracing::info!(%addr, "Json-RPC server listening"); + + server.await; + + Ok(()) +} diff --git a/balius-runtime/src/drivers/mod.rs b/balius-runtime/src/drivers/mod.rs new file mode 100644 index 0000000..ebba793 --- /dev/null +++ b/balius-runtime/src/drivers/mod.rs @@ -0,0 +1 @@ +pub mod jsonrpc; diff --git a/balius-runtime/src/ledgers/u5c.rs b/balius-runtime/src/ledgers/u5c.rs index e0fb12e..4b094fb 100644 --- a/balius-runtime/src/ledgers/u5c.rs +++ b/balius-runtime/src/ledgers/u5c.rs @@ -1,3 +1,4 @@ +use serde::{Deserialize, Serialize}; use utxorpc::CardanoQueryClient; use crate::wit::balius::app::ledger as wit; @@ -77,6 +78,7 @@ impl From> for wit::UtxoPage { } } +#[derive(Clone, Serialize, Deserialize, Debug)] pub struct Config { pub endpoint_url: String, pub api_key: String, diff --git a/balius-runtime/src/lib.rs b/balius-runtime/src/lib.rs index ba6b086..a09989f 100644 --- a/balius-runtime/src/lib.rs +++ b/balius-runtime/src/lib.rs @@ -1,12 +1,12 @@ use pallas::ledger::traverse::MultiEraBlock; use serde_json::json; -use tokio::sync::Mutex; use std::{ collections::{HashMap, HashSet}, path::Path, sync::Arc, }; use thiserror::Error; +use tokio::sync::Mutex; mod wit { wasmtime::component::bindgen!({ @@ -20,6 +20,7 @@ mod router; mod store; // implementations +pub mod drivers; pub mod kv; pub mod ledgers; pub mod submit; @@ -53,6 +54,9 @@ pub enum Error { #[error("ledger error: {0}")] Ledger(String), + + #[error("config error: {0}")] + Config(String), } impl From for Error { @@ -159,8 +163,8 @@ impl Runtime { &mut self, id: &str, wasm_path: impl AsRef, - config: serde_json::Value, - ) -> wasmtime::Result<()> { + config: Option, + ) -> Result<(), Error> { let component = wasmtime::component::Component::from_file(&self.engine, wasm_path)?; let mut store = wasmtime::Store::new( diff --git a/balius-runtime/tests/e2e.rs b/balius-runtime/tests/e2e.rs index c78740a..cbe60c5 100644 --- a/balius-runtime/tests/e2e.rs +++ b/balius-runtime/tests/e2e.rs @@ -24,7 +24,7 @@ async fn faucet_claim() { }); runtime - .register_worker("faucet", "tests/faucet.wasm", config) + .register_worker("faucet", "tests/faucet.wasm", Some(config)) .await .unwrap(); diff --git a/balius-runtime/tests/u5c.rs b/balius-runtime/tests/u5c.rs index be9ac61..1d24328 100644 --- a/balius-runtime/tests/u5c.rs +++ b/balius-runtime/tests/u5c.rs @@ -32,7 +32,7 @@ async fn faucet_claim() { }); runtime - .register_worker("faucet", "tests/faucet.wasm", config) + .register_worker("faucet", "tests/faucet.wasm", Some(config)) .await .unwrap(); diff --git a/baliusd/.gitignore b/baliusd/.gitignore new file mode 100644 index 0000000..4f37f08 --- /dev/null +++ b/baliusd/.gitignore @@ -0,0 +1 @@ +baliusd.db \ No newline at end of file diff --git a/baliusd/Cargo.toml b/baliusd/Cargo.toml new file mode 100644 index 0000000..0fc2287 --- /dev/null +++ b/baliusd/Cargo.toml @@ -0,0 +1,19 @@ +[package] +name = "baliusd" +description = "A standalone Balius runtime that can be used as a daemon" +version = "0.1.0" +edition = "2021" + +[dependencies] +balius-runtime = { version = "0.1.0", path = "../balius-runtime", features = ["utxorpc"] } +gasket = { version = "0.8.0", features = ["derive"] } +miette = { version = "7.2.0", features = ["fancy"] } +serde = { version = "1.0.213", features = ["derive"] } +serde_json = "1.0.132" +serde_with = "3.11.0" +tokio = { version = "1.41.0", features = ["rt-multi-thread", "signal"] } +tokio-macros = "2.4.0" +tokio-util = "0.7.12" +tracing = "0.1.40" +tracing-subscriber = "0.3.18" +config = { version = "0.13.3", default-features = false, features = ["toml", "json"] } diff --git a/baliusd/example/baliusd.toml b/baliusd/example/baliusd.toml new file mode 100644 index 0000000..ec327dd --- /dev/null +++ b/baliusd/example/baliusd.toml @@ -0,0 +1,19 @@ +[rpc] +listen_address = "0.0.0.0:3000" + +[logging] +max_level = "debug" +include_tokio = true + +[ledger] +endpoint_url = "https://mainnet.utxorpc-v0.demeter.run" +api_key = "dmtr_utxorpc1wgnnj0qcfj32zxsz2uc8d4g7uclm2s2w" + +[[workers]] +name = "faucet" +module = "faucet.wasm" + +[workers.config.validator] +ref_txo = { transaction_id = "f7d3837715680f3a170e99cd202b726842d97f82c05af8fcd18053c64e33ec4f", index = 0 } +hash = "ef7a1cebb2dc7de884ddf82f8fcbc91fe9750dcd8c12ec7643a99bbe" +address = "addr1qx2fxv2umyhttkxyxp8x0dlpdt3k6cwng5pxj3jhsydzer3n0d3vllmyqwsx5wktcd8cc3sq835lu7drv2xwl2wywfgse35a3x" diff --git a/baliusd/example/faucet.wasm b/baliusd/example/faucet.wasm new file mode 100644 index 0000000..9f8533a Binary files /dev/null and b/baliusd/example/faucet.wasm differ diff --git a/baliusd/src/boilerplate.rs b/baliusd/src/boilerplate.rs new file mode 100644 index 0000000..8818559 --- /dev/null +++ b/baliusd/src/boilerplate.rs @@ -0,0 +1,124 @@ +use serde::de::DeserializeOwned; +use std::time::Duration; +use tokio::task::JoinHandle; +use tokio_util::sync::CancellationToken; +use tracing::{debug, warn}; +use tracing_subscriber::{filter::Targets, prelude::*}; + +use crate::LoggingConfig; + +pub fn setup_tracing(config: &LoggingConfig) -> miette::Result<()> { + let level = config.max_level; + + let mut filter = Targets::new() + .with_target("baliusd", level) + .with_target("balius_runtime", level) + .with_target("gasket", level); + + if config.include_tokio { + filter = filter + .with_target("tokio", level) + .with_target("runtime", level); + } + + #[cfg(not(feature = "debug"))] + { + tracing_subscriber::registry() + .with(tracing_subscriber::fmt::layer()) + .with(filter) + .init(); + } + + #[cfg(feature = "debug")] + { + tracing_subscriber::registry() + .with(tracing_subscriber::fmt::layer()) + .with(console_subscriber::spawn()) + .with(filter) + .init(); + } + + Ok(()) +} + +#[inline] +#[cfg(unix)] +async fn wait_for_exit_signal() { + let mut sigterm = + tokio::signal::unix::signal(tokio::signal::unix::SignalKind::terminate()).unwrap(); + + tokio::select! { + _ = tokio::signal::ctrl_c() => { + warn!("SIGINT detected"); + } + _ = sigterm.recv() => { + warn!("SIGTERM detected"); + } + }; +} + +#[inline] +#[cfg(windows)] +async fn wait_for_exit_signal() { + tokio::signal::ctrl_c().await.unwrap() +} + +pub fn hook_exit_token() -> CancellationToken { + let cancel = CancellationToken::new(); + + let cancel2 = cancel.clone(); + tokio::spawn(async move { + wait_for_exit_signal().await; + debug!("notifying exit"); + cancel2.cancel(); + }); + + cancel +} + +pub async fn run_pipeline(pipeline: gasket::daemon::Daemon, exit: CancellationToken) { + loop { + tokio::select! { + _ = tokio::time::sleep(Duration::from_secs(5000)) => { + if pipeline.should_stop() { + break; + } + } + _ = exit.cancelled() => { + debug!("exit requested"); + break; + } + } + } + + debug!("shutting down pipeline"); + pipeline.teardown(); +} + +#[allow(dead_code)] +pub fn spawn_pipeline(pipeline: gasket::daemon::Daemon, exit: CancellationToken) -> JoinHandle<()> { + tokio::spawn(run_pipeline(pipeline, exit)) +} + +pub fn load_config(explicit_file: &Option) -> Result +where + T: DeserializeOwned, +{ + let mut s = config::Config::builder(); + + // our base config will always be in /etc/dolos + s = s.add_source(config::File::with_name("/etc/baliusd/daemon.toml").required(false)); + + // but we can override it by having a file in the working dir + s = s.add_source(config::File::with_name("baliusd.toml").required(false)); + + // if an explicit file was passed, then we load it as mandatory + if let Some(explicit) = explicit_file.as_ref().and_then(|x| x.to_str()) { + s = s.add_source(config::File::with_name(explicit).required(true)); + } + + // finally, we use env vars to make some last-step overrides + s = s.add_source(config::Environment::with_prefix("BALIUSD").separator("_")); + + s.build()?.try_deserialize() +} diff --git a/baliusd/src/main.rs b/baliusd/src/main.rs new file mode 100644 index 0000000..4a7f0d1 --- /dev/null +++ b/baliusd/src/main.rs @@ -0,0 +1,80 @@ +use std::path::PathBuf; + +use balius_runtime::{drivers, ledgers, Runtime, Store}; +use miette::{Context as _, IntoDiagnostic as _}; +use serde::{Deserialize, Serialize}; +use serde_json::json; +use serde_with::{serde_as, DisplayFromStr}; +use tracing::info; + +mod boilerplate; + +#[serde_as] +#[derive(Serialize, Deserialize, Debug, Clone)] +pub struct LoggingConfig { + #[serde_as(as = "DisplayFromStr")] + max_level: tracing::Level, + + #[serde(default)] + include_tokio: bool, +} + +#[derive(Deserialize, Serialize, Clone, Debug)] +pub struct WorkerConfig { + pub name: String, + pub module: PathBuf, + pub since_slot: Option, + pub until_slot: Option, + pub config: Option, +} + +#[derive(Deserialize, Serialize, Clone, Debug)] +pub struct Config { + pub rpc: drivers::jsonrpc::Config, + pub ledger: ledgers::u5c::Config, + pub workers: Vec, + pub logging: LoggingConfig, +} + +#[tokio::main] +async fn main() -> miette::Result<()> { + let config: Config = boilerplate::load_config(&None) + .into_diagnostic() + .context("loading config")?; + + boilerplate::setup_tracing(&config.logging).unwrap(); + + let store = Store::open("baliusd.db", None) + .into_diagnostic() + .context("opening store")?; + + let ledger = ledgers::u5c::Ledger::new(config.ledger) + .await + .into_diagnostic() + .context("setting up ledger")?; + + let mut runtime = Runtime::builder(store) + .with_ledger(ledger.into()) + .build() + .into_diagnostic() + .context("setting up runtime")?; + + for worker in config.workers { + runtime + .register_worker(&worker.name, worker.module, worker.config) + .await + .into_diagnostic() + .context("registering worker")?; + + info!(name = worker.name, "registered worker"); + } + + let cancel = boilerplate::hook_exit_token(); + + balius_runtime::drivers::jsonrpc::serve(config.rpc, runtime, cancel) + .await + .into_diagnostic() + .context("serving json-rpc requests")?; + + Ok(()) +}