Skip to content

Commit a7671d3

Browse files
MoonBoi9001claude
andcommitted
feat(dips): add chain_id and structured fields to price rejection logs
Price rejection logs now include chain_id (CAIP-2 identifier) and use structured tracing fields (offered, minimum) instead of format string interpolation. Makes it easier to filter and query rejection events in production log aggregation. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 9a12fb3 commit a7671d3

1 file changed

Lines changed: 17 additions & 8 deletions

File tree

crates/dips/src/lib.rs

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -449,17 +449,25 @@ pub async fn validate_and_create_rca(
449449
return Err(DipsError::UnsupportedNetwork(network_name.to_string()));
450450
}
451451

452+
// Resolve chain ID for logging context
453+
let chain_id = registry
454+
.get_network_by_id(network_name)
455+
.map(|n| n.caip2_id.to_string())
456+
.or_else(|| additional_networks.get(network_name).cloned())
457+
.unwrap_or_else(|| "unknown".to_string());
458+
452459
// Validate price minimums
453460
let offered_tokens_per_second = terms.tokensPerSecond;
454461
match price_calculator.get_minimum_price(network_name) {
455462
Some(price) if offered_tokens_per_second.lt(&Uint::from(price)) => {
456463
tracing::info!(
457464
agreement_id = %agreement_id,
458465
network = %network_name,
466+
chain_id = %chain_id,
459467
deployment_id = %deployment_id,
460-
"offered tokens_per_second '{}' is lower than minimum price '{}'",
461-
offered_tokens_per_second,
462-
price
468+
offered = %offered_tokens_per_second,
469+
minimum = %price,
470+
"tokens_per_second below minimum, rejecting proposal"
463471
);
464472
return Err(DipsError::TokensPerSecondTooLow {
465473
network: network_name.to_string(),
@@ -472,9 +480,9 @@ pub async fn validate_and_create_rca(
472480
tracing::info!(
473481
agreement_id = %agreement_id,
474482
network = %network_name,
483+
chain_id = %chain_id,
475484
deployment_id = %deployment_id,
476-
"network '{}' is not configured in price calculator",
477-
network_name
485+
"network not configured in price calculator, rejecting proposal"
478486
);
479487
return Err(DipsError::UnsupportedNetwork(network_name.to_string()));
480488
}
@@ -486,10 +494,11 @@ pub async fn validate_and_create_rca(
486494
tracing::info!(
487495
agreement_id = %agreement_id,
488496
network = %network_name,
497+
chain_id = %chain_id,
489498
deployment_id = %deployment_id,
490-
"offered tokens_per_entity_per_second '{}' is lower than minimum price '{}'",
491-
offered_entity_price,
492-
price_calculator.entity_price()
499+
offered = %offered_entity_price,
500+
minimum = %price_calculator.entity_price(),
501+
"tokens_per_entity_per_second below minimum, rejecting proposal"
493502
);
494503
return Err(DipsError::TokensPerEntityPerSecondTooLow {
495504
minimum: price_calculator.entity_price(),

0 commit comments

Comments
 (0)