diff --git a/openapi.yaml b/openapi.yaml index 10ac6bfdf61..e7793967118 100644 --- a/openapi.yaml +++ b/openapi.yaml @@ -28,7 +28,7 @@ paths: default: getinfo id: type: string - default: VuJXrxLSw8 + default: QWlDS9bxlK params: type: array items: {} @@ -61,7 +61,7 @@ paths: default: getblockchaininfo id: type: string - default: HDVqYXM9m6 + default: XSg3wvZykA params: type: array items: {} @@ -99,7 +99,7 @@ paths: default: getaddressbalance id: type: string - default: Xw5TDBKXGl + default: GEd1QJWprH params: type: array items: {} @@ -147,7 +147,7 @@ paths: default: sendrawtransaction id: type: string - default: QaJv2bXyZu + default: nhQi7D6Oru params: type: array items: {} @@ -196,7 +196,7 @@ paths: default: getblock id: type: string - default: k0DACJrgZs + default: qIEYMzgbJZ params: type: array items: {} @@ -239,7 +239,7 @@ paths: default: getbestblockhash id: type: string - default: rIFaLhZwHF + default: P9UBS8IXXU params: type: array items: {} @@ -272,7 +272,7 @@ paths: default: getbestblockheightandhash id: type: string - default: oxrhh1swvh + default: gQNhsomx7N params: type: array items: {} @@ -305,7 +305,7 @@ paths: default: getrawmempool id: type: string - default: E7oUD34jk2 + default: c2ScL31PtX params: type: array items: {} @@ -343,7 +343,7 @@ paths: default: z_gettreestate id: type: string - default: Hp22XK728i + default: JQ0mENKbdm params: type: array items: {} @@ -393,7 +393,7 @@ paths: default: z_getsubtreesbyindex id: type: string - default: Cs69hg68pl + default: bZUCv4t0f4 params: type: array items: {} @@ -432,7 +432,7 @@ paths: default: getrawtransaction id: type: string - default: iu395PEErc + default: I0FAejAi4r params: type: array items: {} @@ -480,7 +480,7 @@ paths: default: getaddresstxids id: type: string - default: z3lOKfsQdp + default: '3fMzDHOglf' params: type: array items: {} @@ -528,7 +528,7 @@ paths: default: getaddressutxos id: type: string - default: '7U4Q4dSxej' + default: LE2AR8Tr6X params: type: array items: {} @@ -554,6 +554,39 @@ paths: error: type: string default: Invalid parameters + /stop: + post: + tags: + - control + description: Stop the running zebrad process. + requestBody: + required: true + content: + application/json: + schema: + type: object + properties: + method: + type: string + default: stop + id: + type: string + default: PbxxqB0ZpF + params: + type: array + items: {} + default: '[]' + responses: + '200': + description: OK + content: + application/json: + schema: + type: object + properties: + result: + type: object + default: 'null' /getblockcount: post: tags: @@ -571,7 +604,7 @@ paths: default: getblockcount id: type: string - default: '8yw3EX7Cwi' + default: WO6BAIKSCg params: type: array items: {} @@ -609,7 +642,7 @@ paths: default: getblockhash id: type: string - default: ndDYksCl9E + default: vHpKNIQRLF params: type: array items: {} @@ -657,7 +690,7 @@ paths: default: getblocktemplate id: type: string - default: lJi2hfxty1 + default: L04jp5F2QW params: type: array items: {} @@ -695,7 +728,7 @@ paths: default: submitblock id: type: string - default: '9fEFOdTQle' + default: Izn7vhiMaA params: type: array items: {} @@ -728,7 +761,7 @@ paths: default: getmininginfo id: type: string - default: Dytpq4f3lF + default: SgyuBQbMik params: type: array items: {} @@ -761,7 +794,7 @@ paths: default: getnetworksolps id: type: string - default: yX3woRnOaN + default: FXg2iH3eaX params: type: array items: {} @@ -794,7 +827,7 @@ paths: default: getnetworkhashps id: type: string - default: AyAZMtbezv + default: '2PWjf8QqfI' params: type: array items: {} @@ -827,7 +860,7 @@ paths: default: getpeerinfo id: type: string - default: nNcrsu3ZAR + default: OE9s5wkP0w params: type: array items: {} @@ -865,7 +898,7 @@ paths: default: validateaddress id: type: string - default: LGyfO7zTjW + default: '6FS4iGA4Ht' params: type: array items: {} @@ -903,7 +936,7 @@ paths: default: z_validateaddress id: type: string - default: '2Q09a2Nh4N' + default: utp8tN61yU params: type: array items: {} @@ -941,7 +974,7 @@ paths: default: getblocksubsidy id: type: string - default: nv6lOWCRso + default: dgNZGo7lNa params: type: array items: {} @@ -984,7 +1017,7 @@ paths: default: getdifficulty id: type: string - default: '2O3A0PF1SS' + default: KEJv30D2MI params: type: array items: {} @@ -1022,7 +1055,7 @@ paths: default: z_listunifiedreceivers id: type: string - default: XYgGcDIx2X + default: lfBqvYghGm params: type: array items: {} diff --git a/zebra-rpc/src/methods.rs b/zebra-rpc/src/methods.rs index 471d542922c..cb894182c1f 100644 --- a/zebra-rpc/src/methods.rs +++ b/zebra-rpc/src/methods.rs @@ -301,6 +301,18 @@ pub trait Rpc { &self, address_strings: AddressStrings, ) -> BoxFuture>>; + + #[rpc(name = "stop")] + /// Stop the running zebrad process. + /// + /// # Notes + /// + /// Only works if the network of the running zebrad process is `Regtest`. + /// + /// zcashd reference: [`stop`](https://zcash.github.io/rpc/stop.html) + /// method: post + /// tags: control + fn stop(&self) -> Result<()>; } /// RPC method implementations. @@ -1344,6 +1356,19 @@ where } .boxed() } + + fn stop(&self) -> Result<()> { + if self.network.is_regtest() { + // TODO: Use graceful termination in `stop` RPC (#8850) + std::process::exit(0); + } else { + Err(Error { + code: ErrorCode::MethodNotFound, + message: "stop is only available on regtest networks".to_string(), + data: None, + }) + } + } } /// Returns the best chain tip height of `latest_chain_tip`, diff --git a/zebra-state/src/service/finalized_state/zebra_db/block.rs b/zebra-state/src/service/finalized_state/zebra_db/block.rs index e10fd3b43b4..4dc3a801ef3 100644 --- a/zebra-state/src/service/finalized_state/zebra_db/block.rs +++ b/zebra-state/src/service/finalized_state/zebra_db/block.rs @@ -290,6 +290,7 @@ impl ZebraDb { /// /// - Propagates any errors from writing to the DB /// - Propagates any errors from updating history and note commitment trees + #[allow(clippy::unwrap_in_result)] pub(in super::super) fn write_block( &mut self, finalized: FinalizedBlock, diff --git a/zebra-utils/src/bin/openapi-generator/main.rs b/zebra-utils/src/bin/openapi-generator/main.rs index fd0e9fe9b2b..15e5446d855 100644 --- a/zebra-utils/src/bin/openapi-generator/main.rs +++ b/zebra-utils/src/bin/openapi-generator/main.rs @@ -543,6 +543,7 @@ fn get_default_properties(method_name: &str) -> Result default_property(type_, items.clone(), GetInfo::default())?, + "stop" => default_property(type_, items.clone(), ())?, // transaction "sendrawtransaction" => { default_property(type_, items.clone(), SentTransactionHash::default())? diff --git a/zebrad/src/components/mempool/downloads.rs b/zebrad/src/components/mempool/downloads.rs index b37f988dcc8..eeda6bd9567 100644 --- a/zebrad/src/components/mempool/downloads.rs +++ b/zebrad/src/components/mempool/downloads.rs @@ -240,6 +240,7 @@ where /// /// Returns the action taken in response to the queue request. #[instrument(skip(self, gossiped_tx), fields(txid = %gossiped_tx.id()))] + #[allow(clippy::unwrap_in_result)] pub fn download_if_needed_and_verify( &mut self, gossiped_tx: Gossip, diff --git a/zebrad/tests/common/checkpoints.rs b/zebrad/tests/common/checkpoints.rs index 602525fd926..c1c0ae44716 100644 --- a/zebrad/tests/common/checkpoints.rs +++ b/zebrad/tests/common/checkpoints.rs @@ -136,7 +136,7 @@ pub async fn run(network: Network) -> Result<()> { ?zebra_rpc_address, "waiting for zebrad to open its RPC port...", ); - zebrad.expect_stdout_line_matches(&format!("Opened RPC endpoint at {zebra_rpc_address}"))?; + zebrad.expect_stdout_line_matches(format!("Opened RPC endpoint at {zebra_rpc_address}"))?; tracing::info!( ?network, diff --git a/zebrad/tests/common/get_block_template_rpcs/get_peer_info.rs b/zebrad/tests/common/get_block_template_rpcs/get_peer_info.rs index 4ca0bc797ad..dd30954948c 100644 --- a/zebrad/tests/common/get_block_template_rpcs/get_peer_info.rs +++ b/zebrad/tests/common/get_block_template_rpcs/get_peer_info.rs @@ -34,7 +34,7 @@ pub(crate) async fn run() -> Result<()> { let rpc_address = zebra_rpc_address.expect("getpeerinfo test must have RPC port"); // Wait until port is open. - zebrad.expect_stdout_line_matches(&format!("Opened RPC endpoint at {rpc_address}"))?; + zebrad.expect_stdout_line_matches(format!("Opened RPC endpoint at {rpc_address}"))?; tracing::info!(?rpc_address, "zebrad opened its RPC port",); diff --git a/zebrad/tests/common/get_block_template_rpcs/submit_block.rs b/zebrad/tests/common/get_block_template_rpcs/submit_block.rs index 28f48fb2c14..399efc8d99e 100644 --- a/zebrad/tests/common/get_block_template_rpcs/submit_block.rs +++ b/zebrad/tests/common/get_block_template_rpcs/submit_block.rs @@ -59,7 +59,7 @@ pub(crate) async fn run() -> Result<()> { ?rpc_address, "spawned isolated zebrad with shorter chain, waiting for zebrad to open its RPC port..." ); - zebrad.expect_stdout_line_matches(&format!("Opened RPC endpoint at {rpc_address}"))?; + zebrad.expect_stdout_line_matches(format!("Opened RPC endpoint at {rpc_address}"))?; tracing::info!(?rpc_address, "zebrad opened its RPC port",); diff --git a/zebrad/tests/common/lightwalletd/send_transaction_test.rs b/zebrad/tests/common/lightwalletd/send_transaction_test.rs index f9087771595..bee6cf78356 100644 --- a/zebrad/tests/common/lightwalletd/send_transaction_test.rs +++ b/zebrad/tests/common/lightwalletd/send_transaction_test.rs @@ -118,7 +118,7 @@ pub async fn run() -> Result<()> { ?zebra_rpc_address, "spawned isolated zebrad with shorter chain, waiting for zebrad to open its RPC port..." ); - zebrad.expect_stdout_line_matches(&format!("Opened RPC endpoint at {zebra_rpc_address}"))?; + zebrad.expect_stdout_line_matches(format!("Opened RPC endpoint at {zebra_rpc_address}"))?; tracing::info!( ?zebra_rpc_address,