Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions handlers/slot.go
Original file line number Diff line number Diff line change
Expand Up @@ -1531,6 +1531,12 @@ func getSlotPageBids(ctx context.Context, pageData *models.SlotPageBlockData, bl
SeenCount: bid.SeenCount,
SeenTotal: bid.SeenTotal,
}
if bidData.IsSelfBuilt {
fees, ok := getSlotPagePayloadPriorityFees(pageData, bid.BlockHash)
bidData.Value = fees
bidData.TotalValue = fees + bid.ElPayment
bidData.ValueUnknown = !ok
}
bidData.ClassLabel, bidData.ClassColor, bidData.ClassTitle = describeBidClass(bid)
bidData.SeenColor = seenBadgeColor(bid.SeenCount, bid.SeenTotal)
if !bidData.IsSelfBuilt {
Expand All @@ -1552,6 +1558,28 @@ func getSlotPageBids(ctx context.Context, pageData *models.SlotPageBlockData, bl
pageData.BidsCount = uint64(len(pageData.Bids))
}

func getSlotPagePayloadPriorityFees(pageData *models.SlotPageBlockData, blockHash []byte) (uint64, bool) {
if pageData.ExecutionData == nil || !bytes.Equal(pageData.ExecutionData.BlockHash, blockHash) {
return 0, false
}
if len(pageData.Transactions) == 0 {
return 0, true
}
if !pageData.TransactionsIndexed {
return 0, false
}

baseFee := float64(pageData.ExecutionData.BaseFeePerGas) / 1e9
fees := 0.0
for _, tx := range pageData.Transactions {
if !tx.HasElData {
return 0, false
}
fees += float64(tx.GasUsed) * (tx.EffGasPrice - baseFee)
}
return uint64(math.Round(fees)), true
}

// seenBadgeColor derives the badge color for a bid's gossip visibility:
// green = all connected clients saw it, yellow = majority, red = minority.
func seenBadgeColor(seenCount, seenTotal uint32) string {
Expand Down
17 changes: 16 additions & 1 deletion indexer/beacon/indexer_getter.go
Original file line number Diff line number Diff line change
Expand Up @@ -708,10 +708,25 @@ func (indexer *Indexer) GetBlockBidsForSlot(slot phase0.Slot) []*dbtypes.BlockBi
}

for _, bid := range db.GetBidsForSlot(indexer.ctx, uint64(slot)) {
if cached := cachedBids[makeBidCacheKey(bid)]; cached != nil {
key := makeBidCacheKey(bid)
if cached := cachedBids[key]; cached != nil {
mergeBidSeenCounters(cached, bid)
continue
}
cachedBids[key] = bid
bids = append(bids, bid)
}

for _, block := range indexer.blockCache.getBlocksBySlot(slot) {
bid := getBlockBid(block.GetBlock(indexer.ctx))
if bid == nil {
continue
}
key := makeBidCacheKey(bid)
if cachedBids[key] != nil {
continue
}
cachedBids[key] = bid
bids = append(bids, bid)
}

Expand Down
16 changes: 13 additions & 3 deletions templates/slot/bids.html
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,19 @@
</td>
<td>{{ ethAddressLink $bid.FeeRecipient }}</td>
<td>{{ formatAddCommas $bid.GasLimit }}</td>
<td>{{ formatEthFromGwei $bid.Value }}</td>
<td>{{ formatEthFromGwei $bid.ElPayment }}</td>
<td><strong>{{ formatEthFromGwei $bid.TotalValue }}</strong></td>
{{ if $bid.ValueUnknown }}
<td></td>
<td>{{ formatEthFromGwei $bid.ElPayment }}</td>
<td></td>
{{ else if $bid.IsSelfBuilt }}
<td><span data-bs-toggle="tooltip" title="Priority fees paid to the fee recipient by the self-built payload">{{ formatEthFromGwei $bid.Value }}</span></td>
<td>{{ formatEthFromGwei $bid.ElPayment }}</td>
<td><strong>{{ formatEthFromGwei $bid.TotalValue }}</strong></td>
{{ else }}
<td>{{ formatEthFromGwei $bid.Value }}</td>
<td>{{ formatEthFromGwei $bid.ElPayment }}</td>
<td><strong>{{ formatEthFromGwei $bid.TotalValue }}</strong></td>
{{ end }}
{{ if $.Block.HasGossipBids }}
<td>
{{ if $bid.IsSelfBuilt }}
Expand Down
1 change: 1 addition & 0 deletions types/models/slot.go
Original file line number Diff line number Diff line change
Expand Up @@ -439,6 +439,7 @@ type SlotPageBid struct {
BuilderName string `json:"builder_name"`
BuilderURL string `json:"builder_url"`
IsSelfBuilt bool `json:"is_self_built"`
ValueUnknown bool `json:"value_unknown"`
Slot uint64 `json:"slot"`
Value uint64 `json:"value"`
ElPayment uint64 `json:"el_payment"`
Expand Down
Loading