From f2a2470fb440c6881afbeb2e6a0531bfe5cf1028 Mon Sep 17 00:00:00 2001 From: dnwiebe Date: Tue, 1 Apr 2025 07:35:08 -0400 Subject: [PATCH 1/4] Make Servers Stop Rejecting Requests (#599) * Tests passing * Removed dead code * Moved test back where it belongs * Formatting * Finished TEST_DEFAULT_CHAIN update * More BaseSepolia stuff * Corrected host and port detection in protocol packs; about to make ports non-optional * Abandoning this approach; will revert, but wanted to preserve * Revert "More BaseSepolia stuff" This reverts commit 10735ada8a237f8a82b44b829026935f6ce8e02a. * Everything's compiling now * Interim commit * Fixed the protocol pack * Review issues --- automap/Cargo.lock | 253 ++++++++++++++---- dns_utility/Cargo.lock | 159 ++++++++--- masq_lib/Cargo.toml | 1 + masq_lib/src/test_utils/utils.rs | 12 +- multinode_integration_tests/Cargo.toml | 2 +- node/Cargo.lock | 203 ++++++++++---- node/Cargo.toml | 3 - node/src/actor_system_factory.rs | 4 +- .../blockchain_interface_web3/utils.rs | 2 +- node/src/bootstrapper.rs | 12 +- node/src/daemon/setup_reporter.rs | 18 +- node/src/database/db_initializer.rs | 2 +- .../migrations/migration_1_to_2.rs | 2 +- .../migrations/migration_4_to_5.rs | 2 +- node/src/dispatcher.rs | 24 +- node/src/hopper/consuming_service.rs | 4 +- node/src/hopper/mod.rs | 4 +- node/src/hopper/routing_service.rs | 46 ++-- node/src/neighborhood/node_record.rs | 4 +- .../client_request_payload_factory.rs | 25 +- node/src/proxy_server/http_protocol_pack.rs | 92 +++---- node/src/proxy_server/mod.rs | 174 ++++++++---- node/src/proxy_server/protocol_pack.rs | 11 +- node/src/proxy_server/tls_protocol_pack.rs | 14 +- node/src/stream_handler_pool.rs | 8 +- node/src/stream_reader.rs | 16 +- node/src/sub_lib/dispatcher.rs | 12 +- node/src/sub_lib/route.rs | 16 +- node/src/sub_lib/stream_key.rs | 98 +++++-- node/tests/financials_test.rs | 50 +++- node/tests/ui_gateway_test.rs | 21 +- node/tests/utils.rs | 16 +- 32 files changed, 907 insertions(+), 403 deletions(-) diff --git a/automap/Cargo.lock b/automap/Cargo.lock index 73d051ebb..ee7e2ba72 100644 --- a/automap/Cargo.lock +++ b/automap/Cargo.lock @@ -9,7 +9,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6c616db5fa4b0c40702fb75201c2af7f8aa8f3a2e2c1dda3b0655772aa949666" dependencies = [ "actix_derive", - "bitflags", + "bitflags 1.3.2", "bytes 0.4.12", "crossbeam-channel 0.3.9", "failure", @@ -198,6 +198,12 @@ version = "1.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" +[[package]] +name = "bitflags" +version = "2.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c8214115b7bf84099f1309324e63141d4c5d7cc26862f97a0a857dbefe165bd" + [[package]] name = "bitvec" version = "0.17.4" @@ -310,7 +316,7 @@ checksum = "a0610544180c38b88101fecf2dd634b174a62eef6946f84dfc6a7127512b381c" dependencies = [ "ansi_term", "atty", - "bitflags", + "bitflags 1.3.2", "strsim", "textwrap", "unicode-width", @@ -323,7 +329,7 @@ version = "0.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ddfc5b9aa5d4507acaf872de71051dfd0e309860e88966e1051e462a077aac4f" dependencies = [ - "bitflags", + "bitflags 1.3.2", ] [[package]] @@ -351,8 +357,8 @@ version = "0.2.29" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d897f47bf7270cf70d370f8f98c1abb6d2d4cf60a6845d30e05bfb90c6568650" dependencies = [ - "proc-macro2 1.0.56", - "quote 1.0.26", + "proc-macro2 1.0.94", + "quote 1.0.40", "unicode-xid 0.2.4", ] @@ -485,10 +491,10 @@ dependencies = [ "cc", "codespan-reporting", "once_cell", - "proc-macro2 1.0.56", - "quote 1.0.26", + "proc-macro2 1.0.94", + "quote 1.0.40", "scratch", - "syn 2.0.15", + "syn 2.0.100", ] [[package]] @@ -503,9 +509,9 @@ version = "1.0.94" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2345488264226bf682893e25de0769f3360aac9957980ec49361b083ddaa5bc5" dependencies = [ - "proc-macro2 1.0.56", - "quote 1.0.26", - "syn 2.0.15", + "proc-macro2 1.0.94", + "quote 1.0.40", + "syn 2.0.100", ] [[package]] @@ -595,8 +601,8 @@ version = "0.1.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "aa4da3c766cd7a0db8242e326e9e4e081edd567072893ed320008189715366a4" dependencies = [ - "proc-macro2 1.0.56", - "quote 1.0.26", + "proc-macro2 1.0.94", + "quote 1.0.40", "syn 1.0.109", "synstructure", ] @@ -662,7 +668,7 @@ version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2e9763c69ebaae630ba35f74888db465e49e259ba1bc0eda7d06f4a067615d82" dependencies = [ - "bitflags", + "bitflags 1.3.2", "fuchsia-zircon-sys", ] @@ -709,6 +715,18 @@ dependencies = [ "wasi 0.11.0+wasi-snapshot-preview1", ] +[[package]] +name = "getrandom" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "43a49c392881ce6d5c3b8cb70f98717b7c07aabbdff06687b9030dbfbe2725f8" +dependencies = [ + "cfg-if 1.0.0", + "libc", + "wasi 0.13.3+wasi-0.2.2", + "windows-targets 0.52.6", +] + [[package]] name = "gimli" version = "0.27.2" @@ -962,9 +980,9 @@ checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" [[package]] name = "libc" -version = "0.2.142" +version = "0.2.171" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6a987beff54b60ffa6d51982e1aa1146bc42f19bd26be28b0586f252fccf5317" +checksum = "c19937216e9d3aa9956d9bb8dfc0b0c8beb6058fc4f7a4dc4d850edf86a237d6" [[package]] name = "libsecp256k1" @@ -1063,6 +1081,7 @@ dependencies = [ "lazy_static", "log 0.4.17", "nix", + "rand 0.9.0", "regex", "serde", "serde_derive", @@ -1198,7 +1217,7 @@ version = "0.23.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8f3790c00a0150112de0f4cd161e3d7fc4b2d8a5542ffc35f099a2562aecb35c" dependencies = [ - "bitflags", + "bitflags 1.3.2", "cc", "cfg-if 1.0.0", "libc", @@ -1379,9 +1398,9 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.56" +version = "1.0.94" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2b63bdb0cd06f1f4dedf69b254734f9b45af66e4a031e42a7480257d9898b435" +checksum = "a31971752e70b8b2686d7e46ec17fb38dad4051d94024c88df49b667caea9c84" dependencies = [ "unicode-ident", ] @@ -1403,11 +1422,11 @@ dependencies = [ [[package]] name = "quote" -version = "1.0.26" +version = "1.0.40" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4424af4bf778aae2051a77b60283332f386554255d722233d09fbfc7e30da2fc" +checksum = "1885c039570dc00dcb4ff087a89e185fd56bae234ddc7f056a945bf36467248d" dependencies = [ - "proc-macro2 1.0.56", + "proc-macro2 1.0.94", ] [[package]] @@ -1473,6 +1492,17 @@ dependencies = [ "rand_core 0.6.4", ] +[[package]] +name = "rand" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3779b94aeb87e8bd4e834cee3650289ee9e0d5677f976ecdb6d219e5f4f6cd94" +dependencies = [ + "rand_chacha 0.9.0", + "rand_core 0.9.3", + "zerocopy", +] + [[package]] name = "rand_chacha" version = "0.1.1" @@ -1503,6 +1533,16 @@ dependencies = [ "rand_core 0.6.4", ] +[[package]] +name = "rand_chacha" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d3022b5f1df60f26e1ffddd6c66e8aa15de382ae63b3a0c1bfc0e4d3e3f325cb" +dependencies = [ + "ppv-lite86", + "rand_core 0.9.3", +] + [[package]] name = "rand_core" version = "0.3.1" @@ -1536,6 +1576,15 @@ dependencies = [ "getrandom 0.2.9", ] +[[package]] +name = "rand_core" +version = "0.9.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "99d9a13982dcf210057a8a78572b2217b667c3beacbf3a0d8b454f6f82837d38" +dependencies = [ + "getrandom 0.3.1", +] + [[package]] name = "rand_hc" version = "0.1.0" @@ -1637,7 +1686,7 @@ version = "0.2.16" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fb5a58c1855b4b6819d59012155603f0b22ad30cad752600aadfcb695265519a" dependencies = [ - "bitflags", + "bitflags 1.3.2", ] [[package]] @@ -1765,9 +1814,9 @@ version = "1.0.160" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "291a097c63d8497e00160b166a967a4a79c64f3facdd01cbd7502231688d77df" dependencies = [ - "proc-macro2 1.0.56", - "quote 1.0.26", - "syn 2.0.15", + "proc-macro2 1.0.94", + "quote 1.0.40", + "syn 2.0.100", ] [[package]] @@ -1890,19 +1939,19 @@ version = "1.0.109" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237" dependencies = [ - "proc-macro2 1.0.56", - "quote 1.0.26", + "proc-macro2 1.0.94", + "quote 1.0.40", "unicode-ident", ] [[package]] name = "syn" -version = "2.0.15" +version = "2.0.100" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a34fcf3e8b60f57e6a14301a2e916d323af98b0ea63c599441eec8558660c822" +checksum = "b09a44accad81e1ba1cd74a32461ba89dee89095ba17b32f5d03683b1b1fc2a0" dependencies = [ - "proc-macro2 1.0.56", - "quote 1.0.26", + "proc-macro2 1.0.94", + "quote 1.0.40", "unicode-ident", ] @@ -1912,8 +1961,8 @@ version = "0.12.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f36bdaa60a83aca3921b5259d5400cbf5e90fc51931376a9bd4a0eb79aa7210f" dependencies = [ - "proc-macro2 1.0.56", - "quote 1.0.26", + "proc-macro2 1.0.94", + "quote 1.0.40", "syn 1.0.109", "unicode-xid 0.2.4", ] @@ -1951,9 +2000,9 @@ version = "1.0.40" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f9456a42c5b0d803c8cd86e73dd7cc9edd429499f37a3550d286d5e86720569f" dependencies = [ - "proc-macro2 1.0.56", - "quote 1.0.26", - "syn 2.0.15", + "proc-macro2 1.0.94", + "quote 1.0.40", + "syn 2.0.100", ] [[package]] @@ -2445,6 +2494,15 @@ version = "0.11.0+wasi-snapshot-preview1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" +[[package]] +name = "wasi" +version = "0.13.3+wasi-0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "26816d2e1a4a36a2940b96c5296ce403917633dff8f3440e9b236ed6f6bacad2" +dependencies = [ + "wit-bindgen-rt", +] + [[package]] name = "wasm-bindgen" version = "0.2.84" @@ -2464,8 +2522,8 @@ dependencies = [ "bumpalo", "log 0.4.17", "once_cell", - "proc-macro2 1.0.56", - "quote 1.0.26", + "proc-macro2 1.0.94", + "quote 1.0.40", "syn 1.0.109", "wasm-bindgen-shared", ] @@ -2476,7 +2534,7 @@ version = "0.2.84" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4c21f77c0bedc37fd5dc21f897894a5ca01e7bb159884559461862ae90c0b4c5" dependencies = [ - "quote 1.0.26", + "quote 1.0.40", "wasm-bindgen-macro-support", ] @@ -2486,8 +2544,8 @@ version = "0.2.84" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2aff81306fcac3c7515ad4e177f521b5c9a15f2b08f4e32d823066102f35a5f6" dependencies = [ - "proc-macro2 1.0.56", - "quote 1.0.26", + "proc-macro2 1.0.94", + "quote 1.0.40", "syn 1.0.109", "wasm-bindgen-backend", "wasm-bindgen-shared", @@ -2519,7 +2577,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "49aec794b07318993d1db16156d5a9c750120597a5ee40c6b928d416186cb138" dependencies = [ "base64 0.10.1", - "bitflags", + "bitflags 1.3.2", "byteorder", "rand 0.6.5", "sha-1", @@ -2586,7 +2644,7 @@ version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e686886bc078bc1b0b600cac0147aadb815089b6e4da64016cbd754b6342700f" dependencies = [ - "windows-targets", + "windows-targets 0.48.0", ] [[package]] @@ -2595,13 +2653,29 @@ version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7b1eb6f0cd7c80c79759c929114ef071b87354ce476d9d94271031c0497adfd5" dependencies = [ - "windows_aarch64_gnullvm", - "windows_aarch64_msvc", - "windows_i686_gnu", - "windows_i686_msvc", - "windows_x86_64_gnu", - "windows_x86_64_gnullvm", - "windows_x86_64_msvc", + "windows_aarch64_gnullvm 0.48.0", + "windows_aarch64_msvc 0.48.0", + "windows_i686_gnu 0.48.0", + "windows_i686_msvc 0.48.0", + "windows_x86_64_gnu 0.48.0", + "windows_x86_64_gnullvm 0.48.0", + "windows_x86_64_msvc 0.48.0", +] + +[[package]] +name = "windows-targets" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973" +dependencies = [ + "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.6", + "windows_x86_64_gnu 0.52.6", + "windows_x86_64_gnullvm 0.52.6", + "windows_x86_64_msvc 0.52.6", ] [[package]] @@ -2610,42 +2684,90 @@ version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "91ae572e1b79dba883e0d315474df7305d12f569b400fcf90581b06062f7e1bc" +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3" + [[package]] name = "windows_aarch64_msvc" version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b2ef27e0d7bdfcfc7b868b317c1d32c641a6fe4629c171b8928c7b08d98d7cf3" +[[package]] +name = "windows_aarch64_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469" + [[package]] name = "windows_i686_gnu" version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "622a1962a7db830d6fd0a69683c80a18fda201879f0f447f065a3b7467daa241" +[[package]] +name = "windows_i686_gnu" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b" + +[[package]] +name = "windows_i686_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66" + [[package]] name = "windows_i686_msvc" version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4542c6e364ce21bf45d69fdd2a8e455fa38d316158cfd43b3ac1c5b1b19f8e00" +[[package]] +name = "windows_i686_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66" + [[package]] name = "windows_x86_64_gnu" version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ca2b8a661f7628cbd23440e50b05d705db3686f894fc9580820623656af974b1" +[[package]] +name = "windows_x86_64_gnu" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78" + [[package]] name = "windows_x86_64_gnullvm" version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7896dbc1f41e08872e9d5e8f8baa8fdd2677f29468c4e156210174edc7f7b953" +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d" + [[package]] name = "windows_x86_64_msvc" version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1a515f5799fe4961cb532f983ce2b23082366b898e52ffbce459c86f67c8378a" +[[package]] +name = "windows_x86_64_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" + [[package]] name = "winreg" version = "0.5.1" @@ -2655,6 +2777,15 @@ dependencies = [ "winapi 0.3.9", ] +[[package]] +name = "wit-bindgen-rt" +version = "0.33.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3268f3d866458b787f390cf61f4bbb563b922d091359f9608842999eaee3943c" +dependencies = [ + "bitflags 2.9.0", +] + [[package]] name = "ws2_32-sys" version = "0.2.1" @@ -2685,3 +2816,23 @@ name = "yansi" version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "09041cd90cf85f7f8b2df60c646f853b7f535ce68f85244eb6731cf89fa498ec" + +[[package]] +name = "zerocopy" +version = "0.8.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fd97444d05a4328b90e75e503a34bad781f14e28a823ad3557f0750df1ebcbc6" +dependencies = [ + "zerocopy-derive", +] + +[[package]] +name = "zerocopy-derive" +version = "0.8.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6352c01d0edd5db859a63e2605f4ea3183ddbd15e2c4a9e7d32184df75e4f154" +dependencies = [ + "proc-macro2 1.0.94", + "quote 1.0.40", + "syn 2.0.100", +] diff --git a/dns_utility/Cargo.lock b/dns_utility/Cargo.lock index 59f5a3bda..a497a59dc 100644 --- a/dns_utility/Cargo.lock +++ b/dns_utility/Cargo.lock @@ -9,7 +9,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6c616db5fa4b0c40702fb75201c2af7f8aa8f3a2e2c1dda3b0655772aa949666" dependencies = [ "actix_derive", - "bitflags", + "bitflags 1.3.2", "bytes", "crossbeam-channel 0.3.9", "failure", @@ -160,6 +160,12 @@ version = "1.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" +[[package]] +name = "bitflags" +version = "2.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c8214115b7bf84099f1309324e63141d4c5d7cc26862f97a0a857dbefe165bd" + [[package]] name = "bitvec" version = "0.17.4" @@ -245,7 +251,7 @@ checksum = "a0610544180c38b88101fecf2dd634b174a62eef6946f84dfc6a7127512b381c" dependencies = [ "ansi_term", "atty", - "bitflags", + "bitflags 1.3.2", "strsim", "textwrap", "unicode-width", @@ -258,7 +264,7 @@ version = "0.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ddfc5b9aa5d4507acaf872de71051dfd0e309860e88966e1051e462a077aac4f" dependencies = [ - "bitflags", + "bitflags 1.3.2", ] [[package]] @@ -276,8 +282,8 @@ version = "0.2.29" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d897f47bf7270cf70d370f8f98c1abb6d2d4cf60a6845d30e05bfb90c6568650" dependencies = [ - "proc-macro2 1.0.56", - "quote 1.0.26", + "proc-macro2 1.0.94", + "quote 1.0.40", "unicode-xid 0.2.4", ] @@ -499,8 +505,8 @@ version = "0.1.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "aa4da3c766cd7a0db8242e326e9e4e081edd567072893ed320008189715366a4" dependencies = [ - "proc-macro2 1.0.56", - "quote 1.0.26", + "proc-macro2 1.0.94", + "quote 1.0.40", "syn 1.0.109", "synstructure", ] @@ -541,7 +547,7 @@ version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2e9763c69ebaae630ba35f74888db465e49e259ba1bc0eda7d06f4a067615d82" dependencies = [ - "bitflags", + "bitflags 1.3.2", "fuchsia-zircon-sys", ] @@ -588,6 +594,18 @@ dependencies = [ "wasi 0.11.0+wasi-snapshot-preview1", ] +[[package]] +name = "getrandom" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "73fea8450eea4bac3940448fb7ae50d91f034f941199fcd9d909a5a07aa455f0" +dependencies = [ + "cfg-if 1.0.0", + "libc", + "r-efi", + "wasi 0.14.2+wasi-0.2.4", +] + [[package]] name = "gimli" version = "0.27.2" @@ -780,9 +798,9 @@ checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" [[package]] name = "libc" -version = "0.2.147" +version = "0.2.171" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b4668fb0ea861c1df094127ac5f1da3409a82116a4ba74fca2e58ef927159bb3" +checksum = "c19937216e9d3aa9956d9bb8dfc0b0c8beb6058fc4f7a4dc4d850edf86a237d6" [[package]] name = "libsecp256k1" @@ -866,6 +884,7 @@ dependencies = [ "lazy_static", "log 0.4.17", "nix", + "rand 0.9.0", "regex", "serde", "serde_derive", @@ -1001,7 +1020,7 @@ version = "0.23.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8f3790c00a0150112de0f4cd161e3d7fc4b2d8a5542ffc35f099a2562aecb35c" dependencies = [ - "bitflags", + "bitflags 1.3.2", "cc", "cfg-if 1.0.0", "libc", @@ -1139,9 +1158,9 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.56" +version = "1.0.94" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2b63bdb0cd06f1f4dedf69b254734f9b45af66e4a031e42a7480257d9898b435" +checksum = "a31971752e70b8b2686d7e46ec17fb38dad4051d94024c88df49b667caea9c84" dependencies = [ "unicode-ident", ] @@ -1163,13 +1182,19 @@ dependencies = [ [[package]] name = "quote" -version = "1.0.26" +version = "1.0.40" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4424af4bf778aae2051a77b60283332f386554255d722233d09fbfc7e30da2fc" +checksum = "1885c039570dc00dcb4ff087a89e185fd56bae234ddc7f056a945bf36467248d" dependencies = [ - "proc-macro2 1.0.56", + "proc-macro2 1.0.94", ] +[[package]] +name = "r-efi" +version = "5.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "74765f6d916ee2faa39bc8e68e4f3ed8949b48cccdac59983d287a7cb71ce9c5" + [[package]] name = "radium" version = "0.3.0" @@ -1221,6 +1246,17 @@ dependencies = [ "rand_hc 0.2.0", ] +[[package]] +name = "rand" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3779b94aeb87e8bd4e834cee3650289ee9e0d5677f976ecdb6d219e5f4f6cd94" +dependencies = [ + "rand_chacha 0.9.0", + "rand_core 0.9.3", + "zerocopy", +] + [[package]] name = "rand_chacha" version = "0.1.1" @@ -1241,6 +1277,16 @@ dependencies = [ "rand_core 0.5.1", ] +[[package]] +name = "rand_chacha" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d3022b5f1df60f26e1ffddd6c66e8aa15de382ae63b3a0c1bfc0e4d3e3f325cb" +dependencies = [ + "ppv-lite86", + "rand_core 0.9.3", +] + [[package]] name = "rand_core" version = "0.3.1" @@ -1265,6 +1311,15 @@ dependencies = [ "getrandom 0.1.16", ] +[[package]] +name = "rand_core" +version = "0.9.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "99d9a13982dcf210057a8a78572b2217b667c3beacbf3a0d8b454f6f82837d38" +dependencies = [ + "getrandom 0.3.2", +] + [[package]] name = "rand_hc" version = "0.1.0" @@ -1357,7 +1412,7 @@ version = "0.2.16" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fb5a58c1855b4b6819d59012155603f0b22ad30cad752600aadfcb695265519a" dependencies = [ - "bitflags", + "bitflags 1.3.2", ] [[package]] @@ -1479,9 +1534,9 @@ version = "1.0.160" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "291a097c63d8497e00160b166a967a4a79c64f3facdd01cbd7502231688d77df" dependencies = [ - "proc-macro2 1.0.56", - "quote 1.0.26", - "syn 2.0.15", + "proc-macro2 1.0.94", + "quote 1.0.40", + "syn 2.0.100", ] [[package]] @@ -1604,19 +1659,19 @@ version = "1.0.109" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237" dependencies = [ - "proc-macro2 1.0.56", - "quote 1.0.26", + "proc-macro2 1.0.94", + "quote 1.0.40", "unicode-ident", ] [[package]] name = "syn" -version = "2.0.15" +version = "2.0.100" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a34fcf3e8b60f57e6a14301a2e916d323af98b0ea63c599441eec8558660c822" +checksum = "b09a44accad81e1ba1cd74a32461ba89dee89095ba17b32f5d03683b1b1fc2a0" dependencies = [ - "proc-macro2 1.0.56", - "quote 1.0.26", + "proc-macro2 1.0.94", + "quote 1.0.40", "unicode-ident", ] @@ -1626,8 +1681,8 @@ version = "0.12.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f36bdaa60a83aca3921b5259d5400cbf5e90fc51931376a9bd4a0eb79aa7210f" dependencies = [ - "proc-macro2 1.0.56", - "quote 1.0.26", + "proc-macro2 1.0.94", + "quote 1.0.40", "syn 1.0.109", "unicode-xid 0.2.4", ] @@ -1638,7 +1693,7 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dd4bc0637a2b8c0b1a5145cca3e21b707865edc7e32285771536af1ade129468" dependencies = [ - "bitflags", + "bitflags 1.3.2", "core-foundation", "system-configuration-sys", ] @@ -1677,9 +1732,9 @@ version = "1.0.40" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f9456a42c5b0d803c8cd86e73dd7cc9edd429499f37a3550d286d5e86720569f" dependencies = [ - "proc-macro2 1.0.56", - "quote 1.0.26", - "syn 2.0.15", + "proc-macro2 1.0.94", + "quote 1.0.40", + "syn 2.0.100", ] [[package]] @@ -2160,6 +2215,15 @@ version = "0.11.0+wasi-snapshot-preview1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" +[[package]] +name = "wasi" +version = "0.14.2+wasi-0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9683f9a5a998d873c0d21fcbe3c083009670149a8fab228644b8bd36b2c48cb3" +dependencies = [ + "wit-bindgen-rt", +] + [[package]] name = "websocket" version = "0.26.5" @@ -2180,7 +2244,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "49aec794b07318993d1db16156d5a9c750120597a5ee40c6b928d416186cb138" dependencies = [ "base64 0.10.1", - "bitflags", + "bitflags 1.3.2", "byteorder", "rand 0.6.5", "sha-1", @@ -2259,6 +2323,15 @@ dependencies = [ "winapi 0.3.9", ] +[[package]] +name = "wit-bindgen-rt" +version = "0.39.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6f42320e61fe2cfd34354ecb597f86f413484a798ba44a8ca1165c58d42da6c1" +dependencies = [ + "bitflags 2.9.0", +] + [[package]] name = "ws2_32-sys" version = "0.2.1" @@ -2268,3 +2341,23 @@ dependencies = [ "winapi 0.2.8", "winapi-build", ] + +[[package]] +name = "zerocopy" +version = "0.8.24" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2586fea28e186957ef732a5f8b3be2da217d65c5969d4b1e17f973ebbe876879" +dependencies = [ + "zerocopy-derive", +] + +[[package]] +name = "zerocopy-derive" +version = "0.8.24" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a996a8f63c5c4448cd959ac1bab0aaa3306ccfd060472f85943ee0750f0169be" +dependencies = [ + "proc-macro2 1.0.94", + "quote 1.0.40", + "syn 2.0.100", +] diff --git a/masq_lib/Cargo.toml b/masq_lib/Cargo.toml index af1fd5d15..7375ea461 100644 --- a/masq_lib/Cargo.toml +++ b/masq_lib/Cargo.toml @@ -17,6 +17,7 @@ ethereum-types = "0.9.0" itertools = "0.10.1" lazy_static = "1.4.0" log = "0.4.8" +rand = { version = "0.9.0", features = ["thread_rng"] } regex = "1.5.4" serde = "1.0.133" serde_derive = "1.0.133" diff --git a/masq_lib/src/test_utils/utils.rs b/masq_lib/src/test_utils/utils.rs index fa279a4f4..342472aef 100644 --- a/masq_lib/src/test_utils/utils.rs +++ b/masq_lib/src/test_utils/utils.rs @@ -5,9 +5,10 @@ use crate::test_utils::environment_guard::EnvironmentGuard; use serde_derive::Serialize; use std::fs; use std::path::{Path, PathBuf}; +use std::process::Command; use std::time::Duration; -pub const TEST_DEFAULT_CHAIN: Chain = Chain::EthRopsten; +pub const TEST_DEFAULT_CHAIN: Chain = Chain::BaseSepolia; pub const TEST_DEFAULT_MULTINODE_CHAIN: Chain = Chain::Dev; pub const BASE_TEST_DIR: &str = "generated/test"; const MASQ_SOURCE_CODE_UNAVAILABLE: &str = "MASQ_SOURCE_CODE_UNAVAILABLE"; @@ -49,6 +50,13 @@ pub fn ensure_node_home_directory_exists(module: &str, name: &str) -> PathBuf { home_dir } +pub fn open_all_file_permissions(dir: PathBuf) { + let _ = Command::new("chmod") + .args(&["-R", "777", dir.to_str().unwrap()]) + .output() + .expect("Couldn't chmod 777 files in directory"); +} + pub fn is_running_under_github_actions() -> bool { is_env_variable_set("GITHUB_ACTIONS", "true") } @@ -109,7 +117,7 @@ mod tests { #[test] fn constants_have_correct_values() { - assert_eq!(TEST_DEFAULT_CHAIN, Chain::EthRopsten); + assert_eq!(TEST_DEFAULT_CHAIN, Chain::BaseSepolia); assert_eq!(TEST_DEFAULT_MULTINODE_CHAIN, Chain::Dev); assert_eq!(BASE_TEST_DIR, "generated/test"); } diff --git a/multinode_integration_tests/Cargo.toml b/multinode_integration_tests/Cargo.toml index 18bb5a16d..0030df977 100644 --- a/multinode_integration_tests/Cargo.toml +++ b/multinode_integration_tests/Cargo.toml @@ -18,7 +18,7 @@ lazy_static = "1.4.0" log = "0.4.14" masq_lib = { path = "../masq_lib" } native-tls = "0.2.8" -node = { path = "../node", features = [ "expose_test_privates" ] } +node = { path = "../node" } pretty-hex = "0.2.1" primitive-types = {version = "0.5.0", default-features = false, features = ["default", "rlp", "serde"] } regex = "1.5.4" diff --git a/node/Cargo.lock b/node/Cargo.lock index 63e2b2029..976d2a676 100644 --- a/node/Cargo.lock +++ b/node/Cargo.lock @@ -9,7 +9,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6c616db5fa4b0c40702fb75201c2af7f8aa8f3a2e2c1dda3b0655772aa949666" dependencies = [ "actix_derive", - "bitflags", + "bitflags 1.2.1", "bytes 0.4.12", "crossbeam-channel 0.3.9", "failure", @@ -259,6 +259,12 @@ version = "1.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cf1de2fe8c75bc145a2f577add951f8134889b4795d47466a54a5c846d691693" +[[package]] +name = "bitflags" +version = "2.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c8214115b7bf84099f1309324e63141d4c5d7cc26862f97a0a857dbefe165bd" + [[package]] name = "bitvec" version = "0.17.4" @@ -399,7 +405,7 @@ checksum = "37e58ac78573c40708d45522f0d80fa2f01cc4f9b4e2bf749807255454312002" dependencies = [ "ansi_term", "atty", - "bitflags", + "bitflags 1.2.1", "strsim", "textwrap", "unicode-width", @@ -412,7 +418,7 @@ version = "0.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ddfc5b9aa5d4507acaf872de71051dfd0e309860e88966e1051e462a077aac4f" dependencies = [ - "bitflags", + "bitflags 1.2.1", ] [[package]] @@ -430,8 +436,8 @@ version = "0.2.22" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ef196d5d972878a48da7decb7686eded338b4858fbabeed513d63a7c98b2b82d" dependencies = [ - "proc-macro2 1.0.59", - "quote 1.0.28", + "proc-macro2 1.0.94", + "quote 1.0.40", "unicode-xid 0.2.1", ] @@ -689,8 +695,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "40eebddd2156ce1bb37b20bbe5151340a31828b1f2d22ba4141f3531710e38df" dependencies = [ "convert_case", - "proc-macro2 1.0.59", - "quote 1.0.28", + "proc-macro2 1.0.94", + "quote 1.0.40", "rustc_version 0.3.3", "syn 1.0.85", ] @@ -880,8 +886,8 @@ version = "0.1.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "aa4da3c766cd7a0db8242e326e9e4e081edd567072893ed320008189715366a4" dependencies = [ - "proc-macro2 1.0.59", - "quote 1.0.28", + "proc-macro2 1.0.94", + "quote 1.0.40", "syn 1.0.85", "synstructure", ] @@ -1025,7 +1031,7 @@ version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2e9763c69ebaae630ba35f74888db465e49e259ba1bc0eda7d06f4a067615d82" dependencies = [ - "bitflags", + "bitflags 1.2.1", "fuchsia-zircon-sys", ] @@ -1132,6 +1138,18 @@ dependencies = [ "wasi 0.10.0+wasi-snapshot-preview1", ] +[[package]] +name = "getrandom" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "73fea8450eea4bac3940448fb7ae50d91f034f941199fcd9d909a5a07aa455f0" +dependencies = [ + "cfg-if 1.0.0", + "libc", + "r-efi", + "wasi 0.14.2+wasi-0.2.4", +] + [[package]] name = "gimli" version = "0.23.0" @@ -1644,9 +1662,9 @@ checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" [[package]] name = "libc" -version = "0.2.145" +version = "0.2.171" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fc86cde3ff845662b8f4ef6cb50ea0e20c524eb3d29ae048287e06a1b3fa6a81" +checksum = "c19937216e9d3aa9956d9bb8dfc0b0c8beb6058fc4f7a4dc4d850edf86a237d6" [[package]] name = "libsecp256k1" @@ -1834,6 +1852,7 @@ dependencies = [ "lazy_static", "log 0.4.18", "nix 0.23.1", + "rand 0.9.0", "regex", "serde", "serde_derive", @@ -1987,7 +2006,7 @@ version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8d3b281c45a2dbb0609b854de9df94694fb77eab2fa2933c07d07001dcb29377" dependencies = [ - "bitflags", + "bitflags 1.2.1", "libc", "nix 0.23.1", "smallstr", @@ -2071,7 +2090,7 @@ version = "0.23.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9f866317acbd3a240710c63f065ffb1e4fd466259045ccb504130b7f668f35c6" dependencies = [ - "bitflags", + "bitflags 1.2.1", "cc", "cfg-if 1.0.0", "libc", @@ -2084,7 +2103,7 @@ version = "0.26.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "46a58d1d356c6597d08cde02c2f09d785b09e28711837b1ed667dc652c08a694" dependencies = [ - "bitflags", + "bitflags 1.2.1", "cfg-if 1.0.0", "libc", "static_assertions 1.1.0", @@ -2308,7 +2327,7 @@ version = "0.10.38" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0c7ae222234c30df141154f159066c5093ff73b63204dcda7121eb082fc56a95" dependencies = [ - "bitflags", + "bitflags 1.2.1", "cfg-if 1.0.0", "foreign-types", "libc", @@ -2539,8 +2558,8 @@ version = "1.0.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b95af56fee93df76d721d356ac1ca41fccf168bc448eb14049234df764ba3e76" dependencies = [ - "proc-macro2 1.0.59", - "quote 1.0.28", + "proc-macro2 1.0.94", + "quote 1.0.40", "syn 1.0.85", ] @@ -2570,9 +2589,12 @@ checksum = "325a6d2ac5dee293c3b2612d4993b98aec1dff096b0a2dae70ed7d95784a05da" [[package]] name = "ppv-lite86" -version = "0.2.9" +version = "0.2.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c36fa947111f5c62a733b652544dd0016a43ce89619538a8ef92724a6f501a20" +checksum = "85eae3c4ed2f50dcfe72643da4befc30deadb458a9b590d720cde2f2b1e97da9" +dependencies = [ + "zerocopy", +] [[package]] name = "pretty-hex" @@ -2629,9 +2651,9 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.59" +version = "1.0.94" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6aeca18b86b413c660b781aa319e4e2648a3e6f9eadc9b47e9038e6fe9f3451b" +checksum = "a31971752e70b8b2686d7e46ec17fb38dad4051d94024c88df49b667caea9c84" dependencies = [ "unicode-ident", ] @@ -2653,13 +2675,19 @@ dependencies = [ [[package]] name = "quote" -version = "1.0.28" +version = "1.0.40" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1b9ab9c7eadfd8df19006f1cf1a4aed13540ed5cbc047010ece5826e10825488" +checksum = "1885c039570dc00dcb4ff087a89e185fd56bae234ddc7f056a945bf36467248d" dependencies = [ - "proc-macro2 1.0.59", + "proc-macro2 1.0.94", ] +[[package]] +name = "r-efi" +version = "5.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "74765f6d916ee2faa39bc8e68e4f3ed8949b48cccdac59983d287a7cb71ce9c5" + [[package]] name = "radium" version = "0.3.0" @@ -2734,6 +2762,17 @@ dependencies = [ "rand_hc 0.3.1", ] +[[package]] +name = "rand" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3779b94aeb87e8bd4e834cee3650289ee9e0d5677f976ecdb6d219e5f4f6cd94" +dependencies = [ + "rand_chacha 0.9.0", + "rand_core 0.9.3", + "zerocopy", +] + [[package]] name = "rand_chacha" version = "0.1.1" @@ -2764,6 +2803,16 @@ dependencies = [ "rand_core 0.6.3", ] +[[package]] +name = "rand_chacha" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d3022b5f1df60f26e1ffddd6c66e8aa15de382ae63b3a0c1bfc0e4d3e3f325cb" +dependencies = [ + "ppv-lite86", + "rand_core 0.9.3", +] + [[package]] name = "rand_core" version = "0.3.1" @@ -2797,6 +2846,15 @@ dependencies = [ "getrandom 0.2.3", ] +[[package]] +name = "rand_core" +version = "0.9.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "99d9a13982dcf210057a8a78572b2217b667c3beacbf3a0d8b454f6f82837d38" +dependencies = [ + "getrandom 0.3.2", +] + [[package]] name = "rand_hc" version = "0.1.0" @@ -2932,7 +2990,7 @@ version = "0.2.10" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8383f39639269cde97d255a32bdb68c047337295414940c68bdd30c2e13203ff" dependencies = [ - "bitflags", + "bitflags 1.2.1", ] [[package]] @@ -3052,7 +3110,7 @@ version = "0.28.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "01e213bc3ecb39ac32e81e51ebe31fd888a940515173e3a18a35f8c6e896422a" dependencies = [ - "bitflags", + "bitflags 1.2.1", "fallible-iterator", "fallible-streaming-iterator", "hashlink", @@ -3194,7 +3252,7 @@ version = "2.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "23a2ac85147a3a11d77ecf1bc7166ec0b92febfa4461c37944e180f319ece467" dependencies = [ - "bitflags", + "bitflags 1.2.1", "core-foundation 0.9.2", "core-foundation-sys 0.8.3", "libc", @@ -3269,8 +3327,8 @@ version = "1.0.136" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "08597e7152fcd306f41838ed3e37be9eaeed2b61c42e2117266a554fab4662f9" dependencies = [ - "proc-macro2 1.0.59", - "quote 1.0.28", + "proc-macro2 1.0.94", + "quote 1.0.40", "syn 1.0.85", ] @@ -3314,8 +3372,8 @@ version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b2acd6defeddb41eb60bb468f8825d0cfd0c2a76bc03bfd235b6a1dc4f6a1ad5" dependencies = [ - "proc-macro2 1.0.59", - "quote 1.0.28", + "proc-macro2 1.0.94", + "quote 1.0.40", "syn 1.0.85", ] @@ -3532,19 +3590,30 @@ version = "1.0.85" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a684ac3dcd8913827e18cd09a68384ee66c1de24157e3c556c9ab16d85695fb7" dependencies = [ - "proc-macro2 1.0.59", - "quote 1.0.28", + "proc-macro2 1.0.94", + "quote 1.0.40", "unicode-xid 0.2.1", ] +[[package]] +name = "syn" +version = "2.0.100" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b09a44accad81e1ba1cd74a32461ba89dee89095ba17b32f5d03683b1b1fc2a0" +dependencies = [ + "proc-macro2 1.0.94", + "quote 1.0.40", + "unicode-ident", +] + [[package]] name = "synstructure" version = "0.12.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b834f2d66f734cb897113e34aaff2f1ab4719ca946f9a7358dba8f8064148701" dependencies = [ - "proc-macro2 1.0.59", - "quote 1.0.28", + "proc-macro2 1.0.94", + "quote 1.0.40", "syn 1.0.85", "unicode-xid 0.2.1", ] @@ -3570,7 +3639,7 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dd4bc0637a2b8c0b1a5145cca3e21b707865edc7e32285771536af1ade129468" dependencies = [ - "bitflags", + "bitflags 1.2.1", "core-foundation 0.7.0", "system-configuration-sys", ] @@ -3636,8 +3705,8 @@ version = "1.0.30" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "aa32fd3f627f367fe16f893e2597ae3c05020f8bba2666a4e6ea73d377e5714b" dependencies = [ - "proc-macro2 1.0.59", - "quote 1.0.28", + "proc-macro2 1.0.94", + "quote 1.0.40", "syn 1.0.85", ] @@ -4334,7 +4403,7 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "aae2faf80ac463422992abf4de234731279c058aaf33171ca70277c98406b124" dependencies = [ - "quote 1.0.28", + "quote 1.0.40", "syn 1.0.85", ] @@ -4395,6 +4464,15 @@ version = "0.10.0+wasi-snapshot-preview1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1a143597ca7c7793eff794def352d41792a93c481eb1042423ff7ff72ba2c31f" +[[package]] +name = "wasi" +version = "0.14.2+wasi-0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9683f9a5a998d873c0d21fcbe3c083009670149a8fab228644b8bd36b2c48cb3" +dependencies = [ + "wit-bindgen-rt", +] + [[package]] name = "wasm-bindgen" version = "0.2.78" @@ -4414,8 +4492,8 @@ dependencies = [ "bumpalo", "lazy_static", "log 0.4.18", - "proc-macro2 1.0.59", - "quote 1.0.28", + "proc-macro2 1.0.94", + "quote 1.0.40", "syn 1.0.85", "wasm-bindgen-shared", ] @@ -4438,7 +4516,7 @@ version = "0.2.78" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d56146e7c495528bf6587663bea13a8eb588d39b36b679d83972e1a2dbbdacf9" dependencies = [ - "quote 1.0.28", + "quote 1.0.40", "wasm-bindgen-macro-support", ] @@ -4448,8 +4526,8 @@ version = "0.2.78" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7803e0eea25835f8abdc585cd3021b3deb11543c6fe226dcd30b228857c5c5ab" dependencies = [ - "proc-macro2 1.0.59", - "quote 1.0.28", + "proc-macro2 1.0.94", + "quote 1.0.40", "syn 1.0.85", "wasm-bindgen-backend", "wasm-bindgen-shared", @@ -4527,7 +4605,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "403f3fd505ff930da84156389639932955fb09705b3dccd1a3d60c8e7ff62776" dependencies = [ "base64 0.10.1", - "bitflags", + "bitflags 1.2.1", "byteorder", "bytes 0.4.12", "futures", @@ -4683,6 +4761,15 @@ dependencies = [ "winapi 0.3.9", ] +[[package]] +name = "wit-bindgen-rt" +version = "0.39.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6f42320e61fe2cfd34354ecb597f86f413484a798ba44a8ca1165c58d42da6c1" +dependencies = [ + "bitflags 2.9.0", +] + [[package]] name = "ws2_32-sys" version = "0.2.1" @@ -4714,6 +4801,26 @@ version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9fc79f4a1e39857fc00c3f662cbf2651c771f00e9c15fe2abc341806bd46bd71" +[[package]] +name = "zerocopy" +version = "0.8.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fd97444d05a4328b90e75e503a34bad781f14e28a823ad3557f0750df1ebcbc6" +dependencies = [ + "zerocopy-derive", +] + +[[package]] +name = "zerocopy-derive" +version = "0.8.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6352c01d0edd5db859a63e2605f4ea3183ddbd15e2c4a9e7d32184df75e4f154" +dependencies = [ + "proc-macro2 1.0.94", + "quote 1.0.40", + "syn 2.0.100", +] + [[package]] name = "zeroize" version = "1.4.3" @@ -4729,8 +4836,8 @@ version = "1.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "65f1a51723ec88c66d5d1fe80c841f17f63587d6691901d66be9bec6c3b51f73" dependencies = [ - "proc-macro2 1.0.59", - "quote 1.0.28", + "proc-macro2 1.0.94", + "quote 1.0.40", "syn 1.0.85", "synstructure", ] diff --git a/node/Cargo.toml b/node/Cargo.toml index 7d01fd728..93f2dcde1 100644 --- a/node/Cargo.toml +++ b/node/Cargo.toml @@ -99,8 +99,5 @@ path = "src/main_win.rs" name = "node_lib" path = "src/lib.rs" -[features] -expose_test_privates = [] - #[profile.release] #opt-level = 0 \ No newline at end of file diff --git a/node/src/actor_system_factory.rs b/node/src/actor_system_factory.rs index 20ee55ed2..8ab3426cf 100644 --- a/node/src/actor_system_factory.rs +++ b/node/src/actor_system_factory.rs @@ -1197,7 +1197,7 @@ mod tests { when_pending_too_long_sec: DEFAULT_PENDING_TOO_LONG_SEC, }; let persistent_config = PersistentConfigurationMock::default() - .chain_name_result("eth-ropsten".to_string()) + .chain_name_result("base-sepolia".to_string()) .set_min_hops_result(Ok(())); Bootstrapper::pub_initialize_cryptdes_for_testing( &Some(main_cryptde()), @@ -1953,7 +1953,7 @@ mod tests { #[test] #[should_panic( - expected = "Database with a wrong chain name detected; expected: eth-ropsten, was: eth-mainnet" + expected = "Database with a wrong chain name detected; expected: base-sepolia, was: eth-mainnet" )] fn make_and_start_actors_does_not_tolerate_differences_in_setup_chain_and_database_chain() { let mut bootstrapper_config = BootstrapperConfig::new(); diff --git a/node/src/blockchain/blockchain_interface/blockchain_interface_web3/utils.rs b/node/src/blockchain/blockchain_interface/blockchain_interface_web3/utils.rs index 2be7d5977..03ed4150b 100644 --- a/node/src/blockchain/blockchain_interface/blockchain_interface_web3/utils.rs +++ b/node/src/blockchain/blockchain_interface/blockchain_interface_web3/utils.rs @@ -507,7 +507,7 @@ mod tests { Transactions in the batch:\n\ \n\ gas price: 120 wei\n\ - chain: ropsten\n\ + chain: sepolia\n\ \n\ [wallet address] [payment in wei]\n\ 0x0000000000000000000000000000000077313233 900,000,000,000,000,000\n\ diff --git a/node/src/bootstrapper.rs b/node/src/bootstrapper.rs index 2ef265e69..9e4e72698 100644 --- a/node/src/bootstrapper.rs +++ b/node/src/bootstrapper.rs @@ -1206,11 +1206,11 @@ mod tests { NodeDescriptor::from(( main_cryptde_ref().public_key(), &NodeAddr::new(&IpAddr::from_str("1.2.3.4").unwrap(), &[5123]), - Chain::EthRopsten, + Chain::BaseSepolia, main_cryptde_ref() )) ); - TestLogHandler::new().exists_log_matching("INFO: Bootstrapper: MASQ Node local descriptor: masq://eth-ropsten:.+@1\\.2\\.3\\.4:5123"); + TestLogHandler::new().exists_log_matching("INFO: Bootstrapper: MASQ Node local descriptor: masq://base-sepolia:.+@1\\.2\\.3\\.4:5123"); } #[test] @@ -1322,11 +1322,11 @@ mod tests { NodeDescriptor::from(( main_cryptde_ref().public_key(), &NodeAddr::new(&IpAddr::from_str("1.2.3.4").unwrap(), &[5123]), - Chain::EthRopsten, + Chain::BaseSepolia, main_cryptde_ref() )) ); - TestLogHandler::new().exists_log_matching("INFO: Bootstrapper: MASQ Node local descriptor: masq://eth-ropsten:.+@1\\.2\\.3\\.4:5123"); + TestLogHandler::new().exists_log_matching("INFO: Bootstrapper: MASQ Node local descriptor: masq://base-sepolia:.+@1\\.2\\.3\\.4:5123"); } #[test] @@ -1571,7 +1571,7 @@ mod tests { cryptdes.main }; let expected_descriptor = format!( - "masq://eth-ropsten:{}@2.3.4.5:3456/4567", + "masq://base-sepolia:{}@2.3.4.5:3456/4567", cryptde_ref.public_key_to_descriptor_fragment(cryptde_ref.public_key()) ); TestLogHandler::new().exists_log_containing( @@ -1611,7 +1611,7 @@ mod tests { cryptdes }; let expected_descriptor = format!( - "masq://eth-ropsten:{}@:", + "masq://base-sepolia:{}@:", cryptdes .main .public_key_to_descriptor_fragment(cryptdes.main.public_key()) diff --git a/node/src/daemon/setup_reporter.rs b/node/src/daemon/setup_reporter.rs index 84c1db1e5..1ef47777f 100644 --- a/node/src/daemon/setup_reporter.rs +++ b/node/src/daemon/setup_reporter.rs @@ -1488,7 +1488,7 @@ mod tests { ("mapping-protocol", "pmp", Set), ("min-hops", "2", Set), ("neighborhood-mode", "originate-only", Set), - ("neighbors", "masq://eth-ropsten:MTIzNDU2Nzg5MTEyMzQ1Njc4OTIxMjM0NTY3ODkzMTI@1.2.3.4:1234,masq://eth-ropsten:MTIzNDU2Nzg5MTEyMzQ1Njc4OTIxMjM0NTY3ODkzMTI@5.6.7.8:5678", Set), + ("neighbors", "masq://base-sepolia:MTIzNDU2Nzg5MTEyMzQ1Njc4OTIxMjM0NTY3ODkzMTI@1.2.3.4:1234,masq://base-sepolia:MTIzNDU2Nzg5MTEyMzQ1Njc4OTIxMjM0NTY3ODkzMTI@5.6.7.8:5678", Set), ("payment-thresholds","1234|50000|1000|1000|20000|20000",Set), ("rate-pack","1|3|3|8",Set), #[cfg(not(target_os = "windows"))] @@ -1518,7 +1518,7 @@ mod tests { ("mapping-protocol", "pmp", Set), ("min-hops", "2", Set), ("neighborhood-mode", "originate-only", Set), - ("neighbors", "masq://eth-ropsten:MTIzNDU2Nzg5MTEyMzQ1Njc4OTIxMjM0NTY3ODkzMTI@1.2.3.4:1234,masq://eth-ropsten:MTIzNDU2Nzg5MTEyMzQ1Njc4OTIxMjM0NTY3ODkzMTI@5.6.7.8:5678", Set), + ("neighbors", "masq://base-sepolia:MTIzNDU2Nzg5MTEyMzQ1Njc4OTIxMjM0NTY3ODkzMTI@1.2.3.4:1234,masq://base-sepolia:MTIzNDU2Nzg5MTEyMzQ1Njc4OTIxMjM0NTY3ODkzMTI@5.6.7.8:5678", Set), ("payment-thresholds","1234|50000|1000|1000|20000|20000",Set), ("rate-pack","1|3|3|8",Set), #[cfg(not(target_os = "windows"))] @@ -1558,7 +1558,7 @@ mod tests { ("mapping-protocol", "igdp"), ("min-hops", "2"), ("neighborhood-mode", "originate-only"), - ("neighbors", "masq://eth-ropsten:MTIzNDU2Nzg5MTEyMzQ1Njc4OTIxMjM0NTY3ODkzMTI@1.2.3.4:1234,masq://eth-ropsten:MTIzNDU2Nzg5MTEyMzQ1Njc4OTIxMjM0NTY3ODkzMTI@5.6.7.8:5678"), + ("neighbors", "masq://base-sepolia:MTIzNDU2Nzg5MTEyMzQ1Njc4OTIxMjM0NTY3ODkzMTI@1.2.3.4:1234,masq://base-sepolia:MTIzNDU2Nzg5MTEyMzQ1Njc4OTIxMjM0NTY3ODkzMTI@5.6.7.8:5678"), ("payment-thresholds","1234|50000|1000|1000|15000|15000"), ("rate-pack","1|3|3|8"), #[cfg(not(target_os = "windows"))] @@ -1593,7 +1593,7 @@ mod tests { ("mapping-protocol", "igdp", Set), ("min-hops", "2", Set), ("neighborhood-mode", "originate-only", Set), - ("neighbors", "masq://eth-ropsten:MTIzNDU2Nzg5MTEyMzQ1Njc4OTIxMjM0NTY3ODkzMTI@1.2.3.4:1234,masq://eth-ropsten:MTIzNDU2Nzg5MTEyMzQ1Njc4OTIxMjM0NTY3ODkzMTI@5.6.7.8:5678", Set), + ("neighbors", "masq://base-sepolia:MTIzNDU2Nzg5MTEyMzQ1Njc4OTIxMjM0NTY3ODkzMTI@1.2.3.4:1234,masq://base-sepolia:MTIzNDU2Nzg5MTEyMzQ1Njc4OTIxMjM0NTY3ODkzMTI@5.6.7.8:5678", Set), ("payment-thresholds","1234|50000|1000|1000|15000|15000",Set), ("rate-pack","1|3|3|8",Set), #[cfg(not(target_os = "windows"))] @@ -1634,7 +1634,7 @@ mod tests { ("MASQ_MAPPING_PROTOCOL", "pmp"), ("MASQ_MIN_HOPS", "2"), ("MASQ_NEIGHBORHOOD_MODE", "originate-only"), - ("MASQ_NEIGHBORS", "masq://eth-ropsten:MTIzNDU2Nzg5MTEyMzQ1Njc4OTIxMjM0NTY3ODkzMTI@1.2.3.4:1234,masq://eth-ropsten:MTIzNDU2Nzg5MTEyMzQ1Njc4OTIxMjM0NTY3ODkzMTI@5.6.7.8:5678"), + ("MASQ_NEIGHBORS", "masq://base-sepolia:MTIzNDU2Nzg5MTEyMzQ1Njc4OTIxMjM0NTY3ODkzMTI@1.2.3.4:1234,masq://base-sepolia:MTIzNDU2Nzg5MTEyMzQ1Njc4OTIxMjM0NTY3ODkzMTI@5.6.7.8:5678"), ("MASQ_PAYMENT_THRESHOLDS","12345|50000|1000|1234|19000|20000"), ("MASQ_RATE_PACK","1|3|3|8"), #[cfg(not(target_os = "windows"))] @@ -1666,7 +1666,7 @@ mod tests { ("mapping-protocol", "pmp", Configured), ("min-hops", "2", Configured), ("neighborhood-mode", "originate-only", Configured), - ("neighbors", "masq://eth-ropsten:MTIzNDU2Nzg5MTEyMzQ1Njc4OTIxMjM0NTY3ODkzMTI@1.2.3.4:1234,masq://eth-ropsten:MTIzNDU2Nzg5MTEyMzQ1Njc4OTIxMjM0NTY3ODkzMTI@5.6.7.8:5678", Configured), + ("neighbors", "masq://base-sepolia:MTIzNDU2Nzg5MTEyMzQ1Njc4OTIxMjM0NTY3ODkzMTI@1.2.3.4:1234,masq://base-sepolia:MTIzNDU2Nzg5MTEyMzQ1Njc4OTIxMjM0NTY3ODkzMTI@5.6.7.8:5678", Configured), ("payment-thresholds","12345|50000|1000|1234|19000|20000",Configured), ("rate-pack","1|3|3|8",Configured), #[cfg(not(target_os = "windows"))] @@ -1884,7 +1884,7 @@ mod tests { ("MASQ_MAPPING_PROTOCOL", "pcp"), ("MASQ_MIN_HOPS", "2"), ("MASQ_NEIGHBORHOOD_MODE", "originate-only"), - ("MASQ_NEIGHBORS", "masq://eth-ropsten:MTIzNDU2Nzg5MTEyMzQ1Njc4OTIxMjM0NTY3ODkzMTI@1.2.3.4:1234,masq://eth-ropsten:MTIzNDU2Nzg5MTEyMzQ1Njc4OTIxMjM0NTY3ODkzMTI@5.6.7.8:5678"), + ("MASQ_NEIGHBORS", "masq://base-sepolia:MTIzNDU2Nzg5MTEyMzQ1Njc4OTIxMjM0NTY3ODkzMTI@1.2.3.4:1234,masq://base-sepolia:MTIzNDU2Nzg5MTEyMzQ1Njc4OTIxMjM0NTY3ODkzMTI@5.6.7.8:5678"), ("MASQ_PAYMENT_THRESHOLDS","1234|50000|1000|1000|20000|20000"), ("MASQ_RATE_PACK","1|3|3|8"), #[cfg(not(target_os = "windows"))] @@ -1946,7 +1946,7 @@ mod tests { ("neighborhood-mode", "consume-only", Set), ( "neighbors", - "masq://eth-ropsten:MTIzNDU2Nzg5MTEyMzQ1Njc4OTIxMjM0NTY3ODkzMTI@9.10.11.12:9101", + "masq://base-sepolia:MTIzNDU2Nzg5MTEyMzQ1Njc4OTIxMjM0NTY3ODkzMTI@9.10.11.12:9101", Set, ), ("payment-thresholds", "4321|66666|777|987|123456|124444", Set), @@ -1982,7 +1982,7 @@ mod tests { ("mapping-protocol", "pcp", Configured), ("min-hops", "2", Configured), ("neighborhood-mode", "originate-only", Configured), - ("neighbors", "masq://eth-ropsten:MTIzNDU2Nzg5MTEyMzQ1Njc4OTIxMjM0NTY3ODkzMTI@1.2.3.4:1234,masq://eth-ropsten:MTIzNDU2Nzg5MTEyMzQ1Njc4OTIxMjM0NTY3ODkzMTI@5.6.7.8:5678", Configured), + ("neighbors", "masq://base-sepolia:MTIzNDU2Nzg5MTEyMzQ1Njc4OTIxMjM0NTY3ODkzMTI@1.2.3.4:1234,masq://base-sepolia:MTIzNDU2Nzg5MTEyMzQ1Njc4OTIxMjM0NTY3ODkzMTI@5.6.7.8:5678", Configured), ("payment-thresholds","1234|50000|1000|1000|20000|20000",Configured), ("rate-pack","1|3|3|8",Configured), #[cfg(not(target_os = "windows"))] diff --git a/node/src/database/db_initializer.rs b/node/src/database/db_initializer.rs index 3619cc1b4..be5547576 100644 --- a/node/src/database/db_initializer.rs +++ b/node/src/database/db_initializer.rs @@ -1168,7 +1168,7 @@ mod tests { .initialize( &updated_db_path_dir, DbInitializationConfig::create_or_migrate(ExternalData::new( - Chain::EthRopsten, + Chain::BaseSepolia, NeighborhoodModeLight::Standard, Some("password".to_string()), )), diff --git a/node/src/database/db_migrations/migrations/migration_1_to_2.rs b/node/src/database/db_migrations/migrations/migration_1_to_2.rs index d92bcaf68..23447ba1c 100644 --- a/node/src/database/db_migrations/migrations/migration_1_to_2.rs +++ b/node/src/database/db_migrations/migrations/migration_1_to_2.rs @@ -68,7 +68,7 @@ mod tests { let connection = result.unwrap(); let (chn_value, chn_encrypted) = retrieve_config_row(connection.as_ref(), "chain_name"); let (cs_value, cs_encrypted) = retrieve_config_row(connection.as_ref(), "schema_version"); - assert_eq!(chn_value, Some("eth-ropsten".to_string())); + assert_eq!(chn_value, Some("base-sepolia".to_string())); assert_eq!(chn_encrypted, false); assert_eq!(cs_value, Some("2".to_string())); assert_eq!(cs_encrypted, false); diff --git a/node/src/database/db_migrations/migrations/migration_4_to_5.rs b/node/src/database/db_migrations/migrations/migration_4_to_5.rs index dbc40f1b3..06deb809f 100644 --- a/node/src/database/db_migrations/migrations/migration_4_to_5.rs +++ b/node/src/database/db_migrations/migrations/migration_4_to_5.rs @@ -227,7 +227,7 @@ mod tests { let config_table_after = fetch_all_from_config_table(&conn); assert_eq!(config_table_before, config_table_after); assert_on_schema_5_was_adopted(conn_schema5.as_ref()); - TestLogHandler::new().exists_log_containing("WARN: DbMigrator: Migration from 4 to 5: database belonging to the chain 'eth-ropsten'; \ + TestLogHandler::new().exists_log_containing("WARN: DbMigrator: Migration from 4 to 5: database belonging to the chain 'base-sepolia'; \ we discovered possibly abandoned transactions that are said yet to be pending, these are: \ '0x0000000000000000000000000000000000000000000000000000000002b594d1', \ '0x00000000000000000000000000000000000000000000000000000000000f41d0'; continuing"); diff --git a/node/src/dispatcher.rs b/node/src/dispatcher.rs index b3de16740..067ddf22a 100644 --- a/node/src/dispatcher.rs +++ b/node/src/dispatcher.rs @@ -260,12 +260,12 @@ mod tests { let proxy_server = Recorder::new(); let recording_arc = proxy_server.get_recording(); let awaiter = proxy_server.get_awaiter(); - let peer_addr = SocketAddr::from_str("1.2.3.4:5678").unwrap(); + let client_addr = SocketAddr::from_str("1.2.3.4:5678").unwrap(); let reception_port = Some(8080); let data: Vec = vec![9, 10, 11]; let ibcd_in = InboundClientData { timestamp: SystemTime::now(), - peer_addr, + client_addr, reception_port, sequence_number: Some(0), last_data: false, @@ -285,10 +285,10 @@ mod tests { let recording = recording_arc.lock().unwrap(); let message = recording.get_record::(0); - let actual_socket_addr = message.peer_addr.clone(); + let actual_socket_addr = message.client_addr.clone(); let actual_data = message.data.clone(); - assert_eq!(actual_socket_addr, peer_addr); + assert_eq!(actual_socket_addr, client_addr); assert_eq!(actual_data, data); assert_eq!(recording.len(), 1); } @@ -299,12 +299,12 @@ mod tests { let subject = Dispatcher::new(NODE_DESCRIPTOR.clone(), false); let subject_addr = subject.start(); let (hopper, hopper_awaiter, hopper_recording_arc) = make_recorder(); - let peer_addr = SocketAddr::from_str("1.2.3.4:5678").unwrap(); + let client_addr = SocketAddr::from_str("1.2.3.4:5678").unwrap(); let reception_port = Some(8080); let data: Vec = vec![9, 10, 11]; let ibcd_in = InboundClientData { timestamp: SystemTime::now(), - peer_addr, + client_addr, reception_port, last_data: false, is_clandestine: true, @@ -324,10 +324,10 @@ mod tests { let hopper_recording = hopper_recording_arc.lock().unwrap(); let message = hopper_recording.get_record::(0); - let actual_socket_addr = message.peer_addr.clone(); + let actual_socket_addr = message.client_addr.clone(); let actual_data = message.data.clone(); - assert_eq!(actual_socket_addr, peer_addr); + assert_eq!(actual_socket_addr, client_addr); assert_eq!(actual_data, data); assert_eq!(hopper_recording.len(), 1); } @@ -339,12 +339,12 @@ mod tests { let subject = Dispatcher::new(NODE_DESCRIPTOR.clone(), false); let subject_addr = subject.start(); let subject_ibcd = subject_addr.recipient::(); - let peer_addr = SocketAddr::from_str("1.2.3.4:8765").unwrap(); + let client_addr = SocketAddr::from_str("1.2.3.4:8765").unwrap(); let reception_port = Some(1234); let data: Vec = vec![9, 10, 11]; let ibcd_in = InboundClientData { timestamp: SystemTime::now(), - peer_addr, + client_addr, reception_port, last_data: false, is_clandestine: false, @@ -365,12 +365,12 @@ mod tests { let subject = Dispatcher::new(NODE_DESCRIPTOR.clone(), false); let subject_addr = subject.start(); let subject_ibcd = subject_addr.recipient::(); - let peer_addr = SocketAddr::from_str("1.2.3.4:8765").unwrap(); + let client_addr = SocketAddr::from_str("1.2.3.4:8765").unwrap(); let reception_port = Some(1234); let data: Vec = vec![9, 10, 11]; let ibcd_in = InboundClientData { timestamp: SystemTime::now(), - peer_addr, + client_addr, reception_port, last_data: false, is_clandestine: true, diff --git a/node/src/hopper/consuming_service.rs b/node/src/hopper/consuming_service.rs index 7593e36ed..b0df18b1f 100644 --- a/node/src/hopper/consuming_service.rs +++ b/node/src/hopper/consuming_service.rs @@ -95,7 +95,7 @@ impl ConsumingService { fn zero_hop(&self, encrypted_package: CryptData) { let ibcd = InboundClientData { timestamp: SystemTime::now(), - peer_addr: SocketAddr::new(IpAddr::V4(Ipv4Addr::new(127, 0, 0, 1)), 0), + client_addr: SocketAddr::new(IpAddr::V4(Ipv4Addr::new(127, 0, 0, 1)), 0), reception_port: None, last_data: false, is_clandestine: true, @@ -302,7 +302,7 @@ mod tests { *record, InboundClientData { timestamp: record.timestamp, - peer_addr: SocketAddr::new(IpAddr::V4(Ipv4Addr::new(127, 0, 0, 1)), 0), + client_addr: SocketAddr::new(IpAddr::V4(Ipv4Addr::new(127, 0, 0, 1)), 0), reception_port: None, last_data: false, is_clandestine: true, diff --git a/node/src/hopper/mod.rs b/node/src/hopper/mod.rs index 49e93bec4..8cfe5e955 100644 --- a/node/src/hopper/mod.rs +++ b/node/src/hopper/mod.rs @@ -171,7 +171,7 @@ mod tests { fn panics_if_routing_service_is_unbound() { let main_cryptde = main_cryptde(); let alias_cryptde = alias_cryptde(); - let peer_addr = SocketAddr::from_str("1.2.3.4:5678").unwrap(); + let client_addr = SocketAddr::from_str("1.2.3.4:5678").unwrap(); let route = route_to_proxy_client(&main_cryptde.public_key(), main_cryptde); let serialized_payload = serde_cbor::ser::to_vec(&make_meaningless_message_type()).unwrap(); let data = main_cryptde @@ -189,7 +189,7 @@ mod tests { let inbound_client_data = InboundClientData { timestamp: SystemTime::now(), - peer_addr, + client_addr, reception_port: None, last_data: false, is_clandestine: false, diff --git a/node/src/hopper/routing_service.rs b/node/src/hopper/routing_service.rs index c9613dcd9..05d8af9d6 100644 --- a/node/src/hopper/routing_service.rs +++ b/node/src/hopper/routing_service.rs @@ -63,9 +63,9 @@ impl RoutingService { self.logger, "Instructed to route {} bytes of InboundClientData ({}) from Dispatcher", data_size, - ibcd.peer_addr + ibcd.client_addr ); - let peer_addr = ibcd.peer_addr; + let peer_addr = ibcd.client_addr; let last_data = ibcd.last_data; let ibcd_but_data = ibcd.clone_but_data(); @@ -79,7 +79,7 @@ impl RoutingService { self.logger, "Couldn't decode CORES package in {}-byte buffer from {}: {:?}", ibcd.data.len(), - ibcd.peer_addr, + ibcd.client_addr, e ); return; @@ -185,7 +185,7 @@ impl RoutingService { .expect("Encryption of LiveCoresPackage failed"); let inbound_client_data = InboundClientData { timestamp: ibcd_but_data.timestamp, - peer_addr: ibcd_but_data.peer_addr, + client_addr: ibcd_but_data.client_addr, reception_port: ibcd_but_data.reception_port, last_data: ibcd_but_data.last_data, is_clandestine: ibcd_but_data.is_clandestine, @@ -554,7 +554,7 @@ mod tests { let data_enc = encodex(cryptdes.main, &cryptdes.main.public_key(), &lcp).unwrap(); let inbound_client_data = InboundClientData { timestamp: SystemTime::now(), - peer_addr: SocketAddr::from_str("1.2.3.4:5678").unwrap(), + client_addr: SocketAddr::from_str("1.2.3.4:5678").unwrap(), reception_port: None, sequence_number: None, last_data: false, @@ -602,7 +602,7 @@ mod tests { let data_enc = encodex(cryptdes.main, &cryptdes.main.public_key(), &lcp).unwrap(); let inbound_client_data = InboundClientData { timestamp: SystemTime::now(), - peer_addr: SocketAddr::from_str("1.2.3.4:5678").unwrap(), + client_addr: SocketAddr::from_str("1.2.3.4:5678").unwrap(), reception_port: None, sequence_number: None, last_data: false, @@ -649,7 +649,7 @@ mod tests { let data_enc = encodex(main_cryptde, main_cryptde.public_key(), &lcp).unwrap(); let inbound_client_data = InboundClientData { timestamp: SystemTime::now(), - peer_addr: SocketAddr::from_str("1.2.3.4:5678").unwrap(), + client_addr: SocketAddr::from_str("1.2.3.4:5678").unwrap(), reception_port: None, sequence_number: None, last_data: false, @@ -701,7 +701,7 @@ mod tests { let data_enc = encodex(main_cryptde, &main_cryptde.public_key(), &lcp).unwrap(); let inbound_client_data = InboundClientData { timestamp: SystemTime::now(), - peer_addr: SocketAddr::from_str("1.2.3.4:5678").unwrap(), + client_addr: SocketAddr::from_str("1.2.3.4:5678").unwrap(), reception_port: None, sequence_number: None, last_data: false, @@ -755,7 +755,7 @@ mod tests { .unwrap(); let inbound_client_data = InboundClientData { timestamp: SystemTime::now(), - peer_addr: SocketAddr::from_str("1.2.3.4:5678").unwrap(), + client_addr: SocketAddr::from_str("1.2.3.4:5678").unwrap(), reception_port: None, sequence_number: None, last_data: true, @@ -828,7 +828,7 @@ mod tests { .unwrap(); let inbound_client_data = InboundClientData { timestamp: SystemTime::now(), - peer_addr: SocketAddr::from_str("1.2.3.4:5678").unwrap(), + client_addr: SocketAddr::from_str("1.2.3.4:5678").unwrap(), reception_port: None, sequence_number: None, last_data: true, @@ -887,7 +887,7 @@ mod tests { let lcp_enc = encodex(main_cryptde, main_cryptde.public_key(), &lcp).unwrap(); let inbound_client_data = InboundClientData { timestamp: SystemTime::now(), - peer_addr: SocketAddr::from_str("1.3.2.4:5678").unwrap(), + client_addr: SocketAddr::from_str("1.3.2.4:5678").unwrap(), reception_port: None, last_data: false, is_clandestine: true, @@ -968,7 +968,7 @@ mod tests { let data_enc = encodex(main_cryptde, &main_cryptde.public_key(), &lcp).unwrap(); let inbound_client_data = InboundClientData { timestamp: SystemTime::now(), - peer_addr: SocketAddr::from_str("1.3.2.4:5678").unwrap(), + client_addr: SocketAddr::from_str("1.3.2.4:5678").unwrap(), reception_port: None, last_data: false, is_clandestine: true, @@ -1044,7 +1044,7 @@ mod tests { let data_enc = encodex(cryptde, &cryptde.public_key(), &lcp).unwrap(); let inbound_client_data = InboundClientData { timestamp: SystemTime::now(), - peer_addr: SocketAddr::from_str("1.3.2.4:5678").unwrap(), + client_addr: SocketAddr::from_str("1.3.2.4:5678").unwrap(), reception_port: None, last_data: false, is_clandestine: true, @@ -1124,7 +1124,7 @@ mod tests { .unwrap(); let inbound_client_data = InboundClientData { timestamp: SystemTime::now(), - peer_addr: SocketAddr::from_str("1.2.3.4:5678").unwrap(), + client_addr: SocketAddr::from_str("1.2.3.4:5678").unwrap(), reception_port: None, last_data: true, is_clandestine: true, @@ -1220,7 +1220,7 @@ mod tests { let data_enc = encodex(main_cryptde, &main_cryptde.public_key(), &lcp).unwrap(); let inbound_client_data = InboundClientData { timestamp: SystemTime::now(), - peer_addr: SocketAddr::from_str("1.2.3.4:5678").unwrap(), + client_addr: SocketAddr::from_str("1.2.3.4:5678").unwrap(), reception_port: None, last_data: true, is_clandestine: true, @@ -1266,7 +1266,7 @@ mod tests { *record, InboundClientData { timestamp: record.timestamp, - peer_addr: SocketAddr::from_str("1.2.3.4:5678").unwrap(), + client_addr: SocketAddr::from_str("1.2.3.4:5678").unwrap(), reception_port: None, last_data: true, is_clandestine: true, @@ -1306,7 +1306,7 @@ mod tests { .unwrap(); let inbound_client_data = InboundClientData { timestamp: SystemTime::now(), - peer_addr: SocketAddr::from_str("1.2.3.4:5678").unwrap(), + client_addr: SocketAddr::from_str("1.2.3.4:5678").unwrap(), reception_port: None, last_data: true, is_clandestine: true, @@ -1407,7 +1407,7 @@ mod tests { .unwrap(); let inbound_client_data = InboundClientData { timestamp: SystemTime::now(), - peer_addr: SocketAddr::from_str("1.2.3.4:5678").unwrap(), + client_addr: SocketAddr::from_str("1.2.3.4:5678").unwrap(), reception_port: None, last_data: true, is_clandestine: true, @@ -1591,7 +1591,7 @@ mod tests { let data_enc = encodex(main_cryptde, &main_cryptde.public_key(), &lcp).unwrap(); let inbound_client_data = InboundClientData { timestamp: SystemTime::now(), - peer_addr: SocketAddr::from_str("1.2.3.4:5678").unwrap(), + client_addr: SocketAddr::from_str("1.2.3.4:5678").unwrap(), reception_port: None, last_data: true, is_clandestine: true, @@ -1665,7 +1665,7 @@ mod tests { let data_enc = encodex(main_cryptde, &main_cryptde.public_key(), &lcp).unwrap(); let inbound_client_data = InboundClientData { timestamp: SystemTime::now(), - peer_addr: SocketAddr::from_str("1.2.3.4:5678").unwrap(), + client_addr: SocketAddr::from_str("1.2.3.4:5678").unwrap(), reception_port: None, last_data: true, is_clandestine: true, @@ -1712,7 +1712,7 @@ mod tests { init_test_logging(); let inbound_client_data = InboundClientData { timestamp: SystemTime::now(), - peer_addr: SocketAddr::from_str("1.2.3.4:5678").unwrap(), + client_addr: SocketAddr::from_str("1.2.3.4:5678").unwrap(), reception_port: None, last_data: true, is_clandestine: true, @@ -1770,7 +1770,7 @@ mod tests { .unwrap(); let inbound_client_data = InboundClientData { timestamp: SystemTime::now(), - peer_addr: SocketAddr::from_str("1.2.3.4:5678").unwrap(), + client_addr: SocketAddr::from_str("1.2.3.4:5678").unwrap(), reception_port: None, last_data: true, is_clandestine: true, @@ -1840,7 +1840,7 @@ mod tests { let lcp = LiveCoresPackage::new(Route { hops: vec![] }, CryptData::new(&[])); let ibcd = InboundClientData { timestamp: SystemTime::now(), - peer_addr: SocketAddr::from_str("1.2.3.4:5678").unwrap(), + client_addr: SocketAddr::from_str("1.2.3.4:5678").unwrap(), reception_port: None, last_data: true, is_clandestine: true, diff --git a/node/src/neighborhood/node_record.rs b/node/src/neighborhood/node_record.rs index e490cec1d..d2546e03c 100644 --- a/node/src/neighborhood/node_record.rs +++ b/node/src/neighborhood/node_record.rs @@ -409,7 +409,7 @@ mod tests { result, NodeDescriptor::try_from(( main_cryptde(), - "masq://eth-ropsten:AQIDBA@1.2.3.4:1234/2345" + "masq://base-sepolia:AQIDBA@1.2.3.4:1234/2345" )) .unwrap() ); @@ -424,7 +424,7 @@ mod tests { assert_eq!( result, - NodeDescriptor::try_from((main_cryptde(), "masq://eth-ropsten:AQIDBA@:")).unwrap() + NodeDescriptor::try_from((main_cryptde(), "masq://base-sepolia:AQIDBA@:")).unwrap() ); } diff --git a/node/src/proxy_server/client_request_payload_factory.rs b/node/src/proxy_server/client_request_payload_factory.rs index 006f37a13..e146501e2 100644 --- a/node/src/proxy_server/client_request_payload_factory.rs +++ b/node/src/proxy_server/client_request_payload_factory.rs @@ -43,11 +43,8 @@ impl ClientRequestPayloadFactory for ClientRequestPayloadFactoryReal { }; let data = PlainData::new(&ibcd.data); let target_host = protocol_pack.find_host(&data); - let (target_hostname, target_port) = match target_host { - Some(host) => match host.port { - Some(port) => (Some(host.name), port), - None => (Some(host.name), protocol_pack.standard_port()), - }, + let (target_hostname_opt, target_port) = match target_host { + Some(host) => (Some(host.name), host.port), None => (None, protocol_pack.standard_port()), }; Some(ClientRequestPayload_0v1 { @@ -57,7 +54,7 @@ impl ClientRequestPayloadFactory for ClientRequestPayloadFactoryReal { sequence_number, last_data: ibcd.last_data, }, - target_hostname, + target_hostname: target_hostname_opt, target_port, protocol: protocol_pack.proxy_protocol(), originator_public_key: cryptde.public_key().clone(), @@ -88,7 +85,7 @@ mod tests { let data = PlainData::new(&b"GET http://borkoed.com:2345/fleebs.html HTTP/1.1\r\n\r\n"[..]); let ibcd = InboundClientData { timestamp: SystemTime::now(), - peer_addr: SocketAddr::from_str("1.2.3.4:5678").unwrap(), + client_addr: SocketAddr::from_str("1.2.3.4:5678").unwrap(), reception_port: Some(HTTP_PORT), sequence_number: Some(1), last_data: false, @@ -125,7 +122,7 @@ mod tests { let data = PlainData::new(&b"GET http://borkoed.com/fleebs.html HTTP/1.1\r\n\r\n"[..]); let ibcd = InboundClientData { timestamp: SystemTime::now(), - peer_addr: SocketAddr::from_str("1.2.3.4:5678").unwrap(), + client_addr: SocketAddr::from_str("1.2.3.4:5678").unwrap(), reception_port: Some(HTTP_PORT), sequence_number: Some(1), last_data: false, @@ -180,7 +177,7 @@ mod tests { ]); let ibcd = InboundClientData { timestamp: SystemTime::now(), - peer_addr: SocketAddr::from_str("1.2.3.4:5678").unwrap(), + client_addr: SocketAddr::from_str("1.2.3.4:5678").unwrap(), sequence_number: Some(0), reception_port: Some(443), last_data: false, @@ -230,7 +227,7 @@ mod tests { ]); let ibcd = InboundClientData { timestamp: SystemTime::now(), - peer_addr: SocketAddr::from_str("1.2.3.4:5678").unwrap(), + client_addr: SocketAddr::from_str("1.2.3.4:5678").unwrap(), reception_port: Some(443), last_data: true, is_clandestine: false, @@ -267,7 +264,7 @@ mod tests { let test_name = "makes_no_payload_if_origin_port_is_not_specified"; let ibcd = InboundClientData { timestamp: SystemTime::now(), - peer_addr: SocketAddr::from_str("1.2.3.4:5678").unwrap(), + client_addr: SocketAddr::from_str("1.2.3.4:5678").unwrap(), sequence_number: Some(0), reception_port: None, last_data: false, @@ -293,7 +290,7 @@ mod tests { let test_name = "makes_no_payload_if_origin_port_is_unknown"; let ibcd = InboundClientData { timestamp: SystemTime::now(), - peer_addr: SocketAddr::from_str("1.2.3.4:5678").unwrap(), + client_addr: SocketAddr::from_str("1.2.3.4:5678").unwrap(), reception_port: Some(1234), sequence_number: Some(0), last_data: false, @@ -315,7 +312,7 @@ mod tests { fn use_sequence_from_inbound_client_data_in_client_request_payload() { let ibcd = InboundClientData { timestamp: SystemTime::now(), - peer_addr: SocketAddr::from_str("1.2.3.4:80").unwrap(), + client_addr: SocketAddr::from_str("1.2.3.4:80").unwrap(), reception_port: Some(HTTP_PORT), sequence_number: Some(1), last_data: false, @@ -344,7 +341,7 @@ mod tests { let test_name = "makes_no_payload_if_sequence_number_is_unknown"; let ibcd = InboundClientData { timestamp: SystemTime::now(), - peer_addr: SocketAddr::from_str("1.2.3.4:80").unwrap(), + client_addr: SocketAddr::from_str("1.2.3.4:80").unwrap(), reception_port: Some(HTTP_PORT), last_data: false, is_clandestine: false, diff --git a/node/src/proxy_server/http_protocol_pack.rs b/node/src/proxy_server/http_protocol_pack.rs index 3904c736f..b611f2be3 100644 --- a/node/src/proxy_server/http_protocol_pack.rs +++ b/node/src/proxy_server/http_protocol_pack.rs @@ -24,9 +24,9 @@ impl ProtocolPack for HttpProtocolPack { } fn find_host(&self, data: &PlainData) -> Option { - match HttpProtocolPack::find_url_host(data.as_slice()) { + match HttpProtocolPack::find_header_host(data.as_slice()) { Some(host) => Some(host), - None => HttpProtocolPack::find_header_host(data.as_slice()), + None => HttpProtocolPack::find_url_host(data.as_slice()), } } @@ -67,12 +67,15 @@ impl HttpProtocolPack { match parts.len() { 1 => Some(Host { name: parts.remove(0).to_string(), - port: None, - }), - 2 => Some(Host { - name: parts.remove(0).to_string(), - port: Self::port_from_string(parts.remove(0).to_string()), + port: HTTP_PORT, }), + 2 => { + let name = parts.remove(0).to_string(); + match Self::port_from_string(parts.remove(0).to_string()) { + Ok(port) => Some(Host { name, port }), + Err(_) => None, + } + } _ => None, } } @@ -91,10 +94,10 @@ impl HttpProtocolPack { ) } - fn port_from_string(port_str: String) -> Option { + fn port_from_string(port_str: String) -> Result { match port_str.parse::() { - Err(_) => None, - Ok(port) => Some(port), + Err(_) => Err(format!("Port '{}' is not a number", port_str)), + Ok(port) => Ok(port), } } } @@ -160,7 +163,7 @@ mod tests { let host = HttpProtocolPack {}.find_host(&data).unwrap(); - assert_eq!(String::from("header.host.com"), host.name); + assert_eq!(host, Host::new("header.host.com", HTTP_PORT)); } #[test] @@ -182,31 +185,31 @@ mod tests { let host = HttpProtocolPack {}.find_host(&data).unwrap(); - assert_eq!(String::from("192.168.1.230"), host.name); - assert_eq!(None, host.port); + assert_eq!(host, Host::new("192.168.1.230", HTTP_PORT)); } #[test] - fn returns_host_name_and_port_from_url_if_both_exist() { + fn returns_host_name_and_port_from_header_if_both_exist() { let data = PlainData::new(b"OPTIONS http://top.host.com:1234/index.html HTTP/1.1\r\nHost: header.host.com:5432\r\n\r\nbodybody"); let host = HttpProtocolPack {}.find_host(&data).unwrap(); - assert_eq!(String::from("top.host.com"), host.name); - assert_eq!(Some(1234), host.port); + assert_eq!(host, Host::new("header.host.com", 5432)); } #[test] fn returns_host_name_from_http_url_if_header_doesnt_exist() { + // Note: that "Host: body.host.com" looks like a header, but it's not: it's content. let data = PlainData::new(b"DELETE http://top.host.com/index.html HTTP/1.1\r\nContent-Length: 23\r\n\r\nHost: body.host.com\r\n\r\n"); let host = HttpProtocolPack {}.find_host(&data).unwrap(); - assert_eq!(String::from("top.host.com"), host.name); + assert_eq!(host.name, String::from("top.host.com")); } #[test] fn returns_host_name_from_https_url_if_header_doesnt_exist() { + // Note: that "Host: body.host.com" looks like a header, but it's not: it's content. let data = PlainData::new(b"PUT https://top.host.com/index.html HTTP/1.1\r\nContent-Length: 23\r\n\r\nHost: body.host.com\r\n\r\n"); let host = HttpProtocolPack {}.find_host(&data).unwrap(); @@ -220,25 +223,22 @@ mod tests { let host = HttpProtocolPack {}.find_host(&data).unwrap(); - assert_eq!(String::from("top.host.com"), host.name); + assert_eq!(host, Host::new("top.host.com", HTTP_PORT)); } #[test] fn returns_host_name_from_url_when_no_scheme() { - let data = PlainData::new( - b"CONNECT good.url.dude/path.html HTTP/1.1\r\nHost: wrong.url.dude\r\n\r\n", - ); + let data = PlainData::new(b"GET good.url.dude/path.html HTTP/1.0\r\n\r\n"); let host = HttpProtocolPack {}.find_host(&data).unwrap(); - assert_eq!(String::from("good.url.dude"), host.name); + assert_eq!(host.name, String::from("good.url.dude")); } #[test] fn can_handle_domain_that_starts_with_http() { - let data = PlainData::new( - b"CONNECT http.url.dude/path.html HTTP/1.1\r\nHost: wrong.url.dude\r\n\r\n", - ); + let data = + PlainData::new(b"GET bad.url.dude/path.html HTTP/1.1\r\nHost: http.url.dude\r\n\r\n"); let host = HttpProtocolPack {}.find_host(&data).unwrap(); @@ -251,8 +251,7 @@ mod tests { let host = HttpProtocolPack {}.find_host(&data).unwrap(); - assert_eq!(String::from("top.host.com"), host.name); - assert_eq!(Some(8080), host.port); + assert_eq!(host, Host::new("top.host.com", 8080)); } #[test] @@ -268,39 +267,27 @@ mod tests { fn specifying_a_non_numeric_port_in_the_url() { let data = PlainData::new(b"HEAD http://top.host.com:nanan/index.html HTTP/1.1\r\nContent-Length: 23\r\n\r\nHost: body.host.com\r\n\r\n"); - let host = HttpProtocolPack {}.find_host(&data).unwrap(); + let host = HttpProtocolPack {}.find_host(&data); - assert_eq!(String::from("top.host.com"), host.name); - assert_eq!(None, host.port); + assert_eq!(host, None); } #[test] - fn specifying_a_missing_port_in_the_url() { + fn cant_extract_top_host_if_port_has_syntax_error() { let data = PlainData::new(b"HEAD http://top.host.com:/index.html HTTP/1.1\r\nContent-Length: 23\r\n\r\nHost: body.host.com\r\n\r\n"); - let host = HttpProtocolPack {}.find_host(&data).unwrap(); - - assert_eq!(String::from("top.host.com"), host.name); - assert_eq!(None, host.port); - } - - #[test] - fn from_integration_test() { - let data = PlainData::new(b"GET / HTTP/1.1\r\nHost: www.example.com\r\n\r\n"); - - let host = HttpProtocolPack {}.find_host(&data).unwrap(); + let host = HttpProtocolPack {}.find_host(&data); - assert_eq!(String::from("www.example.com"), host.name); + assert_eq!(host, None); } #[test] - fn explicit_port_is_none_if_it_was_not_specified() { + fn explicit_port_is_80_if_it_was_not_specified() { let data = PlainData::new(b"GET / HTTP/1.1\r\nHost: www.example.com\r\n\r\n"); let host = HttpProtocolPack {}.find_host(&data).unwrap(); - assert_eq!(String::from("www.example.com"), host.name); - assert_eq!(None, host.port); + assert_eq!(host, Host::new("www.example.com", HTTP_PORT)); } #[test] @@ -309,28 +296,25 @@ mod tests { let host = HttpProtocolPack {}.find_host(&data).unwrap(); - assert_eq!(String::from("www.example.com"), host.name); - assert_eq!(Some(8080), host.port); + assert_eq!(host, Host::new("www.example.com", 8080)); } #[test] fn specifying_a_non_numeric_port_in_host_header() { let data = PlainData::new(b"GET / HTTP/1.1\r\nHost: www.example.com:nannan\r\n\r\n"); - let host = HttpProtocolPack {}.find_host(&data).unwrap(); + let host = HttpProtocolPack {}.find_host(&data); - assert_eq!(String::from("www.example.com"), host.name); - assert_eq!(None, host.port); + assert_eq!(host, None); } #[test] fn specifying_a_missing_port_in_host_header() { let data = PlainData::new(b"GET / HTTP/1.1\r\nHost: www.example.com:\r\n\r\n"); - let host = HttpProtocolPack {}.find_host(&data).unwrap(); + let host = HttpProtocolPack {}.find_host(&data); - assert_eq!(String::from("www.example.com"), host.name); - assert_eq!(None, host.port); + assert_eq!(host, None); } #[test] diff --git a/node/src/proxy_server/mod.rs b/node/src/proxy_server/mod.rs index 5ea296a4b..5894991c5 100644 --- a/node/src/proxy_server/mod.rs +++ b/node/src/proxy_server/mod.rs @@ -45,6 +45,7 @@ use actix::Handler; use actix::Recipient; use actix::{Actor, MailboxError}; use actix::{Addr, AsyncContext}; +use masq_lib::constants::TLS_PORT; use masq_lib::logger::Logger; use masq_lib::ui_gateway::NodeFromUiMessage; use masq_lib::utils::MutabilityConflictHelper; @@ -571,7 +572,7 @@ impl ProxyServer { fn tls_connect(&mut self, msg: &InboundClientData) { let http_data = HttpProtocolPack {}.find_host(&msg.data.clone().into()); match http_data { - Some(ref host) if host.port == Some(443) => { + Some(ref host) if host.port == TLS_PORT => { let stream_key = self.find_or_generate_stream_key(msg); self.tunneled_hosts.insert(stream_key, host.name.clone()); self.subs @@ -579,7 +580,7 @@ impl ProxyServer { .expect("Dispatcher unbound in ProxyServer") .dispatcher .try_send(TransmitDataMsg { - endpoint: Endpoint::Socket(msg.peer_addr), + endpoint: Endpoint::Socket(msg.client_addr), last_data: false, sequence_number: msg.sequence_number, data: b"HTTP/1.1 200 OK\r\n\r\n".to_vec(), @@ -592,7 +593,7 @@ impl ProxyServer { .expect("Dispatcher unbound in ProxyServer") .dispatcher .try_send(TransmitDataMsg { - endpoint: Endpoint::Socket(msg.peer_addr), + endpoint: Endpoint::Socket(msg.client_addr), last_data: true, sequence_number: msg.sequence_number, data: b"HTTP/1.1 400 Bad Request\r\nContent-Length: 0\r\n\r\n".to_vec(), @@ -634,7 +635,7 @@ impl ProxyServer { ); let ibcd = InboundClientData { timestamp: SystemTime::now(), - peer_addr: msg.peer_addr, + client_addr: msg.peer_addr, reception_port: Some(nca.reception_port), last_data: true, is_clandestine: false, @@ -650,22 +651,26 @@ impl ProxyServer { } fn find_or_generate_stream_key(&mut self, ibcd: &InboundClientData) -> StreamKey { - match self.keys_and_addrs.b_to_a(&ibcd.peer_addr) { + match self.keys_and_addrs.b_to_a(&ibcd.client_addr) { Some(stream_key) => { debug!( self.logger, - "make_stream_key() retrieved existing key {} for {}", + "find_or_generate_stream_key() retrieved existing key {} for {}", &stream_key, - ibcd.peer_addr + ibcd.client_addr ); stream_key } None => { - let stream_key = self.stream_key_factory.make(); - self.keys_and_addrs.insert(stream_key, ibcd.peer_addr); + let stream_key = self + .stream_key_factory + .make(self.main_cryptde.public_key(), ibcd.client_addr); + self.keys_and_addrs.insert(stream_key, ibcd.client_addr); debug!( self.logger, - "make_stream_key() inserted new key {} for {}", &stream_key, ibcd.peer_addr + "find_or_generate_stream_key() inserted new key {} for {}", + &stream_key, + ibcd.client_addr ); stream_key } @@ -1103,7 +1108,7 @@ impl IBCDHelper for IBCDHelperReal { msg: InboundClientData, retire_stream_key: bool, ) -> Result<(), String> { - let source_addr = msg.peer_addr; + let client_addr = msg.client_addr; if proxy.consuming_wallet_balance.is_none() && proxy.is_decentralized { let protocol_pack = match from_ibcd(&msg) { Err(e) => return Err(e), @@ -1113,7 +1118,7 @@ impl IBCDHelper for IBCDHelperReal { .server_impersonator() .consuming_wallet_absent(); let msg = TransmitDataMsg { - endpoint: Endpoint::Socket(source_addr), + endpoint: Endpoint::Socket(client_addr), last_data: true, sequence_number: Some(0), data, @@ -1151,7 +1156,7 @@ impl IBCDHelper for IBCDHelperReal { .insert(stream_key, dns_failure_retry); } let args = - TransmitToHopperArgs::new(proxy, payload, source_addr, timestamp, retire_stream_key); + TransmitToHopperArgs::new(proxy, payload, client_addr, timestamp, retire_stream_key); let add_return_route_sub = proxy.out_subs("ProxysServer").add_return_route.clone(); let pld = &args.payload; if let Some(route_query_response) = proxy.stream_key_routes.get(&pld.stream_key) { @@ -1268,14 +1273,14 @@ enum ExitServiceSearch { } trait StreamKeyFactory: Send { - fn make(&self) -> StreamKey; + fn make(&self, public_key: &PublicKey, client_addr: SocketAddr) -> StreamKey; } struct StreamKeyFactoryReal {} impl StreamKeyFactory for StreamKeyFactoryReal { - fn make(&self) -> StreamKey { - StreamKey::new() + fn make(&self, public_key: &PublicKey, client_addr: SocketAddr) -> StreamKey { + StreamKey::new(public_key, client_addr) } } @@ -1500,13 +1505,16 @@ mod tests { } struct StreamKeyFactoryMock { - make_parameters: Arc>>, + make_parameters: Arc>>, make_results: RefCell>, } impl StreamKeyFactory for StreamKeyFactoryMock { - fn make(&self) -> StreamKey { - self.make_parameters.lock().unwrap().push(()); + fn make(&self, public_key: &PublicKey, client_addr: SocketAddr) -> StreamKey { + self.make_parameters + .lock() + .unwrap() + .push((public_key.clone(), client_addr)); self.make_results.borrow_mut().remove(0) } } @@ -1519,7 +1527,10 @@ mod tests { } } - fn make_parameters(mut self, params: &Arc>>) -> StreamKeyFactoryMock { + fn make_parameters( + mut self, + params: &Arc>>, + ) -> StreamKeyFactoryMock { self.make_parameters = params.clone(); self } @@ -1631,7 +1642,7 @@ mod tests { let expected_data = http_request.to_vec(); let msg_from_dispatcher = InboundClientData { timestamp: SystemTime::now(), - peer_addr: socket_addr.clone(), + client_addr: socket_addr, reception_port: Some(HTTP_PORT), sequence_number: Some(0), last_data: true, @@ -1695,7 +1706,10 @@ mod tests { let record = recording.get_record::(0); assert_eq!(record, &expected_pkg); let mut make_parameters = make_parameters_arc_a.lock().unwrap(); - assert_eq!(make_parameters.remove(0), ()); + assert_eq!( + make_parameters.remove(0), + (main_cryptde.public_key().clone(), socket_addr) + ); let recording = neighborhood_recording_arc.lock().unwrap(); let record = recording.get_record::(0); assert_eq!( @@ -1733,7 +1747,7 @@ mod tests { let request_data = http_request.to_vec(); let msg_from_dispatcher = InboundClientData { timestamp: SystemTime::now(), - peer_addr: socket_addr.clone(), + client_addr: socket_addr.clone(), reception_port: Some(8443), sequence_number: Some(0), last_data: false, @@ -1742,7 +1756,7 @@ mod tests { }; let tunnelled_msg = InboundClientData { timestamp: SystemTime::now(), - peer_addr: socket_addr.clone(), + client_addr: socket_addr, reception_port: Some(8443), sequence_number: Some(0), last_data: false, @@ -1750,7 +1764,7 @@ mod tests { data: b"client hello".to_vec(), }; let expected_tdm = TransmitDataMsg { - endpoint: Endpoint::Socket(socket_addr.clone()), + endpoint: Endpoint::Socket(socket_addr), last_data: false, sequence_number: Some(0), data: b"HTTP/1.1 200 OK\r\n\r\n".to_vec(), @@ -1811,7 +1825,10 @@ mod tests { let dispatcher_record = dispatcher_recording.get_record::(0); assert_eq!(dispatcher_record, &expected_tdm); let mut make_parameters = make_parameters_arc.lock().unwrap(); - assert_eq!(make_parameters.remove(0), ()); + assert_eq!( + make_parameters.remove(0), + (main_cryptde.public_key().clone(), socket_addr) + ); let hopper_recording = hopper_recording_arc.lock().unwrap(); let hopper_record = hopper_recording.get_record::(0); @@ -1862,7 +1879,7 @@ mod tests { let request_data = http_request.to_vec(); let inbound_client_data = InboundClientData { timestamp: SystemTime::now(), - peer_addr: socket_addr, + client_addr: socket_addr, reception_port: Some(443), last_data: false, is_clandestine: false, @@ -1923,7 +1940,7 @@ mod tests { let request_data = http_request.to_vec(); let msg_from_dispatcher = InboundClientData { timestamp: SystemTime::now(), - peer_addr: socket_addr.clone(), + client_addr: socket_addr.clone(), reception_port: Some(8443), sequence_number: Some(0), last_data: false, @@ -1995,7 +2012,7 @@ mod tests { let request_data = http_request.to_vec(); let msg_from_dispatcher = InboundClientData { timestamp: SystemTime::now(), - peer_addr: socket_addr.clone(), + client_addr: socket_addr.clone(), reception_port: Some(8443), sequence_number: Some(0), last_data: false, @@ -2063,7 +2080,7 @@ mod tests { let expected_data = http_request.to_vec(); let msg_from_dispatcher = InboundClientData { timestamp: SystemTime::now(), - peer_addr: socket_addr.clone(), + client_addr: socket_addr.clone(), reception_port: Some(HTTP_PORT), sequence_number: Some(0), last_data: true, @@ -2122,7 +2139,7 @@ mod tests { let expected_data = tls_request.to_vec(); let msg_from_dispatcher = InboundClientData { timestamp: SystemTime::now(), - peer_addr: socket_addr.clone(), + client_addr: socket_addr.clone(), reception_port: Some(TLS_PORT), sequence_number: Some(0), last_data: true, @@ -2185,7 +2202,7 @@ mod tests { let socket_addr = SocketAddr::from_str("1.2.3.4:5678").unwrap(); let msg_from_dispatcher = InboundClientData { timestamp: SystemTime::now(), - peer_addr: socket_addr.clone(), + client_addr: socket_addr.clone(), reception_port: Some(HTTP_PORT), sequence_number: Some(0), last_data: true, @@ -2265,7 +2282,7 @@ mod tests { let socket_addr = SocketAddr::from_str("1.2.3.4:5678").unwrap(); let msg_from_dispatcher = InboundClientData { timestamp: SystemTime::now(), - peer_addr: socket_addr.clone(), + client_addr: socket_addr.clone(), reception_port: Some(TLS_PORT), sequence_number: Some(0), last_data: true, @@ -2350,7 +2367,7 @@ mod tests { let expected_data = http_request.to_vec(); let msg_from_dispatcher = InboundClientData { timestamp: SystemTime::now(), - peer_addr: socket_addr.clone(), + client_addr: socket_addr.clone(), reception_port: Some(HTTP_PORT), sequence_number: Some(0), last_data: true, @@ -2470,7 +2487,7 @@ mod tests { let expected_data = http_request.to_vec(); let msg_from_dispatcher = InboundClientData { timestamp: SystemTime::now(), - peer_addr: socket_addr.clone(), + client_addr: socket_addr.clone(), reception_port: Some(HTTP_PORT), sequence_number: Some(0), last_data: true, @@ -2559,7 +2576,7 @@ mod tests { let expected_data = http_request.to_vec(); let msg_from_dispatcher = InboundClientData { timestamp: SystemTime::now(), - peer_addr: socket_addr.clone(), + client_addr: socket_addr.clone(), reception_port: Some(HTTP_PORT), sequence_number: Some(0), last_data: true, @@ -2621,7 +2638,7 @@ mod tests { let expected_data = http_request.to_vec(); let msg_from_dispatcher = InboundClientData { timestamp: SystemTime::now(), - peer_addr: socket_addr.clone(), + client_addr: socket_addr.clone(), reception_port: Some(HTTP_PORT), sequence_number: Some(0), last_data: true, @@ -2675,7 +2692,7 @@ mod tests { let expected_data = http_request.to_vec(); let msg_from_dispatcher = InboundClientData { timestamp: SystemTime::now(), - peer_addr: socket_addr.clone(), + client_addr: socket_addr.clone(), reception_port: Some(HTTP_PORT), sequence_number: Some(0), last_data: true, @@ -2726,7 +2743,7 @@ mod tests { let expected_data = http_request.to_vec(); let msg_from_dispatcher = InboundClientData { timestamp: SystemTime::now(), - peer_addr: socket_addr.clone(), + client_addr: socket_addr.clone(), reception_port: Some(HTTP_PORT), sequence_number: Some(0), last_data: true, @@ -3018,7 +3035,7 @@ mod tests { let expected_data = http_request.to_vec(); let msg_from_dispatcher = InboundClientData { timestamp: SystemTime::now(), - peer_addr: socket_addr.clone(), + client_addr: socket_addr.clone(), reception_port: Some(HTTP_PORT), sequence_number: Some(0), last_data: true, @@ -3140,7 +3157,7 @@ mod tests { let stream_key = StreamKey::make_meaningless_stream_key(); let msg_from_dispatcher = InboundClientData { timestamp: SystemTime::now(), - peer_addr: socket_addr.clone(), + client_addr: socket_addr.clone(), reception_port: Some(HTTP_PORT), sequence_number: Some(0), last_data: true, @@ -3320,7 +3337,7 @@ mod tests { let expected_data = http_request.to_vec(); let msg_from_dispatcher = InboundClientData { timestamp: SystemTime::now(), - peer_addr: socket_addr.clone(), + client_addr: socket_addr.clone(), reception_port: Some(HTTP_PORT), sequence_number: Some(0), last_data: true, @@ -3416,7 +3433,7 @@ mod tests { let expected_data = tls_request.to_vec(); let msg_from_dispatcher = InboundClientData { timestamp: SystemTime::now(), - peer_addr: socket_addr.clone(), + client_addr: socket_addr.clone(), reception_port: Some(TLS_PORT), sequence_number: Some(0), last_data: false, @@ -3502,7 +3519,7 @@ mod tests { let expected_data = tls_request.to_vec(); let msg_from_dispatcher = InboundClientData { timestamp: SystemTime::now(), - peer_addr: socket_addr.clone(), + client_addr: socket_addr.clone(), reception_port: Some(TLS_PORT), sequence_number: Some(0), last_data: false, @@ -3587,7 +3604,7 @@ mod tests { let expected_data = tls_request.to_vec(); let msg_from_dispatcher = InboundClientData { timestamp: SystemTime::now(), - peer_addr: client_addr, + client_addr: client_addr, reception_port: Some(TLS_PORT), sequence_number: Some(0), last_data: true, @@ -3678,7 +3695,7 @@ mod tests { let stream_key = StreamKey::make_meaningless_stream_key(); let msg_from_dispatcher = InboundClientData { timestamp: SystemTime::now(), - peer_addr: socket_addr.clone(), + client_addr: socket_addr.clone(), reception_port: Some(TLS_PORT), sequence_number: Some(0), last_data: true, @@ -5546,7 +5563,7 @@ mod tests { let expected_data = http_request.to_vec(); let msg_from_dispatcher = InboundClientData { timestamp: SystemTime::now(), - peer_addr: socket_addr.clone(), + client_addr: socket_addr.clone(), reception_port: Some(80), sequence_number: Some(0), last_data: false, @@ -6081,7 +6098,7 @@ mod tests { let handle_normal_client_data = help_to_handle_normal_client_data_params_arc.lock().unwrap(); let (inbound_client_data_msg, retire_stream_key) = &handle_normal_client_data[0]; - assert_eq!(inbound_client_data_msg.peer_addr, socket_addr); + assert_eq!(inbound_client_data_msg.client_addr, socket_addr); assert_eq!(inbound_client_data_msg.data, Vec::::new()); assert_eq!(inbound_client_data_msg.last_data, true); assert_eq!(inbound_client_data_msg.is_clandestine, false); @@ -6097,7 +6114,7 @@ mod tests { proxy_server.subs = Some(make_proxy_server_out_subs()); let inbound_client_data_msg = InboundClientData { timestamp: SystemTime::now(), - peer_addr: SocketAddr::from_str("1.2.3.4:4578").unwrap(), + client_addr: SocketAddr::from_str("1.2.3.4:4578").unwrap(), reception_port: None, last_data: true, is_clandestine: false, @@ -6201,7 +6218,7 @@ mod tests { Box::new(ClientRequestPayloadFactoryMock::default().make_result(None)); let inbound_client_data_msg = InboundClientData { timestamp: SystemTime::now(), - peer_addr: SocketAddr::from_str("1.2.3.4:4578").unwrap(), + client_addr: SocketAddr::from_str("1.2.3.4:4578").unwrap(), reception_port: Some(568), last_data: true, is_clandestine: false, @@ -6241,7 +6258,7 @@ mod tests { let expected_data = http_request.to_vec(); let msg_from_dispatcher = InboundClientData { timestamp: SystemTime::now(), - peer_addr: socket_addr.clone(), + client_addr: socket_addr.clone(), reception_port: Some(HTTP_PORT), sequence_number: Some(0), last_data: true, @@ -6310,7 +6327,7 @@ mod tests { let expected_data = http_request.to_vec(); let msg_from_dispatcher = InboundClientData { timestamp: SystemTime::now(), - peer_addr: socket_addr.clone(), + client_addr: socket_addr.clone(), reception_port: Some(HTTP_PORT), sequence_number: Some(0), last_data: true, @@ -6436,7 +6453,7 @@ mod tests { proxy_server.subs = Some(make_proxy_server_out_subs()); let inbound_client_data_msg = InboundClientData { timestamp: SystemTime::now(), - peer_addr: SocketAddr::from_str("1.2.3.4:4578").unwrap(), + client_addr: SocketAddr::from_str("1.2.3.4:4578").unwrap(), reception_port: Some(80), last_data: true, is_clandestine: false, @@ -6488,6 +6505,57 @@ mod tests { prove_that_crash_request_handler_is_hooked_up(proxy_server, CRASH_KEY); } + #[test] + fn find_or_generate_stream_key_prioritizes_existing_stream_key_first() { + let socket_addr = SocketAddr::from_str("1.2.3.4:4321").unwrap(); + let stream_key = StreamKey::new(main_cryptde().public_key(), socket_addr); + let mut subject = + ProxyServer::new(main_cryptde(), alias_cryptde(), true, None, false, false); + subject.keys_and_addrs.insert(stream_key, socket_addr); + let ibcd = InboundClientData { + timestamp: SystemTime::now(), + client_addr: socket_addr, + reception_port: Some(2222), + last_data: true, + is_clandestine: false, + sequence_number: Some(333), + data: b"GET /index.html HTTP/1.1\r\nHost: header.com:3333\r\n\r\n".to_vec(), + }; + + let result = subject.find_or_generate_stream_key(&ibcd); + + assert_eq!(result, stream_key); + assert_eq!( + subject.keys_and_addrs.a_to_b(&stream_key), + Some(socket_addr) + ); + } + + #[test] + fn find_or_generate_stream_key_creates_stream_key_if_necessary() { + let socket_addr = SocketAddr::from_str("1.2.3.4:4321").unwrap(); + let stream_key = StreamKey::new(main_cryptde().public_key(), socket_addr); + let mut subject = + ProxyServer::new(main_cryptde(), alias_cryptde(), true, None, false, false); + let ibcd = InboundClientData { + timestamp: SystemTime::now(), + client_addr: socket_addr, + reception_port: Some(2222), + last_data: true, + is_clandestine: false, + sequence_number: Some(333), + data: b"GET /index.html HTTP/1.1\r\nHost: header.com:4444\r\n\r\n".to_vec(), + }; + + let result = subject.find_or_generate_stream_key(&ibcd); + + assert_eq!(result, stream_key); + assert_eq!( + subject.keys_and_addrs.a_to_b(&stream_key), + Some(socket_addr) + ); + } + fn make_exit_service_from_key(public_key: PublicKey) -> ExpectedService { ExpectedService::Exit(public_key, make_wallet("exit wallet"), rate_pack(100)) } diff --git a/node/src/proxy_server/protocol_pack.rs b/node/src/proxy_server/protocol_pack.rs index 38db8e6ff..9697ce6a2 100644 --- a/node/src/proxy_server/protocol_pack.rs +++ b/node/src/proxy_server/protocol_pack.rs @@ -9,7 +9,16 @@ use masq_lib::constants::{HTTP_PORT, TLS_PORT}; #[derive(Clone, Debug, PartialEq, Eq)] pub struct Host { pub name: String, - pub port: Option, + pub port: u16, +} + +impl Host { + pub fn new(name: &str, port: u16) -> Host { + Host { + name: name.to_string(), + port, + } + } } pub trait ProtocolPack: Send + Sync { diff --git a/node/src/proxy_server/tls_protocol_pack.rs b/node/src/proxy_server/tls_protocol_pack.rs index f57177a8f..d167ef0fa 100644 --- a/node/src/proxy_server/tls_protocol_pack.rs +++ b/node/src/proxy_server/tls_protocol_pack.rs @@ -4,6 +4,7 @@ use crate::proxy_server::server_impersonator_tls::ServerImpersonatorTls; use crate::sub_lib::binary_traverser::BinaryTraverser; use crate::sub_lib::cryptde::PlainData; use crate::sub_lib::proxy_server::ProxyProtocol; +use masq_lib::constants::TLS_PORT; pub struct TlsProtocolPack {} @@ -13,7 +14,7 @@ impl ProtocolPack for TlsProtocolPack { } fn standard_port(&self) -> u16 { - 443 + TLS_PORT } fn find_host(&self, data: &PlainData) -> Option { @@ -25,7 +26,10 @@ impl ProtocolPack for TlsProtocolPack { return None; } match Self::host_name_from_client_hello(&mut xvsr) { - Ok(name) => Some(Host { name, port: None }), + Ok(name) => Some(Host { + name, + port: TLS_PORT, + }), Err(()) => None, } } @@ -112,7 +116,7 @@ mod tests { fn knows_its_standard_port() { let result = TlsProtocolPack {}.standard_port(); - assert_eq!(result, 443); + assert_eq!(result, TLS_PORT); } #[test] @@ -709,7 +713,7 @@ mod tests { assert_eq!( Some(Host { name: String::from("server.com"), - port: None, + port: TLS_PORT, }), result ); @@ -754,7 +758,7 @@ mod tests { assert_eq!( Some(Host { name: String::from("server.com"), - port: None + port: TLS_PORT }), result ); diff --git a/node/src/stream_handler_pool.rs b/node/src/stream_handler_pool.rs index db9bdd4e3..470f0c44f 100644 --- a/node/src/stream_handler_pool.rs +++ b/node/src/stream_handler_pool.rs @@ -916,7 +916,7 @@ mod tests { dispatcher_record, &dispatcher::InboundClientData { timestamp: dispatcher_record.timestamp, - peer_addr: peer_addr_a, + client_addr: peer_addr_a, reception_port, last_data: false, is_clandestine, @@ -930,7 +930,7 @@ mod tests { dispatcher_record, &dispatcher::InboundClientData { timestamp: dispatcher_record.timestamp, - peer_addr: peer_addr_a, + client_addr: peer_addr_a, reception_port, last_data: false, is_clandestine, @@ -944,7 +944,7 @@ mod tests { dispatcher_record, &dispatcher::InboundClientData { timestamp: dispatcher_record.timestamp, - peer_addr: peer_addr_a, + client_addr: peer_addr_a, reception_port, last_data: false, is_clandestine, @@ -1499,7 +1499,7 @@ mod tests { ibcd, &InboundClientData { timestamp: ibcd.timestamp, - peer_addr: SocketAddr::from_str("1.2.3.5:7000").unwrap(), + client_addr: SocketAddr::from_str("1.2.3.5:7000").unwrap(), reception_port: Some(54321), last_data: false, is_clandestine: true, diff --git a/node/src/stream_reader.rs b/node/src/stream_reader.rs index df080ede3..34a7b62bd 100644 --- a/node/src/stream_reader.rs +++ b/node/src/stream_reader.rs @@ -161,7 +161,7 @@ impl StreamReaderReal { }; let msg = dispatcher::InboundClientData { timestamp: SystemTime::now(), - peer_addr: self.peer_addr, + client_addr: self.peer_addr, reception_port: self.reception_port, last_data: false, is_clandestine: self.is_clandestine, @@ -169,7 +169,7 @@ impl StreamReaderReal { data: unmasked_chunk.chunk.clone(), }; debug!(self.logger, "Discriminator framed and unmasked {} bytes for {}; transmitting via Hopper", - unmasked_chunk.chunk.len(), msg.peer_addr); + unmasked_chunk.chunk.len(), msg.client_addr); self.ibcd_sub.try_send(msg).expect("Dispatcher is dead"); } None => { @@ -510,7 +510,7 @@ mod tests { d_record, &dispatcher::InboundClientData { timestamp: d_record.timestamp, - peer_addr, + client_addr: peer_addr, reception_port: Some(1234 as u16), last_data: false, is_clandestine: true, @@ -631,7 +631,7 @@ mod tests { d_record, &dispatcher::InboundClientData { timestamp: d_record.timestamp, - peer_addr: peer_addr, + client_addr: peer_addr, reception_port: Some(1234 as u16), last_data: false, is_clandestine: false, @@ -646,7 +646,7 @@ mod tests { d_record, &dispatcher::InboundClientData { timestamp: d_record.timestamp, - peer_addr: peer_addr, + client_addr: peer_addr, reception_port: Some(1234 as u16), last_data: false, is_clandestine: false, @@ -662,7 +662,7 @@ mod tests { let system = System::new("test"); let (_, stream_handler_pool_subs) = stream_handler_pool_stuff(); let (d_recording_arc, dispatcher_subs) = dispatcher_stuff(); - let peer_addr = SocketAddr::from_str("1.2.3.4:5678").unwrap(); + let client_addr = SocketAddr::from_str("1.2.3.4:5678").unwrap(); let local_addr = SocketAddr::from_str("1.2.3.5:6789").unwrap(); let discriminator_factories: Vec> = vec![Box::new(JsonDiscriminatorFactory::new())]; @@ -687,7 +687,7 @@ mod tests { dispatcher_subs.stream_shutdown_sub, discriminator_factories, true, - peer_addr, + client_addr, local_addr, ); let before = SystemTime::now(); @@ -705,7 +705,7 @@ mod tests { d_record, &dispatcher::InboundClientData { timestamp: d_record.timestamp, - peer_addr, + client_addr, reception_port: Some(1234 as u16), last_data: false, is_clandestine: true, diff --git a/node/src/sub_lib/dispatcher.rs b/node/src/sub_lib/dispatcher.rs index 20eea08d7..66e349e11 100644 --- a/node/src/sub_lib/dispatcher.rs +++ b/node/src/sub_lib/dispatcher.rs @@ -115,7 +115,7 @@ pub enum DispatcherError { #[derive(PartialEq, Eq, Clone, Message)] pub struct InboundClientData { pub timestamp: SystemTime, - pub peer_addr: SocketAddr, + pub client_addr: SocketAddr, pub reception_port: Option, pub last_data: bool, pub is_clandestine: bool, @@ -130,7 +130,7 @@ impl Debug for InboundClientData { Err(_) => self.data.hex_dump().to_string(), }; write!(f, "InboundClientData {{ peer_addr: {:?}, reception_port: {:?}, last_data: {}, sequence_number: {:?}, {} bytes of data: {} }}", - self.peer_addr, self.reception_port, self.last_data, self.sequence_number, self.data.len(), data_string) + self.client_addr, self.reception_port, self.last_data, self.sequence_number, self.data.len(), data_string) } } @@ -138,7 +138,7 @@ impl InboundClientData { pub fn clone_but_data(&self) -> InboundClientData { InboundClientData { timestamp: SystemTime::now(), - peer_addr: self.peer_addr, + client_addr: self.client_addr, reception_port: self.reception_port, last_data: self.last_data, is_clandestine: self.is_clandestine, @@ -273,7 +273,7 @@ mod tests { fn inbound_client_data_is_identifiable_as_a_connect() { let subject = InboundClientData { timestamp: SystemTime::now(), - peer_addr: SocketAddr::from_str("1.4.3.2:9999").unwrap(), + client_addr: SocketAddr::from_str("1.4.3.2:9999").unwrap(), reception_port: None, last_data: false, is_clandestine: false, @@ -288,7 +288,7 @@ mod tests { fn inbound_client_data_is_not_connect() { let subject = InboundClientData { timestamp: SystemTime::now(), - peer_addr: SocketAddr::from_str("1.4.3.2:9999").unwrap(), + client_addr: SocketAddr::from_str("1.4.3.2:9999").unwrap(), reception_port: None, last_data: false, is_clandestine: false, @@ -303,7 +303,7 @@ mod tests { fn inbound_client_data_not_connect_if_no_space_after_method() { let subject = InboundClientData { timestamp: SystemTime::now(), - peer_addr: SocketAddr::from_str("1.4.3.2:9999").unwrap(), + client_addr: SocketAddr::from_str("1.4.3.2:9999").unwrap(), reception_port: None, last_data: false, is_clandestine: false, diff --git a/node/src/sub_lib/route.rs b/node/src/sub_lib/route.rs index 8415c758b..ecbd0261e 100644 --- a/node/src/sub_lib/route.rs +++ b/node/src/sub_lib/route.rs @@ -781,9 +781,9 @@ mod tests { result, String::from( r#" -Encrypted with 0x01020304: LiveHop { public_key: 0x02030405, payer: Some(Payer { wallet: Wallet { kind: Address(0x71d0fc7d1c570b1ed786382b551a09391c91e33d) }, proof: Signature { v: 0, r: "8b663e5a10f40c3307e6fb5340482a5e11df78dafc619ceff97f11fa79fea320", s: "8b663e5a10f40c3307e6fb5340482a5e11df78dafc619ceff97f11fa79fea320" } }), component: Hopper } -Encrypted with 0x02030405: LiveHop { public_key: 0x03040506, payer: Some(Payer { wallet: Wallet { kind: Address(0x71d0fc7d1c570b1ed786382b551a09391c91e33d) }, proof: Signature { v: 1, r: "63be72962f19dda7802220ed48c0d8199d510b45608a3789c50f61912b98a15b", s: "63be72962f19dda7802220ed48c0d8199d510b45608a3789c50f61912b98a15b" } }), component: Hopper } -Encrypted with 0x03040506: LiveHop { public_key: 0x, payer: Some(Payer { wallet: Wallet { kind: Address(0x71d0fc7d1c570b1ed786382b551a09391c91e33d) }, proof: Signature { v: 1, r: "9ca23557adf96d7aed407a06ce96851a4184e947a7b29b6c3872eef902fcba1e", s: "9ca23557adf96d7aed407a06ce96851a4184e947a7b29b6c3872eef902fcba1e" } }), component: Neighborhood } +Encrypted with 0x01020304: LiveHop { public_key: 0x02030405, payer: Some(Payer { wallet: Wallet { kind: Address(0x71d0fc7d1c570b1ed786382b551a09391c91e33d) }, proof: Signature { v: 0, r: "3e3a92d7284c2c2ff7119e9f7a7e183b062a335a598e965a47c36a2f288b6f8d", s: "3e3a92d7284c2c2ff7119e9f7a7e183b062a335a598e965a47c36a2f288b6f8d" } }), component: Hopper } +Encrypted with 0x02030405: LiveHop { public_key: 0x03040506, payer: Some(Payer { wallet: Wallet { kind: Address(0x71d0fc7d1c570b1ed786382b551a09391c91e33d) }, proof: Signature { v: 0, r: "4324a40295bb36ef2b927fb24250fe42397a57b861ea152bbbe4f84150d4ff5a", s: "4324a40295bb36ef2b927fb24250fe42397a57b861ea152bbbe4f84150d4ff5a" } }), component: Hopper } +Encrypted with 0x03040506: LiveHop { public_key: 0x, payer: Some(Payer { wallet: Wallet { kind: Address(0x71d0fc7d1c570b1ed786382b551a09391c91e33d) }, proof: Signature { v: 1, r: "8649b8f6db6232cb1e4f1f04786ad4ef33488c968e64bec74ecd893d6d05c1b9", s: "8649b8f6db6232cb1e4f1f04786ad4ef33488c968e64bec74ecd893d6d05c1b9" } }), component: Neighborhood } "# ) ); @@ -818,11 +818,11 @@ Encrypted with 0x03040506: LiveHop { public_key: 0x, payer: Some(Payer { wallet: result, String::from( r#" -Encrypted with 0x01020304: LiveHop { public_key: 0x02030405, payer: Some(Payer { wallet: Wallet { kind: Address(0x71d0fc7d1c570b1ed786382b551a09391c91e33d) }, proof: Signature { v: 0, r: "8b663e5a10f40c3307e6fb5340482a5e11df78dafc619ceff97f11fa79fea320", s: "8b663e5a10f40c3307e6fb5340482a5e11df78dafc619ceff97f11fa79fea320" } }), component: Hopper } -Encrypted with 0x02030405: LiveHop { public_key: 0x03040506, payer: Some(Payer { wallet: Wallet { kind: Address(0x71d0fc7d1c570b1ed786382b551a09391c91e33d) }, proof: Signature { v: 1, r: "63be72962f19dda7802220ed48c0d8199d510b45608a3789c50f61912b98a15b", s: "63be72962f19dda7802220ed48c0d8199d510b45608a3789c50f61912b98a15b" } }), component: Hopper } -Encrypted with 0x03040506: LiveHop { public_key: 0x02030405, payer: Some(Payer { wallet: Wallet { kind: Address(0x71d0fc7d1c570b1ed786382b551a09391c91e33d) }, proof: Signature { v: 1, r: "9ca23557adf96d7aed407a06ce96851a4184e947a7b29b6c3872eef902fcba1e", s: "9ca23557adf96d7aed407a06ce96851a4184e947a7b29b6c3872eef902fcba1e" } }), component: ProxyClient } -Encrypted with 0x02030405: LiveHop { public_key: 0x01020304, payer: Some(Payer { wallet: Wallet { kind: Address(0x71d0fc7d1c570b1ed786382b551a09391c91e33d) }, proof: Signature { v: 1, r: "63be72962f19dda7802220ed48c0d8199d510b45608a3789c50f61912b98a15b", s: "63be72962f19dda7802220ed48c0d8199d510b45608a3789c50f61912b98a15b" } }), component: Hopper } -Encrypted with 0x01020304: LiveHop { public_key: 0x, payer: Some(Payer { wallet: Wallet { kind: Address(0x71d0fc7d1c570b1ed786382b551a09391c91e33d) }, proof: Signature { v: 0, r: "8b663e5a10f40c3307e6fb5340482a5e11df78dafc619ceff97f11fa79fea320", s: "8b663e5a10f40c3307e6fb5340482a5e11df78dafc619ceff97f11fa79fea320" } }), component: ProxyServer } +Encrypted with 0x01020304: LiveHop { public_key: 0x02030405, payer: Some(Payer { wallet: Wallet { kind: Address(0x71d0fc7d1c570b1ed786382b551a09391c91e33d) }, proof: Signature { v: 0, r: "3e3a92d7284c2c2ff7119e9f7a7e183b062a335a598e965a47c36a2f288b6f8d", s: "3e3a92d7284c2c2ff7119e9f7a7e183b062a335a598e965a47c36a2f288b6f8d" } }), component: Hopper } +Encrypted with 0x02030405: LiveHop { public_key: 0x03040506, payer: Some(Payer { wallet: Wallet { kind: Address(0x71d0fc7d1c570b1ed786382b551a09391c91e33d) }, proof: Signature { v: 0, r: "4324a40295bb36ef2b927fb24250fe42397a57b861ea152bbbe4f84150d4ff5a", s: "4324a40295bb36ef2b927fb24250fe42397a57b861ea152bbbe4f84150d4ff5a" } }), component: Hopper } +Encrypted with 0x03040506: LiveHop { public_key: 0x02030405, payer: Some(Payer { wallet: Wallet { kind: Address(0x71d0fc7d1c570b1ed786382b551a09391c91e33d) }, proof: Signature { v: 1, r: "8649b8f6db6232cb1e4f1f04786ad4ef33488c968e64bec74ecd893d6d05c1b9", s: "8649b8f6db6232cb1e4f1f04786ad4ef33488c968e64bec74ecd893d6d05c1b9" } }), component: ProxyClient } +Encrypted with 0x02030405: LiveHop { public_key: 0x01020304, payer: Some(Payer { wallet: Wallet { kind: Address(0x71d0fc7d1c570b1ed786382b551a09391c91e33d) }, proof: Signature { v: 0, r: "4324a40295bb36ef2b927fb24250fe42397a57b861ea152bbbe4f84150d4ff5a", s: "4324a40295bb36ef2b927fb24250fe42397a57b861ea152bbbe4f84150d4ff5a" } }), component: Hopper } +Encrypted with 0x01020304: LiveHop { public_key: 0x, payer: Some(Payer { wallet: Wallet { kind: Address(0x71d0fc7d1c570b1ed786382b551a09391c91e33d) }, proof: Signature { v: 0, r: "3e3a92d7284c2c2ff7119e9f7a7e183b062a335a598e965a47c36a2f288b6f8d", s: "3e3a92d7284c2c2ff7119e9f7a7e183b062a335a598e965a47c36a2f288b6f8d" } }), component: ProxyServer } Encrypted with 0x01020304: Return Route ID: 1234 "# ) diff --git a/node/src/sub_lib/stream_key.rs b/node/src/sub_lib/stream_key.rs index fc02e7a86..7c3110ee1 100644 --- a/node/src/sub_lib/stream_key.rs +++ b/node/src/sub_lib/stream_key.rs @@ -1,12 +1,23 @@ // Copyright (c) 2019, MASQ (https://masq.ai) and/or its affiliates. All rights reserved. +use crate::sub_lib::cryptde::PublicKey; +use lazy_static::lazy_static; use serde::de::Visitor; use serde::Deserialize; use serde::Deserializer; use serde::Serialize; use serde::Serializer; +use sodiumoxide::randombytes::randombytes_into; use std::fmt; -use uuid::Uuid; +use std::net::SocketAddr; + +lazy_static! { + static ref STREAM_KEY_SALT: [u8; 8] = { + let mut salt = [0; 8]; + randombytes_into(&mut salt); + salt + }; +} #[derive(Hash, PartialEq, Eq, Clone, Copy)] pub struct StreamKey { @@ -72,26 +83,18 @@ impl<'a> Visitor<'a> for StreamKeyVisitor { } } -impl Default for StreamKey { - fn default() -> Self { - Self::new() - } -} - impl StreamKey { - pub fn new() -> StreamKey { + pub fn new(public_key: &PublicKey, client_addr: SocketAddr) -> StreamKey { let mut hash = sha1::Sha1::new(); - let uuid = Uuid::new_v4(); - let uuid_bytes: &[u8] = uuid.as_bytes(); - hash.update(uuid_bytes); + hash.update(public_key.as_ref()); + hash = add_socket_addr_to_hash(hash, client_addr); + hash.update(STREAM_KEY_SALT.as_slice()); StreamKey { hash: hash.digest().bytes(), } } } -type HashType = [u8; sha1::DIGEST_LENGTH]; - impl StreamKey { pub fn make_meaningless_stream_key() -> StreamKey { StreamKey { @@ -108,21 +111,74 @@ impl StreamKey { } } +type HashType = [u8; sha1::DIGEST_LENGTH]; + +fn add_socket_addr_to_hash(mut hash: sha1::Sha1, client_addr: SocketAddr) -> sha1::Sha1 { + match client_addr { + SocketAddr::V4(v4_addr) => { + hash.update(&v4_addr.ip().octets()); + hash.update(&[(v4_addr.port() & 0xFF) as u8, (v4_addr.port() >> 8) as u8]); + } + SocketAddr::V6(v6_addr) => { + hash.update(&v6_addr.ip().octets()); + hash.update(&[(v6_addr.port() & 0xFF) as u8, (v6_addr.port() >> 8) as u8]); + } + } + hash +} + #[cfg(test)] mod tests { use super::*; - use std::collections::HashSet; + use crate::test_utils::main_cryptde; + use itertools::Itertools; + use std::net::IpAddr; + use std::str::FromStr; + + #[test] + fn stream_keys_with_different_host_names_are_different() { + let public_key = main_cryptde().public_key(); + let stream_key_count = 100; + let ip_addr = IpAddr::from_str("1.2.3.4").unwrap(); + let client_addrs = (0..stream_key_count).map(|i| SocketAddr::new(ip_addr, 1024 + i as u16)); + + let stream_keys = client_addrs + .map(|client_addr| StreamKey::new(&public_key, client_addr)) + .collect_vec(); + + (0..(stream_key_count - 1)).for_each(|a| { + ((a + 1)..stream_key_count).for_each(|b| { + assert_ne!(stream_keys[a], stream_keys[b]); + }); + }); + } #[test] - fn stream_keys_are_unique() { - let mut stream_keys_set = HashSet::new(); + fn stream_keys_from_different_public_keys_are_different() { + let client_addr = SocketAddr::new(IpAddr::from_str("1.2.3.4").unwrap(), 1024); - for i in 1..=1_000 { - let stream_key = StreamKey::default(); - let is_unique = stream_keys_set.insert(stream_key); + let stream_keys = vec![PublicKey::new(&[1, 2, 3]), PublicKey::new(&[1, 2, 2])] + .iter() + .map(|public_key| StreamKey::new(public_key, client_addr)) + .collect_vec(); - assert!(is_unique, "{}", &format!("Stream key {i} is not unique")); - } + assert_ne!(stream_keys[0], stream_keys[1]); + } + + #[test] + fn stream_keys_are_salted() { + let public_key = main_cryptde().public_key(); + let client_addr = SocketAddr::new(IpAddr::from_str("1.2.3.4").unwrap(), 1024); + + let result = StreamKey::new(&public_key, client_addr); + + let mut hash = sha1::Sha1::new(); + hash.update(public_key.as_ref()); + hash = add_socket_addr_to_hash(hash, client_addr); + let attack = StreamKey { + hash: hash.digest().bytes(), + }; + assert_ne!(attack, result) } #[test] diff --git a/node/tests/financials_test.rs b/node/tests/financials_test.rs index 0874cb39b..9847efa38 100644 --- a/node/tests/financials_test.rs +++ b/node/tests/financials_test.rs @@ -3,29 +3,32 @@ pub mod utils; use crate::utils::{make_conn, CommandConfig}; +use masq_lib::constants::POLYGON_MAINNET_FULL_IDENTIFIER; use masq_lib::messages::{ TopRecordsConfig, TopRecordsOrdering, UiFinancialsRequest, UiFinancialsResponse, UiShutdownRequest, NODE_UI_PROTOCOL, }; use masq_lib::test_utils::ui_connection::UiConnection; -use masq_lib::test_utils::utils::ensure_node_home_directory_exists; +use masq_lib::test_utils::utils::{ensure_node_home_directory_exists, open_all_file_permissions}; use masq_lib::utils::find_free_port; use node_lib::accountant::db_access_objects::payable_dao::{PayableDao, PayableDaoReal}; use node_lib::accountant::db_access_objects::receivable_dao::{ReceivableDao, ReceivableDaoReal}; use node_lib::accountant::db_access_objects::utils::{from_time_t, to_time_t}; use node_lib::accountant::gwei_to_wei; +use node_lib::database::db_initializer::{ + DbInitializationConfig, DbInitializer, DbInitializerReal, +}; +use node_lib::db_config::config_dao::{ConfigDao, ConfigDaoReal}; use node_lib::test_utils::make_wallet; use std::time::SystemTime; use utils::MASQNode; #[test] -fn financials_command_retrieves_payable_and_receivable_records() { +fn financials_command_retrieves_payable_and_receivable_records_integration() { fdlimit::raise_fd_limit(); + let test_name = "financials_command_retrieves_payable_and_receivable_records_integration"; let port = find_free_port(); - let home_dir = ensure_node_home_directory_exists( - "financials_test", - "financials_command_retrieves_payable_and_receivable_records", - ); + let home_dir = ensure_node_home_directory_exists("integration", test_name); let now = SystemTime::now(); let timestamp_payable = from_time_t(to_time_t(now) - 678); let timestamp_receivable_1 = from_time_t(to_time_t(now) - 10000); @@ -36,6 +39,20 @@ fn financials_command_retrieves_payable_and_receivable_records() { let amount_payable = gwei_to_wei(45678357_u64); let amount_receivable_1 = gwei_to_wei(9000_u64); let amount_receivable_2 = gwei_to_wei(345678_u64); + { + let db_initializer = DbInitializerReal {}; + let conn = db_initializer + .initialize(&home_dir, DbInitializationConfig::test_default()) + .unwrap(); + let config_dao = ConfigDaoReal::new(conn); + config_dao + .set( + "chain_name", + Some(POLYGON_MAINNET_FULL_IDENTIFIER.to_string()), + ) + .unwrap(); + } + open_all_file_permissions(home_dir.clone()); PayableDaoReal::new(make_conn(&home_dir)) .more_money_payable(timestamp_payable, &wallet_payable, amount_payable) .unwrap(); @@ -55,7 +72,7 @@ fn financials_command_retrieves_payable_and_receivable_records() { ) .unwrap(); let mut node = MASQNode::start_standard( - "financials_command_retrieves_payable_and_receivable_records", + test_name, Some(CommandConfig::new().pair("--ui-port", &port.to_string())), false, true, @@ -84,16 +101,23 @@ fn financials_command_retrieves_payable_and_receivable_records() { assert_eq!(payable[0].wallet, wallet_payable.to_string()); assert_eq!(payable[0].balance_gwei, 45678357_u64); assert_eq!(payable[0].pending_payable_hash_opt, None); - assert_eq!(receivable[0].wallet, wallet_receivable_1.to_string()); - assert_eq!(receivable[0].balance_gwei, 9000_i64); - assert_eq!(receivable[1].wallet, wallet_receivable_2.to_string()); - assert_eq!(receivable[1].balance_gwei, 345678_i64); let act_period = after.duration_since(before).unwrap().as_secs(); let age_payable = payable[0].age_s; assert!(age_payable >= 678 && age_payable <= (age_payable + act_period)); - let age_receivable_1 = receivable[0].age_s; + let receivable_indexes = if receivable[0].wallet == wallet_receivable_1.to_string() { + vec![0, 1] + } else { + vec![1, 0] + }; + let first_receivable = &receivable[receivable_indexes[0]]; + let second_receivable = &receivable[receivable_indexes[1]]; + assert_eq!(first_receivable.wallet, wallet_receivable_1.to_string()); + assert_eq!(first_receivable.balance_gwei, 9000_i64); + let age_receivable_1 = first_receivable.age_s; assert!(age_receivable_1 >= 10000 && age_receivable_1 <= (age_receivable_1 + act_period)); - let age_receivable_2 = receivable[1].age_s; + assert_eq!(second_receivable.wallet, wallet_receivable_2.to_string()); + assert_eq!(second_receivable.balance_gwei, 345678_i64); + let age_receivable_2 = second_receivable.age_s; assert!(age_receivable_2 >= 1111 && age_receivable_2 <= (age_receivable_2 + act_period)); client.send(UiShutdownRequest {}); node.wait_for_exit(); diff --git a/node/tests/ui_gateway_test.rs b/node/tests/ui_gateway_test.rs index 042cfda42..c38063748 100644 --- a/node/tests/ui_gateway_test.rs +++ b/node/tests/ui_gateway_test.rs @@ -16,15 +16,13 @@ use masq_lib::utils::{add_chain_specific_directory, find_free_port}; use utils::CommandConfig; #[test] -fn ui_requests_something_and_gets_corresponding_response() { +fn ui_requests_something_and_gets_corresponding_response_integration() { fdlimit::raise_fd_limit(); + let test_name = "ui_requests_something_and_gets_corresponding_response"; let port = find_free_port(); - let home_dir = ensure_node_home_directory_exists( - "ui_gateway_test", - "ui_requests_something_and_gets_corresponding_response", - ); + let home_dir = ensure_node_home_directory_exists("ui_gateway_test", test_name); let mut node = utils::MASQNode::start_standard( - "ui_requests_something_and_gets_corresponding_response", + test_name, Some( CommandConfig::new() .pair("--ui-port", &port.to_string()) @@ -98,14 +96,12 @@ fn daemon_does_not_allow_node_to_keep_his_client_alive_integration() { //for the Daemon's client, so we need to make the Daemon send a close message //breaking any reference to him immediately fdlimit::raise_fd_limit(); - let data_directory = ensure_node_home_directory_exists( - "ui_gateway_test", - "daemon_does_not_allow_node_to_keep_his_client_alive_integration", - ); + let test_name = "daemon_does_not_allow_node_to_keep_his_client_alive_integration"; + let data_directory = ensure_node_home_directory_exists("ui_gateway_test", test_name); let expected_chain_data_dir = add_chain_specific_directory(DEFAULT_CHAIN, &data_directory); let daemon_port = find_free_port(); let mut daemon = utils::MASQNode::start_daemon( - "daemon_does_not_allow_node_to_keep_his_client_alive_integration", + test_name, Some(CommandConfig::new().pair("--ui-port", daemon_port.to_string().as_str())), true, true, @@ -172,9 +168,10 @@ fn daemon_does_not_allow_node_to_keep_his_client_alive_integration() { #[test] fn cleanup_after_deceased_clients_integration() { fdlimit::raise_fd_limit(); + let test_name = "cleanup_after_deceased_clients_integration"; let port = find_free_port(); let mut node = utils::MASQNode::start_standard( - "cleanup_after_deceased_clients_integration", + test_name, Some( CommandConfig::new() .pair("--chain", DEFAULT_CHAIN.rec().literal_identifier) diff --git a/node/tests/utils.rs b/node/tests/utils.rs index adeec8c7e..45eaa6970 100644 --- a/node/tests/utils.rs +++ b/node/tests/utils.rs @@ -359,10 +359,18 @@ impl MASQNode { ensure_start: bool, command_getter: F, ) -> MASQNode { - let data_dir = if sterile_database { - ensure_node_home_directory_exists("integration", test_name) - } else { - node_home_directory("integration", test_name) + let configured_data_dir_opt = match &config_opt { + Some(config) => config + .value_of("--data-directory") + .map(|data_dir_str| PathBuf::from(data_dir_str)), + None => None, + }; + let data_dir = match configured_data_dir_opt { + Some(data_dir) => data_dir, + None => match sterile_database { + true => ensure_node_home_directory_exists("integration", test_name), + false => node_home_directory("integration", test_name), + }, }; if sterile_logfile { let _ = Self::remove_logfile(&data_dir); From 32616df9274c09a61f6ce07a624ecd339bb8c42a Mon Sep 17 00:00:00 2001 From: utkarshg6 Date: Tue, 8 Apr 2025 10:31:05 +0530 Subject: [PATCH 2/4] GH-538: increase gas price by 80% --- .../blockchain_interface_web3/lower_level_interface_web3.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/node/src/blockchain/blockchain_interface/blockchain_interface_web3/lower_level_interface_web3.rs b/node/src/blockchain/blockchain_interface/blockchain_interface_web3/lower_level_interface_web3.rs index ff78110e8..3bc4b9f2b 100644 --- a/node/src/blockchain/blockchain_interface/blockchain_interface_web3/lower_level_interface_web3.rs +++ b/node/src/blockchain/blockchain_interface/blockchain_interface_web3/lower_level_interface_web3.rs @@ -12,7 +12,7 @@ use web3::transports::{Batch, Http}; use web3::types::{Address, BlockNumber, Filter, Log, TransactionReceipt}; use web3::{Error, Web3}; -const GAS_PRICE_INCREASE_PERCENTAGE: u128 = 30; +const GAS_PRICE_INCREASE_PERCENTAGE: u128 = 80; #[derive(Debug, PartialEq, Eq, Clone)] pub enum TransactionReceiptResult { @@ -195,7 +195,7 @@ mod tests { #[test] fn constants_have_correct_values() { - assert_eq!(GAS_PRICE_INCREASE_PERCENTAGE, 30); + assert_eq!(GAS_PRICE_INCREASE_PERCENTAGE, 80); } #[test] From 1177696070a0800987c092cb7bbccf238ba96a65 Mon Sep 17 00:00:00 2001 From: utkarshg6 Date: Tue, 8 Apr 2025 10:59:19 +0530 Subject: [PATCH 3/4] GH-538: pass unit test --- node/src/accountant/mod.rs | 16 ++++++++-------- node/src/blockchain/blockchain_bridge.rs | 6 ++++-- .../lower_level_interface_web3.rs | 2 +- .../blockchain_interface_web3/mod.rs | 6 ++++-- .../blockchain_interface_initializer.rs | 5 ++++- 5 files changed, 21 insertions(+), 14 deletions(-) diff --git a/node/src/accountant/mod.rs b/node/src/accountant/mod.rs index 61308ef7f..923a6d0fc 100644 --- a/node/src/accountant/mod.rs +++ b/node/src/accountant/mod.rs @@ -3437,10 +3437,10 @@ mod tests { init_test_logging(); let port = find_free_port(); let pending_tx_hash_1 = - H256::from_str("758b00d9041ce3afe0f88c672ee07bf524d70aa101147942212cada6a753bc40") + H256::from_str("acc64bde11847ec2186914c8cf18b9b153bf1b6e02b534aa314946fc3a828df0") .unwrap(); let pending_tx_hash_2 = - H256::from_str("4f2cd80b817ca717e33b27d73b4483bbe2baf15fdf3e72a59c0d554b96b76192") + H256::from_str("e91c8324cb47305eefc0bff30b5981353326910eede7d3cf41579b5fcce712b4") .unwrap(); let _blockchain_client_server = MBCSBuilder::new(port) // Blockchain Agent Gas Price @@ -3770,16 +3770,16 @@ mod tests { ); let log_handler = TestLogHandler::new(); log_handler.exists_log_containing( - "WARN: Accountant: Broken transactions 0x758b00d9041ce3afe0f88c672ee07bf524d70\ - aa101147942212cada6a753bc40 marked as an error. You should take over the care of those to make sure \ + "WARN: Accountant: Broken transactions 0xacc64bde11847ec2186914c8cf18b9b153bf\ + 1b6e02b534aa314946fc3a828df0 marked as an error. You should take over the care of those to make sure \ your debts are going to be settled properly. At the moment, there is no automated process \ fixing that without your assistance"); - log_handler.exists_log_matching("INFO: Accountant: Transaction 0x4f2cd80b817ca717e\ - 33b27d73b4483bbe2baf15fdf3e72a59c0d554b96b76192 has been added to the blockchain; detected locally at \ + log_handler.exists_log_matching("INFO: Accountant: Transaction 0xe91c8324cb47305eef\ + c0bff30b5981353326910eede7d3cf41579b5fcce712b4 has been added to the blockchain; detected locally at \ attempt 4 at \\d{2,}ms after its sending"); log_handler.exists_log_containing( - "INFO: Accountant: Transactions 0x4f2cd80b817ca717e33b27d73b4483\ - bbe2baf15fdf3e72a59c0d554b96b76192 completed their confirmation process succeeding", + "INFO: Accountant: Transactions 0xe91c8324cb47305eefc0bff30b5981353326910eede7\ + d3cf41579b5fcce712b4 completed their confirmation process succeeding", ); } diff --git a/node/src/blockchain/blockchain_bridge.rs b/node/src/blockchain/blockchain_bridge.rs index d4b66f9bb..ab95ab6fb 100644 --- a/node/src/blockchain/blockchain_bridge.rs +++ b/node/src/blockchain/blockchain_bridge.rs @@ -598,7 +598,7 @@ mod tests { use std::time::{Duration, SystemTime}; use web3::types::{TransactionReceipt, H160}; use masq_lib::constants::DEFAULT_MAX_BLOCK_COUNT; - use crate::blockchain::blockchain_interface::blockchain_interface_web3::lower_level_interface_web3::{TransactionBlock, TxReceipt}; + use crate::blockchain::blockchain_interface::blockchain_interface_web3::lower_level_interface_web3::{TransactionBlock, TxReceipt, GAS_PRICE_INCREASE_PERCENTAGE}; impl Handler> for BlockchainBridge { type Result = (); @@ -745,7 +745,9 @@ mod tests { let accountant_received_payment = accountant_recording_arc.lock().unwrap(); let blockchain_agent_with_context_msg_actual: &BlockchainAgentWithContextMessage = accountant_received_payment.get_record(0); - let expected_gas_price = (9395240960 * 13) / 10; // 30% increase + let gas_price_from_rpc = 9395240960; + let gas_price_increase = (gas_price_from_rpc * GAS_PRICE_INCREASE_PERCENTAGE) / 100; + let expected_gas_price = gas_price_from_rpc + gas_price_increase; assert_eq!( blockchain_agent_with_context_msg_actual.protected_qualified_payables, qualified_payables diff --git a/node/src/blockchain/blockchain_interface/blockchain_interface_web3/lower_level_interface_web3.rs b/node/src/blockchain/blockchain_interface/blockchain_interface_web3/lower_level_interface_web3.rs index 3bc4b9f2b..9c9e9cd78 100644 --- a/node/src/blockchain/blockchain_interface/blockchain_interface_web3/lower_level_interface_web3.rs +++ b/node/src/blockchain/blockchain_interface/blockchain_interface_web3/lower_level_interface_web3.rs @@ -12,7 +12,7 @@ use web3::transports::{Batch, Http}; use web3::types::{Address, BlockNumber, Filter, Log, TransactionReceipt}; use web3::{Error, Web3}; -const GAS_PRICE_INCREASE_PERCENTAGE: u128 = 80; +pub const GAS_PRICE_INCREASE_PERCENTAGE: u128 = 80; #[derive(Debug, PartialEq, Eq, Clone)] pub enum TransactionReceiptResult { diff --git a/node/src/blockchain/blockchain_interface/blockchain_interface_web3/mod.rs b/node/src/blockchain/blockchain_interface/blockchain_interface_web3/mod.rs index 04fd4fc4a..9ec9c052a 100644 --- a/node/src/blockchain/blockchain_interface/blockchain_interface_web3/mod.rs +++ b/node/src/blockchain/blockchain_interface/blockchain_interface_web3/mod.rs @@ -459,7 +459,7 @@ mod tests { use std::str::FromStr; use web3::transports::Http; use web3::types::{H256, U256}; - use crate::blockchain::blockchain_interface::blockchain_interface_web3::lower_level_interface_web3::{TransactionBlock, TxReceipt, TxStatus}; + use crate::blockchain::blockchain_interface::blockchain_interface_web3::lower_level_interface_web3::{TransactionBlock, TxReceipt, TxStatus, GAS_PRICE_INCREASE_PERCENTAGE}; #[test] fn constants_are_correct() { @@ -855,7 +855,9 @@ mod tests { let expected_transaction_fee_balance = U256::from(65_520); let expected_masq_balance = U256::from(65_535); - let expected_gas_price_wei = 1_000_000_000 + 300_000_000; + let gas_price_from_rpc = 1_000_000_000; + let gas_price_increase = (gas_price_from_rpc * GAS_PRICE_INCREASE_PERCENTAGE) / 100; + let expected_gas_price_wei = gas_price_from_rpc + gas_price_increase; assert_eq!(result.consuming_wallet(), &wallet); assert_eq!( result.consuming_wallet_balances(), diff --git a/node/src/blockchain/blockchain_interface_initializer.rs b/node/src/blockchain/blockchain_interface_initializer.rs index 66c24530f..3d8306e86 100644 --- a/node/src/blockchain/blockchain_interface_initializer.rs +++ b/node/src/blockchain/blockchain_interface_initializer.rs @@ -58,6 +58,7 @@ mod tests { use masq_lib::constants::DEFAULT_CHAIN; use masq_lib::test_utils::mock_blockchain_client_server::MBCSBuilder; use masq_lib::utils::find_free_port; + use crate::blockchain::blockchain_interface::blockchain_interface_web3::lower_level_interface_web3::GAS_PRICE_INCREASE_PERCENTAGE; #[test] fn initialize_web3_interface_works() { @@ -83,10 +84,12 @@ mod tests { .wait() .unwrap(); + let gas_price_from_rpc = 1_000_000_000; + let gas_price_increase = (gas_price_from_rpc * GAS_PRICE_INCREASE_PERCENTAGE) / 100; assert_eq!(blockchain_agent.consuming_wallet(), &wallet); assert_eq!( blockchain_agent.agreed_fee_per_computation_unit(), - 1_000_000_000 + 300_000_000 + gas_price_from_rpc + gas_price_increase ); } From aec99a2f2e8ae8c6cb4a610a7385f1ca05955a04 Mon Sep 17 00:00:00 2001 From: Utkarsh Gupta Date: Tue, 8 Apr 2025 11:02:29 +0530 Subject: [PATCH 4/4] GH-538: fix multinode tests --- .../tests/verify_bill_payment.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/multinode_integration_tests/tests/verify_bill_payment.rs b/multinode_integration_tests/tests/verify_bill_payment.rs index 56f87a1d0..edb264fed 100644 --- a/multinode_integration_tests/tests/verify_bill_payment.rs +++ b/multinode_integration_tests/tests/verify_bill_payment.rs @@ -234,7 +234,7 @@ fn verify_bill_payment() { assert_balances( &contract_owner_wallet, &blockchain_interface, - "99994287232000000000", + "99992712652000000000", "471999999700000000000000000", ); @@ -409,7 +409,7 @@ fn verify_pending_payables() { assert_balances( &contract_owner_wallet, &blockchain_interface, - "99994287232000000000", + "99992712652000000000", "471999999700000000000000000", ); assert_balances( @@ -450,17 +450,17 @@ fn verify_pending_payables() { ); MASQNodeUtils::assert_node_wrote_log_containing( real_consuming_node.name(), - "Transaction 0xecab1c73ca90ebcb073526e28f1f8d4678704b74d1e0209779ddeefc8fb861f5 has been added to the blockchain;", + "Transaction 0x7e08536811791ff20855e459fed222e1cc06bcd684524ae1beaa36fb28dca4f8 has been added to the blockchain;", Duration::from_secs(5), ); MASQNodeUtils::assert_node_wrote_log_containing( real_consuming_node.name(), - "Transaction 0xae0bf6400f0b9950a1d456e488549414d118714b81a39233b811b629cf41399b has been added to the blockchain;", + "Transaction 0x21aee15c389bd8894e4b8ffbc35a9f5084c4eea91d01d6ba5b7a93a58555d4e8 has been added to the blockchain;", Duration::from_secs(5), ); MASQNodeUtils::assert_node_wrote_log_containing( real_consuming_node.name(), - "Transaction 0x89acc46da0df6ef8c6f5574307ae237a812bd28af524a62131013b5e19ca3e26 has been added to the blockchain;", + "Transaction 0x619c64860fea5593d74fccb48fd8e3d44fe374345ff4bb657c053b2d83b71138 has been added to the blockchain;", Duration::from_secs(5), ); }