From 01fd186598602c1743a90cba8ef2a8621a81d7b9 Mon Sep 17 00:00:00 2001 From: shana Date: Thu, 14 Sep 2023 12:58:47 -0700 Subject: [PATCH] Fix nil pointer on log in builder submission (#529) * Try fix log point in builder api * Fix log reassignment in builder submission --- services/api/service.go | 14 +++++++------- services/api/service_test.go | 2 +- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/services/api/service.go b/services/api/service.go index d6d5552a..084497fb 100644 --- a/services/api/service.go +++ b/services/api/service.go @@ -1605,7 +1605,7 @@ 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) { @@ -1613,7 +1613,7 @@ func (api *RelayAPI) checkFloorBidValue(opts bidFloorOpts) (*big.Int, *logrus.En } 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 @@ -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 { @@ -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 } diff --git a/services/api/service_test.go b/services/api/service_test.go index 240f08f3..a993ec69 100644 --- a/services/api/service_test.go +++ b/services/api/service_test.go @@ -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)