From 883de175dadee58c4f49fff9a655cae1a2450b3d Mon Sep 17 00:00:00 2001 From: Hansie Odendaal <39146854+hansieodendaal@users.noreply.github.com> Date: Tue, 28 Nov 2023 11:02:03 +0200 Subject: [PATCH 1/2] feat!: disable console wallet grpc (#5988) Description --- Disabled the console wallet gRPC via a feature flag in the console wallet build configuration, where gRPC is not part of the default build. Trying to run with the console wallet with the config option `grpc_enabled = true` where the gRPC feature is not enabled for the build will result in a runtime error. Motivation and Context --- See #5930 How Has This Been Tested? --- Existing unit and cucumber tests pass What process can a PR reviewer use to test or verify this change? --- Code walkthrough Breaking Changes --- - [ ] None - [ ] Requires data directory on base node to be deleted - [ ] Requires hard fork - [x] Other - The console wallet must be build with the `features = ["grpc"]` to enable gRPC --- .../minotari_console_wallet/Cargo.toml | 1 + .../src/wallet_modes.rs | 31 ++++++++++++++----- integration_tests/Cargo.toml | 2 +- 3 files changed, 25 insertions(+), 9 deletions(-) diff --git a/applications/minotari_console_wallet/Cargo.toml b/applications/minotari_console_wallet/Cargo.toml index a3d1c6e4c9..655ad8fee4 100644 --- a/applications/minotari_console_wallet/Cargo.toml +++ b/applications/minotari_console_wallet/Cargo.toml @@ -71,6 +71,7 @@ tari_features = { path = "../../common/tari_features"} [features] libtor = ["tari_libtor"] +grpc = [] [package.metadata.cargo-machete] # We need to specify extra features for log4rs even though it is not used directly in this crate diff --git a/applications/minotari_console_wallet/src/wallet_modes.rs b/applications/minotari_console_wallet/src/wallet_modes.rs index b5a7b4cdc4..d3c96af01a 100644 --- a/applications/minotari_console_wallet/src/wallet_modes.rs +++ b/applications/minotari_console_wallet/src/wallet_modes.rs @@ -268,7 +268,9 @@ pub fn tui_mode( mut wallet: WalletSqlite, ) -> Result<(), ExitError> { let (events_broadcaster, _events_listener) = broadcast::channel(100); + if config.grpc_enabled { + #[cfg(feature = "grpc")] if let Some(address) = config.grpc_address.clone() { let grpc = WalletGrpcServer::new(wallet.clone()).map_err(|e| ExitError { exit_code: ExitCode::UnknownError, @@ -281,6 +283,11 @@ pub fn tui_mode( wallet.clone(), )); } + #[cfg(not(feature = "grpc"))] + return Err(ExitError::new( + ExitCode::GrpcError, + "gRPC server is enabled but not supported in this build", + )); } let notifier = Notifier::new( @@ -377,14 +384,22 @@ pub fn recovery_mode( pub fn grpc_mode(handle: Handle, config: &WalletConfig, wallet: WalletSqlite) -> Result<(), ExitError> { info!(target: LOG_TARGET, "Starting grpc server"); if let Some(address) = config.grpc_address.as_ref().filter(|_| config.grpc_enabled).cloned() { - let grpc = WalletGrpcServer::new(wallet.clone()).map_err(|e| ExitError { - exit_code: ExitCode::UnknownError, - details: Some(e.to_string()), - })?; - let auth = config.grpc_authentication.clone(); - handle - .block_on(run_grpc(grpc, address, auth, wallet)) - .map_err(|e| ExitError::new(ExitCode::GrpcError, e))?; + #[cfg(feature = "grpc")] + { + let grpc = WalletGrpcServer::new(wallet.clone()).map_err(|e| ExitError { + exit_code: ExitCode::UnknownError, + details: Some(e.to_string()), + })?; + let auth = config.grpc_authentication.clone(); + handle + .block_on(run_grpc(grpc, address, auth, wallet)) + .map_err(|e| ExitError::new(ExitCode::GrpcError, e))?; + } + #[cfg(not(feature = "grpc"))] + return Err(ExitError::new( + ExitCode::GrpcError, + "gRPC server is enabled but not supported in this build", + )); } else { println!("GRPC server is disabled"); } diff --git a/integration_tests/Cargo.toml b/integration_tests/Cargo.toml index ecfa79e0df..965e3c9e18 100644 --- a/integration_tests/Cargo.toml +++ b/integration_tests/Cargo.toml @@ -18,7 +18,7 @@ tari_common = { path = "../common" } tari_common_types = { path = "../base_layer/common_types" } tari_comms = { path = "../comms/core" } tari_comms_dht = { path = "../comms/dht" } -minotari_console_wallet = { path = "../applications/minotari_console_wallet" } +minotari_console_wallet = { path = "../applications/minotari_console_wallet", features = ["grpc"] } tari_contacts = { path = "../base_layer/contacts" } tari_core = { path = "../base_layer/core" } minotari_merge_mining_proxy = { path = "../applications/minotari_merge_mining_proxy" } From c54478f1762773c00679752ec12366146863021f Mon Sep 17 00:00:00 2001 From: Stan Bondi Date: Tue, 28 Nov 2023 13:54:04 +0400 Subject: [PATCH 2/2] chore(comms): update snow to 0.9.4 (#5987) Description --- Update snow Motivation and Context --- Commits: https://github.com/mcginty/snow/commits/v0.9.4 Non-breaking update to use the latest version Breaking Changes --- - [x] None - [ ] Requires data directory on base node to be deleted - [ ] Requires hard fork - [ ] Other - Please specify --- Cargo.lock | 119 +++++++++--------------------------------- comms/core/Cargo.toml | 2 +- 2 files changed, 27 insertions(+), 94 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index f455ef95ca..963436d8ac 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -17,15 +17,6 @@ version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" -[[package]] -name = "aead" -version = "0.4.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0b613b8e1e3cf911a086f53f03bf286f52fd7a7258e4fa606f0ef220d39d8877" -dependencies = [ - "generic-array", -] - [[package]] name = "aead" version = "0.5.2" @@ -36,18 +27,6 @@ dependencies = [ "generic-array", ] -[[package]] -name = "aes" -version = "0.7.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9e8b47f52ea9bae42228d07ec09eb676433d7c4ed1ebdf0f1d1c29ed446f1ab8" -dependencies = [ - "cfg-if", - "cipher 0.3.0", - "cpufeatures", - "opaque-debug", -] - [[package]] name = "aes" version = "0.8.3" @@ -61,13 +40,13 @@ dependencies = [ [[package]] name = "aes-gcm" -version = "0.9.2" +version = "0.10.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bc3be92e19a7ef47457b8e6f90707e12b6ac5d20c6f3866584fa3be0787d839f" +checksum = "831010a0f742e1209b3bcea8fab6a8e149051ba6099432c8cb2cc117dec3ead1" dependencies = [ - "aead 0.4.3", - "aes 0.7.5", - "cipher 0.3.0", + "aead", + "aes", + "cipher 0.4.4", "ctr", "ghash", "subtle", @@ -724,18 +703,6 @@ dependencies = [ "cpufeatures", ] -[[package]] -name = "chacha20" -version = "0.8.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c80e5460aa66fe3b91d40bcbdab953a597b60053e34d684ac6903f863b680a6" -dependencies = [ - "cfg-if", - "cipher 0.3.0", - "cpufeatures", - "zeroize", -] - [[package]] name = "chacha20" version = "0.9.1" @@ -747,29 +714,16 @@ dependencies = [ "cpufeatures", ] -[[package]] -name = "chacha20poly1305" -version = "0.9.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a18446b09be63d457bbec447509e85f662f32952b035ce892290396bc0b0cff5" -dependencies = [ - "aead 0.4.3", - "chacha20 0.8.2", - "cipher 0.3.0", - "poly1305 0.7.2", - "zeroize", -] - [[package]] name = "chacha20poly1305" version = "0.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "10cd79432192d1c0f4e1a0fef9527696cc039165d729fb41b3f4f4f354c2dc35" dependencies = [ - "aead 0.5.2", + "aead", "chacha20 0.9.1", "cipher 0.4.4", - "poly1305 0.8.0", + "poly1305", "zeroize", ] @@ -1346,11 +1300,11 @@ dependencies = [ [[package]] name = "ctr" -version = "0.7.0" +version = "0.9.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a232f92a03f37dd7d7dd2adc67166c77e9cd88de5b019b9a9eecfaeaf7bfd481" +checksum = "0369ee1ad671834580515889b80f2ea915f23b8be8d0daa4bbaf2ac5c7590835" dependencies = [ - "cipher 0.3.0", + "cipher 0.4.4", ] [[package]] @@ -2152,9 +2106,9 @@ dependencies = [ [[package]] name = "ghash" -version = "0.4.4" +version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1583cc1656d7839fd3732b80cf4f38850336cdb9b8ded1cd399ca62958de3c99" +checksum = "d930750de5717d2dd0b8c0d42c076c0e884c81a73e6cab859bbd2339c71e3e40" dependencies = [ "opaque-debug", "polyval", @@ -3333,7 +3287,7 @@ dependencies = [ "bincode", "blake2", "borsh", - "chacha20poly1305 0.10.1", + "chacha20poly1305", "chrono", "derivative", "diesel", @@ -3380,7 +3334,7 @@ version = "0.53.0-pre.0" dependencies = [ "borsh", "cbindgen", - "chacha20poly1305 0.10.1", + "chacha20poly1305", "chrono", "futures 0.3.29", "itertools 0.10.5", @@ -4063,7 +4017,7 @@ version = "0.10.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "27e1f8e085bfa9b85763fe3ddaacbe90a09cd847b3833129153a6cb063bbe132" dependencies = [ - "aes 0.8.3", + "aes", "base64 0.21.5", "bitfield", "block-padding", @@ -4222,17 +4176,6 @@ dependencies = [ "plotters-backend", ] -[[package]] -name = "poly1305" -version = "0.7.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "048aeb476be11a4b6ca432ca569e375810de9294ae78f4774e78ea98a9246ede" -dependencies = [ - "cpufeatures", - "opaque-debug", - "universal-hash 0.4.0", -] - [[package]] name = "poly1305" version = "0.8.0" @@ -4241,19 +4184,19 @@ checksum = "8159bd90725d2df49889a078b54f4f79e87f1f8a8444194cdca81d38f5393abf" dependencies = [ "cpufeatures", "opaque-debug", - "universal-hash 0.5.1", + "universal-hash", ] [[package]] name = "polyval" -version = "0.5.3" +version = "0.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8419d2b623c7c0896ff2d5d96e2cb4ede590fed28fcc34934f4c33c036e620a1" +checksum = "d52cff9d1d4dee5fe6d03729099f4a310a41179e0a10dbf542039873f2e826fb" dependencies = [ "cfg-if", "cpufeatures", "opaque-debug", - "universal-hash 0.4.0", + "universal-hash", ] [[package]] @@ -5270,13 +5213,13 @@ dependencies = [ [[package]] name = "snow" -version = "0.9.3" +version = "0.9.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0c9d1425eb528a21de2755c75af4c9b5d57f50a0d4c3b7f1828a4cd03f8ba155" +checksum = "58021967fd0a5eeeb23b08df6cc244a4d4a5b4aec1d27c9e02fad1a58b4cd74e" dependencies = [ "aes-gcm", "blake2", - "chacha20poly1305 0.9.1", + "chacha20poly1305", "curve25519-dalek 4.1.1", "rand_core 0.6.4", "rustc_version", @@ -5629,7 +5572,7 @@ dependencies = [ "base64 0.21.5", "blake2", "borsh", - "chacha20poly1305 0.10.1", + "chacha20poly1305", "digest 0.10.7", "lazy_static", "newtype-ops", @@ -5701,7 +5644,7 @@ dependencies = [ "bitflags 2.4.1", "blake2", "chacha20 0.7.3", - "chacha20poly1305 0.10.1", + "chacha20poly1305", "chrono", "clap 3.2.25", "diesel", @@ -5795,7 +5738,7 @@ dependencies = [ "blake2", "borsh", "bytes 0.5.6", - "chacha20poly1305 0.10.1", + "chacha20poly1305", "chrono", "config", "criterion 0.4.0", @@ -5935,7 +5878,7 @@ dependencies = [ "async-trait", "blake2", "chacha20 0.7.3", - "chacha20poly1305 0.10.1", + "chacha20poly1305", "chrono", "crc32fast", "derivative", @@ -6790,16 +6733,6 @@ version = "0.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f962df74c8c05a667b5ee8bcf162993134c104e96440b663c8daa176dc772d8c" -[[package]] -name = "universal-hash" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8326b2c654932e3e4f9196e69d08fdf7cfd718e1dc6f66b347e6024a0c961402" -dependencies = [ - "generic-array", - "subtle", -] - [[package]] name = "universal-hash" version = "0.5.1" diff --git a/comms/core/Cargo.toml b/comms/core/Cargo.toml index 82c486e5bd..21c02f4b2a 100644 --- a/comms/core/Cargo.toml +++ b/comms/core/Cargo.toml @@ -40,7 +40,7 @@ rand = "0.8" serde = "1.0.119" serde_derive = "1.0.119" sha3 = "0.10" -snow = { version = "=0.9.3", features = ["default-resolver"] } +snow = { version = "0.9.4", features = ["default-resolver"] } thiserror = "1.0.26" tokio = { version = "1.23", features = ["rt-multi-thread", "time", "sync", "signal", "net", "macros", "io-util"] } tokio-stream = { version = "0.1.9", features = ["sync"] }