relayscan
relayscan copied to clipboard
Improve builder profit estimation by taking bid adjustments into account
📝 Summary
- Added a new script
cmd/core/bid-adjustments-backfill.goto fetch bid adjustments from ultrasound relay. - Amended builder profit query in
GetBuilderProfitsindatabase/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
@metachris I made some changes:
- I optimized the new query by adding a better index
- I added a backfill_adjustments script
- 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.