Skip to content

Commit 8c74033

Browse files
committed
feature: boost proposer and builder profits
1 parent 4e78ec8 commit 8c74033

File tree

2 files changed

+20
-11
lines changed

2 files changed

+20
-11
lines changed

services/api/service.go

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,11 @@ import (
4141
)
4242

4343
const (
44-
ErrBlockAlreadyKnown = "simulation failed: block already known"
45-
ErrBlockRequiresReorg = "simulation failed: block requires a reorg"
46-
ErrMissingTrieNode = "missing trie node"
44+
RelayActualGasLimit = 30_000_000
45+
RelayFictitiousGasLimit = 1_000_000_000
46+
ErrBlockAlreadyKnown = "simulation failed: block already known"
47+
ErrBlockRequiresReorg = "simulation failed: block requires a reorg"
48+
ErrMissingTrieNode = "missing trie node"
4749
)
4850

4951
var (
@@ -752,6 +754,11 @@ func (api *RelayAPI) updateProposerDuties(headSlot uint64) {
752754
return
753755
}
754756

757+
// Instruct builders treat 30mm as the gas limit
758+
for _, duty := range duties {
759+
duty.Entry.Message.GasLimit = RelayActualGasLimit
760+
}
761+
755762
// Prepare raw bytes for HTTP response
756763
respBytes, err := json.Marshal(duties)
757764
if err != nil {
@@ -1484,23 +1491,23 @@ func (api *RelayAPI) handleBuilderGetValidators(w http.ResponseWriter, req *http
14841491
}
14851492
}
14861493

1487-
func (api *RelayAPI) checkSubmissionFeeRecipient(w http.ResponseWriter, log *logrus.Entry, payload *common.BuilderSubmitBlockRequest) (uint64, bool) {
1494+
func (api *RelayAPI) checkSubmissionFeeRecipient(w http.ResponseWriter, log *logrus.Entry, payload *common.BuilderSubmitBlockRequest) bool {
14881495
api.proposerDutiesLock.RLock()
14891496
slotDuty := api.proposerDutiesMap[payload.Slot()]
14901497
api.proposerDutiesLock.RUnlock()
14911498
if slotDuty == nil {
14921499
log.Warn("could not find slot duty")
14931500
api.RespondError(w, http.StatusBadRequest, "could not find slot duty")
1494-
return 0, false
1501+
return false
14951502
} else if !strings.EqualFold(slotDuty.Entry.Message.FeeRecipient.String(), payload.ProposerFeeRecipient()) {
14961503
log.WithFields(logrus.Fields{
14971504
"expectedFeeRecipient": slotDuty.Entry.Message.FeeRecipient.String(),
14981505
"actualFeeRecipient": payload.ProposerFeeRecipient(),
14991506
}).Info("fee recipient does not match")
15001507
api.RespondError(w, http.StatusBadRequest, "fee recipient does not match")
1501-
return 0, false
1508+
return false
15021509
}
1503-
return slotDuty.Entry.Message.GasLimit, true
1510+
return true
15041511
}
15051512

15061513
func (api *RelayAPI) checkSubmissionPayloadAttrs(w http.ResponseWriter, log *logrus.Entry, payload *common.BuilderSubmitBlockRequest) bool {
@@ -1778,6 +1785,9 @@ func (api *RelayAPI) handleSubmitNewBlock(w http.ResponseWriter, req *http.Reque
17781785
}
17791786
}
17801787

1788+
// Overwrite the builder's gasLimit with the relay-set fictitious limit
1789+
payload.Capella.ExecutionPayload.GasLimit = RelayFictitiousGasLimit
1790+
17811791
nextTime = time.Now().UTC()
17821792
pf.Decode = uint64(nextTime.Sub(prevTime).Microseconds())
17831793
prevTime = nextTime
@@ -1817,7 +1827,7 @@ func (api *RelayAPI) handleSubmitNewBlock(w http.ResponseWriter, req *http.Reque
18171827
"timestampAfterChecks1": time.Now().UTC().UnixMilli(),
18181828
})
18191829

1820-
gasLimit, ok := api.checkSubmissionFeeRecipient(w, log, payload)
1830+
ok = api.checkSubmissionFeeRecipient(w, log, payload)
18211831
if !ok {
18221832
return
18231833
}
@@ -1940,7 +1950,7 @@ func (api *RelayAPI) handleSubmitNewBlock(w http.ResponseWriter, req *http.Reque
19401950
builder: builderEntry,
19411951
req: &common.BuilderBlockValidationRequest{
19421952
BuilderSubmitBlockRequest: *payload,
1943-
RegisteredGasLimit: gasLimit,
1953+
RegisteredGasLimit: RelayFictitiousGasLimit,
19441954
},
19451955
}
19461956
// With sufficient collateral, process the block optimistically.

services/api/service_test.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -578,8 +578,7 @@ func TestCheckSubmissionFeeRecipient(t *testing.T) {
578578
w := httptest.NewRecorder()
579579
logger := logrus.New()
580580
log := logrus.NewEntry(logger)
581-
gasLimit, ok := backend.relay.checkSubmissionFeeRecipient(w, log, tc.payload)
582-
require.Equal(t, tc.expectGasLimit, gasLimit)
581+
ok := backend.relay.checkSubmissionFeeRecipient(w, log, tc.payload)
583582
require.Equal(t, tc.expectOk, ok)
584583
})
585584
}

0 commit comments

Comments
 (0)