Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

debug(rpc): witness and build logging #2974

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 23 additions & 10 deletions crates/view/src/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1293,15 +1293,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 @@ -1310,6 +1313,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 @@ -1326,19 +1330,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 @@ -1354,17 +1361,23 @@ impl ViewProtocolService for ViewService {
tonic::Status::failed_precondition("Error retrieving full viewing key")
})?;

let transaction = Some(
transaction_plan
.build(&fvk, witness_data)
.map_err(|_| tonic::Status::failed_precondition("Error building transaction"))?
.authorize(&mut OsRng, &authorization_data)
.map_err(|_| tonic::Status::failed_precondition("Error authorizing transaction"))?
.into(),
);

tracing::debug!("Generating transaction from txp");
// let transaction = Some(
// transaction_plan
// .build(&fvk, witness_data)
// .map_err(|_| tonic::Status::failed_precondition("Error building transaction"))?
// .authorize(&mut OsRng, &authorization_data)
// .map_err(|_| tonic::Status::failed_precondition("Error authorizing transaction"))?
// .into(),
// );
tracing::debug!("Building txp");
let t1 = transaction_plan.build(&fvk, witness_data).map_err(|_| tonic::Status::failed_precondition("Error building transaction"))?;
tracing::debug!("Authorizing txp");
let t2 = t1.authorize(&mut OsRng, &authorization_data).map_err(|_| tonic::Status::failed_precondition("Error authorizing transaction"))?;

tracing::debug!("Returning WitnessAndBuildResponse");
Ok(tonic::Response::new(pb::WitnessAndBuildResponse {
transaction,
transaction: Some(t2.into()),
}))
}

Expand Down
20 changes: 20 additions & 0 deletions deployments/containerfiles/Containerfile-strangelove-penumbra
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Cannot use pclientd built from Penumbra feature branch,\
# due to bullseye/bookworm mismatch.
# FROM ghcr.io/penumbra-zone/penumbra:debug-witness-and-build AS pz

FROM rust:1-bullseye AS pz

RUN apt-get update && apt-get install -y \
build-essential \
pkg-config \
libssl-dev \
clang
COPY . /app
WORKDIR /app
RUN cargo build --release

# Reference the upstream Strangelove container image, which is required
# for interchaintest, due to helper scripts and uid/gid info.
FROM ghcr.io/strangelove-ventures/heighliner/penumbra:v0.59.0 AS sl

COPY --from=pz /app/target/release/pclientd /bin/pclientd
3 changes: 3 additions & 0 deletions justfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
build:
podman build -t harbor.ruin.dev/library/penumbra:debug-witness-and-build -f ./deployments/containerfiles/Containerfile-strangelove-penumbra .
podman push harbor.ruin.dev/library/penumbra:debug-witness-and-build