Skip to content

Commit 3df591f

Browse files
Revert "Merge pull request #922 from IABTechLab/trace-auction-winners-to-creatives"
This reverts commit 58706b4, reversing changes made to 96fec88.
1 parent 78bb93e commit 3df591f

15 files changed

Lines changed: 8 additions & 816 deletions

File tree

crates/trusted-server-core/src/auction/formats.rs

Lines changed: 0 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ use url::Url;
1414
use uuid::Uuid;
1515

1616
use crate::auction::context::ContextValue;
17-
use crate::auction::types::adm_trace_hash;
1817
use crate::consent::ConsentContext;
1918
use crate::constants::{HEADER_X_TS_EC_CONSENT, HEADER_X_TS_EIDS, HEADER_X_TS_EIDS_TRUNCATED};
2019
use crate::creative;
@@ -342,39 +341,6 @@ pub fn convert_to_openrtb_response(
342341
}));
343342
};
344343

345-
// Trace hash over the exact markup delivered to the client (post
346-
// sanitize/rewrite) so the client can stamp the rendered creative with
347-
// a value that matches this response byte-for-byte. Logged at info so
348-
// server logs join against the DOM markers without debug logging.
349-
let adm_hash = adm
350-
.as_deref()
351-
.filter(|markup| !markup.is_empty())
352-
.map(adm_trace_hash);
353-
if let Some(ref hash) = adm_hash {
354-
log::info!(
355-
"auction delivered creative: auction_id={} slot_id={} bidder={} crid={:?} adm_hash={}",
356-
auction_request.id,
357-
slot_id,
358-
bid.bidder,
359-
bid.creative_id,
360-
hash,
361-
);
362-
}
363-
let mut ts_ext = serde_json::Map::new();
364-
ts_ext.insert(
365-
"auction_id".to_string(),
366-
serde_json::Value::String(auction_request.id.clone()),
367-
);
368-
if let Some(ref hash) = adm_hash {
369-
ts_ext.insert(
370-
"adm_hash".to_string(),
371-
serde_json::Value::String(hash.clone()),
372-
);
373-
}
374-
let mut ext = ext.unwrap_or_default();
375-
ext.insert("ts".to_string(), JsonValue::Object(ts_ext));
376-
let ext = Some(ext);
377-
378344
let openrtb_bid = OpenRtbBid {
379345
id: bid
380346
.bid_id

crates/trusted-server-core/src/auction/mod.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ pub use telemetry::{
3535
};
3636
pub use types::{
3737
AdFormat, AuctionContext, AuctionRequest, AuctionResponse, Bid, BidStatus, MediaType,
38-
adm_trace_hash,
3938
};
4039

4140
/// Type alias for provider builder functions.

crates/trusted-server-core/src/auction/orchestrator.rs

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -166,29 +166,6 @@ fn remaining_budget_ms(start: Instant, timeout_ms: u32) -> u32 {
166166
timeout_ms.saturating_sub(elapsed)
167167
}
168168

169-
/// Log one structured trace line per winning bid.
170-
///
171-
/// Emits the full trace tuple — auction ID, slot, bidder, ad/cache/creative
172-
/// IDs, and the creative trace hash — so a rendered creative on the page
173-
/// (carrying the same tuple in its DOM markers) can be joined back to this
174-
/// auction in server logs.
175-
fn log_winning_bids(auction_id: &str, winning_bids: &HashMap<String, Bid>) {
176-
for (slot_id, bid) in winning_bids {
177-
log::info!(
178-
"auction winner: auction_id={} slot_id={} bidder={} price={:?} bid_id={:?} ad_id={:?} cache_id={:?} crid={:?} adm_hash={:?}",
179-
auction_id,
180-
slot_id,
181-
bid.bidder,
182-
bid.price,
183-
bid.bid_id,
184-
bid.ad_id,
185-
bid.cache_id,
186-
bid.creative_id,
187-
bid.creative_trace_hash(),
188-
);
189-
}
190-
}
191-
192169
fn snapshot_context_request(request: &Request<EdgeBody>) -> Request<EdgeBody> {
193170
let mut snapshot = Request::new(EdgeBody::empty());
194171
*snapshot.method_mut() = request.method().clone();
@@ -303,8 +280,6 @@ impl AuctionOrchestrator {
303280
strategy_name
304281
);
305282

306-
log_winning_bids(&request.id, &result.winning_bids);
307-
308283
Ok(OrchestrationResult {
309284
total_time_ms: start_time.elapsed().as_millis() as u64,
310285
..result
@@ -1325,7 +1300,6 @@ impl AuctionOrchestrator {
13251300
responses.len(),
13261301
);
13271302
let winning = self.select_winning_bids(&responses, &floor_prices);
1328-
log_winning_bids(&request.id, &winning);
13291303
return OrchestrationResult {
13301304
provider_responses: responses,
13311305
mediator_response: None,
@@ -1443,8 +1417,6 @@ impl AuctionOrchestrator {
14431417
(None, self.select_winning_bids(&responses, &floor_prices))
14441418
};
14451419

1446-
log_winning_bids(&request.id, &winning_bids);
1447-
14481420
OrchestrationResult {
14491421
provider_responses: responses,
14501422
mediator_response,

crates/trusted-server-core/src/auction/types.rs

Lines changed: 0 additions & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -313,49 +313,6 @@ impl From<&AuctionResponse> for ProviderSummary {
313313
}
314314
}
315315

316-
/// Length of the hex-encoded creative trace hash.
317-
///
318-
/// 16 hex chars (64 bits of SHA-256) — short enough for a DOM attribute and a
319-
/// log field, long enough that collisions across a page's creatives are not a
320-
/// practical concern for tracing.
321-
const ADM_TRACE_HASH_LEN: usize = 16;
322-
323-
/// Compute the trace hash for a creative markup string.
324-
///
325-
/// The hash is the first [`ADM_TRACE_HASH_LEN`] hex characters of the SHA-256
326-
/// of the exact bytes handed to the client. It is a correlation key for
327-
/// tracing a winning bid to the creative rendered on the page — server logs,
328-
/// the injected bid payload, and DOM markers all carry the same value — not an
329-
/// integrity mechanism.
330-
///
331-
/// # Examples
332-
///
333-
/// ```
334-
/// use trusted_server_core::auction::adm_trace_hash;
335-
///
336-
/// let hash = adm_trace_hash("<div>example creative</div>");
337-
/// assert_eq!(hash.len(), 16);
338-
/// ```
339-
#[must_use]
340-
pub fn adm_trace_hash(adm: &str) -> String {
341-
use sha2::{Digest as _, Sha256};
342-
343-
let digest = Sha256::digest(adm.as_bytes());
344-
let mut hex = hex::encode(digest);
345-
hex.truncate(ADM_TRACE_HASH_LEN);
346-
hex
347-
}
348-
349-
impl Bid {
350-
/// Trace hash of this bid's creative markup, when present.
351-
///
352-
/// See [`adm_trace_hash`] for the hash definition.
353-
#[must_use]
354-
pub fn creative_trace_hash(&self) -> Option<String> {
355-
self.creative.as_deref().map(adm_trace_hash)
356-
}
357-
}
358-
359316
/// `OpenRTB` response metadata for the orchestrator.
360317
#[derive(Debug, Clone, Serialize, Deserialize)]
361318
pub struct OrchestratorExt {
@@ -451,42 +408,6 @@ mod tests {
451408
}
452409
}
453410

454-
#[test]
455-
fn adm_trace_hash_is_sha256_prefix() {
456-
// SHA-256("abc") = ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad
457-
assert_eq!(
458-
adm_trace_hash("abc"),
459-
"ba7816bf8f01cfea",
460-
"should be the first 16 hex chars of the SHA-256 digest"
461-
);
462-
}
463-
464-
#[test]
465-
fn adm_trace_hash_distinguishes_creatives() {
466-
assert_ne!(
467-
adm_trace_hash("<div>creative a</div>"),
468-
adm_trace_hash("<div>creative b</div>"),
469-
"should produce different hashes for different markup"
470-
);
471-
}
472-
473-
#[test]
474-
fn creative_trace_hash_follows_creative_presence() {
475-
let mut bid = make_bid("kargo");
476-
assert_eq!(
477-
bid.creative_trace_hash(),
478-
None,
479-
"should be None without creative markup"
480-
);
481-
482-
bid.creative = Some("<div>example creative</div>".to_owned());
483-
assert_eq!(
484-
bid.creative_trace_hash(),
485-
Some(adm_trace_hash("<div>example creative</div>")),
486-
"should hash the creative markup when present"
487-
);
488-
}
489-
490411
#[test]
491412
fn provider_summary_from_successful_response() {
492413
let response = AuctionResponse::success(

crates/trusted-server-core/src/integrations/prebid.rs

Lines changed: 0 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -6844,49 +6844,6 @@ set = { networkId = 42 }
68446844
);
68456845
}
68466846

6847-
#[test]
6848-
fn parse_bid_extracts_crid() {
6849-
let bid_json = serde_json::json!({
6850-
"id": "bid-id-321",
6851-
"impid": "atf_sidebar_ad",
6852-
"price": 1.25,
6853-
"adm": "<div>ad</div>",
6854-
"crid": "cr-98765",
6855-
"w": 300,
6856-
"h": 250
6857-
});
6858-
let provider = PrebidAuctionProvider::new(base_config());
6859-
let bid = provider
6860-
.parse_bid(&bid_json, "kargo")
6861-
.expect("should parse bid");
6862-
assert_eq!(
6863-
bid.creative_id.as_deref(),
6864-
Some("cr-98765"),
6865-
"should extract the OpenRTB creative ID"
6866-
);
6867-
assert_eq!(
6868-
bid.bid_id.as_deref(),
6869-
Some("bid-id-321"),
6870-
"should extract the OpenRTB bid ID"
6871-
);
6872-
}
6873-
6874-
#[test]
6875-
fn parse_bid_sets_crid_to_none_when_absent() {
6876-
let bid_json = serde_json::json!({
6877-
"id": "bid-id-322",
6878-
"impid": "atf_sidebar_ad",
6879-
"price": 1.25,
6880-
"w": 300,
6881-
"h": 250
6882-
});
6883-
let provider = PrebidAuctionProvider::new(base_config());
6884-
let bid = provider
6885-
.parse_bid(&bid_json, "kargo")
6886-
.expect("should parse bid");
6887-
assert!(bid.creative_id.is_none(), "should be None when crid absent");
6888-
}
6889-
68906847
#[test]
68916848
fn parse_bid_sets_cache_fields_to_none_when_no_cache_entry() {
68926849
let bid_json = serde_json::json!({

0 commit comments

Comments
 (0)