@@ -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 ( ) ,
0 commit comments