Skip to content
Open
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
12 changes: 10 additions & 2 deletions src/client_query.rs
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,11 @@ async fn run_indexer_queries(
let start_time = Instant::now();
// URL checked: ref df8e647b-1e6e-422a-8846-dc9ee7e0dcc2
let deployment_url = url.join(&format!("subgraphs/id/{deployment}")).unwrap();
let auth = IndexerAuth::Paid(&receipt, ctx.attestation_domain);
let auth = IndexerAuth::Paid(
&receipt,
ctx.attestation_domain,
ctx.legacy_attestation_domain,
);
let result = indexer_client
.query_indexer(deployment_url, auth, &indexer_query)
.in_current_span()
Expand Down Expand Up @@ -695,7 +699,11 @@ pub async fn handle_indexer_query(
.url
.join(&format!("subgraphs/id/{deployment}"))
.unwrap();
let indexer_auth = IndexerAuth::Paid(&receipt, ctx.attestation_domain);
let indexer_auth = IndexerAuth::Paid(
&receipt,
ctx.attestation_domain,
ctx.legacy_attestation_domain,
);

let indexer_start_time = Instant::now();
let result = ctx
Expand Down
1 change: 1 addition & 0 deletions src/client_query/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,6 @@ pub struct Context {
pub network: NetworkService,
pub indexing_perf: IndexingPerformance,
pub attestation_domain: &'static Eip712Domain,
pub legacy_attestation_domain: &'static Eip712Domain,
pub reporter: mpsc::UnboundedSender<reports::ClientRequest>,
}
1 change: 1 addition & 0 deletions src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ pub enum BlocklistEntry {
pub struct AttestationConfig {
pub chain_id: String,
pub dispute_manager: Address,
pub legacy_dispute_manager: Address,
}

/// The exchange rate provider.
Expand Down
18 changes: 13 additions & 5 deletions src/indexer_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ pub struct IndexerClient {
}

pub enum IndexerAuth<'a> {
Paid(&'a Receipt, &'a Eip712Domain),
Paid(&'a Receipt, &'a Eip712Domain, &'a Eip712Domain),
Free(&'a str),
}

Expand All @@ -47,7 +47,7 @@ impl IndexerClient {
query: &str,
) -> Result<IndexerResponse, IndexerError> {
let (auth_key, auth_value) = match auth {
IndexerAuth::Paid(receipt, _) => ("Tap-Receipt", receipt.serialize()),
IndexerAuth::Paid(receipt, _, _) => ("Tap-Receipt", receipt.serialize()),
IndexerAuth::Free(token) => (AUTHORIZATION.as_str(), format!("Bearer {token}")),
};

Expand Down Expand Up @@ -113,18 +113,26 @@ impl IndexerClient {
return Err(BadResponse(format!("unattestable response: {error}")));
}

if let IndexerAuth::Paid(receipt, attestation_domain) = auth {
if let IndexerAuth::Paid(receipt, attestation_domain, legacy_attestation_domain) = auth {
match &payload.attestation {
Some(attestation) => {
let allocation = receipt.allocation();
if let Err(err) = attestation::verify(
if let Err(legacy_err) = attestation::verify(
legacy_attestation_domain,
attestation,
&allocation,
query,
&original_response,
) && let Err(err) = attestation::verify(
attestation_domain,
attestation,
&allocation,
query,
&original_response,
) {
return Err(BadResponse(format!("bad attestation: {err}")));
return Err(BadResponse(format!(
"bad attestation: {legacy_err} - {err}"
)));
}
}
None => {
Expand Down
10 changes: 10 additions & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,15 @@ async fn main() {
conf.attestations.dispute_manager,
)));

let legacy_attestation_domain: &'static Eip712Domain =
Box::leak(Box::new(attestation::eip712_domain(
conf.attestations
.chain_id
.parse::<ChainId>()
.expect("failed to parse attestation domain chain_id"),
conf.attestations.legacy_dispute_manager,
)));

let indexer_client = IndexerClient {
client: http_client.clone(),
};
Expand Down Expand Up @@ -171,6 +180,7 @@ async fn main() {
indexing_perf,
network,
attestation_domain,
legacy_attestation_domain,
reporter,
};

Expand Down