Skip to content

feat(pbs): Log auction participants with bid value and delta at INFO level - #426

Closed
selfuryon wants to merge 2 commits into
Commit-Boost:mainfrom
selfuryon:chore/auction-logs
Closed

feat(pbs): Log auction participants with bid value and delta at INFO level#426
selfuryon wants to merge 2 commits into
Commit-Boost:mainfrom
selfuryon:chore/auction-logs

Conversation

@selfuryon

Copy link
Copy Markdown
Contributor

We have auction logs in Vouch which I really like. This log shows bid auction and who won it with which value, so I also want to add that type of logs in PBS module too

@selfuryon

Copy link
Copy Markdown
ContributorAuthor

Failed test isn't from my code :)

@selfuryon

Copy link
Copy Markdown
ContributorAuthor

This PR should fix tests: #427

value = %value,
value_eth = format_ether(value),
value_delta = %delta,
selected,

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

An issue is if the max bid is the same across relays there will be multiple logs with selected = true. You can add more logic to set selected but potentially a more efficient approach that avoids pushing the losing GetHeaderResponses to a vec is:

// ....letmut relay_bids:Vec<(&str,U256,B256)> = Vec::with_capacity(relays.len());letmut best_value = U256::ZERO;letmut best_response:Option<GetHeaderResponse> = None;letmut best_relay_id:Option<&str> = None;for(i, res)in results.into_iter().enumerate(){let relay_id = relays[i].id.as_str();match res {Ok(Some(res)) => {let value = *res.data.message.value();let block_hash = res.block_hash();RELAY_LAST_SLOT.with_label_values(&[relay_id]).set(params.slotasi64);let value_gwei = (value / U256::from(1_000_000_000)).try_into().unwrap_or_default();RELAY_HEADER_VALUE.with_label_values(&[relay_id]).set(value_gwei);if best_response.is_none() || value > best_value {
best_value = value;
best_response = Some(res);// move winner here
best_relay_id = Some(relay_id);}else{// buffer small fields for logging
relay_bids.push((relay_id, value, block_hash));}}Ok(_) => {}Err(err)if err.is_timeout() => error!(err = "Timed Out", relay_id),Err(err) => error!(%err, relay_id),}}// Log winner first (if any)ifletSome(winner) = best_response.as_ref(){let relay_id = best_relay_id.unwrap_or("unknown");info!(
relay_id,
value = %best_value,
value_eth = format_ether(best_value),
value_delta = %U256::ZERO,
selected = true,
block_hash = %winner.block_hash(),"Auction participant");}// Log the restfor(relay_id, value, block_hash)in relay_bids {let delta = best_value.saturating_sub(value);info!(
relay_id,
value = %value,
value_eth = format_ether(value),
value_delta = %delta,
selected = false,
block_hash = %block_hash,"Auction participant");}// Return the moved winning responselet max_bid = best_response;Ok(max_bid)

@JasonVranek

Copy link
Copy Markdown
Collaborator

closed by #443

Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

@selfuryon@JasonVranek@jclapis