Skip to content

Commit 578b7d4

Browse files
committed
feat(dips): enhance logging with agreement ID in DIPs processing
Signed-off-by: Lorenzo Delgado <[email protected]>
1 parent 0abcb89 commit 578b7d4

File tree

2 files changed

+47
-4
lines changed

2 files changed

+47
-4
lines changed

crates/dips/src/lib.rs

Lines changed: 45 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -325,6 +325,9 @@ pub async fn validate_and_create_agreement(
325325

326326
decoded_voucher.validate(signer_validator, domain, expected_payee, allowed_payers)?;
327327

328+
// Extract and parse the agreement ID from the voucher
329+
let agreement_id = Uuid::from_bytes(decoded_voucher.voucher.agreement_id.into());
330+
328331
let manifest = ipfs_fetcher.fetch(&metadata.subgraphDeploymentId).await?;
329332

330333
let network = match registry.get_network_by_id(&metadata.chainId) {
@@ -337,7 +340,9 @@ pub async fn validate_and_create_agreement(
337340

338341
match manifest.network() {
339342
Some(manifest_network_name) => {
340-
tracing::debug!("Subgraph manifest network: {}", manifest_network_name);
343+
tracing::debug!(
344+
agreement_id = %agreement_id,
345+
"Subgraph manifest network: {}", manifest_network_name);
341346
if manifest_network_name != network {
342347
return Err(DipsError::InvalidSubgraphManifest(
343348
metadata.subgraphDeploymentId,
@@ -354,28 +359,64 @@ pub async fn validate_and_create_agreement(
354359
let offered_epoch_price = metadata.basePricePerEpoch;
355360
match price_calculator.get_minimum_price(&metadata.chainId) {
356361
Some(price) if offered_epoch_price.lt(&Uint::from(price)) => {
362+
tracing::debug!(
363+
agreement_id = %agreement_id,
364+
chain_id = %metadata.chainId,
365+
deployment_id = %metadata.subgraphDeploymentId,
366+
"offered epoch price '{}' is lower than minimum price '{}'",
367+
offered_epoch_price,
368+
price
369+
);
357370
return Err(DipsError::PricePerEpochTooLow(
358371
network,
359372
price,
360373
offered_epoch_price.to_string(),
361-
))
374+
));
362375
}
363376
Some(_) => {}
364-
None => return Err(DipsError::UnsupportedChainId(metadata.chainId)),
377+
None => {
378+
tracing::debug!(
379+
agreement_id = %agreement_id,
380+
chain_id = %metadata.chainId,
381+
deployment_id = %metadata.subgraphDeploymentId,
382+
"chain id '{}' is not supported",
383+
metadata.chainId
384+
);
385+
return Err(DipsError::UnsupportedChainId(metadata.chainId));
386+
}
365387
}
366388

367389
let offered_entity_price = metadata.pricePerEntity;
368390
if offered_entity_price < price_calculator.entity_price() {
391+
tracing::debug!(
392+
agreement_id = %agreement_id,
393+
chain_id = %metadata.chainId,
394+
deployment_id = %metadata.subgraphDeploymentId,
395+
"offered entity price '{}' is lower than minimum price '{}'",
396+
offered_entity_price,
397+
price_calculator.entity_price()
398+
);
369399
return Err(DipsError::PricePerEntityTooLow(
370400
network,
371401
price_calculator.entity_price(),
372402
offered_entity_price.to_string(),
373403
));
374404
}
375405

406+
tracing::debug!(
407+
agreement_id = %agreement_id,
408+
chain_id = %metadata.chainId,
409+
deployment_id = %metadata.subgraphDeploymentId,
410+
"creating agreement"
411+
);
412+
376413
store
377414
.create_agreement(decoded_voucher.clone(), metadata)
378-
.await?;
415+
.await
416+
.map_err(|error| {
417+
tracing::error!(%agreement_id, %error, "failed to create agreement");
418+
error
419+
})?;
379420

380421
Ok(Uuid::from_bytes(
381422
decoded_voucher.voucher.agreement_id.into(),

crates/monitor/src/escrow_accounts.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,8 @@ async fn get_escrow_accounts_v1(
144144

145145
let response = response?;
146146

147+
tracing::trace!("Escrow accounts response: {:?}", response);
148+
147149
let senders_balances: HashMap<Address, U256> = response
148150
.escrow_accounts
149151
.iter()

0 commit comments

Comments
 (0)