-
-
Notifications
You must be signed in to change notification settings - Fork 290
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
Mev/Builder api integration #3969
Conversation
Codecov Report
@@ Coverage Diff @@
## unstable #3969 +/- ##
================================
================================
|
}), | ||
|
||
// At the same time fetch any remaining unknown validator indices, then poll duties for those newIndices only | ||
this.indicesService | ||
.pollValidatorIndices() | ||
.then((newIndices) => this.api.validator.prepareBeaconProposer(this.getProposerData(newIndices))) | ||
.then((newIndices) => this.getProposerData(slot, newIndices)) | ||
.then((proposerData) => this.api.validator.prepareBeaconProposer(proposerData)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
At this point just use an async function instead of a then chain, for consistency with the rest of the codebase
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
modeled changes on the rebased function
thanks @dapplion for looking through ❤️, yes need to refactor as the bn <> boost interaction is now CL api style. will incorporate the feedback once am able to successfully implement the flow 🙂 |
5752b9f
to
ef57bec
Compare
Builder spec was moved to https://github.com/ethereum/builder-specs |
67b6c5d
to
cbefe3d
Compare
Performance Report✔️ no performance regression detected Full benchmark results
|
2e78e09
to
3608f31
Compare
2b2ebfd
to
9e57a7f
Compare
import {toHexString, byteArrayEquals} from "@chainsafe/ssz"; | ||
import {CachedBeaconStateBellatrix} from "../types.js"; | ||
import {getRandaoMix} from "../util/index.js"; | ||
import {ExecutionEngine} from "../util/executionEngine.js"; | ||
import {isMergeTransitionComplete} from "../util/bellatrix.js"; | ||
|
||
export function processExecutionPayload( | ||
export function processExecutionPayload<T extends allForks.BlockType>( | ||
type: T, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If would be nice if we can avoid having to pass this type everywhere
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
changed, now conditioned on the body's execution payload/header inspection of the block 👍
packages/beacon-state-transition/src/block/processExecutionPayload.ts
Outdated
Show resolved
Hide resolved
|
||
private registerValidator = async (epoch: Epoch): Promise<void> => { | ||
if (epoch < this.config.BELLATRIX_FORK_EPOCH - 1) return; | ||
this.getValidatorRegistrations(epoch, this.indicesService.getAllLocalIndices()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why do we have to register all validators for every epoch?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
because a validator registration might only be valid for 2 epochs on the builder, its just simpler to blindly register validator with them every epoch. 🤔
6936a04
to
7bf6a82
Compare
const fullOrBlindedBody = ((block as bellatrix.BlindedBeaconBlock).body ?? | ||
(block as bellatrix.BeaconBlock).body) as allForks.FullOrBlindedBellatrixBeaconBlockBody; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this intended? It looks like without type assertions, this reads like block.body ?? block.body
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good eye @wemeetagain! thanks 🙂
packages/beacon-state-transition/src/block/processBlockHeader.ts
Outdated
Show resolved
Hide resolved
): ISignatureSet { | ||
const {config, epochCtx} = state; | ||
const domain = state.config.getDomain(DOMAIN_BEACON_PROPOSER, signedBlock.message.slot); | ||
|
||
// eslint-disable-next-line @typescript-eslint/strict-boolean-expressions | ||
const blockType = (signedBlock.message as bellatrix.BlindedBeaconBlock).body.executionPayloadHeader | ||
? ssz.bellatrix.BlindedBeaconBlock |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should add the blinded variants to getForkTypes
somehow.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can I pick this in the followup ? Will add this to a followup issue tracker among few others i think.
cddba5f
to
e23a3dd
Compare
* extract builder in its own folder space * fix engine path * rebase fixes * refactor the builder with latest beacon state transtion processing changes * fix the registration signature * make typescript happy * remove the early return * rebase fixes * gas limit option * builder enabling on validator, gaslimit and other refac * fixes * Rebase fixes with the api refac * some cleanup fixes * comment explaining the immediate registration call * use already defined batchItems * serialize the validator registration chunks * validate transactions root on payload response * removing the BlockType from global types and sandboxing it just inside block factory * make builder optional in dev validator setup * option builder with dev val init with keystores * add builder api test routes * fix validator tests * fix block assembly scripts * handle the mergemock customization * fix body extraction * remove linter superession for boolean expressions
e23a3dd
to
d5a128f
Compare
@@ -46,10 +46,18 @@ export function processExecutionPayload( | |||
// if executionEngine is null, executionEngine.onPayload MUST be called after running processBlock to get the | |||
// correct randao mix. Since executionEngine will be an async call in most cases it is called afterwards to keep | |||
// the state transition sync | |||
if (executionEngine && !executionEngine.notifyNewPayload(payload)) { | |||
if ( | |||
(payload as bellatrix.ExecutionPayload).transactions !== undefined && |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unless it looks really annoying this should be a type guard. Like
function isExecutionPayload(
payload: bellatrix.ExecutionPayload | bellatrix.ExecutionPayloadBlinded
): payload is bellatrix.ExecutionPayload {
return (payload as bellatrix.ExecutionPayload).transactions !== undefined
}
if (isExecutionPayload(payload) && !executionEngine.notifyNewPayload(payload as bellatrix.ExecutionPayload)) {
throw Error("Invalid execution payload");
}
throw Error("Invalid execution payload"); | ||
} | ||
|
||
const transactionsRoot = | ||
(payload as bellatrix.ExecutionPayloadHeader).transactionsRoot ?? | ||
ssz.bellatrix.Transactions.hashTreeRoot((payload as bellatrix.ExecutionPayload).transactions); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here, use type guards
): ISignatureSet { | ||
const {config, epochCtx} = state; | ||
const domain = state.config.getDomain(DOMAIN_BEACON_PROPOSER, signedBlock.message.slot); | ||
|
||
const blockType = | ||
(signedBlock.message as bellatrix.BlindedBeaconBlock).body.executionPayloadHeader !== undefined |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use type guards
options?: {verifyStateRoot?: boolean; verifyProposer?: boolean; verifySignatures?: boolean}, | ||
metrics?: IBeaconStateTransitionMetrics | null | ||
): CachedBeaconStateAllForks { | ||
const {verifyStateRoot = true, verifyProposer = true, verifySignatures = true} = options || {}; | ||
|
||
const block = signedBlock.message; | ||
const block = signedBlock.message as allForks.FullOrBlindedBeaconBlock; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this casting necessary? If so why?
return ( | ||
isMergeTransitionComplete(state) || | ||
!ssz.bellatrix.ExecutionPayload.equals(body.executionPayload, ssz.bellatrix.ExecutionPayload.defaultValue()) | ||
((body as bellatrix.BlindedBeaconBlockBody).executionPayloadHeader !== undefined |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use type guards
I think we can have two directories named |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGMT! @g11tech merging so be able to test live, let's keep iterating on it after the fact
Motivation
Reference: https://github.com/ethereum/execution-apis/pull/209/files
Dev TODOs
- [ ] Choice logic to be includedmoving to a followup issue Followup tracker for MeV related pending issues/cleanup #4208Dev Cleanup
builder.enabled
optionTests with mergemock
Tests with the full mev builder
Mergemock/local testnet relay integration with merge-interop
- [ ] path needs to be figured out yet#4208Old work
This PR integrates the builder api and consists broadly of 3 parts:
Json rpc setupIt was decided to implement the api CL styleValidatorRegistrationV1
in beacon proposer api which BN can propagatebuilder_registerValidatorV1
builder_getHeaderV1
in parallel with fetching payload from engine while assembling body to get theExecutionPayloadHeaderV1
and signedBuilderBidV1
BlindedSignedBeaconBlock
and sendbuilder_getPayloadV1
and getExecutionPayloadV1
which can be used be combined with the signedBlindedBeaconBlock
to form SignedBeaconBlock and propogatedCloses #3953
UPDATE: integration/test SUCCESS with
mergemock
!!! 🥳 locally with some caveatsCaveats