From 6c866195900eff02f1489df831fd16a12444d8d8 Mon Sep 17 00:00:00 2001 From: Emil Lai <39825288+EmilLa1@users.noreply.github.com> Date: Mon, 10 Oct 2022 09:54:48 +0200 Subject: [PATCH] Grpc2 endpoint enabling (#542) * Fix missing definitions in the lib.def --- concordium-consensus/lib.def | 4 +- concordium-node/src/grpc2.rs | 324 ++++++++++++++++++++++++++++++++++- docs/grpc2.md | 50 +++++- 3 files changed, 368 insertions(+), 10 deletions(-) diff --git a/concordium-consensus/lib.def b/concordium-consensus/lib.def index 2b26896be6..f1f57aa850 100644 --- a/concordium-consensus/lib.def +++ b/concordium-consensus/lib.def @@ -78,4 +78,6 @@ EXPORTS getBlockPendingUpdatesV2 getNextUpdateSequenceNumbersV2 getBlockChainParametersV2 - getBlockFinalizationSummaryV2 \ No newline at end of file + getBlockFinalizationSummaryV2 + getBlockItemsV2 + getLastFinalizedBlockSlotTimeV2 \ No newline at end of file diff --git a/concordium-node/src/grpc2.rs b/concordium-node/src/grpc2.rs index 2f72fc5ab5..9a4bcc3cbd 100644 --- a/concordium-node/src/grpc2.rs +++ b/concordium-node/src/grpc2.rs @@ -521,25 +521,163 @@ pub mod service { /// Service configuration, listing which endpoints are enabled. /// If the endpoint is not listed in the configuration file it will be disabled. /// This is what the `#[serde(default)]` annotations achieve. -#[derive(serde::Deserialize)] +#[derive(Debug, serde::Deserialize)] struct ServiceConfig { #[serde(default)] get_finalized_blocks: bool, #[serde(default)] - get_blocks: bool, + get_blocks: bool, #[serde(default)] - get_account_list: bool, + get_account_list: bool, #[serde(default)] - get_account_info: bool, + get_account_info: bool, + #[serde(default)] + get_module_list: bool, + #[serde(default)] + get_module_source: bool, + #[serde(default)] + get_instance_list: bool, + #[serde(default)] + get_instance_info: bool, + #[serde(default)] + get_instance_state: bool, + #[serde(default)] + instance_state_lookup: bool, + #[serde(default)] + get_next_account_sequence_number: bool, + #[serde(default)] + get_consensus_info: bool, + #[serde(default)] + get_ancestors: bool, + #[serde(default)] + get_block_item_status: bool, + #[serde(default)] + invoke_instance: bool, + #[serde(default)] + get_cryptographic_parameters: bool, + #[serde(default)] + get_block_info: bool, + #[serde(default)] + get_baker_list: bool, + #[serde(default)] + get_pool_info: bool, + #[serde(default)] + get_passive_delegation_info: bool, + #[serde(default)] + get_blocks_at_height: bool, + #[serde(default)] + get_tokenomics_info: bool, + #[serde(default)] + get_pool_delegators: bool, + #[serde(default)] + get_pool_delegators_reward_period: bool, + #[serde(default)] + get_passive_delegators: bool, + #[serde(default)] + get_passive_delegators_reward_period: bool, + #[serde(default)] + get_branches: bool, + #[serde(default)] + get_election_info: bool, + #[serde(default)] + get_identity_providers: bool, + #[serde(default)] + get_anonymity_revokers: bool, + #[serde(default)] + get_account_non_finalized_transactions: bool, + #[serde(default)] + get_block_transaction_events: bool, + #[serde(default)] + get_block_special_events: bool, + #[serde(default)] + get_block_pending_updates: bool, + #[serde(default)] + get_next_update_sequence_numbers: bool, + #[serde(default)] + get_block_chain_parameters: bool, + #[serde(default)] + get_block_finalization_summary: bool, + #[serde(default)] + shutdown: bool, + #[serde(default)] + peer_connect: bool, + #[serde(default)] + peer_disconnect: bool, + #[serde(default)] + get_banned_peers: bool, + #[serde(default)] + ban_peer: bool, + #[serde(default)] + unban_peer: bool, + #[serde(default)] + dump_start: bool, + #[serde(default)] + dump_stop: bool, + #[serde(default)] + get_peers_info: bool, + #[serde(default)] + get_node_info: bool, + #[serde(default)] + send_block_item: bool, + #[serde(default)] + get_account_transaction_sign_hash: bool, + #[serde(default)] + get_block_items: bool, } impl ServiceConfig { pub const fn new_all_enabled() -> Self { Self { get_finalized_blocks: true, - get_blocks: true, - get_account_list: true, - get_account_info: true, + get_blocks: true, + get_account_list: true, + get_account_info: true, + get_module_list: true, + get_module_source: true, + get_instance_list: true, + get_instance_info: true, + get_instance_state: true, + instance_state_lookup: true, + get_next_account_sequence_number: true, + get_consensus_info: true, + get_ancestors: true, + get_block_item_status: true, + invoke_instance: true, + get_cryptographic_parameters: true, + get_block_info: true, + get_baker_list: true, + get_pool_info: true, + get_passive_delegation_info: true, + get_blocks_at_height: true, + get_tokenomics_info: true, + get_pool_delegators: true, + get_pool_delegators_reward_period: true, + get_passive_delegators: true, + get_passive_delegators_reward_period: true, + get_branches: true, + get_election_info: true, + get_identity_providers: true, + get_anonymity_revokers: true, + get_account_non_finalized_transactions: true, + get_block_transaction_events: true, + get_block_special_events: true, + get_block_pending_updates: true, + get_next_update_sequence_numbers: true, + get_block_chain_parameters: true, + get_block_finalization_summary: true, + shutdown: true, + peer_connect: true, + peer_disconnect: true, + get_banned_peers: true, + ban_peer: true, + unban_peer: true, + dump_start: true, + dump_stop: true, + get_peers_info: true, + get_node_info: true, + send_block_item: true, + get_account_transaction_sign_hash: true, + get_block_items: true, } } @@ -711,6 +849,7 @@ pub mod server { } else { ServiceConfig::new_all_enabled() }; + debug!("GRPC endpoints enabled: {:#?}", service_config); let identity = match (&config.x509_cert, &config.cert_private_key) { (None, None) => None, @@ -1021,7 +1160,9 @@ pub mod server { &self, request: tonic::Request, ) -> Result, tonic::Status> { - // TODO: Configuration. + if !self.service_config.get_module_list { + return Err(tonic::Status::unimplemented("`GetModuleList` is not enabled.")); + } let (sender, receiver) = futures::channel::mpsc::channel(100); let hash = self.consensus.get_module_list_v2(request.get_ref(), sender)?; let mut response = tonic::Response::new(receiver); @@ -1033,6 +1174,9 @@ pub mod server { &self, request: tonic::Request, ) -> Result>, tonic::Status> { + if !self.service_config.get_module_source { + return Err(tonic::Status::unimplemented("`GetModuleSource` is not enabled.")); + } let request = request.get_ref(); let block_hash = request.block_hash.as_ref().require()?; let module_ref = request.module_ref.as_ref().require()?; @@ -1046,6 +1190,9 @@ pub mod server { &self, request: tonic::Request, ) -> Result, tonic::Status> { + if !self.service_config.get_instance_list { + return Err(tonic::Status::unimplemented("`GetInstanceList` is not enabled.")); + } let (sender, receiver) = futures::channel::mpsc::channel(100); let hash = self.consensus.get_instance_list_v2(request.get_ref(), sender)?; let mut response = tonic::Response::new(receiver); @@ -1057,6 +1204,9 @@ pub mod server { &self, request: tonic::Request, ) -> Result>, tonic::Status> { + if !self.service_config.get_instance_info { + return Err(tonic::Status::unimplemented("`GetInstanceInfo` is not enabled.")); + } let request = request.get_ref(); let block_hash = request.block_hash.as_ref().require()?; let contract_address = request.address.as_ref().require()?; @@ -1071,6 +1221,9 @@ pub mod server { &self, request: tonic::Request, ) -> Result, tonic::Status> { + if !self.service_config.get_instance_state { + return Err(tonic::Status::unimplemented("`GetInstanceState` is not enabled.")); + } let request = request.get_ref(); let block_hash = request.block_hash.as_ref().require()?; let contract_address = request.address.as_ref().require()?; @@ -1133,6 +1286,9 @@ pub mod server { &self, request: tonic::Request, ) -> Result, tonic::Status> { + if !self.service_config.instance_state_lookup { + return Err(tonic::Status::unimplemented("`InstanceStateLookup` is not enabled.")); + } let request = request.get_ref(); let block_hash = request.block_hash.as_ref().require()?; let contract_address = request.address.as_ref().require()?; @@ -1172,6 +1328,11 @@ pub mod server { &self, request: tonic::Request, ) -> Result>, tonic::Status> { + if !self.service_config.get_next_account_sequence_number { + return Err(tonic::Status::unimplemented( + "`GetNextAccountSequenceNumber` is not enabled.", + )); + } let response = self.consensus.get_next_account_sequence_number_v2(request.get_ref())?; Ok(tonic::Response::new(response)) } @@ -1180,6 +1341,9 @@ pub mod server { &self, _request: tonic::Request, ) -> Result>, tonic::Status> { + if !self.service_config.get_consensus_info { + return Err(tonic::Status::unimplemented("`GetConsensusInfo` is not enabled.")); + } let response = self.consensus.get_consensus_info_v2()?; Ok(tonic::Response::new(response)) } @@ -1188,6 +1352,9 @@ pub mod server { &self, request: tonic::Request, ) -> Result, tonic::Status> { + if !self.service_config.get_ancestors { + return Err(tonic::Status::unimplemented("`GetAncestors` is not enabled.")); + } let (sender, receiver) = futures::channel::mpsc::channel(100); let request = request.get_ref(); let block_hash = request.block_hash.as_ref().require()?; @@ -1202,6 +1369,9 @@ pub mod server { &self, request: tonic::Request, ) -> Result>, tonic::Status> { + if !self.service_config.get_block_item_status { + return Err(tonic::Status::unimplemented("`GetBlockItemStatus` is not enabled.")); + } let response = self.consensus.get_block_item_status_v2(request.get_ref())?; Ok(tonic::Response::new(response)) } @@ -1210,6 +1380,9 @@ pub mod server { &self, request: tonic::Request, ) -> Result>, tonic::Status> { + if !self.service_config.invoke_instance { + return Err(tonic::Status::unimplemented("`InvokeInstance` is not enabled.")); + } if request .get_ref() .energy @@ -1233,6 +1406,11 @@ pub mod server { request: tonic::Request, ) -> Result, tonic::Status> { + if !self.service_config.get_cryptographic_parameters { + return Err(tonic::Status::unimplemented( + "`GetCryptographicParameters` is not enabled.", + )); + } let (hash, response) = self.consensus.get_cryptographic_parameters_v2(request.get_ref())?; let mut response = tonic::Response::new(response); @@ -1244,6 +1422,9 @@ pub mod server { &self, request: tonic::Request, ) -> Result>, tonic::Status> { + if !self.service_config.get_block_info { + return Err(tonic::Status::unimplemented("`GetBlockInfo` is not enabled.")); + } let (hash, response) = self.consensus.get_block_info_v2(request.get_ref())?; let mut response = tonic::Response::new(response); add_hash(&mut response, hash)?; @@ -1254,6 +1435,9 @@ pub mod server { &self, request: tonic::Request, ) -> Result, tonic::Status> { + if !self.service_config.get_baker_list { + return Err(tonic::Status::unimplemented("`GetBakerList` is not enabled.")); + } let (sender, receiver) = futures::channel::mpsc::channel(100); let hash = self.consensus.get_baker_list_v2(request.get_ref(), sender)?; let mut response = tonic::Response::new(receiver); @@ -1265,6 +1449,9 @@ pub mod server { &self, request: tonic::Request, ) -> Result>, tonic::Status> { + if !self.service_config.get_pool_info { + return Err(tonic::Status::unimplemented("`GetPoolInfo` is not enabled.")); + } let (hash, response) = self.consensus.get_pool_info_v2(request.get_ref())?; let mut response = tonic::Response::new(response); add_hash(&mut response, hash)?; @@ -1275,6 +1462,11 @@ pub mod server { &self, request: tonic::Request, ) -> Result>, tonic::Status> { + if !self.service_config.get_passive_delegation_info { + return Err(tonic::Status::unimplemented( + "`GetPassiveDelegationInfo` is not enabled.", + )); + } let (hash, response) = self.consensus.get_passive_delegation_info_v2(request.get_ref())?; let mut response = tonic::Response::new(response); @@ -1286,6 +1478,9 @@ pub mod server { &self, request: tonic::Request, ) -> Result>, tonic::Status> { + if !self.service_config.get_blocks_at_height { + return Err(tonic::Status::unimplemented("`GetBlocksAtHeight` is not enabled.")); + } let data = self.consensus.get_blocks_at_height_v2(request.get_ref())?; let response = tonic::Response::new(data); Ok(response) @@ -1295,6 +1490,9 @@ pub mod server { &self, request: tonic::Request, ) -> Result>, tonic::Status> { + if !self.service_config.get_tokenomics_info { + return Err(tonic::Status::unimplemented("`GetTokenomicsInfo` is not enabled.")); + } let (hash, response) = self.consensus.get_tokenomics_info_v2(request.get_ref())?; let mut response = tonic::Response::new(response); add_hash(&mut response, hash)?; @@ -1305,6 +1503,9 @@ pub mod server { &self, request: tonic::Request, ) -> Result, tonic::Status> { + if !self.service_config.get_pool_delegators { + return Err(tonic::Status::unimplemented("`GetPoolDelegators` is not enabled.")); + } let (sender, receiver) = futures::channel::mpsc::channel(100); let hash = self.consensus.get_pool_delegators_v2(request.get_ref(), sender)?; let mut response = tonic::Response::new(receiver); @@ -1317,6 +1518,11 @@ pub mod server { request: tonic::Request, ) -> Result, tonic::Status> { + if !self.service_config.get_pool_delegators_reward_period { + return Err(tonic::Status::unimplemented( + "`GetPoolDelegatorsRewardPeriod` is not enabled.", + )); + } let (sender, receiver) = futures::channel::mpsc::channel(100); let hash = self.consensus.get_pool_delegators_reward_period_v2(request.get_ref(), sender)?; @@ -1329,6 +1535,9 @@ pub mod server { &self, request: tonic::Request, ) -> Result, tonic::Status> { + if !self.service_config.get_passive_delegators { + return Err(tonic::Status::unimplemented("`GetPassiveDelegators` is not enabled.")); + } let (sender, receiver) = futures::channel::mpsc::channel(100); let hash = self.consensus.get_passive_delegators_v2(request.get_ref(), sender)?; let mut response = tonic::Response::new(receiver); @@ -1341,6 +1550,11 @@ pub mod server { request: tonic::Request, ) -> Result, tonic::Status> { + if !self.service_config.get_passive_delegators_reward_period { + return Err(tonic::Status::unimplemented( + "`GetPassiveDelegatorsRewardPeriod` is not enabled.", + )); + } let (sender, receiver) = futures::channel::mpsc::channel(100); let hash = self .consensus @@ -1354,6 +1568,9 @@ pub mod server { &self, _request: tonic::Request, ) -> Result>, tonic::Status> { + if !self.service_config.get_branches { + return Err(tonic::Status::unimplemented("`GetBranches` is not enabled.")); + } Ok(tonic::Response::new(self.consensus.get_branches_v2()?)) } @@ -1361,6 +1578,9 @@ pub mod server { &self, request: tonic::Request, ) -> Result>, tonic::Status> { + if !self.service_config.get_election_info { + return Err(tonic::Status::unimplemented("`GetElectionInfo` is not enabled.")); + } let (hash, response) = self.consensus.get_election_info_v2(request.get_ref())?; let mut response = tonic::Response::new(response); add_hash(&mut response, hash)?; @@ -1371,6 +1591,9 @@ pub mod server { &self, request: tonic::Request, ) -> Result, tonic::Status> { + if !self.service_config.get_identity_providers { + return Err(tonic::Status::unimplemented("`GetIdentityProviders` is not enabled.")); + } let (sender, receiver) = futures::channel::mpsc::channel(10); let hash = self.consensus.get_identity_providers_v2(request.get_ref(), sender)?; let mut response = tonic::Response::new(receiver); @@ -1382,6 +1605,9 @@ pub mod server { &self, request: tonic::Request, ) -> Result, tonic::Status> { + if !self.service_config.get_anonymity_revokers { + return Err(tonic::Status::unimplemented("`GetAnonymityRevokers` is not enabled.")); + } let (sender, receiver) = futures::channel::mpsc::channel(10); let hash = self.consensus.get_anonymity_revokers_v2(request.get_ref(), sender)?; let mut response = tonic::Response::new(receiver); @@ -1394,6 +1620,11 @@ pub mod server { request: tonic::Request, ) -> Result, tonic::Status> { + if !self.service_config.get_account_non_finalized_transactions { + return Err(tonic::Status::unimplemented( + "`GetAccountNonFinalizedTransactions` is not enabled.", + )); + } let (sender, receiver) = futures::channel::mpsc::channel(10); self.consensus.get_account_non_finalized_transactions_v2(request.get_ref(), sender)?; let response = tonic::Response::new(receiver); @@ -1404,6 +1635,11 @@ pub mod server { &self, request: tonic::Request, ) -> Result, tonic::Status> { + if !self.service_config.get_block_transaction_events { + return Err(tonic::Status::unimplemented( + "`GetBlockTransactionEvents` is not enabled.", + )); + } let (sender, receiver) = futures::channel::mpsc::channel(10); let hash = self.consensus.get_block_transaction_events_v2(request.get_ref(), sender)?; let mut response = tonic::Response::new(receiver); @@ -1415,6 +1651,11 @@ pub mod server { &self, request: tonic::Request, ) -> Result, tonic::Status> { + if !self.service_config.get_block_special_events { + return Err(tonic::Status::unimplemented( + "`GetBlockSpecialEvents` is not enabled.", + )); + } let (sender, receiver) = futures::channel::mpsc::channel(10); let hash = self.consensus.get_block_special_events_v2(request.get_ref(), sender)?; let mut response = tonic::Response::new(receiver); @@ -1426,6 +1667,11 @@ pub mod server { &self, request: tonic::Request, ) -> Result, tonic::Status> { + if !self.service_config.get_block_pending_updates { + return Err(tonic::Status::unimplemented( + "`GetBlockPendingUpdates` is not enabled.", + )); + } let (sender, receiver) = futures::channel::mpsc::channel(10); let hash = self.consensus.get_block_pending_updates_v2(request.get_ref(), sender)?; let mut response = tonic::Response::new(receiver); @@ -1437,6 +1683,11 @@ pub mod server { &self, request: tonic::Request, ) -> Result>, tonic::Status> { + if !self.service_config.get_next_update_sequence_numbers { + return Err(tonic::Status::unimplemented( + "`GetNextUpdateSequenceNumber` is not enabled.", + )); + } let (hash, response) = self.consensus.get_next_update_sequence_numbers_v2(request.get_ref())?; let mut response = tonic::Response::new(response); @@ -1448,6 +1699,11 @@ pub mod server { &self, request: tonic::Request, ) -> Result>, tonic::Status> { + if !self.service_config.get_block_chain_parameters { + return Err(tonic::Status::unimplemented( + "`GetBlockChainParameters` is not enabled.", + )); + } let (hash, response) = self.consensus.get_block_chain_parameters_v2(request.get_ref())?; let mut response = tonic::Response::new(response); @@ -1459,6 +1715,11 @@ pub mod server { &self, request: tonic::Request, ) -> Result>, tonic::Status> { + if !self.service_config.get_block_finalization_summary { + return Err(tonic::Status::unimplemented( + "`GetBlockFinalizationSummary` is not enabled.", + )); + } let (hash, response) = self.consensus.get_block_finalization_summary_v2(request.get_ref())?; let mut response = tonic::Response::new(response); @@ -1470,6 +1731,9 @@ pub mod server { &self, _request: tonic::Request, ) -> Result, tonic::Status> { + if !self.service_config.shutdown { + return Err(tonic::Status::unimplemented("`Shutdown` is not enabled.")); + } match self.node.close() { Ok(_) => Ok(tonic::Response::new(crate::grpc2::types::Empty {})), Err(e) => Err(tonic::Status::internal(format!("Unable to shutdown server {}.", e))), @@ -1480,6 +1744,9 @@ pub mod server { &self, request: tonic::Request, ) -> Result, tonic::Status> { + if !self.service_config.peer_connect { + return Err(tonic::Status::unimplemented("`PeerConnect` is not enabled.")); + } if self.node.is_network_stopped() { Err(tonic::Status::failed_precondition( "The network is stopped due to unrecognized protocol update.", @@ -1504,6 +1771,9 @@ pub mod server { &self, request: tonic::Request, ) -> Result, tonic::Status> { + if !self.service_config.peer_disconnect { + return Err(tonic::Status::unimplemented("`PeerDisconnect` is not enabled.")); + } if self.node.is_network_stopped() { Err(tonic::Status::failed_precondition( "The network is stopped due to unrecognized protocol update.", @@ -1527,6 +1797,9 @@ pub mod server { &self, _request: tonic::Request, ) -> Result, tonic::Status> { + if !self.service_config.get_banned_peers { + return Err(tonic::Status::unimplemented("`GetBannedPeers` is not enabled.")); + } if let Ok(banned_peers) = self.node.get_banlist() { let peers = banned_peers .into_iter() @@ -1553,6 +1826,9 @@ pub mod server { &self, request: tonic::Request, ) -> Result, tonic::Status> { + if !self.service_config.ban_peer { + return Err(tonic::Status::unimplemented("`BanPeer` is not enabled.")); + } let ip = request.into_inner().ip_address.require()?; match ip.value.parse::() { Ok(ip_addr) => match self.node.drop_by_ip_and_ban(ip_addr) { @@ -1570,6 +1846,9 @@ pub mod server { &self, request: tonic::Request, ) -> Result, tonic::Status> { + if !self.service_config.unban_peer { + return Err(tonic::Status::unimplemented("`UnbanPeer` is not enabled.")); + } match request.into_inner().ip_address.require()?.value.parse::() { Ok(ip_addr) => { let banned_id = crate::p2p::bans::PersistedBanId::Ip(ip_addr); @@ -1591,6 +1870,9 @@ pub mod server { &self, request: tonic::Request, ) -> Result, tonic::Status> { + if !self.service_config.dump_start { + return Err(tonic::Status::unimplemented("`DumpStart` is not enabled.")); + } let file_path = request.get_ref().file.to_owned(); if file_path.is_empty() { Err(tonic::Status::invalid_argument("The supplied path must be non-empty")) @@ -1609,6 +1891,9 @@ pub mod server { &self, _request: tonic::Request, ) -> Result, tonic::Status> { + if !self.service_config.dump_start { + return Err(tonic::Status::unimplemented("`DumpStart` is not enabled.")); + } Err(tonic::Status::failed_precondition("Feature \"network_dump\" is not active.")) } @@ -1617,6 +1902,9 @@ pub mod server { &self, _request: tonic::Request, ) -> Result, tonic::Status> { + if !self.service_config.dump_stop { + return Err(tonic::Status::unimplemented("`DumpStop` is not enabled.")); + } match self.node.stop_dump() { Ok(_) => Ok(tonic::Response::new(crate::grpc2::types::Empty {})), Err(e) => { @@ -1630,6 +1918,9 @@ pub mod server { &self, _request: tonic::Request, ) -> Result, tonic::Status> { + if !self.service_config.dump_stop { + return Err(tonic::Status::unimplemented("`DumpStop` is not enabled.")); + } Err(tonic::Status::failed_precondition("Feature \"network_dump\" is not active.")) } @@ -1637,6 +1928,9 @@ pub mod server { &self, _request: tonic::Request, ) -> Result, tonic::Status> { + if !self.service_config.get_peers_info { + return Err(tonic::Status::unimplemented("`GetPeersInfo` is not enabled.")); + } // we do a clone so we can release the lock quickly. let peer_statuses = (*crate::read_or_die!(self.node.peers)).peer_states.clone(); let peers = self @@ -1705,6 +1999,9 @@ pub mod server { &self, _request: tonic::Request, ) -> Result, tonic::Status> { + if !self.service_config.get_node_info { + return Err(tonic::Status::unimplemented("`GetNodeInfo` is not enabled.")); + } let peer_version = self.node.get_version(); let local_time = Some(types::Timestamp { value: std::time::SystemTime::now() @@ -1831,6 +2128,9 @@ pub mod server { request: tonic::Request, ) -> Result, tonic::Status> { use ConsensusFfiResponse::*; + if !self.service_config.send_block_item { + return Err(tonic::Status::unimplemented("`SendBlockItem` is not enabled.")); + } if self.node.is_network_stopped() { return Err(tonic::Status::failed_precondition( @@ -1913,6 +2213,11 @@ pub mod server { request: tonic::Request, ) -> Result, tonic::Status> { + if !self.service_config.get_account_transaction_sign_hash { + return Err(tonic::Status::unimplemented( + "`GetAccountTransactionSignHash` is not enabled.", + )); + } let request = request.into_inner(); let (header, payload) = request.try_into()?; let sign_hash = @@ -1926,6 +2231,9 @@ pub mod server { &self, request: tonic::Request, ) -> Result, tonic::Status> { + if !self.service_config.get_block_items { + return Err(tonic::Status::unimplemented("`GetBlockItems` is not enabled.")); + } let (sender, receiver) = futures::channel::mpsc::channel(100); let hash = self.consensus.get_block_items_v2(request.get_ref(), sender)?; let mut response = tonic::Response::new(receiver); diff --git a/docs/grpc2.md b/docs/grpc2.md index caa7817ebf..fc3345ddf5 100644 --- a/docs/grpc2.md +++ b/docs/grpc2.md @@ -41,11 +41,59 @@ If these are enabled then the following options become available available. The format of the file is a simple key-value list, with values being booleans. - Keys are names of endpoints in snake_case. For example + Keys are names of endpoints in snake_case. For example the following configuration file + would enable all available endpoints except the ones flagged with `false` i.e. `get_account_info`, + `shutdown`, `dump_start` and `dump_end`. ```toml get_finalized_blocks = true get_blocks = true get_account_list = true get_account_info = false + get_module_list = true + get_module_source = true + get_instance_list = true + get_instance_info = true + get_instance_state = true + instance_state_lookup = true + get_next_account_sequence_number = true + get_consensus_info = true + get_ancestors = true + get_block_item_status = true + invoke_instance = true + get_cryptographic_parameters = true + get_block_info = true + get_baker_list = true + get_pool_info = true + get_passive_delegation_info = true + get_blocks_at_height = true + get_tokenomics_info = true + get_pool_delegators = true + get_pool_delegators_reward_period = true + get_passive_delegators = true + get_passive_delegators_reward_period = true + get_branches = true + get_election_info = true + get_identity_providers = true + get_anonymity_revokers = true + get_account_non_finalized_transactions = true + get_block_transaction_events = true + get_block_special_events = true + get_block_pending_updates = true + get_next_update_sequence_numbers = true + get_block_chain_parameters = true + get_block_finalization_summary = true + shutdown = false + peer_connect = true + peer_disconnect = true + get_banned_peers = true + ban_peer = true + unban_peer = true + dump_start = false + dump_stop = false + get_peers_info = true + get_node_info = true + send_block_item = true + get_account_transaction_sign_hash = true + get_block_items = true ```