Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feature: boost proposer and builder profits #519

Open
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

prestwich
Copy link

@prestwich prestwich commented Sep 6, 2023

📝 Summary

Boosts proposer and builder profits by adjusting gas limit behavior in the relay api

⛱ Motivation and Context

Proposers and builders lose money that would be paid in fees, because users are forced to burn it via the base fee mechanism. This PR implements a simple Relay-side fix to help recapture these funds

This fix does 2 things:

  • It informs builders that the gas limit is 30,000,000 regardless of validator preferences. It does this by overwriting the API response containing the validator preference.
  • It overwrites the gas limit in builder-submitted blocks to 1_000_000_000 before verification.

These two behaviors will have the following effect:

  • Builders will submit block bids and templates that are valid for the 30mm limit (as current)
  • The actual proposer-signed block will include a limit of 1_000_000_000
  • The high limit, with low actual usage will quickly push down the base fee to near-0
  • This will allow for the formation of a first-price fee auction in the mempool, with proceeds going to the proposers instead of being burned

📚 References

Discussion of motivation


✅ I have run these commands

  • make lint
  • make test-race
  • go mod tidy
  • I have seen and agree to CONTRIBUTING.md

services/api/service.go Outdated Show resolved Hide resolved
return
}
// Overwrite the builder's gasLimit with the relay-set fictitious limit
payload.Capella.ExecutionPayload.GasLimit = RelayFictitiousGasLimit
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

overriding any payload field renders the payload's block hash invalid and the payload simulation would fail on this integrity check. might be missing smth obv here...
https://github.com/flashbots/builder/blob/ca9f4b1ae44aadc6c254e9198ce72d143c19badd/eth/block-validation/api.go#L247-L249

Copy link
Contributor

@rkrasiuk rkrasiuk Sep 6, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also, iiuc, even tho the expected desired gas limit increase will be calculated correctly, the gas limit check will still fail on header verification here
https://github.com/flashbots/builder/blob/ca9f4b1ae44aadc6c254e9198ce72d143c19badd/core/blockchain.go#L2519
since the payload's gas limit is not auto-adjusted during simulation

Copy link
Author

@prestwich prestwich Sep 6, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ya there are 3 changes to be made rn

  • change invocation such that ValidateBlock call utils.CalcGasLimit with the fictitious target
  • Set payload gasLimit to output of utils.CalcGasLimit with the ficititous target
  • Calculate correct hash & override payload header hash

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was hopeful I could do it all in the API layer, however, that would require looking up the parent block. So we'll have to make some changes to the builder backend as well

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

okay new implementation plan:

We require the builder backend to look up the previous blockhash in order to calculate the correct gasLimit given the ficitious registered target. We then require a way to get that info back to the relay API. So we need to return data from the builder's RPC endpoint that currently returns no data. That data is the new gas_limit and blockhash. This output can then used to modify the Builder's payload

So to enumerate changes:

  • modify the ValidateBuilderSubmissionV2 behavior to calculate the correct gasLimit and blockhash before simulating the block
  • modify ValidateBuilderSubmissionV2 to return the modified gasLimit and blockHash
  • modify the relay API to override the builder payload with the returned result before storing it in the bids

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

okay updated 👍

@prestwich
Copy link
Author

This PR relies on the behavior in flashbots/builder#113

@prestwich
Copy link
Author

oh i also need to change the defered database upsert function in the middle to use the overridden payload value. will push that commit later

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants