@@ -1361,6 +1361,38 @@ func (api *RelayAPI) handleGetPayload(w http.ResponseWriter, req *http.Request)
1361
1361
var getPayloadResp * builderApi.VersionedSubmitBlindedBlockResponse
1362
1362
var msNeededForPublishing uint64
1363
1363
1364
+ // Get the response - from Redis, Memcache or DB
1365
+ getPayloadResp , err = api .datastore .GetGetPayloadResponse (log , uint64 (slot ), proposerPubkey .String (), blockHash .String ())
1366
+ if err != nil || getPayloadResp == nil {
1367
+ log .WithError (err ).Warn ("failed getting execution payload (1/2)" )
1368
+ time .Sleep (time .Duration (timeoutGetPayloadRetryMs ) * time .Millisecond )
1369
+
1370
+ // Try again
1371
+ getPayloadResp , err = api .datastore .GetGetPayloadResponse (log , uint64 (slot ), proposerPubkey .String (), blockHash .String ())
1372
+ if err != nil || getPayloadResp == nil {
1373
+ // Still not found! Error out now.
1374
+ if errors .Is (err , datastore .ErrExecutionPayloadNotFound ) {
1375
+ // Couldn't find the execution payload, maybe it never was submitted to our relay! Check that now
1376
+ _ , err := api .db .GetBlockSubmissionEntry (uint64 (slot ), proposerPubkey .String (), blockHash .String ())
1377
+ if errors .Is (err , sql .ErrNoRows ) {
1378
+ log .Warn ("failed getting execution payload (2/2) - payload not found, block was never submitted to this relay" )
1379
+ api .RespondError (w , http .StatusBadRequest , "no execution payload for this request - block was never seen by this relay" )
1380
+ } else if err != nil {
1381
+ log .WithError (err ).Error ("failed getting execution payload (2/2) - payload not found, and error on checking bids" )
1382
+ } else {
1383
+ log .Error ("failed getting execution payload (2/2) - payload not found, but found bid in database" )
1384
+ }
1385
+ } else { // some other error
1386
+ log .WithError (err ).Error ("failed getting execution payload (2/2) - error" )
1387
+ }
1388
+ api .RespondError (w , http .StatusBadRequest , "no execution payload for this request" )
1389
+ return
1390
+ }
1391
+ }
1392
+
1393
+ // Now we know this relay also has the payload
1394
+ log = log .WithField ("timestampAfterLoadResponse" , time .Now ().UTC ().UnixMilli ())
1395
+
1364
1396
// Save information about delivered payload
1365
1397
defer func () {
1366
1398
bidTrace , err := api .redis .GetBidTrace (uint64 (slot ), proposerPubkey .String (), blockHash .String ())
@@ -1442,39 +1474,6 @@ func (api *RelayAPI) handleGetPayload(w http.ResponseWriter, req *http.Request)
1442
1474
}
1443
1475
}()
1444
1476
1445
- // Get the response - from Redis, Memcache or DB
1446
- // note that recent mev-boost versions only send getPayload to relays that provided the bid
1447
- getPayloadResp , err = api .datastore .GetGetPayloadResponse (log , uint64 (slot ), proposerPubkey .String (), blockHash .String ())
1448
- if err != nil || getPayloadResp == nil {
1449
- log .WithError (err ).Warn ("failed getting execution payload (1/2)" )
1450
- time .Sleep (time .Duration (timeoutGetPayloadRetryMs ) * time .Millisecond )
1451
-
1452
- // Try again
1453
- getPayloadResp , err = api .datastore .GetGetPayloadResponse (log , uint64 (slot ), proposerPubkey .String (), blockHash .String ())
1454
- if err != nil || getPayloadResp == nil {
1455
- // Still not found! Error out now.
1456
- if errors .Is (err , datastore .ErrExecutionPayloadNotFound ) {
1457
- // Couldn't find the execution payload, maybe it never was submitted to our relay! Check that now
1458
- _ , err := api .db .GetBlockSubmissionEntry (uint64 (slot ), proposerPubkey .String (), blockHash .String ())
1459
- if errors .Is (err , sql .ErrNoRows ) {
1460
- log .Warn ("failed getting execution payload (2/2) - payload not found, block was never submitted to this relay" )
1461
- api .RespondError (w , http .StatusBadRequest , "no execution payload for this request - block was never seen by this relay" )
1462
- } else if err != nil {
1463
- log .WithError (err ).Error ("failed getting execution payload (2/2) - payload not found, and error on checking bids" )
1464
- } else {
1465
- log .Error ("failed getting execution payload (2/2) - payload not found, but found bid in database" )
1466
- }
1467
- } else { // some other error
1468
- log .WithError (err ).Error ("failed getting execution payload (2/2) - error" )
1469
- }
1470
- api .RespondError (w , http .StatusBadRequest , "no execution payload for this request" )
1471
- return
1472
- }
1473
- }
1474
-
1475
- // Now we know this relay also has the payload
1476
- log = log .WithField ("timestampAfterLoadResponse" , time .Now ().UTC ().UnixMilli ())
1477
-
1478
1477
// Check whether getPayload has already been called -- TODO: do we need to allow multiple submissions of one blinded block?
1479
1478
err = api .redis .CheckAndSetLastSlotAndHashDelivered (uint64 (slot ), blockHash .String ())
1480
1479
log = log .WithField ("timestampAfterAlreadyDeliveredCheck" , time .Now ().UTC ().UnixMilli ())
0 commit comments