Skip to content

Commit

Permalink
Add config for gRPC methods
Browse files Browse the repository at this point in the history
Added configuration options for the base node's gRPC methods whereby each method can
be enabled or disabled with the startup config settings.
  • Loading branch information
hansieodendaal committed Oct 30, 2023
1 parent df9bc9a commit 3e0c548
Show file tree
Hide file tree
Showing 4 changed files with 347 additions and 2 deletions.
114 changes: 114 additions & 0 deletions applications/minotari_node/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,8 @@ pub struct BaseNodeConfig {
pub grpc_enabled: bool,
/// GRPC address of base node
pub grpc_address: Option<Multiaddr>,
/// GRPC server config - which methods are active and which not
pub grpc_server_config: BaseNodeGrpcServerConfig,
/// A path to the file that stores the base node identity and secret key
pub identity_file: PathBuf,
/// Spin up and use a built-in Tor instance. This only works on macos/linux - requires that the wallet was built
Expand Down Expand Up @@ -143,6 +145,44 @@ impl Default for BaseNodeConfig {
network: Network::default(),
grpc_enabled: true,
grpc_address: None,
grpc_server_config: BaseNodeGrpcServerConfig {
// These gRPC server methods will not share sensitive information, thus enabled by default
enable_list_headers: true,
enable_get_header_by_hash: true,
enable_get_blocks: true,
enable_get_block_timing: true,
enable_get_constants: true,
enable_get_block_size: true,
enable_get_block_fees: true,
enable_get_tokens_in_circulation: true,
enable_get_network_difficulty: true,
enable_get_new_block_template: true,
enable_get_new_block: true,
enable_get_new_block_blob: true,
enable_submit_block: true,
enable_submit_block_blob: true,
enable_submit_transaction: true,
enable_search_kernels: true,
enable_search_utxos: true,
enable_fetch_matching_utxos: true,
enable_get_peers: true,
enable_get_mempool_transactions: true,
enable_transaction_state: true,
enable_list_connected_peers: true,
enable_get_mempool_stats: true,
enable_get_active_validator_nodes: true,
enable_get_shard_key: true,
enable_get_template_registrations: true,
enable_get_side_chain_utxos: true,
// These gRPC server methods share sensitive information, thus disabled by default
enable_get_version: false,
enable_check_for_updates: false,
enable_get_sync_info: false,
enable_get_sync_progress: false,
enable_get_tip_info: false,
enable_identify: false,
enable_get_network_status: false,
},
identity_file: PathBuf::from("config/base_node_id.json"),
use_libtor: false,
tor_identity_file: PathBuf::from("config/base_node_tor_id.json"),
Expand Down Expand Up @@ -195,3 +235,77 @@ impl BaseNodeConfig {
pub enum DatabaseType {
Lmdb,
}

#[derive(Clone, Serialize, Deserialize, Debug)]
#[serde(deny_unknown_fields)]
#[allow(clippy::struct_excessive_bools)]
pub struct BaseNodeGrpcServerConfig {
/// Enable the ListHeaders gRPC server method
pub enable_list_headers: bool,
/// Enable the GetHeaderByHash gRPC server method
pub enable_get_header_by_hash: bool,
/// Enable the GetBlocks gRPC server method
pub enable_get_blocks: bool,
/// Enable the GetBlockTiming gRPC server method
pub enable_get_block_timing: bool,
/// Enable the GetConstants gRPC server method
pub enable_get_constants: bool,
/// Enable the GetBlockSize gRPC server method
pub enable_get_block_size: bool,
/// Enable the GetBlockFees gRPC server method
pub enable_get_block_fees: bool,
/// Enable the GetVersion gRPC server method
pub enable_get_version: bool,
/// Enable the CheckForUpdates gRPC server method
pub enable_check_for_updates: bool,
/// Enable the GetTokensInCirculation gRPC server method
pub enable_get_tokens_in_circulation: bool,
/// Enable the GetNetworkDifficulty gRPC server method
pub enable_get_network_difficulty: bool,
/// Enable the GetNewBlockTemplate gRPC server method
pub enable_get_new_block_template: bool,
/// Enable the GetNewBlock gRPC server method
pub enable_get_new_block: bool,
/// Enable the GetNewBlockBlob gRPC server method
pub enable_get_new_block_blob: bool,
/// Enable the SubmitBlock gRPC server method
pub enable_submit_block: bool,
/// Enable the SubmitBlockBlob gRPC server method
pub enable_submit_block_blob: bool,
/// Enable the SubmitTransaction gRPC server method
pub enable_submit_transaction: bool,
/// Enable the GetSyncInfo gRPC server method
pub enable_get_sync_info: bool,
/// Enable the GetSyncProgress gRPC server method
pub enable_get_sync_progress: bool,
/// Enable the GetTipInfo gRPC server method
pub enable_get_tip_info: bool,
/// Enable the SearchKernels gRPC server method
pub enable_search_kernels: bool,
/// Enable the SearchUtxos gRPC server method
pub enable_search_utxos: bool,
/// Enable the FetchMatchingUtxos gRPC server method
pub enable_fetch_matching_utxos: bool,
/// Enable the GetPeers gRPC server method
pub enable_get_peers: bool,
/// Enable the GetMempoolTransactions gRPC server method
pub enable_get_mempool_transactions: bool,
/// Enable the TransactionState gRPC server method
pub enable_transaction_state: bool,
/// Enable the Identify gRPC server method
pub enable_identify: bool,
/// Enable the GetNetworkStatus gRPC server method
pub enable_get_network_status: bool,
/// Enable the ListConnectedPeers gRPC server method
pub enable_list_connected_peers: bool,
/// Enable the GetMempoolState gRPC server method
pub enable_get_mempool_stats: bool,
/// Enable the GetActiveValidatorNodes gRPC server method
pub enable_get_active_validator_nodes: bool,
/// Enable the GetShardKey gRPC server method
pub enable_get_shard_key: bool,
/// Enable the GetTemplateRegistrations gRPC server method
pub enable_get_template_registrations: bool,
/// Enable the GetSideChainUtxos gRPC server method
pub enable_get_side_chain_utxos: bool,
}
Loading

0 comments on commit 3e0c548

Please sign in to comment.