diff --git a/.gitignore b/.gitignore index 2c85a92e5..f881a9cbd 100644 --- a/.gitignore +++ b/.gitignore @@ -34,3 +34,6 @@ expand.rs # Benchmarks [0-9]/ /benches + +# AI +.claude diff --git a/.zed/settings.json b/.zed/settings.json deleted file mode 100644 index 391fdabca..000000000 --- a/.zed/settings.json +++ /dev/null @@ -1,22 +0,0 @@ -{ - "file_scan_exclusions": [ - // default - "**/.git", - "**/.svn", - "**/.hg", - "**/.jj", - "**/CVS", - "**/.DS_Store", - "**/Thumbs.db", - "**/.classpath", - "**/.settings", - // custom - "**/lean-qr/*/index.mjs", - "**/modern-screenshot/*/index.mjs", - "**/solidjs-signals/*/dist/prod.js", - "uFuzzy.mjs", - "lightweight-charts.standalone.production.mjs" - // "scripts/packages", - // "dist" - ] -} diff --git a/Cargo.lock b/Cargo.lock index 6d4fd6fe3..ab28a51a3 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -261,9 +261,9 @@ dependencies = [ [[package]] name = "axum-core" -version = "0.5.5" +version = "0.5.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "59446ce19cd142f8833f856eb31f3eb097812d1479ab224f54d72428ca21ea22" +checksum = "08c78f31d7b1291f7ee735c1c6780ccde7785daae9a9206026862dab7d8792d1" dependencies = [ "bytes", "futures-core", @@ -849,9 +849,9 @@ dependencies = [ [[package]] name = "brk_rolldown" -version = "0.5.1" +version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0e4c28de774e0ef00d245c08e58ad26c912afd40149897af597bd50a0f65a248" +checksum = "b663fc71e6bfb55bb85706acbb12ad20c69f2034dc63fab16661ad83e96a4acc" dependencies = [ "anyhow", "append-only-vec", @@ -868,6 +868,7 @@ dependencies = [ "brk_rolldown_plugin_chunk_import_map", "brk_rolldown_plugin_data_uri", "brk_rolldown_plugin_hmr", + "brk_rolldown_plugin_lazy_compilation", "brk_rolldown_plugin_oxc_runtime", "brk_rolldown_resolver", "brk_rolldown_sourcemap", @@ -903,9 +904,9 @@ dependencies = [ [[package]] name = "brk_rolldown_common" -version = "0.5.1" +version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "468af65fa5bab1026237d36c450109018a7f2b1232c22bf34c5207b0a88c6ae1" +checksum = "18b8ec7db68a6e506204f1c3a52a3430236d679ce333adc16a022f728ec38e5e" dependencies = [ "anyhow", "arcstr", @@ -935,9 +936,9 @@ dependencies = [ [[package]] name = "brk_rolldown_dev_common" -version = "0.5.1" +version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4e266f6c9721ef770e47884a626f930f6b9d195fd578195c00c679ab50eb0841" +checksum = "e30475c1f8e9e717cac29880d4ed625add518cc1b271e8f95e4099aeac1578cf" dependencies = [ "brk_rolldown_common", "brk_rolldown_error", @@ -946,9 +947,9 @@ dependencies = [ [[package]] name = "brk_rolldown_devtools" -version = "0.5.1" +version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6bc520612874708cfa1476f32d706756403d0cee519fc66f276c70af2a60807d" +checksum = "6fdf5ff0cdad5b1097d75059c28a70c150be3cd2bee12bb2dbd23499f5b07630" dependencies = [ "blake3", "brk_rolldown_devtools_action", @@ -962,9 +963,9 @@ dependencies = [ [[package]] name = "brk_rolldown_devtools_action" -version = "0.5.1" +version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a13eb16a0561095b134f0e39dac08b320150c249e8c57bf919154e0d4d5f310a" +checksum = "86b1791f7534249a71106fdbe3865dab344fad298e9cba6b2d2ba43931ffef62" dependencies = [ "serde", "ts-rs", @@ -972,9 +973,9 @@ dependencies = [ [[package]] name = "brk_rolldown_ecmascript" -version = "0.5.1" +version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e8582c0a01de8978aa1fab9b14e96943104aeb9ecacbb4f427fec32b9c247b7c" +checksum = "12d26e2532952544c39008f433b027bc5f8f9edfbb5ab5e311f4a7005c2aeb5a" dependencies = [ "arcstr", "brk_rolldown_error", @@ -985,20 +986,21 @@ dependencies = [ [[package]] name = "brk_rolldown_ecmascript_utils" -version = "0.5.1" +version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f33e703d8d85cdd73fca0d1699c559af4fba345b3110d49601d3f9b6dd5b436c" +checksum = "79358b81155f0afa079d53b796370fbb56c3bb730c3790af6542509aec3479aa" dependencies = [ "brk_rolldown_common", + "brk_rolldown_utils", "oxc", "smallvec", ] [[package]] name = "brk_rolldown_error" -version = "0.5.1" +version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dcc15aad987d1c6c8e85defe85a0df3f6fc096089bd6fc994b3b3d54e4d1233c" +checksum = "01bf061dca4d33bb0268736b95165ff7cb837341d1ed60d596e54d9949bb7099" dependencies = [ "anyhow", "arcstr", @@ -1016,9 +1018,9 @@ dependencies = [ [[package]] name = "brk_rolldown_fs" -version = "0.5.1" +version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1a993d55c60467e62a1c8093a7f092d4690bf04f39f6f99dd701cd39529aa610" +checksum = "d6e34c23974f0099042093821fd49de7fae6ed8d7177ad4e8418469c45b46677" dependencies = [ "oxc_resolver", "vfs", @@ -1026,9 +1028,9 @@ dependencies = [ [[package]] name = "brk_rolldown_plugin" -version = "0.5.1" +version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "21c0cc2fd5929acb738d3e5d6f1b43c44f71935d6c4b1cb1f67801adb85c84fd" +checksum = "49171536730187d7154281b7830ef1874f1deb6ff0c166b5571ee9aa891851e8" dependencies = [ "anyhow", "arcstr", @@ -1044,6 +1046,7 @@ dependencies = [ "brk_string_wizard", "dashmap", "derive_more", + "nodejs-built-in-modules", "oxc_index", "rustc-hash", "serde", @@ -1056,9 +1059,9 @@ dependencies = [ [[package]] name = "brk_rolldown_plugin_chunk_import_map" -version = "0.5.1" +version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c201332bec8851626e62c6320b3fdc08e17a12764db111335903a554f3b8c59" +checksum = "40d1670473ab8b403186ff59b3acaf5fc6585888cd96281181435629ea737639" dependencies = [ "arcstr", "brk_rolldown_common", @@ -1071,9 +1074,9 @@ dependencies = [ [[package]] name = "brk_rolldown_plugin_data_uri" -version = "0.5.1" +version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9fc1e9e46d4f01c138de7234153b2d8947a78de88503cc15e24fe9607bcd0614" +checksum = "812aa9ecfca91b39854e1456cdcb9ea29ef0792effe655c119987b964a89695e" dependencies = [ "arcstr", "base64-simd", @@ -1086,9 +1089,9 @@ dependencies = [ [[package]] name = "brk_rolldown_plugin_hmr" -version = "0.5.1" +version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "87fbad836388ac021815de74523aef5960bdc951a8dbbaf4c186a782da8bbcd5" +checksum = "b5121b446e0d7134ca8591cd202193015e342bcc5245a5a848ce352c4758e825" dependencies = [ "arcstr", "brk_rolldown_common", @@ -1097,10 +1100,22 @@ dependencies = [ ] [[package]] -name = "brk_rolldown_plugin_oxc_runtime" -version = "0.5.1" +name = "brk_rolldown_plugin_lazy_compilation" +version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7e1fa517f1cdd1b84feb1d3f3e3a13a34cea498c2cfa7f216a49e634208336fc" +checksum = "11302e58eb56f543e3fdfb5fd555050f73162f11c72adde4238be7717310280f" +dependencies = [ + "arcstr", + "brk_rolldown_common", + "brk_rolldown_plugin", + "brk_rolldown_utils", +] + +[[package]] +name = "brk_rolldown_plugin_oxc_runtime" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f742caad9c8e99e8ef9e7c444b080838317a945230b6befac271ab97337e844" dependencies = [ "arcstr", "brk_rolldown_plugin", @@ -1110,9 +1125,9 @@ dependencies = [ [[package]] name = "brk_rolldown_resolver" -version = "0.5.1" +version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "74d231a0dac24bdabca95501d3c4914db2dfd851957cc1dfc7ab163418fd64e7" +checksum = "6c1a629f24ebb97efc1b3b534595edef9c8c0cf5d64de4562f62cb044ffd3b96" dependencies = [ "anyhow", "arcstr", @@ -1127,9 +1142,9 @@ dependencies = [ [[package]] name = "brk_rolldown_sourcemap" -version = "0.5.1" +version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "388f6aad886ebcb9a93ee6a88bcea70629016617296caf4643fca935cab2f044" +checksum = "b4da81607ddcff806e067ae5c1afadfeda0d3fe69edd6325e9f11404179f7f18" dependencies = [ "brk_rolldown_utils", "memchr", @@ -1140,18 +1155,18 @@ dependencies = [ [[package]] name = "brk_rolldown_std_utils" -version = "0.5.1" +version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ade8f44d7f6217501f7d78baa25d30c2a953d1455026933ec67ca178b8269fdf" +checksum = "c6b587f4eb33cec46b60e6678cb184d51150ef397462ab420e6f5fe7d677a124" dependencies = [ "regex", ] [[package]] name = "brk_rolldown_tracing" -version = "0.5.1" +version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9feb3e6d9066865a18186e6791de0061910cea10ca89cdae4cc3737db62323ab" +checksum = "9aa971b9b87999cd83a958068b1dee1c404ae1528ec1786ef991b9f84e7c281f" dependencies = [ "tracing", "tracing-chrome", @@ -1160,9 +1175,9 @@ dependencies = [ [[package]] name = "brk_rolldown_utils" -version = "0.5.1" +version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "115e79f091452c0dc535d17c81342e7bc227e135c7d8c21e574aaa209fee24eb" +checksum = "6b24794f5e7e65d4c126ae6cc6e18286f4363c2df318a2a06256cdf8d660f789" dependencies = [ "anyhow", "arcstr", @@ -1253,9 +1268,9 @@ dependencies = [ [[package]] name = "brk_string_wizard" -version = "0.5.1" +version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6fd91a55e6cb47ded6db1e618443e0ce29ecb31b8f1196dcf526a738cfd24a17" +checksum = "f7b2328e2cf4d22ff7c7a620ed887cd7e2fc0c81546fd03448d8e261ff00d905" dependencies = [ "memchr", "oxc_index", @@ -2773,9 +2788,9 @@ dependencies = [ [[package]] name = "itoa" -version = "1.0.16" +version = "1.0.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ee5b5339afb4c41626dde77b7a611bd4f2c202b897852b4bcf5d03eddc61010" +checksum = "92ecc6618181def0457392ccd0ee51198e065e016d1d527a7ac1b6dc7c1f09d2" [[package]] name = "jiff" @@ -2936,13 +2951,13 @@ dependencies = [ [[package]] name = "libredox" -version = "0.1.11" +version = "0.1.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "df15f6eac291ed1cf25865b1ee60399f57e7c227e7f51bdbd4c5270396a9ed50" +checksum = "3d0b95e02c851351f877147b7deea7b1afb1df71b63aa5f8270716e0c5720616" dependencies = [ "bitflags 2.10.0", "libc", - "redox_syscall 0.6.0", + "redox_syscall 0.7.0", ] [[package]] @@ -3260,6 +3275,25 @@ dependencies = [ "objc2-encode", ] +[[package]] +name = "objc2-core-foundation" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2a180dd8642fa45cdb7dd721cd4c11b1cadd4929ce112ebd8b9f5803cc79d536" +dependencies = [ + "bitflags 2.10.0", +] + +[[package]] +name = "objc2-core-services" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "583300ad934cba24ff5292aee751ecc070f7ca6b39a574cc21b7b5e588e06a0b" +dependencies = [ + "libc", + "objc2-core-foundation", +] + [[package]] name = "objc2-encode" version = "4.1.0" @@ -3307,9 +3341,9 @@ checksum = "9c6901729fa79e91a0913333229e9ca5dc725089d1c363b2f4b4760709dc4a52" [[package]] name = "oxc" -version = "0.101.0" +version = "0.103.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a84dd7448a9e9c8b7d5a3af20d1a66ef5516dc3a575d7cfcf291736bcd2d733f" +checksum = "0cbd3721f31187ec4f01caee2f772209987710f512ac8aab3a1fbcef9669220a" dependencies = [ "oxc_allocator", "oxc_ast", @@ -3373,9 +3407,9 @@ dependencies = [ [[package]] name = "oxc_allocator" -version = "0.101.0" +version = "0.103.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5b360908629f56d1b18f60e0aa5a70122fb61e33543078fafbe565edb759d77f" +checksum = "70809b2ee0d82d38e0a145ae4c46c8384f1342ebb7be8503c1cde4d7ff9c9b8b" dependencies = [ "allocator-api2", "bumpalo", @@ -3388,9 +3422,9 @@ dependencies = [ [[package]] name = "oxc_ast" -version = "0.101.0" +version = "0.103.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "89e58ea2b49f8940307bb2d012ca0d2a744f6d98e9f96fc87b0a89c8578d57bf" +checksum = "70e993b5f9f6ec07b5a52375564fcb60a13b9fc60b4260380c022e7eb09381d2" dependencies = [ "bitflags 2.10.0", "oxc_allocator", @@ -3405,9 +3439,9 @@ dependencies = [ [[package]] name = "oxc_ast_macros" -version = "0.101.0" +version = "0.103.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "91c6039e721360dd47a101f7ae1e183f90b3c812cd4ed52e0221d791f70d184a" +checksum = "efae81973774d77eed1195a965d439c2f6812fa69393c68543bdb8fb7c0807de" dependencies = [ "phf", "proc-macro2", @@ -3417,9 +3451,9 @@ dependencies = [ [[package]] name = "oxc_ast_visit" -version = "0.101.0" +version = "0.103.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "11ecdea97ef3f0e7ee7d9b0d29327040acfe30c8c4593bdf4e0bc8fea0d75899" +checksum = "220baf0e5b21585787a08683db46898f5b58aaf18cd2f6e2d3d777ef4931fb22" dependencies = [ "oxc_allocator", "oxc_ast", @@ -3429,9 +3463,9 @@ dependencies = [ [[package]] name = "oxc_cfg" -version = "0.101.0" +version = "0.103.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "99efc2ae6e378cb26414e2ce7bad8d909a978753ffd46484a5b4a359c40dca0d" +checksum = "90dfb7c008174ab87bc12f2c43f99ef4a4ea0ca2bc61985658464febea68aed5" dependencies = [ "bitflags 2.10.0", "itertools 0.14.0", @@ -3443,9 +3477,9 @@ dependencies = [ [[package]] name = "oxc_codegen" -version = "0.101.0" +version = "0.103.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0de87539d889ed530f5811c5c17af31b3346e3b709c1fd6b9e2a5e00c4bac934" +checksum = "05c0e632ae6cd9d99543006d4dacb9f35ef43c247828918273156a438740578a" dependencies = [ "bitflags 2.10.0", "cow-utils", @@ -3464,9 +3498,9 @@ dependencies = [ [[package]] name = "oxc_compat" -version = "0.101.0" +version = "0.103.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7319a884684197f2a524231d05d25df2a0155c49a9dc6400980410c746779731" +checksum = "c065e71c19a1cbf820a952336120baa7edf6c0185e9935e86dc216e78d411718" dependencies = [ "cow-utils", "oxc-browserslist", @@ -3477,18 +3511,18 @@ dependencies = [ [[package]] name = "oxc_data_structures" -version = "0.101.0" +version = "0.103.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e0e95d9a0caba623cc004b9d420951a7d490a0cd172912ac776df12a51063353" +checksum = "47e8d129933ab203ea42d061f4ea5cf24aea7981bbccb3393bd86840a0414e4f" dependencies = [ "ropey", ] [[package]] name = "oxc_diagnostics" -version = "0.101.0" +version = "0.103.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cbf468b479ee17919e8bc11c31c405f059762abb78c90cb0931f5e94d7eac30b" +checksum = "e8508cdba30d0df947d31577c394b6afacfb7fca376c347b74246c0b552bf1c1" dependencies = [ "cow-utils", "oxc-miette", @@ -3497,9 +3531,9 @@ dependencies = [ [[package]] name = "oxc_ecmascript" -version = "0.101.0" +version = "0.103.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c5af7a036c4e13de3f0b6bfa7bcf22326c3e1da32210b65ec114c96e17e8d77d" +checksum = "bb338ab6d3354919f0125a70f618d72f961777a724aa97eef963b9ccfbf90121" dependencies = [ "cow-utils", "num-bigint", @@ -3512,9 +3546,9 @@ dependencies = [ [[package]] name = "oxc_estree" -version = "0.101.0" +version = "0.103.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bb9bac2f3fd66cdb7b538e551d9d72b01ceb9009244c25d370684dce01301114" +checksum = "1745278e805cf12e56e789dd7202639ba8e662b18dab390719ea295eddcb7ea2" dependencies = [ "dragonbox_ecma", "itoa", @@ -3534,9 +3568,9 @@ dependencies = [ [[package]] name = "oxc_isolated_declarations" -version = "0.101.0" +version = "0.103.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a645efa67f8bf7c68cefc35766a36a5136753b0cbf5237abc8c6206970348eca" +checksum = "0a0e8f15425926ad00beec1a2464b90d96ed37c7ff818a59089aa1a0288dfaec" dependencies = [ "bitflags 2.10.0", "oxc_allocator", @@ -3551,9 +3585,9 @@ dependencies = [ [[package]] name = "oxc_mangler" -version = "0.101.0" +version = "0.103.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4f944d504ae8d359db077de7c1869691da098bce01155639fdf324d8df9de857" +checksum = "3e1771f55ff388d5b29d3bda7d8415ec0c9c900a15959960192efaa9250ba6e4" dependencies = [ "itertools 0.14.0", "oxc_allocator", @@ -3568,9 +3602,9 @@ dependencies = [ [[package]] name = "oxc_minifier" -version = "0.101.0" +version = "0.103.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0995fd7b64ca4433ce12c4b3701574c1fb494c2a879442096d18cdbbe945547f" +checksum = "271b0d78245d1c0288dc5cb85ff4b18e4abcd1cbc57631e5def8f8d4440e9e3a" dependencies = [ "cow-utils", "oxc_allocator", @@ -3593,9 +3627,9 @@ dependencies = [ [[package]] name = "oxc_parser" -version = "0.101.0" +version = "0.103.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "12077275a0b65791602bbd398bc83253328e8ab656a2218a7d6bb571787551f9" +checksum = "a43bfbde680f7e55fb879f56901a6f65d8450fc3f16b7c924e4f4b3f2629929a" dependencies = [ "bitflags 2.10.0", "cow-utils", @@ -3616,9 +3650,9 @@ dependencies = [ [[package]] name = "oxc_regular_expression" -version = "0.101.0" +version = "0.103.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b02e8106836d7128a3fac86db05409910c3d96fe46d465cd071877a12802d5b3" +checksum = "9076c980a2795d009b7509677dfbf765945b4aeec44bf7f796a4084a6e02e2ce" dependencies = [ "bitflags 2.10.0", "oxc_allocator", @@ -3660,9 +3694,9 @@ dependencies = [ [[package]] name = "oxc_semantic" -version = "0.101.0" +version = "0.103.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f474c2a181362369f44a0ffe3bc780b286602c920a8ec166f12d7818664b391a" +checksum = "5e7532ec0fc54f0ee864ed144634bb1ca5f093646d60a0db53568acccc8470ff" dependencies = [ "itertools 0.14.0", "oxc_allocator", @@ -3695,9 +3729,9 @@ dependencies = [ [[package]] name = "oxc_span" -version = "0.101.0" +version = "0.103.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4106c63cc7e72fc8b34943b2b85ce1f5350cdd5c7ad70757d1691ac0ebded943" +checksum = "e79a2ab3c8f38813e24ac5d853e66c352254ed8ccd6fc773a9c666266644e6ea" dependencies = [ "compact_str", "oxc-miette", @@ -3709,9 +3743,9 @@ dependencies = [ [[package]] name = "oxc_syntax" -version = "0.101.0" +version = "0.103.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "25aa1d1b60990a801ec16f7f984ea148bfbcb330590aeabf3cf639537401ebca" +checksum = "659c494d5979c1aa6f1c4c2f8baf98ec7a97b4dff31d580393494302bffc9278" dependencies = [ "bitflags 2.10.0", "cow-utils", @@ -3730,9 +3764,9 @@ dependencies = [ [[package]] name = "oxc_transformer" -version = "0.101.0" +version = "0.103.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "baed8f7ad713ba560917e3b6e0a8fb07d2ad98df08cdfcaed5f98ba7fe3dc80c" +checksum = "e0dfa6ec657feadd689b4a400cc0a7f46d9c656d88b5bc7590070ffee1f37368" dependencies = [ "base64 0.22.1", "compact_str", @@ -3759,9 +3793,9 @@ dependencies = [ [[package]] name = "oxc_transformer_plugins" -version = "0.101.0" +version = "0.103.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "34b1b2873f1d50d88d28d521bfe8572b40ea3cd88f8d46e59896bed97b342fe7" +checksum = "d2710a94a9829b9b22f7eb13675c63cb3227298fad675903ed7d56e6ab387305" dependencies = [ "cow-utils", "itoa", @@ -3781,9 +3815,9 @@ dependencies = [ [[package]] name = "oxc_traverse" -version = "0.101.0" +version = "0.103.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "634336ede7a5007a8e3ef629cd3c224c7ccbba5d3a9e332e69250e4fb853456b" +checksum = "c77bbade9aae708a8bafcfe7e0d17a7d53a36f91af9a3aeac7e9ef7c18d89f0c" dependencies = [ "itoa", "oxc_allocator", @@ -4100,9 +4134,9 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.103" +version = "1.0.104" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5ee95bc4ef87b8d5ba32e8b7714ccc834865276eab0aed5c9958d00ec45f49e8" +checksum = "9695f8df41bb4f3d222c95a67532365f569318332d03d5f3f67f37b20e6ebdf0" dependencies = [ "unicode-ident", ] @@ -4232,7 +4266,9 @@ dependencies = [ [[package]] name = "rawdb" -version = "0.4.6" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "48974be79d0854eb9ae7a0931882bc84052bc9c0be10b39a324aab0be975e2d9" dependencies = [ "libc", "log", @@ -4274,9 +4310,9 @@ dependencies = [ [[package]] name = "redox_syscall" -version = "0.6.0" +version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ec96166dafa0886eb81fe1c0a388bece180fbef2135f97c1e2cf8302e74b43b5" +checksum = "49f3fe0889e69e2ae9e41f4d6c4c0181701d00e4697b356fb1f74173a5e0ee27" dependencies = [ "bitflags 2.10.0", ] @@ -4386,15 +4422,17 @@ dependencies = [ [[package]] name = "rolldown-notify" -version = "9.1.1" +version = "10.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "681ee850deb4f1f1c47e024cb518fa093909cd0ec431d9c390e53d8e6a5c4971" +checksum = "e8bf250d410b79487a6d054e6bd16ec08dddd2998f5f5e6291867a35066cfc37" dependencies = [ "bitflags 2.10.0", "inotify", "kqueue", "libc", "mio", + "objc2-core-foundation", + "objc2-core-services", "rolldown-notify-types", "tracing", "walkdir", @@ -4481,9 +4519,9 @@ checksum = "b39cdef0fa800fc44525c84ccb54a029961a8215f9619753635a9c0d2538d46d" [[package]] name = "ryu" -version = "1.0.21" +version = "1.0.22" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "62049b2877bf12821e8f9ad256ee38fdc31db7387ec2d3b3f403024de2034aea" +checksum = "a50f4cf475b65d88e057964e0e9bb1f0aa9bbb2036dc65c64596b42932536984" [[package]] name = "same-file" @@ -4639,9 +4677,9 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.147" +version = "1.0.148" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6af14725505314343e673e9ecb7cd7e8a36aa9791eb936235a3567cc31447ae4" +checksum = "3084b546a1dd6289475996f182a22aba973866ea8e8b02c51d9f46b1336a22da" dependencies = [ "indexmap", "itoa", @@ -5422,7 +5460,9 @@ checksum = "8f54a172d0620933a27a4360d3db3e2ae0dd6cceae9730751a036bbf182c4b23" [[package]] name = "vecdb" -version = "0.4.6" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c9bb3a189dc833e0e1eeb4816230f4478412fbddaaeffec56cbfd3d7f778a25d" dependencies = [ "ctrlc", "log", @@ -5430,7 +5470,6 @@ dependencies = [ "parking_lot", "pco", "rawdb", - "schemars", "serde", "serde_json", "thiserror 2.0.17", @@ -5441,7 +5480,9 @@ dependencies = [ [[package]] name = "vecdb_derive" -version = "0.4.6" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "daf3feda7d28c275661d640ad454830ad3ed6ccdaa297d3ec24faa06741142e3" dependencies = [ "quote", "syn 2.0.111", @@ -6035,9 +6076,9 @@ checksum = "40990edd51aae2c2b6907af74ffb635029d5788228222c4bb811e9351c0caad3" [[package]] name = "zmij" -version = "0.1.9" +version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d0095ecd462946aa3927d9297b63ef82fb9a5316d7a37d134eeb36e58228615a" +checksum = "e6d6085d62852e35540689d1f97ad663e3971fc19cf5eceab364d62c646ea167" [[package]] name = "zopfli" diff --git a/Cargo.toml b/Cargo.toml index 47dadc268..5b3785c86 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -78,11 +78,11 @@ schemars = "1.2.0" serde = "1.0.228" serde_bytes = "0.11.19" serde_derive = "1.0.228" -serde_json = { version = "1.0.147", features = ["float_roundtrip"] } +serde_json = { version = "1.0.148", features = ["float_roundtrip"] } smallvec = "1.15.1" tokio = { version = "1.48.0", features = ["rt-multi-thread"] } -# vecdb = { version = "0.4.6", features = ["derive", "serde_json", "pco"] } -vecdb = { path = "../anydb/crates/vecdb", features = ["derive", "serde_json", "pco", "schemars"] } +vecdb = { version = "0.5.0", features = ["derive", "serde_json", "pco"] } +# vecdb = { path = "../anydb/crates/vecdb", features = ["derive", "serde_json", "pco", "schemars"] } # vecdb = { git = "https://github.com/anydb-rs/anydb", features = ["derive", "serde_json", "pco"] } [workspace.metadata.release] diff --git a/crates/brk_bundler/Cargo.toml b/crates/brk_bundler/Cargo.toml index 379fae737..1bf78686a 100644 --- a/crates/brk_bundler/Cargo.toml +++ b/crates/brk_bundler/Cargo.toml @@ -12,6 +12,6 @@ build = "build.rs" log = { workspace = true } notify = "8.2.0" # rolldown = { path = "../../../rolldown/crates/rolldown", package = "brk_rolldown" } -rolldown = { version = "0.5.1", package = "brk_rolldown" } +rolldown = { version = "0.6.0", package = "brk_rolldown" } sugar_path = "1.2.1" tokio = { workspace = true } diff --git a/crates/brk_bundler/src/lib.rs b/crates/brk_bundler/src/lib.rs index b3f5a9c3e..8a733ce16 100644 --- a/crates/brk_bundler/src/lib.rs +++ b/crates/brk_bundler/src/lib.rs @@ -3,17 +3,15 @@ use std::{ fs, io, path::{Path, PathBuf}, - sync::Arc, }; use log::error; use notify::{EventKind, RecursiveMode, Watcher}; use rolldown::{ - Bundler, BundlerOptions, InlineConstConfig, InlineConstMode, InlineConstOption, + Bundler, BundlerConfig, BundlerOptions, InlineConstConfig, InlineConstMode, InlineConstOption, OptimizationOption, RawMinifyOptions, SourceMapType, }; use sugar_path::SugarPath; -use tokio::sync::Mutex; const VERSION: &str = env!("CARGO_PKG_VERSION"); @@ -59,7 +57,7 @@ pub async fn bundle( // dbg!(BundlerOptions::default()); - let mut bundler = Bundler::new(BundlerOptions { + let bundler_options = BundlerOptions { input: Some(vec![format!("./{source_folder}/scripts/entry.js").into()]), dir: Some("./dist/scripts".to_string()), cwd: Some(absolute_websites_path), @@ -88,8 +86,9 @@ pub async fn bundle( ..Default::default() }), ..Default::default() - }) - .unwrap(); + }; + + let mut bundler = Bundler::new(bundler_options.clone()).unwrap(); if let Err(error) = bundler.write().await { error!("{error:?}"); @@ -170,7 +169,8 @@ pub async fn bundle( .watch(&absolute_modules_path_clone, RecursiveMode::Recursive) .unwrap(); - let watcher = rolldown::Watcher::new(vec![Arc::new(Mutex::new(bundler))], None).unwrap(); + let config = BundlerConfig::new(bundler_options, vec![]); + let watcher = rolldown::Watcher::new(config, None).unwrap(); watcher.start().await; }); diff --git a/crates/brk_computer/src/blks.rs b/crates/brk_computer/src/blks.rs index 3320ab19c..67d905f81 100644 --- a/crates/brk_computer/src/blks.rs +++ b/crates/brk_computer/src/blks.rs @@ -12,6 +12,8 @@ use vecdb::{ use super::Indexes; +pub const DB_NAME: &str = "blks"; + #[derive(Clone, Traversable)] pub struct Vecs { db: Database, @@ -22,7 +24,7 @@ pub struct Vecs { impl Vecs { pub fn forced_import(parent_path: &Path, parent_version: Version) -> Result { - let db = Database::open(&parent_path.join("blks"))?; + let db = Database::open(&parent_path.join(DB_NAME))?; db.set_min_len(PAGE_SIZE * 1_000_000)?; let version = parent_version + Version::ZERO; @@ -39,7 +41,6 @@ impl Vecs { .flat_map(|v| v.region_names()) .collect(), )?; - this.db.compact()?; Ok(this) @@ -70,7 +71,8 @@ impl Vecs { let Some(min_height) = indexer .vecs - .tx.txindex_to_height + .tx + .txindex_to_height .iter()? .get(min_txindex) .map(|h| h.min(starting_indexes.height)) diff --git a/crates/brk_computer/src/chain/import.rs b/crates/brk_computer/src/chain/import.rs index 633607802..79a6c880e 100644 --- a/crates/brk_computer/src/chain/import.rs +++ b/crates/brk_computer/src/chain/import.rs @@ -31,7 +31,7 @@ impl Vecs { indexes: &indexes::Vecs, price: Option<&price::Vecs>, ) -> Result { - let db = Database::open(&parent_path.join("chain"))?; + let db = Database::open(&parent_path.join(super::DB_NAME))?; db.set_min_len(PAGE_SIZE * 50_000_000)?; let version = parent_version + Version::ZERO; @@ -463,7 +463,6 @@ impl Vecs { .flat_map(|v| v.region_names()) .collect(), )?; - this.db.compact()?; Ok(this) diff --git a/crates/brk_computer/src/chain/mod.rs b/crates/brk_computer/src/chain/mod.rs index 2688d8417..3afebb6d5 100644 --- a/crates/brk_computer/src/chain/mod.rs +++ b/crates/brk_computer/src/chain/mod.rs @@ -14,6 +14,8 @@ use crate::grouped::{ ComputedVecsFromHeight, ComputedVecsFromTxindex, }; +pub const DB_NAME: &str = "chain"; + pub(crate) const TARGET_BLOCKS_PER_DAY_F64: f64 = 144.0; pub(crate) const TARGET_BLOCKS_PER_DAY_F32: f32 = 144.0; pub(crate) const TARGET_BLOCKS_PER_DAY: u64 = 144; diff --git a/crates/brk_computer/src/cointime.rs b/crates/brk_computer/src/cointime.rs index b6ffb84ab..65f0568bc 100644 --- a/crates/brk_computer/src/cointime.rs +++ b/crates/brk_computer/src/cointime.rs @@ -16,6 +16,8 @@ use super::{ indexes, price, stateful, }; +pub const DB_NAME: &str = "cointime"; + #[derive(Clone, Traversable)] pub struct Vecs { db: Database, @@ -56,7 +58,7 @@ impl Vecs { indexes: &indexes::Vecs, price: Option<&price::Vecs>, ) -> Result { - let db = Database::open(&parent_path.join("cointime"))?; + let db = Database::open(&parent_path.join(DB_NAME))?; db.set_min_len(PAGE_SIZE * 1_000_000)?; let compute_dollars = price.is_some(); @@ -174,7 +176,6 @@ impl Vecs { .flat_map(|v| v.region_names()) .collect(), )?; - this.db.compact()?; Ok(this) diff --git a/crates/brk_computer/src/constants.rs b/crates/brk_computer/src/constants.rs index ac28518bb..46088b50d 100644 --- a/crates/brk_computer/src/constants.rs +++ b/crates/brk_computer/src/constants.rs @@ -13,6 +13,8 @@ use super::{ indexes, }; +pub const DB_NAME: &str = "constants"; + #[derive(Clone, Traversable)] pub struct Vecs { db: Database, @@ -39,7 +41,7 @@ impl Vecs { parent_version: Version, indexes: &indexes::Vecs, ) -> Result { - let db = Database::open(&parent_path.join("constants"))?; + let db = Database::open(&parent_path.join(DB_NAME))?; db.set_min_len(PAGE_SIZE * 1_000_000)?; let version = parent_version + Version::ZERO; @@ -166,7 +168,6 @@ impl Vecs { .flat_map(|v| v.region_names()) .collect(), )?; - this.db.compact()?; Ok(this) diff --git a/crates/brk_computer/src/fetched.rs b/crates/brk_computer/src/fetched.rs index a48db36b4..0624718a5 100644 --- a/crates/brk_computer/src/fetched.rs +++ b/crates/brk_computer/src/fetched.rs @@ -48,7 +48,6 @@ impl Vecs { .flat_map(|v| v.region_names()) .collect(), )?; - this.db.compact()?; Ok(this) diff --git a/crates/brk_computer/src/indexes.rs b/crates/brk_computer/src/indexes.rs index 84b819ca9..cfd89efea 100644 --- a/crates/brk_computer/src/indexes.rs +++ b/crates/brk_computer/src/indexes.rs @@ -18,6 +18,7 @@ use vecdb::{ }; const VERSION: Version = Version::ZERO; +pub const DB_NAME: &str = "indexes"; #[derive(Clone, Traversable)] pub struct Vecs { @@ -101,7 +102,7 @@ impl Vecs { parent_version: Version, indexer: &Indexer, ) -> Result { - let db = Database::open(&parent.join("indexes"))?; + let db = Database::open(&parent.join(DB_NAME))?; db.set_min_len(PAGE_SIZE * 10_000_000)?; let version = parent_version + VERSION; @@ -222,7 +223,6 @@ impl Vecs { .flat_map(|v| v.region_names()) .collect(), )?; - this.db.compact()?; Ok(this) diff --git a/crates/brk_computer/src/lib.rs b/crates/brk_computer/src/lib.rs index 103f6542c..627999c38 100644 --- a/crates/brk_computer/src/lib.rs +++ b/crates/brk_computer/src/lib.rs @@ -1,6 +1,6 @@ #![doc = include_str!("../README.md")] -use std::{path::Path, thread, time::Instant}; +use std::{fs, path::Path, thread, time::Instant}; use brk_error::Result; use brk_fetcher::Fetcher; @@ -147,7 +147,7 @@ impl Computer { info!("Total import time: {:?}", import_start.elapsed()); - Ok(Self { + let this = Self { constants, market, stateful, @@ -160,7 +160,50 @@ impl Computer { fetched, price, txouts, - }) + }; + + Self::retain_databases(&computed_path)?; + + Ok(this) + } + + /// Removes database folders that are no longer in use. + fn retain_databases(computed_path: &Path) -> Result<()> { + const EXPECTED_DBS: &[&str] = &[ + blks::DB_NAME, + chain::DB_NAME, + cointime::DB_NAME, + constants::DB_NAME, + indexes::DB_NAME, + market::DB_NAME, + pools::DB_NAME, + price::DB_NAME, + stateful::DB_NAME, + txins::DB_NAME, + txouts::DB_NAME, + ]; + + if !computed_path.exists() { + return Ok(()); + } + + for entry in fs::read_dir(computed_path)? { + let entry = entry?; + let file_type = entry.file_type()?; + + if !file_type.is_dir() { + continue; + } + + if let Some(name) = entry.file_name().to_str() { + if !EXPECTED_DBS.contains(&name) { + info!("Removing obsolete database folder: {}", name); + fs::remove_dir_all(entry.path())?; + } + } + } + + Ok(()) } pub fn compute( diff --git a/crates/brk_computer/src/market/import.rs b/crates/brk_computer/src/market/import.rs index ceea5380c..d31c00459 100644 --- a/crates/brk_computer/src/market/import.rs +++ b/crates/brk_computer/src/market/import.rs @@ -21,7 +21,7 @@ impl Vecs { parent_version: Version, indexes: &indexes::Vecs, ) -> Result { - let db = Database::open(&parent_path.join("market"))?; + let db = Database::open(&parent_path.join(super::DB_NAME))?; db.set_min_len(PAGE_SIZE * 1_000_000)?; let version = parent_version + Version::ZERO; @@ -32,20 +32,49 @@ impl Vecs { macro_rules! computed_di { ($name:expr) => { - ComputedVecsFromDateIndex::forced_import(&db, $name, Source::Compute, version + v0, indexes, last.clone())? + ComputedVecsFromDateIndex::forced_import( + &db, + $name, + Source::Compute, + version + v0, + indexes, + last.clone(), + )? }; ($name:expr, $v:expr) => { - ComputedVecsFromDateIndex::forced_import(&db, $name, Source::Compute, version + $v, indexes, last.clone())? + ComputedVecsFromDateIndex::forced_import( + &db, + $name, + Source::Compute, + version + $v, + indexes, + last.clone(), + )? }; } macro_rules! ratio_di { ($name:expr) => { - ComputedRatioVecsFromDateIndex::forced_import(&db, $name, Source::Compute, version + v0, indexes, true)? + ComputedRatioVecsFromDateIndex::forced_import( + &db, + $name, + Source::Compute, + version + v0, + indexes, + true, + )? }; } macro_rules! sd_di { ($name:expr, $window:expr, $v:expr) => { - ComputedStandardDeviationVecsFromDateIndex::forced_import(&db, $name, $window, Source::Compute, version + $v, indexes, StandardDeviationVecsOptions::default())? + ComputedStandardDeviationVecsFromDateIndex::forced_import( + &db, + $name, + $window, + Source::Compute, + version + $v, + indexes, + StandardDeviationVecsOptions::default(), + )? }; } macro_rules! eager_h { @@ -239,7 +268,6 @@ impl Vecs { .flat_map(|v| v.region_names()) .collect(), )?; - this.db.compact()?; Ok(this) diff --git a/crates/brk_computer/src/market/mod.rs b/crates/brk_computer/src/market/mod.rs index 4878c6936..e21dc3a1a 100644 --- a/crates/brk_computer/src/market/mod.rs +++ b/crates/brk_computer/src/market/mod.rs @@ -10,6 +10,8 @@ use crate::grouped::{ ComputedVecsFromDateIndex, }; +pub const DB_NAME: &str = "market"; + #[derive(Clone, Traversable)] pub struct Vecs { pub(crate) db: Database, diff --git a/crates/brk_computer/src/pools/mod.rs b/crates/brk_computer/src/pools/mod.rs index 980244031..4a3824027 100644 --- a/crates/brk_computer/src/pools/mod.rs +++ b/crates/brk_computer/src/pools/mod.rs @@ -19,6 +19,8 @@ use crate::{ price, }; +pub const DB_NAME: &str = "pools"; + #[derive(Clone, Traversable)] pub struct Vecs { db: Database, @@ -35,7 +37,7 @@ impl Vecs { indexes: &indexes::Vecs, price: Option<&price::Vecs>, ) -> Result { - let db = Database::open(&parent_path.join("pools"))?; + let db = Database::open(&parent_path.join(DB_NAME))?; db.set_min_len(PAGE_SIZE * 1_000_000)?; let pools = pools(); @@ -66,7 +68,6 @@ impl Vecs { .flat_map(|v| v.region_names()) .collect(), )?; - this.db.compact()?; Ok(this) @@ -129,8 +130,7 @@ impl Vecs { let mut txindex_to_output_count_iter = indexes.txindex_to_output_count.iter(); let mut txoutindex_to_outputtype_iter = indexer.vecs.txout.txoutindex_to_outputtype.iter()?; - let mut txoutindex_to_typeindex_iter = - indexer.vecs.txout.txoutindex_to_typeindex.iter()?; + let mut txoutindex_to_typeindex_iter = indexer.vecs.txout.txoutindex_to_typeindex.iter()?; let mut p2pk65addressindex_to_p2pk65bytes_iter = indexer .vecs .address diff --git a/crates/brk_computer/src/price.rs b/crates/brk_computer/src/price.rs index 0d50694d4..fd29d16ad 100644 --- a/crates/brk_computer/src/price.rs +++ b/crates/brk_computer/src/price.rs @@ -16,6 +16,8 @@ use super::{ indexes, }; +pub const DB_NAME: &str = "price"; + #[derive(Clone, Traversable)] pub struct Vecs { db: Database, @@ -71,26 +73,44 @@ const VERSION_IN_SATS: Version = Version::ZERO; impl Vecs { pub fn forced_import(parent: &Path, version: Version, indexes: &indexes::Vecs) -> Result { - let db = Database::open(&parent.join("price"))?; + let db = Database::open(&parent.join(DB_NAME))?; db.set_min_len(PAGE_SIZE * 1_000_000)?; let v = version + VERSION; let v_sats = version + VERSION + VERSION_IN_SATS; macro_rules! eager { - ($name:expr) => { EagerVec::forced_import(&db, $name, v)? }; + ($name:expr) => { + EagerVec::forced_import(&db, $name, v)? + }; } macro_rules! eager_sats { - ($name:expr) => { EagerVec::forced_import(&db, $name, v_sats)? }; + ($name:expr) => { + EagerVec::forced_import(&db, $name, v_sats)? + }; } macro_rules! computed_di { ($name:expr, $opts:expr) => { - ComputedVecsFromDateIndex::forced_import(&db, $name, Source::Compute, v, indexes, $opts)? + ComputedVecsFromDateIndex::forced_import( + &db, + $name, + Source::Compute, + v, + indexes, + $opts, + )? }; } macro_rules! computed_di_sats { ($name:expr, $opts:expr) => { - ComputedVecsFromDateIndex::forced_import(&db, $name, Source::Compute, v_sats, indexes, $opts)? + ComputedVecsFromDateIndex::forced_import( + &db, + $name, + Source::Compute, + v_sats, + indexes, + $opts, + )? }; } macro_rules! computed_h { @@ -162,7 +182,6 @@ impl Vecs { .flat_map(|v| v.region_names()) .collect(), )?; - this.db.compact()?; Ok(this) diff --git a/crates/brk_computer/src/stateful/metrics/unrealized.rs b/crates/brk_computer/src/stateful/metrics/unrealized.rs deleted file mode 100644 index f4b82ca58..000000000 --- a/crates/brk_computer/src/stateful/metrics/unrealized.rs +++ /dev/null @@ -1,427 +0,0 @@ -use brk_error::Result; -use brk_traversable::Traversable; -use brk_types::{DateIndex, Dollars, Height, Sats, Version}; -use rayon::prelude::*; -use vecdb::{ - AnyStoredVec, EagerVec, Exit, GenericStoredVec, ImportableVec, IterableCloneableVec, PcoVec, -}; - -use crate::{ - Indexes, - grouped::{ - ComputedHeightValueVecs, ComputedValueVecsFromDateIndex, ComputedVecsFromDateIndex, Source, - VecBuilderOptions, - }, - stateful::states::UnrealizedState, -}; - -use super::ImportConfig; - -/// Unrealized profit/loss metrics. -#[derive(Clone, Traversable)] -pub struct UnrealizedMetrics { - // === Supply in Profit/Loss === - pub height_to_supply_in_profit: EagerVec>, - pub indexes_to_supply_in_profit: ComputedValueVecsFromDateIndex, - pub height_to_supply_in_loss: EagerVec>, - pub indexes_to_supply_in_loss: ComputedValueVecsFromDateIndex, - pub dateindex_to_supply_in_profit: EagerVec>, - pub dateindex_to_supply_in_loss: EagerVec>, - pub height_to_supply_in_profit_value: ComputedHeightValueVecs, - pub height_to_supply_in_loss_value: ComputedHeightValueVecs, - - // === Unrealized Profit/Loss === - pub height_to_unrealized_profit: EagerVec>, - pub indexes_to_unrealized_profit: ComputedVecsFromDateIndex, - pub height_to_unrealized_loss: EagerVec>, - pub indexes_to_unrealized_loss: ComputedVecsFromDateIndex, - pub dateindex_to_unrealized_profit: EagerVec>, - pub dateindex_to_unrealized_loss: EagerVec>, - - // === Negated and Net === - pub height_to_neg_unrealized_loss: EagerVec>, - pub indexes_to_neg_unrealized_loss: ComputedVecsFromDateIndex, - pub height_to_net_unrealized_pnl: EagerVec>, - pub indexes_to_net_unrealized_pnl: ComputedVecsFromDateIndex, - pub height_to_total_unrealized_pnl: EagerVec>, - pub indexes_to_total_unrealized_pnl: ComputedVecsFromDateIndex, -} - -impl UnrealizedMetrics { - /// Import unrealized metrics from database. - pub fn forced_import(cfg: &ImportConfig) -> Result { - let v0 = Version::ZERO; - let compute_dollars = cfg.compute_dollars(); - let last = VecBuilderOptions::default().add_last(); - - // Pre-import the dateindex vecs that are used as sources - let dateindex_to_supply_in_profit = - EagerVec::forced_import(cfg.db, &cfg.name("supply_in_profit"), cfg.version + v0)?; - let dateindex_to_supply_in_loss = - EagerVec::forced_import(cfg.db, &cfg.name("supply_in_loss"), cfg.version + v0)?; - let dateindex_to_unrealized_profit = - EagerVec::forced_import(cfg.db, &cfg.name("unrealized_profit"), cfg.version + v0)?; - let dateindex_to_unrealized_loss = - EagerVec::forced_import(cfg.db, &cfg.name("unrealized_loss"), cfg.version + v0)?; - - Ok(Self { - // === Supply in Profit/Loss === - height_to_supply_in_profit: EagerVec::forced_import( - cfg.db, - &cfg.name("supply_in_profit"), - cfg.version + v0, - )?, - indexes_to_supply_in_profit: ComputedValueVecsFromDateIndex::forced_import( - cfg.db, - &cfg.name("supply_in_profit"), - Source::Vec(dateindex_to_supply_in_profit.boxed_clone()), - cfg.version + v0, - last, - compute_dollars, - cfg.indexes, - )?, - height_to_supply_in_loss: EagerVec::forced_import( - cfg.db, - &cfg.name("supply_in_loss"), - cfg.version + v0, - )?, - indexes_to_supply_in_loss: ComputedValueVecsFromDateIndex::forced_import( - cfg.db, - &cfg.name("supply_in_loss"), - Source::Vec(dateindex_to_supply_in_loss.boxed_clone()), - cfg.version + v0, - last, - compute_dollars, - cfg.indexes, - )?, - dateindex_to_supply_in_profit, - dateindex_to_supply_in_loss, - height_to_supply_in_profit_value: ComputedHeightValueVecs::forced_import( - cfg.db, - &cfg.name("supply_in_profit"), - Source::None, - cfg.version + v0, - compute_dollars, - )?, - height_to_supply_in_loss_value: ComputedHeightValueVecs::forced_import( - cfg.db, - &cfg.name("supply_in_loss"), - Source::None, - cfg.version + v0, - compute_dollars, - )?, - - // === Unrealized Profit/Loss === - height_to_unrealized_profit: EagerVec::forced_import( - cfg.db, - &cfg.name("unrealized_profit"), - cfg.version + v0, - )?, - indexes_to_unrealized_profit: ComputedVecsFromDateIndex::forced_import( - cfg.db, - &cfg.name("unrealized_profit"), - Source::Vec(dateindex_to_unrealized_profit.boxed_clone()), - cfg.version + v0, - cfg.indexes, - last, - )?, - height_to_unrealized_loss: EagerVec::forced_import( - cfg.db, - &cfg.name("unrealized_loss"), - cfg.version + v0, - )?, - indexes_to_unrealized_loss: ComputedVecsFromDateIndex::forced_import( - cfg.db, - &cfg.name("unrealized_loss"), - Source::Vec(dateindex_to_unrealized_loss.boxed_clone()), - cfg.version + v0, - cfg.indexes, - last, - )?, - dateindex_to_unrealized_profit, - dateindex_to_unrealized_loss, - - // === Negated and Net === - height_to_neg_unrealized_loss: EagerVec::forced_import( - cfg.db, - &cfg.name("neg_unrealized_loss"), - cfg.version + v0, - )?, - indexes_to_neg_unrealized_loss: ComputedVecsFromDateIndex::forced_import( - cfg.db, - &cfg.name("neg_unrealized_loss"), - Source::Compute, - cfg.version + v0, - cfg.indexes, - last, - )?, - height_to_net_unrealized_pnl: EagerVec::forced_import( - cfg.db, - &cfg.name("net_unrealized_pnl"), - cfg.version + v0, - )?, - indexes_to_net_unrealized_pnl: ComputedVecsFromDateIndex::forced_import( - cfg.db, - &cfg.name("net_unrealized_pnl"), - Source::Compute, - cfg.version + v0, - cfg.indexes, - last, - )?, - height_to_total_unrealized_pnl: EagerVec::forced_import( - cfg.db, - &cfg.name("total_unrealized_pnl"), - cfg.version + v0, - )?, - indexes_to_total_unrealized_pnl: ComputedVecsFromDateIndex::forced_import( - cfg.db, - &cfg.name("total_unrealized_pnl"), - Source::Compute, - cfg.version + v0, - cfg.indexes, - last, - )?, - }) - } - - /// Push unrealized state values to height-indexed vectors. - pub fn truncate_push( - &mut self, - height: Height, - dateindex: Option, - height_state: &UnrealizedState, - date_state: Option<&UnrealizedState>, - ) -> Result<()> { - self.height_to_supply_in_profit - .truncate_push(height, height_state.supply_in_profit)?; - self.height_to_supply_in_loss - .truncate_push(height, height_state.supply_in_loss)?; - self.height_to_unrealized_profit - .truncate_push(height, height_state.unrealized_profit)?; - self.height_to_unrealized_loss - .truncate_push(height, height_state.unrealized_loss)?; - - if let (Some(dateindex), Some(date_state)) = (dateindex, date_state) { - self.dateindex_to_supply_in_profit - .truncate_push(dateindex, date_state.supply_in_profit)?; - self.dateindex_to_supply_in_loss - .truncate_push(dateindex, date_state.supply_in_loss)?; - self.dateindex_to_unrealized_profit - .truncate_push(dateindex, date_state.unrealized_profit)?; - self.dateindex_to_unrealized_loss - .truncate_push(dateindex, date_state.unrealized_loss)?; - } - - Ok(()) - } - - /// Write height-indexed vectors to disk. - pub fn write(&mut self) -> Result<()> { - self.height_to_supply_in_profit.write()?; - self.height_to_supply_in_loss.write()?; - self.height_to_unrealized_profit.write()?; - self.height_to_unrealized_loss.write()?; - self.dateindex_to_supply_in_profit.write()?; - self.dateindex_to_supply_in_loss.write()?; - self.dateindex_to_unrealized_profit.write()?; - self.dateindex_to_unrealized_loss.write()?; - Ok(()) - } - - /// Returns a parallel iterator over all vecs for parallel writing. - pub fn par_iter_mut(&mut self) -> impl ParallelIterator { - vec![ - &mut self.height_to_supply_in_profit as &mut dyn AnyStoredVec, - &mut self.height_to_supply_in_loss as &mut dyn AnyStoredVec, - &mut self.height_to_unrealized_profit as &mut dyn AnyStoredVec, - &mut self.height_to_unrealized_loss as &mut dyn AnyStoredVec, - &mut self.dateindex_to_supply_in_profit as &mut dyn AnyStoredVec, - &mut self.dateindex_to_supply_in_loss as &mut dyn AnyStoredVec, - &mut self.dateindex_to_unrealized_profit as &mut dyn AnyStoredVec, - &mut self.dateindex_to_unrealized_loss as &mut dyn AnyStoredVec, - ] - .into_par_iter() - } - - /// Compute aggregate values from separate cohorts. - pub fn compute_from_stateful( - &mut self, - starting_indexes: &Indexes, - others: &[&Self], - exit: &Exit, - ) -> Result<()> { - self.height_to_supply_in_profit.compute_sum_of_others( - starting_indexes.height, - &others - .iter() - .map(|v| &v.height_to_supply_in_profit) - .collect::>(), - exit, - )?; - self.height_to_supply_in_loss.compute_sum_of_others( - starting_indexes.height, - &others - .iter() - .map(|v| &v.height_to_supply_in_loss) - .collect::>(), - exit, - )?; - self.height_to_unrealized_profit.compute_sum_of_others( - starting_indexes.height, - &others - .iter() - .map(|v| &v.height_to_unrealized_profit) - .collect::>(), - exit, - )?; - self.height_to_unrealized_loss.compute_sum_of_others( - starting_indexes.height, - &others - .iter() - .map(|v| &v.height_to_unrealized_loss) - .collect::>(), - exit, - )?; - self.dateindex_to_supply_in_profit.compute_sum_of_others( - starting_indexes.dateindex, - &others - .iter() - .map(|v| &v.dateindex_to_supply_in_profit) - .collect::>(), - exit, - )?; - self.dateindex_to_supply_in_loss.compute_sum_of_others( - starting_indexes.dateindex, - &others - .iter() - .map(|v| &v.dateindex_to_supply_in_loss) - .collect::>(), - exit, - )?; - self.dateindex_to_unrealized_profit.compute_sum_of_others( - starting_indexes.dateindex, - &others - .iter() - .map(|v| &v.dateindex_to_unrealized_profit) - .collect::>(), - exit, - )?; - self.dateindex_to_unrealized_loss.compute_sum_of_others( - starting_indexes.dateindex, - &others - .iter() - .map(|v| &v.dateindex_to_unrealized_loss) - .collect::>(), - exit, - )?; - Ok(()) - } - - /// First phase of computed metrics. - pub fn compute_rest_part1( - &mut self, - price: Option<&crate::price::Vecs>, - starting_indexes: &Indexes, - exit: &Exit, - ) -> Result<()> { - // Compute supply value (bitcoin + dollars) from sats - self.height_to_supply_in_profit_value.compute_rest( - price, - starting_indexes, - exit, - Some(&self.height_to_supply_in_profit), - )?; - self.height_to_supply_in_loss_value.compute_rest( - price, - starting_indexes, - exit, - Some(&self.height_to_supply_in_loss), - )?; - - // Compute indexes from dateindex sources - self.indexes_to_supply_in_profit.compute_rest( - price, - starting_indexes, - exit, - Some(&self.dateindex_to_supply_in_profit), - )?; - - self.indexes_to_supply_in_loss.compute_rest( - price, - starting_indexes, - exit, - Some(&self.dateindex_to_supply_in_loss), - )?; - - self.indexes_to_unrealized_profit.compute_rest( - starting_indexes, - exit, - Some(&self.dateindex_to_unrealized_profit), - )?; - - self.indexes_to_unrealized_loss.compute_rest( - starting_indexes, - exit, - Some(&self.dateindex_to_unrealized_loss), - )?; - - // total_unrealized_pnl = profit + loss - self.height_to_total_unrealized_pnl.compute_add( - starting_indexes.height, - &self.height_to_unrealized_profit, - &self.height_to_unrealized_loss, - exit, - )?; - - self.indexes_to_total_unrealized_pnl - .compute_all(starting_indexes, exit, |vec| { - vec.compute_add( - starting_indexes.dateindex, - &self.dateindex_to_unrealized_profit, - &self.dateindex_to_unrealized_loss, - exit, - )?; - Ok(()) - })?; - - // neg_unrealized_loss = loss * -1 - self.height_to_neg_unrealized_loss.compute_transform( - starting_indexes.height, - &self.height_to_unrealized_loss, - |(h, v, ..)| (h, v * -1_i64), - exit, - )?; - - self.indexes_to_neg_unrealized_loss - .compute_all(starting_indexes, exit, |vec| { - vec.compute_transform( - starting_indexes.dateindex, - &self.dateindex_to_unrealized_loss, - |(h, v, ..)| (h, v * -1_i64), - exit, - )?; - Ok(()) - })?; - - // net_unrealized_pnl = profit - loss - self.height_to_net_unrealized_pnl.compute_subtract( - starting_indexes.height, - &self.height_to_unrealized_profit, - &self.height_to_unrealized_loss, - exit, - )?; - - self.indexes_to_net_unrealized_pnl - .compute_all(starting_indexes, exit, |vec| { - vec.compute_subtract( - starting_indexes.dateindex, - &self.dateindex_to_unrealized_profit, - &self.dateindex_to_unrealized_loss, - exit, - )?; - Ok(()) - })?; - - Ok(()) - } -} diff --git a/crates/brk_computer/src/stateful/mod.rs b/crates/brk_computer/src/stateful/mod.rs index 64be1e5a5..12ce46bcb 100644 --- a/crates/brk_computer/src/stateful/mod.rs +++ b/crates/brk_computer/src/stateful/mod.rs @@ -11,5 +11,7 @@ use states::*; pub use range_map::RangeMap; pub use vecs::Vecs; +pub const DB_NAME: &str = "stateful"; + pub use address::{AddressTypeToTypeIndexMap, AddressesDataVecs, AnyAddressIndexesVecs}; pub use cohorts::{AddressCohorts, CohortVecs, DynCohortVecs, UTXOCohorts}; diff --git a/crates/brk_computer/src/stateful/vecs.rs b/crates/brk_computer/src/stateful/vecs.rs index db70ebf29..ea0316176 100644 --- a/crates/brk_computer/src/stateful/vecs.rs +++ b/crates/brk_computer/src/stateful/vecs.rs @@ -19,11 +19,12 @@ use crate::{ ComputedValueVecsFromHeight, ComputedVecsFromDateIndex, ComputedVecsFromHeight, Source, VecBuilderOptions, }, - indexes, price, txins, + indexes, price, stateful::{ compute::{StartMode, determine_start_mode, process_blocks, recover_state, reset_state}, states::BlockState, }, + txins, utils::OptionExt, }; @@ -75,7 +76,7 @@ impl Vecs { indexes: &indexes::Vecs, price: Option<&price::Vecs>, ) -> Result { - let db_path = parent.join("stateful"); + let db_path = parent.join(super::DB_NAME); let states_path = db_path.join("states"); let db = Database::open(&db_path)?; @@ -112,7 +113,7 @@ impl Vecs { |index, _| Some(index), ); - Ok(Self { + let this = Self { chain_state: BytesVec::forced_import_with( vecdb::ImportOptions::new(&db, "chain", v0) .with_saved_stamped_changes(SAVED_STAMPED_CHANGES), @@ -221,7 +222,16 @@ impl Vecs { emptyaddressindex_to_emptyaddressindex, db, - }) + }; + + this.db.retain_regions( + this.iter_any_exportable() + .flat_map(|v| v.region_names()) + .collect(), + )?; + this.db.compact()?; + + Ok(this) } /// Main computation loop. diff --git a/crates/brk_computer/src/txins.rs b/crates/brk_computer/src/txins.rs index 4e2e2c5d3..de3627baf 100644 --- a/crates/brk_computer/src/txins.rs +++ b/crates/brk_computer/src/txins.rs @@ -13,6 +13,7 @@ use vecdb::{ use super::Indexes; const BATCH_SIZE: usize = 2 * 1024 * 1024 * 1024 / size_of::(); +pub const DB_NAME: &str = "txins"; #[derive(Clone, Traversable)] pub struct Vecs { @@ -23,7 +24,7 @@ pub struct Vecs { impl Vecs { pub fn forced_import(parent_path: &Path, parent_version: Version) -> Result { - let db = Database::open(&parent_path.join("txins"))?; + let db = Database::open(&parent_path.join(DB_NAME))?; db.set_min_len(PAGE_SIZE * 10_000_000)?; let version = parent_version + Version::ZERO; diff --git a/crates/brk_computer/src/txouts.rs b/crates/brk_computer/src/txouts.rs index 1ec9fd91b..e7e9455db 100644 --- a/crates/brk_computer/src/txouts.rs +++ b/crates/brk_computer/src/txouts.rs @@ -12,6 +12,8 @@ use vecdb::{ use super::{Indexes, txins}; +pub const DB_NAME: &str = "txouts"; + #[derive(Clone, Traversable)] pub struct Vecs { db: Database, @@ -20,7 +22,7 @@ pub struct Vecs { impl Vecs { pub fn forced_import(parent_path: &Path, parent_version: Version) -> Result { - let db = Database::open(&parent_path.join("txouts"))?; + let db = Database::open(&parent_path.join(DB_NAME))?; db.set_min_len(PAGE_SIZE * 10_000_000)?; let version = parent_version + Version::ZERO; diff --git a/crates/brk_indexer/src/vecs/mod.rs b/crates/brk_indexer/src/vecs/mod.rs index d332257f5..0b057410b 100644 --- a/crates/brk_indexer/src/vecs/mod.rs +++ b/crates/brk_indexer/src/vecs/mod.rs @@ -94,16 +94,12 @@ impl Vecs { output, }; - log::debug!("Retaining regions..."); this.db.retain_regions( this.iter_any_exportable() .flat_map(|v| v.region_names()) .collect(), )?; - - log::debug!("Compacting database..."); this.db.compact()?; - log::debug!("Vecs import complete."); Ok(this) } diff --git a/crates/brk_traversable_derive/Cargo.toml b/crates/brk_traversable_derive/Cargo.toml index b525d99c6..44799100f 100644 --- a/crates/brk_traversable_derive/Cargo.toml +++ b/crates/brk_traversable_derive/Cargo.toml @@ -14,4 +14,4 @@ proc-macro = true [dependencies] syn = "2.0" quote = "1.0" -proc-macro2 = "1.0.103" +proc-macro2 = "1.0.104" diff --git a/crates/brk_types/Cargo.toml b/crates/brk_types/Cargo.toml index 6610b9b3a..1ca9e3ac7 100644 --- a/crates/brk_types/Cargo.toml +++ b/crates/brk_types/Cargo.toml @@ -13,11 +13,11 @@ bitcoin = { workspace = true } brk_error = { workspace = true } byteview = { workspace = true } derive_deref = { workspace = true } -itoa = "1.0.16" +itoa = "1.0.17" jiff = { workspace = true } num_enum = "0.7.5" rapidhash = "4.2.0" -ryu = "1.0.21" +ryu = "1.0.22" schemars = { workspace = true } serde = { workspace = true } serde_json = { workspace = true } diff --git a/.claude/prompts/changelog.md b/docs/claude/changelog.md similarity index 100% rename from .claude/prompts/changelog.md rename to docs/claude/changelog.md diff --git a/.claude/prompts/readmes.md b/docs/claude/readmes.md similarity index 100% rename from .claude/prompts/readmes.md rename to docs/claude/readmes.md