-
-
Notifications
You must be signed in to change notification settings - Fork 474
refactor: use builder boost factor for gloas block production #9807
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
Changes from all commits
8819e9a
800d071
6770dc8
5857625
795a1fd
d86978c
afdb897
8b79473
a3eeb83
fce5625
bc251e5
2413c69
c246e0d
d14910f
5f17284
ad08c8c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -92,7 +92,12 @@ import {getStateResponseWithRegen} from "../beacon/state/utils.js"; | |
| import {ApiError, FailureList, IndexedError, NodeIsSyncing, OnlySupportedByDVT} from "../errors.js"; | ||
| import {ApiModules} from "../types.js"; | ||
| import {notWhileSyncing} from "../utils.js"; | ||
| import {computeSubnetForCommitteesAtSlot, getPubkeysForIndices, selectBlockProductionSource} from "./utils.js"; | ||
| import { | ||
| computeSubnetForCommitteesAtSlot, | ||
| getPubkeysForIndices, | ||
| selectBlockProductionSource, | ||
| selectBlockProductionSourceByBoostFactor, | ||
| } from "./utils.js"; | ||
|
|
||
| /** | ||
| * Cutoff time to wait from start of the slot for execution and builder block production apis to resolve. | ||
|
|
@@ -577,8 +582,7 @@ export function getValidatorApi( | |
| builderSelection, | ||
| isBuilderEnabled, | ||
| strictFeeRecipientCheck, | ||
| // winston logger doesn't like bigint | ||
| builderBoostFactor: `${builderBoostFactor}`, | ||
| builderBoostFactor, | ||
|
matthewkeil marked this conversation as resolved.
|
||
| }; | ||
|
|
||
| logger.verbose("Assembling block with produceEngineOrBuilderBlock", loggerContext); | ||
|
|
@@ -851,8 +855,8 @@ export function getValidatorApi( | |
| randaoReveal, | ||
| graffiti, | ||
| feeRecipient, | ||
| strictFeeRecipientCheck, | ||
| includePayload, | ||
| builderSelection, | ||
| builderBoostFactor, | ||
| }) { | ||
| const fork = config.getForkName(slot); | ||
|
|
@@ -861,11 +865,6 @@ export function getValidatorApi( | |
| throw new ApiError(400, `produceBlockV4 not supported for pre-gloas fork=${fork}`); | ||
| } | ||
|
|
||
| builderSelection = builderSelection ?? routes.validator.BuilderSelection.MaxProfit; | ||
| if (builderSelection === routes.validator.BuilderSelection.BuilderOnly) { | ||
| logger.warn("Builder selection builderonly is no longer supported, treating as builderalways"); | ||
| builderSelection = routes.validator.BuilderSelection.BuilderAlways; | ||
| } | ||
| builderBoostFactor = builderBoostFactor ?? BigInt(100); | ||
| if (builderBoostFactor > MAX_BUILDER_BOOST_FACTOR) { | ||
| throw new ApiError(400, `Invalid builderBoostFactor=${builderBoostFactor} > MAX_BUILDER_BOOST_FACTOR`); | ||
|
|
@@ -896,23 +895,20 @@ export function getValidatorApi( | |
| // TODO GLOAS: add external builder api support when it is implemented | ||
| const isBuildingOnFull = chain.forkChoice.shouldBuildOnFull(parentBlock, slot); | ||
| const bidParentBlockHash = isBuildingOnFull ? parentBlock.executionPayloadBlockHash : parentBlock.parentBlockHash; | ||
| // Bids are only skipped entirely with executiononly or while the circuit breaker is active, | ||
| // other engine-preferring selections still build a block with the best bid as fallback in | ||
| // case local production fails | ||
| const circuitBreakerActive = chain.builderCircuitBreaker.isActive(slot); | ||
| const builderBid = | ||
| builderSelection === routes.validator.BuilderSelection.ExecutionOnly || circuitBreakerActive | ||
| ? null | ||
| : chain.executionPayloadBidPool.getBestBid(slot, bidParentBlockHash, parentBlockRootHex); | ||
| // Keep a builder bid as fallback unless the circuit breaker is active | ||
| const builderBid = circuitBreakerActive | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. could easily keep the
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yes, if we wanna keep |
||
| ? null | ||
|
Comment on lines
+899
to
+901
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. unsure if we should still pick a builder bid even if the circuit breaker is active in case local fails, it's not very likely that local payload production fails but having bid as a fallback could be good still, on the other hand, it could also be that builders are attacking the network with large payloads that are slow to process or equivocations, or other attacks, so not selecting builder bids at all might be a safety feature |
||
| : chain.executionPayloadBidPool.getBestBid(slot, bidParentBlockHash, parentBlockRootHex); | ||
|
|
||
| const logCtx = { | ||
| slot, | ||
| parentSlot, | ||
| parentBlockRoot: parentBlockRootHex, | ||
| parentBlockHash: parentBlock.executionPayloadBlockHash, | ||
| fork, | ||
| builderSelection, | ||
| builderBoostFactor, | ||
| strictFeeRecipientCheck, | ||
| circuitBreakerActive, | ||
| ...(builderBid !== null | ||
| ? { | ||
|
|
@@ -936,6 +932,7 @@ export function getValidatorApi( | |
| randaoReveal, | ||
| graffiti: graffitiBytes, | ||
| feeRecipient, | ||
| strictFeeRecipientCheck, | ||
| commonBlockBodyPromise, | ||
| }; | ||
|
|
||
|
|
@@ -960,12 +957,8 @@ export function getValidatorApi( | |
| chain.produceBlock(baseAttrs) | ||
| ).then((engineBlock) => { | ||
| // No need to wait for the bid block if the engine block will always be selected due to | ||
| // suspected builder censorship, a builder boost factor of 0 or executionalways selection | ||
| if ( | ||
| engineBlock.shouldOverrideBuilder || | ||
| builderBoostFactor === BigInt(0) || | ||
| builderSelection === routes.validator.BuilderSelection.ExecutionAlways | ||
| ) { | ||
| // suspected builder censorship or a builder boost factor of 0 | ||
| if (engineBlock.shouldOverrideBuilder || builderBoostFactor === BigInt(0)) { | ||
| controller.abort(); | ||
| } | ||
| return engineBlock; | ||
|
|
@@ -994,8 +987,7 @@ export function getValidatorApi( | |
| }); | ||
| logger.warn("Selected local block: censorship suspected in builder bid", logCtx); | ||
| } else if (engineResult.status === "fulfilled" && bidResult.status === "fulfilled") { | ||
| const result = selectBlockProductionSource({ | ||
| builderSelection, | ||
| const result = selectBlockProductionSourceByBoostFactor({ | ||
| builderBoostFactor, | ||
| engineExecutionPayloadValue: engineResult.value.executionPayloadValue, | ||
| // The bid value is the payment to the proposer, in Gwei | ||
|
|
@@ -1061,7 +1053,10 @@ export function getValidatorApi( | |
| root: blockRoot, | ||
| }); | ||
| if (chain.opts.persistProducedBlocks) { | ||
| void chain.persistBlock(block, "produced_engine_block"); | ||
| void chain.persistBlock( | ||
| block, | ||
| source === ProducedBlockSource.builder ? "produced_builder_block" : "produced_engine_block" | ||
| ); | ||
| } | ||
|
|
||
| // Include the payload for self-builds unless disabled (stateless flow) | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.