-
-
Notifications
You must be signed in to change notification settings - Fork 291
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
Race building execution and builder block with cutoff #5223
Conversation
Can this be done with somehting like: function allSettledWithTimeout<T>(promises: Promise<T>, timeoutMs: number) {
const timerPromise = new Promise((_resolve, reject) => setTimeout(reject, timeoutMs));
return Promise.allSettled(promises.map((promise) => Promise.race(promise, timerPromise)));
} |
Performance Report✔️ no performance regression detected Full benchmark results
|
problem with this is ( i think) it will force timeout both execution/blinded block at 3 sec for e.g. , but we want to resolve for whoever completes first post cutoff if all promises exceeds cutoff let me see how i can code it up in a cleaner manner |
@@ -1,7 +1,7 @@ | |||
{ | |||
"compilerOptions": { | |||
"target": "es2019", | |||
"lib": ["es2020", "esnext.bigint", "es2020.string", "es2020.symbol.wellknown", "dom"], | |||
"lib": ["es2020", "esnext.bigint", "es2020.string", "es2020.symbol.wellknown", "dom", "es2021.promise"], |
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.
required for Promise.any
@wemeetagain i have updated the racefn using the inbuild primitives, let me know how it looks now |
@@ -11,13 +11,20 @@ import {ValidatorStore, BuilderSelection} from "./validatorStore.js"; | |||
import {BlockDutiesService, GENESIS_SLOT} from "./blockDuties.js"; | |||
|
|||
const ETH_TO_WEI = BigInt("1000000000000000000"); | |||
const BLOCK_PRODUCTION_RACE_CUTOFF_MS = 3_000; | |||
const BLOCK_PRODUCTION_RACE_TIMEOUT_MS = 12_000; |
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.
are these values optimal (or good enough to being with)?
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.
do you know how other CL clients handle this and what cutoff they use?
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.
these values make sense to me
packages/beacon-node/test/scripts/el-interop/mergemock/post-merge.sh
Outdated
Show resolved
Hide resolved
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.
looks really clean and well tested!
precutoff = "precutoff-return", | ||
/** cutoff reached as some were pending till cutoff **/ | ||
cutoff = "cutoff-reached", | ||
/** atleast one resolved till cutoff so no race required */ |
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.
/** atleast one resolved till cutoff so no race required */ | |
/** at least one resolved till cutoff so no race required */ |
return mapStatusesToResponses(promisesStates); | ||
} | ||
|
||
// Post deadline resolve with any of the promise or all rejected before timeout |
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.
deadline is the cutoff here, right?
// Post deadline resolve with any of the promise or all rejected before timeout | |
// Post cutoff resolve with any of the promise or all rejected before timeout |
// or rejected (-ve number) | ||
// Third item in testcase row is the expected value or error message in string | ||
// Last item is expected events | ||
const testcases: [string, number[], (string | Error)[], RaceEvent[]][] = [ |
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.
thanks for a bunch of test cases 👍
🎉 This PR is included in v1.6.0 🎉 |
We have scenarios where builder api responded with block but execution api took forever to resolve causing an avoidable delay in block proposal (and hence orphaned block)
This PR races building execution and builder block with cutoff of 3 seconds post which the race resolves with whoever wins
racePromisesWithCutoff
utilityCloses #5219