@@ -1278,6 +1278,38 @@ func (api *RelayAPI) handleGetPayload(w http.ResponseWriter, req *http.Request)
12781278 var getPayloadResp * common.VersionedExecutionPayload
12791279 var msNeededForPublishing uint64
12801280
1281+ // Get the response - from Redis, Memcache or DB
1282+ getPayloadResp , err = api .datastore .GetGetPayloadResponse (log , payload .Slot (), proposerPubkey .String (), payload .BlockHash ())
1283+ if err != nil || getPayloadResp == nil {
1284+ log .WithError (err ).Warn ("failed getting execution payload (1/2)" )
1285+ time .Sleep (time .Duration (timeoutGetPayloadRetryMs ) * time .Millisecond )
1286+
1287+ // Try again
1288+ getPayloadResp , err = api .datastore .GetGetPayloadResponse (log , payload .Slot (), proposerPubkey .String (), payload .BlockHash ())
1289+ if err != nil || getPayloadResp == nil {
1290+ // Still not found! Error out now.
1291+ if errors .Is (err , datastore .ErrExecutionPayloadNotFound ) {
1292+ // Couldn't find the execution payload, maybe it never was submitted to our relay! Check that now
1293+ _ , err := api .db .GetBlockSubmissionEntry (payload .Slot (), proposerPubkey .String (), payload .BlockHash ())
1294+ if errors .Is (err , sql .ErrNoRows ) {
1295+ log .Warn ("failed getting execution payload (2/2) - payload not found, block was never submitted to this relay" )
1296+ api .RespondError (w , http .StatusBadRequest , "no execution payload for this request - block was never seen by this relay" )
1297+ } else if err != nil {
1298+ log .WithError (err ).Error ("failed getting execution payload (2/2) - payload not found, and error on checking bids" )
1299+ } else {
1300+ log .Error ("failed getting execution payload (2/2) - payload not found, but found bid in database" )
1301+ }
1302+ } else { // some other error
1303+ log .WithError (err ).Error ("failed getting execution payload (2/2) - error" )
1304+ }
1305+ api .RespondError (w , http .StatusBadRequest , "no execution payload for this request" )
1306+ return
1307+ }
1308+ }
1309+
1310+ // Now we know this relay also has the payload
1311+ log = log .WithField ("timestampAfterLoadResponse" , time .Now ().UTC ().UnixMilli ())
1312+
12811313 // Save information about delivered payload
12821314 defer func () {
12831315 bidTrace , err := api .redis .GetBidTrace (payload .Slot (), proposerPubkey .String (), payload .BlockHash ())
@@ -1354,39 +1386,6 @@ func (api *RelayAPI) handleGetPayload(w http.ResponseWriter, req *http.Request)
13541386 }
13551387 }()
13561388
1357- // Get the response - from Redis, Memcache or DB
1358- // note that recent mev-boost versions only send getPayload to relays that provided the bid
1359- getPayloadResp , err = api .datastore .GetGetPayloadResponse (log , payload .Slot (), proposerPubkey .String (), payload .BlockHash ())
1360- if err != nil || getPayloadResp == nil {
1361- log .WithError (err ).Warn ("failed getting execution payload (1/2)" )
1362- time .Sleep (time .Duration (timeoutGetPayloadRetryMs ) * time .Millisecond )
1363-
1364- // Try again
1365- getPayloadResp , err = api .datastore .GetGetPayloadResponse (log , payload .Slot (), proposerPubkey .String (), payload .BlockHash ())
1366- if err != nil || getPayloadResp == nil {
1367- // Still not found! Error out now.
1368- if errors .Is (err , datastore .ErrExecutionPayloadNotFound ) {
1369- // Couldn't find the execution payload, maybe it never was submitted to our relay! Check that now
1370- _ , err := api .db .GetBlockSubmissionEntry (payload .Slot (), proposerPubkey .String (), payload .BlockHash ())
1371- if errors .Is (err , sql .ErrNoRows ) {
1372- log .Warn ("failed getting execution payload (2/2) - payload not found, block was never submitted to this relay" )
1373- api .RespondError (w , http .StatusBadRequest , "no execution payload for this request - block was never seen by this relay" )
1374- } else if err != nil {
1375- log .WithError (err ).Error ("failed getting execution payload (2/2) - payload not found, and error on checking bids" )
1376- } else {
1377- log .Error ("failed getting execution payload (2/2) - payload not found, but found bid in database" )
1378- }
1379- } else { // some other error
1380- log .WithError (err ).Error ("failed getting execution payload (2/2) - error" )
1381- }
1382- api .RespondError (w , http .StatusBadRequest , "no execution payload for this request" )
1383- return
1384- }
1385- }
1386-
1387- // Now we know this relay also has the payload
1388- log = log .WithField ("timestampAfterLoadResponse" , time .Now ().UTC ().UnixMilli ())
1389-
13901389 // Check whether getPayload has already been called -- TODO: do we need to allow multiple submissions of one blinded block?
13911390 err = api .redis .CheckAndSetLastSlotAndHashDelivered (payload .Slot (), payload .BlockHash ())
13921391 log = log .WithField ("timestampAfterAlreadyDeliveredCheck" , time .Now ().UTC ().UnixMilli ())
0 commit comments