Skip to content

Commit

Permalink
feat(advance-runner): log tainted session reason
Browse files Browse the repository at this point in the history
  • Loading branch information
marcelstanley committed Aug 22, 2024
1 parent cf53bfb commit 384f5fe
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 3 deletions.
56 changes: 54 additions & 2 deletions offchain/advance-runner/src/server_manager/facade.rs
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ impl ServerManagerFacade {
) -> Result<Vec<RollupsOutput>> {
tracing::trace!("sending advance-state input to server-manager");

grpc_call!(self, advance_state, {
let response = grpc_call!(self, advance_state, {
let input_metadata = InputMetadata {
msg_sender: Some(Address {
data: (*input_metadata.msg_sender.inner()).into(),
Expand All @@ -197,7 +197,9 @@ impl ServerManagerFacade {
input_metadata: Some(input_metadata),
input_payload: input_payload.clone(),
}
})?;
});

self.handle_advance_state_error(response).await;

tracing::trace!("waiting until the input is processed");

Expand Down Expand Up @@ -271,6 +273,56 @@ impl ServerManagerFacade {
Ok(outputs)
}

/// Handle response to advance-state request
#[tracing::instrument(level = "trace", skip_all)]
async fn handle_advance_state_error(
&mut self,
response: Result<grpc_interfaces::cartesi_machine::Void>,
) {
// Capture server-manager error for advance-state request
// to try to get the reason for a possible tainted session error.
if response.is_err() {
match response.unwrap_err() {
ServerManagerError::MethodCallError {
method: _,
request_id: _,
source,
} => {
// Original error message to be reported by default.
let mut message = source.message().to_string();
// The server-manager signals with code Dataloss when the session has been previously tainted.
if source.code() == tonic::Code::DataLoss {
// Recover the tainted session reason from the session's status.
// If not available, log the original error message.
let status_response = grpc_call!(
self,
get_session_status,
GetSessionStatusRequest {
session_id: self.config.session_id.clone(),
}
);

if status_response.is_err() {
match status_response.unwrap_err() {
ServerManagerError::MethodCallError {
method: _,
request_id: _,
source,
} => {
message = format!("Server manager session was tainted: {} ({})", source.code(), source.message());
}
_ => {}
}
} else {
}
}
tracing::error!(message);
}
_ => {}
}
}
}

/// Send a finish-epoch request to the server-manager
/// Return the epoch claim and the proofs
#[tracing::instrument(level = "trace", skip_all)]
Expand Down
2 changes: 1 addition & 1 deletion offchain/inspect-server/src/inspect.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ async fn handle_inspect(
let endpoint = format!("http://{}", address);
while let Some(request) = inspect_rx.recv().await {
match ServerManagerClient::connect(endpoint.clone()).await {
Err(e) => {
v Err(e) => {
respond(
request.response_tx,
Err(InspectError::FailedToConnect {
Expand Down

0 comments on commit 384f5fe

Please sign in to comment.