Skip to content

Commit

Permalink
refactor: update BidTrace type to BidTraceV2WithBlobFields
Browse files Browse the repository at this point in the history
Update auction API and service methods to use BidTraceV2WithBlobFields instead of BidTraceV2, as blob fields are now passed by the auction.
  • Loading branch information
alextes committed Feb 20, 2025
1 parent 233171f commit 0abbb16
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 9 deletions.
8 changes: 4 additions & 4 deletions datastore/auction_api.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ func (ds *Datastore) RemotePayloadContents(slot uint64, proposerPubkey, blockHas
return getPayloadContents(slot, proposerPubkey, blockHash, ds.remoteAuctionHost, "private", ds.auctionAuthToken, 1*time.Second)
}

func getBidTrace(slot uint64, proposerPubkey, blockHash, auctionHost, basePath, authToken string) (*common.BidTraceV2, error) {
func getBidTrace(slot uint64, proposerPubkey, blockHash, auctionHost, basePath, authToken string) (*common.BidTraceV2WithBlobFields, error) {
client := &http.Client{}

queryParams := url.Values{}
Expand Down Expand Up @@ -118,7 +118,7 @@ func getBidTrace(slot uint64, proposerPubkey, blockHash, auctionHost, basePath,
return nil, errors.Wrap(err, "failed to read bit trace response body")
}

bidtrace := new(common.BidTraceV2)
bidtrace := new(common.BidTraceV2WithBlobFields)
err = json.Unmarshal(body, &bidtrace)
if err != nil {
return nil, err
Expand All @@ -127,10 +127,10 @@ func getBidTrace(slot uint64, proposerPubkey, blockHash, auctionHost, basePath,
return bidtrace, nil
}

func (ds *Datastore) LocalBidTrace(slot uint64, proposerPubkey, blockHash string) (*common.BidTraceV2, error) {
func (ds *Datastore) LocalBidTrace(slot uint64, proposerPubkey, blockHash string) (*common.BidTraceV2WithBlobFields, error) {
return getBidTrace(slot, proposerPubkey, blockHash, ds.localAuctionHost, "internal", "")
}

func (ds *Datastore) RemoteBidTrace(slot uint64, proposerPubkey, blockHash string) (*common.BidTraceV2, error) {
func (ds *Datastore) RemoteBidTrace(slot uint64, proposerPubkey, blockHash string) (*common.BidTraceV2WithBlobFields, error) {
return getBidTrace(slot, proposerPubkey, blockHash, ds.remoteAuctionHost, "private", ds.auctionAuthToken)
}
8 changes: 3 additions & 5 deletions services/api/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -1545,8 +1545,7 @@ func (api *RelayAPI) handleGetPayload(w http.ResponseWriter, req *http.Request)
return
}

convertedBidTrace := common.ConvertToBidTraceV2WithBlobFields(bidTrace)
err = api.db.SaveDeliveredPayload(convertedBidTrace, payload, decodeTime, msNeededForPublishing)
err = api.db.SaveDeliveredPayload(bidTrace, payload, decodeTime, msNeededForPublishing)
if err != nil {
log.WithError(err).WithFields(logrus.Fields{
"bidTrace": bidTrace,
Expand All @@ -1564,8 +1563,7 @@ func (api *RelayAPI) handleGetPayload(w http.ResponseWriter, req *http.Request)
api.optimisticBlocksWG.Wait()

// Check if there is a demotion for the winning block.
convertedBidTrace = common.ConvertToBidTraceV2WithBlobFields(bidTrace)
_, err = api.db.GetBuilderDemotion(convertedBidTrace)
_, err = api.db.GetBuilderDemotion(bidTrace)
// If demotion not found, we are done!
if errors.Is(err, sql.ErrNoRows) {
log.Info("no demotion in getPayload, successful block proposal")
Expand Down Expand Up @@ -1609,7 +1607,7 @@ func (api *RelayAPI) handleGetPayload(w http.ResponseWriter, req *http.Request)
}
}

err = api.db.UpdateBuilderDemotion(convertedBidTrace, signedBeaconBlock, signedRegistration)
err = api.db.UpdateBuilderDemotion(bidTrace, signedBeaconBlock, signedRegistration)
if err != nil {
log.WithFields(logrus.Fields{
"errorWritingRefundToDB": true,
Expand Down

0 comments on commit 0abbb16

Please sign in to comment.