diff --git a/.changelog/4386.bugfix.md b/.changelog/4386.bugfix.md new file mode 100644 index 00000000000..5581939c607 --- /dev/null +++ b/.changelog/4386.bugfix.md @@ -0,0 +1,5 @@ +runtime: Propagate panics during transaction/local RPC/policy dispatch + +A panic during transaction/local RPC/policy dispatch signals a serious +problem so it should be propagated and the runtime should crash to force +state reset. diff --git a/runtime/src/dispatcher.rs b/runtime/src/dispatcher.rs index 7c4dd3e305a..b052e011376 100644 --- a/runtime/src/dispatcher.rs +++ b/runtime/src/dispatcher.rs @@ -684,6 +684,10 @@ impl Dispatcher { inputs: TxnBatch, state: TxDispatchState, ) -> Result { + // Make sure to abort the process on panic during transaction processing as that indicates + // a serious problem and should make sure to clean up the process. + let _guard = AbortOnPanic; + debug!(self.logger, "Received transaction batch request"; "state_root" => ?state.header.state_root, "round" => state.header.round + 1, @@ -721,7 +725,8 @@ impl Dispatcher { ) } }) - .await? + .await + .unwrap() // Propagate panics during transaction dispatch. } async fn dispatch_rpc( @@ -841,6 +846,10 @@ impl Dispatcher { ctx: Context, request: Vec, ) -> Result { + // Make sure to abort the process on panic during local RPC processing as that indicates a + // serious problem and should make sure to clean up the process. + let _guard = AbortOnPanic; + debug!(self.logger, "Received local RPC call request"); let req: RpcRequest = cbor::from_slice(&request) @@ -869,7 +878,8 @@ impl Dispatcher { let response = cbor::to_vec(response); Ok(Body::RuntimeLocalRPCCallResponse { response }) }) - .await? + .await + .unwrap() // Propagate panics during local RPC dispatch. } fn handle_km_policy_update( @@ -878,6 +888,10 @@ impl Dispatcher { _ctx: Context, signed_policy_raw: Vec, ) -> Result { + // Make sure to abort the process on panic during policy processing as that indicates a + // serious problem and should make sure to clean up the process. + let _guard = AbortOnPanic; + debug!(self.logger, "Received km policy update request"); rpc_dispatcher.handle_km_policy_update(signed_policy_raw); debug!(self.logger, "KM policy update request complete");