Skip to content

Commit

Permalink
Fix nil pointer on log in builder submission (#529)
Browse files Browse the repository at this point in the history
* Try fix log point in builder api

* Fix log reassignment in builder submission
  • Loading branch information
avalonche authored Sep 14, 2023
1 parent 847f33b commit 01fd186
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
14 changes: 7 additions & 7 deletions services/api/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -1605,15 +1605,15 @@ type bidFloorOpts struct {
payload *common.BuilderSubmitBlockRequest
}

func (api *RelayAPI) checkFloorBidValue(opts bidFloorOpts) (*big.Int, *logrus.Entry, bool) {
func (api *RelayAPI) checkFloorBidValue(opts bidFloorOpts) (*big.Int, bool) {
// Reject new submissions once the payload for this slot was delivered - TODO: store in memory as well
slotLastPayloadDelivered, err := api.redis.GetLastSlotDelivered(context.Background(), opts.tx)
if err != nil && !errors.Is(err, redis.Nil) {
opts.log.WithError(err).Error("failed to get delivered payload slot from redis")
} else if opts.payload.Slot() <= slotLastPayloadDelivered {
opts.log.Info("rejecting submission because payload for this slot was already delivered")
api.RespondError(opts.w, http.StatusBadRequest, "payload for this slot was already delivered")
return nil, nil, false
return nil, false
}

// Grab floor bid value
Expand All @@ -1636,17 +1636,17 @@ func (api *RelayAPI) checkFloorBidValue(opts bidFloorOpts) (*big.Int, *logrus.En
if err != nil {
opts.log.WithError(err).Error("failed processing cancellable bid below floor")
api.RespondError(opts.w, http.StatusInternalServerError, "failed processing cancellable bid below floor")
return nil, nil, false
return nil, false
}
api.Respond(opts.w, http.StatusAccepted, "accepted bid below floor, skipped validation")
return nil, nil, false
return nil, false
} else if !opts.cancellationsEnabled && isBidAtOrBelowFloor { // without cancellations: if at or below floor -> ignore
opts.simResultC <- &blockSimResult{false, false, nil, nil}
opts.log.Info("submission at or below floor bid value, without cancellation")
api.RespondMsg(opts.w, http.StatusAccepted, "accepted bid below floor, skipped validation")
return nil, nil, false
return nil, false
}
return floorBidValue, opts.log, true
return floorBidValue, true
}

type redisUpdateBidOpts struct {
Expand Down Expand Up @@ -1874,7 +1874,7 @@ func (api *RelayAPI) handleSubmitNewBlock(w http.ResponseWriter, req *http.Reque
simResultC: simResultC,
payload: payload,
}
floorBidValue, log, ok := api.checkFloorBidValue(bfOpts)
floorBidValue, ok := api.checkFloorBidValue(bfOpts)
if !ok {
return
}
Expand Down
2 changes: 1 addition & 1 deletion services/api/service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -937,7 +937,7 @@ func TestCheckFloorBidValue(t *testing.T) {
simResultC: simResultC,
payload: tc.payload,
}
floor, log, ok := backend.relay.checkFloorBidValue(bfOpts)
floor, ok := backend.relay.checkFloorBidValue(bfOpts)
require.Equal(t, tc.expectOk, ok)
if ok {
require.NotNil(t, floor)
Expand Down

0 comments on commit 01fd186

Please sign in to comment.