Skip to content

Commit

Permalink
debug(rpc): witness and build logging
Browse files Browse the repository at this point in the history
Adding some debug logging statements to the witness and build logic,
to aid in tracing a failure encountered during interchaintest
integration. The WitnessAndBuild RPC never returns: pclientd balloons in
memory consumption until oomkilled. Let's isolate where in the
witness-and-build logic it's getting stuck.
  • Loading branch information
conorsch committed Sep 6, 2023
1 parent dbf1bc2 commit 1ac2967
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions crates/view/src/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1295,15 +1295,18 @@ impl ViewProtocolService for ViewService {
Ok(tonic::Response::new(witness_response))
}

#[instrument(skip(self))]
async fn witness_and_build(
&self,
request: tonic::Request<pb::WitnessAndBuildRequest>,
) -> Result<tonic::Response<pb::WitnessAndBuildResponse>, tonic::Status> {
tracing::debug!("Building WitnessAndBuildRequest");
let pb::WitnessAndBuildRequest {
transaction_plan,
authorization_data,
} = request.into_inner();

tracing::debug!("Building TransactionPlan");
let transaction_plan: TransactionPlan = transaction_plan
.ok_or_else(|| tonic::Status::invalid_argument("missing transaction plan"))?
.try_into()
Expand All @@ -1312,6 +1315,7 @@ impl ViewProtocolService for ViewService {

// Get the witness data from the view service only for non-zero amounts of value,
// since dummy spends will have a zero amount.
tracing::debug!("Gathering note commitments");
let note_commitments = transaction_plan
.spend_plans()
.filter(|plan| plan.note.amount() != 0u64.into())
Expand All @@ -1328,19 +1332,22 @@ impl ViewProtocolService for ViewService {
)
.collect();

tracing::debug!("Inspecting authorization data");
let authorization_data: AuthorizationData = authorization_data
.ok_or_else(|| tonic::Status::invalid_argument("missing authorization data"))?
.try_into()
.map_err(|e: anyhow::Error| e.context("could not decode authorization data"))
.map_err(|e| tonic::Status::invalid_argument(format!("{:#}", e)))?;

tracing::debug!("Generating WitnessRequest");
let witness_request = pb::WitnessRequest {
account_group_id: Some(self.account_group_id.into()),
note_commitments,
transaction_plan: Some(transaction_plan.clone().into()),
..Default::default()
};

tracing::debug!("Generating WitnessData");
let witness_data: WitnessData = self
.witness(tonic::Request::new(witness_request))
.await?
Expand All @@ -1356,6 +1363,7 @@ impl ViewProtocolService for ViewService {
tonic::Status::failed_precondition("Error retrieving full viewing key")
})?;

tracing::debug!("Generating transaction from txp");
let transaction = Some(
transaction_plan
.build(&fvk, witness_data)
Expand All @@ -1365,6 +1373,7 @@ impl ViewProtocolService for ViewService {
.into(),
);

tracing::debug!("Returning WitnessAndBuildResponse");
Ok(tonic::Response::new(pb::WitnessAndBuildResponse {
transaction,
}))
Expand Down

0 comments on commit 1ac2967

Please sign in to comment.