@@ -550,9 +550,10 @@ func (api *RelayAPI) startValidatorRegistrationDBProcessor() {
550550}
551551
552552// simulateBlock sends a request for a block simulation to blockSimRateLimiter.
553- func (api * RelayAPI ) simulateBlock (ctx context.Context , opts blockSimOptions ) (requestErr , validationErr error ) {
553+ func (api * RelayAPI ) simulateBlock (ctx context.Context , opts blockSimOptions ) (overrides * common. BuilderBlockValidationResponseV2 , requestErr , validationErr error ) {
554554 t := time .Now ()
555- requestErr , validationErr = api .blockSimRateLimiter .Send (ctx , opts .req , opts .isHighPrio , opts .fastTrack )
555+ overrides , requestErr , validationErr = api .blockSimRateLimiter .Send (ctx , opts .req , opts .isHighPrio , opts .fastTrack )
556+
556557 log := opts .log .WithFields (logrus.Fields {
557558 "durationMs" : time .Since (t ).Milliseconds (),
558559 "numWaiting" : api .blockSimRateLimiter .CurrentCounter (),
@@ -563,18 +564,18 @@ func (api *RelayAPI) simulateBlock(ctx context.Context, opts blockSimOptions) (r
563564 ignoreError := validationErr .Error () == ErrBlockAlreadyKnown || validationErr .Error () == ErrBlockRequiresReorg || strings .Contains (validationErr .Error (), ErrMissingTrieNode )
564565 if ignoreError {
565566 log .WithError (validationErr ).Warn ("block validation failed with ignorable error" )
566- return nil , nil
567+ return nil , nil , nil
567568 }
568569 }
569570 log .WithError (validationErr ).Warn ("block validation failed" )
570- return nil , validationErr
571+ return nil , nil , validationErr
571572 }
572573 if requestErr != nil {
573574 log .WithError (requestErr ).Warn ("block validation failed: request error" )
574- return requestErr , nil
575+ return nil , requestErr , nil
575576 }
576577 log .Info ("block validation successful" )
577- return nil , nil
578+ return overrides , nil , nil
578579}
579580
580581func (api * RelayAPI ) demoteBuilder (pubkey string , req * common.BuilderSubmitBlockRequest , simError error ) {
@@ -620,7 +621,13 @@ func (api *RelayAPI) processOptimisticBlock(opts blockSimOptions, simResultC cha
620621 // it for logging, it is not atomic to avoid the performance impact.
621622 "optBlocksInFlight" : api .optimisticBlocksInFlight ,
622623 }).Infof ("simulating optimistic block with hash: %v" , opts .req .BuilderSubmitBlockRequest .BlockHash ())
623- reqErr , simErr := api .simulateBlock (ctx , opts )
624+ overrides , reqErr , simErr := api .simulateBlock (ctx , opts )
625+
626+ overrideGasValues (
627+ opts .req ,
628+ overrides ,
629+ )
630+
624631 simResultC <- & blockSimResult {reqErr == nil , true , reqErr , simErr }
625632 if reqErr != nil || simErr != nil {
626633 // Mark builder as non-optimistic.
@@ -1785,13 +1792,6 @@ func (api *RelayAPI) handleSubmitNewBlock(w http.ResponseWriter, req *http.Reque
17851792 }
17861793 }
17871794
1788- // Refuse blocks outside the specified gas limit
1789- if payload .Capella .ExecutionPayload .GasLimit > RelayActualGasLimit {
1790- return
1791- }
1792- // Overwrite the builder's gasLimit with the relay-set fictitious limit
1793- payload .Capella .ExecutionPayload .GasLimit = RelayFictitiousGasLimit
1794-
17951795 nextTime = time .Now ().UTC ()
17961796 pf .Decode = uint64 (nextTime .Sub (prevTime ).Microseconds ())
17971797 prevTime = nextTime
@@ -1964,7 +1964,13 @@ func (api *RelayAPI) handleSubmitNewBlock(w http.ResponseWriter, req *http.Reque
19641964 go api .processOptimisticBlock (opts , simResultC )
19651965 } else {
19661966 // Simulate block (synchronously).
1967- requestErr , validationErr := api .simulateBlock (context .Background (), opts ) // success/error logging happens inside
1967+ overrides , requestErr , validationErr := api .simulateBlock (context .Background (), opts ) // success/error logging happens inside
1968+
1969+ overrideGasValues (
1970+ opts .req ,
1971+ overrides ,
1972+ )
1973+
19681974 simResultC <- & blockSimResult {requestErr == nil , false , requestErr , validationErr }
19691975 validationDurationMs := time .Since (timeBeforeValidation ).Milliseconds ()
19701976 log = log .WithFields (logrus.Fields {
@@ -2375,3 +2381,13 @@ func (api *RelayAPI) handleReadyz(w http.ResponseWriter, req *http.Request) {
23752381 api .RespondMsg (w , http .StatusServiceUnavailable , "not ready" )
23762382 }
23772383}
2384+
2385+ func overrideGasValues (
2386+ req * common.BuilderBlockValidationRequest ,
2387+ overrides * common.BuilderBlockValidationResponseV2 ,
2388+ ) {
2389+ if overrides != nil {
2390+ req .Capella .ExecutionPayload .BlockHash = overrides .NewBlockHash
2391+ req .Capella .ExecutionPayload .GasLimit = overrides .NewGasLimit
2392+ }
2393+ }
0 commit comments