relayscan icon indicating copy to clipboard operation
relayscan copied to clipboard

Improve builder profit estimation by taking bid adjustments into account

Open ababino opened this issue 1 year ago • 1 comments

📝 Summary

  1. Added a new script cmd/core/bid-adjustments-backfill.go to fetch bid adjustments from ultrasound relay.
  2. Amended builder profit query in GetBuilderProfits in database/database.go. Now, if the slot is a bid-adjusted-slot, the query will subtract the validator profit from coinbase_diff.

⛱ Motivation and Context

Builder profit is not accurate when bids are adjusted by ultrasound relay.


✅ I have run these commands

  • [x] make lint
  • [x] make test
  • [x] go mod tidy

ababino avatar Oct 08 '24 20:10 ababino

@metachris I made some changes:

  1. I optimized the new query by adding a better index
  2. I added a backfill_adjustments script
  3. I added the new commands to the README file

Regarding the performance of the new query, I ran it with 1 day of data, and these are the stats (I used EXPLAIN ANALYZE): Old query: Execution Time: 27.580 ms Peak Memory Usage: 913kB

New query: Execution Time: 59.042 ms Peak Memory Usage: 1681kB

So, we are talking about 2x slower and 2x more memory. I don't know what our hardware requirements are. If we need more performance, we'd have to change the way we store the data, so we move the computation from query time to data fetching time.

Let me know how we should proceed.

ababino avatar Oct 25 '24 14:10 ababino