diff --git a/Cargo.lock b/Cargo.lock index e10f981..d8a3c7d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -76,11 +76,69 @@ dependencies = [ "libc", ] +[[package]] +name = "ansi_term" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d52a9bb7ec0cf484c551830a7ce27bd20d67eac647e1befb56b0be4ee39a55d2" +dependencies = [ + "winapi", +] + +[[package]] +name = "anstream" +version = "0.6.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8acc5369981196006228e28809f761875c0327210a891e941f4c683b3a99529b" +dependencies = [ + "anstyle", + "anstyle-parse", + "anstyle-query", + "anstyle-wincon", + "colorchoice", + "is_terminal_polyfill", + "utf8parse", +] + +[[package]] +name = "anstyle" +version = "1.0.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "55cc3b69f167a1ef2e161439aa98aed94e6028e5f9a59be9a6ffb47aef1651f9" + +[[package]] +name = "anstyle-parse" +version = "0.2.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3b2d16507662817a6a20a9ea92df6652ee4f94f914589377d69f3b21bc5798a9" +dependencies = [ + "utf8parse", +] + +[[package]] +name = "anstyle-query" +version = "1.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "79947af37f4177cfead1110013d678905c37501914fba0efea834c3fe9a8d60c" +dependencies = [ + "windows-sys 0.59.0", +] + +[[package]] +name = "anstyle-wincon" +version = "3.0.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2109dbce0e72be3ec00bed26e6a7479ca384ad226efdd66db8fa2e3a38c83125" +dependencies = [ + "anstyle", + "windows-sys 0.59.0", +] + [[package]] name = "anyhow" -version = "1.0.91" +version = "1.0.93" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c042108f3ed77fd83760a5fd79b53be043192bb3b9dba91d8c574c0ada7850c8" +checksum = "4c95c10ba0b00a02636238b814946408b1322d5ac4760326e6fb8ec956d85775" [[package]] name = "arc-swap" @@ -119,7 +177,7 @@ checksum = "3b43422f69d8ff38f95f1b2bb76517c91589a924d1559a0e935d7c8ce0274c11" dependencies = [ "proc-macro2", "quote", - "syn 2.0.85", + "syn 2.0.89", ] [[package]] @@ -141,7 +199,7 @@ checksum = "c7c24de15d275a1ecfd47a380fb4d5ec9bfe0933f309ed5e705b775596a3574d" dependencies = [ "proc-macro2", "quote", - "syn 2.0.85", + "syn 2.0.89", ] [[package]] @@ -152,7 +210,7 @@ checksum = "721cae7de5c34fbb2acd27e21e6d2cf7b886dce0c27388d46c4e6c47ea4318dd" dependencies = [ "proc-macro2", "quote", - "syn 2.0.85", + "syn 2.0.89", ] [[package]] @@ -161,6 +219,17 @@ version = "1.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1505bd5d3d116872e7271a6d4e16d81d0c8570876c8de68093a09ac269d8aac0" +[[package]] +name = "atty" +version = "0.2.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8" +dependencies = [ + "hermit-abi 0.1.19", + "libc", + "winapi", +] + [[package]] name = "autocfg" version = "1.4.0" @@ -169,9 +238,9 @@ checksum = "ace50bade8e6234aa140d9a2f552bbee1db4d353f69b8217bc503490fc1a9f26" [[package]] name = "axum" -version = "0.7.7" +version = "0.7.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "504e3947307ac8326a5437504c517c4b56716c9d98fac0028c2acc7ca47d70ae" +checksum = "edca88bc138befd0323b20752846e6587272d3b03b0343c8ea28a6f819e6e71f" dependencies = [ "async-trait", "axum-core", @@ -188,7 +257,7 @@ dependencies = [ "pin-project-lite", "rustversion", "serde", - "sync_wrapper 1.0.1", + "sync_wrapper 1.0.2", "tower 0.5.1", "tower-layer", "tower-service", @@ -209,7 +278,7 @@ dependencies = [ "mime", "pin-project-lite", "rustversion", - "sync_wrapper 1.0.1", + "sync_wrapper 1.0.2", "tower-layer", "tower-service", ] @@ -343,9 +412,9 @@ dependencies = [ [[package]] name = "borsh" -version = "1.5.1" +version = "1.5.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a6362ed55def622cddc70a4746a68554d7b687713770de539e59a739b249f8ed" +checksum = "2506947f73ad44e344215ccd6403ac2ae18cd8e046e581a441bf8d199f257f03" dependencies = [ "borsh-derive", "cfg_aliases", @@ -353,16 +422,15 @@ dependencies = [ [[package]] name = "borsh-derive" -version = "1.5.1" +version = "1.5.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c3ef8005764f53cd4dca619f5bf64cafd4664dada50ece25e4d81de54c80cc0b" +checksum = "c2593a3b8b938bd68373196c9832f516be11fa487ef4ae745eb282e6a56a7244" dependencies = [ "once_cell", "proc-macro-crate 3.2.0", "proc-macro2", "quote", - "syn 2.0.85", - "syn_derive", + "syn 2.0.89", ] [[package]] @@ -415,9 +483,9 @@ dependencies = [ [[package]] name = "cc" -version = "1.1.31" +version = "1.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c2e7962b54006dcfcc61cb72735f4d89bb97061dd6a7ed882ec6b8ee53714c6f" +checksum = "fd9de9f2205d5ef3fd67e685b0df337994ddd4495e2a28d185500d0e1edfea47" dependencies = [ "shlex", ] @@ -477,8 +545,10 @@ checksum = "a21f936df1771bf62b77f047b726c4625ff2e8aa607c01ec06e5a05bd8463401" dependencies = [ "android-tzdata", "iana-time-zone", + "js-sys", "num-traits", "serde", + "wasm-bindgen", "windows-targets 0.52.6", ] @@ -518,11 +588,21 @@ version = "2.34.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a0610544180c38b88101fecf2dd634b174a62eef6946f84dfc6a7127512b381c" dependencies = [ + "ansi_term", + "atty", "bitflags 1.3.2", + "strsim 0.8.0", "textwrap", "unicode-width", + "vec_map", ] +[[package]] +name = "colorchoice" +version = "1.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5b63caa9aa9397e2d9480a9b13673856c78d8ac123288526c37d7839f2a86990" + [[package]] name = "config" version = "0.14.1" @@ -552,9 +632,9 @@ dependencies = [ [[package]] name = "cpufeatures" -version = "0.2.14" +version = "0.2.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "608697df725056feaccfa42cffdaeeec3fccc4ffc38358ecd19b243e716a78e0" +checksum = "16b80225097f2e5ae4e7179dd2266824648f3e2f49d9134d584b76389d31c4c3" dependencies = [ "libc", ] @@ -626,7 +706,7 @@ checksum = "f46882e17999c6cc590af592290432be3bce0428cb0d5f8b6715e4dc7b383eb3" dependencies = [ "proc-macro2", "quote", - "syn 2.0.85", + "syn 2.0.89", ] [[package]] @@ -649,8 +729,8 @@ dependencies = [ "ident_case", "proc-macro2", "quote", - "strsim", - "syn 2.0.85", + "strsim 0.11.1", + "syn 2.0.89", ] [[package]] @@ -661,7 +741,7 @@ checksum = "d336a2a514f6ccccaa3e09b02d41d35330c07ddf03a62165fcec10bb561c7806" dependencies = [ "darling_core", "quote", - "syn 2.0.85", + "syn 2.0.89", ] [[package]] @@ -707,9 +787,9 @@ checksum = "3c877555693c14d2f84191cfd3ad8582790fc52b5e2274b40b59cf5f5cea25c7" [[package]] name = "diesel" -version = "2.2.4" +version = "2.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "158fe8e2e68695bd615d7e4f3227c0727b151330d3e253b525086c348d055d5e" +checksum = "cbf9649c05e0a9dbd6d0b0b8301db5182b972d0fd02f0a7c6736cf632d7c0fd5" dependencies = [ "bigdecimal", "chrono", @@ -733,7 +813,7 @@ dependencies = [ "dsl_auto_type", "proc-macro2", "quote", - "syn 2.0.85", + "syn 2.0.89", ] [[package]] @@ -753,7 +833,7 @@ version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "209c735641a413bc68c4923a9d6ad4bcb3ca306b794edaa7eb0b3228a99ffb25" dependencies = [ - "syn 2.0.85", + "syn 2.0.89", ] [[package]] @@ -788,6 +868,17 @@ dependencies = [ "winapi", ] +[[package]] +name = "displaydoc" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "97369cbbc041bc366949bc74d34658d6cda5621039731c6310521892a3a20ae0" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.89", +] + [[package]] name = "doc-comment" version = "0.3.3" @@ -805,7 +896,7 @@ dependencies = [ "heck 0.5.0", "proc-macro2", "quote", - "syn 2.0.85", + "syn 2.0.89", ] [[package]] @@ -829,7 +920,30 @@ dependencies = [ "heck 0.5.0", "proc-macro2", "quote", - "syn 2.0.85", + "syn 2.0.89", +] + +[[package]] +name = "env_filter" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4f2c92ceda6ceec50f43169f9ee8424fe2db276791afde7b2cd8bc084cb376ab" +dependencies = [ + "log", + "regex", +] + +[[package]] +name = "env_logger" +version = "0.11.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e13fa619b91fb2381732789fc5de83b45675e882f66623b7d8cb4f643017018d" +dependencies = [ + "anstream", + "anstyle", + "env_filter", + "humantime", + "log", ] [[package]] @@ -850,9 +964,9 @@ dependencies = [ [[package]] name = "fastrand" -version = "2.1.1" +version = "2.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e8c02a5121d4ea3eb16a80748c74f5549a5665e4c21333c6098f283870fbdea6" +checksum = "486f806e73c5707928240ddc295403b1b93c96a02038563881c4a2fd84b81ac4" [[package]] name = "ff" @@ -894,6 +1008,21 @@ version = "1.0.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" +[[package]] +name = "foreign-types" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f6f339eb8adc052cd2ca78910fda869aefa38d22d5cb648e6485e4d3fc06f3b1" +dependencies = [ + "foreign-types-shared", +] + +[[package]] +name = "foreign-types-shared" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "00b0228411908ca8685dba7fc2cdd70ec9990a6e753e89b6ac91a84c40fbaf4b" + [[package]] name = "form_urlencoded" version = "1.2.1" @@ -981,7 +1110,7 @@ checksum = "162ee34ebcb7c64a8abebc059ce0fee27c2262618d7b60ed8faf72fef13c3650" dependencies = [ "proc-macro2", "quote", - "syn 2.0.85", + "syn 2.0.89", ] [[package]] @@ -1071,9 +1200,9 @@ dependencies = [ [[package]] name = "h2" -version = "0.4.6" +version = "0.4.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "524e8ac6999421f49a846c2d4411f337e53497d8ec55d67753beffa43c5d9205" +checksum = "ccae279728d634d083c00f6099cb58f01cc99c145b84b8be2f6c74618d79922e" dependencies = [ "atomic-waker", "bytes 1.8.0", @@ -1096,9 +1225,9 @@ checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" [[package]] name = "hashbrown" -version = "0.15.0" +version = "0.15.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e087f84d4f86bf4b218b927129862374b72199ae7d8657835f1e89000eea4fb" +checksum = "3a9bfc1af68b1726ea47d3d5109de126281def866b33970e10fbab11b5dafab3" [[package]] name = "hdrhistogram" @@ -1131,6 +1260,15 @@ version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea" +[[package]] +name = "hermit-abi" +version = "0.1.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "62b467343b94ba476dcb2500d242dadbb39557df889310ac77c5d99100aaac33" +dependencies = [ + "libc", +] + [[package]] name = "hermit-abi" version = "0.3.9" @@ -1183,9 +1321,10 @@ dependencies = [ "futures-channel", "futures-io", "futures-util", - "idna", + "idna 0.5.0", "ipnet", "once_cell", + "openssl", "rand", "ring", "rustls", @@ -1294,9 +1433,9 @@ checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4" [[package]] name = "hyper" -version = "1.5.0" +version = "1.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bbbff0a806a4728c99295b254c8838933b5b082d75e3cb70c8dab21fdfbcfa9a" +checksum = "97818827ef4f364230e16705d4706e2897df2bb60617d6ca15d598025a3c481f" dependencies = [ "bytes 1.8.0", "futures-channel", @@ -1315,9 +1454,9 @@ dependencies = [ [[package]] name = "hyper-timeout" -version = "0.5.1" +version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3203a961e5c83b6f5498933e78b6b263e208c197b63e9c6c53cc82ffd3f63793" +checksum = "2b90d566bffbce6a75bd8b09a05aa8c2cb1fabb6cb348f8840c9e4c90a0d83b0" dependencies = [ "hyper", "hyper-util", @@ -1368,6 +1507,124 @@ dependencies = [ "cc", ] +[[package]] +name = "icu_collections" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "db2fa452206ebee18c4b5c2274dbf1de17008e874b4dc4f0aea9d01ca79e4526" +dependencies = [ + "displaydoc", + "yoke", + "zerofrom", + "zerovec", +] + +[[package]] +name = "icu_locid" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "13acbb8371917fc971be86fc8057c41a64b521c184808a698c02acc242dbf637" +dependencies = [ + "displaydoc", + "litemap", + "tinystr", + "writeable", + "zerovec", +] + +[[package]] +name = "icu_locid_transform" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "01d11ac35de8e40fdeda00d9e1e9d92525f3f9d887cdd7aa81d727596788b54e" +dependencies = [ + "displaydoc", + "icu_locid", + "icu_locid_transform_data", + "icu_provider", + "tinystr", + "zerovec", +] + +[[package]] +name = "icu_locid_transform_data" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fdc8ff3388f852bede6b579ad4e978ab004f139284d7b28715f773507b946f6e" + +[[package]] +name = "icu_normalizer" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "19ce3e0da2ec68599d193c93d088142efd7f9c5d6fc9b803774855747dc6a84f" +dependencies = [ + "displaydoc", + "icu_collections", + "icu_normalizer_data", + "icu_properties", + "icu_provider", + "smallvec", + "utf16_iter", + "utf8_iter", + "write16", + "zerovec", +] + +[[package]] +name = "icu_normalizer_data" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f8cafbf7aa791e9b22bec55a167906f9e1215fd475cd22adfcf660e03e989516" + +[[package]] +name = "icu_properties" +version = "1.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "93d6020766cfc6302c15dbbc9c8778c37e62c14427cb7f6e601d849e092aeef5" +dependencies = [ + "displaydoc", + "icu_collections", + "icu_locid_transform", + "icu_properties_data", + "icu_provider", + "tinystr", + "zerovec", +] + +[[package]] +name = "icu_properties_data" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "67a8effbc3dd3e4ba1afa8ad918d5684b8868b3b26500753effea8d2eed19569" + +[[package]] +name = "icu_provider" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6ed421c8a8ef78d3e2dbc98a973be2f3770cb42b606e3ab18d6237c4dfde68d9" +dependencies = [ + "displaydoc", + "icu_locid", + "icu_provider_macros", + "stable_deref_trait", + "tinystr", + "writeable", + "yoke", + "zerofrom", + "zerovec", +] + +[[package]] +name = "icu_provider_macros" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1ec89e9337638ecdc08744df490b221a7399bf8d164eb52a665454e60e075ad6" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.89", +] + [[package]] name = "ident_case" version = "1.0.1" @@ -1384,6 +1641,27 @@ dependencies = [ "unicode-normalization", ] +[[package]] +name = "idna" +version = "1.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "686f825264d630750a544639377bae737628043f20d38bbc029e8f29ea968a7e" +dependencies = [ + "idna_adapter", + "smallvec", + "utf8_iter", +] + +[[package]] +name = "idna_adapter" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "daca1df1c957320b2cf139ac61e7bd64fed304c5040df000a745aa1de3b4ef71" +dependencies = [ + "icu_normalizer", + "icu_properties", +] + [[package]] name = "impl-codec" version = "0.6.0" @@ -1393,6 +1671,15 @@ dependencies = [ "parity-scale-codec", ] +[[package]] +name = "impl-codec" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b67aa010c1e3da95bf151bd8b4c059b2ed7e75387cdb969b4f8f2723a43f9941" +dependencies = [ + "parity-scale-codec", +] + [[package]] name = "impl-serde" version = "0.4.0" @@ -1402,15 +1689,24 @@ dependencies = [ "serde", ] +[[package]] +name = "impl-serde" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4a143eada6a1ec4aefa5049037a26a6d597bfd64f8c026d07b77133e02b7dd0b" +dependencies = [ + "serde", +] + [[package]] name = "impl-trait-for-tuples" -version = "0.2.2" +version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "11d7a9f6330b71fea57921c9b61c47ee6e84f72d394754eff6163ae67e7395eb" +checksum = "a0eb5a3343abf848c0984fe4604b2b105da9539376e24fc0a3b0007411ae4fd9" dependencies = [ "proc-macro2", "quote", - "syn 1.0.109", + "syn 2.0.89", ] [[package]] @@ -1430,7 +1726,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "707907fe3c25f5424cce2cb7e1cbcafee6bdbe735ca90ef77c29e84591e5b9da" dependencies = [ "equivalent", - "hashbrown 0.15.0", + "hashbrown 0.15.1", ] [[package]] @@ -1466,6 +1762,12 @@ version = "2.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ddc24109865250148c2e0f3d25d4f0f479571723792d3802153c60922a4fb708" +[[package]] +name = "is_terminal_polyfill" +version = "1.70.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7943c866cc5cd64cbc25b2e01621d07fa8eb2a1a23160ee81ce38704e97b8ecf" + [[package]] name = "itertools" version = "0.10.5" @@ -1495,9 +1797,9 @@ dependencies = [ [[package]] name = "itoa" -version = "1.0.11" +version = "1.0.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "49f1f14873335454500d59611f1cf4a4b0f786f9ac11f4312a78e4cf2566695b" +checksum = "540654e97a3f4470a492cd30ff187bc95d89557a903a2bbf112e2fae98104ef2" [[package]] name = "js-sys" @@ -1525,9 +1827,9 @@ checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" [[package]] name = "libc" -version = "0.2.161" +version = "0.2.164" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e9489c2807c139ffd9c1794f4af0ebe86a828db53ecdc7fea2111d0fed085d1" +checksum = "433bfe06b8c75da9b2e3fbea6e5329ff87748f0b144ef75306e674c3f6f7c13f" [[package]] name = "liblmdb-sys" @@ -1577,6 +1879,12 @@ version = "0.4.14" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "78b3ae25bc7c8c38cec158d1f2757ee79e9b3740fbc7ccf0e59e4b08d793fa89" +[[package]] +name = "litemap" +version = "0.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "643cb0b8d4fcc284004d5fd0d67ccf61dfffadb7f75e1e71bc420f4688a3a704" + [[package]] name = "lmdb-zero" version = "0.4.4" @@ -1717,8 +2025,8 @@ dependencies = [ [[package]] name = "minotari_app_grpc" -version = "1.8.0-pre.0" -source = "git+https://github.com/tari-project/tari.git?branch=development#47b48770f84e05c3dce1926d0a8d21eee4ccfe21" +version = "1.9.0-pre.0" +source = "git+https://github.com/tari-project/tari.git?branch=development#d22ef6582e9a671577efc419e5d121c384972aad" dependencies = [ "argon2", "base64 0.13.1", @@ -1747,8 +2055,8 @@ dependencies = [ [[package]] name = "minotari_ledger_wallet_common" -version = "1.8.0-pre.0" -source = "git+https://github.com/tari-project/tari.git?branch=development#47b48770f84e05c3dce1926d0a8d21eee4ccfe21" +version = "1.9.0-pre.0" +source = "git+https://github.com/tari-project/tari.git?branch=development#d22ef6582e9a671577efc419e5d121c384972aad" dependencies = [ "bs58 0.5.1", ] @@ -1756,7 +2064,7 @@ dependencies = [ [[package]] name = "minotari_node_grpc_client" version = "0.1.0" -source = "git+https://github.com/tari-project/tari.git?branch=development#47b48770f84e05c3dce1926d0a8d21eee4ccfe21" +source = "git+https://github.com/tari-project/tari.git?branch=development#d22ef6582e9a671577efc419e5d121c384972aad" dependencies = [ "minotari_app_grpc", ] @@ -1767,7 +2075,7 @@ version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "80e04d1dcff3aae0704555fe5fee3bcfaf3d1fdf8a7e521d5b9d2b42acb52cec" dependencies = [ - "hermit-abi", + "hermit-abi 0.3.9", "libc", "wasi", "windows-sys 0.52.0", @@ -1830,7 +2138,7 @@ dependencies = [ "proc-macro2", "quote", "syn 1.0.109", - "synstructure", + "synstructure 0.12.6", ] [[package]] @@ -1900,7 +2208,7 @@ checksum = "ed3955f1a9c7c0c15e092f9c887db08b1fc683305fdf6eb6684f22555355e202" dependencies = [ "proc-macro2", "quote", - "syn 2.0.85", + "syn 2.0.89", ] [[package]] @@ -1956,6 +2264,44 @@ version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c08d65885ee38876c4f86fa503fb49d7b507c2b62552df7c70b2fce627e06381" +[[package]] +name = "openssl" +version = "0.10.68" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6174bc48f102d208783c2c84bf931bb75927a617866870de8a4ea85597f871f5" +dependencies = [ + "bitflags 2.6.0", + "cfg-if", + "foreign-types", + "libc", + "once_cell", + "openssl-macros", + "openssl-sys", +] + +[[package]] +name = "openssl-macros" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a948666b637a0f465e8564c73e89d4dde00d72d4d473cc972f390fc3dcee7d9c" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.89", +] + +[[package]] +name = "openssl-sys" +version = "0.9.104" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "45abf306cbf99debc8195b66b7346498d7b10c210de50418b5ccd7ceba08c741" +dependencies = [ + "cc", + "libc", + "pkg-config", + "vcpkg", +] + [[package]] name = "ordered-float" version = "2.10.1" @@ -1967,28 +2313,29 @@ dependencies = [ [[package]] name = "parity-scale-codec" -version = "3.6.12" +version = "3.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "306800abfa29c7f16596b5970a588435e3d5b3149683d00c12b699cc19f895ee" +checksum = "8be4817d39f3272f69c59fe05d0535ae6456c2dc2fa1ba02910296c7e0a5c590" dependencies = [ "arrayvec", "bitvec", "byte-slice-cast", "impl-trait-for-tuples", "parity-scale-codec-derive", + "rustversion", "serde", ] [[package]] name = "parity-scale-codec-derive" -version = "3.6.12" +version = "3.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d830939c76d294956402033aee57a6da7b438f2294eb94864c37b0569053a42c" +checksum = "8781a75c6205af67215f382092b6e0a4ff3734798523e69073d4bcd294ec767b" dependencies = [ "proc-macro-crate 3.2.0", "proc-macro2", "quote", - "syn 1.0.109", + "syn 2.0.89", ] [[package]] @@ -2100,7 +2447,7 @@ checksum = "3c0f5fad0874fc7abcd4d750e76917eaebbecaa2c20bde22e1dbeeba8beb758c" dependencies = [ "proc-macro2", "quote", - "syn 2.0.85", + "syn 2.0.89", ] [[package]] @@ -2182,7 +2529,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "64d1ec885c64d0457d564db4ec299b2dae3f9c02808b8ad9c3a089c591b18033" dependencies = [ "proc-macro2", - "syn 2.0.85", + "syn 2.0.89", ] [[package]] @@ -2192,9 +2539,21 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0b34d9fd68ae0b74a41b21c03c2f62847aa0ffea044eee893b4c140b37e244e2" dependencies = [ "fixed-hash", - "impl-codec", - "impl-serde", - "uint", + "impl-codec 0.6.0", + "impl-serde 0.4.0", + "uint 0.9.5", +] + +[[package]] +name = "primitive-types" +version = "0.13.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d15600a7d856470b7d278b3fe0e311fe28c2526348549f8ef2ff7db3299c87f5" +dependencies = [ + "fixed-hash", + "impl-codec 0.7.0", + "impl-serde 0.5.0", + "uint 0.10.0", ] [[package]] @@ -2242,9 +2601,9 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.89" +version = "1.0.92" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f139b0662de085916d1fb67d2b4169d1addddda1919e696f3252b740b629986e" +checksum = "37d3544b3f2748c54e147655edb5025752e2303145b5aefb3c3ea2c78b973bb0" dependencies = [ "unicode-ident", ] @@ -2308,7 +2667,7 @@ dependencies = [ "prost 0.13.3", "prost-types 0.13.3", "regex", - "syn 2.0.85", + "syn 2.0.89", "tempfile", ] @@ -2335,7 +2694,7 @@ dependencies = [ "itertools 0.13.0", "proc-macro2", "quote", - "syn 2.0.85", + "syn 2.0.89", ] [[package]] @@ -2430,9 +2789,9 @@ dependencies = [ [[package]] name = "randomx-rs" -version = "1.3.1" +version = "1.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9abb8f2aa3432700c2b64a67406ac0da4956d78991f50559509cecc2b6abf249" +checksum = "09c347596479c4796192e68aec20e62e31655b57753586f2b1ec320b779ef14c" dependencies = [ "bitflags 1.3.2", "libc", @@ -2485,9 +2844,9 @@ dependencies = [ [[package]] name = "regex-automata" -version = "0.4.8" +version = "0.4.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "368758f23274712b504848e9d5a6f010445cc8b87a7cdb4d7cbee666c1288da3" +checksum = "809e8dc61f6de73b46c85f4c96486310fe304c434cfa43669d7b40f711150908" dependencies = [ "aho-corasick", "memchr", @@ -2548,9 +2907,9 @@ dependencies = [ [[package]] name = "rustix" -version = "0.38.38" +version = "0.38.41" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aa260229e6538e52293eeb577aabd09945a09d6d9cc0fc550ed7529056c2e32a" +checksum = "d7f649912bc1495e167a6edee79151c84b1bad49748cb4f1f1167f459f6224f6" dependencies = [ "bitflags 2.6.0", "errno", @@ -2561,9 +2920,9 @@ dependencies = [ [[package]] name = "rustls" -version = "0.23.16" +version = "0.23.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eee87ff5d9b36712a58574e12e9f0ea80f915a5b0ac518d322b24a465617925e" +checksum = "7f1a745511c54ba6d4465e8d5dfbd81b45791756de28d4981af70d6dca128f1e" dependencies = [ "log", "once_cell", @@ -2636,7 +2995,7 @@ dependencies = [ "heck 0.4.1", "proc-macro2", "quote", - "syn 2.0.85", + "syn 2.0.89", ] [[package]] @@ -2647,9 +3006,9 @@ checksum = "61697e0a1c7e512e84a621326239844a24d8207b4669b41bc18b32ea5cbf988b" [[package]] name = "serde" -version = "1.0.214" +version = "1.0.215" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f55c3193aca71c12ad7890f1785d2b73e1b9f63a0bbc353c08ef26fe03fc56b5" +checksum = "6513c1ad0b11a9376da888e3e0baa0077f1aed55c17f50e7b2397136129fb88f" dependencies = [ "serde_derive", ] @@ -2666,20 +3025,20 @@ dependencies = [ [[package]] name = "serde_derive" -version = "1.0.214" +version = "1.0.215" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "de523f781f095e28fa605cdce0f8307e451cc0fd14e2eb4cd2e98a355b147766" +checksum = "ad1e866f866923f252f05c889987993144fb74e722403468a4ebd70c3cd756c0" dependencies = [ "proc-macro2", "quote", - "syn 2.0.85", + "syn 2.0.89", ] [[package]] name = "serde_json" -version = "1.0.132" +version = "1.0.133" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d726bfaff4b320266d395898905d0eba0345aae23b54aee3a737e260fd46db03" +checksum = "c7fceb2473b9166b2294ef05efcb65a3db80803f0b03ef86a5fc88a2b85ee377" dependencies = [ "itoa", "memchr", @@ -2695,7 +3054,7 @@ checksum = "6c64451ba24fc7a6a2d60fc75dd9c83c90903b19028d4eff35e88fc1e86564e9" dependencies = [ "proc-macro2", "quote", - "syn 2.0.85", + "syn 2.0.89", ] [[package]] @@ -2825,6 +3184,12 @@ version = "0.9.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6980e8d7511241f8acf4aebddbb1ff938df5eebe98691418c4468d0b72a96a67" +[[package]] +name = "stable_deref_trait" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3" + [[package]] name = "stack-buf" version = "0.1.6" @@ -2837,6 +3202,12 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" +[[package]] +name = "strsim" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8ea5119cdb4c55b55d432abb513a0429384878c15dde60cc77b1c99de1a95a6a" + [[package]] name = "strsim" version = "0.11.1" @@ -2913,27 +3284,15 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.85" +version = "2.0.89" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5023162dfcd14ef8f32034d8bcd4cc5ddc61ef7a247c024a33e24e1f24d21b56" +checksum = "44d46482f1c1c87acd84dea20c1bf5ebff4c757009ed6bf19cfd36fb10e92c4e" dependencies = [ "proc-macro2", "quote", "unicode-ident", ] -[[package]] -name = "syn_derive" -version = "0.1.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1329189c02ff984e9736652b1631330da25eaa6bc639089ed4915d25446cbe7b" -dependencies = [ - "proc-macro-error", - "proc-macro2", - "quote", - "syn 2.0.85", -] - [[package]] name = "sync_wrapper" version = "0.1.2" @@ -2942,9 +3301,9 @@ checksum = "2047c6ded9c721764247e62cd3b03c09ffc529b2ba5b10ec482ae507a4a70160" [[package]] name = "sync_wrapper" -version = "1.0.1" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a7065abeca94b6a8a577f9bd45aa0867a2238b74e8eb67cf10d492bc39351394" +checksum = "0bf256ce5efdfa370213c1dabab5935a12e49f2c58d15e9eac2870d3b4f27263" [[package]] name = "synstructure" @@ -2958,6 +3317,17 @@ dependencies = [ "unicode-xid", ] +[[package]] +name = "synstructure" +version = "0.13.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c8af7666ab7b6390ab78131fb5b0fce11d6b7a6951602017c35fa82800708971" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.89", +] + [[package]] name = "tap" version = "1.0.1" @@ -2969,8 +3339,15 @@ name = "tari-grpc-bridge" version = "0.1.0" dependencies = [ "anyhow", + "chrono", + "env_logger", + "log", "minotari_node_grpc_client", + "primitive-types 0.13.1", + "structopt", + "tari_common_types", "tokio", + "tonic", ] [[package]] @@ -3006,8 +3383,8 @@ dependencies = [ [[package]] name = "tari_common" -version = "1.8.0-pre.0" -source = "git+https://github.com/tari-project/tari.git?branch=development#47b48770f84e05c3dce1926d0a8d21eee4ccfe21" +version = "1.9.0-pre.0" +source = "git+https://github.com/tari-project/tari.git?branch=development#d22ef6582e9a671577efc419e5d121c384972aad" dependencies = [ "anyhow", "config", @@ -3030,8 +3407,8 @@ dependencies = [ [[package]] name = "tari_common_sqlite" -version = "1.8.0-pre.0" -source = "git+https://github.com/tari-project/tari.git?branch=development#47b48770f84e05c3dce1926d0a8d21eee4ccfe21" +version = "1.9.0-pre.0" +source = "git+https://github.com/tari-project/tari.git?branch=development#d22ef6582e9a671577efc419e5d121c384972aad" dependencies = [ "diesel", "diesel_migrations", @@ -3044,8 +3421,8 @@ dependencies = [ [[package]] name = "tari_common_types" -version = "1.8.0-pre.0" -source = "git+https://github.com/tari-project/tari.git?branch=development#47b48770f84e05c3dce1926d0a8d21eee4ccfe21" +version = "1.9.0-pre.0" +source = "git+https://github.com/tari-project/tari.git?branch=development#d22ef6582e9a671577efc419e5d121c384972aad" dependencies = [ "base64 0.21.7", "bitflags 2.6.0", @@ -3057,7 +3434,7 @@ dependencies = [ "minotari_ledger_wallet_common", "newtype-ops", "once_cell", - "primitive-types", + "primitive-types 0.12.2", "rand", "serde", "strum", @@ -3070,8 +3447,8 @@ dependencies = [ [[package]] name = "tari_comms" -version = "1.8.0-pre.0" -source = "git+https://github.com/tari-project/tari.git?branch=development#47b48770f84e05c3dce1926d0a8d21eee4ccfe21" +version = "1.9.0-pre.0" +source = "git+https://github.com/tari-project/tari.git?branch=development#d22ef6582e9a671577efc419e5d121c384972aad" dependencies = [ "anyhow", "async-trait", @@ -3114,8 +3491,8 @@ dependencies = [ [[package]] name = "tari_comms_dht" -version = "1.8.0-pre.0" -source = "git+https://github.com/tari-project/tari.git?branch=development#47b48770f84e05c3dce1926d0a8d21eee4ccfe21" +version = "1.9.0-pre.0" +source = "git+https://github.com/tari-project/tari.git?branch=development#d22ef6582e9a671577efc419e5d121c384972aad" dependencies = [ "anyhow", "bitflags 2.6.0", @@ -3149,8 +3526,8 @@ dependencies = [ [[package]] name = "tari_comms_rpc_macros" -version = "1.8.0-pre.0" -source = "git+https://github.com/tari-project/tari.git?branch=development#47b48770f84e05c3dce1926d0a8d21eee4ccfe21" +version = "1.9.0-pre.0" +source = "git+https://github.com/tari-project/tari.git?branch=development#d22ef6582e9a671577efc419e5d121c384972aad" dependencies = [ "proc-macro2", "quote", @@ -3159,9 +3536,10 @@ dependencies = [ [[package]] name = "tari_core" -version = "1.8.0-pre.0" -source = "git+https://github.com/tari-project/tari.git?branch=development#47b48770f84e05c3dce1926d0a8d21eee4ccfe21" +version = "1.9.0-pre.0" +source = "git+https://github.com/tari-project/tari.git?branch=development#d22ef6582e9a671577efc419e5d121c384972aad" dependencies = [ + "anyhow", "async-trait", "bincode", "bitflags 2.6.0", @@ -3177,6 +3555,7 @@ dependencies = [ "fs2", "futures 0.3.31", "hex", + "hickory-client", "integer-encoding", "lmdb-zero", "log", @@ -3187,7 +3566,7 @@ dependencies = [ "num-format", "num-traits", "once_cell", - "primitive-types", + "primitive-types 0.12.2", "prost 0.13.3", "rand", "randomx-rs", @@ -3250,13 +3629,13 @@ dependencies = [ [[package]] name = "tari_features" -version = "1.8.0-pre.0" -source = "git+https://github.com/tari-project/tari.git?branch=development#47b48770f84e05c3dce1926d0a8d21eee4ccfe21" +version = "1.9.0-pre.0" +source = "git+https://github.com/tari-project/tari.git?branch=development#d22ef6582e9a671577efc419e5d121c384972aad" [[package]] name = "tari_hashing" -version = "1.8.0-pre.0" -source = "git+https://github.com/tari-project/tari.git?branch=development#47b48770f84e05c3dce1926d0a8d21eee4ccfe21" +version = "1.9.0-pre.0" +source = "git+https://github.com/tari-project/tari.git?branch=development#d22ef6582e9a671577efc419e5d121c384972aad" dependencies = [ "borsh", "digest", @@ -3265,8 +3644,8 @@ dependencies = [ [[package]] name = "tari_key_manager" -version = "1.8.0-pre.0" -source = "git+https://github.com/tari-project/tari.git?branch=development#47b48770f84e05c3dce1926d0a8d21eee4ccfe21" +version = "1.9.0-pre.0" +source = "git+https://github.com/tari-project/tari.git?branch=development#d22ef6582e9a671577efc419e5d121c384972aad" dependencies = [ "argon2", "async-trait", @@ -3298,8 +3677,8 @@ dependencies = [ [[package]] name = "tari_max_size" -version = "1.8.0-pre.0" -source = "git+https://github.com/tari-project/tari.git?branch=development#47b48770f84e05c3dce1926d0a8d21eee4ccfe21" +version = "1.9.0-pre.0" +source = "git+https://github.com/tari-project/tari.git?branch=development#d22ef6582e9a671577efc419e5d121c384972aad" dependencies = [ "borsh", "serde", @@ -3309,8 +3688,8 @@ dependencies = [ [[package]] name = "tari_mmr" -version = "1.8.0-pre.0" -source = "git+https://github.com/tari-project/tari.git?branch=development#47b48770f84e05c3dce1926d0a8d21eee4ccfe21" +version = "1.9.0-pre.0" +source = "git+https://github.com/tari-project/tari.git?branch=development#d22ef6582e9a671577efc419e5d121c384972aad" dependencies = [ "borsh", "digest", @@ -3323,8 +3702,8 @@ dependencies = [ [[package]] name = "tari_p2p" -version = "1.8.0-pre.0" -source = "git+https://github.com/tari-project/tari.git?branch=development#47b48770f84e05c3dce1926d0a8d21eee4ccfe21" +version = "1.9.0-pre.0" +source = "git+https://github.com/tari-project/tari.git?branch=development#d22ef6582e9a671577efc419e5d121c384972aad" dependencies = [ "anyhow", "fs2", @@ -3354,8 +3733,8 @@ dependencies = [ [[package]] name = "tari_script" -version = "1.8.0-pre.0" -source = "git+https://github.com/tari-project/tari.git?branch=development#47b48770f84e05c3dce1926d0a8d21eee4ccfe21" +version = "1.9.0-pre.0" +source = "git+https://github.com/tari-project/tari.git?branch=development#d22ef6582e9a671577efc419e5d121c384972aad" dependencies = [ "blake2", "borsh", @@ -3372,8 +3751,8 @@ dependencies = [ [[package]] name = "tari_service_framework" -version = "1.8.0-pre.0" -source = "git+https://github.com/tari-project/tari.git?branch=development#47b48770f84e05c3dce1926d0a8d21eee4ccfe21" +version = "1.9.0-pre.0" +source = "git+https://github.com/tari-project/tari.git?branch=development#d22ef6582e9a671577efc419e5d121c384972aad" dependencies = [ "anyhow", "async-trait", @@ -3387,16 +3766,16 @@ dependencies = [ [[package]] name = "tari_shutdown" -version = "1.8.0-pre.0" -source = "git+https://github.com/tari-project/tari.git?branch=development#47b48770f84e05c3dce1926d0a8d21eee4ccfe21" +version = "1.9.0-pre.0" +source = "git+https://github.com/tari-project/tari.git?branch=development#d22ef6582e9a671577efc419e5d121c384972aad" dependencies = [ "futures 0.3.31", ] [[package]] name = "tari_storage" -version = "1.8.0-pre.0" -source = "git+https://github.com/tari-project/tari.git?branch=development#47b48770f84e05c3dce1926d0a8d21eee4ccfe21" +version = "1.9.0-pre.0" +source = "git+https://github.com/tari-project/tari.git?branch=development#d22ef6582e9a671577efc419e5d121c384972aad" dependencies = [ "bincode", "lmdb-zero", @@ -3407,8 +3786,8 @@ dependencies = [ [[package]] name = "tari_test_utils" -version = "1.8.0-pre.0" -source = "git+https://github.com/tari-project/tari.git?branch=development#47b48770f84e05c3dce1926d0a8d21eee4ccfe21" +version = "1.9.0-pre.0" +source = "git+https://github.com/tari-project/tari.git?branch=development#d22ef6582e9a671577efc419e5d121c384972aad" dependencies = [ "futures 0.3.31", "rand", @@ -3439,9 +3818,9 @@ dependencies = [ [[package]] name = "tempfile" -version = "3.13.0" +version = "3.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f0f2c9fc62d0beef6951ccffd757e241266a2c833136efbe35af6cd2567dca5b" +checksum = "28cce251fcbc87fac86a866eeb0d6c2d536fc16d06f184bb61aeae11aa4cee0c" dependencies = [ "cfg-if", "fastrand", @@ -3461,22 +3840,22 @@ dependencies = [ [[package]] name = "thiserror" -version = "1.0.65" +version = "1.0.69" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5d11abd9594d9b38965ef50805c5e469ca9cc6f197f883f717e0269a3057b3d5" +checksum = "b6aaf5339b578ea85b50e080feb250a3e8ae8cfcdff9a461c9ec2904bc923f52" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.65" +version = "1.0.69" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ae71770322cbd277e69d762a16c444af02aa0575ac0d174f0b9562d3b37f8602" +checksum = "4fee6c4efc90059e10f81e6d42c60a18f76588c3d74cb83a0b242a2b6c7504c1" dependencies = [ "proc-macro2", "quote", - "syn 2.0.85", + "syn 2.0.89", ] [[package]] @@ -3539,6 +3918,16 @@ dependencies = [ "crunchy", ] +[[package]] +name = "tinystr" +version = "0.7.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9117f5d4db391c1cf6927e7bea3db74b9a1c1add8f7eda9ffd5364f40f57b82f" +dependencies = [ + "displaydoc", + "zerovec", +] + [[package]] name = "tinyvec" version = "1.8.0" @@ -3556,9 +3945,9 @@ checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" [[package]] name = "tokio" -version = "1.41.0" +version = "1.41.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "145f3413504347a2be84393cc8a7d2fb4d863b375909ea59f2158261aa258bbb" +checksum = "22cfb5bee7a6a52939ca9224d6ac897bb669134078daa8735560897f69de4d33" dependencies = [ "backtrace", "bytes 1.8.0", @@ -3580,7 +3969,7 @@ checksum = "693d596312e88961bc67d7f1f97af8a70227d9f90c31bba5806eec004978d752" dependencies = [ "proc-macro2", "quote", - "syn 2.0.85", + "syn 2.0.89", ] [[package]] @@ -3720,7 +4109,7 @@ dependencies = [ "prost-build 0.13.3", "prost-types 0.13.3", "quote", - "syn 2.0.85", + "syn 2.0.89", ] [[package]] @@ -3790,7 +4179,7 @@ checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.85", + "syn 2.0.89", ] [[package]] @@ -3835,6 +4224,18 @@ dependencies = [ "static_assertions", ] +[[package]] +name = "uint" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "909988d098b2f738727b161a106cfc7cab00c539c2687a8836f8e565976fb53e" +dependencies = [ + "byteorder", + "crunchy", + "hex", + "static_assertions", +] + [[package]] name = "unicode-bidi" version = "0.3.17" @@ -3843,9 +4244,9 @@ checksum = "5ab17db44d7388991a428b2ee655ce0c212e862eff1768a455c58f9aad6e7893" [[package]] name = "unicode-ident" -version = "1.0.13" +version = "1.0.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e91b56cd4cadaeb79bbf1a5645f6b4f8dc5bde8834ad5894a8db35fda9efa1fe" +checksum = "adb9e6ca4f869e1180728b7950e35922a7fc6397f7b641499e8f3ef06e50dc83" [[package]] name = "unicode-normalization" @@ -3913,21 +4314,45 @@ checksum = "8ecb6da28b8a351d773b68d5825ac39017e680750f980f3a1a85cd8dd28a47c1" [[package]] name = "url" -version = "2.5.2" +version = "2.5.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "22784dbdf76fdde8af1aeda5622b546b422b6fc585325248a2bf9f5e41e94d6c" +checksum = "8d157f1b96d14500ffdc1f10ba712e780825526c03d9a49b4d0324b0d9113ada" dependencies = [ "form_urlencoded", - "idna", + "idna 1.0.3", "percent-encoding", ] +[[package]] +name = "utf16_iter" +version = "1.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c8232dd3cdaed5356e0f716d285e4b40b932ac434100fe9b7e0e8e935b9e6246" + +[[package]] +name = "utf8_iter" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6c140620e7ffbb22c2dee59cafe6084a59b5ffc27a8859a5f0d494b5d52b6be" + +[[package]] +name = "utf8parse" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "06abde3611657adf66d383f00b093d7faecc7fa57071cce2578660c9f1010821" + [[package]] name = "vcpkg" version = "0.2.15" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426" +[[package]] +name = "vec_map" +version = "0.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f1bddf1187be692e79c5ffeab891132dfb0f236ed36a43c7ed39f1165ee20191" + [[package]] name = "version_check" version = "0.9.5" @@ -3971,7 +4396,7 @@ dependencies = [ "once_cell", "proc-macro2", "quote", - "syn 2.0.85", + "syn 2.0.89", "wasm-bindgen-shared", ] @@ -3993,7 +4418,7 @@ checksum = "26c6ab57572f7a24a4985830b120de1594465e5d500f24afe89e16b4e833ef68" dependencies = [ "proc-macro2", "quote", - "syn 2.0.85", + "syn 2.0.89", "wasm-bindgen-backend", "wasm-bindgen-shared", ] @@ -4016,9 +4441,9 @@ dependencies = [ [[package]] name = "webpki-roots" -version = "0.26.6" +version = "0.26.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "841c67bff177718f1d4dfefde8d8f0e78f9b6589319ba88312f567fc5841a958" +checksum = "5d642ff16b7e79272ae451b7322067cdc17cadf68c23264be9d94a32319efe7e" dependencies = [ "rustls-pki-types", ] @@ -4239,6 +4664,18 @@ dependencies = [ "windows-sys 0.48.0", ] +[[package]] +name = "write16" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d1890f4022759daae28ed4fe62859b1236caebfc61ede2f63ed4e695f3f6d936" + +[[package]] +name = "writeable" +version = "0.5.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e9df38ee2d2c3c5948ea468a8406ff0db0b29ae1ffde1bcf20ef305bcc95c51" + [[package]] name = "wyz" version = "0.5.1" @@ -4250,9 +4687,9 @@ dependencies = [ [[package]] name = "yamux" -version = "0.13.3" +version = "0.13.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a31b5e376a8b012bee9c423acdbb835fc34d45001cfa3106236a624e4b738028" +checksum = "17610762a1207ee816c6fadc29220904753648aba0a9ed61c7b8336e80a559c4" dependencies = [ "futures 0.3.31", "log", @@ -4273,6 +4710,30 @@ dependencies = [ "time", ] +[[package]] +name = "yoke" +version = "0.7.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6c5b1314b079b0930c31e3af543d8ee1757b1951ae1e1565ec704403a7240ca5" +dependencies = [ + "serde", + "stable_deref_trait", + "yoke-derive", + "zerofrom", +] + +[[package]] +name = "yoke-derive" +version = "0.7.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "28cc31741b18cb6f1d5ff12f5b7523e3d6eb0852bbbad19d73905511d9849b95" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.89", + "synstructure 0.13.1", +] + [[package]] name = "zerocopy" version = "0.7.35" @@ -4291,7 +4752,28 @@ checksum = "fa4f8080344d4671fb4e831a13ad1e68092748387dfc4f55e356242fae12ce3e" dependencies = [ "proc-macro2", "quote", - "syn 2.0.85", + "syn 2.0.89", +] + +[[package]] +name = "zerofrom" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "91ec111ce797d0e0784a1116d0ddcdbea84322cd79e5d5ad173daeba4f93ab55" +dependencies = [ + "zerofrom-derive", +] + +[[package]] +name = "zerofrom-derive" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0ea7b4a3637ea8669cedf0f1fd5c286a17f3de97b8dd5a70a6c167a1730e63a5" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.89", + "synstructure 0.13.1", ] [[package]] @@ -4311,5 +4793,27 @@ checksum = "ce36e65b0d2999d2aafac989fb249189a141aee1f53c612c1f37d72631959f69" dependencies = [ "proc-macro2", "quote", - "syn 2.0.85", + "syn 2.0.89", +] + +[[package]] +name = "zerovec" +version = "0.10.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "aa2b893d79df23bfb12d5461018d408ea19dfafe76c2c7ef6d4eba614f8ff079" +dependencies = [ + "yoke", + "zerofrom", + "zerovec-derive", +] + +[[package]] +name = "zerovec-derive" +version = "0.10.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6eafa6dfb17584ea3e2bd6e76e0cc15ad7af12b09abdd1ca55961bed9b1063c6" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.89", ] diff --git a/Cargo.toml b/Cargo.toml index c7bc954..84ed9f1 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -4,6 +4,17 @@ name = "tari-grpc-bridge" version = "0.1.0" [dependencies] -anyhow = "1.0" +# TODO: Dependencies for 'hickory-client', 'hickory-resolver' and 'hickory-proto' have been fixed in the 'cargo.lock' +# file, as there have been an interface change between versions '0.25.0-alpha.2' and '0.25.0-alpha.3'. Update the +# lock file once 'tari-project' is updated. minotari_node_grpc_client = {git = "https://github.com/tari-project/tari.git", branch = "development"} +tari_common_types = {git = "https://github.com/tari-project/tari.git", branch = "development"} + +anyhow = "1.0" +chrono = "0.4.38" +env_logger = "0.11.5" +log = { version = "0.4.8", features = ["std"] } +primitive-types = { version = "0.13.1", features = ["serde"] } +structopt = "0.3.26" tokio = {version = "1", features = ["full"]} +tonic = "0.12.3" diff --git a/rust-toolchain.toml b/rust-toolchain.toml new file mode 100644 index 0000000..e814b4c --- /dev/null +++ b/rust-toolchain.toml @@ -0,0 +1,19 @@ +# So, you want to update the Rust toolchain... + +# Besides making sure the code compiles (duh) and the tests/clippy pass (obviously) +# Please note that you'll have to update all the toolchain references in the codebase! +# AND build new docker images for: +# - rust_tari-build-with-deps +# - rust-ndk +# AND update the action-buildlibs dockerfile. + + +# Hours spent updating the Rust Toolchain = 12 +# other places to check: +# - the CI files in .github folder +# - the Makefile in base_layer/key_manager/Makefile +[toolchain] +#channel = "nightly-2024-11-11" +channel = "nightly-2024-07-07" +#channel = "nightly" +#channel = "stable" diff --git a/src/main.rs b/src/main.rs index 197d36f..e0f28e2 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,47 +1,608 @@ -use core::num; +// Copyright 2021. The Tari Project +// +// Redistribution and use in source and binary forms, with or without modification, are permitted provided that the +// following conditions are met: +// +// 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following +// disclaimer. +// +// 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the +// following disclaimer in the documentation and/or other materials provided with the distribution. +// +// 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote +// products derived from this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, +// INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +// WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE +// USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. use anyhow::Error; +use log::LevelFilter::{ + Debug as DebugL, Error as ErrorL, Info as InfoL, Trace as TraceL, Warn as WarnL, +}; +use log::*; +use minotari_node_grpc_client::grpc::base_node_client::BaseNodeClient; +use minotari_node_grpc_client::grpc::{BlockHeader, ListHeadersRequest, MetaData}; use minotari_node_grpc_client::{ - grpc::{Empty, GetBlocksRequest, SubmitBlockRequest}, + grpc::{Empty, GetBlocksRequest}, BaseNodeGrpcClient, }; +use primitive_types::U256; +use std::cmp::{max, min}; +use std::fs::File; +use std::io::Write; +use std::str::FromStr; +use std::{env, fs}; +use structopt::StructOpt; +use tari_common_types::types::FixedHash; +use tokio::sync::watch; +use tokio::sync::watch::{Receiver, Sender}; +use tokio::time::{Duration, MissedTickBehavior}; +use tokio::{signal, time}; +use tonic::transport::Channel; -#[tokio::main] -async fn main() -> Result<(), Error> { - let client_source = "http://localhost:18142"; - let client_dest = "http://localhost:18143"; +const LOG_SERVICE: &str = "grp_bridge::service"; +const LOG_UPDATE: &str = "grp_bridge::update"; +const LOG_CHAIN_SPLIT: &str = "grp_bridge::chain_split"; + +#[derive(StructOpt, Debug)] +struct CommandLineArgs { + #[structopt( + long, + short = "c", + default_value = "10", + help = "The number of seconds between sync attempts" + )] + cadence_seconds: u64, + + #[structopt( + long, + default_value = "localhost", + help = "The IP address of the first base node" + )] + ip1: String, + + #[structopt( + long, + default_value = "localhost", + help = "The IP address of the second base node" + )] + ip2: String, + + #[structopt( + long, + short = "1", + help = "The gRPC port number of the first base node" + )] + port1: String, + + #[structopt( + long, + short = "2", + help = "The gRPC port number of the second base node" + )] + port2: String, + + #[structopt( + long, + default_value = "service1 on ", + help = "An alias name for the first service" + )] + alias1: String, + + #[structopt( + long, + default_value = "service2 on ", + help = "An alias name for the second service" + )] + alias2: String, - let mut gclient_source = BaseNodeGrpcClient::connect(client_source).await?; - let mut gclient_dest = BaseNodeGrpcClient::connect(client_dest).await?; + #[structopt( + long, + short = "v", + help = "Validate the chain with headers, otherwise just use the tip information" + )] + validate_with_headers: bool, - let tip_height = gclient_dest.get_tip_info(Empty {}).await?; + #[structopt( + long, + short = "h", + default_value = "100", + help = "The initial number of headers to fetch from the other base node below its chain tip to find a chain split" + )] + initial_headers_back: u64, - let dest_height = tip_height.into_inner().metadata.unwrap().best_block_height; + #[structopt(long, short = "g", default_value = "info")] + log_level: String, +} + +#[derive(Clone)] +struct SyncData { + last_synced_header: Option, +} + +impl SyncData { + fn new() -> Self { + SyncData { + last_synced_header: Default::default(), + } + } +} + +async fn get_tip_info(client: &mut BaseNodeGrpcClient) -> Result, Error> { + let tip_info = client.get_tip_info(Empty {}).await?; + Ok(tip_info.into_inner().metadata) +} - let tip_height = gclient_source.get_tip_info(Empty {}).await?; - let source_height = tip_height.into_inner().metadata.unwrap().best_block_height; +async fn fetch_and_submit_blocks( + this_client: &mut BaseNodeGrpcClient, + other_client: &mut BaseNodeGrpcClient, + client_name: &str, + sync_data: &mut SyncData, + validate_with_headers: bool, + initial_headers_back: u64, + receiver: Receiver<()>, +) -> Result<(), Error> { + // Fetch and compare meta data + let this_meta_data = if let Some(data) = get_tip_info(this_client).await? { + data + } else { + warn!(target: LOG_UPDATE, "Service '{}' - no tip info for this base node", client_name); + return Ok(()); + }; + let this_accumulated_difficulty = U256::from_big_endian(&this_meta_data.accumulated_difficulty); + debug!( + target: LOG_UPDATE, + "Service '{}' - this base node tip height: {}, hash: {}, accumulated difficulty: {}", + client_name, + this_meta_data.best_block_height, + FixedHash::try_from(this_meta_data.best_block_hash.clone()).unwrap_or(FixedHash::zero()), + this_accumulated_difficulty, + ); + let other_meta_data = if let Some(data) = get_tip_info(other_client).await? { + data + } else { + warn!(target: LOG_UPDATE, "Service '{}' - no tip info for other base node", client_name); + return Ok(()); + }; + let other_accumulated_difficulty = + U256::from_big_endian(&other_meta_data.accumulated_difficulty); + debug!( + target: LOG_UPDATE, + "Service '{}' - other base node tip height: {}, hash: {}, accumulated difficulty: {}", + client_name, + other_meta_data.best_block_height, + FixedHash::try_from(other_meta_data.best_block_hash.clone()).unwrap_or(FixedHash::zero()), + other_accumulated_difficulty, + ); + let last_height = sync_data + .last_synced_header + .as_ref() + .map(|h| h.height) + .unwrap_or(0); + let last_block = sync_data + .last_synced_header + .as_ref() + .map(|h| FixedHash::try_from(h.hash.clone()).unwrap_or(FixedHash::zero())) + .unwrap_or(FixedHash::zero()); + info!(target: LOG_UPDATE, "Service '{}' - last synced {}, {}", client_name, last_height, last_block); - let mut num_blocks = 0; - for height in dest_height.saturating_sub(20)..source_height { - dbg!(height); - let mut block_stream = gclient_source + if this_meta_data.best_block_hash == other_meta_data.best_block_hash { + info!(target: LOG_UPDATE, "Service '{}' - nothing to do here, we are synced", client_name); + return Ok(()); + } else if this_accumulated_difficulty >= other_accumulated_difficulty { + info!(target: LOG_UPDATE, "Service '{}' - nothing to do here, we are ahead (or equal)", client_name); + return Ok(()); + } + + // Fetch headers from the other client + let last_synced_header = { sync_data.last_synced_header.clone() }; + let headers_back = if let Some(header) = last_synced_header { + max( + this_meta_data + .best_block_height + .saturating_sub(header.height), + 5, + ) + } else { + initial_headers_back + }; + debug!(target: LOG_UPDATE, "Service '{}' - headers_back {}", client_name, headers_back); + + let mut other_headers = Vec::new(); + if validate_with_headers { + let num_other_headers = other_meta_data + .best_block_height + .saturating_sub(this_meta_data.best_block_height) + .saturating_add(headers_back) as usize; + let mut other_headers_stream = other_client + .list_headers(ListHeadersRequest { + from_height: other_meta_data.best_block_height, + num_headers: num_other_headers as u64, + sorting: 0, + }) + .await? + .into_inner(); + while let Some(header) = other_headers_stream.message().await? { + if receiver.has_changed()? { + return Ok(()); + } + let header = header.header.unwrap(); + other_headers.push(header.clone()); + trace!( + target: LOG_UPDATE, + "Service '{}' - received other base node header {}, {}", + client_name, header.height, FixedHash::try_from(header.hash).unwrap_or(FixedHash::zero()) + ); + } + debug!(target: LOG_UPDATE, "Service '{}' - streamed {} other base node headers", client_name, other_headers.len()); + } + + // See if our best header or one of our parent headers is in theirs, otherwise just fetch from a lower height + let mut missing_blocks = vec![]; + if validate_with_headers { + missing_blocks = if other_headers + .iter() + .any(|h| h.hash == this_meta_data.best_block_hash) + { + debug!(target: LOG_UPDATE, "Service '{}' - our best header is in the other chain", client_name); + (this_meta_data.best_block_height..other_meta_data.best_block_height + 1) + .collect::>() + } else if let Some(height) = find_chain_split( + other_headers, + this_client, + this_meta_data.clone(), + client_name, + ) + .await? + { + debug!(target: LOG_UPDATE, "Service '{}' - chain split found at height {}", client_name, height); + (height..other_meta_data.best_block_height + 1).collect::>() + } else { + vec![] + }; + } + if missing_blocks.is_empty() { + missing_blocks = if this_meta_data.best_block_height <= other_meta_data.best_block_height { + debug!(target: LOG_UPDATE, "Service '{}' - our best block height <= theirs", client_name); + (this_meta_data + .best_block_height + .saturating_sub(headers_back)..other_meta_data.best_block_height + 1) + .collect::>() + } else { + debug!(target: LOG_UPDATE, "Service '{}' - our best block height > theirs", client_name); + (other_meta_data + .best_block_height + .saturating_sub(headers_back)..other_meta_data.best_block_height + 1) + .collect::>() + }; + } + + // Stream and submit blocks - just one at a time + debug!( + target: LOG_UPDATE, "Service '{}' - attempting to stream blocks {} to {}", + client_name, missing_blocks[0], missing_blocks.last().unwrap() + ); + for block_number in &missing_blocks { + if receiver.has_changed()? { + return Ok(()); + } + let mut block_stream = other_client .get_blocks(GetBlocksRequest { - heights: vec![height], + heights: vec![*block_number], }) .await? .into_inner(); while let Some(resp) = block_stream.message().await? { - dbg!("Block received"); + trace!(target: LOG_UPDATE, "Service '{}' - received block {} from other base node", client_name, block_number); let block = resp.block.unwrap(); - let submit_response = gclient_dest.submit_block(block).await?; - dbg!(submit_response); - num_blocks += 1; - if num_blocks > 2000 { + let header = block.header.clone().unwrap(); + let response = match this_client.submit_block(block).await { + Ok(val) => val.into_inner(), + Err(err) => { + warn!( + target: LOG_UPDATE, + "Service '{}' - error submitting block {} to this base node", + client_name, block_number + ); + return Err(err.into()); + } + }; + trace!( + target: LOG_UPDATE, + "Service '{}' - submitted block {} to this base node (hash response {})", + client_name, block_number, FixedHash::try_from(response.block_hash).unwrap_or(FixedHash::zero()) + ); + sync_data.last_synced_header = Some(header); + } + } + info!(target: LOG_UPDATE, "Service '{}' - synced {} blocks", client_name, missing_blocks.len()); + + Ok(()) +} + +async fn find_chain_split( + other_headers: Vec, + this_client: &mut BaseNodeGrpcClient, + this_meta_data: MetaData, + client_name: &str, +) -> Result, Error> { + info!(target: LOG_CHAIN_SPLIT, "Service '{}' - find chain split", client_name); + let mut from_height = this_meta_data.best_block_height; + const CHUNKS: u64 = 100; + while from_height > 0 { + let mut this_headers_stream = this_client + .list_headers(ListHeadersRequest { + from_height, + num_headers: min(from_height, CHUNKS), + sorting: 0, + }) + .await? + .into_inner(); + debug!( + target: LOG_CHAIN_SPLIT, "Service '{}' - attempting to stream {} local headers from height {}", + client_name, min(from_height, CHUNKS), from_height + ); + while let Some(header) = this_headers_stream.message().await? { + if let Some(split_header) = other_headers + .iter() + .find(|h| h.hash == header.header.as_ref().unwrap().hash) + { + debug!(target: LOG_CHAIN_SPLIT, "Service '{}' - found chain split", client_name); + return Ok(Some(split_header.height)); + } + } + from_height = from_height.saturating_sub(CHUNKS); + } + Ok(None) +} + +fn log_and_print(log_level: LevelFilter, msg: &str, add_newline: bool) { + match log_level { + TraceL => trace!(target: LOG_SERVICE, "{}", msg), + DebugL => debug!(target: LOG_SERVICE, "{}", msg), + InfoL => info!(target: LOG_SERVICE, "{}", msg), + WarnL => warn!(target: LOG_SERVICE, "{}", msg), + ErrorL => error!(target: LOG_SERVICE, "{}", msg), + _ => {} + } + if add_newline { + println!("\n{}", msg); + } else { + println!("{}", msg); + } +} + +#[allow(clippy::too_many_arguments)] +async fn sync_service( + this_client_url: String, + other_client_url: String, + cadence: u64, + client_name: String, + validate_with_headers: bool, + initial_headers_back: u64, + mut shutdown_rx: watch::Receiver<()>, + connected_tx: Sender<()>, +) -> Result<(), Error> { + let mut sync_data = SyncData::new(); + info!(target: LOG_SERVICE, "Service '{}' starting", client_name); + let mut count = 0u64; + loop { + tokio::select! { + _ = shutdown_rx.changed() => { + log_and_print( + InfoL, + &format!("Shutdown signal for '{}' received before connecting clients", client_name), + false + ); return Ok(()); - // dbg!(num_blocks); + } + + result = async { + let this_client = BaseNodeGrpcClient::connect(this_client_url.clone()).await; + let other_client = BaseNodeGrpcClient::connect(other_client_url.clone()).await; + match (this_client, other_client) { + (Ok(this_client), Ok(other_client)) => { + log_and_print( + InfoL, + &format!( + "Service '{}' connected to {} and {}", + client_name, this_client_url.clone(), other_client_url.clone() + ), + true + ); + Ok::<(BaseNodeClient, BaseNodeClient), Error>((this_client, other_client)) + }, + (Ok(_), Err(_)) => { + log_and_print( + WarnL, + &format!( + "Service '{}' could not connect to {} ... ('Ctrl-C' to quit)", + client_name, other_client_url.clone() + ), + false + ); + Err(anyhow::anyhow!("Failed to connect to clients")) + }, + (Err(_), Ok(_)) => { + log_and_print( + WarnL, + &format!( + "Service '{}' could not connect to {} ... ('Ctrl-C' to quit)", + client_name, this_client_url.clone() + ), + false + ); + Err(anyhow::anyhow!("Failed to connect to clients")) + }, + _ => { + log_and_print( + WarnL, + &format!( + "Service '{}' could not connect to {} or {} ... ('Ctrl-C' to quit)", + client_name, this_client_url.clone(), other_client_url.clone() + ), + false + ); + Err(anyhow::anyhow!("Failed to connect to clients")) + }, + } + } => { + match result { + Ok((mut this_client, mut other_client)) => { + let _ = connected_tx.send(()); + let mut interval = time::interval(Duration::from_secs(cadence)); + interval.set_missed_tick_behavior(MissedTickBehavior::Delay); + tokio::pin!(interval); + loop { + count += 1; + debug!(target: LOG_SERVICE, "Service '{}' sync loop {}", client_name, count); + tokio::select! { + _ = interval.tick() => if let Err(e) = fetch_and_submit_blocks( + &mut this_client, + &mut other_client, + &client_name, + &mut sync_data, + validate_with_headers, + initial_headers_back, + shutdown_rx.clone() + ).await { + log_and_print( + ErrorL, &format!("Service '{}' error: {}", client_name, e), false + ); + // Get new client connections + break; + }, + _ = shutdown_rx.changed() => { + log_and_print( + InfoL, &format!("Service '{}' shutdown signal received", client_name), false + ); + return Ok(()); + } + } + } + } + Err(_) => { + tokio::time::sleep(Duration::from_millis(2500)).await; + } + } } } } +} + +fn init_logger(log_level: LevelFilter) -> Result<(), Box> { + let log_path = env::current_exe()? + .parent() + .ok_or_else(|| std::io::Error::new(std::io::ErrorKind::Other, "no exe path"))? + .canonicalize()? + .join("log"); + let log_file = log_path.join("bridge.log"); + println!("Logging data to '{}'", log_file.display()); + if !log_path.exists() { + fs::create_dir(&log_path)?; + } + let file = File::create(log_file)?; + + env_logger::Builder::new() + .format(move |buf, record| { + let timestamp = chrono::Local::now().format("%Y-%m-%d %H:%M:%S%.3f"); + writeln!(buf, "{} {} - {}", timestamp, record.level(), record.args()) + }) + .filter(Some("grp_bridge"), log_level) + .format_timestamp_millis() + .target(env_logger::Target::Pipe(Box::new(file))) + .init(); + + Ok(()) +} + +#[tokio::main] +async fn main() -> Result<(), Error> { + println!(); + println!("gRPC Bridge Service Running - 'Ctrl-C' to quit"); + println!(); + + let args = CommandLineArgs::from_args(); + init_logger( + LevelFilter::from_str(&args.log_level) + .map_err(|_e| { + let levels = LevelFilter::iter() + .map(|l| l.to_string()) + .collect::>() + .join(", "); + format!("Invalid log level, choose from '{}'", levels) + }) + .expect(""), + ) + .expect("Failed to initialize logger"); + + let (shutdown_tx, shutdown_rx) = watch::channel(()); + let client1_url = format!("http://{}:{}", args.ip1, args.port1); + let client2_url = format!("http://{}:{}", args.ip2, args.port2); + let alias1 = if args.alias1.is_empty() || args.alias1 == "service1 on " { + format!("service1 on {}", args.port1) + } else { + args.alias1.clone() + }; + let alias2 = if args.alias2.is_empty() || args.alias2 == "service2 on " { + format!("service2 on {}", args.port2) + } else { + args.alias2.clone() + }; + + let (client1_connected_tx, mut client1_connected_rx) = watch::channel(()); + let service1 = sync_service( + client1_url.clone(), + client2_url.clone(), + args.cadence_seconds, + alias1, + args.validate_with_headers, + args.initial_headers_back, + shutdown_rx.clone(), + client1_connected_tx, + ); + + let (client2_connected_tx, mut client2_connected_rx) = watch::channel(()); + let service2 = sync_service( + client2_url, + client1_url, + args.cadence_seconds, + alias2, + args.validate_with_headers, + args.initial_headers_back, + shutdown_rx, + client2_connected_tx, + ); + + let handle1 = tokio::spawn(service1); + if client1_connected_rx.changed().await.is_ok() { + println!(); + println!("Spawned service for {}", args.port1); + } + let handle2 = tokio::spawn(service2); + if client2_connected_rx.changed().await.is_ok() { + println!(); + println!("Spawned service for {}", args.port2); + } + + // Wait for a shutdown signal (e.g., Ctrl+C) + println!(); + println!("'Ctrl-C' to quit"); + println!(); + signal::ctrl_c().await?; + println!("Shutdown signal received, shutting down services..."); + println!(); + let _ = shutdown_tx.send(()); + + // Await the completion of the services + let _ = handle1.await?; + let _ = handle2.await?; + println!(); Ok(()) }