From 319db482ad5a15306d020f696859afdc43ae1257 Mon Sep 17 00:00:00 2001 From: dkf Date: Tue, 9 Jul 2024 13:51:31 +0100 Subject: [PATCH 1/5] feat: add log4rs logger --- Cargo.lock | 471 ++++++++++++++++++++++++----------- Cargo.toml | 22 +- log4rs_sample.yml | 53 ++++ src/main.rs | 39 ++- src/server/grpc/base_node.rs | 56 +---- src/server/grpc/p2pool.rs | 29 +-- src/server/p2p/client.rs | 5 +- src/server/p2p/p2p.rs | 31 +-- src/server/p2p/peer_store.rs | 2 +- src/server/server.rs | 11 +- src/sharechain/in_memory.rs | 12 +- 11 files changed, 463 insertions(+), 268 deletions(-) create mode 100644 log4rs_sample.yml diff --git a/Cargo.lock b/Cargo.lock index 7624ca12..d0c9c1e1 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -202,7 +202,7 @@ checksum = "7378575ff571966e99a744addeff0bff98b8ada0dedf1956d59e634db95eaac1" dependencies = [ "proc-macro2", "quote", - "syn 2.0.68", + "syn 2.0.69", "synstructure 0.13.1", ] @@ -214,7 +214,7 @@ checksum = "7b18050c2cd6fe86c3a76584ef5e0baf286d038cda203eb6223df2cc413565f7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.68", + "syn 2.0.69", ] [[package]] @@ -266,18 +266,18 @@ checksum = "16e62a023e7c117e27523144c5d2459f4397fcc3cab0085af8e2224f643a0193" dependencies = [ "proc-macro2", "quote", - "syn 2.0.68", + "syn 2.0.69", ] [[package]] name = "async-trait" -version = "0.1.80" +version = "0.1.81" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c6fa2087f2753a7da8cc1c0dbfcf89579dd57458e36769de5ac750b4671737ca" +checksum = "6e0c28dcc82d7c8ead5cb13beb15405b57b8546e93215673ff8ca0349a028107" dependencies = [ "proc-macro2", "quote", - "syn 2.0.68", + "syn 2.0.69", ] [[package]] @@ -517,7 +517,7 @@ dependencies = [ "proc-macro-crate 3.1.0", "proc-macro2", "quote", - "syn 2.0.68", + "syn 2.0.69", "syn_derive", ] @@ -580,9 +580,9 @@ dependencies = [ [[package]] name = "cc" -version = "1.0.104" +version = "1.0.106" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "74b6a57f98764a267ff415d50a25e6e166f3831a5071af4995296ea97d210490" +checksum = "066fce287b1d4eafef758e89e09d724a24808a9196fe9756b8ca90e86d0719a2" [[package]] name = "cfg-if" @@ -641,7 +641,7 @@ dependencies = [ "iana-time-zone", "num-traits", "serde", - "windows-targets 0.52.5", + "windows-targets 0.52.6", ] [[package]] @@ -716,7 +716,7 @@ dependencies = [ "heck 0.5.0", "proc-macro2", "quote", - "syn 2.0.68", + "syn 2.0.69", ] [[package]] @@ -832,6 +832,31 @@ version = "0.8.20" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "22ec99545bb0ed0ea7bb9b8e1e9122ea386ff8a48c0922e43f36d45ab09e0e80" +[[package]] +name = "crossterm" +version = "0.25.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e64e6c0fbe2c17357405f7c758c1ef960fce08bdfb2c03d88d2a18d7e09c4b67" +dependencies = [ + "bitflags 1.3.2", + "crossterm_winapi", + "libc", + "mio", + "parking_lot", + "signal-hook", + "signal-hook-mio", + "winapi", +] + +[[package]] +name = "crossterm_winapi" +version = "0.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "acdd7c62a3665c7f6830a51635d9ac9b23ed385797f70a83bb8bafe9c572ab2b" +dependencies = [ + "winapi", +] + [[package]] name = "crunchy" version = "0.2.2" @@ -885,7 +910,7 @@ checksum = "f46882e17999c6cc590af592290432be3bce0428cb0d5f8b6715e4dc7b383eb3" dependencies = [ "proc-macro2", "quote", - "syn 2.0.68", + "syn 2.0.69", ] [[package]] @@ -909,7 +934,7 @@ dependencies = [ "proc-macro2", "quote", "strsim", - "syn 2.0.68", + "syn 2.0.69", ] [[package]] @@ -920,7 +945,7 @@ checksum = "733cabb43482b1a1b53eee8583c2b9e8684d592215ea83efd305dd31bc2f0178" dependencies = [ "darling_core", "quote", - "syn 2.0.68", + "syn 2.0.69", ] [[package]] @@ -1036,7 +1061,7 @@ dependencies = [ "dsl_auto_type", "proc-macro2", "quote", - "syn 2.0.68", + "syn 2.0.69", ] [[package]] @@ -1056,7 +1081,7 @@ version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "209c735641a413bc68c4923a9d6ad4bcb3ca306b794edaa7eb0b3228a99ffb25" dependencies = [ - "syn 2.0.68", + "syn 2.0.69", ] [[package]] @@ -1070,6 +1095,15 @@ dependencies = [ "subtle", ] +[[package]] +name = "dirs" +version = "4.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ca3aa72a6f96ea37bbc5aa912f6788242832f75369bdfdadcb0e38423f100059" +dependencies = [ + "dirs-sys", +] + [[package]] name = "dirs-next" version = "1.0.2" @@ -1080,6 +1114,17 @@ dependencies = [ "dirs-sys-next", ] +[[package]] +name = "dirs-sys" +version = "0.3.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1b1d1d91c932ef41c0f2663aa8b0ca0342d444d842c06914aa0a7e352d0bada6" +dependencies = [ + "libc", + "redox_users", + "winapi", +] + [[package]] name = "dirs-sys-next" version = "0.1.2" @@ -1099,7 +1144,7 @@ checksum = "97369cbbc041bc366949bc74d34658d6cda5621039731c6310521892a3a20ae0" dependencies = [ "proc-macro2", "quote", - "syn 2.0.68", + "syn 2.0.69", ] [[package]] @@ -1119,7 +1164,7 @@ dependencies = [ "heck 0.5.0", "proc-macro2", "quote", - "syn 2.0.68", + "syn 2.0.69", ] [[package]] @@ -1186,30 +1231,7 @@ dependencies = [ "heck 0.4.1", "proc-macro2", "quote", - "syn 2.0.68", -] - -[[package]] -name = "env_filter" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a009aa4810eb158359dda09d0c87378e4bbb89b5a801f016885a4707ba24f7ea" -dependencies = [ - "log", - "regex", -] - -[[package]] -name = "env_logger" -version = "0.11.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "38b35839ba51819680ba087cd351788c9a3c476841207e0b8cee0b04722343b9" -dependencies = [ - "anstream", - "anstyle", - "env_filter", - "humantime", - "log", + "syn 2.0.69", ] [[package]] @@ -1295,6 +1317,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" @@ -1403,7 +1440,7 @@ checksum = "87750cf4b7a4c0625b1529e4c543c2182106e4dedc60a2a6455e00d212c489ac" dependencies = [ "proc-macro2", "quote", - "syn 2.0.68", + "syn 2.0.69", ] [[package]] @@ -2117,15 +2154,14 @@ dependencies = [ [[package]] name = "libp2p-core" -version = "0.41.2" +version = "0.41.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8130a8269e65a2554d55131c770bdf4bcd94d2b8d4efb24ca23699be65066c05" +checksum = "a5a8920cbd8540059a01950c1e5c96ea8d89eb50c51cd366fc18bdf540a6e48f" dependencies = [ "either", "fnv", "futures 0.3.30", "futures-timer", - "instant", "libp2p-identity", "multiaddr 0.18.1", "multihash 0.19.1", @@ -2142,6 +2178,7 @@ dependencies = [ "tracing", "unsigned-varint 0.8.0", "void", + "web-time", ] [[package]] @@ -2409,7 +2446,7 @@ dependencies = [ "heck 0.5.0", "proc-macro2", "quote", - "syn 2.0.68", + "syn 2.0.69", ] [[package]] @@ -2556,16 +2593,24 @@ checksum = "0816135ae15bd0391cf284eab37e6e3ee0a6ee63d2ceeb659862bd8d0a984ca6" dependencies = [ "anyhow", "arc-swap", + "chrono", "derivative", "fnv", "humantime", + "libc", "log", + "log-mdc", "once_cell", + "parking_lot", + "rand", "serde", "serde-value", + "serde_json", "serde_yaml", "thiserror", + "thread-id", "typemap-ors", + "winapi", ] [[package]] @@ -2666,8 +2711,8 @@ dependencies = [ [[package]] name = "minotari_app_grpc" -version = "1.0.0-pre.14" -source = "git+https://github.com/ksrichard/tari.git?branch=p2pool#56d65428c1257cd9c750c4d1c4100e270202a6d5" +version = "1.0.0-pre.15" +source = "git+https://github.com/tari-project/tari.git#cb1eb6383a0887c95f869146b94c0da00f3faffd" dependencies = [ "argon2", "base64 0.13.1", @@ -2696,7 +2741,7 @@ dependencies = [ [[package]] name = "minotari_node_grpc_client" version = "0.1.0" -source = "git+https://github.com/ksrichard/tari.git?branch=p2pool#56d65428c1257cd9c750c4d1c4100e270202a6d5" +source = "git+https://github.com/tari-project/tari.git#cb1eb6383a0887c95f869146b94c0da00f3faffd" dependencies = [ "minotari_app_grpc", ] @@ -2708,15 +2753,16 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a4a650543ca06a924e8b371db273b2756685faae30f8487da1b56505a8f78b0c" dependencies = [ "libc", + "log", "wasi", "windows-sys 0.48.0", ] [[package]] name = "moka" -version = "0.12.7" +version = "0.12.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9e0d88686dc561d743b40de8269b26eaf0dc58781bde087b0984646602021d08" +checksum = "32cf62eb4dd975d2dde76432fb1075c49e3ee2331cf36f1f8fd4b66550d32b6f" dependencies = [ "async-lock", "async-trait", @@ -2857,6 +2903,23 @@ dependencies = [ "unsigned-varint 0.7.2", ] +[[package]] +name = "native-tls" +version = "0.2.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a8614eb2c83d59d1c8cc974dd3f920198647674a0a035e1af1fa58707e317466" +dependencies = [ + "libc", + "log", + "openssl", + "openssl-probe", + "openssl-sys", + "schannel", + "security-framework", + "security-framework-sys", + "tempfile", +] + [[package]] name = "netlink-packet-core" version = "0.4.2" @@ -2989,7 +3052,7 @@ checksum = "ed3955f1a9c7c0c15e092f9c887db08b1fc683305fdf6eb6684f22555355e202" dependencies = [ "proc-macro2", "quote", - "syn 2.0.68", + "syn 2.0.69", ] [[package]] @@ -3064,6 +3127,50 @@ version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c08d65885ee38876c4f86fa503fb49d7b507c2b62552df7c70b2fce627e06381" +[[package]] +name = "openssl" +version = "0.10.64" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "95a0481286a310808298130d22dd1fef0fa571e05a8f44ec801801e84b216b1f" +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.69", +] + +[[package]] +name = "openssl-probe" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf" + +[[package]] +name = "openssl-sys" +version = "0.9.102" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c597637d56fbc83893a35eb0dd04b2b8e7a50c91e64e9493e398b5df4fb45fa2" +dependencies = [ + "cc", + "libc", + "pkg-config", + "vcpkg", +] + [[package]] name = "ordered-float" version = "2.10.1" @@ -3125,7 +3232,7 @@ dependencies = [ "libc", "redox_syscall", "smallvec", - "windows-targets 0.52.5", + "windows-targets 0.52.6", ] [[package]] @@ -3220,7 +3327,7 @@ checksum = "2f38a4412a78282e09a2cf38d195ea5420d15ba0602cb375210efbc877243965" dependencies = [ "proc-macro2", "quote", - "syn 2.0.68", + "syn 2.0.69", ] [[package]] @@ -3401,7 +3508,7 @@ checksum = "440f724eba9f6996b75d63681b0a92b06947f1457076d503a4d2e2c8f56442b8" dependencies = [ "proc-macro2", "quote", - "syn 2.0.68", + "syn 2.0.69", ] [[package]] @@ -3821,7 +3928,7 @@ dependencies = [ "once_cell", "ring 0.17.8", "rustls-pki-types", - "rustls-webpki 0.102.4", + "rustls-webpki 0.102.5", "subtle", "zeroize", ] @@ -3862,9 +3969,9 @@ dependencies = [ [[package]] name = "rustls-webpki" -version = "0.102.4" +version = "0.102.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ff448f7e92e913c4b7d4c6d8e4540a1724b319b4152b8aef6d4cf8339712b33e" +checksum = "f9a6fccd794a42c2c105b513a2f62bc3fd8f3ba57a4593677ceb0bd035164d78" dependencies = [ "ring 0.17.8", "rustls-pki-types", @@ -3894,6 +4001,15 @@ version = "1.0.18" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f3cb5ba0dc43242ce17de99c180e96db90b235b8a9fdc9543c96d2209116bd9f" +[[package]] +name = "schannel" +version = "0.1.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fbc91545643bcf3a0bbb6569265615222618bdf33ce4ffbbd13c4bbd4c093534" +dependencies = [ + "windows-sys 0.52.0", +] + [[package]] name = "scheduled-thread-pool" version = "0.2.7" @@ -3928,7 +4044,30 @@ dependencies = [ "heck 0.4.1", "proc-macro2", "quote", - "syn 2.0.68", + "syn 2.0.69", +] + +[[package]] +name = "security-framework" +version = "2.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c627723fd09706bacdb5cf41499e95098555af3c3c29d014dc3c458ef6be11c0" +dependencies = [ + "bitflags 2.6.0", + "core-foundation", + "core-foundation-sys", + "libc", + "security-framework-sys", +] + +[[package]] +name = "security-framework-sys" +version = "2.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "317936bbbd05227752583946b9e66d7ce3b489f84e11a94a510b4437fef407d7" +dependencies = [ + "core-foundation-sys", + "libc", ] [[package]] @@ -3939,9 +4078,9 @@ checksum = "61697e0a1c7e512e84a621326239844a24d8207b4669b41bc18b32ea5cbf988b" [[package]] name = "serde" -version = "1.0.203" +version = "1.0.204" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7253ab4de971e72fb7be983802300c30b5a7f0c2e56fab8abfc6a214307c0094" +checksum = "bc76f558e0cbb2a839d37354c575f1dc3fdc6546b5be373ba43d95f231bf7c12" dependencies = [ "serde_derive", ] @@ -3968,13 +4107,13 @@ dependencies = [ [[package]] name = "serde_derive" -version = "1.0.203" +version = "1.0.204" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "500cbc0ebeb6f46627f50f3f5811ccf6bf00643be300b4c3eabc0ef55dc5b5ba" +checksum = "e0cd7e117be63d3c3678776753929474f3b04a43a080c744d6b0ae2a8c28e222" dependencies = [ "proc-macro2", "quote", - "syn 2.0.68", + "syn 2.0.69", ] [[package]] @@ -3996,7 +4135,7 @@ checksum = "6c64451ba24fc7a6a2d60fc75dd9c83c90903b19028d4eff35e88fc1e86564e9" dependencies = [ "proc-macro2", "quote", - "syn 2.0.68", + "syn 2.0.69", ] [[package]] @@ -4050,13 +4189,16 @@ dependencies = [ "async-trait", "blake2", "clap 4.5.8", + "crossterm", "digest", - "env_logger", + "dirs", "libp2p", "log", + "log4rs", "minotari_app_grpc", "minotari_node_grpc_client", "moka", + "native-tls", "serde", "serde_cbor", "tari_common", @@ -4068,6 +4210,27 @@ dependencies = [ "tonic", ] +[[package]] +name = "signal-hook" +version = "0.3.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8621587d4798caf8eb44879d42e56b9a93ea5dcd315a6487c357130095b62801" +dependencies = [ + "libc", + "signal-hook-registry", +] + +[[package]] +name = "signal-hook-mio" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "29ad2e15f37ec9a6cc544097b78a1ec90001e9f71b81338ca39f430adaca99af" +dependencies = [ + "libc", + "mio", + "signal-hook", +] + [[package]] name = "signal-hook-registry" version = "1.4.2" @@ -4260,9 +4423,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.68" +version = "2.0.69" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "901fa70d88b9d6c98022e23b4136f9f3e54e4662c3bc1bd1d84a42a9a0f0c1e9" +checksum = "201fcda3845c23e8212cd466bfebf0bd20694490fc0356ae8e428e0824a915a6" dependencies = [ "proc-macro2", "quote", @@ -4278,7 +4441,7 @@ dependencies = [ "proc-macro-error", "proc-macro2", "quote", - "syn 2.0.68", + "syn 2.0.69", ] [[package]] @@ -4307,7 +4470,7 @@ checksum = "c8af7666ab7b6390ab78131fb5b0fce11d6b7a6951602017c35fa82800708971" dependencies = [ "proc-macro2", "quote", - "syn 2.0.68", + "syn 2.0.69", ] [[package]] @@ -4376,8 +4539,8 @@ dependencies = [ [[package]] name = "tari_common" -version = "1.0.0-pre.14" -source = "git+https://github.com/ksrichard/tari.git?branch=p2pool#56d65428c1257cd9c750c4d1c4100e270202a6d5" +version = "1.0.0-pre.15" +source = "git+https://github.com/tari-project/tari.git#cb1eb6383a0887c95f869146b94c0da00f3faffd" dependencies = [ "anyhow", "blake2", @@ -4402,8 +4565,8 @@ dependencies = [ [[package]] name = "tari_common_sqlite" -version = "1.0.0-pre.14" -source = "git+https://github.com/ksrichard/tari.git?branch=p2pool#56d65428c1257cd9c750c4d1c4100e270202a6d5" +version = "1.0.0-pre.15" +source = "git+https://github.com/tari-project/tari.git#cb1eb6383a0887c95f869146b94c0da00f3faffd" dependencies = [ "diesel", "diesel_migrations", @@ -4416,8 +4579,8 @@ dependencies = [ [[package]] name = "tari_common_types" -version = "1.0.0-pre.14" -source = "git+https://github.com/ksrichard/tari.git?branch=p2pool#56d65428c1257cd9c750c4d1c4100e270202a6d5" +version = "1.0.0-pre.15" +source = "git+https://github.com/tari-project/tari.git#cb1eb6383a0887c95f869146b94c0da00f3faffd" dependencies = [ "base64 0.21.7", "bitflags 2.6.0", @@ -4441,8 +4604,8 @@ dependencies = [ [[package]] name = "tari_comms" -version = "1.0.0-pre.14" -source = "git+https://github.com/ksrichard/tari.git?branch=p2pool#56d65428c1257cd9c750c4d1c4100e270202a6d5" +version = "1.0.0-pre.15" +source = "git+https://github.com/tari-project/tari.git#cb1eb6383a0887c95f869146b94c0da00f3faffd" dependencies = [ "anyhow", "async-trait", @@ -4485,8 +4648,8 @@ dependencies = [ [[package]] name = "tari_comms_dht" -version = "1.0.0-pre.14" -source = "git+https://github.com/ksrichard/tari.git?branch=p2pool#56d65428c1257cd9c750c4d1c4100e270202a6d5" +version = "1.0.0-pre.15" +source = "git+https://github.com/tari-project/tari.git#cb1eb6383a0887c95f869146b94c0da00f3faffd" dependencies = [ "anyhow", "bitflags 2.6.0", @@ -4520,8 +4683,8 @@ dependencies = [ [[package]] name = "tari_comms_rpc_macros" -version = "1.0.0-pre.14" -source = "git+https://github.com/ksrichard/tari.git?branch=p2pool#56d65428c1257cd9c750c4d1c4100e270202a6d5" +version = "1.0.0-pre.15" +source = "git+https://github.com/tari-project/tari.git#cb1eb6383a0887c95f869146b94c0da00f3faffd" dependencies = [ "proc-macro2", "quote", @@ -4530,8 +4693,8 @@ dependencies = [ [[package]] name = "tari_core" -version = "1.0.0-pre.14" -source = "git+https://github.com/ksrichard/tari.git?branch=p2pool#56d65428c1257cd9c750c4d1c4100e270202a6d5" +version = "1.0.0-pre.15" +source = "git+https://github.com/tari-project/tari.git#cb1eb6383a0887c95f869146b94c0da00f3faffd" dependencies = [ "async-trait", "bincode", @@ -4595,9 +4758,9 @@ dependencies = [ [[package]] name = "tari_crypto" -version = "0.20.2" +version = "0.20.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dd8b549b292deddde212f389f345ef58c0bffb552b7e0f561f5504859ca82466" +checksum = "22b761f7cf1754eb2223286c9d437c81737526f393f09f69b2456bf49ba25a5b" dependencies = [ "blake2", "borsh", @@ -4619,13 +4782,13 @@ dependencies = [ [[package]] name = "tari_features" -version = "1.0.0-pre.14" -source = "git+https://github.com/ksrichard/tari.git?branch=p2pool#56d65428c1257cd9c750c4d1c4100e270202a6d5" +version = "1.0.0-pre.15" +source = "git+https://github.com/tari-project/tari.git#cb1eb6383a0887c95f869146b94c0da00f3faffd" [[package]] name = "tari_hashing" -version = "1.0.0-pre.14" -source = "git+https://github.com/ksrichard/tari.git?branch=p2pool#56d65428c1257cd9c750c4d1c4100e270202a6d5" +version = "1.0.0-pre.15" +source = "git+https://github.com/tari-project/tari.git#cb1eb6383a0887c95f869146b94c0da00f3faffd" dependencies = [ "borsh", "digest", @@ -4634,8 +4797,8 @@ dependencies = [ [[package]] name = "tari_key_manager" -version = "1.0.0-pre.14" -source = "git+https://github.com/ksrichard/tari.git?branch=p2pool#56d65428c1257cd9c750c4d1c4100e270202a6d5" +version = "1.0.0-pre.15" +source = "git+https://github.com/tari-project/tari.git#cb1eb6383a0887c95f869146b94c0da00f3faffd" dependencies = [ "argon2", "async-trait", @@ -4667,8 +4830,8 @@ dependencies = [ [[package]] name = "tari_mmr" -version = "1.0.0-pre.14" -source = "git+https://github.com/ksrichard/tari.git?branch=p2pool#56d65428c1257cd9c750c4d1c4100e270202a6d5" +version = "1.0.0-pre.15" +source = "git+https://github.com/tari-project/tari.git#cb1eb6383a0887c95f869146b94c0da00f3faffd" dependencies = [ "borsh", "digest", @@ -4682,8 +4845,8 @@ dependencies = [ [[package]] name = "tari_p2p" -version = "1.0.0-pre.14" -source = "git+https://github.com/ksrichard/tari.git?branch=p2pool#56d65428c1257cd9c750c4d1c4100e270202a6d5" +version = "1.0.0-pre.15" +source = "git+https://github.com/tari-project/tari.git#cb1eb6383a0887c95f869146b94c0da00f3faffd" dependencies = [ "anyhow", "fs2", @@ -4712,8 +4875,8 @@ dependencies = [ [[package]] name = "tari_script" -version = "1.0.0-pre.14" -source = "git+https://github.com/ksrichard/tari.git?branch=p2pool#56d65428c1257cd9c750c4d1c4100e270202a6d5" +version = "1.0.0-pre.15" +source = "git+https://github.com/tari-project/tari.git#cb1eb6383a0887c95f869146b94c0da00f3faffd" dependencies = [ "blake2", "borsh", @@ -4729,8 +4892,8 @@ dependencies = [ [[package]] name = "tari_service_framework" -version = "1.0.0-pre.14" -source = "git+https://github.com/ksrichard/tari.git?branch=p2pool#56d65428c1257cd9c750c4d1c4100e270202a6d5" +version = "1.0.0-pre.15" +source = "git+https://github.com/tari-project/tari.git#cb1eb6383a0887c95f869146b94c0da00f3faffd" dependencies = [ "anyhow", "async-trait", @@ -4744,16 +4907,16 @@ dependencies = [ [[package]] name = "tari_shutdown" -version = "1.0.0-pre.14" -source = "git+https://github.com/ksrichard/tari.git?branch=p2pool#56d65428c1257cd9c750c4d1c4100e270202a6d5" +version = "1.0.0-pre.15" +source = "git+https://github.com/tari-project/tari.git#cb1eb6383a0887c95f869146b94c0da00f3faffd" dependencies = [ "futures 0.3.30", ] [[package]] name = "tari_storage" -version = "1.0.0-pre.14" -source = "git+https://github.com/ksrichard/tari.git?branch=p2pool#56d65428c1257cd9c750c4d1c4100e270202a6d5" +version = "1.0.0-pre.15" +source = "git+https://github.com/tari-project/tari.git#cb1eb6383a0887c95f869146b94c0da00f3faffd" dependencies = [ "bincode", "lmdb-zero", @@ -4764,8 +4927,8 @@ dependencies = [ [[package]] name = "tari_test_utils" -version = "1.0.0-pre.14" -source = "git+https://github.com/ksrichard/tari.git?branch=p2pool#56d65428c1257cd9c750c4d1c4100e270202a6d5" +version = "1.0.0-pre.15" +source = "git+https://github.com/tari-project/tari.git#cb1eb6383a0887c95f869146b94c0da00f3faffd" dependencies = [ "futures 0.3.30", "rand", @@ -4832,7 +4995,7 @@ checksum = "46c3384250002a6d5af4d114f2845d37b57521033f30d5c3f46c4d70e1197533" dependencies = [ "proc-macro2", "quote", - "syn 2.0.68", + "syn 2.0.69", ] [[package]] @@ -4855,6 +5018,16 @@ dependencies = [ "thiserror-impl-no-std", ] +[[package]] +name = "thread-id" +version = "4.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f0ec81c46e9eb50deaa257be2f148adf052d1fb7701cfd55ccfab2525280b70b" +dependencies = [ + "libc", + "winapi", +] + [[package]] name = "time" version = "0.3.36" @@ -4897,9 +5070,9 @@ dependencies = [ [[package]] name = "tinyvec" -version = "1.6.1" +version = "1.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c55115c6fbe2d2bef26eb09ad74bde02d8255476fc0c7b515ef09fbb35742d82" +checksum = "ce6b6a2fb3a985e99cebfaefa9faa3024743da73304ca1c683a36429613d3d22" dependencies = [ "tinyvec_macros", ] @@ -4947,7 +5120,7 @@ checksum = "5f5ae998a069d4b5aba8ee9dad856af7d520c3699e6159b185c2acd48155d39a" dependencies = [ "proc-macro2", "quote", - "syn 2.0.68", + "syn 2.0.69", ] [[package]] @@ -5155,7 +5328,7 @@ checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.68", + "syn 2.0.69", ] [[package]] @@ -5179,9 +5352,9 @@ dependencies = [ [[package]] name = "triomphe" -version = "0.1.13" +version = "0.1.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e6631e42e10b40c0690bf92f404ebcfe6e1fdb480391d15f17cc8e96eeed5369" +checksum = "859eb650cfee7434994602c3a68b25d77ad9e68c8a6cd491616ef86661382eb3" [[package]] name = "trust-dns-client" @@ -5437,7 +5610,7 @@ dependencies = [ "once_cell", "proc-macro2", "quote", - "syn 2.0.68", + "syn 2.0.69", "wasm-bindgen-shared", ] @@ -5459,7 +5632,7 @@ checksum = "e94f17b526d0a461a191c78ea52bbce64071ed5c04c9ffe424dcb38f74171bb7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.68", + "syn 2.0.69", "wasm-bindgen-backend", "wasm-bindgen-shared", ] @@ -5565,7 +5738,7 @@ version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "33ab640c8d7e35bf8ba19b884ba838ceb4fba93a4e8c65a9059d08afcfc683d9" dependencies = [ - "windows-targets 0.52.5", + "windows-targets 0.52.6", ] [[package]] @@ -5583,7 +5756,7 @@ version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" dependencies = [ - "windows-targets 0.52.5", + "windows-targets 0.52.6", ] [[package]] @@ -5603,18 +5776,18 @@ dependencies = [ [[package]] name = "windows-targets" -version = "0.52.5" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6f0713a46559409d202e70e28227288446bf7841d3211583a4b53e3f6d96e7eb" +checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973" dependencies = [ - "windows_aarch64_gnullvm 0.52.5", - "windows_aarch64_msvc 0.52.5", - "windows_i686_gnu 0.52.5", + "windows_aarch64_gnullvm 0.52.6", + "windows_aarch64_msvc 0.52.6", + "windows_i686_gnu 0.52.6", "windows_i686_gnullvm", - "windows_i686_msvc 0.52.5", - "windows_x86_64_gnu 0.52.5", - "windows_x86_64_gnullvm 0.52.5", - "windows_x86_64_msvc 0.52.5", + "windows_i686_msvc 0.52.6", + "windows_x86_64_gnu 0.52.6", + "windows_x86_64_gnullvm 0.52.6", + "windows_x86_64_msvc 0.52.6", ] [[package]] @@ -5625,9 +5798,9 @@ checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8" [[package]] name = "windows_aarch64_gnullvm" -version = "0.52.5" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7088eed71e8b8dda258ecc8bac5fb1153c5cffaf2578fc8ff5d61e23578d3263" +checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3" [[package]] name = "windows_aarch64_msvc" @@ -5637,9 +5810,9 @@ checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc" [[package]] name = "windows_aarch64_msvc" -version = "0.52.5" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9985fd1504e250c615ca5f281c3f7a6da76213ebd5ccc9561496568a2752afb6" +checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469" [[package]] name = "windows_i686_gnu" @@ -5649,15 +5822,15 @@ checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e" [[package]] name = "windows_i686_gnu" -version = "0.52.5" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "88ba073cf16d5372720ec942a8ccbf61626074c6d4dd2e745299726ce8b89670" +checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b" [[package]] name = "windows_i686_gnullvm" -version = "0.52.5" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "87f4261229030a858f36b459e748ae97545d6f1ec60e5e0d6a3d32e0dc232ee9" +checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66" [[package]] name = "windows_i686_msvc" @@ -5667,9 +5840,9 @@ checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406" [[package]] name = "windows_i686_msvc" -version = "0.52.5" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "db3c2bf3d13d5b658be73463284eaf12830ac9a26a90c717b7f771dfe97487bf" +checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66" [[package]] name = "windows_x86_64_gnu" @@ -5679,9 +5852,9 @@ checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e" [[package]] name = "windows_x86_64_gnu" -version = "0.52.5" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4e4246f76bdeff09eb48875a0fd3e2af6aada79d409d33011886d3e1581517d9" +checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78" [[package]] name = "windows_x86_64_gnullvm" @@ -5691,9 +5864,9 @@ checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc" [[package]] name = "windows_x86_64_gnullvm" -version = "0.52.5" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "852298e482cd67c356ddd9570386e2862b5673c85bd5f88df9ab6802b334c596" +checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d" [[package]] name = "windows_x86_64_msvc" @@ -5703,9 +5876,9 @@ checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538" [[package]] name = "windows_x86_64_msvc" -version = "0.52.5" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bec47e5bfd1bff0eeaf6d8b485cc1074891a197ab4225d504cb7a1ab88b02bf0" +checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" [[package]] name = "winnow" @@ -5830,22 +6003,22 @@ dependencies = [ [[package]] name = "zerocopy" -version = "0.7.34" +version = "0.7.35" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ae87e3fcd617500e5d106f0380cf7b77f3c6092aae37191433159dda23cfb087" +checksum = "1b9b4fd18abc82b8136838da5d50bae7bdea537c574d8dc1a34ed098d6c166f0" dependencies = [ "zerocopy-derive", ] [[package]] name = "zerocopy-derive" -version = "0.7.34" +version = "0.7.35" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "15e934569e47891f7d9411f1a451d947a60e000ab3bd24fbb970f000387d1b3b" +checksum = "fa4f8080344d4671fb4e831a13ad1e68092748387dfc4f55e356242fae12ce3e" dependencies = [ "proc-macro2", "quote", - "syn 2.0.68", + "syn 2.0.69", ] [[package]] @@ -5865,5 +6038,5 @@ checksum = "ce36e65b0d2999d2aafac989fb249189a141aee1f53c612c1f37d72631959f69" dependencies = [ "proc-macro2", "quote", - "syn 2.0.68", + "syn 2.0.69", ] diff --git a/Cargo.toml b/Cargo.toml index 99e076f2..33989bd4 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -5,15 +5,12 @@ edition = "2021" [dependencies] #sha_p2pool_grpc = { path = "../sha_p2pool_grpc" } -#minotari_app_grpc = { git = "https://github.com/tari-project/tari.git" } -#minotari_node_grpc_client = { git = "https://github.com/tari-project/tari.git" } -#tari_common_types = { git = "https://github.com/tari-project/tari.git" } -minotari_app_grpc = { git = "https://github.com/ksrichard/tari.git", branch = "p2pool" } -minotari_node_grpc_client = { git = "https://github.com/ksrichard/tari.git", branch = "p2pool" } -tari_common_types = { git = "https://github.com/ksrichard/tari.git", branch = "p2pool" } -tari_common = { git = "https://github.com/ksrichard/tari.git", branch = "p2pool" } -tari_core = { git = "https://github.com/ksrichard/tari.git", branch = "p2pool" } +minotari_app_grpc = { git = "https://github.com/tari-project/tari.git" } +minotari_node_grpc_client = { git = "https://github.com/tari-project/tari.git" } +tari_common_types = { git = "https://github.com/tari-project/tari.git" } +tari_common = { git = "https://github.com/tari-project/tari.git" } +tari_core = { git = "https://github.com/tari-project/tari.git" } tari_utilities = { version = "0.7", features = ["borsh"] } libp2p = { version = "0.53.2", features = [ @@ -36,8 +33,9 @@ tokio = { version = "1.38.0", features = ["full"] } thiserror = "1.0" serde = "1.0.203" anyhow = "1.0" -log = "0.4.21" -env_logger = "0.11.3" +log = { version = "0.4", features = ["std"] } +log4rs = { version = "1.3.0", features = ["config_parsing", "threshold_filter", "yaml_format", "console_appender", "rolling_file_appender", "compound_policy", "size_trigger", "fixed_window_roller"] } +native-tls = "0.2" tonic = "0.8.3" async-trait = "0.1.80" serde_cbor = "0.11.2" @@ -45,5 +43,5 @@ blake2 = "0.10.6" digest = "0.10.7" clap = { version = "4.5.7", features = ["derive"] } moka = { version = "0.12.7", features = ["future"] } - - +dirs = "4.0.0" +crossterm = "0.25.0" diff --git a/log4rs_sample.yml b/log4rs_sample.yml new file mode 100644 index 00000000..71502294 --- /dev/null +++ b/log4rs_sample.yml @@ -0,0 +1,53 @@ +refresh_rate: 30 seconds +appenders: + # An appender named "stdout" that writes to stdout + stdout: + kind: console + encoder: + pattern: "{d(%Y-%m-%dT%H:%M:%S%Z)} {h({l}):5} {t} {m}{n}" + filters: + - kind: threshold + level: info + + # An appender named "p2pool" that writes to a file with a custom pattern encoder + p2pool: + kind: rolling_file + path: "{{log_dir}}/log/p2pool.log" + policy: + kind: compound + trigger: + kind: size + limit: 10mb + roller: + kind: fixed_window + base: 1 + count: 5 + pattern: "{{log_dir}}/log/p2pool.{}.log" + encoder: + pattern: "[{d(%Y-%m-%d %H:%M:%S.%f)} [{t}] [Thread:{I}] {l:5} {m}{n}]" + +# Set the default logging level to "warn" and attach the "stdout" appender to the root +root: + level: info + appenders: + - stdout + +loggers: + sharechain: + level: info + appenders: + - p2pool + - stdout + additive: false + p2p: + level: info + appenders: + - p2pool + - stdout + additive: false + server: + level: info + appenders: + - p2pool + - stdout + additive: false diff --git a/src/main.rs b/src/main.rs index 0631bd41..48437b6c 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,15 +1,18 @@ // Copyright 2024 The Tari Project // SPDX-License-Identifier: BSD-3-Clause +use std::io::stdout; use std::path::PathBuf; use clap::{ builder::{styling::AnsiColor, Styles}, Parser, }; -use env_logger::Builder; +use crossterm::{execute, terminal::SetTitle}; use log::LevelFilter; +use tari_common::initialize_logging; + use crate::sharechain::in_memory::InMemoryShareChain; mod server; @@ -26,7 +29,7 @@ fn cli_styles() -> Styles { .valid(AnsiColor::BrightGreen.on_default()) } -#[derive(Parser)] +#[derive(Clone, Parser)] #[command(version)] #[command(styles = cli_styles())] #[command(about = "⛏ Decentralized mining pool for Tari network ⛏", long_about = None)] @@ -77,13 +80,37 @@ struct Cli { /// By setting this it can be used as a stable node for routing only. #[arg(long, value_name = "mining-disabled", default_value_t = false)] mining_disabled: bool, + + base_dir: Option, +} + +impl Cli { + pub fn base_dir(&self) -> PathBuf { + self.base_dir + .clone() + .unwrap_or_else(|| dirs::home_dir().unwrap().join(".p2pool/miner")) + } } #[tokio::main] async fn main() -> anyhow::Result<()> { - // cli let cli = Cli::parse(); - Builder::new().filter_level(cli.log_level).init(); + + // logger setup + if let Err(e) = initialize_logging( + &cli.base_dir().join("configs/logs.yml"), + &cli.base_dir(), + include_str!("../log4rs_sample.yml"), + ) { + eprintln!("{}", e); + return Err(e.into()); + } + + let terminal_title = "Decentralized mining pool for Tari network".to_string(); + if let Err(e) = execute!(stdout(), SetTitle(terminal_title.as_str())) { + println!("Error setting terminal title. {}", e) + } + let mut config_builder = server::Config::builder(); if let Some(grpc_port) = cli.grpc_port { config_builder.with_grpc_port(grpc_port); @@ -91,11 +118,11 @@ async fn main() -> anyhow::Result<()> { if let Some(p2p_port) = cli.p2p_port { config_builder.with_p2p_port(p2p_port); } - if let Some(seed_peers) = cli.seed_peers { + if let Some(seed_peers) = cli.seed_peers.clone() { config_builder.with_seed_peers(seed_peers); } config_builder.with_stable_peer(cli.stable_peer); - config_builder.with_private_key_folder(cli.private_key_folder); + config_builder.with_private_key_folder(cli.private_key_folder.clone()); config_builder.with_mining_enabled(!cli.mining_disabled); // server start diff --git a/src/server/grpc/base_node.rs b/src/server/grpc/base_node.rs index 23dcf152..145167ef 100644 --- a/src/server/grpc/base_node.rs +++ b/src/server/grpc/base_node.rs @@ -8,52 +8,16 @@ use log::error; use minotari_app_grpc::{ tari_rpc, tari_rpc::{ - base_node_client::BaseNodeClient, - Block, - BlockBlobRequest, - BlockGroupRequest, - BlockGroupResponse, - BlockHeaderResponse, - BlockHeight, - BlockTimingResponse, - ConsensusConstants, - Empty, - FetchMatchingUtxosRequest, - GetActiveValidatorNodesRequest, - GetBlocksRequest, - GetHeaderByHashRequest, - GetMempoolTransactionsRequest, - GetNewBlockBlobResult, - GetNewBlockResult, - GetNewBlockTemplateWithCoinbasesRequest, - GetNewBlockWithCoinbasesRequest, - GetPeersRequest, - GetShardKeyRequest, - GetShardKeyResponse, - GetSideChainUtxosRequest, - GetTemplateRegistrationsRequest, - HeightRequest, - HistoricalBlock, - ListConnectedPeersResponse, - ListHeadersRequest, - MempoolStatsResponse, - NetworkStatusResponse, - NewBlockTemplate, - NewBlockTemplateRequest, - NewBlockTemplateResponse, - NodeIdentity, - SearchKernelsRequest, - SearchUtxosRequest, - SoftwareUpdate, - StringValue, - SubmitBlockResponse, - SubmitTransactionRequest, - SubmitTransactionResponse, - SyncInfoResponse, - SyncProgressResponse, - TipInfoResponse, - TransactionStateRequest, - TransactionStateResponse, + base_node_client::BaseNodeClient, Block, BlockBlobRequest, BlockGroupRequest, BlockGroupResponse, + BlockHeaderResponse, BlockHeight, BlockTimingResponse, ConsensusConstants, Empty, FetchMatchingUtxosRequest, + GetActiveValidatorNodesRequest, GetBlocksRequest, GetHeaderByHashRequest, GetMempoolTransactionsRequest, + GetNewBlockBlobResult, GetNewBlockResult, GetNewBlockTemplateWithCoinbasesRequest, + GetNewBlockWithCoinbasesRequest, GetPeersRequest, GetShardKeyRequest, GetShardKeyResponse, + GetSideChainUtxosRequest, GetTemplateRegistrationsRequest, HeightRequest, HistoricalBlock, + ListConnectedPeersResponse, ListHeadersRequest, MempoolStatsResponse, NetworkStatusResponse, NewBlockTemplate, + NewBlockTemplateRequest, NewBlockTemplateResponse, NodeIdentity, SearchKernelsRequest, SearchUtxosRequest, + SoftwareUpdate, StringValue, SubmitBlockResponse, SubmitTransactionRequest, SubmitTransactionResponse, + SyncInfoResponse, SyncProgressResponse, TipInfoResponse, TransactionStateRequest, TransactionStateResponse, ValueAtHeightResponse, }, }; diff --git a/src/server/grpc/p2pool.rs b/src/server/grpc/p2pool.rs index 76208639..39790a4b 100644 --- a/src/server/grpc/p2pool.rs +++ b/src/server/grpc/p2pool.rs @@ -5,17 +5,9 @@ use std::sync::Arc; use log::{debug, info, warn}; use minotari_app_grpc::tari_rpc::{ - base_node_client::BaseNodeClient, - pow_algo::PowAlgos, - sha_p2_pool_server::ShaP2Pool, - GetNewBlockRequest, - GetNewBlockResponse, - GetNewBlockTemplateWithCoinbasesRequest, - HeightRequest, - NewBlockTemplateRequest, - PowAlgo, - SubmitBlockRequest, - SubmitBlockResponse, + base_node_client::BaseNodeClient, pow_algo::PowAlgos, sha_p2_pool_server::ShaP2Pool, GetNewBlockRequest, + GetNewBlockResponse, GetNewBlockTemplateWithCoinbasesRequest, HeightRequest, NewBlockTemplateRequest, PowAlgo, + SubmitBlockRequest, SubmitBlockResponse, }; use tari_core::proof_of_work::sha3x_difficulty; use tokio::sync::Mutex; @@ -29,11 +21,12 @@ use crate::{ sharechain::{block::Block, ShareChain, SHARE_COUNT}, }; -const LOG_TARGET: &str = "p2pool_grpc"; +const LOG_TARGET: &str = "p2pool::server::grpc::p2pool"; /// P2Pool specific gRPC service to provide `get_new_block` and `submit_block` functionalities. pub struct ShaP2PoolGrpc -where S: ShareChain + Send + Sync + 'static +where + S: ShareChain + Send + Sync + 'static, { /// Base node client client: Arc>>, @@ -44,7 +37,8 @@ where S: ShareChain + Send + Sync + 'static } impl ShaP2PoolGrpc -where S: ShareChain + Send + Sync + 'static +where + S: ShareChain + Send + Sync + 'static, { pub async fn new( base_node_address: String, @@ -73,7 +67,8 @@ where S: ShareChain + Send + Sync + 'static #[tonic::async_trait] impl ShaP2Pool for ShaP2PoolGrpc -where S: ShareChain + Send + Sync + 'static +where + S: ShareChain + Send + Sync + 'static, { /// Returns a new block (that can be mined) which contains all the shares generated /// from the current share chain as coinbase transactions. @@ -173,8 +168,8 @@ where S: ShareChain + Send + Sync + 'static .into_inner(); let mut network_difficulty_matches = false; while let Ok(Some(diff_resp)) = network_difficulty_stream.message().await { - if origin_block_header.height == diff_resp.height + 1 && - request_block_difficulty.as_u64() > diff_resp.difficulty + if origin_block_header.height == diff_resp.height + 1 + && request_block_difficulty.as_u64() > diff_resp.difficulty { network_difficulty_matches = true; } diff --git a/src/server/p2p/client.rs b/src/server/p2p/client.rs index dc96dd07..1bcb5136 100644 --- a/src/server/p2p/client.rs +++ b/src/server/p2p/client.rs @@ -13,8 +13,7 @@ use tokio::{ sync::{ broadcast, broadcast::error::{RecvError, SendError}, - mpsc, - Mutex, + mpsc, Mutex, }, time::sleep, }; @@ -27,7 +26,7 @@ use crate::{ sharechain::block::Block, }; -const LOG_TARGET: &str = "p2p_service_client"; +const LOG_TARGET: &str = "p2pool::server::p2p::client"; #[derive(Error, Debug)] pub enum ClientError { diff --git a/src/server/p2p/p2p.rs b/src/server/p2p/p2p.rs index 1ac13704..dedcd263 100644 --- a/src/server/p2p/p2p.rs +++ b/src/server/p2p/p2p.rs @@ -18,15 +18,10 @@ use libp2p::{ mdns, mdns::tokio::Tokio, multiaddr::Protocol, - noise, - request_response, + noise, request_response, request_response::{cbor, ResponseChannel}, swarm::{NetworkBehaviour, SwarmEvent}, - tcp, - yamux, - Multiaddr, - StreamProtocol, - Swarm, + tcp, yamux, Multiaddr, StreamProtocol, Swarm, }; use log::{debug, error, info, warn}; use tari_common::configuration::Network; @@ -43,20 +38,12 @@ use crate::{ server::{ config, p2p::{ - client, - messages, + client, messages, messages::{ - PeerInfo, - ShareChainSyncRequest, - ShareChainSyncResponse, - ValidateBlockRequest, - ValidateBlockResult, + PeerInfo, ShareChainSyncRequest, ShareChainSyncResponse, ValidateBlockRequest, ValidateBlockResult, }, peer_store::PeerStore, - Error, - LibP2PError, - ServiceClient, - ServiceClientChannels, + Error, LibP2PError, ServiceClient, ServiceClientChannels, }, }, sharechain::{block::Block, ShareChain}, @@ -67,7 +54,7 @@ const BLOCK_VALIDATION_REQUESTS_TOPIC: &str = "block_validation_requests"; const BLOCK_VALIDATION_RESULTS_TOPIC: &str = "block_validation_results"; const NEW_BLOCK_TOPIC: &str = "new_block"; const SHARE_CHAIN_SYNC_REQ_RESP_PROTOCOL: &str = "/share_chain_sync/1"; -const LOG_TARGET: &str = "p2p_service"; +const LOG_TARGET: &str = "p2pool::server::p2p::p2p"; const STABLE_PRIVATE_KEY_FILE: &str = "p2pool_private.key"; #[derive(Clone, Debug)] @@ -102,7 +89,8 @@ pub struct ServerNetworkBehaviour { /// Service is the implementation that holds every peer-to-peer related logic /// that makes sure that all the communications, syncing, broadcasting etc... are done. pub struct Service -where S: ShareChain + Send + Sync + 'static +where + S: ShareChain + Send + Sync + 'static, { swarm: Swarm, port: u16, @@ -122,7 +110,8 @@ where S: ShareChain + Send + Sync + 'static } impl Service -where S: ShareChain + Send + Sync + 'static +where + S: ShareChain + Send + Sync + 'static, { /// Constructs a new Service from the provided config. /// It also instantiates libp2p swarm inside. diff --git a/src/server/p2p/peer_store.rs b/src/server/p2p/peer_store.rs index 56208f60..2fcc4e4e 100644 --- a/src/server/p2p/peer_store.rs +++ b/src/server/p2p/peer_store.rs @@ -12,7 +12,7 @@ use moka::future::{Cache, CacheBuilder}; use crate::server::p2p::messages::PeerInfo; -const LOG_TARGET: &str = "peer_store"; +const LOG_TARGET: &str = "p2pool::server::p2p::peer_store"; #[derive(Copy, Clone, Debug)] pub struct PeerStoreConfig { diff --git a/src/server/server.rs b/src/server/server.rs index 45c5b088..ae019886 100644 --- a/src/server/server.rs +++ b/src/server/server.rs @@ -13,15 +13,14 @@ use thiserror::Error; use crate::{ server::{ - config, - grpc, + config, grpc, grpc::{base_node::TariBaseNodeGrpc, error::TonicError, p2pool::ShaP2PoolGrpc}, p2p, }, sharechain::ShareChain, }; -const LOG_TARGET: &str = "server"; +const LOG_TARGET: &str = "p2pool::server::server"; #[derive(Error, Debug)] pub enum Error { @@ -35,7 +34,8 @@ pub enum Error { /// Server represents the server running all the necessary components for sha-p2pool. pub struct Server -where S: ShareChain + Send + Sync + 'static +where + S: ShareChain + Send + Sync + 'static, { config: config::Config, p2p_service: p2p::Service, @@ -45,7 +45,8 @@ where S: ShareChain + Send + Sync + 'static // TODO: add graceful shutdown impl Server -where S: ShareChain + Send + Sync + 'static +where + S: ShareChain + Send + Sync + 'static, { pub async fn new(config: config::Config, share_chain: S) -> Result { let share_chain = Arc::new(share_chain); diff --git a/src/sharechain/in_memory.rs b/src/sharechain/in_memory.rs index 446bc3fb..c65bab58 100644 --- a/src/sharechain/in_memory.rs +++ b/src/sharechain/in_memory.rs @@ -13,14 +13,10 @@ use tokio::sync::{RwLock, RwLockWriteGuard}; use crate::sharechain::{ error::{BlockConvertError, Error}, - Block, - ShareChain, - ShareChainResult, - MAX_BLOCKS_COUNT, - SHARE_COUNT, + Block, ShareChain, ShareChainResult, MAX_BLOCKS_COUNT, SHARE_COUNT, }; -const LOG_TARGET: &str = "in_memory_share_chain"; +const LOG_TARGET: &str = "p2pool::sharechain::in_memory"; pub struct InMemoryShareChain { max_blocks_count: usize, @@ -142,8 +138,8 @@ impl ShareChain for InMemoryShareChain { let mut blocks_write_lock = self.blocks.write().await; let last_block = blocks_write_lock.last(); - if (sync && last_block.is_none()) || - (sync && last_block.is_some() && !blocks.is_empty() && last_block.unwrap().height() < blocks[0].height()) + if (sync && last_block.is_none()) + || (sync && last_block.is_some() && !blocks.is_empty() && last_block.unwrap().height() < blocks[0].height()) { blocks_write_lock.clear(); } From 02fd22314d4ec99bc6211af6f54fe427bd393b92 Mon Sep 17 00:00:00 2001 From: dkf Date: Tue, 9 Jul 2024 14:02:26 +0100 Subject: [PATCH 2/5] chore: make clippy happy --- src/server/p2p/error.rs | 7 +------ src/server/p2p/messages.rs | 8 ++++++-- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/src/server/p2p/error.rs b/src/server/p2p/error.rs index b73ad386..5921469e 100644 --- a/src/server/p2p/error.rs +++ b/src/server/p2p/error.rs @@ -2,12 +2,7 @@ // SPDX-License-Identifier: BSD-3-Clause use libp2p::{ - gossipsub::PublishError, - identity::DecodingError, - kad::NoKnownPeers, - multiaddr, - noise, - swarm::DialError, + gossipsub::PublishError, identity::DecodingError, kad::NoKnownPeers, multiaddr, noise, swarm::DialError, TransportError, }; use thiserror::Error; diff --git a/src/server/p2p/messages.rs b/src/server/p2p/messages.rs index cc9e3cad..2e60debe 100644 --- a/src/server/p2p/messages.rs +++ b/src/server/p2p/messages.rs @@ -29,12 +29,16 @@ macro_rules! impl_conversions { }; } pub fn deserialize_message<'a, T>(raw_message: &'a [u8]) -> Result -where T: Deserialize<'a> { +where + T: Deserialize<'a>, +{ serde_cbor::from_slice(raw_message).map_err(Error::SerializeDeserialize) } pub fn serialize_message(input: &T) -> Result, Error> -where T: Serialize { +where + T: Serialize, +{ serde_cbor::to_vec(input).map_err(Error::SerializeDeserialize) } From e0f70ddb91a63b6cc9665e701d0ebbcf2560c6f3 Mon Sep 17 00:00:00 2001 From: dkf Date: Tue, 9 Jul 2024 14:04:41 +0100 Subject: [PATCH 3/5] chore: make machete happy --- Cargo.toml | 2 -- 1 file changed, 2 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 33989bd4..f71f2b64 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -34,8 +34,6 @@ thiserror = "1.0" serde = "1.0.203" anyhow = "1.0" log = { version = "0.4", features = ["std"] } -log4rs = { version = "1.3.0", features = ["config_parsing", "threshold_filter", "yaml_format", "console_appender", "rolling_file_appender", "compound_policy", "size_trigger", "fixed_window_roller"] } -native-tls = "0.2" tonic = "0.8.3" async-trait = "0.1.80" serde_cbor = "0.11.2" From 7a0382f92cc2981a117676a1da4e5c9ced8a126c Mon Sep 17 00:00:00 2001 From: dkf Date: Wed, 10 Jul 2024 14:54:51 +0100 Subject: [PATCH 4/5] fixes --- Cargo.lock | 443 ++++++++++---------------- Cargo.toml | 18 +- src/server/p2p/mod.rs | 2 +- src/server/p2p/{p2p.rs => network.rs} | 2 +- 4 files changed, 176 insertions(+), 289 deletions(-) rename src/server/p2p/{p2p.rs => network.rs} (99%) diff --git a/Cargo.lock b/Cargo.lock index d0c9c1e1..150547ec 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -202,7 +202,7 @@ checksum = "7378575ff571966e99a744addeff0bff98b8ada0dedf1956d59e634db95eaac1" dependencies = [ "proc-macro2", "quote", - "syn 2.0.69", + "syn 2.0.68", "synstructure 0.13.1", ] @@ -214,7 +214,7 @@ checksum = "7b18050c2cd6fe86c3a76584ef5e0baf286d038cda203eb6223df2cc413565f7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.69", + "syn 2.0.68", ] [[package]] @@ -266,18 +266,18 @@ checksum = "16e62a023e7c117e27523144c5d2459f4397fcc3cab0085af8e2224f643a0193" dependencies = [ "proc-macro2", "quote", - "syn 2.0.69", + "syn 2.0.68", ] [[package]] name = "async-trait" -version = "0.1.81" +version = "0.1.80" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6e0c28dcc82d7c8ead5cb13beb15405b57b8546e93215673ff8ca0349a028107" +checksum = "c6fa2087f2753a7da8cc1c0dbfcf89579dd57458e36769de5ac750b4671737ca" dependencies = [ "proc-macro2", "quote", - "syn 2.0.69", + "syn 2.0.68", ] [[package]] @@ -517,7 +517,7 @@ dependencies = [ "proc-macro-crate 3.1.0", "proc-macro2", "quote", - "syn 2.0.69", + "syn 2.0.68", "syn_derive", ] @@ -580,9 +580,9 @@ dependencies = [ [[package]] name = "cc" -version = "1.0.106" +version = "1.0.104" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "066fce287b1d4eafef758e89e09d724a24808a9196fe9756b8ca90e86d0719a2" +checksum = "74b6a57f98764a267ff415d50a25e6e166f3831a5071af4995296ea97d210490" [[package]] name = "cfg-if" @@ -716,7 +716,7 @@ dependencies = [ "heck 0.5.0", "proc-macro2", "quote", - "syn 2.0.69", + "syn 2.0.68", ] [[package]] @@ -832,31 +832,6 @@ version = "0.8.20" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "22ec99545bb0ed0ea7bb9b8e1e9122ea386ff8a48c0922e43f36d45ab09e0e80" -[[package]] -name = "crossterm" -version = "0.25.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e64e6c0fbe2c17357405f7c758c1ef960fce08bdfb2c03d88d2a18d7e09c4b67" -dependencies = [ - "bitflags 1.3.2", - "crossterm_winapi", - "libc", - "mio", - "parking_lot", - "signal-hook", - "signal-hook-mio", - "winapi", -] - -[[package]] -name = "crossterm_winapi" -version = "0.9.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "acdd7c62a3665c7f6830a51635d9ac9b23ed385797f70a83bb8bafe9c572ab2b" -dependencies = [ - "winapi", -] - [[package]] name = "crunchy" version = "0.2.2" @@ -910,7 +885,7 @@ checksum = "f46882e17999c6cc590af592290432be3bce0428cb0d5f8b6715e4dc7b383eb3" dependencies = [ "proc-macro2", "quote", - "syn 2.0.69", + "syn 2.0.68", ] [[package]] @@ -934,7 +909,7 @@ dependencies = [ "proc-macro2", "quote", "strsim", - "syn 2.0.69", + "syn 2.0.68", ] [[package]] @@ -945,7 +920,7 @@ checksum = "733cabb43482b1a1b53eee8583c2b9e8684d592215ea83efd305dd31bc2f0178" dependencies = [ "darling_core", "quote", - "syn 2.0.69", + "syn 2.0.68", ] [[package]] @@ -1061,7 +1036,7 @@ dependencies = [ "dsl_auto_type", "proc-macro2", "quote", - "syn 2.0.69", + "syn 2.0.68", ] [[package]] @@ -1081,7 +1056,7 @@ version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "209c735641a413bc68c4923a9d6ad4bcb3ca306b794edaa7eb0b3228a99ffb25" dependencies = [ - "syn 2.0.69", + "syn 2.0.68", ] [[package]] @@ -1095,15 +1070,6 @@ dependencies = [ "subtle", ] -[[package]] -name = "dirs" -version = "4.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ca3aa72a6f96ea37bbc5aa912f6788242832f75369bdfdadcb0e38423f100059" -dependencies = [ - "dirs-sys", -] - [[package]] name = "dirs-next" version = "1.0.2" @@ -1114,17 +1080,6 @@ dependencies = [ "dirs-sys-next", ] -[[package]] -name = "dirs-sys" -version = "0.3.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1b1d1d91c932ef41c0f2663aa8b0ca0342d444d842c06914aa0a7e352d0bada6" -dependencies = [ - "libc", - "redox_users", - "winapi", -] - [[package]] name = "dirs-sys-next" version = "0.1.2" @@ -1144,7 +1099,7 @@ checksum = "97369cbbc041bc366949bc74d34658d6cda5621039731c6310521892a3a20ae0" dependencies = [ "proc-macro2", "quote", - "syn 2.0.69", + "syn 2.0.68", ] [[package]] @@ -1164,7 +1119,7 @@ dependencies = [ "heck 0.5.0", "proc-macro2", "quote", - "syn 2.0.69", + "syn 2.0.68", ] [[package]] @@ -1231,7 +1186,30 @@ dependencies = [ "heck 0.4.1", "proc-macro2", "quote", - "syn 2.0.69", + "syn 2.0.68", +] + +[[package]] +name = "env_filter" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a009aa4810eb158359dda09d0c87378e4bbb89b5a801f016885a4707ba24f7ea" +dependencies = [ + "log", + "regex", +] + +[[package]] +name = "env_logger" +version = "0.11.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "38b35839ba51819680ba087cd351788c9a3c476841207e0b8cee0b04722343b9" +dependencies = [ + "anstream", + "anstyle", + "env_filter", + "humantime", + "log", ] [[package]] @@ -1317,21 +1295,6 @@ 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" @@ -1440,7 +1403,7 @@ checksum = "87750cf4b7a4c0625b1529e4c543c2182106e4dedc60a2a6455e00d212c489ac" dependencies = [ "proc-macro2", "quote", - "syn 2.0.69", + "syn 2.0.68", ] [[package]] @@ -2154,14 +2117,15 @@ dependencies = [ [[package]] name = "libp2p-core" -version = "0.41.3" +version = "0.41.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a5a8920cbd8540059a01950c1e5c96ea8d89eb50c51cd366fc18bdf540a6e48f" +checksum = "8130a8269e65a2554d55131c770bdf4bcd94d2b8d4efb24ca23699be65066c05" dependencies = [ "either", "fnv", "futures 0.3.30", "futures-timer", + "instant", "libp2p-identity", "multiaddr 0.18.1", "multihash 0.19.1", @@ -2178,7 +2142,6 @@ dependencies = [ "tracing", "unsigned-varint 0.8.0", "void", - "web-time", ] [[package]] @@ -2446,7 +2409,7 @@ dependencies = [ "heck 0.5.0", "proc-macro2", "quote", - "syn 2.0.69", + "syn 2.0.68", ] [[package]] @@ -2593,24 +2556,16 @@ checksum = "0816135ae15bd0391cf284eab37e6e3ee0a6ee63d2ceeb659862bd8d0a984ca6" dependencies = [ "anyhow", "arc-swap", - "chrono", "derivative", "fnv", "humantime", - "libc", "log", - "log-mdc", "once_cell", - "parking_lot", - "rand", "serde", "serde-value", - "serde_json", "serde_yaml", "thiserror", - "thread-id", "typemap-ors", - "winapi", ] [[package]] @@ -2712,7 +2667,7 @@ dependencies = [ [[package]] name = "minotari_app_grpc" version = "1.0.0-pre.15" -source = "git+https://github.com/tari-project/tari.git#cb1eb6383a0887c95f869146b94c0da00f3faffd" +source = "git+https://github.com/ksrichard/tari.git?branch=p2pool#982c89a4de2b24de0dfd811733dd68a8f681e44a" dependencies = [ "argon2", "base64 0.13.1", @@ -2724,11 +2679,11 @@ dependencies = [ "rand", "rcgen", "subtle", - "tari_common_types", + "tari_common_types 1.0.0-pre.15 (git+https://github.com/ksrichard/tari.git?branch=p2pool)", "tari_comms", "tari_core", "tari_crypto", - "tari_features", + "tari_features 1.0.0-pre.15 (git+https://github.com/ksrichard/tari.git?branch=p2pool)", "tari_script", "tari_utilities", "thiserror", @@ -2741,7 +2696,7 @@ dependencies = [ [[package]] name = "minotari_node_grpc_client" version = "0.1.0" -source = "git+https://github.com/tari-project/tari.git#cb1eb6383a0887c95f869146b94c0da00f3faffd" +source = "git+https://github.com/ksrichard/tari.git?branch=p2pool#982c89a4de2b24de0dfd811733dd68a8f681e44a" dependencies = [ "minotari_app_grpc", ] @@ -2753,16 +2708,15 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a4a650543ca06a924e8b371db273b2756685faae30f8487da1b56505a8f78b0c" dependencies = [ "libc", - "log", "wasi", "windows-sys 0.48.0", ] [[package]] name = "moka" -version = "0.12.8" +version = "0.12.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "32cf62eb4dd975d2dde76432fb1075c49e3ee2331cf36f1f8fd4b66550d32b6f" +checksum = "9e0d88686dc561d743b40de8269b26eaf0dc58781bde087b0984646602021d08" dependencies = [ "async-lock", "async-trait", @@ -2903,23 +2857,6 @@ dependencies = [ "unsigned-varint 0.7.2", ] -[[package]] -name = "native-tls" -version = "0.2.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a8614eb2c83d59d1c8cc974dd3f920198647674a0a035e1af1fa58707e317466" -dependencies = [ - "libc", - "log", - "openssl", - "openssl-probe", - "openssl-sys", - "schannel", - "security-framework", - "security-framework-sys", - "tempfile", -] - [[package]] name = "netlink-packet-core" version = "0.4.2" @@ -3052,7 +2989,7 @@ checksum = "ed3955f1a9c7c0c15e092f9c887db08b1fc683305fdf6eb6684f22555355e202" dependencies = [ "proc-macro2", "quote", - "syn 2.0.69", + "syn 2.0.68", ] [[package]] @@ -3127,50 +3064,6 @@ version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c08d65885ee38876c4f86fa503fb49d7b507c2b62552df7c70b2fce627e06381" -[[package]] -name = "openssl" -version = "0.10.64" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "95a0481286a310808298130d22dd1fef0fa571e05a8f44ec801801e84b216b1f" -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.69", -] - -[[package]] -name = "openssl-probe" -version = "0.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf" - -[[package]] -name = "openssl-sys" -version = "0.9.102" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c597637d56fbc83893a35eb0dd04b2b8e7a50c91e64e9493e398b5df4fb45fa2" -dependencies = [ - "cc", - "libc", - "pkg-config", - "vcpkg", -] - [[package]] name = "ordered-float" version = "2.10.1" @@ -3327,7 +3220,7 @@ checksum = "2f38a4412a78282e09a2cf38d195ea5420d15ba0602cb375210efbc877243965" dependencies = [ "proc-macro2", "quote", - "syn 2.0.69", + "syn 2.0.68", ] [[package]] @@ -3508,7 +3401,7 @@ checksum = "440f724eba9f6996b75d63681b0a92b06947f1457076d503a4d2e2c8f56442b8" dependencies = [ "proc-macro2", "quote", - "syn 2.0.69", + "syn 2.0.68", ] [[package]] @@ -4001,15 +3894,6 @@ version = "1.0.18" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f3cb5ba0dc43242ce17de99c180e96db90b235b8a9fdc9543c96d2209116bd9f" -[[package]] -name = "schannel" -version = "0.1.23" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fbc91545643bcf3a0bbb6569265615222618bdf33ce4ffbbd13c4bbd4c093534" -dependencies = [ - "windows-sys 0.52.0", -] - [[package]] name = "scheduled-thread-pool" version = "0.2.7" @@ -4044,30 +3928,7 @@ dependencies = [ "heck 0.4.1", "proc-macro2", "quote", - "syn 2.0.69", -] - -[[package]] -name = "security-framework" -version = "2.11.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c627723fd09706bacdb5cf41499e95098555af3c3c29d014dc3c458ef6be11c0" -dependencies = [ - "bitflags 2.6.0", - "core-foundation", - "core-foundation-sys", - "libc", - "security-framework-sys", -] - -[[package]] -name = "security-framework-sys" -version = "2.11.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "317936bbbd05227752583946b9e66d7ce3b489f84e11a94a510b4437fef407d7" -dependencies = [ - "core-foundation-sys", - "libc", + "syn 2.0.68", ] [[package]] @@ -4078,9 +3939,9 @@ checksum = "61697e0a1c7e512e84a621326239844a24d8207b4669b41bc18b32ea5cbf988b" [[package]] name = "serde" -version = "1.0.204" +version = "1.0.203" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bc76f558e0cbb2a839d37354c575f1dc3fdc6546b5be373ba43d95f231bf7c12" +checksum = "7253ab4de971e72fb7be983802300c30b5a7f0c2e56fab8abfc6a214307c0094" dependencies = [ "serde_derive", ] @@ -4107,13 +3968,13 @@ dependencies = [ [[package]] name = "serde_derive" -version = "1.0.204" +version = "1.0.203" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e0cd7e117be63d3c3678776753929474f3b04a43a080c744d6b0ae2a8c28e222" +checksum = "500cbc0ebeb6f46627f50f3f5811ccf6bf00643be300b4c3eabc0ef55dc5b5ba" dependencies = [ "proc-macro2", "quote", - "syn 2.0.69", + "syn 2.0.68", ] [[package]] @@ -4135,7 +3996,7 @@ checksum = "6c64451ba24fc7a6a2d60fc75dd9c83c90903b19028d4eff35e88fc1e86564e9" dependencies = [ "proc-macro2", "quote", - "syn 2.0.69", + "syn 2.0.68", ] [[package]] @@ -4189,48 +4050,26 @@ dependencies = [ "async-trait", "blake2", "clap 4.5.8", - "crossterm", "digest", - "dirs", + "env_logger", "libp2p", "log", - "log4rs", "minotari_app_grpc", "minotari_node_grpc_client", "moka", - "native-tls", + "rand", "serde", "serde_cbor", - "tari_common", - "tari_common_types", + "tari_common 1.0.0-pre.15 (git+https://github.com/tari-project/tari.git)", + "tari_common_types 1.0.0-pre.15 (git+https://github.com/tari-project/tari.git)", "tari_core", + "tari_crypto", "tari_utilities", "thiserror", "tokio", "tonic", ] -[[package]] -name = "signal-hook" -version = "0.3.17" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8621587d4798caf8eb44879d42e56b9a93ea5dcd315a6487c357130095b62801" -dependencies = [ - "libc", - "signal-hook-registry", -] - -[[package]] -name = "signal-hook-mio" -version = "0.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "29ad2e15f37ec9a6cc544097b78a1ec90001e9f71b81338ca39f430adaca99af" -dependencies = [ - "libc", - "mio", - "signal-hook", -] - [[package]] name = "signal-hook-registry" version = "1.4.2" @@ -4423,9 +4262,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.69" +version = "2.0.68" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "201fcda3845c23e8212cd466bfebf0bd20694490fc0356ae8e428e0824a915a6" +checksum = "901fa70d88b9d6c98022e23b4136f9f3e54e4662c3bc1bd1d84a42a9a0f0c1e9" dependencies = [ "proc-macro2", "quote", @@ -4441,7 +4280,7 @@ dependencies = [ "proc-macro-error", "proc-macro2", "quote", - "syn 2.0.69", + "syn 2.0.68", ] [[package]] @@ -4470,7 +4309,7 @@ checksum = "c8af7666ab7b6390ab78131fb5b0fce11d6b7a6951602017c35fa82800708971" dependencies = [ "proc-macro2", "quote", - "syn 2.0.69", + "syn 2.0.68", ] [[package]] @@ -4540,7 +4379,7 @@ dependencies = [ [[package]] name = "tari_common" version = "1.0.0-pre.15" -source = "git+https://github.com/tari-project/tari.git#cb1eb6383a0887c95f869146b94c0da00f3faffd" +source = "git+https://github.com/ksrichard/tari.git?branch=p2pool#982c89a4de2b24de0dfd811733dd68a8f681e44a" dependencies = [ "anyhow", "blake2", @@ -4557,16 +4396,40 @@ dependencies = [ "sha2", "structopt", "tari_crypto", - "tari_features", + "tari_features 1.0.0-pre.15 (git+https://github.com/ksrichard/tari.git?branch=p2pool)", "tempfile", "thiserror", "toml 0.5.11", ] +[[package]] +name = "tari_common" +version = "1.0.0-pre.15" +source = "git+https://github.com/tari-project/tari.git#43b76d993d7ada9db2a8ebbc9b7969ba19279d6d" +dependencies = [ + "anyhow", + "blake2", + "config", + "dirs-next", + "log", + "log4rs", + "multiaddr 0.14.0", + "path-clean", + "serde", + "serde_json", + "serde_yaml", + "sha2", + "structopt", + "tari_crypto", + "tari_features 1.0.0-pre.15 (git+https://github.com/tari-project/tari.git)", + "tempfile", + "thiserror", +] + [[package]] name = "tari_common_sqlite" version = "1.0.0-pre.15" -source = "git+https://github.com/tari-project/tari.git#cb1eb6383a0887c95f869146b94c0da00f3faffd" +source = "git+https://github.com/ksrichard/tari.git?branch=p2pool#982c89a4de2b24de0dfd811733dd68a8f681e44a" dependencies = [ "diesel", "diesel_migrations", @@ -4580,7 +4443,32 @@ dependencies = [ [[package]] name = "tari_common_types" version = "1.0.0-pre.15" -source = "git+https://github.com/tari-project/tari.git#cb1eb6383a0887c95f869146b94c0da00f3faffd" +source = "git+https://github.com/ksrichard/tari.git?branch=p2pool#982c89a4de2b24de0dfd811733dd68a8f681e44a" +dependencies = [ + "base64 0.21.7", + "bitflags 2.6.0", + "blake2", + "borsh", + "bs58 0.5.1", + "chacha20poly1305", + "digest", + "newtype-ops", + "once_cell", + "primitive-types", + "rand", + "serde", + "strum", + "strum_macros", + "tari_common 1.0.0-pre.15 (git+https://github.com/ksrichard/tari.git?branch=p2pool)", + "tari_crypto", + "tari_utilities", + "thiserror", +] + +[[package]] +name = "tari_common_types" +version = "1.0.0-pre.15" +source = "git+https://github.com/tari-project/tari.git#43b76d993d7ada9db2a8ebbc9b7969ba19279d6d" dependencies = [ "base64 0.21.7", "bitflags 2.6.0", @@ -4596,7 +4484,7 @@ dependencies = [ "serde", "strum", "strum_macros", - "tari_common", + "tari_common 1.0.0-pre.15 (git+https://github.com/tari-project/tari.git)", "tari_crypto", "tari_utilities", "thiserror", @@ -4605,7 +4493,7 @@ dependencies = [ [[package]] name = "tari_comms" version = "1.0.0-pre.15" -source = "git+https://github.com/tari-project/tari.git#cb1eb6383a0887c95f869146b94c0da00f3faffd" +source = "git+https://github.com/ksrichard/tari.git?branch=p2pool#982c89a4de2b24de0dfd811733dd68a8f681e44a" dependencies = [ "anyhow", "async-trait", @@ -4631,7 +4519,7 @@ dependencies = [ "serde_derive", "sha3", "snow", - "tari_common", + "tari_common 1.0.0-pre.15 (git+https://github.com/ksrichard/tari.git?branch=p2pool)", "tari_crypto", "tari_shutdown", "tari_storage", @@ -4649,7 +4537,7 @@ dependencies = [ [[package]] name = "tari_comms_dht" version = "1.0.0-pre.15" -source = "git+https://github.com/tari-project/tari.git#cb1eb6383a0887c95f869146b94c0da00f3faffd" +source = "git+https://github.com/ksrichard/tari.git?branch=p2pool#982c89a4de2b24de0dfd811733dd68a8f681e44a" dependencies = [ "anyhow", "bitflags 2.6.0", @@ -4667,7 +4555,7 @@ dependencies = [ "prost", "rand", "serde", - "tari_common", + "tari_common 1.0.0-pre.15 (git+https://github.com/ksrichard/tari.git?branch=p2pool)", "tari_common_sqlite", "tari_comms", "tari_comms_rpc_macros", @@ -4684,7 +4572,7 @@ dependencies = [ [[package]] name = "tari_comms_rpc_macros" version = "1.0.0-pre.15" -source = "git+https://github.com/tari-project/tari.git#cb1eb6383a0887c95f869146b94c0da00f3faffd" +source = "git+https://github.com/ksrichard/tari.git?branch=p2pool#982c89a4de2b24de0dfd811733dd68a8f681e44a" dependencies = [ "proc-macro2", "quote", @@ -4694,7 +4582,7 @@ dependencies = [ [[package]] name = "tari_core" version = "1.0.0-pre.15" -source = "git+https://github.com/tari-project/tari.git#cb1eb6383a0887c95f869146b94c0da00f3faffd" +source = "git+https://github.com/ksrichard/tari.git?branch=p2pool#982c89a4de2b24de0dfd811733dd68a8f681e44a" dependencies = [ "async-trait", "bincode", @@ -4732,14 +4620,14 @@ dependencies = [ "strum", "strum_macros", "tari-tiny-keccak", - "tari_common", + "tari_common 1.0.0-pre.15 (git+https://github.com/ksrichard/tari.git?branch=p2pool)", "tari_common_sqlite", - "tari_common_types", + "tari_common_types 1.0.0-pre.15 (git+https://github.com/ksrichard/tari.git?branch=p2pool)", "tari_comms", "tari_comms_dht", "tari_comms_rpc_macros", "tari_crypto", - "tari_features", + "tari_features 1.0.0-pre.15 (git+https://github.com/ksrichard/tari.git?branch=p2pool)", "tari_hashing", "tari_key_manager", "tari_mmr", @@ -4783,12 +4671,17 @@ dependencies = [ [[package]] name = "tari_features" version = "1.0.0-pre.15" -source = "git+https://github.com/tari-project/tari.git#cb1eb6383a0887c95f869146b94c0da00f3faffd" +source = "git+https://github.com/ksrichard/tari.git?branch=p2pool#982c89a4de2b24de0dfd811733dd68a8f681e44a" + +[[package]] +name = "tari_features" +version = "1.0.0-pre.15" +source = "git+https://github.com/tari-project/tari.git#43b76d993d7ada9db2a8ebbc9b7969ba19279d6d" [[package]] name = "tari_hashing" version = "1.0.0-pre.15" -source = "git+https://github.com/tari-project/tari.git#cb1eb6383a0887c95f869146b94c0da00f3faffd" +source = "git+https://github.com/ksrichard/tari.git?branch=p2pool#982c89a4de2b24de0dfd811733dd68a8f681e44a" dependencies = [ "borsh", "digest", @@ -4798,7 +4691,7 @@ dependencies = [ [[package]] name = "tari_key_manager" version = "1.0.0-pre.15" -source = "git+https://github.com/tari-project/tari.git#cb1eb6383a0887c95f869146b94c0da00f3faffd" +source = "git+https://github.com/ksrichard/tari.git?branch=p2pool#982c89a4de2b24de0dfd811733dd68a8f681e44a" dependencies = [ "argon2", "async-trait", @@ -4819,7 +4712,7 @@ dependencies = [ "strum_macros", "subtle", "tari_common_sqlite", - "tari_common_types", + "tari_common_types 1.0.0-pre.15 (git+https://github.com/ksrichard/tari.git?branch=p2pool)", "tari_crypto", "tari_service_framework", "tari_utilities", @@ -4831,13 +4724,13 @@ dependencies = [ [[package]] name = "tari_mmr" version = "1.0.0-pre.15" -source = "git+https://github.com/tari-project/tari.git#cb1eb6383a0887c95f869146b94c0da00f3faffd" +source = "git+https://github.com/ksrichard/tari.git?branch=p2pool#982c89a4de2b24de0dfd811733dd68a8f681e44a" dependencies = [ "borsh", "digest", "log", "serde", - "tari_common", + "tari_common 1.0.0-pre.15 (git+https://github.com/ksrichard/tari.git?branch=p2pool)", "tari_crypto", "tari_utilities", "thiserror", @@ -4846,7 +4739,7 @@ dependencies = [ [[package]] name = "tari_p2p" version = "1.0.0-pre.15" -source = "git+https://github.com/tari-project/tari.git#cb1eb6383a0887c95f869146b94c0da00f3faffd" +source = "git+https://github.com/ksrichard/tari.git?branch=p2pool#982c89a4de2b24de0dfd811733dd68a8f681e44a" dependencies = [ "anyhow", "fs2", @@ -4857,7 +4750,7 @@ dependencies = [ "rand", "rustls 0.20.9", "serde", - "tari_common", + "tari_common 1.0.0-pre.15 (git+https://github.com/ksrichard/tari.git?branch=p2pool)", "tari_comms", "tari_comms_dht", "tari_crypto", @@ -4876,7 +4769,7 @@ dependencies = [ [[package]] name = "tari_script" version = "1.0.0-pre.15" -source = "git+https://github.com/tari-project/tari.git#cb1eb6383a0887c95f869146b94c0da00f3faffd" +source = "git+https://github.com/ksrichard/tari.git?branch=p2pool#982c89a4de2b24de0dfd811733dd68a8f681e44a" dependencies = [ "blake2", "borsh", @@ -4893,7 +4786,7 @@ dependencies = [ [[package]] name = "tari_service_framework" version = "1.0.0-pre.15" -source = "git+https://github.com/tari-project/tari.git#cb1eb6383a0887c95f869146b94c0da00f3faffd" +source = "git+https://github.com/ksrichard/tari.git?branch=p2pool#982c89a4de2b24de0dfd811733dd68a8f681e44a" dependencies = [ "anyhow", "async-trait", @@ -4908,7 +4801,7 @@ dependencies = [ [[package]] name = "tari_shutdown" version = "1.0.0-pre.15" -source = "git+https://github.com/tari-project/tari.git#cb1eb6383a0887c95f869146b94c0da00f3faffd" +source = "git+https://github.com/ksrichard/tari.git?branch=p2pool#982c89a4de2b24de0dfd811733dd68a8f681e44a" dependencies = [ "futures 0.3.30", ] @@ -4916,7 +4809,7 @@ dependencies = [ [[package]] name = "tari_storage" version = "1.0.0-pre.15" -source = "git+https://github.com/tari-project/tari.git#cb1eb6383a0887c95f869146b94c0da00f3faffd" +source = "git+https://github.com/ksrichard/tari.git?branch=p2pool#982c89a4de2b24de0dfd811733dd68a8f681e44a" dependencies = [ "bincode", "lmdb-zero", @@ -4928,7 +4821,7 @@ dependencies = [ [[package]] name = "tari_test_utils" version = "1.0.0-pre.15" -source = "git+https://github.com/tari-project/tari.git#cb1eb6383a0887c95f869146b94c0da00f3faffd" +source = "git+https://github.com/ksrichard/tari.git?branch=p2pool#982c89a4de2b24de0dfd811733dd68a8f681e44a" dependencies = [ "futures 0.3.30", "rand", @@ -4995,7 +4888,7 @@ checksum = "46c3384250002a6d5af4d114f2845d37b57521033f30d5c3f46c4d70e1197533" dependencies = [ "proc-macro2", "quote", - "syn 2.0.69", + "syn 2.0.68", ] [[package]] @@ -5018,16 +4911,6 @@ dependencies = [ "thiserror-impl-no-std", ] -[[package]] -name = "thread-id" -version = "4.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f0ec81c46e9eb50deaa257be2f148adf052d1fb7701cfd55ccfab2525280b70b" -dependencies = [ - "libc", - "winapi", -] - [[package]] name = "time" version = "0.3.36" @@ -5070,9 +4953,9 @@ dependencies = [ [[package]] name = "tinyvec" -version = "1.7.0" +version = "1.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ce6b6a2fb3a985e99cebfaefa9faa3024743da73304ca1c683a36429613d3d22" +checksum = "c55115c6fbe2d2bef26eb09ad74bde02d8255476fc0c7b515ef09fbb35742d82" dependencies = [ "tinyvec_macros", ] @@ -5120,7 +5003,7 @@ checksum = "5f5ae998a069d4b5aba8ee9dad856af7d520c3699e6159b185c2acd48155d39a" dependencies = [ "proc-macro2", "quote", - "syn 2.0.69", + "syn 2.0.68", ] [[package]] @@ -5328,7 +5211,7 @@ checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.69", + "syn 2.0.68", ] [[package]] @@ -5352,9 +5235,9 @@ dependencies = [ [[package]] name = "triomphe" -version = "0.1.11" +version = "0.1.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "859eb650cfee7434994602c3a68b25d77ad9e68c8a6cd491616ef86661382eb3" +checksum = "e6631e42e10b40c0690bf92f404ebcfe6e1fdb480391d15f17cc8e96eeed5369" [[package]] name = "trust-dns-client" @@ -5610,7 +5493,7 @@ dependencies = [ "once_cell", "proc-macro2", "quote", - "syn 2.0.69", + "syn 2.0.68", "wasm-bindgen-shared", ] @@ -5632,7 +5515,7 @@ checksum = "e94f17b526d0a461a191c78ea52bbce64071ed5c04c9ffe424dcb38f74171bb7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.69", + "syn 2.0.68", "wasm-bindgen-backend", "wasm-bindgen-shared", ] @@ -6018,7 +5901,7 @@ checksum = "fa4f8080344d4671fb4e831a13ad1e68092748387dfc4f55e356242fae12ce3e" dependencies = [ "proc-macro2", "quote", - "syn 2.0.69", + "syn 2.0.68", ] [[package]] @@ -6038,5 +5921,5 @@ checksum = "ce36e65b0d2999d2aafac989fb249189a141aee1f53c612c1f37d72631959f69" dependencies = [ "proc-macro2", "quote", - "syn 2.0.69", + "syn 2.0.68", ] diff --git a/Cargo.toml b/Cargo.toml index f71f2b64..763efffa 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -5,14 +5,17 @@ edition = "2021" [dependencies] #sha_p2pool_grpc = { path = "../sha_p2pool_grpc" } +#minotari_app_grpc = { git = "https://github.com/tari-project/tari.git" } +#minotari_node_grpc_client = { git = "https://github.com/tari-project/tari.git" } +minotari_app_grpc = { git = "https://github.com/ksrichard/tari.git", branch = "p2pool" } +minotari_node_grpc_client = { git = "https://github.com/ksrichard/tari.git", branch = "p2pool" } +tari_core = { git = "https://github.com/ksrichard/tari.git", branch = "p2pool" } -minotari_app_grpc = { git = "https://github.com/tari-project/tari.git" } -minotari_node_grpc_client = { git = "https://github.com/tari-project/tari.git" } +tari_crypto = "0.20.1" tari_common_types = { git = "https://github.com/tari-project/tari.git" } tari_common = { git = "https://github.com/tari-project/tari.git" } -tari_core = { git = "https://github.com/tari-project/tari.git" } - tari_utilities = { version = "0.7", features = ["borsh"] } + libp2p = { version = "0.53.2", features = [ "dns", "identify", @@ -33,7 +36,8 @@ tokio = { version = "1.38.0", features = ["full"] } thiserror = "1.0" serde = "1.0.203" anyhow = "1.0" -log = { version = "0.4", features = ["std"] } +log = "0.4.21" +env_logger = "0.11.3" tonic = "0.8.3" async-trait = "0.1.80" serde_cbor = "0.11.2" @@ -41,5 +45,5 @@ blake2 = "0.10.6" digest = "0.10.7" clap = { version = "4.5.7", features = ["derive"] } moka = { version = "0.12.7", features = ["future"] } -dirs = "4.0.0" -crossterm = "0.25.0" +rand = "0.8.0" + diff --git a/src/server/p2p/mod.rs b/src/server/p2p/mod.rs index 62cdba3e..2fba0a24 100644 --- a/src/server/p2p/mod.rs +++ b/src/server/p2p/mod.rs @@ -11,5 +11,5 @@ pub use p2p::*; pub(crate) mod client; mod error; pub mod messages; -mod p2p; +mod network; pub mod peer_store; diff --git a/src/server/p2p/p2p.rs b/src/server/p2p/network.rs similarity index 99% rename from src/server/p2p/p2p.rs rename to src/server/p2p/network.rs index dedcd263..15f08335 100644 --- a/src/server/p2p/p2p.rs +++ b/src/server/p2p/network.rs @@ -54,7 +54,7 @@ const BLOCK_VALIDATION_REQUESTS_TOPIC: &str = "block_validation_requests"; const BLOCK_VALIDATION_RESULTS_TOPIC: &str = "block_validation_results"; const NEW_BLOCK_TOPIC: &str = "new_block"; const SHARE_CHAIN_SYNC_REQ_RESP_PROTOCOL: &str = "/share_chain_sync/1"; -const LOG_TARGET: &str = "p2pool::server::p2p::p2p"; +const LOG_TARGET: &str = "p2p_service"; const STABLE_PRIVATE_KEY_FILE: &str = "p2pool_private.key"; #[derive(Clone, Debug)] From cf4cf5e8edaffc98c9a3a99748eba516e9872a0f Mon Sep 17 00:00:00 2001 From: dkf Date: Wed, 10 Jul 2024 15:15:25 +0100 Subject: [PATCH 5/5] chore: various fixes --- .github/workflows/integration_tests.yml | 7 ---- Cargo.lock | 45 ++++++++++++------------- Cargo.toml | 3 +- src/main.rs | 7 ---- 4 files changed, 22 insertions(+), 40 deletions(-) diff --git a/.github/workflows/integration_tests.yml b/.github/workflows/integration_tests.yml index 63f7d991..989f4328 100644 --- a/.github/workflows/integration_tests.yml +++ b/.github/workflows/integration_tests.yml @@ -91,9 +91,6 @@ jobs: tari-${{ runner.os }}-${{ runner.cpu-model }}-${{ env.toolchain }}-nightly-${{ hashFiles('**/Cargo.lock') }} tari-${{ runner.os }}-${{ runner.cpu-model }}-${{ env.toolchain }}-nightly - - name: cargo test compile - run: cargo test --no-run --locked --all-features --release ${{ env.TARGET_BINS }} - - name: upload artifact uses: actions/upload-artifact@v4 # upload test results as artifact if: always() @@ -158,10 +155,6 @@ jobs: tari-${{ runner.os }}-${{ runner.cpu-model }}-${{ env.toolchain }}-nightly-${{ hashFiles('**/Cargo.lock') }} tari-${{ runner.os }}-${{ runner.cpu-model }}-${{ env.toolchain }}-nightly - - name: cargo test compile - if: ${{ env.CI_FFI == 'true' }} - run: cargo test --no-run --locked --all-features --release ${{ env.TARGET_BINS }} - - name: upload artifact uses: actions/upload-artifact@v4 # upload test results as artifact if: always() diff --git a/Cargo.lock b/Cargo.lock index 150547ec..9ab359d4 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1070,6 +1070,15 @@ dependencies = [ "subtle", ] +[[package]] +name = "dirs" +version = "4.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ca3aa72a6f96ea37bbc5aa912f6788242832f75369bdfdadcb0e38423f100059" +dependencies = [ + "dirs-sys", +] + [[package]] name = "dirs-next" version = "1.0.2" @@ -1080,6 +1089,17 @@ dependencies = [ "dirs-sys-next", ] +[[package]] +name = "dirs-sys" +version = "0.3.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1b1d1d91c932ef41c0f2663aa8b0ca0342d444d842c06914aa0a7e352d0bada6" +dependencies = [ + "libc", + "redox_users", + "winapi", +] + [[package]] name = "dirs-sys-next" version = "0.1.2" @@ -1189,29 +1209,6 @@ dependencies = [ "syn 2.0.68", ] -[[package]] -name = "env_filter" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a009aa4810eb158359dda09d0c87378e4bbb89b5a801f016885a4707ba24f7ea" -dependencies = [ - "log", - "regex", -] - -[[package]] -name = "env_logger" -version = "0.11.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "38b35839ba51819680ba087cd351788c9a3c476841207e0b8cee0b04722343b9" -dependencies = [ - "anstream", - "anstyle", - "env_filter", - "humantime", - "log", -] - [[package]] name = "equivalent" version = "1.0.1" @@ -4051,7 +4048,7 @@ dependencies = [ "blake2", "clap 4.5.8", "digest", - "env_logger", + "dirs", "libp2p", "log", "minotari_app_grpc", diff --git a/Cargo.toml b/Cargo.toml index 763efffa..b6fb32f3 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -37,7 +37,6 @@ thiserror = "1.0" serde = "1.0.203" anyhow = "1.0" log = "0.4.21" -env_logger = "0.11.3" tonic = "0.8.3" async-trait = "0.1.80" serde_cbor = "0.11.2" @@ -46,4 +45,4 @@ digest = "0.10.7" clap = { version = "4.5.7", features = ["derive"] } moka = { version = "0.12.7", features = ["future"] } rand = "0.8.0" - +dirs = "4.0.0" diff --git a/src/main.rs b/src/main.rs index 48437b6c..2fb9ec81 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,14 +1,12 @@ // Copyright 2024 The Tari Project // SPDX-License-Identifier: BSD-3-Clause -use std::io::stdout; use std::path::PathBuf; use clap::{ builder::{styling::AnsiColor, Styles}, Parser, }; -use crossterm::{execute, terminal::SetTitle}; use log::LevelFilter; use tari_common::initialize_logging; @@ -106,11 +104,6 @@ async fn main() -> anyhow::Result<()> { return Err(e.into()); } - let terminal_title = "Decentralized mining pool for Tari network".to_string(); - if let Err(e) = execute!(stdout(), SetTitle(terminal_title.as_str())) { - println!("Error setting terminal title. {}", e) - } - let mut config_builder = server::Config::builder(); if let Some(grpc_port) = cli.grpc_port { config_builder.with_grpc_port(grpc_port);