Skip to content

Commit

Permalink
fix: attestation recovery (#408)
Browse files Browse the repository at this point in the history
  • Loading branch information
Theodus authored Oct 23, 2023
1 parent bff919b commit 6df8180
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
5 changes: 2 additions & 3 deletions graph-gateway/src/client_query.rs
Original file line number Diff line number Diff line change
Expand Up @@ -873,18 +873,17 @@ async fn handle_indexer_query_inner(
}

if let Some(attestation) = &response.payload.attestation {
let indexer = selection.indexing.indexer;
let verified = attestation::verify(
ctx.attestation_domain,
attestation,
&indexer,
&allocation,
&deterministic_query,
&response.payload.body,
);
// We send the Kafka message directly to avoid passing the request & response payloads
// through the normal reporting path. This is to reduce log bloat.
let response = response.payload.body.to_string();
let payload = serialize_attestation(attestation, indexer, deterministic_query, response);
let payload = serialize_attestation(attestation, allocation, deterministic_query, response);
ctx.kafka_client.send("gateway_attestations", &payload);
if let Err(attestation_verification_err) = verified {
tracing::debug!(%attestation_verification_err);
Expand Down
6 changes: 3 additions & 3 deletions graph-gateway/src/reports.rs
Original file line number Diff line number Diff line change
Expand Up @@ -515,14 +515,14 @@ pub fn indexer_attempt_status_code(result: &Result<ResponsePayload, IndexerError

pub fn serialize_attestation(
attestation: &Attestation,
indexer: Address,
allocation: Address,
request: String,
response: String,
) -> Vec<u8> {
AttestationProtobuf {
request,
response,
indexer: indexer.0 .0.into(),
allocation: allocation.0 .0.into(),
subgraph_deployment: attestation.deployment.0.into(),
request_cid: attestation.request_cid.0.into(),
response_cid: attestation.response_cid.0.into(),
Expand All @@ -539,7 +539,7 @@ pub struct AttestationProtobuf {
response: String,
/// 20 bytes
#[prost(bytes, tag = "3")]
indexer: Vec<u8>,
allocation: Vec<u8>,
/// 32 bytes
#[prost(bytes, tag = "4")]
subgraph_deployment: Vec<u8>,
Expand Down

0 comments on commit 6df8180

Please sign in to comment.