Skip to content

Commit

Permalink
feat!: disable console wallet grpc (#5988)
Browse files Browse the repository at this point in the history
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

<!-- Checklist -->
<!-- 1. Is the title of your PR in the form that would make nice release
notes? The title, excluding the conventional commit
tag, will be included exactly as is in the CHANGELOG, so please think
about it carefully. -->


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

<!-- Does this include a breaking change? If so, include this line as a
footer -->
<!-- BREAKING CHANGE: Description what the user should do, e.g. delete a
database, resync the chain -->
  • Loading branch information
hansieodendaal committed Nov 28, 2023
1 parent 0b0eab8 commit 883de17
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 9 deletions.
1 change: 1 addition & 0 deletions applications/minotari_console_wallet/Cargo.toml
Expand Up @@ -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
Expand Down
31 changes: 23 additions & 8 deletions applications/minotari_console_wallet/src/wallet_modes.rs
Expand Up @@ -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,
Expand All @@ -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(
Expand Down Expand Up @@ -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");
}
Expand Down
2 changes: 1 addition & 1 deletion integration_tests/Cargo.toml
Expand Up @@ -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" }
Expand Down

0 comments on commit 883de17

Please sign in to comment.