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

adding builder boost factor to get block v3 #13409

Merged
merged 15 commits into from
Jan 4, 2024
Merged

Conversation

james-prysm
Copy link
Contributor

@james-prysm james-prysm commented Jan 3, 2024

What type of PR is this?

Feature

What does this PR do? Why is it needed?

Implements the query parameter builder_boost_factor used for [/eth/v3/validator/blocks/{slot}](https://ethereum.github.io/beacon-APIs/?urls.primaryName=dev#/Validator/produceBlockV3)

description from beacon apis

Percentage multiplier to apply to the builder's payload value when choosing between a builder payload header and payload from the paired execution node. This parameter is only relevant if the beacon node is connected to a builder, deems it safe to produce a builder payload, and receives valid responses from both the builder endpoint and the paired execution node. When these preconditions are met, the server MUST act as follows:

if exec_node_payload_value >= builder_boost_factor * (builder_payload_value // 100), then return a full (unblinded) block containing the execution node payload.
otherwise, return a blinded block containing the builder payload header.
Servers must support the following values of the boost factor which encode common preferences:

builder_boost_factor=0: prefer the execution node payload unless an error makes it unviable.
builder_boost_factor=100: default profit maximization mode; choose whichever payload pays more.
builder_boost_factor=2**64 - 1: prefer the builder payload unless an error or beacon node health check makes it unviable.
Servers should use saturating arithmetic or another technique to ensure that large values of the builder_boost_factor do not trigger overflows or errors. If this parameter is provided and the beacon node is not configured with a builder then the beacon node MUST respond with a full block, which the caller can choose to reject if it wishes. If this parameter is not provided then it should be treated as having the default value of 100. If the value is provided but out of range for a 64-bit unsigned integer, then an error response with status code 400 MUST be returned.

Which issues(s) does this PR fix?

ethereum/beacon-APIs#386, ethereum/beacon-APIs#398

Other notes for review

@james-prysm james-prysm added the API Api related tasks label Jan 3, 2024
@james-prysm james-prysm marked this pull request as ready for review January 3, 2024 17:55
@james-prysm james-prysm requested a review from a team as a code owner January 3, 2024 17:55
@james-prysm james-prysm requested review from kasey, rauljordan, prestonvanloon, potuz and terencechain and removed request for kasey January 3, 2024 17:55
@james-prysm james-prysm added the Ready For Review A pull request ready for code review label Jan 3, 2024
switch trimmed {
case "": // default to 100 if it's not provided
return 100, nil
case "2**64-1":
Copy link
Contributor

Choose a reason for hiding this comment

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

Lol I thought that the user would have to specify explicitly 18446744073709551615

@@ -80,9 +80,9 @@ func setExecutionData(ctx context.Context, blk interfaces.SignedBeaconBlock, loc
}

// Use builder payload if the following in true:
// builder_bid_value * 100 > local_block_value * (local-block-value-boost + 100)
// builder_bid_value * builderBoostFactor(default 100) > local_block_value * (local-block-value-boost + 100)
Copy link
Contributor

@potuz potuz Jan 3, 2024

Choose a reason for hiding this comment

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

Hmmm I don't like this. The point of builderBoostFactor is that it replaces our current parameter local-block-value-boost not to use both... I'm not sure what the right approach is here but at the very least we should log if there's a request and the local boost is set to non-zero and the boost factor to non default

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I added a log for now we'll see if others have an opinion

@james-prysm james-prysm changed the title adding builder boost factor to functions adding builder boost factor to get block v3 Jan 3, 2024
@@ -566,6 +567,9 @@ message BlockRequest {

// Signal server to skip outsourcing block request from mev-boost/relayer so that returned block will always be a local block.
bool skip_mev_boost = 4;

// Percentage multiplier to apply to the builder's payload value when choosing between a builder payload header and payload from the paired execution node
google.protobuf.UInt64Value builder_boost_factor = 5;
Copy link
Contributor

Choose a reason for hiding this comment

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

Wait, why isn't this simply uint64?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I wanted to keep it nullable since 0 is a valid value and we don't have defaults in protobuf3. this way i can check if it was set or not and add a default

}, any)
}

func processBuilderBoostFactor(raw string) (*wrapperspb.UInt64Value, error) {
Copy link
Contributor

Choose a reason for hiding this comment

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

The spec defines the boost factor as Uint64. There is no need for this function, you can just call shared.UintFromQuery

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I need it as nullable, i'll doublecheck sharedUintFromQuery though

@@ -96,7 +97,7 @@ func TestServer_setExecutionData(t *testing.T) {
builderPayload, builderKzgCommitments, err := vs.getBuilderPayloadAndBlobs(ctx, b.Slot(), b.ProposerIndex())
require.NoError(t, err)
require.DeepEqual(t, [][]uint8(nil), builderKzgCommitments)
require.NoError(t, setExecutionData(context.Background(), blk, localPayload, builderPayload, builderKzgCommitments))
require.NoError(t, setExecutionData(context.Background(), blk, localPayload, builderPayload, builderKzgCommitments, 100))
Copy link
Contributor

Choose a reason for hiding this comment

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

Please use the constant default value here and everywhere else

@james-prysm james-prysm enabled auto-merge January 4, 2024 17:18
@james-prysm james-prysm added this pull request to the merge queue Jan 4, 2024
Merged via the queue into develop with commit d439e6d Jan 4, 2024
17 checks passed
@james-prysm james-prysm deleted the builder-boost-factor branch January 4, 2024 17:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
API Api related tasks Ready For Review A pull request ready for code review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants